From 02c0af4bb4b6e1f472e2b57478b3944b5e13d754 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 14 Dec 2021 07:31:39 +0100 Subject: [PATCH] ath10k: use a custom backports package for ath10k based units Fixes: WIFI-6161 Signed-off-by: John Crispin --- ...rnel-backport-napi-threading-patches.patch | 1088 +++++++++++++++ feeds/wifi-ath10k/ath10k-ct-firmware/Makefile | 701 ++++++++++ feeds/wifi-ath10k/ath10k-ct/Makefile | 121 ++ ...64-ath10k-commit-rates-from-mac80211.patch | 37 + ...rolling-support-for-various-chipsets.patch | 598 ++++++++ ...02-ath10k-use-tpt-trigger-by-default.patch | 53 + ...10k-Add-NL80211_EXT_FEATURE_AQL-flag.patch | 10 + ...0-0010-ath10k-limit-htt-rx-ring-size.patch | 14 + ...60-0011-ath10k-limit-pci-buffer-size.patch | 50 + ...cmd_processing_time_for_scan_timeout.patch | 22 + .../patches/970-accumulate-survey-info-data | 11 + .../970-add-survey-local-bss-receive-time | 31 + .../patches/999-ath10k-threading.patch | 14 + feeds/wifi-ath10k/ath10k-firmware/Makefile | 182 +++ feeds/wifi-ath10k/batctl/Makefile | 231 ++++ feeds/wifi-ath10k/batman-adv/Config.in | 110 ++ feeds/wifi-ath10k/batman-adv/Makefile | 91 ++ .../etc/uci-defaults/99-migrate-batadv_hardif | 97 ++ .../files/lib/netifd/proto/batadv.sh | 123 ++ .../files/lib/netifd/proto/batadv_hardif.sh | 49 + .../files/lib/netifd/proto/batadv_vlan.sh | 25 + .../wifi-ath10k/batman-adv/src/compat-hacks.h | 181 +++ feeds/wifi-ath10k/mac80211/Makefile | 544 ++++++++ feeds/wifi-ath10k/mac80211/ath.mk | 310 +++++ feeds/wifi-ath10k/mac80211/ath.mk.orig | 302 ++++ feeds/wifi-ath10k/mac80211/broadcom.mk | 510 +++++++ .../mac80211/files/lib/netifd/mac80211.sh | 36 + .../files/lib/netifd/wireless/mac80211.sh | 1232 +++++++++++++++++ .../mac80211/files/lib/wifi/mac80211.sh | 190 +++ .../mac80211/files/mac80211.hotplug | 5 + feeds/wifi-ath10k/mac80211/intel.mk | 200 +++ feeds/wifi-ath10k/mac80211/marvell.mk | 90 ++ .../patches/ath/070-ath_common_config.patch | 10 + .../ath/080-ath10k_thermal_config.patch | 47 + .../patches/ath/120-owl-loader-compat.patch | 53 + .../201-ath5k-WAR-for-AR71xx-PCI-bug.patch | 38 + ...w-reset-AHB-WMAC-interface-on-AR91xx.patch | 25 + ..._hw-issue-external-reset-for-QCA955x.patch | 129 ++ ...h9k-force-rx_clear-when-disabling-rx.patch | 35 + ...erpret-requested-txpower-in-EIRP-dom.patch | 36 + ...power-reduction-for-US-regulatory-do.patch | 24 + .../patches/ath/400-ath_move_debug_code.patch | 31 + .../patches/ath/401-ath9k_blink_default.patch | 11 + .../patches/ath/402-ath_regd_optional.patch | 92 ++ .../patches/ath/403-world_regd_fixup.patch | 84 ++ .../patches/ath/404-regd_no_assoc_hints.patch | 19 + .../patches/ath/405-ath_regd_us.patch | 26 + .../ath/406-ath_relax_default_regd.patch | 51 + .../ath/410-ath9k_allow_adhoc_and_ap.patch | 10 + .../ath/411-ath5k_allow_adhoc_and_ap.patch | 46 + .../ath/420-ath5k_disable_fast_cc.patch | 18 + .../patches/ath/430-add_ath5k_platform.patch | 33 + ...add_platform_eeprom_support_to_ath5k.patch | 56 + .../patches/ath/432-ath5k_add_pciids.patch | 11 + .../ath/440-ath5k_channel_bw_debugfs.patch | 142 ++ ...abled-MFP-capability-unconditionally.patch | 34 + .../ath/500-ath9k_eeprom_debugfs.patch | 65 + .../patches/ath/501-ath9k_ahb_init.patch | 34 + .../ath/510-ath9k_intr_mitigation_tweak.patch | 18 + .../patches/ath/511-ath9k_reduce_rxbuf.patch | 11 + .../ath/512-ath9k_channelbw_debugfs.patch | 125 ++ .../patches/ath/513-ath9k_add_pci_ids.patch | 30 + .../patches/ath/530-ath9k_extra_leds.patch | 267 ++++ .../ath/531-ath9k_extra_platform_leds.patch | 76 + .../ath/540-ath9k_reduce_ani_interval.patch | 11 + .../patches/ath/542-ath9k_debugfs_diag.patch | 139 ++ .../ath/543-ath9k_entropy_from_adc.patch | 186 +++ ...544-ath9k-ar933x-usb-hang-workaround.patch | 79 ++ .../patches/ath/545-ath9k_ani_ws_detect.patch | 155 +++ .../ath/547-ath9k_led_defstate_fix.patch | 29 + .../ath/548-ath9k_enable_gpio_chip.patch | 251 ++++ .../ath/549-ath9k_enable_gpio_buttons.patch | 143 ++ .../ath/550-ath9k-disable-bands-via-dt.patch | 15 + .../ath/551-ath9k_ubnt_uap_plus_hsr.patch | 418 ++++++ .../mac80211/patches/ath/552-ahb_of.patch | 337 +++++ .../patches/ath/553-ath9k_of_gpio_mask.patch | 25 + ...21-ath10k_init_devices_synchronously.patch | 33 + ...h10k-increase-rx-buffer-size-to-2048.patch | 37 + .../ath/930-ath10k_add_tpt_led_trigger.patch | 37 + ...rolling-support-for-various-chipsets.patch | 609 ++++++++ ...75-ath10k-use-tpt-trigger-by-default.patch | 53 + ...980-ath10k-fix-max-antenna-gain-unit.patch | 49 + ...-power-reduction-for-US-regulatory-d.patch | 101 ++ .../patches/brcm/040-brcmutil_option.patch | 10 + .../810-b43-gpio-mask-module-option.patch | 37 + .../patches/brcm/811-b43_no_pio.patch | 86 ++ .../brcm/812-b43-add-antenna-control.patch | 131 ++ .../813-b43-reduce-number-of-RX-slots.patch | 11 + .../814-b43-only-use-gpio-0-1-for-led.patch | 17 + ...815-b43-always-take-overlapping-devs.patch | 11 + ...-remove-extra-regulation-restriction.patch | 27 + ...-register-wiphy-s-during-module_init.patch | 74 + ...und-bug-with-some-inconsistent-BSSes.patch | 49 + ...62-brcmfmac-Disable-power-management.patch | 27 + ...-in-driver-tables-with-country-codes.patch | 60 + ...e-internal-roaming-engine-by-default.patch | 23 + .../mac80211/patches/brcm/998-survey.patch | 148 ++ .../patches/build/000-fix_kconfig.patch | 14 + .../patches/build/001-fix_build.patch | 169 +++ .../patches/build/002-change_allconfig.patch | 64 + .../build/003-remove_bogus_modparams.patch | 34 + .../build/004-kconfig_backport_fix.patch | 28 + .../patches/build/010-disable_rfkill.patch | 15 + .../build/012-kernel_build_check.patch | 11 + .../patches/build/015-ipw200-mtu.patch | 34 + .../patches/build/050-lib80211_option.patch | 33 + .../patches/build/060-no_local_ssb_bcma.patch | 335 +++++ ...700-mwl8k-missing-pci-id-for-WNR854T.patch | 10 + .../801-libertas-configure-sysfs-links.patch | 21 + .../802-libertas-set-wireless-macaddr.patch | 11 + ...940-mwl8k_init_devices_synchronously.patch | 20 + ...define-RF5592-in-init_eeprom-routine.patch | 51 + .../patches/rt2x00/100-rt2x00_options.patch | 47 + ...to-build-rt2800soc-module-for-RT3883.patch | 30 + ...1-rt2x00-introduce-rt2x00_platform_h.patch | 32 + .../602-rt2x00-introduce-rt2x00eeprom.patch | 296 ++++ .../603-rt2x00-of_load_eeprom_filename.patch | 33 + ...om-on-SoC-from-a-mtd-device-defines-.patch | 113 ++ ...isabling_bands_through_platform_data.patch | 47 + ...07-rt2x00-add_platform_data_mac_addr.patch | 26 + ...00-allow_disabling_bands_through_dts.patch | 19 + ...c-loadable-via-OF-on-rt288x-305x-SoC.patch | 33 + ...0-rt2x00-change-led-polarity-from-OF.patch | 40 + .../611-rt2x00-add-AP+STA-support.patch | 11 + .../612-rt2x00-led-tpt-trigger-support.patch | 44 + ...dd-support-for-external-PA-on-MT7620.patch | 107 ++ ...-rt2x00-add-rf-self-txdc-calibration.patch | 67 + .../rt2x00/983-rt2x00-add-r-calibration.patch | 166 +++ .../984-rt2x00-add-rxdcoc-calibration.patch | 81 ++ .../985-rt2x00-add-rxiq-calibration.patch | 395 ++++++ .../986-rt2x00-add-TX-LOFT-calibration.patch | 973 +++++++++++++ ...backports-add-netif_receive_skb_list.patch | 30 + .../071-backports-add-skb_list_del_init.patch | 24 + .../100-remove-cryptoapi-dependencies.patch | 698 ++++++++++ .../110-mac80211_keep_keys_on_stop_ap.patch | 12 + .../120-cfg80211_allow_perm_addr_change.patch | 43 + ...aes-cmac-switch-to-shash-CMAC-driver.patch | 230 +++ .../132-mac80211-remove-cmac-dependency.patch | 10 + .../subsys/150-disable_addr_notifier.patch | 67 + .../mac80211/patches/subsys/210-ap_scan.patch | 11 + .../300-mac80211-optimize-skb-resizing.patch | 201 +++ ...domize-BA-session-dialog-token-alloc.patch | 38 + ...11-improve-AQL-tx-airtime-estimation.patch | 81 ++ ...unction-for-running-rx-without-passi.patch | 186 +++ ...skb_get_hash-instead-of-skb_get_hash.patch | 55 + ...lcate-skb-hash-early-when-using-itxq.patch | 19 + ...ce-packet-loss-event-false-positives.patch | 116 ++ ...e-provided-via-status-rate-on-ieee80.patch | 151 ++ ...out-code-to-look-up-the-average-pack.patch | 187 +++ ...-AQL-aggregation-estimation-for-low-.patch | 67 + ...sing-queue-hash-initialization-to-80.patch | 25 + ...nd-refresh-aggregation-session-in-en.patch | 45 + ...cap-offload-for-tx-multicast-control.patch | 136 ++ ...o-control.hw_key-for-encap-offload-p.patch | 31 + ...-rework-tx-encapsulation-offload-API.patch | 613 ++++++++ ...e-duplication-in-tx-status-functions.patch | 197 +++ ...tx-status-call-to-ieee80211_sta_regi.patch | 26 + ...-optimize-station-connection-monitor.patch | 174 +++ ...ED_TXPROCESSING-and-HW_80211_ENCAP-t.patch | 227 +++ ...02.3-offload-and-802.11-tx-status-co.patch | 159 +++ ...-using-ieee80211_tx_status_ext-to-fr.patch | 63 + ...ieee80211_tx_status_ext-to-support-b.patch | 53 + ...the-driver-when-a-sta-uses-4-address.patch | 109 ++ ...ize-code-to-remove-a-forward-declara.patch | 1110 +++++++++++++++ ...AQL-aggregation-estimation-to-HE-and.patch | 49 + ...-add-AQL-support-for-VHT160-tx-rates.patch | 23 + ...11-fix-misplaced-while-instead-of-if.patch | 31 + .../patches/subsys/400-allow-ibss-mixed.patch | 29 + .../500-mac80211_configure_antenna_gain.patch | 160 +++ .../mac80211/patches/subsys/800-oom.patch | 71 + feeds/wifi-ath10k/mac80211/ralink.mk | 172 +++ feeds/wifi-ath10k/mac80211/realtek.mk | 206 +++ .../mac80211/scripts/import-backports.sh | 109 ++ ...dd-packet_steering-script-from-19.07.patch | 87 ++ .../0056-ipq40xx-enable-napi-threading.patch | 27 + profiles/cig_wf160d.yml | 9 +- profiles/edgecore_ecw5211.yml | 8 +- profiles/edgecore_ecw5410.yml | 9 +- profiles/edgecore_oap100.yml | 8 +- profiles/edgecore_spw2ac1200-lan-poe.yml | 9 +- profiles/edgecore_spw2ac1200.yml | 9 +- profiles/edgecore_ssw2ac2600.yml | 9 +- profiles/hfcl_ion4.yml | 9 +- profiles/linksys_ea8300.yml | 9 +- profiles/tp-link_ec420-g1.yml | 9 +- profiles/wallys_dr40x9.yml | 9 +- profiles/wifi-ath10k.yml | 13 + 187 files changed, 21955 insertions(+), 86 deletions(-) create mode 100644 backports/0058-kernel-backport-napi-threading-patches.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct-firmware/Makefile create mode 100644 feeds/wifi-ath10k/ath10k-ct/Makefile create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/164-ath10k-commit-rates-from-mac80211.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/205-ath10k-Add-NL80211_EXT_FEATURE_AQL-flag.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/960-0012-ath10k-add_cmd_processing_time_for_scan_timeout.patch create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/970-accumulate-survey-info-data create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/970-add-survey-local-bss-receive-time create mode 100644 feeds/wifi-ath10k/ath10k-ct/patches/999-ath10k-threading.patch create mode 100644 feeds/wifi-ath10k/ath10k-firmware/Makefile create mode 100644 feeds/wifi-ath10k/batctl/Makefile create mode 100644 feeds/wifi-ath10k/batman-adv/Config.in create mode 100644 feeds/wifi-ath10k/batman-adv/Makefile create mode 100755 feeds/wifi-ath10k/batman-adv/files/etc/uci-defaults/99-migrate-batadv_hardif create mode 100755 feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv.sh create mode 100755 feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_hardif.sh create mode 100755 feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_vlan.sh create mode 100644 feeds/wifi-ath10k/batman-adv/src/compat-hacks.h create mode 100644 feeds/wifi-ath10k/mac80211/Makefile create mode 100644 feeds/wifi-ath10k/mac80211/ath.mk create mode 100644 feeds/wifi-ath10k/mac80211/ath.mk.orig create mode 100644 feeds/wifi-ath10k/mac80211/broadcom.mk create mode 100644 feeds/wifi-ath10k/mac80211/files/lib/netifd/mac80211.sh create mode 100644 feeds/wifi-ath10k/mac80211/files/lib/netifd/wireless/mac80211.sh create mode 100644 feeds/wifi-ath10k/mac80211/files/lib/wifi/mac80211.sh create mode 100644 feeds/wifi-ath10k/mac80211/files/mac80211.hotplug create mode 100644 feeds/wifi-ath10k/mac80211/intel.mk create mode 100644 feeds/wifi-ath10k/mac80211/marvell.mk create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/070-ath_common_config.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/080-ath10k_thermal_config.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/120-owl-loader-compat.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/201-ath5k-WAR-for-AR71xx-PCI-bug.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/354-ath9k-force-rx_clear-when-disabling-rx.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/400-ath_move_debug_code.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/401-ath9k_blink_default.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/402-ath_regd_optional.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/403-world_regd_fixup.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/404-regd_no_assoc_hints.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/405-ath_regd_us.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/406-ath_relax_default_regd.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/410-ath9k_allow_adhoc_and_ap.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/411-ath5k_allow_adhoc_and_ap.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/420-ath5k_disable_fast_cc.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/430-add_ath5k_platform.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/431-add_platform_eeprom_support_to_ath5k.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/432-ath5k_add_pciids.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/440-ath5k_channel_bw_debugfs.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/450-ath9k-enabled-MFP-capability-unconditionally.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/500-ath9k_eeprom_debugfs.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/501-ath9k_ahb_init.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/511-ath9k_reduce_rxbuf.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/512-ath9k_channelbw_debugfs.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/513-ath9k_add_pci_ids.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/530-ath9k_extra_leds.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/531-ath9k_extra_platform_leds.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/540-ath9k_reduce_ani_interval.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/542-ath9k_debugfs_diag.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/543-ath9k_entropy_from_adc.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/545-ath9k_ani_ws_detect.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/547-ath9k_led_defstate_fix.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/548-ath9k_enable_gpio_chip.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/549-ath9k_enable_gpio_buttons.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/550-ath9k-disable-bands-via-dt.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/551-ath9k_ubnt_uap_plus_hsr.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/552-ahb_of.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/921-ath10k_init_devices_synchronously.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/922-ath10k-increase-rx-buffer-size-to-2048.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/930-ath10k_add_tpt_led_trigger.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/975-ath10k-use-tpt-trigger-by-default.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/980-ath10k-fix-max-antenna-gain-unit.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/ath/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/040-brcmutil_option.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/810-b43-gpio-mask-module-option.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/811-b43_no_pio.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/812-b43-add-antenna-control.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/813-b43-reduce-number-of-RX-slots.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/814-b43-only-use-gpio-0-1-for-led.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/850-brcmsmac-remove-extra-regulation-restriction.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/brcm/998-survey.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/000-fix_kconfig.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/001-fix_build.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/002-change_allconfig.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/003-remove_bogus_modparams.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/004-kconfig_backport_fix.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/010-disable_rfkill.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/012-kernel_build_check.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/015-ipw200-mtu.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/050-lib80211_option.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/build/060-no_local_ssb_bcma.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/100-rt2x00_options.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/601-rt2x00-introduce-rt2x00_platform_h.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/070-backports-add-netif_receive_skb_list.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/071-backports-add-skb_list_del_init.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/100-remove-cryptoapi-dependencies.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/131-Revert-mac80211-aes-cmac-switch-to-shash-CMAC-driver.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/132-mac80211-remove-cmac-dependency.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/150-disable_addr_notifier.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/210-ap_scan.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/300-mac80211-optimize-skb-resizing.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/305-mac80211-improve-AQL-tx-airtime-estimation.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/307-mac80211-add-a-function-for-running-rx-without-passi.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/308-net-fq_impl-use-skb_get_hash-instead-of-skb_get_hash.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/309-mac80211-calculcate-skb-hash-early-when-using-itxq.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/310-mac80211-reduce-packet-loss-event-false-positives.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/311-mac80211-use-rate-provided-via-status-rate-on-ieee80.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/312-mac80211-factor-out-code-to-look-up-the-average-pack.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/313-mac80211-improve-AQL-aggregation-estimation-for-low-.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/314-mac80211-add-missing-queue-hash-initialization-to-80.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/315-mac80211-check-and-refresh-aggregation-session-in-en.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/316-mac80211-skip-encap-offload-for-tx-multicast-control.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/317-mac80211-set-info-control.hw_key-for-encap-offload-p.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/318-mac80211-rework-tx-encapsulation-offload-API.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/319-mac80211-reduce-duplication-in-tx-status-functions.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/320-mac80211-remove-tx-status-call-to-ieee80211_sta_regi.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/321-mac80211-optimize-station-connection-monitor.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/322-mac80211-swap-NEED_TXPROCESSING-and-HW_80211_ENCAP-t.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/323-mac80211-unify-802.3-offload-and-802.11-tx-status-co.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/324-mac80211-support-using-ieee80211_tx_status_ext-to-fr.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/325-mac80211-extend-ieee80211_tx_status_ext-to-support-b.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/326-mac80211-notify-the-driver-when-a-sta-uses-4-address.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/327-mac80211-reorganize-code-to-remove-a-forward-declara.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/328-mac80211-extend-AQL-aggregation-estimation-to-HE-and.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/329-mac80211-add-AQL-support-for-VHT160-tx-rates.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/370-mac80211-fix-misplaced-while-instead-of-if.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/400-allow-ibss-mixed.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch create mode 100644 feeds/wifi-ath10k/mac80211/patches/subsys/800-oom.patch create mode 100644 feeds/wifi-ath10k/mac80211/ralink.mk create mode 100644 feeds/wifi-ath10k/mac80211/realtek.mk create mode 100755 feeds/wifi-ath10k/mac80211/scripts/import-backports.sh create mode 100644 patches/0055-ipq40xx-add-packet_steering-script-from-19.07.patch create mode 100644 patches/0056-ipq40xx-enable-napi-threading.patch create mode 100644 profiles/wifi-ath10k.yml diff --git a/backports/0058-kernel-backport-napi-threading-patches.patch b/backports/0058-kernel-backport-napi-threading-patches.patch new file mode 100644 index 000000000..c8b273e3f --- /dev/null +++ b/backports/0058-kernel-backport-napi-threading-patches.patch @@ -0,0 +1,1088 @@ +From 9e48f3b55c4a379ad36974097fadc6bd034a8ce5 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Tue, 14 Dec 2021 09:39:42 +0100 +Subject: [PATCH] kernel: backport napi threading patches + +Signed-off-by: John Crispin +--- + ...pi-poll-functionality-to-__napi_poll.patch | 88 +++++ + ...threaded-able-napi-poll-loop-support.patch | 261 +++++++++++++ + ...tribute-to-control-napi-threaded-mod.patch | 177 +++++++++ + ...ween-napi-kthread-mode-and-busy-poll.patch | 93 +++++ + ...up-on-napi_disable-for-threaded-napi.patch | 53 +++ + ...dd-support-for-threaded-NAPI-polling.patch | 356 ------------------ + 6 files changed, 672 insertions(+), 356 deletions(-) + create mode 100644 target/linux/generic/backport-5.4/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch + create mode 100644 target/linux/generic/backport-5.4/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch + create mode 100644 target/linux/generic/backport-5.4/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch + create mode 100644 target/linux/generic/backport-5.4/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch + create mode 100644 target/linux/generic/backport-5.4/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch + delete mode 100644 target/linux/generic/pending-5.4/690-net-add-support-for-threaded-NAPI-polling.patch + +diff --git a/target/linux/generic/backport-5.4/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch b/target/linux/generic/backport-5.4/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch +new file mode 100644 +index 0000000000..961140aabb +--- /dev/null ++++ b/target/linux/generic/backport-5.4/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch +@@ -0,0 +1,88 @@ ++From: Felix Fietkau ++Date: Mon, 8 Feb 2021 11:34:08 -0800 ++Subject: [PATCH] net: extract napi poll functionality to __napi_poll() ++ ++This commit introduces a new function __napi_poll() which does the main ++logic of the existing napi_poll() function, and will be called by other ++functions in later commits. ++This idea and implementation is done by Felix Fietkau and ++is proposed as part of the patch to move napi work to work_queue ++context. ++This commit by itself is a code restructure. ++ ++Signed-off-by: Felix Fietkau ++Signed-off-by: Wei Wang ++Reviewed-by: Alexander Duyck ++Signed-off-by: David S. Miller ++--- ++ ++--- a/net/core/dev.c +++++ b/net/core/dev.c ++@@ -6322,15 +6322,10 @@ void netif_napi_del(struct napi_struct * ++ } ++ EXPORT_SYMBOL(netif_napi_del); ++ ++-static int napi_poll(struct napi_struct *n, struct list_head *repoll) +++static int __napi_poll(struct napi_struct *n, bool *repoll) ++ { ++- void *have; ++ int work, weight; ++ ++- list_del_init(&n->poll_list); ++- ++- have = netpoll_poll_lock(n); ++- ++ weight = n->weight; ++ ++ /* This NAPI_STATE_SCHED test is for avoiding a race ++@@ -6348,7 +6343,7 @@ static int napi_poll(struct napi_struct ++ WARN_ON_ONCE(work > weight); ++ ++ if (likely(work < weight)) ++- goto out_unlock; +++ return work; ++ ++ /* Drivers must not modify the NAPI state if they ++ * consume the entire weight. In such cases this code ++@@ -6357,7 +6352,7 @@ static int napi_poll(struct napi_struct ++ */ ++ if (unlikely(napi_disable_pending(n))) { ++ napi_complete(n); ++- goto out_unlock; +++ return work; ++ } ++ ++ if (n->gro_bitmask) { ++@@ -6375,12 +6370,29 @@ static int napi_poll(struct napi_struct ++ if (unlikely(!list_empty(&n->poll_list))) { ++ pr_warn_once("%s: Budget exhausted after napi rescheduled\n", ++ n->dev ? n->dev->name : "backlog"); ++- goto out_unlock; +++ return work; ++ } ++ ++- list_add_tail(&n->poll_list, repoll); +++ *repoll = true; +++ +++ return work; +++} +++ +++static int napi_poll(struct napi_struct *n, struct list_head *repoll) +++{ +++ bool do_repoll = false; +++ void *have; +++ int work; +++ +++ list_del_init(&n->poll_list); +++ +++ have = netpoll_poll_lock(n); +++ +++ work = __napi_poll(n, &do_repoll); +++ +++ if (do_repoll) +++ list_add_tail(&n->poll_list, repoll); ++ ++-out_unlock: ++ netpoll_poll_unlock(have); ++ ++ return work; +diff --git a/target/linux/generic/backport-5.4/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch b/target/linux/generic/backport-5.4/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch +new file mode 100644 +index 0000000000..c9bd4abb53 +--- /dev/null ++++ b/target/linux/generic/backport-5.4/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch +@@ -0,0 +1,261 @@ ++From: Wei Wang ++Date: Mon, 8 Feb 2021 11:34:09 -0800 ++Subject: [PATCH] net: implement threaded-able napi poll loop support ++ ++This patch allows running each napi poll loop inside its own ++kernel thread. ++The kthread is created during netif_napi_add() if dev->threaded ++is set. And threaded mode is enabled in napi_enable(). We will ++provide a way to set dev->threaded and enable threaded mode ++without a device up/down in the following patch. ++ ++Once that threaded mode is enabled and the kthread is ++started, napi_schedule() will wake-up such thread instead ++of scheduling the softirq. ++ ++The threaded poll loop behaves quite likely the net_rx_action, ++but it does not have to manipulate local irqs and uses ++an explicit scheduling point based on netdev_budget. ++ ++Co-developed-by: Paolo Abeni ++Signed-off-by: Paolo Abeni ++Co-developed-by: Hannes Frederic Sowa ++Signed-off-by: Hannes Frederic Sowa ++Co-developed-by: Jakub Kicinski ++Signed-off-by: Jakub Kicinski ++Signed-off-by: Wei Wang ++Reviewed-by: Alexander Duyck ++Signed-off-by: David S. Miller ++--- ++ ++--- a/include/linux/netdevice.h +++++ b/include/linux/netdevice.h ++@@ -340,6 +340,7 @@ struct napi_struct { ++ struct list_head dev_list; ++ struct hlist_node napi_hash_node; ++ unsigned int napi_id; +++ struct task_struct *thread; ++ }; ++ ++ enum { ++@@ -350,6 +351,7 @@ enum { ++ NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */ ++ NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */ ++ NAPI_STATE_IN_BUSY_POLL,/* sk_busy_loop() owns this NAPI */ +++ NAPI_STATE_THREADED, /* The poll is performed inside its own thread*/ ++ }; ++ ++ enum { ++@@ -360,6 +362,7 @@ enum { ++ NAPIF_STATE_HASHED = BIT(NAPI_STATE_HASHED), ++ NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL), ++ NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL), +++ NAPIF_STATE_THREADED = BIT(NAPI_STATE_THREADED), ++ }; ++ ++ enum gro_result { ++@@ -504,20 +507,7 @@ bool napi_hash_del(struct napi_struct *n ++ */ ++ void napi_disable(struct napi_struct *n); ++ ++-/** ++- * napi_enable - enable NAPI scheduling ++- * @n: NAPI context ++- * ++- * Resume NAPI from being scheduled on this context. ++- * Must be paired with napi_disable. ++- */ ++-static inline void napi_enable(struct napi_struct *n) ++-{ ++- BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); ++- smp_mb__before_atomic(); ++- clear_bit(NAPI_STATE_SCHED, &n->state); ++- clear_bit(NAPI_STATE_NPSVC, &n->state); ++-} +++void napi_enable(struct napi_struct *n); ++ ++ /** ++ * napi_synchronize - wait until NAPI is not running ++@@ -1783,6 +1773,8 @@ enum netdev_ml_priv_type { ++ * ++ * @wol_enabled: Wake-on-LAN is enabled ++ * +++ * @threaded: napi threaded mode is enabled +++ * ++ * FIXME: cleanup struct net_device such that network protocol info ++ * moves out. ++ */ ++@@ -2075,6 +2067,7 @@ struct net_device { ++ struct lock_class_key addr_list_lock_key; ++ bool proto_down; ++ unsigned wol_enabled:1; +++ unsigned threaded:1; ++ }; ++ #define to_net_dev(d) container_of(d, struct net_device, dev) ++ ++--- a/net/core/dev.c +++++ b/net/core/dev.c ++@@ -91,6 +91,7 @@ ++ #include ++ #include ++ #include +++#include ++ #include ++ #include ++ #include ++@@ -1289,6 +1290,27 @@ void netdev_notify_peers(struct net_devi ++ } ++ EXPORT_SYMBOL(netdev_notify_peers); ++ +++static int napi_threaded_poll(void *data); +++ +++static int napi_kthread_create(struct napi_struct *n) +++{ +++ int err = 0; +++ +++ /* Create and wake up the kthread once to put it in +++ * TASK_INTERRUPTIBLE mode to avoid the blocked task +++ * warning and work with loadavg. +++ */ +++ n->thread = kthread_run(napi_threaded_poll, n, "napi/%s-%d", +++ n->dev->name, n->napi_id); +++ if (IS_ERR(n->thread)) { +++ err = PTR_ERR(n->thread); +++ pr_err("kthread_run failed with err %d\n", err); +++ n->thread = NULL; +++ } +++ +++ return err; +++} +++ ++ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack) ++ { ++ const struct net_device_ops *ops = dev->netdev_ops; ++@@ -3885,6 +3907,21 @@ int gro_normal_batch __read_mostly = 8; ++ static inline void ____napi_schedule(struct softnet_data *sd, ++ struct napi_struct *napi) ++ { +++ struct task_struct *thread; +++ +++ if (test_bit(NAPI_STATE_THREADED, &napi->state)) { +++ /* Paired with smp_mb__before_atomic() in +++ * napi_enable(). Use READ_ONCE() to guarantee +++ * a complete read on napi->thread. Only call +++ * wake_up_process() when it's not NULL. +++ */ +++ thread = READ_ONCE(napi->thread); +++ if (thread) { +++ wake_up_process(thread); +++ return; +++ } +++ } +++ ++ list_add_tail(&napi->poll_list, &sd->poll_list); ++ __raise_softirq_irqoff(NET_RX_SOFTIRQ); ++ } ++@@ -6276,6 +6313,12 @@ void netif_napi_add(struct net_device *d ++ set_bit(NAPI_STATE_NPSVC, &napi->state); ++ list_add_rcu(&napi->dev_list, &dev->napi_list); ++ napi_hash_add(napi); +++ /* Create kthread for this napi if dev->threaded is set. +++ * Clear dev->threaded if kthread creation failed so that +++ * threaded mode will not be enabled in napi_enable(). +++ */ +++ if (dev->threaded && napi_kthread_create(napi)) +++ dev->threaded = 0; ++ } ++ EXPORT_SYMBOL(netif_napi_add); ++ ++@@ -6292,9 +6335,28 @@ void napi_disable(struct napi_struct *n) ++ hrtimer_cancel(&n->timer); ++ ++ clear_bit(NAPI_STATE_DISABLE, &n->state); +++ clear_bit(NAPI_STATE_THREADED, &n->state); ++ } ++ EXPORT_SYMBOL(napi_disable); ++ +++/** +++ * napi_enable - enable NAPI scheduling +++ * @n: NAPI context +++ * +++ * Resume NAPI from being scheduled on this context. +++ * Must be paired with napi_disable. +++ */ +++void napi_enable(struct napi_struct *n) +++{ +++ BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); +++ smp_mb__before_atomic(); +++ clear_bit(NAPI_STATE_SCHED, &n->state); +++ clear_bit(NAPI_STATE_NPSVC, &n->state); +++ if (n->dev->threaded && n->thread) +++ set_bit(NAPI_STATE_THREADED, &n->state); +++} +++EXPORT_SYMBOL(napi_enable); +++ ++ static void flush_gro_hash(struct napi_struct *napi) ++ { ++ int i; ++@@ -6319,6 +6381,11 @@ void netif_napi_del(struct napi_struct * ++ ++ flush_gro_hash(napi); ++ napi->gro_bitmask = 0; +++ +++ if (napi->thread) { +++ kthread_stop(napi->thread); +++ napi->thread = NULL; +++ } ++ } ++ EXPORT_SYMBOL(netif_napi_del); ++ ++@@ -6398,6 +6465,51 @@ static int napi_poll(struct napi_struct ++ return work; ++ } ++ +++static int napi_thread_wait(struct napi_struct *napi) +++{ +++ set_current_state(TASK_INTERRUPTIBLE); +++ +++ while (!kthread_should_stop() && !napi_disable_pending(napi)) { +++ if (test_bit(NAPI_STATE_SCHED, &napi->state)) { +++ WARN_ON(!list_empty(&napi->poll_list)); +++ __set_current_state(TASK_RUNNING); +++ return 0; +++ } +++ +++ schedule(); +++ set_current_state(TASK_INTERRUPTIBLE); +++ } +++ __set_current_state(TASK_RUNNING); +++ return -1; +++} +++ +++static int napi_threaded_poll(void *data) +++{ +++ struct napi_struct *napi = data; +++ void *have; +++ +++ while (!napi_thread_wait(napi)) { +++ for (;;) { +++ bool repoll = false; +++ +++ local_bh_disable(); +++ +++ have = netpoll_poll_lock(napi); +++ __napi_poll(napi, &repoll); +++ netpoll_poll_unlock(have); +++ +++ __kfree_skb_flush(); +++ local_bh_enable(); +++ +++ if (!repoll) +++ break; +++ +++ cond_resched(); +++ } +++ } +++ return 0; +++} +++ ++ static __latent_entropy void net_rx_action(struct softirq_action *h) ++ { ++ struct softnet_data *sd = this_cpu_ptr(&softnet_data); +diff --git a/target/linux/generic/backport-5.4/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch b/target/linux/generic/backport-5.4/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch +new file mode 100644 +index 0000000000..d8b932978c +--- /dev/null ++++ b/target/linux/generic/backport-5.4/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch +@@ -0,0 +1,177 @@ ++From: Wei Wang ++Date: Mon, 8 Feb 2021 11:34:10 -0800 ++Subject: [PATCH] net: add sysfs attribute to control napi threaded mode ++ ++This patch adds a new sysfs attribute to the network device class. ++Said attribute provides a per-device control to enable/disable the ++threaded mode for all the napi instances of the given network device, ++without the need for a device up/down. ++User sets it to 1 or 0 to enable or disable threaded mode. ++Note: when switching between threaded and the current softirq based mode ++for a napi instance, it will not immediately take effect if the napi is ++currently being polled. The mode switch will happen for the next time ++napi_schedule() is called. ++ ++Co-developed-by: Paolo Abeni ++Signed-off-by: Paolo Abeni ++Co-developed-by: Hannes Frederic Sowa ++Signed-off-by: Hannes Frederic Sowa ++Co-developed-by: Felix Fietkau ++Signed-off-by: Felix Fietkau ++Signed-off-by: Wei Wang ++Reviewed-by: Alexander Duyck ++Signed-off-by: David S. Miller ++--- ++ ++--- a/Documentation/ABI/testing/sysfs-class-net +++++ b/Documentation/ABI/testing/sysfs-class-net ++@@ -301,3 +301,18 @@ Contact: netdev@vger.kernel.org ++ Description: ++ 32-bit unsigned integer counting the number of times the link has ++ been down +++ +++What: /sys/class/net//threaded +++Date: Jan 2021 +++KernelVersion: 5.12 +++Contact: netdev@vger.kernel.org +++Description: +++ Boolean value to control the threaded mode per device. User could +++ set this value to enable/disable threaded mode for all napi +++ belonging to this device, without the need to do device up/down. +++ +++ Possible values: +++ == ================================== +++ 0 threaded mode disabled for this dev +++ 1 threaded mode enabled for this dev +++ == ================================== ++--- a/include/linux/netdevice.h +++++ b/include/linux/netdevice.h ++@@ -498,6 +498,8 @@ static inline bool napi_complete(struct ++ */ ++ bool napi_hash_del(struct napi_struct *napi); ++ +++int dev_set_threaded(struct net_device *dev, bool threaded); +++ ++ /** ++ * napi_disable - prevent NAPI from scheduling ++ * @n: NAPI context ++--- a/net/core/dev.c +++++ b/net/core/dev.c ++@@ -3911,8 +3911,9 @@ static inline void ____napi_schedule(str ++ ++ if (test_bit(NAPI_STATE_THREADED, &napi->state)) { ++ /* Paired with smp_mb__before_atomic() in ++- * napi_enable(). Use READ_ONCE() to guarantee ++- * a complete read on napi->thread. Only call +++ * napi_enable()/dev_set_threaded(). +++ * Use READ_ONCE() to guarantee a complete +++ * read on napi->thread. Only call ++ * wake_up_process() when it's not NULL. ++ */ ++ thread = READ_ONCE(napi->thread); ++@@ -6290,6 +6291,49 @@ static void init_gro_hash(struct napi_st ++ napi->gro_bitmask = 0; ++ } ++ +++int dev_set_threaded(struct net_device *dev, bool threaded) +++{ +++ struct napi_struct *napi; +++ int err = 0; +++ +++ if (dev->threaded == threaded) +++ return 0; +++ +++ if (threaded) { +++ list_for_each_entry(napi, &dev->napi_list, dev_list) { +++ if (!napi->thread) { +++ err = napi_kthread_create(napi); +++ if (err) { +++ threaded = false; +++ break; +++ } +++ } +++ } +++ } +++ +++ dev->threaded = threaded; +++ +++ /* Make sure kthread is created before THREADED bit +++ * is set. +++ */ +++ smp_mb__before_atomic(); +++ +++ /* Setting/unsetting threaded mode on a napi might not immediately +++ * take effect, if the current napi instance is actively being +++ * polled. In this case, the switch between threaded mode and +++ * softirq mode will happen in the next round of napi_schedule(). +++ * This should not cause hiccups/stalls to the live traffic. +++ */ +++ list_for_each_entry(napi, &dev->napi_list, dev_list) { +++ if (threaded) +++ set_bit(NAPI_STATE_THREADED, &napi->state); +++ else +++ clear_bit(NAPI_STATE_THREADED, &napi->state); +++ } +++ +++ return err; +++} +++ ++ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, ++ int (*poll)(struct napi_struct *, int), int weight) ++ { ++--- a/net/core/net-sysfs.c +++++ b/net/core/net-sysfs.c ++@@ -557,6 +557,45 @@ static ssize_t phys_switch_id_show(struc ++ } ++ static DEVICE_ATTR_RO(phys_switch_id); ++ +++static ssize_t threaded_show(struct device *dev, +++ struct device_attribute *attr, char *buf) +++{ +++ struct net_device *netdev = to_net_dev(dev); +++ ssize_t ret = -EINVAL; +++ +++ if (!rtnl_trylock()) +++ return restart_syscall(); +++ +++ if (dev_isalive(netdev)) +++ ret = sprintf(buf, fmt_dec, netdev->threaded); +++ +++ rtnl_unlock(); +++ return ret; +++} +++ +++static int modify_napi_threaded(struct net_device *dev, unsigned long val) +++{ +++ int ret; +++ +++ if (list_empty(&dev->napi_list)) +++ return -EOPNOTSUPP; +++ +++ if (val != 0 && val != 1) +++ return -EOPNOTSUPP; +++ +++ ret = dev_set_threaded(dev, val); +++ +++ return ret; +++} +++ +++static ssize_t threaded_store(struct device *dev, +++ struct device_attribute *attr, +++ const char *buf, size_t len) +++{ +++ return netdev_store(dev, attr, buf, len, modify_napi_threaded); +++} +++static DEVICE_ATTR_RW(threaded); +++ ++ static struct attribute *net_class_attrs[] __ro_after_init = { ++ &dev_attr_netdev_group.attr, ++ &dev_attr_type.attr, ++@@ -587,6 +626,7 @@ static struct attribute *net_class_attrs ++ &dev_attr_proto_down.attr, ++ &dev_attr_carrier_up_count.attr, ++ &dev_attr_carrier_down_count.attr, +++ &dev_attr_threaded.attr, ++ NULL, ++ }; ++ ATTRIBUTE_GROUPS(net_class); +diff --git a/target/linux/generic/backport-5.4/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch b/target/linux/generic/backport-5.4/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch +new file mode 100644 +index 0000000000..19c5a53a27 +--- /dev/null ++++ b/target/linux/generic/backport-5.4/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch +@@ -0,0 +1,93 @@ ++From: Wei Wang ++Date: Mon, 1 Mar 2021 17:21:13 -0800 ++Subject: [PATCH] net: fix race between napi kthread mode and busy poll ++ ++Currently, napi_thread_wait() checks for NAPI_STATE_SCHED bit to ++determine if the kthread owns this napi and could call napi->poll() on ++it. However, if socket busy poll is enabled, it is possible that the ++busy poll thread grabs this SCHED bit (after the previous napi->poll() ++invokes napi_complete_done() and clears SCHED bit) and tries to poll ++on the same napi. napi_disable() could grab the SCHED bit as well. ++This patch tries to fix this race by adding a new bit ++NAPI_STATE_SCHED_THREADED in napi->state. This bit gets set in ++____napi_schedule() if the threaded mode is enabled, and gets cleared ++in napi_complete_done(), and we only poll the napi in kthread if this ++bit is set. This helps distinguish the ownership of the napi between ++kthread and other scenarios and fixes the race issue. ++ ++Fixes: 29863d41bb6e ("net: implement threaded-able napi poll loop support") ++Reported-by: Martin Zaharinov ++Suggested-by: Jakub Kicinski ++Signed-off-by: Wei Wang ++Cc: Alexander Duyck ++Cc: Eric Dumazet ++Cc: Paolo Abeni ++Cc: Hannes Frederic Sowa ++--- ++ ++--- a/include/linux/netdevice.h +++++ b/include/linux/netdevice.h ++@@ -352,6 +352,7 @@ enum { ++ NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */ ++ NAPI_STATE_IN_BUSY_POLL,/* sk_busy_loop() owns this NAPI */ ++ NAPI_STATE_THREADED, /* The poll is performed inside its own thread*/ +++ NAPI_STATE_SCHED_THREADED, /* Napi is currently scheduled in threaded mode */ ++ }; ++ ++ enum { ++@@ -363,6 +364,7 @@ enum { ++ NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL), ++ NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL), ++ NAPIF_STATE_THREADED = BIT(NAPI_STATE_THREADED), +++ NAPIF_STATE_SCHED_THREADED = BIT(NAPI_STATE_SCHED_THREADED), ++ }; ++ ++ enum gro_result { ++--- a/net/core/dev.c +++++ b/net/core/dev.c ++@@ -3918,6 +3918,8 @@ static inline void ____napi_schedule(str ++ */ ++ thread = READ_ONCE(napi->thread); ++ if (thread) { +++ if (thread->state != TASK_INTERRUPTIBLE) +++ set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); ++ wake_up_process(thread); ++ return; ++ } ++@@ -6078,7 +6080,8 @@ bool napi_complete_done(struct napi_stru ++ ++ WARN_ON_ONCE(!(val & NAPIF_STATE_SCHED)); ++ ++- new = val & ~(NAPIF_STATE_MISSED | NAPIF_STATE_SCHED); +++ new = val & ~(NAPIF_STATE_MISSED | NAPIF_STATE_SCHED | +++ NAPIF_STATE_SCHED_THREADED); ++ ++ /* If STATE_MISSED was set, leave STATE_SCHED set, ++ * because we will call napi->poll() one more time. ++@@ -6511,16 +6514,25 @@ static int napi_poll(struct napi_struct ++ ++ static int napi_thread_wait(struct napi_struct *napi) ++ { +++ bool woken = false; +++ ++ set_current_state(TASK_INTERRUPTIBLE); ++ ++ while (!kthread_should_stop() && !napi_disable_pending(napi)) { ++- if (test_bit(NAPI_STATE_SCHED, &napi->state)) { +++ /* Testing SCHED_THREADED bit here to make sure the current +++ * kthread owns this napi and could poll on this napi. +++ * Testing SCHED bit is not enough because SCHED bit might be +++ * set by some other busy poll thread or by napi_disable(). +++ */ +++ if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) { ++ WARN_ON(!list_empty(&napi->poll_list)); ++ __set_current_state(TASK_RUNNING); ++ return 0; ++ } ++ ++ schedule(); +++ /* woken being true indicates this thread owns this napi. */ +++ woken = true; ++ set_current_state(TASK_INTERRUPTIBLE); ++ } ++ __set_current_state(TASK_RUNNING); +diff --git a/target/linux/generic/backport-5.4/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch b/target/linux/generic/backport-5.4/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch +new file mode 100644 +index 0000000000..108cf809f8 +--- /dev/null ++++ b/target/linux/generic/backport-5.4/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch +@@ -0,0 +1,53 @@ ++From: Paolo Abeni ++Date: Fri, 9 Apr 2021 17:24:17 +0200 ++Subject: [PATCH] net: fix hangup on napi_disable for threaded napi ++ ++napi_disable() is subject to an hangup, when the threaded ++mode is enabled and the napi is under heavy traffic. ++ ++If the relevant napi has been scheduled and the napi_disable() ++kicks in before the next napi_threaded_wait() completes - so ++that the latter quits due to the napi_disable_pending() condition, ++the existing code leaves the NAPI_STATE_SCHED bit set and the ++napi_disable() loop waiting for such bit will hang. ++ ++This patch addresses the issue by dropping the NAPI_STATE_DISABLE ++bit test in napi_thread_wait(). The later napi_threaded_poll() ++iteration will take care of clearing the NAPI_STATE_SCHED. ++ ++This also addresses a related problem reported by Jakub: ++before this patch a napi_disable()/napi_enable() pair killed ++the napi thread, effectively disabling the threaded mode. ++On the patched kernel napi_disable() simply stops scheduling ++the relevant thread. ++ ++v1 -> v2: ++ - let the main napi_thread_poll() loop clear the SCHED bit ++ ++Reported-by: Jakub Kicinski ++Fixes: 29863d41bb6e ("net: implement threaded-able napi poll loop support") ++Signed-off-by: Paolo Abeni ++Reviewed-by: Eric Dumazet ++Link: https://lore.kernel.org/r/883923fa22745a9589e8610962b7dc59df09fb1f.1617981844.git.pabeni@redhat.com ++Signed-off-by: Jakub Kicinski ++--- ++ ++--- a/net/core/dev.c +++++ b/net/core/dev.c ++@@ -6518,7 +6518,7 @@ static int napi_thread_wait(struct napi_ ++ ++ set_current_state(TASK_INTERRUPTIBLE); ++ ++- while (!kthread_should_stop() && !napi_disable_pending(napi)) { +++ while (!kthread_should_stop()) { ++ /* Testing SCHED_THREADED bit here to make sure the current ++ * kthread owns this napi and could poll on this napi. ++ * Testing SCHED bit is not enough because SCHED bit might be ++@@ -6536,6 +6536,7 @@ static int napi_thread_wait(struct napi_ ++ set_current_state(TASK_INTERRUPTIBLE); ++ } ++ __set_current_state(TASK_RUNNING); +++ ++ return -1; ++ } ++ +diff --git a/target/linux/generic/pending-5.4/690-net-add-support-for-threaded-NAPI-polling.patch b/target/linux/generic/pending-5.4/690-net-add-support-for-threaded-NAPI-polling.patch +deleted file mode 100644 +index f45efdf12b..0000000000 +--- a/target/linux/generic/pending-5.4/690-net-add-support-for-threaded-NAPI-polling.patch ++++ /dev/null +@@ -1,356 +0,0 @@ +-From: Felix Fietkau +-Date: Sun, 26 Jul 2020 14:03:21 +0200 +-Subject: [PATCH] net: add support for threaded NAPI polling +- +-For some drivers (especially 802.11 drivers), doing a lot of work in the NAPI +-poll function does not perform well. Since NAPI poll is bound to the CPU it +-was scheduled from, we can easily end up with a few very busy CPUs spending +-most of their time in softirq/ksoftirqd and some idle ones. +- +-Introduce threaded NAPI for such drivers based on a workqueue. The API is the +-same except for using netif_threaded_napi_add instead of netif_napi_add. +- +-In my tests with mt76 on MT7621 using threaded NAPI + a thread for tx scheduling +-improves LAN->WLAN bridging throughput by 10-50%. Throughput without threaded +-NAPI is wildly inconsistent, depending on the CPU that runs the tx scheduling +-thread. +- +-With threaded NAPI it seems stable and consistent (and higher than the best +-results I got without it). +- +-Based on a patch by Hillf Danton +- +-Cc: Hillf Danton +-Signed-off-by: Felix Fietkau +---- +- +---- a/include/linux/netdevice.h +-+++ b/include/linux/netdevice.h +-@@ -340,6 +340,7 @@ struct napi_struct { +- struct list_head dev_list; +- struct hlist_node napi_hash_node; +- unsigned int napi_id; +-+ struct work_struct work; +- }; +- +- enum { +-@@ -350,6 +351,7 @@ enum { +- NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */ +- NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */ +- NAPI_STATE_IN_BUSY_POLL,/* sk_busy_loop() owns this NAPI */ +-+ NAPI_STATE_THREADED, /* Use threaded NAPI */ +- }; +- +- enum { +-@@ -360,6 +362,7 @@ enum { +- NAPIF_STATE_HASHED = BIT(NAPI_STATE_HASHED), +- NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL), +- NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL), +-+ NAPIF_STATE_THREADED = BIT(NAPI_STATE_THREADED), +- }; +- +- enum gro_result { +-@@ -2101,6 +2104,7 @@ struct net_device { +- struct lock_class_key addr_list_lock_key; +- bool proto_down; +- unsigned wol_enabled:1; +-+ unsigned threaded:1; +- }; +- #define to_net_dev(d) container_of(d, struct net_device, dev) +- +-@@ -2281,6 +2285,26 @@ void netif_napi_add(struct net_device *d +- int (*poll)(struct napi_struct *, int), int weight); +- +- /** +-+ * netif_threaded_napi_add - initialize a NAPI context +-+ * @dev: network device +-+ * @napi: NAPI context +-+ * @poll: polling function +-+ * @weight: default weight +-+ * +-+ * This variant of netif_napi_add() should be used from drivers using NAPI +-+ * with CPU intensive poll functions. +-+ * This will schedule polling from a high priority workqueue +-+ */ +-+static inline void netif_threaded_napi_add(struct net_device *dev, +-+ struct napi_struct *napi, +-+ int (*poll)(struct napi_struct *, int), +-+ int weight) +-+{ +-+ set_bit(NAPI_STATE_THREADED, &napi->state); +-+ netif_napi_add(dev, napi, poll, weight); +-+} +-+ +-+/** +- * netif_tx_napi_add - initialize a NAPI context +- * @dev: network device +- * @napi: NAPI context +---- a/net/core/dev.c +-+++ b/net/core/dev.c +-@@ -156,6 +156,7 @@ static DEFINE_SPINLOCK(offload_lock); +- struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly; +- struct list_head ptype_all __read_mostly; /* Taps */ +- static struct list_head offload_base __read_mostly; +-+static struct workqueue_struct *napi_workq __read_mostly; +- +- static int netif_rx_internal(struct sk_buff *skb); +- static int call_netdevice_notifiers_info(unsigned long val, +-@@ -5931,6 +5932,11 @@ void __napi_schedule(struct napi_struct +- { +- unsigned long flags; +- +-+ if (test_bit(NAPI_STATE_THREADED, &n->state)) { +-+ queue_work(napi_workq, &n->work); +-+ return; +-+ } +-+ +- local_irq_save(flags); +- ____napi_schedule(this_cpu_ptr(&softnet_data), n); +- local_irq_restore(flags); +-@@ -5982,6 +5988,11 @@ EXPORT_SYMBOL(napi_schedule_prep); +- */ +- void __napi_schedule_irqoff(struct napi_struct *n) +- { +-+ if (test_bit(NAPI_STATE_THREADED, &n->state)) { +-+ queue_work(napi_workq, &n->work); +-+ return; +-+ } +-+ +- if (!IS_ENABLED(CONFIG_PREEMPT_RT)) +- ____napi_schedule(this_cpu_ptr(&softnet_data), n); +- else +-@@ -6246,9 +6257,89 @@ static void init_gro_hash(struct napi_st +- napi->gro_bitmask = 0; +- } +- +-+static int __napi_poll(struct napi_struct *n, bool *repoll) +-+{ +-+ int work, weight; +-+ +-+ weight = n->weight; +-+ +-+ /* This NAPI_STATE_SCHED test is for avoiding a race +-+ * with netpoll's poll_napi(). Only the entity which +-+ * obtains the lock and sees NAPI_STATE_SCHED set will +-+ * actually make the ->poll() call. Therefore we avoid +-+ * accidentally calling ->poll() when NAPI is not scheduled. +-+ */ +-+ work = 0; +-+ if (test_bit(NAPI_STATE_SCHED, &n->state)) { +-+ work = n->poll(n, weight); +-+ trace_napi_poll(n, work, weight); +-+ } +-+ +-+ WARN_ON_ONCE(work > weight); +-+ +-+ if (likely(work < weight)) +-+ return work; +-+ +-+ /* Drivers must not modify the NAPI state if they +-+ * consume the entire weight. In such cases this code +-+ * still "owns" the NAPI instance and therefore can +-+ * move the instance around on the list at-will. +-+ */ +-+ if (unlikely(napi_disable_pending(n))) { +-+ napi_complete(n); +-+ return work; +-+ } +-+ +-+ if (n->gro_bitmask) { +-+ /* flush too old packets +-+ * If HZ < 1000, flush all packets. +-+ */ +-+ napi_gro_flush(n, HZ >= 1000); +-+ } +-+ +-+ gro_normal_list(n); +-+ +-+ *repoll = true; +-+ +-+ return work; +-+} +-+ +-+static void napi_workfn(struct work_struct *work) +-+{ +-+ struct napi_struct *n = container_of(work, struct napi_struct, work); +-+ void *have; +-+ +-+ for (;;) { +-+ bool repoll = false; +-+ +-+ local_bh_disable(); +-+ +-+ have = netpoll_poll_lock(n); +-+ __napi_poll(n, &repoll); +-+ netpoll_poll_unlock(have); +-+ +-+ local_bh_enable(); +-+ +-+ if (!repoll) +-+ return; +-+ +-+ if (!need_resched()) +-+ continue; +-+ +-+ /* +-+ * have to pay for the latency of task switch even if +-+ * napi is scheduled +-+ */ +-+ queue_work(napi_workq, work); +-+ return; +-+ } +-+} +-+ +- void netif_napi_add(struct net_device *dev, struct napi_struct *napi, +- int (*poll)(struct napi_struct *, int), int weight) +- { +-+ if (dev->threaded) +-+ set_bit(NAPI_STATE_THREADED, &napi->state); +- INIT_LIST_HEAD(&napi->poll_list); +- hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); +- napi->timer.function = napi_watchdog; +-@@ -6265,6 +6356,7 @@ void netif_napi_add(struct net_device *d +- #ifdef CONFIG_NETPOLL +- napi->poll_owner = -1; +- #endif +-+ INIT_WORK(&napi->work, napi_workfn); +- set_bit(NAPI_STATE_SCHED, &napi->state); +- set_bit(NAPI_STATE_NPSVC, &napi->state); +- list_add_rcu(&napi->dev_list, &dev->napi_list); +-@@ -6305,6 +6397,7 @@ static void flush_gro_hash(struct napi_s +- void netif_napi_del(struct napi_struct *napi) +- { +- might_sleep(); +-+ cancel_work_sync(&napi->work); +- if (napi_hash_del(napi)) +- synchronize_net(); +- list_del_init(&napi->dev_list); +-@@ -6317,50 +6410,18 @@ EXPORT_SYMBOL(netif_napi_del); +- +- static int napi_poll(struct napi_struct *n, struct list_head *repoll) +- { +-+ bool do_repoll = false; +- void *have; +-- int work, weight; +-+ int work; +- +- list_del_init(&n->poll_list); +- +- have = netpoll_poll_lock(n); +- +-- weight = n->weight; +-+ work = __napi_poll(n, &do_repoll); +- +-- /* This NAPI_STATE_SCHED test is for avoiding a race +-- * with netpoll's poll_napi(). Only the entity which +-- * obtains the lock and sees NAPI_STATE_SCHED set will +-- * actually make the ->poll() call. Therefore we avoid +-- * accidentally calling ->poll() when NAPI is not scheduled. +-- */ +-- work = 0; +-- if (test_bit(NAPI_STATE_SCHED, &n->state)) { +-- work = n->poll(n, weight); +-- trace_napi_poll(n, work, weight); +-- } +-- +-- WARN_ON_ONCE(work > weight); +-- +-- if (likely(work < weight)) +-- goto out_unlock; +-- +-- /* Drivers must not modify the NAPI state if they +-- * consume the entire weight. In such cases this code +-- * still "owns" the NAPI instance and therefore can +-- * move the instance around on the list at-will. +-- */ +-- if (unlikely(napi_disable_pending(n))) { +-- napi_complete(n); +-+ if (!do_repoll) +- goto out_unlock; +-- } +-- +-- if (n->gro_bitmask) { +-- /* flush too old packets +-- * If HZ < 1000, flush all packets. +-- */ +-- napi_gro_flush(n, HZ >= 1000); +-- } +-- +-- gro_normal_list(n); +- +- /* Some drivers may have called napi_schedule +- * prior to exhausting their budget. +-@@ -10340,6 +10401,10 @@ static int __init net_dev_init(void) +- sd->backlog.weight = weight_p; +- } +- +-+ napi_workq = alloc_workqueue("napi_workq", WQ_UNBOUND | WQ_HIGHPRI, +-+ WQ_UNBOUND_MAX_ACTIVE | WQ_SYSFS); +-+ BUG_ON(!napi_workq); +-+ +- dev_boot_phase = 0; +- +- /* The loopback device is special if any other network devices +---- a/net/core/net-sysfs.c +-+++ b/net/core/net-sysfs.c +-@@ -442,6 +442,52 @@ static ssize_t proto_down_store(struct d +- } +- NETDEVICE_SHOW_RW(proto_down, fmt_dec); +- +-+static int change_napi_threaded(struct net_device *dev, unsigned long val) +-+{ +-+ struct napi_struct *napi; +-+ +-+ if (list_empty(&dev->napi_list)) +-+ return -EOPNOTSUPP; +-+ +-+ list_for_each_entry(napi, &dev->napi_list, dev_list) { +-+ if (val) +-+ set_bit(NAPI_STATE_THREADED, &napi->state); +-+ else +-+ clear_bit(NAPI_STATE_THREADED, &napi->state); +-+ } +-+ +-+ return 0; +-+} +-+ +-+static ssize_t napi_threaded_store(struct device *dev, +-+ struct device_attribute *attr, +-+ const char *buf, size_t len) +-+{ +-+ return netdev_store(dev, attr, buf, len, change_napi_threaded); +-+} +-+ +-+static ssize_t napi_threaded_show(struct device *dev, +-+ struct device_attribute *attr, +-+ char *buf) +-+{ +-+ struct net_device *netdev = to_net_dev(dev); +-+ struct napi_struct *napi; +-+ bool enabled = false; +-+ +-+ if (!rtnl_trylock()) +-+ return restart_syscall(); +-+ +-+ list_for_each_entry(napi, &netdev->napi_list, dev_list) { +-+ if (test_bit(NAPI_STATE_THREADED, &napi->state)) +-+ enabled = true; +-+ } +-+ +-+ rtnl_unlock(); +-+ +-+ return sprintf(buf, fmt_dec, enabled); +-+} +-+static DEVICE_ATTR_RW(napi_threaded); +-+ +- static ssize_t phys_port_id_show(struct device *dev, +- struct device_attribute *attr, char *buf) +- { +-@@ -532,6 +578,7 @@ static struct attribute *net_class_attrs +- &dev_attr_flags.attr, +- &dev_attr_tx_queue_len.attr, +- &dev_attr_gro_flush_timeout.attr, +-+ &dev_attr_napi_threaded.attr, +- &dev_attr_phys_port_id.attr, +- &dev_attr_phys_port_name.attr, +- &dev_attr_phys_switch_id.attr, +-- +2.25.1 + diff --git a/feeds/wifi-ath10k/ath10k-ct-firmware/Makefile b/feeds/wifi-ath10k/ath10k-ct-firmware/Makefile new file mode 100644 index 000000000..ce92567b5 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct-firmware/Makefile @@ -0,0 +1,701 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ath10k-ct-firmware +PKG_VERSION:=2020-10-07 +PKG_RELEASE:=2 +CTVER1=021 +CTVER2=021 + +# From fw_lede.bash, or can do it manually as well. +H988XFC=a4c3d1e2fb80f6b8b9738c7189795ab9505e6c09efc12ba5f08ee7f49e934239 +H988XFCH=93108bd0870652860cdb57749f5a12205ecb15bb1f129d916ad73b6f06406c82 +H9887FC=459692deb186a63ab8eeddb7ad5d54779266e68ca686e7c46062554db6dca12b +H9887FCH=fd126a457d0927d0c8ea10d66ef5b67d5e1e0741f8692bb3016bb602d0af3098 +H9980FC=52300e9d128c3d506e0b133d7a7964df3115f9511f1b574ef2a0767972c063bd +H9980FCH=9c20c3a44b701f8fef0fe02f156e382b36b717fb56c76d540f6eac2077ec189b +H9980CH=55f27045e7cf87a6a5656a050771d6d7a6197153a0737288a702c0836d5c6572 +H9980FHQ=add509b2a15ba90869f403c2e4440dbb91bd7037188d8468249cf1263adfd44e +H9984FC=e6354a1547a308b4b0fe4cbc29693848c234acedd9e7a483a1b4fb5f9bbf0dc0 +H9984FCH=6e19ecd0b001ffb594a8b033deb2007595b8c0402402789b7de55b208639ebec +H9984CH=7b6fdf3d970f3eff7c34df476c934a9bebb4f289b7968067950d31b82c71bb07 +H9984FHQ=f6a5d5a3a7b2c9267dc31673a19ee3b5312a2f84f26123cb5e8c000428ed76d2 +H4019FC=cde992cb328680e81cf85e195554699bcceef065c0c696ce4ef90c3311ab11fb +H4019FCH=818afeb1226389357dfde754d641f936fb82ebe78607f10e15efd5c952a54f48 +H4019CH=30ba10f0d82116c6617cb58c3df5cc81e5ed8f29dbc8f95c0ca9c5013ce4f702 +H4019FHQ=8e4161f7bed5bd56513ca5caab582a6eee64e9e14a69f4de67587563b7b4d735 +H9888FC=d24e66bdb2f1098a2e06ff20fe037e31937e1a483e87c68827830513b4233b5d +H9888FCH=5891e1c184da433ecc12ca0176ca89a77f7bc2b675576698b69bc93d46b77042 +H9888CH=b94f46cdda6171e5f566b1cdd6aafd68ff1a4f7e8a27762b90eb5d4f03839d99 +H9888FHQ=3cc81f8707bf5ba63bc9ffc14578c77637cae0e15766ae146af02eefb9ab7bfd + +include $(INCLUDE_DIR)/package.mk + +ATH10K_FIRMWARE_REV:=d622d160e9f552ead68d9ae81b715422892dc2ef +ATH10K_FIRMWARE_URL:=@GITHUB/kvalo/ath10k-firmware/$(ATH10K_FIRMWARE_REV) + +QCA9887_BOARD_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca9887-board.bin +define Download/qca9887-board + FILE:=$(QCA9887_BOARD_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA9887/hw1.0 + URL_FILE:=board.bin + HASH:=cf4df099f6ee05c181f55ce17297a1d32c61d725eb96246fd315ad5587c42426 +endef +$(eval $(call Download,qca9887-board)) + +QCA988X_BOARD_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca988x-board.bin +define Download/qca988x-board + FILE:=$(QCA988X_BOARD_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA988X/hw2.0 + URL_FILE:=board.bin + HASH:=5b5b380333c2dd3b6ce67f30e2f7008f4020bf594970d3b464fd8d4a80fcd880 +endef +$(eval $(call Download,qca988x-board)) + +QCA99X0_BOARD_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca99x0-board.bin +define Download/qca99x0-board + FILE:=$(QCA99X0_BOARD_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA99X0/hw2.0 + URL_FILE:=boardData_AR900B_CUS239_5G_v2_001.bin + HASH:=3bf7561ee373b369025dcd366d276d038a97d3397ccae41ce841d98a58b30aff +endef +$(eval $(call Download,qca99x0-board)) + +QCA99X0_BOARD2_REV:=ddcec9efd245da9365c474f513a855a55f3ac7fe +QCA99X0_BOARD2_FILE:=ath10k-firmware-$(QCA99X0_BOARD2_REV)-qca99x0-board-2.bin +define Download/qca99x0-board2 + FILE:=$(QCA99X0_BOARD2_FILE) + URL:=https://source.codeaurora.org/quic/qsdk/oss/firmware/ath10k-firmware/plain/ath10k/QCA99X0/hw2.0 + URL_FILE:=board-2.bin?id=$(QCA99X0_BOARD2_REV) + HASH:=03711ac21e60ef59d3815e235eb721c0c22851b5410299411085aa6f2af45401 +endef +$(eval $(call Download,qca99x0-board2)) + +QCA9984_BOARD2_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca9984-board-2.bin +define Download/qca9984-board2 + FILE:=$(QCA9984_BOARD2_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA9984/hw1.0 + URL_FILE:=board-2.bin + HASH:=0d6d46cf0467185e3959ce3cb69e2415be6e48ab8a4bee3eb400edbe48cb9c25 +endef +$(eval $(call Download,qca9984-board2)) + +QCA4019_BOARD2_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca4019-board-2.bin +define Download/qca4019-board2 + FILE:=$(QCA4019_BOARD2_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA4019/hw1.0 + URL_FILE:=board-2.bin + HASH:=94b66aa4ddbed5110a96364d3c7b4ebcb320e3ac4e8697660b277e76077bc338 +endef +$(eval $(call Download,qca4019-board2)) + +QCA9888_BOARD2_FILE:=ath10k-firmware-$(ATH10K_FIRMWARE_REV)-qca9888-board-2.bin +define Download/qca9888-board2 + FILE:=$(QCA9888_BOARD2_FILE) + URL:=$(ATH10K_FIRMWARE_URL)/QCA9888/hw2.0 + URL_FILE:=board-2.bin + HASH:=5b871bb567f64525ca45adb88063211de472015d09e0f9aa3fa61ab71c8fdfd3 +endef +$(eval $(call Download,qca9888-board2)) + +CT_FIRMWARE_FILE = $(1)-$($(1)_FIRMWARE_FILE_CT) +CT_FIRMWARE_FILE_FULL_HTT = $(1)-$($(1)_FIRMWARE_FILE_CT_FULL_HTT) +CT_FIRMWARE_FILE_HTT = $(1)-$($(1)_FIRMWARE_FILE_CT_HTT) + +define Download/ct-firmware + URL:=https://www.candelatech.com/downloads/$(2) + FILE:=$(call CT_FIRMWARE_FILE,$(1)) + URL_FILE:=$($(1)_FIRMWARE_FILE_CT) +endef + +define Download/ct-firmware-full-htt + URL:=https://www.candelatech.com/downloads/$(2) + FILE:=$(call CT_FIRMWARE_FILE_FULL_HTT,$(1)) + URL_FILE:=$($(1)_FIRMWARE_FILE_CT_FULL_HTT) +endef + +define Download/ct-firmware-htt + URL:=https://www.candelatech.com/downloads/$(2) + FILE:=$(call CT_FIRMWARE_FILE_HTT,$(1)) + URL_FILE:=$($(1)_FIRMWARE_FILE_CT_HTT) +endef + +QCA988X_FIRMWARE_FILE_CT:=firmware-2-ct-full-community-22.bin.lede.$(CTVER1) +define Download/ath10k-firmware-qca988x-ct + $(call Download/ct-firmware,QCA988X,) + HASH:=$(H988XFC) +endef +$(eval $(call Download,ath10k-firmware-qca988x-ct)) + +QCA988X_FIRMWARE_FILE_CT_FULL_HTT:=firmware-2-ct-full-htt-mgt-community-22.bin.lede.$(CTVER1) +define Download/ath10k-firmware-qca988x-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA988X,) + HASH:=$(H988XFCH) +endef +$(eval $(call Download,ath10k-firmware-qca988x-ct-full-htt)) + + +QCA9887_FIRMWARE_FILE_CT:=firmware-2-ct-full-community-22.bin.lede.$(CTVER1) +define Download/ath10k-firmware-qca9887-ct + $(call Download/ct-firmware,QCA9887,ath10k-9887) + HASH:=$(H9887FC) +endef +$(eval $(call Download,ath10k-firmware-qca9887-ct)) + +QCA9887_FIRMWARE_FILE_CT_FULL_HTT:=firmware-2-ct-full-htt-mgt-community-22.bin.lede.$(CTVER1) +define Download/ath10k-firmware-qca9887-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA9887,ath10k-9887) + HASH:=$(H9887FCH) +endef +$(eval $(call Download,ath10k-firmware-qca9887-ct-full-htt)) + + +QCA99X0_FIRMWARE_FILE_CT:=firmware-5-ct-full-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca99x0-ct + $(call Download/ct-firmware,QCA99X0,ath10k-10-4b) + HASH:=$(H9980FC) +endef +$(eval $(call Download,ath10k-firmware-qca99x0-ct)) + +QCA99X0_FIRMWARE_FILE_CT_FULL_HTT:=firmware-5-ct-full-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca99x0-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA99X0,ath10k-10-4b) + HASH:=$(H9980FCH) +endef +$(eval $(call Download,ath10k-firmware-qca99x0-ct-full-htt)) + +QCA99X0_FIRMWARE_FILE_CT_HTT:=firmware-5-ct-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca99x0-ct-htt + $(call Download/ct-firmware-htt,QCA99X0,ath10k-10-4b) + HASH:=$(H9980CH) +endef +$(eval $(call Download,ath10k-firmware-qca99x0-ct-htt)) + + +QCA9984_FIRMWARE_FILE_CT:=firmware-5-ct-full-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9984-ct + $(call Download/ct-firmware,QCA9984,ath10k-9984-10-4b) + HASH:=$(H9984FC) +endef +$(eval $(call Download,ath10k-firmware-qca9984-ct)) + +QCA9984_FIRMWARE_FILE_CT_FULL_HTT:=firmware-5-ct-full-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9984-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA9984,ath10k-9984-10-4b) + HASH:=$(H9984FCH) +endef +$(eval $(call Download,ath10k-firmware-qca9984-ct-full-htt)) + +QCA9984_FIRMWARE_FILE_CT_HTT:=firmware-5-ct-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9984-ct-htt + $(call Download/ct-firmware-htt,QCA9984,ath10k-9984-10-4b) + HASH:=$(H9984CH) +endef +$(eval $(call Download,ath10k-firmware-qca9984-ct-htt)) + + +QCA4019_FIRMWARE_FILE_CT:=firmware-5-ct-full-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca4019-ct + $(call Download/ct-firmware,QCA4019,ath10k-4019-10-4b) + HASH:=$(H4019FC) +endef +$(eval $(call Download,ath10k-firmware-qca4019-ct)) + +QCA4019_FIRMWARE_FILE_CT_FULL_HTT:=firmware-5-ct-full-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca4019-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA4019,ath10k-4019-10-4b) + HASH:=$(H4019FCH) +endef +$(eval $(call Download,ath10k-firmware-qca4019-ct-full-htt)) + +QCA4019_FIRMWARE_FILE_CT_HTT:=firmware-5-ct-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca4019-ct-htt + $(call Download/ct-firmware-htt,QCA4019,ath10k-4019-10-4b) + HASH:=$(H4019CH) +endef +$(eval $(call Download,ath10k-firmware-qca4019-ct-htt)) + + +QCA9888_FIRMWARE_FILE_CT:=firmware-5-ct-full-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9888-ct + $(call Download/ct-firmware,QCA9888,ath10k-9888-10-4b) + HASH:=$(H9888FC) +endef +$(eval $(call Download,ath10k-firmware-qca9888-ct)) + +QCA9888_FIRMWARE_FILE_CT_FULL_HTT:=firmware-5-ct-full-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9888-ct-full-htt + $(call Download/ct-firmware-full-htt,QCA9888,ath10k-9888-10-4b) + HASH:=$(H9888FCH) +endef +$(eval $(call Download,ath10k-firmware-qca9888-ct-full-htt)) + +QCA9888_FIRMWARE_FILE_CT_HTT:=firmware-5-ct-htt-mgt-community-12.bin-lede.$(CTVER2) +define Download/ath10k-firmware-qca9888-ct-htt + $(call Download/ct-firmware-htt,QCA9888,ath10k-9888-10-4b) + HASH:=$(H9888CH) +endef +$(eval $(call Download,ath10k-firmware-qca9888-ct-htt)) + + +define Package/ath10k-ct-firmware-default + SECTION:=firmware + CATEGORY:=Firmware + URL:=https://www.candelatech.com/ath10k.php + DEPENDS:= +endef + +define Package/ath10k-firmware-qca988x-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.1 firmware for QCA988x devices + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca988x +endef +define Package/ath10k-firmware-qca988x-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.1 full-htt-mgt fw for QCA988x + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca988x + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + +define Package/ath10k-firmware-qca9887-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.1 firmware for QCA9887 devices + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9887 +endef +define Package/ath10k-firmware-qca9887-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.1 full-htt-mgt fw for QCA9887 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9887 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + +define Package/ath10k-firmware-qca99x0-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 firmware for QCA99x0 devices + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca99x0 +endef +define Package/ath10k-firmware-qca99x0-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 full-htt-mgt fw for QCA99x0 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca99x0 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef +define Package/ath10k-firmware-qca99x0-ct-htt +$(Package/ath10k-firmware-default) + TITLE:=ath10k CT 10.4 htt-mgt fw for QCA99x0 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca99x0 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + +define Package/ath10k-firmware-qca9984-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 firmware for QCA9984 devices + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9984 +endef +define Package/ath10k-firmware-qca9984-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 full-htt-mgt fw for QCA9984 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9984 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef +define Package/ath10k-firmware-qca9984-ct-htt +$(Package/ath10k-firmware-default) + TITLE:=ath10k CT 10.4 htt-mgt fw for QCA9984 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9984 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + +define Package/ath10k-firmware-qca4019-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 firmware for QCA4018/9 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca4019 +endef +define Package/ath10k-firmware-qca4019-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 full-htt-mgt for QCA4018/9 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca4019 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef +define Package/ath10k-firmware-qca4019-ct-htt +$(Package/ath10k-firmware-default) + TITLE:=ath10k CT 10.4 htt-mgt for QCA4018/9 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca4019 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + +define Package/ath10k-firmware-qca9888-ct +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 fw for QCA9886/8 devices + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9888 +endef +define Package/ath10k-firmware-qca9888-ct-full-htt +$(Package/ath10k-ct-firmware-default) + TITLE:=ath10k CT 10.4 full-htt-mgt fw for QCA9886/8 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9888 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef +define Package/ath10k-firmware-qca9888-ct-htt +$(Package/ath10k-firmware-default) + TITLE:=ath10k CT 10.4 htt-mgt fw for QCA9886/8 + SECTION:=firmware + CATEGORY:=Firmware + PROVIDES:=ath10k-firmware-qca9888 + DEPENDS:=+!PACKAGE_kmod-ath10k-ct-smallbuffers:kmod-ath10k-ct +endef + + +define Package/ath10k-firmware-qca9887-ct/description +Alternative ath10k firmware for QCA9887 from Candela Technologies. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.1.php +This firmware conflicts with the standard 9887 firmware, so select only +one. +endef +define Package/ath10k-firmware-qca9887-ct-full-htt/description +Alternative ath10k firmware for QCA9887 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and fixes .11r authentication. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.1.php +This firmware selects and requires the ath10k-ct driver. +endef + +define Package/ath10k-firmware-qca988x-ct/description +Alternative ath10k firmware for QCA988X from Candela Technologies. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.1.php +This firmware will NOT be used unless the standard ath10k-firmware-qca988x +is un-selected since the driver will try to load firmware-5.bin before +firmware-2.bin +endef +define Package/ath10k-firmware-qca988x-ct-full-htt/description +Alternative ath10k firmware for QCA988X from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and fixes .11r authentication. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.1.php +This firmware selects and requires the ath10k-ct driver. +endef + +define Package/ath10k-firmware-qca99x0-ct/description +Alternative ath10k firmware for QCA99x0 from Candela Technologies. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware conflicts with the standard 99x0 firmware, so select only +one. +endef +define Package/ath10k-firmware-qca99x0-ct-full-htt/description +Alternative ath10k firmware for QCA99x0 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef +define Package/ath10k-firmware-qca99x0-ct-htt/description +Alternative ath10k firmware for QCA99x0 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +This firmware lacks a lot of features that ath10k does not use, saving +a lot of resources. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef + +define Package/ath10k-firmware-qca9984-ct/description +Alternative ath10k firmware for QCA9984 from Candela Technologies. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware conflicts with the standard 9984 firmware, so select only +one. +endef +define Package/ath10k-firmware-qca9984-ct-full-htt/description +Alternative ath10k firmware for QCA9984 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef +define Package/ath10k-firmware-qca9984-ct-htt/description +Alternative ath10k firmware for QCA9984 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +This firmware lacks a lot of features that ath10k does not use, saving +a lot of resources. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef + +define Package/ath10k-firmware-qca4019-ct/description +Alternative ath10k firmware for IPQ4019 radio from Candela Technologies. +Enables IBSS and other features. Works with standard or ath10k-ct driver. +See: http://www.candelatech.com/ath10k-10.4.php +endef +define Package/ath10k-firmware-qca4019-ct-full-htt/description +Alternative ath10k firmware for IPQ4019 radio from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +Enables IBSS and other features. +See: http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef +define Package/ath10k-firmware-qca4019-ct-htt/description +Alternative ath10k firmware for IPQ4019 radio from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +This firmware lacks a lot of features that ath10k does not use, saving +a lot of resources. +Enables IBSS and other features. +See: http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef + +define Package/ath10k-firmware-qca9888-ct/description +Alternative ath10k firmware for QCA9886 and QCA9888 from Candela Technologies. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware conflicts with the standard 9886 and 9888 firmware, so select only +one. +endef +define Package/ath10k-firmware-qca9888-ct-full-htt/description +Alternative ath10k firmware for QCA9886 and QCA9888 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef +define Package/ath10k-firmware-qca9888-ct-htt/description +Alternative ath10k firmware for QCA9886 and QCA9888 from Candela Technologies. +Uses normal HTT TX data path for management frames, which improves +stability in busy networks and may be required for .11r authentication. +This firmware lacks a lot of features that ath10k does not use, saving +a lot of resources. +Enables IBSS and other features. See: +http://www.candelatech.com/ath10k-10.4.php +This firmware selects and requires the ath10k-ct driver. +endef + + +define Build/Compile + +endef + + +define Package/ath10k-firmware-qca9887-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9887/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA9887) \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/firmware-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9887_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/board.bin +endef +define Package/ath10k-firmware-qca9887-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9887/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA9887) \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/ct-firmware-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9887_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/board.bin +endef + +define Package/ath10k-firmware-qca988x-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA988X_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA988X) \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/firmware-2.bin +endef +define Package/ath10k-firmware-qca988x-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA988X_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA988X) \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/ct-firmware-2.bin +endef + +define Package/ath10k-firmware-qca99x0-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA99X0/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA99X0) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/firmware-5.bin +endef +define Package/ath10k-firmware-qca99x0-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA99X0/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA99X0) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/ct-firmware-5.bin +endef +define Package/ath10k-firmware-qca99x0-ct-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA99X0/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_HTT,QCA99X0) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/ct-firmware-5.bin +endef + +define Package/ath10k-firmware-qca9984-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9984/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9984_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA9984) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/firmware-5.bin +endef +define Package/ath10k-firmware-qca9984-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9984/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9984_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA9984) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/ct-firmware-5.bin +endef +define Package/ath10k-firmware-qca9984-ct-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9984/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9984_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_HTT,QCA9984) \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/ct-firmware-5.bin +endef + +define Package/ath10k-firmware-qca4019-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA4019/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA4019_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA4019) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/firmware-5.bin +endef +define Package/ath10k-firmware-qca4019-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA4019/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA4019_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA4019) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/ct-firmware-5.bin +endef +define Package/ath10k-firmware-qca4019-ct-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA4019/hw1.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA4019_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_HTT,QCA4019) \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/ct-firmware-5.bin +endef + +define Package/ath10k-firmware-qca9888-ct/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9888/hw2.0 + ln -s \ + ../../cal-pci-0000:01:00.0.bin \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9888_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE,QCA9888) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/firmware-5.bin +endef +define Package/ath10k-firmware-qca9888-ct-full-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9888/hw2.0 + ln -s \ + ../../cal-pci-0000:01:00.0.bin \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9888_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_FULL_HTT,QCA9888) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/ct-firmware-5.bin +endef +define Package/ath10k-firmware-qca9888-ct-htt/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9888/hw2.0 + ln -s \ + ../../cal-pci-0000:01:00.0.bin \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA9888_BOARD2_FILE) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(DL_DIR)/$(call CT_FIRMWARE_FILE_HTT,QCA9888) \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/ct-firmware-5.bin +endef + + +$(eval $(call BuildPackage,ath10k-firmware-qca9887-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca9887-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca988x-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca988x-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca99x0-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca99x0-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca99x0-ct-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca9984-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca9984-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca9984-ct-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca4019-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca4019-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca4019-ct-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca9888-ct)) +$(eval $(call BuildPackage,ath10k-firmware-qca9888-ct-full-htt)) +$(eval $(call BuildPackage,ath10k-firmware-qca9888-ct-htt)) diff --git a/feeds/wifi-ath10k/ath10k-ct/Makefile b/feeds/wifi-ath10k/ath10k-ct/Makefile new file mode 100644 index 000000000..ba99b51fa --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/Makefile @@ -0,0 +1,121 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ath10k-ct +PKG_RELEASE=1 + +PKG_LICENSE:=GPLv2 +PKG_LICENSE_FILES:= + +PKG_SOURCE_URL:=https://github.com/greearb/ath10k-ct.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2021-05-22b +PKG_SOURCE_VERSION:=54a9ac02f1139596ea4361ebbc3e444955d86cfd +#PKG_MIRROR_HASH:=97cf22a4a57381c7eb7a9b8a8b1e347e9711ce51c89db971b4ab9a35af476ece + +# Build the 5.4 ath10k-ct driver version. Other option is "-4.19". +# Probably this should match as closely as +# possible to whatever mac80211 backports version is being used. +CT_KVER="-5.7" + +PKG_MAINTAINER:=Ben Greear +PKG_BUILD_PARALLEL:=1 +PKG_EXTMOD_SUBDIRS:=ath10k$(CT_KVER) + +STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ath10k-ct + SUBMENU:=Wireless Drivers + TITLE:=ath10k-ct driver optimized for CT ath10k firmware + DEPENDS:=+kmod-mac80211 +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11W_SUPPORT @PCI_SUPPORT +kmod-hwmon-core + FILES:=\ + $(PKG_BUILD_DIR)/ath10k$(CT_KVER)/ath10k_pci.ko \ + $(PKG_BUILD_DIR)/ath10k$(CT_KVER)/ath10k_core.ko + AUTOLOAD:=$(call AutoProbe,ath10k_pci) + PROVIDES:=kmod-ath10k + VARIANT:=regular +endef + +define KernelPackage/ath10k-ct/config + + config ATH10K-CT_LEDS + bool "Enable LED support" + default y + depends on PACKAGE_kmod-ath10k-ct || PACKAGE_kmod-ath10k-ct-smallbuffers +endef + +define KernelPackage/ath10k-ct-smallbuffers +$(call KernelPackage/ath10k-ct) + TITLE+= (small buffers for low-RAM devices) + VARIANT:=smallbuffers +endef + +NOSTDINC_FLAGS = \ + -I$(PKG_BUILD_DIR) \ + -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \ + -I$(STAGING_DIR)/usr/include/mac80211-backport \ + -I$(STAGING_DIR)/usr/include/mac80211/uapi \ + -I$(STAGING_DIR)/usr/include/mac80211 \ + -include backport/autoconf.h \ + -include backport/backport.h + +ifdef CONFIG_PACKAGE_MAC80211_MESH + NOSTDINC_FLAGS += -DCONFIG_MAC80211_MESH +endif + +CT_MAKEDEFS += CONFIG_ATH10K=m CONFIG_ATH10K_PCI=m CONFIG_ATH10K_CE=y + +# This AHB logic is needed for IPQ4019 radios +CT_MAKEDEFS += CONFIG_ATH10K_AHB=m +NOSTDINC_FLAGS += -DCONFIG_ATH10K_AHB + +NOSTDINC_FLAGS += -DSTANDALONE_CT + +ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS + CT_MAKEDEFS += CONFIG_ATH10K_DEBUGFS=y CONFIG_MAC80211_DEBUGFS=y + NOSTDINC_FLAGS += -DCONFIG_MAC80211_DEBUGFS + NOSTDINC_FLAGS += -DCONFIG_ATH10K_DEBUGFS +endif + +ifdef CONFIG_PACKAGE_ATH_DEBUG + NOSTDINC_FLAGS += -DCONFIG_ATH10K_DEBUG +endif + +ifdef CONFIG_PACKAGE_ATH_DFS + NOSTDINC_FLAGS += -DCONFIG_ATH10K_DFS_CERTIFIED +endif + +ifdef CONFIG_PACKAGE_ATH_SPECTRAL + CT_MAKEDEFS += CONFIG_ATH10K_SPECTRAL=y + NOSTDINC_FLAGS += -DCONFIG_ATH10K_SPECTRAL +endif + +ifeq ($(CONFIG_ATH10K-CT_LEDS),y) + CT_MAKEDEFS += CONFIG_ATH10K_LEDS=y + NOSTDINC_FLAGS += -DCONFIG_ATH10K_LEDS +endif + +ifeq ($(BUILD_VARIANT),smallbuffers) + NOSTDINC_FLAGS += -DCONFIG_ATH10K_SMALLBUFFERS +endif + +define Build/Configure + cp $(STAGING_DIR)/usr/include/mac80211/ath/*.h $(PKG_BUILD_DIR) +endef + +ifneq ($(findstring c,$(OPENWRT_VERBOSE)),) + CT_MAKEDEFS += V=1 +endif + +define Build/Compile + +$(MAKE) $(CT_MAKEDEFS) $(PKG_JOBS) -C "$(LINUX_DIR)" \ + $(KERNEL_MAKE_FLAGS) \ + M="$(PKG_BUILD_DIR)/ath10k$(CT_KVER)" \ + NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ + modules +endef + +$(eval $(call KernelPackage,ath10k-ct)) +$(eval $(call KernelPackage,ath10k-ct-smallbuffers)) diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/164-ath10k-commit-rates-from-mac80211.patch b/feeds/wifi-ath10k/ath10k-ct/patches/164-ath10k-commit-rates-from-mac80211.patch new file mode 100644 index 000000000..4e88c8a19 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/164-ath10k-commit-rates-from-mac80211.patch @@ -0,0 +1,37 @@ +From: Sven Eckelmann +Date: Tue, 26 Feb 2019 08:06:35 +0100 +Subject: ath10k-ct: apply mac80211 rates to ath10k-ct rate state + +The rates from mac80211 have to be copied to the state of ath10k-ct or +otherwise the ath10k_check_apply_special_rates function overwrites +them again with some default values. This breaks for example the +mcast_rate set for a wifi-iface. + +Signed-off-by: Sven Eckelmann + +--- a/ath10k-5.4/mac.c ++++ b/ath10k-5.4/mac.c +@@ -6793,6 +6793,7 @@ static void ath10k_bss_info_changed(stru + "mac vdev %d mcast_rate %x\n", + arvif->vdev_id, rate); + ++ arvif->mcast_rate[band] = rate; + vdev_param = ar->wmi.vdev_param->mcast_data_rate; + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, + vdev_param, rate); +@@ -6801,6 +6802,7 @@ static void ath10k_bss_info_changed(stru + "failed to set mcast rate on vdev %i: %d\n", + arvif->vdev_id, ret); + ++ arvif->bcast_rate[band] = rate; + vdev_param = ar->wmi.vdev_param->bcast_data_rate; + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, + vdev_param, rate); +@@ -6827,6 +6829,7 @@ static void ath10k_bss_info_changed(stru + return; + } + ++ arvif->mgt_rate[def.chan->band] = hw_rate_code; + vdev_param = ar->wmi.vdev_param->mgmt_rate; + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, + hw_rate_code); diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch b/feeds/wifi-ath10k/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch new file mode 100644 index 000000000..c20800209 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch @@ -0,0 +1,598 @@ +From: Sebastian Gottschall + +Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based +chipsets with on chipset connected led's using WMI Firmware API. The LED +device will get available named as "ath10k-phyX" at sysfs and can be controlled +with various triggers. adds also debugfs interface for gpio control. + +This patch is specific for OpenWRt base, as is use old backported package +with old wireless source. Support for QCA9984 is removed. +Reworked to use ath10k-ct custom source + + +Signed-off-by: Sebastian Gottschall +Reviewed-by: Steve deRosier +[kvalo: major reorg and cleanup] +Signed-off-by: Kalle Valo +Signed-off-by: Ansuel Smith +--- + +v13: + +* only compile tested! + +* fix all checkpatch warnings + +* fix commit log + +* sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio) + +* unsigned -> unsigned int + +* remove GPIOLIB code, that should be added in a separate patch + +* rename gpio.c to leds.c + +* add leds.h + +* rename some functions: + + ath10k_attach_led() -> ath10k_leds_register() + ath10k_unregister_led() -> ath10k_leds_unregister() + ath10k_reset_led_pin() -> ath10k_leds_start() + +* call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering + +* call ath10k_leds_start() only from ath10k_core_start() and not from mac.c + +* rename struct ath10k_gpiocontrol as anonymous function under struct + ath10k::leds, no need for memory allocation + +* merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller + +* remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it + +* Kconfig help text improvement and move it lower in the menu, also don't enable it by default + +* switch to set_brightness_blocking() so that the callback can sleep, + then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex + to access ar->state + +* don't touch ath10k_wmi_pdev_get_temperature() + +* as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface + +* remove debugfs interface, that should be added in another patch + +* cleanup includes + + ath10k-5.4/Kconfig | 10 +++ + ath10k-5.4/Makefile | 1 + + ath10k-5.4/core.c | 22 +++++++ + ath10k-5.4/core.h | 9 ++- + ath10k-5.4/hw.h | 1 + + ath10k-5.4/leds.c | 103 ++++++++++++++++++++++++++++++ + ath10k-5.4/leds.h | 45 +++++++++++++ + ath10k-5.4/mac.c | 1 + + ath10k-5.4/wmi-ops.h | 32 ++++++++++ + ath10k-5.4/wmi-tlv.c | 2 + + ath10k-5.4/wmi.c | 54 ++++++++++++++++ + ath10k-5.4/wmi.h | 35 ++++++++++ + 12 files changed, 314 insertions(+), 1 deletion(-) + create mode 100644 ath10k-5.4/leds.c + create mode 100644 ath10k-5.4/leds.h + +--- a/ath10k-5.4/Kconfig ++++ b/ath10k-5.4/Kconfig +@@ -66,6 +66,16 @@ config ATH10K_DEBUGFS + + If unsure, say Y to make it easier to debug problems. + ++config ATH10K_LEDS ++ bool "Atheros ath10k LED support" ++ depends on ATH10K ++ select MAC80211_LEDS ++ select LEDS_CLASS ++ select NEW_LEDS ++ default y ++ ---help--- ++ This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N. ++ + config ATH10K_SPECTRAL + bool "Atheros ath10k spectral scan support" + depends on ATH10K_DEBUGFS +--- a/ath10k-5.4/Makefile ++++ b/ath10k-5.4/Makefile +@@ -19,6 +19,7 @@ ath10k_core-$(CONFIG_ATH10K_SPECTRAL) += + ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o + ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o + ath10k_core-$(CONFIG_THERMAL) += thermal.o ++ath10k_core-$(CONFIG_ATH10K_LEDS) += leds.o + ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o + ath10k_core-$(CONFIG_PM) += wow.o + ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o +--- a/ath10k-5.4/core.c ++++ b/ath10k-5.4/core.c +@@ -25,6 +25,7 @@ + #include "testmode.h" + #include "wmi-ops.h" + #include "coredump.h" ++#include "leds.h" + + /* Disable ath10k-ct DBGLOG output by default */ + unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG; +@@ -67,6 +68,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA988X_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca988x hw2.0", ++ .led_pin = 1, + .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, +@@ -137,6 +139,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9887_1_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9887 hw1.0", ++ .led_pin = 1, + .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, +@@ -344,6 +347,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA99X0_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca99x0 hw2.0", ++ .led_pin = 17, + .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .otp_exe_param = 0x00000700, +@@ -385,6 +389,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9984_1_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9984/qca9994 hw1.0", ++ .led_pin = 17, + .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, +@@ -433,6 +438,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9888_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9888 hw2.0", ++ .led_pin = 17, + .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, +@@ -3573,6 +3579,10 @@ int ath10k_core_start(struct ath10k *ar, + ath10k_wmi_check_apply_board_power_ctl_table(ar); + } + ++ status = ath10k_leds_start(ar); ++ if (status) ++ goto err_hif_stop; ++ + return 0; + + err_hif_stop: +@@ -3829,9 +3839,18 @@ static void ath10k_core_register_work(st + goto err_spectral_destroy; + } + ++ status = ath10k_leds_register(ar); ++ if (status) { ++ ath10k_err(ar, "could not register leds: %d\n", ++ status); ++ goto err_thermal_unregister; ++ } ++ + set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags); + return; + ++err_thermal_unregister: ++ ath10k_thermal_unregister(ar); + err_spectral_destroy: + ath10k_spectral_destroy(ar); + err_debug_destroy: +@@ -3891,6 +3910,8 @@ void ath10k_core_unregister(struct ath10 + if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags)) + return; + ++ ath10k_leds_unregister(ar); ++ + ath10k_thermal_unregister(ar); + /* Stop spectral before unregistering from mac80211 to remove the + * relayfs debugfs file cleanly. Otherwise the parent debugfs tree +--- a/ath10k-5.4/core.h ++++ b/ath10k-5.4/core.h +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + #include "htt.h" + #include "htc.h" +@@ -1469,6 +1470,13 @@ struct ath10k { + } testmode; + + struct { ++ struct gpio_led wifi_led; ++ struct led_classdev cdev; ++ char label[48]; ++ u32 gpio_state_pin; ++ } leds; ++ ++ struct { + /* protected by data_lock */ + u32 fw_crash_counter; + u32 fw_warm_reset_counter; +--- a/ath10k-5.4/hw.h ++++ b/ath10k-5.4/hw.h +@@ -518,6 +518,7 @@ struct ath10k_hw_params { + const char *name; + u32 patch_load_addr; + int uart_pin; ++ int led_pin; + u32 otp_exe_param; + + /* Type of hw cycle counter wraparound logic, for more info +--- /dev/null ++++ b/ath10k-5.4/leds.c +@@ -0,0 +1,103 @@ ++/* ++ * Copyright (c) 2005-2011 Atheros Communications Inc. ++ * Copyright (c) 2011-2017 Qualcomm Atheros, Inc. ++ * Copyright (c) 2018 Sebastian Gottschall ++ * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++ ++#include "core.h" ++#include "wmi.h" ++#include "wmi-ops.h" ++ ++#include "leds.h" ++ ++static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev, ++ enum led_brightness brightness) ++{ ++ struct ath10k *ar = container_of(led_cdev, struct ath10k, ++ leds.cdev); ++ struct gpio_led *led = &ar->leds.wifi_led; ++ ++ mutex_lock(&ar->conf_mutex); ++ ++ if (ar->state != ATH10K_STATE_ON) ++ goto out; ++ ++ ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low; ++ ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin); ++ ++out: ++ mutex_unlock(&ar->conf_mutex); ++ ++ return 0; ++} ++ ++int ath10k_leds_start(struct ath10k *ar) ++{ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return 0; ++ ++ /* under some circumstances, the gpio pin gets reconfigured ++ * to default state by the firmware, so we need to ++ * reconfigure it this behaviour has only ben seen on ++ * QCA9984 and QCA99XX devices so far ++ */ ++ ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0, ++ WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE); ++ ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1); ++ ++ return 0; ++} ++ ++int ath10k_leds_register(struct ath10k *ar) ++{ ++ int ret; ++ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return 0; ++ ++ snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s", ++ wiphy_name(ar->hw->wiphy)); ++ ar->leds.wifi_led.active_low = 1; ++ ar->leds.wifi_led.gpio = ar->hw_params.led_pin; ++ ar->leds.wifi_led.name = ar->leds.label; ++ ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP; ++ ++ ar->leds.cdev.name = ar->leds.label; ++ ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking; ++ ++ /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */ ++ ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger; ++ ++ ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++void ath10k_leds_unregister(struct ath10k *ar) ++{ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return; ++ ++ led_classdev_unregister(&ar->leds.cdev); ++} ++ +--- /dev/null ++++ b/ath10k-5.4/leds.h +@@ -0,0 +1,41 @@ ++/* ++ * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++#ifndef _LEDS_H_ ++#define _LEDS_H_ ++ ++#include "core.h" ++ ++#ifdef CONFIG_ATH10K_LEDS ++void ath10k_leds_unregister(struct ath10k *ar); ++int ath10k_leds_start(struct ath10k *ar); ++int ath10k_leds_register(struct ath10k *ar); ++#else ++static inline void ath10k_leds_unregister(struct ath10k *ar) ++{ ++} ++ ++static inline int ath10k_leds_start(struct ath10k *ar) ++{ ++ return 0; ++} ++ ++static inline int ath10k_leds_register(struct ath10k *ar) ++{ ++ return 0; ++} ++ ++#endif ++#endif /* _LEDS_H_ */ +--- a/ath10k-5.4/mac.c ++++ b/ath10k-5.4/mac.c +@@ -24,6 +24,7 @@ + #include "wmi-tlv.h" + #include "wmi-ops.h" + #include "wow.h" ++#include "leds.h" + + /*********/ + /* Rates */ +--- a/ath10k-5.4/wmi-ops.h ++++ b/ath10k-5.4/wmi-ops.h +@@ -218,7 +218,10 @@ struct wmi_ops { + struct sk_buff *(*gen_bb_timing) + (struct ath10k *ar, + const struct wmi_bb_timing_cfg_arg *arg); ++ struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num, ++ u32 input, u32 pull_type, u32 intr_mode); + ++ struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set); + }; + + int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id); +@@ -1105,6 +1108,35 @@ ath10k_wmi_force_fw_hang(struct ath10k * + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); + } + ++static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num, ++ u32 input, u32 pull_type, u32 intr_mode) ++{ ++ struct sk_buff *skb; ++ ++ if (!ar->wmi.ops->gen_gpio_config) ++ return -EOPNOTSUPP; ++ ++ skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode); ++ if (IS_ERR(skb)) ++ return PTR_ERR(skb); ++ ++ return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid); ++} ++ ++static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set) ++{ ++ struct sk_buff *skb; ++ ++ if (!ar->wmi.ops->gen_gpio_config) ++ return -EOPNOTSUPP; ++ ++ skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set); ++ if (IS_ERR(skb)) ++ return PTR_ERR(skb); ++ ++ return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid); ++} ++ + static inline int + ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level) + { +--- a/ath10k-5.4/wmi-tlv.c ++++ b/ath10k-5.4/wmi-tlv.c +@@ -4364,6 +4364,8 @@ static const struct wmi_ops wmi_tlv_ops + .gen_echo = ath10k_wmi_tlv_op_gen_echo, + .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf, + .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable, ++ /* .gen_gpio_config not implemented */ ++ /* .gen_gpio_output not implemented */ + }; + + static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = { +--- a/ath10k-5.4/wmi.c ++++ b/ath10k-5.4/wmi.c +@@ -8295,6 +8295,49 @@ ath10k_wmi_op_gen_peer_set_param(struct + return skb; + } + ++static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar, ++ u32 gpio_num, u32 input, ++ u32 pull_type, u32 intr_mode) ++{ ++ struct wmi_gpio_config_cmd *cmd; ++ struct sk_buff *skb; ++ ++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); ++ if (!skb) ++ return ERR_PTR(-ENOMEM); ++ ++ cmd = (struct wmi_gpio_config_cmd *)skb->data; ++ cmd->pull_type = __cpu_to_le32(pull_type); ++ cmd->gpio_num = __cpu_to_le32(gpio_num); ++ cmd->input = __cpu_to_le32(input); ++ cmd->intr_mode = __cpu_to_le32(intr_mode); ++ ++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_config gpio_num 0x%08x input 0x%08x pull_type 0x%08x intr_mode 0x%08x\n", ++ gpio_num, input, pull_type, intr_mode); ++ ++ return skb; ++} ++ ++static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar, ++ u32 gpio_num, u32 set) ++{ ++ struct wmi_gpio_output_cmd *cmd; ++ struct sk_buff *skb; ++ ++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); ++ if (!skb) ++ return ERR_PTR(-ENOMEM); ++ ++ cmd = (struct wmi_gpio_output_cmd *)skb->data; ++ cmd->gpio_num = __cpu_to_le32(gpio_num); ++ cmd->set = __cpu_to_le32(set); ++ ++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n", ++ gpio_num, set); ++ ++ return skb; ++} ++ + static struct sk_buff * + ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id, + enum wmi_sta_ps_mode psmode) +@@ -10094,6 +10137,9 @@ static const struct wmi_ops wmi_ops = { + .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, + .gen_echo = ath10k_wmi_op_gen_echo, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, ++ + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -10164,6 +10210,8 @@ static const struct wmi_ops wmi_10_1_ops + .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, + .gen_echo = ath10k_wmi_op_gen_echo, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -10243,6 +10291,8 @@ static const struct wmi_ops wmi_10_2_ops + .gen_delba_send = ath10k_wmi_op_gen_delba_send, + .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_pdev_enable_adaptive_cca not implemented */ + }; + +@@ -10314,6 +10364,8 @@ static const struct wmi_ops wmi_10_2_4_o + ath10k_wmi_op_gen_pdev_enable_adaptive_cca, + .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype, + .gen_bb_timing = ath10k_wmi_10_2_4_op_gen_bb_timing, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -10395,6 +10447,8 @@ static const struct wmi_ops wmi_10_4_ops + .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info, + .gen_echo = ath10k_wmi_op_gen_echo, + .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + }; + + int ath10k_wmi_attach(struct ath10k *ar) +--- a/ath10k-5.4/wmi.h ++++ b/ath10k-5.4/wmi.h +@@ -3110,6 +3110,41 @@ enum wmi_10_4_feature_mask { + + }; + ++/* WMI_GPIO_CONFIG_CMDID */ ++enum { ++ WMI_GPIO_PULL_NONE, ++ WMI_GPIO_PULL_UP, ++ WMI_GPIO_PULL_DOWN, ++}; ++ ++enum { ++ WMI_GPIO_INTTYPE_DISABLE, ++ WMI_GPIO_INTTYPE_RISING_EDGE, ++ WMI_GPIO_INTTYPE_FALLING_EDGE, ++ WMI_GPIO_INTTYPE_BOTH_EDGE, ++ WMI_GPIO_INTTYPE_LEVEL_LOW, ++ WMI_GPIO_INTTYPE_LEVEL_HIGH ++}; ++ ++/* WMI_GPIO_CONFIG_CMDID */ ++struct wmi_gpio_config_cmd { ++ __le32 gpio_num; /* GPIO number to be setup */ ++ __le32 input; /* 0 - Output/ 1 - Input */ ++ __le32 pull_type; /* Pull type defined above */ ++ __le32 intr_mode; /* Interrupt mode defined above (Input) */ ++} __packed; ++ ++/* WMI_GPIO_OUTPUT_CMDID */ ++struct wmi_gpio_output_cmd { ++ __le32 gpio_num; /* GPIO number to be setup */ ++ __le32 set; /* Set the GPIO pin*/ ++} __packed; ++ ++/* WMI_GPIO_INPUT_EVENTID */ ++struct wmi_gpio_input_event { ++ __le32 gpio_num; /* GPIO number which changed state */ ++} __packed; ++ + struct wmi_ext_resource_config_10_4_cmd { + /* contains enum wmi_host_platform_type */ + __le32 host_platform_config; diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch b/feeds/wifi-ath10k/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch new file mode 100644 index 000000000..b1c7bae19 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch @@ -0,0 +1,53 @@ +From 79c9d7aabae1d1da9eea97d83b61e1517a8a2221 Mon Sep 17 00:00:00 2001 +From: Mathias Kresin +Date: Fri, 22 Jun 2018 18:59:44 +0200 +Subject: [PATCH] ath10k: use tpt LED trigger by default + +Use the tpt LED trigger for each created phy led. Ths way LEDs attached +to the ath10k GPIO pins are indicating the phy status and blink on +traffic. + +Signed-off-by: Mathias Kresin +--- + ath10k-5.4/core.h | 4 ++++ + ath10k-5.4/leds.c | 4 +--- + ath10k-5.4/mac.c | 2 +- + 3 files changed, 6 insertions(+), 4 deletions(-) + +--- a/ath10k-5.4/core.h ++++ b/ath10k-5.4/core.h +@@ -1573,6 +1573,10 @@ struct ath10k { + u8 csi_data[4096]; + u16 csi_data_len; + ++#ifdef CPTCFG_MAC80211_LEDS ++ const char *led_default_trigger; ++#endif ++ + /* must be last */ + u8 drv_priv[0] __aligned(sizeof(void *)); + }; +--- a/ath10k-5.4/leds.c ++++ b/ath10k-5.4/leds.c +@@ -81,9 +81,7 @@ int ath10k_leds_register(struct ath10k * + + ar->leds.cdev.name = ar->leds.label; + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking; +- +- /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */ +- ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger; ++ ar->leds.cdev.default_trigger = ar->led_default_trigger; + + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev); + if (ret) +--- a/ath10k-5.4/mac.c ++++ b/ath10k-5.4/mac.c +@@ -10367,7 +10367,7 @@ int ath10k_mac_register(struct ath10k *a + ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; + + #ifdef CPTCFG_MAC80211_LEDS +- ieee80211_create_tpt_led_trigger(ar->hw, ++ ar->led_default_trigger = ieee80211_create_tpt_led_trigger(ar->hw, + IEEE80211_TPT_LEDTRIG_FL_RADIO, ath10k_tpt_blink, + ARRAY_SIZE(ath10k_tpt_blink)); + #endif diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/205-ath10k-Add-NL80211_EXT_FEATURE_AQL-flag.patch b/feeds/wifi-ath10k/ath10k-ct/patches/205-ath10k-Add-NL80211_EXT_FEATURE_AQL-flag.patch new file mode 100644 index 000000000..41b917089 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/205-ath10k-Add-NL80211_EXT_FEATURE_AQL-flag.patch @@ -0,0 +1,10 @@ +--- a/ath10k-5.4/mac.c ++++ b/ath10k-5.4/mac.c +@@ -10180,6 +10180,7 @@ int ath10k_mac_register(struct ath10k *a + wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS); + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_SET_SCAN_DWELL); ++ wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_AQL); + + if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map) || + test_bit(WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS, ar->wmi.svc_map)) diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch b/feeds/wifi-ath10k/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch new file mode 100644 index 000000000..c52743089 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch @@ -0,0 +1,14 @@ +--- a/ath10k-5.4/htt.h ++++ b/ath10k-5.4/htt.h +@@ -225,7 +225,11 @@ enum htt_rx_ring_flags { + }; + + #define HTT_RX_RING_SIZE_MIN 128 ++#ifndef CONFIG_ATH10K_SMALLBUFFERS + #define HTT_RX_RING_SIZE_MAX 2048 ++#else ++#define HTT_RX_RING_SIZE_MAX 512 ++#endif + #define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX + #define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1) + #define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1) diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch b/feeds/wifi-ath10k/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch new file mode 100644 index 000000000..f559a78f2 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch @@ -0,0 +1,50 @@ +--- a/ath10k-5.4/pci.c ++++ b/ath10k-5.4/pci.c +@@ -131,7 +131,11 @@ static struct ce_attr host_ce_config_wla + .flags = CE_ATTR_FLAGS, + .src_nentries = 0, + .src_sz_max = 2048, ++#ifndef CONFIG_ATH10K_SMALLBUFFERS + .dest_nentries = 512, ++#else ++ .dest_nentries = 128, ++#endif + .recv_cb = ath10k_pci_htt_htc_rx_cb, + }, + +@@ -140,7 +144,11 @@ static struct ce_attr host_ce_config_wla + .flags = CE_ATTR_FLAGS, + .src_nentries = 0, + .src_sz_max = 2048, ++#ifndef CONFIG_ATH10K_SMALLBUFFERS + .dest_nentries = 128, ++#else ++ .dest_nentries = 64, ++#endif + .recv_cb = ath10k_pci_htc_rx_cb, + }, + +@@ -167,7 +175,11 @@ static struct ce_attr host_ce_config_wla + .flags = CE_ATTR_FLAGS, + .src_nentries = 0, + .src_sz_max = 512, ++#ifndef CONFIG_ATH10K_SMALLBUFFERS + .dest_nentries = 512, ++#else ++ .dest_nentries = 128, ++#endif + .recv_cb = ath10k_pci_htt_rx_cb, + }, + +@@ -192,7 +204,11 @@ static struct ce_attr host_ce_config_wla + .flags = CE_ATTR_FLAGS, + .src_nentries = 0, + .src_sz_max = 2048, ++#ifndef CONFIG_ATH10K_SMALLBUFFERS + .dest_nentries = 128, ++#else ++ .dest_nentries = 96, ++#endif + .recv_cb = ath10k_pci_pktlog_rx_cb, + }, + diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/960-0012-ath10k-add_cmd_processing_time_for_scan_timeout.patch b/feeds/wifi-ath10k/ath10k-ct/patches/960-0012-ath10k-add_cmd_processing_time_for_scan_timeout.patch new file mode 100644 index 000000000..9a2118167 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/960-0012-ath10k-add_cmd_processing_time_for_scan_timeout.patch @@ -0,0 +1,22 @@ +diff -Naur a/ath10k-5.7/mac.c b/ath10k-5.7/mac.c +--- a/ath10k-5.7/mac.c 2021-06-09 16:30:17.793556032 -0400 ++++ b/ath10k-5.7/mac.c 2021-06-09 17:38:08.587733979 -0400 +@@ -7103,13 +7103,15 @@ + scan_timeout = min_t(u32, arg.max_rest_time * + (arg.n_channels - 1) + (req->duration + + ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) * +- arg.n_channels, arg.max_scan_time + 200); ++ arg.n_channels, arg.max_scan_time); + + } else { +- /* Add a 200ms margin to account for event/command processing */ +- scan_timeout = arg.max_scan_time + 200; ++ scan_timeout = arg.max_scan_time; + } + ++ /* Add a 200ms margin to account for event/command processing */ ++ scan_timeout += 200; ++ + ret = ath10k_start_scan(ar, &arg); + if (ret) { + ath10k_warn(ar, "failed to start hw scan: %d\n", ret); diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/970-accumulate-survey-info-data b/feeds/wifi-ath10k/ath10k-ct/patches/970-accumulate-survey-info-data new file mode 100644 index 000000000..615d3e126 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/970-accumulate-survey-info-data @@ -0,0 +1,11 @@ +--- a/ath10k-5.7/mac.c 2021-07-06 11:12:56.022146449 -0700 ++++ b/ath10k-5.7/mac.c 2021-07-06 19:37:52.352753693 -0700 +@@ -8286,7 +8286,7 @@ + struct ieee80211_channel *channel) + { + int ret; +- enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR; ++ enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ; + + lockdep_assert_held(&ar->conf_mutex); + diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/970-add-survey-local-bss-receive-time b/feeds/wifi-ath10k/ath10k-ct/patches/970-add-survey-local-bss-receive-time new file mode 100644 index 000000000..c400445fd --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/970-add-survey-local-bss-receive-time @@ -0,0 +1,31 @@ +--- a/ath10k-5.7/wmi.c ++++ b/ath10k-5.7/wmi.c +@@ -6347,16 +6347,18 @@ + + survey = &ar->survey[idx]; + +- survey->noise = noise_floor; +- survey->time = div_u64(total, cc_freq_hz); +- survey->time_busy = div_u64(busy, cc_freq_hz); +- survey->time_rx = div_u64(rx_bss, cc_freq_hz); +- survey->time_tx = div_u64(tx, cc_freq_hz); +- survey->filled |= (SURVEY_INFO_NOISE_DBM | +- SURVEY_INFO_TIME | +- SURVEY_INFO_TIME_BUSY | +- SURVEY_INFO_TIME_RX | +- SURVEY_INFO_TIME_TX); ++ survey->noise = noise_floor; ++ survey->time = div_u64(total, cc_freq_hz); ++ survey->time_busy = div_u64(busy, cc_freq_hz); ++ survey->time_rx = div_u64(rx, cc_freq_hz); ++ survey->time_bss_rx = div_u64(rx_bss, cc_freq_hz); ++ survey->time_tx = div_u64(tx, cc_freq_hz); ++ survey->filled |= (SURVEY_INFO_NOISE_DBM | ++ SURVEY_INFO_TIME | ++ SURVEY_INFO_TIME_BUSY | ++ SURVEY_INFO_TIME_RX | ++ SURVEY_INFO_TIME_TX | ++ SURVEY_INFO_TIME_BSS_RX); + exit: + spin_unlock_bh(&ar->data_lock); + complete(&ar->bss_survey_done); diff --git a/feeds/wifi-ath10k/ath10k-ct/patches/999-ath10k-threading.patch b/feeds/wifi-ath10k/ath10k-ct/patches/999-ath10k-threading.patch new file mode 100644 index 000000000..4bcb84cf5 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-ct/patches/999-ath10k-threading.patch @@ -0,0 +1,14 @@ +Index: ath10k-ct-2021-05-22b-54a9ac02/ath10k-5.7/core.c +=================================================================== +--- ath10k-ct-2021-05-22b-54a9ac02.orig/ath10k-5.7/core.c ++++ ath10k-ct-2021-05-22b-54a9ac02/ath10k-5.7/core.c +@@ -4146,6 +4146,9 @@ struct ath10k *ath10k_core_create(size_t + INIT_WORK(&ar->stop_scan_work, ath10k_wmi_stop_scan_work); + + init_dummy_netdev(&ar->napi_dev); ++ snprintf(ar->napi_dev.name, sizeof(ar->napi_dev.name), "%s", ++ wiphy_name(ar->hw->wiphy)); ++ ar->napi_dev.threaded = 1; + + ret = ath10k_coredump_create(ar); + if (ret) diff --git a/feeds/wifi-ath10k/ath10k-firmware/Makefile b/feeds/wifi-ath10k/ath10k-firmware/Makefile new file mode 100644 index 000000000..c427f0884 --- /dev/null +++ b/feeds/wifi-ath10k/ath10k-firmware/Makefile @@ -0,0 +1,182 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=ath10k-firmware +PKG_SOURCE_DATE:=2019-10-03 +PKG_SOURCE_VERSION:=d622d160e9f552ead68d9ae81b715422892dc2ef +PKG_MIRROR_HASH:=2e504e071c3f896d629c4cfffe7ff4b5f1acdb4fecd3f01e8ff8c73e87a67cc7 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/kvalo/ath10k-firmware.git + +PKG_MAINTAINER:=Felix Fietkau + +include $(INCLUDE_DIR)/package.mk + +define Package/ath10k-firmware-default + SECTION:=firmware + CATEGORY:=Firmware + URL:=$(PKG_SOURCE_URL) + DEPENDS:= +endef + +define Package/ath10k-firmware-qca9887 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA9887 devices +endef + +define Package/ath10k-firmware-qca9888 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA9888 devices +endef + +define Package/ath10k-firmware-qca988x +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA988x devices + SECTION:=firmware + CATEGORY:=Firmware +endef + +define Package/ath10k-firmware-qca99x0 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA99x0 devices + SECTION:=firmware + CATEGORY:=Firmware +endef + +define Package/ath10k-firmware-qca99x0/description +Standard ath10k firmware for QCA99x0 from QCA +This firmware conflicts with the CT 99x0 firmware, so select only +one. +endef + +define Package/ath10k-firmware-qca9984 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA9984 devices + SECTION:=firmware + CATEGORY:=Firmware +endef + +define Package/ath10k-firmware-qca4019 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for IPQ/QCA4019 devices + SECTION:=firmware + CATEGORY:=Firmware +endef + +define Package/ath10k-firmware-qca6174 +$(Package/ath10k-firmware-default) + TITLE:=ath10k firmware for QCA6174 devices + SECTION:=firmware + CATEGORY:=Firmware +endef + +QCA99X0_BOARD_REV:=ddcec9efd245da9365c474f513a855a55f3ac7fe +QCA99X0_BOARD_FILE:=board-2.bin.$(QCA99X0_BOARD_REV) + +define Download/qca99x0-board + URL:=https://source.codeaurora.org/quic/qsdk/oss/firmware/ath10k-firmware/plain/ath10k/QCA99X0/hw2.0 + URL_FILE:=board-2.bin?id=$(QCA99X0_BOARD_REV) + FILE:=$(QCA99X0_BOARD_FILE) + HASH:=03711ac21e60ef59d3815e235eb721c0c22851b5410299411085aa6f2af45401 +endef +$(eval $(call Download,qca99x0-board)) + +define Build/Compile + +endef + +define Package/ath10k-firmware-qca4019/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA4019/hw1.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA4019/hw1.0/board-2.bin \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA4019/hw1.0/3.5.3/firmware-5.bin_10.4-3.5.3-00057 \ + $(1)/lib/firmware/ath10k/QCA4019/hw1.0/firmware-5.bin +endef + +define Package/ath10k-firmware-qca9887/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9887/hw1.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9887/hw1.0/10.2.4-1.0/firmware-5.bin_10.2.4-1.0-00047 \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/firmware-5.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9887/hw1.0/board.bin \ + $(1)/lib/firmware/ath10k/QCA9887/hw1.0/board.bin +endef + +define Package/ath10k-firmware-qca9888/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9888/hw2.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9888/hw2.0/board-2.bin \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9888/hw2.0/3.5.3/firmware-5.bin_10.4-3.5.3-00053 \ + $(1)/lib/firmware/ath10k/QCA9888/hw2.0/firmware-5.bin +endef + +define Package/ath10k-firmware-qca988x/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA988X/hw2.0/board.bin \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA988X/hw2.0/10.2.4-1.0/firmware-5.bin_10.2.4-1.0-00047 \ + $(1)/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin +endef + +define Package/ath10k-firmware-qca6174/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA6174/hw2.1 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA6174/hw2.1/board-2.bin \ + $(1)/lib/firmware/ath10k/QCA6174/hw2.1/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA6174/hw2.1/firmware-5.bin_SW_RM.1.1.1-00157-QCARMSWPZ-1 \ + $(1)/lib/firmware/ath10k/QCA6174/hw2.1/firmware-5.bin + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA6174/hw3.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA6174/hw3.0/board-2.bin \ + $(1)/lib/firmware/ath10k/QCA6174/hw3.0/ + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA6174/hw3.0/4.4.1.c1/firmware-6.bin_RM.4.4.1.c1-00042-QCARMSWP-1 \ + $(1)/lib/firmware/ath10k/QCA6174/hw3.0/firmware-6.bin +endef + +define Package/ath10k-firmware-qca99x0/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA99X0/hw2.0 + $(INSTALL_DATA) \ + $(DL_DIR)/$(QCA99X0_BOARD_FILE) \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board-2.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA99X0/hw2.0/boardData_AR900B_CUS239_5G_v2_001.bin \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/board.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA99X0/hw2.0/firmware-5.bin_10.4.1.00030-1 \ + $(1)/lib/firmware/ath10k/QCA99X0/hw2.0/firmware-5.bin +endef + +define Package/ath10k-firmware-qca9984/install + $(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA9984/hw1.0 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9984/hw1.0/board-2.bin \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/board-2.bin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/QCA9984/hw1.0/3.5.3/firmware-5.bin_10.4-3.5.3-00053 \ + $(1)/lib/firmware/ath10k/QCA9984/hw1.0/firmware-5.bin +endef + +$(eval $(call BuildPackage,ath10k-firmware-qca9887)) +#$(eval $(call BuildPackage,ath10k-firmware-qca9888)) +$(eval $(call BuildPackage,ath10k-firmware-qca988x)) +#$(eval $(call BuildPackage,ath10k-firmware-qca99x0)) +#$(eval $(call BuildPackage,ath10k-firmware-qca6174)) +#$(eval $(call BuildPackage,ath10k-firmware-qca9984)) +#$(eval $(call BuildPackage,ath10k-firmware-qca4019)) diff --git a/feeds/wifi-ath10k/batctl/Makefile b/feeds/wifi-ath10k/batctl/Makefile new file mode 100644 index 000000000..895e9ea67 --- /dev/null +++ b/feeds/wifi-ath10k/batctl/Makefile @@ -0,0 +1,231 @@ +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk + +PKG_NAME:=batctl +PKG_VERSION:=2020.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) +PKG_HASH:=d29cdb53ee68abd5027eae07d9fd645b3f154e0d577efa2666c1334bb6d60efd +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_MAINTAINER:=Simon Wunderlich +PKG_LICENSE:=GPL-2.0-only ISC MIT +PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT LICENSES/deprecated/ISC + +include $(INCLUDE_DIR)/package.mk + +define Package/batctl/Default + SECTION:=net + CATEGORY:=Network + URL:=https://www.open-mesh.org/ + DEPENDS:=+libnl-tiny +libc +librt + PROVIDES:=batctl +endef + +define Package/batctl/description + batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced. + It is an easier method for configuring batman-adv and provides some + additional tools for debugging as well. This package builds + version $(PKG_VERSION) of the user space utility. +endef + +define Package/batctl-tiny +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Minimal) + VARIANT:=tiny + ALTERNATIVES:=100:/usr/sbin/batctl:/usr/libexec/batctl-tiny +endef + +define Package/batctl-tiny/description +$(Package/batctl/description) + Only configuration relevant subcommands are enabled. +endef + +define Package/batctl-default +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Default) + VARIANT:=default + ALTERNATIVES:=200:/usr/sbin/batctl:/usr/libexec/batctl-default +endef + +define Package/batctl-default/description +$(Package/batctl/description) + Standard subcommands for configuration and online debugging are enabled. +endef + +define Package/batctl-full +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Full) + VARIANT:=full + ALTERNATIVES:=300:/usr/sbin/batctl:/usr/libexec/batctl-full +endef + +define Package/batctl-full/description +$(Package/batctl/description) + Subcommands for configuration, online and offline debugging are enabled. +endef + +# The linker can identify unused sections of a binary when each symbol is stored +# in a separate section. This mostly removes unused linker sections and reduces +# the size by ~3% on mipsel. + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +# Link-time optimization allows to move parts of the optimization from the single +# source file to the global source view. This is done by emitting the GIMPLE +# representation in each object file and analyzing it again during the link step. + +TARGET_CFLAGS += -flto +TARGET_LDFLAGS += -fuse-linker-plugin + +MAKE_VARS += \ + LIBNL_NAME="libnl-tiny" \ + LIBNL_GENL_NAME="libnl-tiny" + +MAKE_FLAGS += \ + REVISION="$(PKG_VERSION)-openwrt-$(PKG_RELEASE)" + +config-n := \ + aggregation \ + ap_isolation \ + backbonetable \ + bisect_iv \ + bonding \ + bridge_loop_avoidance \ + claimtable \ + dat_cache \ + distributed_arp_table \ + elp_interval \ + event \ + fragmentation \ + gateways \ + gw_mode \ + hop_penalty \ + interface \ + isolation_mark \ + loglevel \ + mcast_flags \ + multicast_fanout \ + multicast_forceflood \ + multicast_mode \ + nc_nodes \ + neighbors \ + network_coding \ + orig_interval \ + originators \ + ping \ + routing_algo \ + statistics \ + tcpdump \ + throughput_override \ + throughputmeter \ + traceroute \ + transglobal \ + translate \ + translocal \ + +config-settings := \ + aggregation \ + ap_isolation \ + bonding \ + bridge_loop_avoidance \ + distributed_arp_table \ + elp_interval \ + fragmentation \ + gw_mode \ + hop_penalty \ + interface \ + isolation_mark \ + loglevel \ + multicast_fanout \ + multicast_forceflood \ + multicast_mode \ + network_coding \ + orig_interval \ + routing_algo \ + throughput_override \ + +config-tables := \ + backbonetable \ + claimtable \ + dat_cache \ + gateways \ + loglevel \ + nc_nodes \ + neighbors \ + originators \ + statistics \ + transglobal \ + translocal \ + +config-tools := \ + event \ + ping \ + tcpdump \ + throughputmeter \ + traceroute \ + translate \ + +config-extratools := \ + bisect_iv \ + +ifeq ($(BUILD_VARIANT),tiny) + +config-y := \ + $(config-settings) \ + +endif + +ifeq ($(BUILD_VARIANT),default) + +config-y := \ + $(config-settings) \ + $(config-tables) \ + $(config-tools) \ + +endif + +ifeq ($(BUILD_VARIANT),full) + +config-y := \ + $(config-settings) \ + $(config-tables) \ + $(config-tools) \ + $(config-extratools) \ + +endif + +define ConfigVars +$(subst $(space),,$(foreach opt,$(config-$(1)),CONFIG_$(opt)=$(1) +)) +endef + +define batctl_config +$(call ConfigVars,n)$(call ConfigVars,y) +endef +$(eval $(call shexport,batctl_config)) + +MAKE_FLAGS += $$$$$(call shvar,batctl_config) + +define Package/batctl-tiny/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-tiny +endef + +define Package/batctl-default/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-default +endef + +define Package/batctl-full/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-full +endef + +$(eval $(call BuildPackage,batctl-default)) +$(eval $(call BuildPackage,batctl-tiny)) +$(eval $(call BuildPackage,batctl-full)) diff --git a/feeds/wifi-ath10k/batman-adv/Config.in b/feeds/wifi-ath10k/batman-adv/Config.in new file mode 100644 index 000000000..70cc48ffe --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/Config.in @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2007-2019 B.A.T.M.A.N. contributors: +# +# Marek Lindner, Simon Wunderlich + +# +# B.A.T.M.A.N meshing protocol +# + +config BATMAN_ADV_BATMAN_V + bool "B.A.T.M.A.N. V protocol" + depends on PACKAGE_kmod-batman-adv + default y + help + This option enables the B.A.T.M.A.N. V protocol, the successor + of the currently used B.A.T.M.A.N. IV protocol. The main + changes include splitting of the OGM protocol into a neighbor + discovery protocol (Echo Location Protocol, ELP) and a new OGM + Protocol OGMv2 for flooding protocol information through the + network, as well as a throughput based metric. + B.A.T.M.A.N. V is currently considered experimental and not + compatible to B.A.T.M.A.N. IV networks. + +config BATMAN_ADV_BLA + bool "Bridge Loop Avoidance" + depends on PACKAGE_kmod-batman-adv + select PACKAGE_kmod-lib-crc16 + default y + help + This option enables BLA (Bridge Loop Avoidance), a mechanism + to avoid Ethernet frames looping when mesh nodes are connected + to both the same LAN and the same mesh. If you will never use + more than one mesh node in the same LAN, you can safely remove + this feature and save some space. + +config BATMAN_ADV_DAT + bool "Distributed ARP Table" + depends on PACKAGE_kmod-batman-adv + default y + help + This option enables DAT (Distributed ARP Table), a DHT based + mechanism that increases ARP reliability on sparse wireless + mesh networks. If you think that your network does not need + this option you can safely remove it and save some space. + +config BATMAN_ADV_NC + bool "Network Coding" + depends on PACKAGE_kmod-batman-adv + help + This option enables network coding, a mechanism that aims to + increase the overall network throughput by fusing multiple + packets in one transmission. + Note that interfaces controlled by batman-adv must be manually + configured to have promiscuous mode enabled in order to make + network coding work. + If you think that your network does not need this feature you + can safely disable it and save some space. + +config BATMAN_ADV_MCAST + bool "Multicast optimisation" + depends on PACKAGE_kmod-batman-adv + default y + help + This option enables the multicast optimisation which aims to + reduce the air overhead while improving the reliability of + multicast messages. + +config BATMAN_ADV_DEBUGFS + bool "batman-adv debugfs entries" + depends on PACKAGE_kmod-batman-adv + select KERNEL_DEBUG_FS + help + Enable this to export routing related debug tables via debugfs. + The information for each soft-interface and used hard-interface can be + found under batman_adv/ + + If unsure, say N. + +config BATMAN_ADV_DEBUG + bool "B.A.T.M.A.N. debugging" + depends on PACKAGE_kmod-batman-adv + help + This is an option for use by developers; most people should + say N here. This enables compilation of support for + outputting debugging information to the debugfs log or tracing + buffer. The output is controlled via the batadv netdev specific + log_level setting. + +config BATMAN_ADV_SYSFS + bool "batman-adv sysfs entries" + depends on PACKAGE_kmod-batman-adv + help + Say Y here if you want to enable batman-adv device configuration and + status interface through sysfs attributes. It is replaced by the + batadv generic netlink family but still used by various userspace + tools and scripts. + + If unsure, say Y. + +config BATMAN_ADV_TRACING + bool "B.A.T.M.A.N. tracing support" + depends on PACKAGE_kmod-batman-adv + select KERNEL_FTRACE + select KERNEL_ENABLE_DEFAULT_TRACERS + help + This is an option for use by developers; most people should + say N here. Select this option to gather traces like the debug + messages using the generic tracing infrastructure of the kernel. + BATMAN_ADV_DEBUG must also be selected to get trace events for + batadv_dbg. diff --git a/feeds/wifi-ath10k/batman-adv/Makefile b/feeds/wifi-ath10k/batman-adv/Makefile new file mode 100644 index 000000000..5813b0585 --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/Makefile @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk + +PKG_NAME:=batman-adv +PKG_VERSION:=2020.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) +PKG_HASH:=a73f5ce72c6efa9dd7bd7cc8daa667d0982e12e40811c978bb652607bb5666a3 +PKG_EXTMOD_SUBDIRS:=net/batman-adv + +PKG_MAINTAINER:=Simon Wunderlich +PKG_LICENSE:=GPL-2.0-only MIT +PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT + +STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/batman-adv + SUBMENU:=Network Support + TITLE:=B.A.T.M.A.N. Adv + URL:=https://www.open-mesh.org/ + DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl + FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoProbe,batman-adv) +endef + +define KernelPackage/batman-adv/description + B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is + a routing protocol for multi-hop ad-hoc mesh networks. The + networks may be wired or wireless. See + https://www.open-mesh.org/ for more information and user space + tools. This package builds version $(PKG_VERSION) of the kernel + module. +endef + +define KernelPackage/batman-adv/config + source "$(SOURCE)/Config.in" +endef + +define Package/kmod-batman-adv/conffiles +/etc/config/batman-adv +endef + +PKG_EXTRA_KCONFIG:= \ + CONFIG_BATMAN_ADV=m \ + CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_BATMAN_ADV_DEBUG),y,n) \ + CONFIG_BATMAN_ADV_DEBUGFS=$(if $(CONFIG_BATMAN_ADV_DEBUGFS),y,n) \ + CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_BATMAN_ADV_BLA),y,n) \ + CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_BATMAN_ADV_DAT),y,n) \ + CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_BATMAN_ADV_MCAST),y,n) \ + CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_BATMAN_ADV_NC),y,n) \ + CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_BATMAN_ADV_BATMAN_V),y,n) \ + CONFIG_BATMAN_ADV_SYSFS=$(if $(CONFIG_BATMAN_ADV_SYSFS),y,n) \ + CONFIG_BATMAN_ADV_TRACING=$(if $(CONFIG_BATMAN_ADV_TRACING),y,n) \ + +PKG_EXTRA_CFLAGS:= \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \ + +NOSTDINC_FLAGS = \ + -I$(PKG_BUILD_DIR)/net/batman-adv \ + -I$(STAGING_DIR)/usr/include/mac80211-backport \ + -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \ + -I$(STAGING_DIR)/usr/include/mac80211 \ + -I$(STAGING_DIR)/usr/include/mac80211/uapi \ + -I$(PKG_BUILD_DIR)/include/ \ + -include backport/autoconf.h \ + -include backport/backport.h \ + -include $(PKG_BUILD_DIR)/compat-hacks.h \ + -DBATADV_SOURCE_VERSION=\\\"$(PKG_VERSION)-openwrt-$(PKG_RELEASE)\\\" + +define Build/Compile + $(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ + $(KERNEL_MAKE_FLAGS) \ + M="$(PKG_BUILD_DIR)/net/batman-adv" \ + $(PKG_EXTRA_KCONFIG) \ + EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \ + NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ + modules +endef + +define KernelPackage/batman-adv/install + $(CP) ./files/. $(1)/ +endef + +$(eval $(call KernelPackage,batman-adv)) diff --git a/feeds/wifi-ath10k/batman-adv/files/etc/uci-defaults/99-migrate-batadv_hardif b/feeds/wifi-ath10k/batman-adv/files/etc/uci-defaults/99-migrate-batadv_hardif new file mode 100755 index 000000000..258b7bd6a --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/files/etc/uci-defaults/99-migrate-batadv_hardif @@ -0,0 +1,97 @@ +#!/bin/sh + +# This UCI-Defaults script will split the batadv proto network interfaces +# in batadv_hardif and batadv proto. The configuration options from +# /etc/config/batman-adv will be moved to the latter. + +. /lib/functions.sh + +proto_batadv_to_batadv_hardif() { + local section="$1" + local proto + local mesh + local routing_algo + + config_get proto "${section}" proto + config_get mesh "${section}" mesh + config_get routing_algo "${section}" routing_algo + + if [ -z "$mesh" -o "${proto}" != "batadv" ]; then + continue + fi + + uci set network."${section}".proto="batadv_hardif" + uci rename network."${section}".mesh="master" + uci delete network."${section}".routing_algo + + # create new section or adjust existing one + uci set network."${mesh}"=interface + uci set network."${mesh}".proto=batadv + [ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}" +} + +mv_batadv_config_section() { + local section="$1" + local aggregated_ogms + local ap_isolation + local bonding + local bridge_loop_avoidance + local distributed_arp_table + local fragmentation + local gw_bandwidth + local gw_mode + local gw_sel_class + local hop_penalty + local isolation_mark + local log_level + local multicast_mode + local network_coding + local orig_interval + + config_get aggregated_ogms "${section}" aggregated_ogms + config_get ap_isolation "${section}" ap_isolation + config_get bonding "${section}" bonding + config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance + config_get distributed_arp_table "${section}" distributed_arp_table + config_get fragmentation "${section}" fragmentation + config_get gw_bandwidth "${section}" gw_bandwidth + config_get gw_mode "${section}" gw_mode + config_get gw_sel_class "${section}" gw_sel_class + config_get hop_penalty "${section}" hop_penalty + config_get isolation_mark "${section}" isolation_mark + config_get log_level "${section}" log_level + config_get multicast_mode "${section}" multicast_mode + config_get network_coding "${section}" network_coding + config_get orig_interval "${section}" orig_interval + + # update section in case it exists + [ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}" + [ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}" + [ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}" + [ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}" + [ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}" + [ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}" + [ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}" + [ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}" + [ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}" + [ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}" + [ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}" + [ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}" + [ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}" + [ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}" + [ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}" +} + +if [ -f /etc/config/batman-adv ]; then + config_load network + config_foreach proto_batadv_to_batadv_hardif 'interface' + uci commit network + + config_load batman-adv + config_foreach mv_batadv_config_section 'mesh' + uci commit network + + rm -f /etc/config/batman-adv +fi + +exit 0 diff --git a/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv.sh b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv.sh new file mode 100755 index 000000000..edc14f4cb --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv.sh @@ -0,0 +1,123 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_batadv_init_config() { + no_device=1 + available=1 + + proto_config_add_boolean 'aggregated_ogms:bool' + proto_config_add_boolean 'ap_isolation:bool' + proto_config_add_boolean 'bonding:bool' + proto_config_add_boolean 'bridge_loop_avoidance:bool' + proto_config_add_boolean 'distributed_arp_table:bool' + proto_config_add_boolean 'fragmentation:bool' + proto_config_add_string 'gw_bandwidth' + proto_config_add_string 'gw_mode' + proto_config_add_int 'gw_sel_class' + proto_config_add_int 'hop_penalty' + proto_config_add_string 'isolation_mark' + proto_config_add_string 'log_level' + proto_config_add_int 'multicast_fanout' + proto_config_add_boolean 'multicast_mode:bool' + proto_config_add_boolean 'network_coding:bool' + proto_config_add_int 'orig_interval' + proto_config_add_string 'routing_algo' +} + +proto_batadv_setup() { + local config="$1" + local iface="$config" + + local aggregated_ogms + local ap_isolation + local bonding + local bridge_loop_avoidance + local distributed_arp_table + local fragmentation + local gw_bandwidth + local gw_mode + local gw_sel_class + local hop_penalty + local isolation_mark + local log_level + local multicast_fanout + local multicast_mode + local network_coding + local orig_interval + local routing_algo + + json_get_vars aggregated_ogms + json_get_vars ap_isolation + json_get_vars bonding + json_get_vars bridge_loop_avoidance + json_get_vars distributed_arp_table + json_get_vars fragmentation + json_get_vars gw_bandwidth + json_get_vars gw_mode + json_get_vars gw_sel_class + json_get_vars hop_penalty + json_get_vars isolation_mark + json_get_vars log_level + json_get_vars multicast_fanout + json_get_vars multicast_mode + json_get_vars network_coding + json_get_vars orig_interval + json_get_vars routing_algo + + set_default routing_algo 'BATMAN_IV' + + batctl routing_algo "$routing_algo" + batctl meshif "$iface" interface create + + [ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms" + [ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation" + [ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding" + [ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&- + [ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&- + [ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation" + + case "$gw_mode" in + server) + if [ -n "$gw_bandwidth" ]; then + batctl meshif "$iface" gw_mode "server" "$gw_bandwidth" + else + batctl meshif "$iface" gw_mode "server" + fi + ;; + client) + if [ -n "$gw_sel_class" ]; then + batctl meshif "$iface" gw_mode "client" "$gw_sel_class" + else + batctl meshif "$iface" gw_mode "client" + fi + ;; + *) + batctl meshif "$iface" gw_mode "off" + ;; + esac + + [ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty" + [ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark" + [ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout" + [ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&- + [ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&- + [ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&- + [ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval" + + proto_init_update "$iface" 1 + proto_send_update "$config" +} + +proto_batadv_teardown() { + local config="$1" + local iface="$config" + + batctl meshif "$iface" interface destroy +} + +add_protocol batadv diff --git a/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_hardif.sh b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_hardif.sh new file mode 100755 index 000000000..6eb597ff6 --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_hardif.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_batadv_hardif_init_config() { + proto_config_add_int 'elp_interval' + proto_config_add_string "master" + proto_config_add_string 'throughput_override' +} + +proto_batadv_hardif_setup() { + local config="$1" + local iface="$2" + + local elp_interval + local master + local throughput_override + + json_get_vars elp_interval + json_get_vars master + json_get_vars throughput_override + + ( proto_add_host_dependency "$config" '' "$master" ) + + batctl meshif "$master" interface -M add "$iface" + + [ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval" + [ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override" + + proto_init_update "$iface" 1 + proto_send_update "$config" +} + +proto_batadv_hardif_teardown() { + local config="$1" + local iface="$2" + + local master + + json_get_vars master + + batctl meshif "$master" interface -M del "$iface" || true +} + +add_protocol batadv_hardif diff --git a/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_vlan.sh b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_vlan.sh new file mode 100755 index 000000000..115e61cde --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/files/lib/netifd/proto/batadv_vlan.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_batadv_vlan_init_config() { + proto_config_add_boolean 'ap_isolation:bool' +} + +proto_batadv_vlan_setup() { + local config="$1" + local iface="$2" + + # batadv_vlan options + local ap_isolation + + json_get_vars ap_isolation + + [ -n "$ap_isolation" ] && batctl vlan "$iface" ap_isolation "$ap_isolation" + proto_init_update "$iface" 1 + proto_send_update "$config" +} + +add_protocol batadv_vlan diff --git a/feeds/wifi-ath10k/batman-adv/src/compat-hacks.h b/feeds/wifi-ath10k/batman-adv/src/compat-hacks.h new file mode 100644 index 000000000..b57f7b6e0 --- /dev/null +++ b/feeds/wifi-ath10k/batman-adv/src/compat-hacks.h @@ -0,0 +1,181 @@ +/* Please avoid adding hacks here - instead add it to mac80211/backports.git */ + +#undef CONFIG_MODULE_STRIPPED + +#include /* LINUX_VERSION_CODE */ +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + +#include + +#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) ({\ + BUILD_BUG_ON(extack != NULL); \ + netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info); \ +}) + +#endif /* < KERNEL_VERSION(4, 15, 0) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + +#ifndef sizeof_field +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) +#endif + +#endif /* < KERNEL_VERSION(4, 16, 0) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) + +#include_next +#include_next + +static inline int batadv_ipv6_mc_check_mld1(struct sk_buff *skb) +{ + return ipv6_mc_check_mld(skb, NULL); +} + +static inline int batadv_ipv6_mc_check_mld2(struct sk_buff *skb, + struct sk_buff **skb_trimmed) +{ + return ipv6_mc_check_mld(skb, skb_trimmed); +} + +#define ipv6_mc_check_mld_get(_1, _2, ipv6_mc_check_mld_name, ...) ipv6_mc_check_mld_name +#define ipv6_mc_check_mld(...) \ + ipv6_mc_check_mld_get(__VA_ARGS__, batadv_ipv6_mc_check_mld2, batadv_ipv6_mc_check_mld1)(__VA_ARGS__) + +static inline int batadv_ip_mc_check_igmp1(struct sk_buff *skb) +{ + return ip_mc_check_igmp(skb, NULL); +} + +static inline int batadv_ip_mc_check_igmp2(struct sk_buff *skb, + struct sk_buff **skb_trimmed) +{ + return ip_mc_check_igmp(skb, skb_trimmed); +} + +#define ip_mc_check_igmp_get(_1, _2, ip_mc_check_igmp_name, ...) ip_mc_check_igmp_name +#define ip_mc_check_igmp(...) \ + ip_mc_check_igmp_get(__VA_ARGS__, batadv_ip_mc_check_igmp2, batadv_ip_mc_check_igmp1)(__VA_ARGS__) + +#endif /* < KERNEL_VERSION(5, 1, 0) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + +#define batadv_softif_slave_add(__dev, __slave_dev, __extack) \ + batadv_softif_slave_add(__dev, __slave_dev) + +#endif /* < KERNEL_VERSION(4, 15, 0) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + +static inline int batadv_access_ok(int type, const void __user *p, + unsigned long size) +{ + return access_ok(type, p, size); +} + +#ifdef access_ok +#undef access_ok +#endif + +#define access_ok_get(_1, _2, _3 , access_ok_name, ...) access_ok_name +#define access_ok(...) \ + access_ok_get(__VA_ARGS__, access_ok3, access_ok2)(__VA_ARGS__) + +#define access_ok2(addr, size) batadv_access_ok(VERIFY_WRITE, (addr), (size)) +#define access_ok3(type, addr, size) batadv_access_ok((type), (addr), (size)) + +#endif /* < KERNEL_VERSION(5, 0, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) + +#ifndef fallthrough +#if __GNUC__ > 7 && !defined(__CHECKER__) +# define fallthrough __attribute__((__fallthrough__)) +#else +# define fallthrough do {} while (0) /* fallthrough */ +#endif +#endif + +#endif /* < KERNEL_VERSION(5, 4, 0) */ + +/* */ + +#include +#include_next + +#include + +#ifdef DECLARE_EWMA +#undef DECLARE_EWMA +#endif /* DECLARE_EWMA */ + +/* + * Exponentially weighted moving average (EWMA) + * + * This implements a fixed-precision EWMA algorithm, with both the + * precision and fall-off coefficient determined at compile-time + * and built into the generated helper funtions. + * + * The first argument to the macro is the name that will be used + * for the struct and helper functions. + * + * The second argument, the precision, expresses how many bits are + * used for the fractional part of the fixed-precision values. + * + * The third argument, the weight reciprocal, determines how the + * new values will be weighed vs. the old state, new values will + * get weight 1/weight_rcp and old values 1-1/weight_rcp. Note + * that this parameter must be a power of two for efficiency. + */ + +#define DECLARE_EWMA(name, _precision, _weight_rcp) \ + struct ewma_##name { \ + unsigned long internal; \ + }; \ + static inline void ewma_##name##_init(struct ewma_##name *e) \ + { \ + BUILD_BUG_ON(!__builtin_constant_p(_precision)); \ + BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \ + /* \ + * Even if you want to feed it just 0/1 you should have \ + * some bits for the non-fractional part... \ + */ \ + BUILD_BUG_ON((_precision) > 30); \ + BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \ + e->internal = 0; \ + } \ + static inline unsigned long \ + ewma_##name##_read(struct ewma_##name *e) \ + { \ + BUILD_BUG_ON(!__builtin_constant_p(_precision)); \ + BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \ + BUILD_BUG_ON((_precision) > 30); \ + BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \ + return e->internal >> (_precision); \ + } \ + static inline void ewma_##name##_add(struct ewma_##name *e, \ + unsigned long val) \ + { \ + unsigned long internal = READ_ONCE(e->internal); \ + unsigned long weight_rcp = ilog2(_weight_rcp); \ + unsigned long precision = _precision; \ + \ + BUILD_BUG_ON(!__builtin_constant_p(_precision)); \ + BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \ + BUILD_BUG_ON((_precision) > 30); \ + BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \ + \ + WRITE_ONCE(e->internal, internal ? \ + (((internal << weight_rcp) - internal) + \ + (val << precision)) >> weight_rcp : \ + (val << precision)); \ + } + +/* */ diff --git a/feeds/wifi-ath10k/mac80211/Makefile b/feeds/wifi-ath10k/mac80211/Makefile new file mode 100644 index 000000000..13fc008d1 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/Makefile @@ -0,0 +1,544 @@ +# +# Copyright (C) 2007-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=mac80211 + +PKG_VERSION:=5.8-1 +PKG_RELEASE:=1 +PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.8/ +PKG_HASH:=19b4174d89bf11ee221458e11f1e8dace26558498774b823051156f522d2036b + +PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_MAINTAINER:=Felix Fietkau + +PKG_DRIVERS = \ + adm8211 \ + airo \ + hermes hermes-pci hermes-pcmcia hermes-plx\ + lib80211 \ + mac80211-hwsim \ + mt7601u \ + p54-common p54-pci p54-usb \ + rsi91x rsi91x-usb rsi91x-sdio\ + wlcore wl12xx wl18xx \ + zd1211rw + +PKG_CONFIG_DEPENDS:= \ + CONFIG_PACKAGE_kmod-mac80211 \ + CONFIG_PACKAGE_CFG80211_TESTMODE \ + CONFIG_PACKAGE_MAC80211_DEBUGFS \ + CONFIG_PACKAGE_MAC80211_MESH \ + CONFIG_PACKAGE_MAC80211_TRACING \ + CONFIG_PACKAGE_IWLWIFI_DEBUG \ + CONFIG_PACKAGE_IWLWIFI_DEBUGFS \ + CONFIG_PACKAGE_RTLWIFI_DEBUG \ + +include $(INCLUDE_DIR)/package.mk + +WMENU:=Wireless Drivers + +define KernelPackage/mac80211/Default + SUBMENU:=$(WMENU) + URL:=https://wireless.wiki.kernel.org/ + MAINTAINER:=Felix Fietkau +endef + +config_package=$(if $(CONFIG_PACKAGE_kmod-$(1)),m) + +config-y:= \ + WLAN \ + CFG80211_WEXT \ + CFG80211_CERTIFICATION_ONUS \ + MAC80211_RC_MINSTREL \ + MAC80211_RC_MINSTREL_HT \ + MAC80211_RC_MINSTREL_VHT \ + MAC80211_RC_DEFAULT_MINSTREL \ + WLAN_VENDOR_ADMTEK \ + WLAN_VENDOR_ATH \ + WLAN_VENDOR_ATMEL \ + WLAN_VENDOR_BROADCOM \ + WLAN_VENDOR_CISCO \ + WLAN_VENDOR_INTEL \ + WLAN_VENDOR_INTERSIL \ + WLAN_VENDOR_MARVELL \ + WLAN_VENDOR_MEDIATEK \ + WLAN_VENDOR_RALINK \ + WLAN_VENDOR_REALTEK \ + WLAN_VENDOR_RSI \ + WLAN_VENDOR_ST \ + WLAN_VENDOR_TI \ + WLAN_VENDOR_ZYDAS \ + +config-$(call config_package,cfg80211) += CFG80211 +config-$(CONFIG_PACKAGE_CFG80211_TESTMODE) += NL80211_TESTMODE + +config-$(call config_package,mac80211) += MAC80211 +config-$(CONFIG_PACKAGE_MAC80211_MESH) += MAC80211_MESH + +include ath.mk +include broadcom.mk +include intel.mk +include marvell.mk +include ralink.mk +include realtek.mk + +PKG_CONFIG_DEPENDS += \ + $(patsubst %,CONFIG_PACKAGE_kmod-%,$(PKG_DRIVERS)) + +define KernelPackage/cfg80211 + $(call KernelPackage/mac80211/Default) + TITLE:=cfg80211 - wireless configuration API + DEPENDS+= +iw +wireless-regdb + ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) + FILES:= \ + $(PKG_BUILD_DIR)/compat/compat.ko \ + $(PKG_BUILD_DIR)/net/wireless/cfg80211.ko +endef + +define KernelPackage/cfg80211/description +cfg80211 is the Linux wireless LAN (802.11) configuration API. +endef + +define KernelPackage/cfg80211/config + if PACKAGE_kmod-cfg80211 + + config PACKAGE_CFG80211_TESTMODE + bool "Enable testmode command support" + default n + help + This is typically used for tests and calibration during + manufacturing, or vendor specific debugging features + + endif +endef + + +define KernelPackage/mac80211 + $(call KernelPackage/mac80211/Default) + TITLE:=Linux 802.11 Wireless Networking Stack + # +kmod-crypto-cmac is a runtime only dependency of net/mac80211/aes_cmac.c + DEPENDS+= +kmod-cfg80211 +hostapd-common + KCONFIG:=\ + CONFIG_AVERAGE=y + FILES:= $(PKG_BUILD_DIR)/net/mac80211/mac80211.ko + ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) + MENU:=1 +endef + +define KernelPackage/mac80211/config + if PACKAGE_kmod-mac80211 + + config PACKAGE_MAC80211_DEBUGFS + bool "Export mac80211 internals in DebugFS" + select KERNEL_DEBUG_FS + default y + help + Select this to see extensive information about + the internal state of mac80211 in debugfs. + + config PACKAGE_MAC80211_TRACING + bool "Enable tracing (mac80211 and supported drivers)" + select KERNEL_FTRACE + select KERNEL_ENABLE_DEFAULT_TRACERS + default n + help + Select this to enable tracing of mac80211 and + related wifi drivers (using trace-cmd). + + config PACKAGE_MAC80211_MESH + bool "Enable 802.11s mesh support" + default y + + endif +endef + +define KernelPackage/mac80211/description +Generic IEEE 802.11 Networking Stack (mac80211) +endef + +define KernelPackage/adm8211 + $(call KernelPackage/mac80211/Default) + TITLE:=ADMTek 8211 support + DEPENDS+=@PCI_SUPPORT +kmod-mac80211 +kmod-eeprom-93cx6 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/admtek/adm8211.ko + AUTOLOAD:=$(call AutoProbe,adm8211) +endef + +define KernelPackage/airo + $(call KernelPackage/mac80211/Default) + TITLE:=Cisco Aironet driver + DEPENDS+=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT +kmod-cfg80211 @TARGET_x86 @BROKEN + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/cisco/airo.ko + AUTOLOAD:=$(call AutoProbe,airo) +endef + +define KernelPackage/airo/description + Kernel support for Cisco Aironet cards +endef + +define KernelPackage/hermes + $(call KernelPackage/mac80211/Default) + TITLE:=Hermes 802.11b chipset support + DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT +kmod-crypto-michael-mic + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/orinoco/orinoco.ko + AUTOLOAD:=$(call AutoProbe,orinoco) +endef + +define KernelPackage/hermes/description + Kernel support for Hermes 802.11b chipsets +endef + +define KernelPackage/hermes-pci + $(call KernelPackage/mac80211/Default) + TITLE:=Intersil Prism 2.5 PCI support + DEPENDS:=@PCI_SUPPORT +kmod-hermes + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/orinoco/orinoco_pci.ko + AUTOLOAD:=$(call AutoProbe,orinoco_pci) +endef + +define KernelPackage/hermes-pci/description + Kernel modules for Intersil Prism 2.5 PCI support +endef + +define KernelPackage/hermes-plx + $(call KernelPackage/mac80211/Default) + TITLE:=PLX9052 based PCI adaptor + DEPENDS:=@PCI_SUPPORT +kmod-hermes + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/orinoco/orinoco_plx.ko + AUTOLOAD:=$(call AutoProbe,orinoco_plx) +endef + +define KernelPackage/hermes-plx/description + Kernel modules for Hermes in PLX9052 based PCI adaptors +endef + +define KernelPackage/hermes-pcmcia + $(call KernelPackage/mac80211/Default) + TITLE:=Hermes based PCMCIA adaptors + DEPENDS:=@PCMCIA_SUPPORT +kmod-hermes +kmod-pcmcia-core + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/orinoco/orinoco_cs.ko + AUTOLOAD:=$(call AutoProbe,orinoco_cs) +endef + +define KernelPackage/hermes-pcmcia/description + Kernel modules for Hermes based PCMCIA adaptors +endef + + +define KernelPackage/lib80211 + $(call KernelPackage/mac80211/Default) + TITLE:=802.11 Networking stack + DEPENDS:=+kmod-cfg80211 +kmod-crypto-hash +kmod-crypto-ccm + FILES:= \ + $(PKG_BUILD_DIR)/net/wireless/lib80211.ko \ + $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_wep.ko \ + $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_ccmp.ko \ + $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_tkip.ko + AUTOLOAD:=$(call AutoProbe, \ + lib80211 \ + lib80211_crypt_wep \ + lib80211_crypt_ccmp \ + lib80211_crypt_tkip \ + ) +endef + +define KernelPackage/lib80211/description + Kernel modules for 802.11 Networking stack + Includes: + - lib80211 + - lib80211_crypt_wep + - lib80211_crypt_tkip + - lib80211_crytp_ccmp +endef + + +define KernelPackage/mac80211-hwsim + $(call KernelPackage/mac80211/Default) + TITLE:=mac80211 HW simulation device + DEPENDS+= +kmod-mac80211 +@DRIVER_11AC_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mac80211_hwsim.ko + AUTOLOAD:=$(call AutoProbe,mac80211_hwsim) +endef + + +define KernelPackage/mt7601u + $(call KernelPackage/mac80211/Default) + TITLE:=MT7601U-based USB dongles Wireless Driver + DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT @USB_SUPPORT +kmod-usb-core +mt7601u-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mediatek/mt7601u/mt7601u.ko + AUTOLOAD:=$(call AutoProbe,mt7601u) +endef + +define KernelPackage/p54/Default + $(call KernelPackage/mac80211/Default) + TITLE:=Prism54 Drivers +endef + +define KernelPackage/p54/description + Kernel module for Prism54 chipsets (mac80211) +endef + +define KernelPackage/p54-common + $(call KernelPackage/p54/Default) + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT) +kmod-mac80211 +kmod-lib-crc-ccitt +@DRIVER_11W_SUPPORT + TITLE+= (COMMON) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/p54/p54common.ko +endef + +define KernelPackage/p54-pci + $(call KernelPackage/p54/Default) + TITLE+= (PCI) + DEPENDS+= @PCI_SUPPORT +kmod-p54-common +p54-pci-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/p54/p54pci.ko + AUTOLOAD:=$(call AutoProbe,p54pci) +endef + +define KernelPackage/p54-usb + $(call KernelPackage/p54/Default) + TITLE+= (USB) + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-p54-common +p54-usb-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intersil/p54/p54usb.ko + AUTOLOAD:=$(call AutoProbe,p54usb) +endef + +define KernelPackage/rsi91x + $(call KernelPackage/mac80211/Default) + TITLE:=Redpine Signals Inc 91x WLAN driver support + DEPENDS+= +kmod-mac80211 +rs9113-firmware +@DRIVER_11N_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rsi/rsi_91x.ko +endef + +define KernelPackage/rsi91x-usb + $(call KernelPackage/mac80211/Default) + TITLE:=Redpine Signals USB bus support + DEPENDS+=@USB_SUPPORT +kmod-usb-core +kmod-mac80211 +kmod-rsi91x +rs9113-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rsi/rsi_usb.ko + AUTOLOAD:=$(call AutoProbe,rsi_usb) +endef + +define KernelPackage/rsi91x-sdio + $(call KernelPackage/mac80211/Default) + TITLE:=Redpine Signals SDIO bus support + DEPENDS+= +kmod-mac80211 +kmod-mmc +kmod-rsi91x +rs9113-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rsi/rsi_sdio.ko + AUTOLOAD:=$(call AutoProbe,rsi_sdio) +endef + + +define KernelPackage/wlcore + $(call KernelPackage/mac80211/Default) + TITLE:=TI common driver part + DEPENDS+= +kmod-mmc +kmod-mac80211 +@DRIVER_11N_SUPPORT + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko + AUTOLOAD:=$(call AutoProbe,wlcore wlcore_sdio) +endef + +define KernelPackage/wlcore/description + This module contains some common parts needed by TI Wireless drivers. +endef + +define KernelPackage/wl12xx + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for TI WL12xx + URL:=https://wireless.wiki.kernel.org/en/users/drivers/wl12xx + DEPENDS+= +kmod-wlcore +wl12xx-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl12xx/wl12xx.ko + AUTOLOAD:=$(call AutoProbe,wl12xx) +endef + +define KernelPackage/wl12xx/description + Kernel modules for TI WL12xx +endef + +define KernelPackage/wl18xx + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for TI WL18xx + URL:=https://wireless.wiki.kernel.org/en/users/drivers/wl18xx + DEPENDS+= +kmod-wlcore +wl18xx-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl18xx/wl18xx.ko + AUTOLOAD:=$(call AutoProbe,wl18xx) +endef + +define KernelPackage/wl18xx/description + Kernel modules for TI WL18xx +endef + + +ZD1211FW_NAME:=zd1211-firmware +ZD1211FW_VERSION:=1.4 +define Download/zd1211rw + FILE:=$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2 + URL:=@SF/zd1211/ + HASH:=866308f6f59f7075f075d4959dff2ede47735c751251fecd1496df1ba4d338e1 +endef +$(eval $(call Download,zd1211rw)) + +define KernelPackage/zd1211rw + $(call KernelPackage/mac80211/Default) + TITLE:=Zydas ZD1211 support + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-mac80211 +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/zydas/zd1211rw/zd1211rw.ko + AUTOLOAD:=$(call AutoProbe,zd1211rw) +endef + +ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS + config-y += \ + CFG80211_DEBUGFS \ + MAC80211_DEBUGFS +endif + +ifdef CONFIG_PACKAGE_MAC80211_TRACING + config-y += \ + IWLWIFI_DEVICE_TRACING +endif + +config-$(call config_package,lib80211) += LIB80211 LIB80211_CRYPT_WEP LIB80211_CRYPT_CCMP LIB80211_CRYPT_TKIP + +config-$(call config_package,airo) += AIRO + +config-$(call config_package,mac80211-hwsim) += MAC80211_HWSIM +config-$(call config_package,mt7601u) += MT7601U +config-y += WL_MEDIATEK + +config-$(call config_package,p54-common) += P54_COMMON +config-$(call config_package,p54-pci) += P54_PCI +config-$(call config_package,p54-usb) += P54_USB + +config-$(call config_package,hermes) += HERMES +config-$(call config_package,hermes-pci) += PCI_HERMES +config-$(call config_package,hermes-plx) += PLX_HERMES +config-$(call config_package,hermes-pcmcia) += PCMCIA_HERMES +config-y += HERMES_PRISM + +config-$(call config_package,adm8211) += ADM8211 +config-$(call config_package,wlcore) += WLCORE WLCORE_SDIO +config-$(call config_package,wl12xx) += WL12XX +config-$(call config_package,wl18xx) += WL18XX +config-y += WL_TI WILINK_PLATFORM_DATA +config-$(call config_package,zd1211rw) += ZD1211RW +config-$(call config_package,rsi91x) += RSI_91X +config-$(call config_package,rsi91x-usb) += RSI_USB +config-$(call config_package,rsi91x-sdio) += RSI_SDIO + +config-$(CONFIG_LEDS_TRIGGERS) += MAC80211_LEDS + +MAKE_OPTS:= -C "$(PKG_BUILD_DIR)" \ + $(KERNEL_MAKE_FLAGS) \ + EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/include $(IREMAP_CFLAGS)" \ + KLIB_BUILD="$(LINUX_DIR)" \ + MODPROBE=true \ + KLIB=$(TARGET_MODULES_DIR) \ + KERNEL_SUBLEVEL=$(lastword $(subst ., ,$(KERNEL_PATCHVER))) \ + KBUILD_LDFLAGS_MODULE_PREREQ= + +define ConfigVars +$(subst $(space),,$(foreach opt,$(config-$(1)),CPTCFG_$(opt)=$(1) +)) +endef + +define mac80211_config +$(call ConfigVars,m)$(call ConfigVars,y) +endef +$(eval $(call shexport,mac80211_config)) + +define Build/Prepare + rm -rf $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) + $(PKG_UNPACK) + $(Build/Patch) + $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2100_NAME)-$(IPW2100_VERSION).tgz + $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION).tgz + $(TAR) -C $(PKG_BUILD_DIR) -xjf $(DL_DIR)/$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2 + rm -rf \ + $(PKG_BUILD_DIR)/include/linux/ssb \ + $(PKG_BUILD_DIR)/include/linux/bcma \ + $(PKG_BUILD_DIR)/include/net/bluetooth + + rm -f \ + $(PKG_BUILD_DIR)/include/linux/cordic.h \ + $(PKG_BUILD_DIR)/include/linux/crc8.h \ + $(PKG_BUILD_DIR)/include/linux/eeprom_93cx6.h \ + $(PKG_BUILD_DIR)/include/linux/wl12xx.h \ + $(PKG_BUILD_DIR)/include/linux/spi/libertas_spi.h \ + $(PKG_BUILD_DIR)/include/net/ieee80211.h \ + $(PKG_BUILD_DIR)/backport-include/linux/bcm47xx_nvram.h + + echo 'compat-wireless-$(PKG_VERSION)-$(PKG_RELEASE)-$(REVISION)' > $(PKG_BUILD_DIR)/compat_version +endef + +ifneq ($(CONFIG_PACKAGE_kmod-cfg80211)$(CONFIG_PACKAGE_kmod-lib80211),) + define Build/Compile/kmod + rm -rf $(PKG_BUILD_DIR)/modules + +$(MAKE) $(PKG_JOBS) $(MAKE_OPTS) modules + endef +endif + +define Build/Patch + $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/build,build/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/subsys,subsys/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath,ath/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/) + $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used) +endef + +define Quilt/Refresh/Package + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/build,build/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/subsys,subsys/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath,ath/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/) +endef + +define Build/Compile + $(SH_FUNC) var2file "$(call shvar,mac80211_config)" $(PKG_BUILD_DIR)/.config + $(MAKE) $(MAKE_OPTS) allnoconfig + $(call Build/Compile/kmod) +endef + +define Build/InstallDev + mkdir -p \ + $(1)/usr/include/mac80211 \ + $(1)/usr/include/mac80211-backport \ + $(1)/usr/include/mac80211/ath \ + $(1)/usr/include/net/mac80211 + $(CP) $(PKG_BUILD_DIR)/net/mac80211/*.h $(PKG_BUILD_DIR)/include/* $(1)/usr/include/mac80211/ + $(CP) $(PKG_BUILD_DIR)/backport-include/* $(1)/usr/include/mac80211-backport/ + $(CP) $(PKG_BUILD_DIR)/net/mac80211/rate.h $(1)/usr/include/net/mac80211/ + $(CP) $(PKG_BUILD_DIR)/drivers/net/wireless/ath/*.h $(1)/usr/include/mac80211/ath/ + rm -f $(1)/usr/include/mac80211-backport/linux/module.h +endef + + +define KernelPackage/cfg80211/install + $(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless + $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi + $(INSTALL_DATA) ./files/lib/netifd/mac80211.sh $(1)/lib/netifd + $(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless + $(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211 + $(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/10-wifi-detect +endef + +define KernelPackage/zd1211rw/install + $(INSTALL_DIR) $(1)/lib/firmware/zd1211 + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(ZD1211FW_NAME)/zd1211* $(1)/lib/firmware/zd1211 +endef + +$(eval $(foreach drv,$(PKG_DRIVERS),$(call KernelPackage,$(drv)))) +$(eval $(call KernelPackage,cfg80211)) +$(eval $(call KernelPackage,mac80211)) diff --git a/feeds/wifi-ath10k/mac80211/ath.mk b/feeds/wifi-ath10k/mac80211/ath.mk new file mode 100644 index 000000000..5db4be8da --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/ath.mk @@ -0,0 +1,310 @@ +PKG_DRIVERS += \ + ath ath5k ath6kl ath6kl-sdio ath6kl-usb ath9k ath9k-common ath9k-htc ath10k \ + carl9170 owl-loader ar5523 + +PKG_CONFIG_DEPENDS += \ + CONFIG_PACKAGE_ATH_DEBUG \ + CONFIG_PACKAGE_ATH_DFS \ + CONFIG_PACKAGE_ATH_SPECTRAL \ + CONFIG_PACKAGE_ATH_DYNACK \ + CONFIG_ATH9K_HWRNG \ + CONFIG_ATH9K_SUPPORT_PCOEM \ + CONFIG_ATH9K_TX99 \ + CONFIG_ATH10K_LEDS \ + CONFIG_ATH10K_THERMAL \ + CONFIG_ATH_USER_REGD + +ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS + config-y += \ + ATH9K_DEBUGFS \ + ATH9K_HTC_DEBUGFS \ + ATH10K_DEBUGFS \ + CARL9170_DEBUGFS \ + ATH5K_DEBUG \ + ATH6KL_DEBUG +endif + +ifdef CONFIG_PACKAGE_MAC80211_TRACING + config-y += \ + ATH10K_TRACING \ + ATH6KL_TRACING \ + ATH_TRACEPOINTS \ + ATH5K_TRACER +endif + +config-$(call config_package,ath) += ATH_CARDS ATH_COMMON ATH_REG_DYNAMIC_USER_REG_HINTS +config-$(CONFIG_PACKAGE_ATH_DEBUG) += ATH_DEBUG ATH10K_DEBUG ATH9K_STATION_STATISTICS +config-$(CONFIG_PACKAGE_ATH_DFS) += ATH9K_DFS_CERTIFIED ATH10K_DFS_CERTIFIED +config-$(CONFIG_PACKAGE_ATH_SPECTRAL) += ATH9K_COMMON_SPECTRAL ATH10K_SPECTRAL +config-$(CONFIG_PACKAGE_ATH_DYNACK) += ATH9K_DYNACK +config-$(call config_package,ath9k) += ATH9K +config-$(call config_package,ath9k-common) += ATH9K_COMMON +config-$(call config_package,owl-loader) += ATH9K_PCI_NO_EEPROM +config-$(CONFIG_TARGET_ath79) += ATH9K_AHB +config-$(CONFIG_TARGET_ipq40xx) += ATH10K_AHB +config-$(CONFIG_PCI) += ATH9K_PCI +config-$(CONFIG_ATH_USER_REGD) += ATH_USER_REGD +config-$(CONFIG_ATH9K_HWRNG) += ATH9K_HWRNG +config-$(CONFIG_ATH9K_SUPPORT_PCOEM) += ATH9K_PCOEM +config-$(CONFIG_ATH9K_TX99) += ATH9K_TX99 +config-$(CONFIG_ATH9K_UBNTHSR) += ATH9K_UBNTHSR +config-$(CONFIG_ATH10K_LEDS) += ATH10K_LEDS +config-$(CONFIG_ATH10K_THERMAL) += ATH10K_THERMAL + +config-$(call config_package,ath9k-htc) += ATH9K_HTC +config-$(call config_package,ath10k) += ATH10K ATH10K_PCI + +config-$(call config_package,ath5k) += ATH5K +ifdef CONFIG_TARGET_ath25 + config-y += ATH5K_AHB +else + config-y += ATH5K_PCI +endif + +config-$(call config_package,ath6kl) += ATH6KL +config-$(call config_package,ath6kl-sdio) += ATH6KL_SDIO +config-$(call config_package,ath6kl-usb) += ATH6KL_USB + +config-$(call config_package,carl9170) += CARL9170 +config-$(call config_package,ar5523) += AR5523 + +define KernelPackage/ath/config + if PACKAGE_kmod-ath + config ATH_USER_REGD + bool "Force Atheros drivers to respect the user's regdomain settings" + default y + help + Atheros' idea of regulatory handling is that the EEPROM of the card defines + the regulatory limits and the user is only allowed to restrict the settings + even further, even if the country allows frequencies or power levels that + are forbidden by the EEPROM settings. + + Select this option if you want the driver to respect the user's decision about + regulatory settings. + + config PACKAGE_ATH_DEBUG + bool "Atheros wireless debugging" + help + Say Y, if you want to debug atheros wireless drivers. + Only ath9k & ath10k make use of this. + + config PACKAGE_ATH_DFS + bool "Enable DFS support" + default y + help + Dynamic frequency selection (DFS) is required for most of the 5 GHz band + channels in Europe, US, and Japan. + + Select this option if you want to use such channels. + + config PACKAGE_ATH_SPECTRAL + bool "Atheros spectral scan support" + depends on PACKAGE_ATH_DEBUG + select KERNEL_RELAY + help + Say Y to enable access to the FFT/spectral data via debugfs. + + config PACKAGE_ATH_DYNACK + bool "Enable Dynack support" + depends on PACKAGE_kmod-ath9k-common + help + Enables support for Dynamic ACK estimation, which allows the fastest possible speed + at any distance automatically by increasing/decreasing the max frame ACK time for + the most remote station detected. It can be enabled by using iw (iw phy0 set distance auto), + or by sending the NL80211_ATTR_WIPHY_DYN_ACK flag to mac80211 driver using netlink. + + Select this option if you want to enable this feature + + endif +endef + +define KernelPackage/ath + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros common driver part + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ath79||TARGET_ath25 +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath.ko + MENU:=1 +endef + +define KernelPackage/ath/description + This module contains some common parts needed by Atheros Wireless drivers. +endef + +define KernelPackage/ath5k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 5xxx wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath5k + DEPENDS+= @(PCI_SUPPORT||TARGET_ath25) +kmod-ath +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath5k/ath5k.ko + AUTOLOAD:=$(call AutoProbe,ath5k) +endef + +define KernelPackage/ath5k/description + This module adds support for wireless adapters based on + Atheros 5xxx chipset. +endef + +define KernelPackage/ath6kl + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros FullMAC wireless devices (common code for ath6kl_sdio and ath6kl_usb) + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + HIDDEN:=1 + DEPENDS+= +kmod-ath +@DRIVER_11N_SUPPORT + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko +endef + +define KernelPackage/ath6kl-sdio + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n SDIO wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + DEPENDS+= +kmod-mmc +kmod-ath6kl + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko + AUTOLOAD:=$(call AutoProbe,ath6kl_sdio) +endef + +define KernelPackage/ath6kl-sdio/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11n AR6003 and AR6004 family of chipsets. +endef + +define KernelPackage/ath6kl-usb + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n USB wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-ath6kl + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko + AUTOLOAD:=$(call AutoProbe,ath6kl_usb) +endef + +define KernelPackage/ath6kl-usb/description +This module adds support for wireless adapters based on the +Atheros IEEE 802.11n AR6004 chipset. +endef + +define KernelPackage/ath9k-common + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n wireless devices (common code for ath9k and ath9k_htc) + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + HIDDEN:=1 + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ath79 +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko +endef + +define KernelPackage/ath9k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n PCI wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + DEPENDS+= @PCI_SUPPORT||TARGET_ath79 +kmod-ath9k-common + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k.ko + AUTOLOAD:=$(call AutoProbe,ath9k) +endef + +define KernelPackage/ath9k/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11n AR5008 and AR9001 family of chipsets. +endef + +define KernelPackage/ath9k/config + + config ATH9K_HWRNG + bool "Add wireless noise as source of randomness to kernel entropy pool" + depends on PACKAGE_kmod-ath9k + select PACKAGE_kmod-random-core + default n + + config ATH9K_SUPPORT_PCOEM + bool "Support chips used in PC OEM cards" + depends on PACKAGE_kmod-ath9k + + config ATH9K_TX99 + bool "Enable TX99 support (WARNING: testing only, breaks normal operation!)" + depends on PACKAGE_kmod-ath9k + + config ATH9K_UBNTHSR + bool "Support for Ubiquiti UniFi Outdoor+ access point" + depends on PACKAGE_kmod-ath9k && TARGET_ath79 + default y + +endef + +define KernelPackage/ath9k-htc + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n USB device support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core +ath9k-htc-firmware + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko + AUTOLOAD:=$(call AutoProbe,ath9k_htc) +endef + +define KernelPackage/ath9k-htc/description +This module adds support for wireless adapters based on +Atheros USB AR9271 and AR7010 family of chipsets. +endef + +define KernelPackage/ath10k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11ac wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath10k + DEPENDS+= @PCI_SUPPORT +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11W_SUPPORT \ + +ATH10K_THERMAL:kmod-hwmon-core +ATH10K_THERMAL:kmod-thermal + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath10k/ath10k_core.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath10k/ath10k_pci.ko + AUTOLOAD:=$(call AutoProbe,ath10k_pci) +endef + +define KernelPackage/ath10k/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11ac family of chipsets. For now only +PCI is supported. +endef + +define KernelPackage/ath10k/config + + config ATH10K_LEDS + bool "Enable LED support" + default y + depends on PACKAGE_kmod-ath10k + + config ATH10K_THERMAL + bool "Enable thermal sensors and throttling support" + depends on PACKAGE_kmod-ath10k + +endef + +define KernelPackage/carl9170 + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Atheros AR9170 USB sticks + DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT +carl9170-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko + AUTOLOAD:=$(call AutoProbe,carl9170) +endef + +define KernelPackage/owl-loader + $(call KernelPackage/mac80211/Default) + TITLE:=Owl loader for initializing Atheros PCI(e) Wifi chips + DEPENDS:=@PCI_SUPPORT +kmod-ath9k + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.ko + AUTOLOAD:=$(call AutoProbe,ath9k_pci_owl_loader) +endef + +define KernelPackage/owl-loader/description + Kernel module that helps to initialize certain Qualcomm + Atheros' PCI(e) Wifi chips, which have the init data + (which contains the PCI device ID for example) stored + together with the calibration data in the file system. + + This is necessary for devices like the Cisco Meraki Z1. +endef + +define KernelPackage/ar5523 + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Atheros AR5523 USB sticks + DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ar5523/ar5523.ko + AUTOLOAD:=$(call AutoProbe,ar5523) +endef diff --git a/feeds/wifi-ath10k/mac80211/ath.mk.orig b/feeds/wifi-ath10k/mac80211/ath.mk.orig new file mode 100644 index 000000000..352d192fa --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/ath.mk.orig @@ -0,0 +1,302 @@ +PKG_DRIVERS += \ + ath ath5k ath6kl ath6kl-sdio ath6kl-usb ath9k ath9k-common ath9k-htc ath10k \ + carl9170 owl-loader + +PKG_CONFIG_DEPENDS += \ + CONFIG_PACKAGE_ATH_DEBUG \ + CONFIG_PACKAGE_ATH_DFS \ + CONFIG_PACKAGE_ATH_SPECTRAL \ + CONFIG_PACKAGE_ATH_DYNACK \ + CONFIG_ATH9K_HWRNG \ + CONFIG_ATH9K_SUPPORT_PCOEM \ + CONFIG_ATH9K_TX99 \ + CONFIG_ATH10K_LEDS \ + CONFIG_ATH10K_THERMAL \ + CONFIG_ATH_USER_REGD + +ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS + config-y += \ + ATH9K_DEBUGFS \ + ATH9K_HTC_DEBUGFS \ + ATH10K_DEBUGFS \ + CARL9170_DEBUGFS \ + ATH5K_DEBUG \ + ATH6KL_DEBUG +endif + +ifdef CONFIG_PACKAGE_MAC80211_TRACING + config-y += \ + ATH10K_TRACING \ + ATH6KL_TRACING \ + ATH_TRACEPOINTS \ + ATH5K_TRACER +endif + +config-$(call config_package,ath) += ATH_CARDS ATH_COMMON ATH_REG_DYNAMIC_USER_REG_HINTS +config-$(CONFIG_PACKAGE_ATH_DEBUG) += ATH_DEBUG ATH10K_DEBUG ATH9K_STATION_STATISTICS +config-$(CONFIG_PACKAGE_ATH_DFS) += ATH9K_DFS_CERTIFIED ATH10K_DFS_CERTIFIED +config-$(CONFIG_PACKAGE_ATH_SPECTRAL) += ATH9K_COMMON_SPECTRAL ATH10K_SPECTRAL +config-$(CONFIG_PACKAGE_ATH_DYNACK) += ATH9K_DYNACK +config-$(call config_package,ath9k) += ATH9K +config-$(call config_package,ath9k-common) += ATH9K_COMMON +config-$(call config_package,owl-loader) += ATH9K_PCI_NO_EEPROM +config-$(CONFIG_TARGET_ar71xx) += ATH9K_AHB +config-$(CONFIG_TARGET_ath79) += ATH9K_AHB +config-$(CONFIG_TARGET_ipq40xx) += ATH10K_AHB +config-$(CONFIG_PCI) += ATH9K_PCI +config-$(CONFIG_ATH_USER_REGD) += ATH_USER_REGD +config-$(CONFIG_ATH9K_HWRNG) += ATH9K_HWRNG +config-$(CONFIG_ATH9K_SUPPORT_PCOEM) += ATH9K_PCOEM +config-$(CONFIG_ATH9K_TX99) += ATH9K_TX99 +config-$(CONFIG_ATH9K_UBNTHSR) += ATH9K_UBNTHSR +config-$(CONFIG_ATH10K_LEDS) += ATH10K_LEDS +config-$(CONFIG_ATH10K_THERMAL) += ATH10K_THERMAL + +config-$(call config_package,ath9k-htc) += ATH9K_HTC +config-$(call config_package,ath10k) += ATH10K ATH10K_PCI + +config-$(call config_package,ath5k) += ATH5K +ifdef CONFIG_TARGET_ath25 + config-y += ATH5K_AHB +else + config-y += ATH5K_PCI +endif + +config-$(call config_package,ath6kl) += ATH6KL +config-$(call config_package,ath6kl-sdio) += ATH6KL_SDIO +config-$(call config_package,ath6kl-usb) += ATH6KL_USB + +config-$(call config_package,carl9170) += CARL9170 + +define KernelPackage/ath/config + if PACKAGE_kmod-ath + config ATH_USER_REGD + bool "Force Atheros drivers to respect the user's regdomain settings" + default y + help + Atheros' idea of regulatory handling is that the EEPROM of the card defines + the regulatory limits and the user is only allowed to restrict the settings + even further, even if the country allows frequencies or power levels that + are forbidden by the EEPROM settings. + + Select this option if you want the driver to respect the user's decision about + regulatory settings. + + config PACKAGE_ATH_DEBUG + bool "Atheros wireless debugging" + help + Say Y, if you want to debug atheros wireless drivers. + Only ath9k & ath10k make use of this. + + config PACKAGE_ATH_DFS + bool "Enable DFS support" + default y + help + Dynamic frequency selection (DFS) is required for most of the 5 GHz band + channels in Europe, US, and Japan. + + Select this option if you want to use such channels. + + config PACKAGE_ATH_SPECTRAL + bool "Atheros spectral scan support" + depends on PACKAGE_ATH_DEBUG + select KERNEL_RELAY + help + Say Y to enable access to the FFT/spectral data via debugfs. + + config PACKAGE_ATH_DYNACK + bool "Enable Dynack support" + depends on PACKAGE_kmod-ath9k-common + help + Enables support for Dynamic ACK estimation, which allows the fastest possible speed + at any distance automatically by increasing/decreasing the max frame ACK time for + the most remote station detected. It can be enabled by using iw (iw phy0 set distance auto), + or by sending the NL80211_ATTR_WIPHY_DYN_ACK flag to mac80211 driver using netlink. + + Select this option if you want to enable this feature + + endif +endef + +define KernelPackage/ath + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros common driver part + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx||TARGET_ath79||TARGET_ath25 +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath.ko + MENU:=1 +endef + +define KernelPackage/ath/description + This module contains some common parts needed by Atheros Wireless drivers. +endef + +define KernelPackage/ath5k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 5xxx wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath5k + DEPENDS+= @(PCI_SUPPORT||TARGET_ath25) +kmod-ath +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath5k/ath5k.ko + AUTOLOAD:=$(call AutoProbe,ath5k) +endef + +define KernelPackage/ath5k/description + This module adds support for wireless adapters based on + Atheros 5xxx chipset. +endef + +define KernelPackage/ath6kl + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros FullMAC wireless devices (common code for ath6kl_sdio and ath6kl_usb) + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + HIDDEN:=1 + DEPENDS+= +kmod-ath +@DRIVER_11N_SUPPORT + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko +endef + +define KernelPackage/ath6kl-sdio + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n SDIO wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + DEPENDS+= +kmod-mmc +kmod-ath6kl + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko + AUTOLOAD:=$(call AutoProbe,ath6kl_sdio) +endef + +define KernelPackage/ath6kl-sdio/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11n AR6003 and AR6004 family of chipsets. +endef + +define KernelPackage/ath6kl-usb + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n USB wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-ath6kl + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko + AUTOLOAD:=$(call AutoProbe,ath6kl_usb) +endef + +define KernelPackage/ath6kl-usb/description +This module adds support for wireless adapters based on the +Atheros IEEE 802.11n AR6004 chipset. +endef + +define KernelPackage/ath9k-common + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n wireless devices (common code for ath9k and ath9k_htc) + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + HIDDEN:=1 + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx||TARGET_ath79 +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko +endef + +define KernelPackage/ath9k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n PCI wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + DEPENDS+= @PCI_SUPPORT||TARGET_ar71xx||TARGET_ath79 +kmod-ath9k-common + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k.ko + AUTOLOAD:=$(call AutoProbe,ath9k) +endef + +define KernelPackage/ath9k/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11n AR5008 and AR9001 family of chipsets. +endef + +define KernelPackage/ath9k/config + + config ATH9K_HWRNG + bool "Add wireless noise as source of randomness to kernel entropy pool" + depends on PACKAGE_kmod-ath9k + select PACKAGE_kmod-random-core + default n + + config ATH9K_SUPPORT_PCOEM + bool "Support chips used in PC OEM cards" + depends on PACKAGE_kmod-ath9k + + config ATH9K_TX99 + bool "Enable TX99 support (WARNING: testing only, breaks normal operation!)" + depends on PACKAGE_kmod-ath9k + + config ATH9K_UBNTHSR + bool "Support for Ubiquiti UniFi Outdoor+ access point" + depends on PACKAGE_kmod-ath9k && (TARGET_ar71xx_generic||TARGET_ath79) + default y + +endef + +define KernelPackage/ath9k-htc + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n USB device support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core +ath9k-htc-firmware + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko + AUTOLOAD:=$(call AutoProbe,ath9k_htc) +endef + +define KernelPackage/ath9k-htc/description +This module adds support for wireless adapters based on +Atheros USB AR9271 and AR7010 family of chipsets. +endef + +define KernelPackage/ath10k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11ac wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath10k + DEPENDS+= @PCI_SUPPORT +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11W_SUPPORT \ + +ATH10K_THERMAL:kmod-hwmon-core +ATH10K_THERMAL:kmod-thermal + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath10k/ath10k_core.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath10k/ath10k_pci.ko + AUTOLOAD:=$(call AutoProbe,ath10k_pci) +endef + +define KernelPackage/ath10k/description +This module adds support for wireless adapters based on +Atheros IEEE 802.11ac family of chipsets. For now only +PCI is supported. +endef + +define KernelPackage/ath10k/config + + config ATH10K_LEDS + bool "Enable LED support" + default y + depends on PACKAGE_kmod-ath10k + + config ATH10K_THERMAL + bool "Enable thermal sensors and throttling support" + depends on PACKAGE_kmod-ath10k + +endef + +define KernelPackage/carl9170 + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Atheros AR9170 USB sticks + DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT +carl9170-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko + AUTOLOAD:=$(call AutoProbe,carl9170) +endef + +define KernelPackage/owl-loader + $(call KernelPackage/mac80211/Default) + TITLE:=Owl loader for initializing Atheros PCI(e) Wifi chips + DEPENDS:=@PCI_SUPPORT +kmod-ath9k + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.ko + AUTOLOAD:=$(call AutoProbe,ath9k_pci_owl_loader) +endef + +define KernelPackage/owl-loader/description + Kernel module that helps to initialize certain Qualcomm + Atheros' PCI(e) Wifi chips, which have the init data + (which contains the PCI device ID for example) stored + together with the calibration data in the file system. + + This is necessary for devices like the Cisco Meraki Z1. +endef diff --git a/feeds/wifi-ath10k/mac80211/broadcom.mk b/feeds/wifi-ath10k/mac80211/broadcom.mk new file mode 100644 index 000000000..4dfc4e29a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/broadcom.mk @@ -0,0 +1,510 @@ +PKG_DRIVERS += \ + b43 b43legacy brcmsmac brcmfmac brcmutil + +PKG_CONFIG_DEPENDS += \ + CONFIG_PACKAGE_B43_DEBUG \ + CONFIG_PACKAGE_B43_PIO \ + CONFIG_PACKAGE_B43_PHY_G \ + CONFIG_PACKAGE_B43_PHY_N \ + CONFIG_PACKAGE_B43_PHY_LP \ + CONFIG_PACKAGE_B43_PHY_HT \ + CONFIG_PACKAGE_B43_BUSES_BCMA_AND_SSB \ + CONFIG_PACKAGE_B43_BUSES_BCMA \ + CONFIG_PACKAGE_B43_BUSES_SSB \ + CONFIG_PACKAGE_BRCM80211_DEBUG + +config-$(call config_package,b43) += B43 +config-$(CONFIG_PACKAGE_B43_BUSES_BCMA_AND_SSB) += B43_BUSES_BCMA_AND_SSB +config-$(CONFIG_PACKAGE_B43_BUSES_BCMA) += B43_BUSES_BCMA +config-$(CONFIG_PACKAGE_B43_BUSES_SSB) += B43_BUSES_SSB +config-$(CONFIG_PACKAGE_B43_PHY_G) += B43_PHY_G +config-$(CONFIG_PACKAGE_B43_PHY_N) += B43_PHY_N +config-$(CONFIG_PACKAGE_B43_PHY_LP) += B43_PHY_LP +config-$(CONFIG_PACKAGE_B43_PHY_HT) += B43_PHY_HT +config-$(CONFIG_PACKAGE_B43_PIO) += B43_PIO +config-$(CONFIG_PACKAGE_B43_DEBUG) += B43_DEBUG + +config-$(call config_package,b43legacy) += B43LEGACY +config-y += B43LEGACY_DMA_MODE + +config-$(call config_package,brcmutil) += BRCMUTIL +config-$(call config_package,brcmsmac) += BRCMSMAC +config-$(call config_package,brcmfmac) += BRCMFMAC +config-$(CONFIG_BRCMFMAC_SDIO) += BRCMFMAC_SDIO +config-$(CONFIG_BRCMFMAC_USB) += BRCMFMAC_USB +config-$(CONFIG_BRCMFMAC_PCIE) += BRCMFMAC_PCIE +config-$(CONFIG_PACKAGE_BRCM80211_DEBUG) += BRCMDBG + +config-$(CONFIG_LEDS_TRIGGERS) += B43_LEDS B43LEGACY_LEDS + +#Broadcom firmware +ifneq ($(CONFIG_B43_FW_6_30),) + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=6.30.163.46 + PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).wl_apsta.o + PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2 + PKG_B43_FWV4_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/ + PKG_B43_FWV4_HASH:=a07c3b6b277833c7dbe61daa511f908cd66c5e2763eb7a0859abc36cd9335c2d +else +ifneq ($(CONFIG_B43_FW_5_10),) + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=5.10.56.27.3 + PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta/wl_prebuilt.o + PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)_mipsel.tar.bz2 + PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/ + PKG_B43_FWV4_HASH:=26a8c370f48fc129d0731cfd751c36cae1419b0bc8ca35781126744e60eae009 +else +ifneq ($(CONFIG_B43_FW_4_178),) + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=4.178.10.4 + PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o + PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2 + PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/ + PKG_B43_FWV4_HASH:=32f6ad98facbb9045646fdc8b54bb03086d204153253f9c65d0234a5d90ae53f +else +ifneq ($(CONFIG_B43_FW_5_100_138),) + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=5.100.138 + PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o + PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2 + PKG_B43_FWV4_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/ + PKG_B43_FWV4_HASH:=f1e7067aac5b62b67b8b6e4c517990277804339ac16065eb13c731ff909ae46f +else + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=4.150.10.5 + PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta_mimo.o + PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2 + PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/ + PKG_B43_FWV4_HASH:=a9f4e276a4d8d3a1cd0f2eb87080ae89b77f0a7140f06d4e9e2135fc44fdd533 +endif +endif +endif +endif +ifneq ($(CONFIG_B43_OPENFIRMWARE),) + PKG_B43_FWV4_NAME:=broadcom-wl + PKG_B43_FWV4_VERSION:=5.2 + PKG_B43_FWV4_OBJECT:=openfwwf-$(PKG_B43_FWV4_VERSION) + PKG_B43_FWV4_SOURCE:=openfwwf-$(PKG_B43_FWV4_VERSION).tar.gz + PKG_B43_FWV4_SOURCE_URL:=http://netweb.ing.unibs.it/~openfwwf/firmware + PKG_B43_FWV4_HASH:=9de03320083201080b2e94b81637ac07a159cf4e6f3481383e1a217e627bc0dc +endif + + +define Download/b43 + FILE:=$(PKG_B43_FWV4_SOURCE) + URL:=$(PKG_B43_FWV4_SOURCE_URL) + HASH:=$(PKG_B43_FWV4_HASH) +endef +$(eval $(call Download,b43)) + +define KernelPackage/b43 + $(call KernelPackage/mac80211/Default) + TITLE:=Broadcom 43xx wireless support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/b43 + KCONFIG:= \ + CONFIG_HW_RANDOM=y + # Depend on PCI_SUPPORT to make sure we can select kmod-bcma or kmod-ssb + DEPENDS += \ + @PCI_SUPPORT +@DRIVER_11W_SUPPORT +kmod-mac80211 +kmod-lib-cordic \ + $(if $(CONFIG_PACKAGE_B43_USE_SSB),+kmod-ssb) \ + $(if $(CONFIG_PACKAGE_B43_USE_BCMA),+kmod-bcma) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/b43/b43.ko + AUTOLOAD:=$(call AutoProbe,b43) + MENU:=1 +endef + +define KernelPackage/b43/config + +config PACKAGE_B43_USE_SSB + select PACKAGE_kmod-ssb + tristate + depends on !TARGET_bcm47xx && !TARGET_bcm63xx + default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA_AND_SSB + default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_SSB + +config PACKAGE_B43_USE_BCMA + select PACKAGE_kmod-bcma + tristate + depends on !TARGET_bcm47xx && !TARGET_bcm53xx + default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA_AND_SSB + default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA + + if PACKAGE_kmod-b43 + + choice + prompt "b43 firmware version" + default B43_FW_5_100_138 + help + This option allows you to select the version of the b43 firmware. + + config B43_FW_4_150 + bool "Firmware 410.2160 from driver 4.150.10.5 (old stable)" + help + Old stable firmware for BCM43xx devices. + + If unsure, select this. + + config B43_FW_4_178 + bool "Firmware 478.104 from driver 4.178.10.4" + help + Older firmware for BCM43xx devices. + + If unsure, select the "stable" firmware. + + config B43_FW_5_10 + bool "Firmware 508.1084 from driver 5.10.56.27" + help + Older firmware for BCM43xx devices. + + If unsure, select the "stable" firmware. + + config B43_FW_5_100_138 + bool "Firmware 666.2 from driver 5.100.138 (stable)" + help + The currently default firmware for BCM43xx devices. + + This firmware currently gets most of the testing and is needed for some N-PHY devices. + + If unsure, select the this firmware. + + config B43_FW_6_30 + bool "Firmware 784.2 from driver 6.30.163.46 (experimental)" + help + Newer experimental firmware for BCM43xx devices. + + This firmware is mostly untested. + + If unsure, select the "stable" firmware. + + config B43_OPENFIRMWARE + bool "Open FirmWare for WiFi networks" + help + Opensource firmware for BCM43xx devices. + + Do _not_ select this, unless you know what you are doing. + The Opensource firmware is not suitable for embedded devices, yet. + It does not support QoS, which is bad for AccessPoints. + It does not support hardware crypto acceleration, which is a showstopper + for embedded devices with low CPU resources. + + If unsure, select the "stable" firmware. + + endchoice + + config B43_FW_SQUASH + bool "Remove unnecessary firmware files" + depends on !B43_OPENFIRMWARE + default y + help + This options allows you to remove unnecessary b43 firmware files + from the final rootfs image. This can reduce the rootfs size by + up to 200k. + + If unsure, say Y. + + config B43_FW_SQUASH_COREREVS + string "Core revisions to include" + depends on B43_FW_SQUASH + default "5,6,7,8,9,10,11,13,15" if TARGET_bcm47xx_legacy + default "16,28,29,30" if TARGET_bcm47xx_mips74k + default "5,6,7,8,9,10,11,13,15,16,28,29,30" + help + This is a comma seperated list of core revision numbers. + + Example (keep files for rev5 only): + 5 + + Example (keep files for rev5 and rev11): + 5,11 + + config B43_FW_SQUASH_PHYTYPES + string "PHY types to include" + depends on B43_FW_SQUASH + default "G,N,LP" if TARGET_bcm47xx_legacy + default "N,HT" if TARGET_bcm47xx_mips74k + default "G,N,LP,HT" + help + This is a comma seperated list of PHY types: + A => A-PHY + AG => Dual A-PHY G-PHY + G => G-PHY + LP => LP-PHY + N => N-PHY + HT => HT-PHY + LCN => LCN-PHY + LCN40 => LCN40-PHY + AC => AC-PHY + + Example (keep files for G-PHY only): + G + + Example (keep files for G-PHY and N-PHY): + G,N + + choice + prompt "Supported buses" + default PACKAGE_B43_BUSES_BCMA_AND_SSB + help + This allows choosing buses that b43 should support. + + config PACKAGE_B43_BUSES_BCMA_AND_SSB + depends on !TARGET_bcm47xx_legacy && !TARGET_bcm47xx_mips74k && !TARGET_bcm53xx + bool "BCMA and SSB" + + config PACKAGE_B43_BUSES_BCMA + depends on !TARGET_bcm47xx_legacy + bool "BCMA only" + + config PACKAGE_B43_BUSES_SSB + depends on !TARGET_bcm47xx_mips74k && !TARGET_bcm53xx + bool "SSB only" + + endchoice + + config PACKAGE_B43_DEBUG + bool "Enable debug output and debugfs for b43" + default n + help + Enable additional debug output and runtime sanity checks for b43 + and enables the debugfs interface. + + If unsure, say N. + + config PACKAGE_B43_PIO + bool "Enable support for PIO transfer mode" + default n + help + Enable support for using PIO instead of DMA. Unless you have DMA + transfer problems you don't need this. + + If unsure, say N. + + config PACKAGE_B43_PHY_G + bool "Enable support for G-PHYs" + default n if TARGET_bcm47xx_mips74k + default y + help + Enable support for G-PHY. This includes support for the following devices: + PCI: BCM4306, BCM4311, BCM4318 + SoC: BCM5352E, BCM4712 + + If unsure, say Y. + + config PACKAGE_B43_PHY_N + bool "Enable support for N-PHYs" + default y + help + Enable support for N-PHY. This includes support for the following devices: + PCI: BCM4321, BCM4322, BCM43222, BCM43224, BCM43225 + SoC: BCM4716, BCM4717, BCM4718 + + Currently only 11g speed is available. + + If unsure, say Y. + + config PACKAGE_B43_PHY_LP + bool "Enable support for LP-PHYs" + default n if TARGET_bcm47xx_mips74k + default y + help + Enable support for LP-PHY. This includes support for the following devices: + PCI: BCM4312 + SoC: BCM5354 + + If unsure, say Y. + + config PACKAGE_B43_PHY_HT + bool "Enable support for HT-PHYs" + default n if TARGET_bcm47xx_legacy + default y + help + Enable support for HT-PHY. This includes support for the following devices: + PCI: BCM4331 + + Currently only 11g speed is available. + + If unsure, say Y. + + config PACKAGE_B43_PHY_LCN + bool "Enable support for LCN-PHYs" + depends on BROKEN + default n + help + Currently broken. + + If unsure, say N. + + endif +endef + +define KernelPackage/b43/description +Kernel module for Broadcom 43xx wireless support (mac80211 stack) new +endef + +define KernelPackage/b43legacy + $(call KernelPackage/mac80211/Default) + TITLE:=Broadcom 43xx-legacy wireless support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/b43 + KCONFIG:= \ + CONFIG_HW_RANDOM=y + DEPENDS+= +kmod-mac80211 +!(TARGET_bcm47xx||TARGET_bcm63xx):kmod-ssb @!TARGET_bcm47xx_mips74k +b43legacy-firmware +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/b43legacy/b43legacy.ko + AUTOLOAD:=$(call AutoProbe,b43legacy) + MENU:=1 +endef + +define KernelPackage/b43legacy/description +Kernel module for Broadcom 43xx-legacy wireless support (mac80211 stack) new +endef + + +define KernelPackage/brcmutil + $(call KernelPackage/mac80211/Default) + TITLE:=Broadcom IEEE802.11n common driver parts + URL:=https://wireless.wiki.kernel.org/en/users/drivers/brcm80211 + DEPENDS+=@PCI_SUPPORT||USB_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko + AUTOLOAD:=$(call AutoProbe,brcmutil) + MENU:=1 +endef + +define KernelPackage/brcmutil/description + This module contains some common parts needed by Broadcom Wireless drivers brcmsmac and brcmfmac. +endef + +define KernelPackage/brcmutil/config + if PACKAGE_kmod-brcmutil + + config PACKAGE_BRCM80211_DEBUG + bool "Broadcom wireless driver debugging" + help + Say Y, if you want to debug brcmsmac and brcmfmac wireless driver. + + endif +endef + +PKG_BRCMSMAC_FW_NAME:=broadcom-wl +PKG_BRCMSMAC_FW_VERSION:=5.100.138 +PKG_BRCMSMAC_FW_OBJECT:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION)/linux/wl_apsta.o +PKG_BRCMSMAC_FW_SOURCE:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION).tar.bz2 +PKG_BRCMSMAC_FW_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/ +PKG_BRCMSMAC_FW_HASH:=f1e7067aac5b62b67b8b6e4c517990277804339ac16065eb13c731ff909ae46f + +define Download/brcmsmac + FILE:=$(PKG_BRCMSMAC_FW_SOURCE) + URL:=$(PKG_BRCMSMAC_FW_SOURCE_URL) + HASH:=$(PKG_BRCMSMAC_FW_HASH) +endef +$(eval $(call Download,brcmsmac)) + +define KernelPackage/brcmsmac + $(call KernelPackage/mac80211/Default) + TITLE:=Broadcom IEEE802.11n PCIe SoftMAC WLAN driver + URL:=https://wireless.wiki.kernel.org/en/users/drivers/brcm80211 + DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +!TARGET_bcm47xx:kmod-bcma +kmod-lib-cordic +kmod-lib-crc8 +kmod-brcmutil +!BRCMSMAC_USE_FW_FROM_WL:brcmsmac-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcmsmac.ko + AUTOLOAD:=$(call AutoProbe,brcmsmac) + MENU:=1 +endef + +define KernelPackage/brcmsmac/description + Kernel module for Broadcom IEEE802.11n PCIe Wireless cards +endef + +define KernelPackage/brcmsmac/config + if PACKAGE_kmod-brcmsmac + + config BRCMSMAC_USE_FW_FROM_WL + bool "Use firmware extracted from broadcom proprietary driver" + default y + help + Instead of using the official brcmsmac firmware a firmware + version 666.2 extracted from the proprietary Broadcom driver + is used. This is needed to get core rev 17 used in bcm4716 + to work. + + If unsure, say Y. + + endif +endef + + +define KernelPackage/brcmfmac + $(call KernelPackage/mac80211/Default) + TITLE:=Broadcom IEEE802.11n USB FullMAC WLAN driver + URL:=https://wireless.wiki.kernel.org/en/users/drivers/brcm80211 + DEPENDS+= @USB_SUPPORT +kmod-cfg80211 +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11W_SUPPORT \ + +kmod-brcmutil +BRCMFMAC_SDIO:kmod-mmc @!TARGET_uml \ + +BRCMFMAC_USB:kmod-usb-core +BRCMFMAC_USB:brcmfmac-firmware-usb + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko + AUTOLOAD:=$(call AutoProbe,brcmfmac) +endef + +define KernelPackage/brcmfmac/description + Kernel module for Broadcom IEEE802.11n USB Wireless cards +endef + +define KernelPackage/brcmfmac/config + if PACKAGE_kmod-brcmfmac + + config BRCMFMAC_SDIO + bool "Enable SDIO bus interface support" + default y if TARGET_bcm27xx + default y if TARGET_sunxi + default n + help + Enable support for cards attached to an SDIO bus. + Select this option only if you are sure that your + board has a Broadcom wireless chip atacched to + that bus. + + config BRCMFMAC_USB + bool "Enable USB bus interface support" + depends on USB_SUPPORT + default y + help + Supported USB connected chipsets: + BCM43235, BCM43236, BCM43238 (all in revision 3 only) + BCM43143, BCM43242, BCM43566, BCM43569 + + config BRCMFMAC_PCIE + bool "Enable PCIE bus interface support" + depends on PCI_SUPPORT + default y + help + Supported PCIe connected chipsets: + BCM4354, BCM4356, BCM43567, BCM43570, BCM43602 + + endif +endef + + +define KernelPackage/b43/install + rm -rf $(1)/lib/firmware/ +ifeq ($(CONFIG_B43_OPENFIRMWARE),y) + tar xzf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)" +else + tar xjf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)" +endif + $(INSTALL_DIR) $(1)/lib/firmware/ +ifeq ($(CONFIG_B43_OPENFIRMWARE),y) + $(MAKE) -C "$(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/" + $(INSTALL_DIR) $(1)/lib/firmware/b43-open/ + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/ucode5.fw $(1)/lib/firmware/b43-open/ucode5.fw + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0bsinitvals5.fw $(1)/lib/firmware/b43-open/b0g0bsinitvals5.fw + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0initvals5.fw $(1)/lib/firmware/b43-open/b0g0initvals5.fw +else + b43-fwcutter -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT) +endif +ifneq ($(CONFIG_B43_FW_SQUASH),) + b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43" +endif +endef + +define KernelPackage/brcmsmac/install + $(INSTALL_DIR) $(1)/lib/firmware/brcm +ifeq ($(CONFIG_BRCMSMAC_USE_FW_FROM_WL),y) + tar xjf "$(DL_DIR)/$(PKG_BRCMSMAC_FW_SOURCE)" -C "$(PKG_BUILD_DIR)" + b43-fwcutter --brcmsmac -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_BRCMSMAC_FW_OBJECT) +endif +endef diff --git a/feeds/wifi-ath10k/mac80211/files/lib/netifd/mac80211.sh b/feeds/wifi-ath10k/mac80211/files/lib/netifd/mac80211.sh new file mode 100644 index 000000000..92e5c0e39 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/files/lib/netifd/mac80211.sh @@ -0,0 +1,36 @@ +mac80211_phy_to_path() { + local phy="$1" + + [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${phy} ] || return + + local path="$(readlink -f /sys/class/ieee80211/${phy}/device)" + [ -n "$path" ] || return + + path="${path##/sys/devices/}" + case "$path" in + platform*/pci*) path="${path##platform/}";; + esac + + local p + local seq="" + for p in $(ls /sys/class/ieee80211/$phy/device/ieee80211); do + [ "$p" = "$phy" ] && { + echo "$path${seq:++$seq}" + break + } + + seq=$((${seq:-0} + 1)) + done +} + +mac80211_path_to_phy() { + local path="$1" + + local p + for p in $(ls /sys/class/ieee80211); do + local cur="$(mac80211_phy_to_path "$p")" + case "$cur" in + *$path) echo "$p"; return;; + esac + done +} diff --git a/feeds/wifi-ath10k/mac80211/files/lib/netifd/wireless/mac80211.sh b/feeds/wifi-ath10k/mac80211/files/lib/netifd/wireless/mac80211.sh new file mode 100644 index 000000000..97c567031 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -0,0 +1,1232 @@ +#!/bin/sh +. /lib/netifd/netifd-wireless.sh +. /lib/netifd/hostapd.sh + +init_wireless_driver "$@" + +MP_CONFIG_INT="mesh_retry_timeout mesh_confirm_timeout mesh_holding_timeout mesh_max_peer_links + mesh_max_retries mesh_ttl mesh_element_ttl mesh_hwmp_max_preq_retries + mesh_path_refresh_time mesh_min_discovery_timeout mesh_hwmp_active_path_timeout + mesh_hwmp_preq_min_interval mesh_hwmp_net_diameter_traversal_time mesh_hwmp_rootmode + mesh_hwmp_rann_interval mesh_gate_announcements mesh_sync_offset_max_neighor + mesh_rssi_threshold mesh_hwmp_active_path_to_root_timeout mesh_hwmp_root_interval + mesh_hwmp_confirmation_interval mesh_awake_window mesh_plink_timeout" +MP_CONFIG_BOOL="mesh_auto_open_plinks mesh_fwding" +MP_CONFIG_STRING="mesh_power_mode" + +NEWAPLIST= +OLDAPLIST= +NEWSPLIST= +OLDSPLIST= +NEWUMLIST= +OLDUMLIST= + +drv_mac80211_init_device_config() { + hostapd_common_add_device_config + + config_add_string path phy 'macaddr:macaddr' + config_add_string tx_burst + config_add_string distance + config_add_int beacon_int chanbw frag rts + config_add_int rxantenna txantenna antenna_gain txpower + config_add_int num_global_macaddr + config_add_boolean noscan ht_coex acs_exclude_dfs + config_add_array ht_capab + config_add_array channels + config_add_array scan_list + config_add_boolean \ + rxldpc \ + short_gi_80 \ + short_gi_160 \ + tx_stbc_2by1 \ + su_beamformer \ + su_beamformee \ + mu_beamformer \ + mu_beamformee \ + he_su_beamformer \ + he_su_beamformee \ + he_mu_beamformer \ + vht_txop_ps \ + htc_vht \ + rx_antenna_pattern \ + tx_antenna_pattern \ + he_spr_sr_control \ + he_twt_required + config_add_int \ + beamformer_antennas \ + beamformee_antennas \ + vht_max_a_mpdu_len_exp \ + vht_max_mpdu \ + vht_link_adapt \ + vht160 \ + rx_stbc \ + tx_stbc \ + he_bss_color \ + he_spr_non_srg_obss_pd_max_offset + config_add_boolean \ + ldpc \ + greenfield \ + short_gi_20 \ + short_gi_40 \ + max_amsdu \ + dsss_cck_40 +} + +drv_mac80211_init_iface_config() { + hostapd_common_add_bss_config + + config_add_string 'macaddr:macaddr' ifname + + config_add_boolean wds powersave enable + config_add_string wds_bridge + config_add_int maxassoc + config_add_int max_listen_int + config_add_int dtim_period + config_add_int start_disabled + + # mesh + config_add_string mesh_id + config_add_int $MP_CONFIG_INT + config_add_boolean $MP_CONFIG_BOOL + config_add_string $MP_CONFIG_STRING +} + +mac80211_add_capabilities() { + local __var="$1"; shift + local __mask="$1"; shift + local __out= oifs + + oifs="$IFS" + IFS=: + for capab in "$@"; do + set -- $capab + + [ "$(($4))" -gt 0 ] || continue + [ "$(($__mask & $2))" -eq "$((${3:-$2}))" ] || continue + __out="$__out[$1]" + done + IFS="$oifs" + + export -n -- "$__var=$__out" +} + +mac80211_add_he_capabilities() { + local __out= oifs + + oifs="$IFS" + IFS=: + for capab in "$@"; do + set -- $capab + [ "$(($4))" -gt 0 ] || continue + [ "$(((0x$2) & $3))" -gt 0 ] || { + eval "$1=0" + continue + } + append base_cfg "$1=1" "$N" + done + IFS="$oifs" +} + +mac80211_hostapd_setup_base() { + local phy="$1" + + json_select config + + [ "$auto_channel" -gt 0 ] && channel=acs_survey + + [ "$auto_channel" -gt 0 ] && json_get_vars acs_exclude_dfs + [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] && + append base_cfg "acs_exclude_dfs=1" "$N" + + json_get_vars noscan ht_coex + json_get_values ht_capab_list ht_capab tx_burst + json_get_values channel_list channels + + [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \ + channel_list="$channel" + + set_default noscan 0 + + [ "$noscan" -gt 0 ] && hostapd_noscan=1 + [ "$tx_burst" = 0 ] && tx_burst= + + chan_ofs=0 + [ "$band" = "6g" ] && chan_ofs=1 + + ieee80211n=1 + ht_capab= + case "$htmode" in + VHT20|HT20|HE20) ;; + HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160) + case "$hwmode" in + a) + case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in + 1) ht_capab="[HT40+]";; + 0) ht_capab="[HT40-]";; + esac + ;; + *) + case "$htmode" in + HT40+) ht_capab="[HT40+]";; + HT40-) ht_capab="[HT40-]";; + *) + if [ "$channel" -lt 7 ]; then + ht_capab="[HT40+]" + else + ht_capab="[HT40-]" + fi + ;; + esac + ;; + esac + [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]" + ;; + *) ieee80211n= ;; + esac + + [ -n "$ieee80211n" ] && { + append base_cfg "ieee80211n=1" "$N" + + set_default ht_coex 0 + append base_cfg "ht_coex=$ht_coex" "$N" + + json_get_vars \ + ldpc:1 \ + greenfield:0 \ + short_gi_20:1 \ + short_gi_40:1 \ + tx_stbc:1 \ + rx_stbc:3 \ + max_amsdu:1 \ + dsss_cck_40:1 + + ht_cap_mask=0 + for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do + ht_cap_mask="$(($ht_cap_mask | $cap))" + done + + cap_rx_stbc=$((($ht_cap_mask >> 8) & 3)) + [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" + ht_cap_mask="$(( ($ht_cap_mask & ~(0x300)) | ($cap_rx_stbc << 8) ))" + + mac80211_add_capabilities ht_capab_flags $ht_cap_mask \ + LDPC:0x1::$ldpc \ + GF:0x10::$greenfield \ + SHORT-GI-20:0x20::$short_gi_20 \ + SHORT-GI-40:0x40::$short_gi_40 \ + TX-STBC:0x80::$tx_stbc \ + RX-STBC1:0x300:0x100:1 \ + RX-STBC12:0x300:0x200:1 \ + RX-STBC123:0x300:0x300:1 \ + MAX-AMSDU-7935:0x800::$max_amsdu \ + DSSS_CCK-40:0x1000::$dsss_cck_40 + + ht_capab="$ht_capab$ht_capab_flags" + [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N" + } + + # 802.11ac + enable_ac=0 + vht_oper_chwidth=0 + vht_center_seg0= + + idx="$channel" + case "$htmode" in + VHT20|HE20) enable_ac=1;; + VHT40|HE40) + case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in + 1) idx=$(($channel + 2));; + 0) idx=$(($channel - 2));; + esac + enable_ac=1 + vht_center_seg0=$idx + ;; + VHT80|HE80) + case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in + 1) idx=$(($channel + 6));; + 2) idx=$(($channel + 2));; + 3) idx=$(($channel - 2));; + 0) idx=$(($channel - 6));; + esac + enable_ac=1 + vht_oper_chwidth=1 + vht_center_seg0=$idx + ;; + VHT160|HE160) + if [ "$band" = "6g" ]; then + case "$channel" in + 1|5|9|13|17|21|25|29) idx=15;; + 33|37|41|45|49|53|57|61) idx=47;; + 65|69|73|77|81|85|89|93) idx=79;; + 97|101|105|109|113|117|121|125) idx=111;; + 129|133|137|141|145|149|153|157) idx=143;; + 161|165|169|173|177|181|185|189) idx=175;; + 193|197|201|205|209|213|217|221) idx=207;; + esac + else + case "$channel" in + 36|40|44|48|52|56|60|64) idx=50;; + 100|104|108|112|116|120|124|128) idx=114;; + esac + fi + enable_ac=1 + vht_oper_chwidth=2 + vht_center_seg0=$idx + ;; + esac + [ "$band" = "6g" ] && { + op_class= + case "$htmode" in + HE20) op_class=131;; + HE*) op_class=$((132 + $vht_oper_chwidth)) + esac + [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N" + } + [ "$hwmode" = "a" ] || enable_ac=0 + + if [ "$enable_ac" != "0" ]; then + json_get_vars \ + rxldpc:1 \ + short_gi_80:1 \ + short_gi_160:1 \ + tx_stbc_2by1:1 \ + su_beamformer:1 \ + su_beamformee:1 \ + mu_beamformer:1 \ + mu_beamformee:1 \ + vht_txop_ps:1 \ + htc_vht:1 \ + beamformee_antennas:4 \ + beamformer_antennas:4 \ + rx_antenna_pattern:1 \ + tx_antenna_pattern:1 \ + vht_max_a_mpdu_len_exp:7 \ + vht_max_mpdu:11454 \ + rx_stbc:4 \ + vht_link_adapt:3 \ + vht160:2 + + set_default tx_burst 2.0 + append base_cfg "ieee80211ac=1" "$N" + vht_cap=0 + for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do + vht_cap="$(($vht_cap | $cap))" + done + + append base_cfg "vht_oper_chwidth=$vht_oper_chwidth" "$N" + append base_cfg "vht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N" + + cap_rx_stbc=$((($vht_cap >> 8) & 7)) + [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" + vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))" + + mac80211_add_capabilities vht_capab $vht_cap \ + RXLDPC:0x10::$rxldpc \ + SHORT-GI-80:0x20::$short_gi_80 \ + SHORT-GI-160:0x40::$short_gi_160 \ + TX-STBC-2BY1:0x80::$tx_stbc_2by1 \ + SU-BEAMFORMER:0x800::$su_beamformer \ + SU-BEAMFORMEE:0x1000::$su_beamformee \ + MU-BEAMFORMER:0x80000::$mu_beamformer \ + MU-BEAMFORMEE:0x100000::$mu_beamformee \ + VHT-TXOP-PS:0x200000::$vht_txop_ps \ + HTC-VHT:0x400000::$htc_vht \ + RX-ANTENNA-PATTERN:0x10000000::$rx_antenna_pattern \ + TX-ANTENNA-PATTERN:0x20000000::$tx_antenna_pattern \ + RX-STBC-1:0x700:0x100:1 \ + RX-STBC-12:0x700:0x200:1 \ + RX-STBC-123:0x700:0x300:1 \ + RX-STBC-1234:0x700:0x400:1 \ + + [ "$(($vht_cap & 0x800))" -gt 0 -a "$su_beamformer" -gt 0 ] && { + cap_ant="$(( ( ($vht_cap >> 16) & 3 ) + 1 ))" + [ "$cap_ant" -gt "$beamformer_antennas" ] && cap_ant="$beamformer_antennas" + [ "$cap_ant" -gt 1 ] && vht_capab="$vht_capab[SOUNDING-DIMENSION-$cap_ant]" + } + + [ "$(($vht_cap & 0x1000))" -gt 0 -a "$su_beamformee" -gt 0 ] && { + cap_ant="$(( ( ($vht_cap >> 13) & 3 ) + 1 ))" + [ "$cap_ant" -gt "$beamformee_antennas" ] && cap_ant="$beamformee_antennas" + [ "$cap_ant" -gt 1 ] && vht_capab="$vht_capab[BF-ANTENNA-$cap_ant]" + } + + # supported Channel widths + vht160_hw=0 + [ "$(($vht_cap & 12))" -eq 4 -a 1 -le "$vht160" ] && \ + vht160_hw=1 + [ "$(($vht_cap & 12))" -eq 8 -a 2 -le "$vht160" ] && \ + vht160_hw=2 + [ "$vht160_hw" = 1 ] && vht_capab="$vht_capab[VHT160]" + [ "$vht160_hw" = 2 ] && vht_capab="$vht_capab[VHT160-80PLUS80]" + + # maximum MPDU length + vht_max_mpdu_hw=3895 + [ "$(($vht_cap & 3))" -ge 1 -a 7991 -le "$vht_max_mpdu" ] && \ + vht_max_mpdu_hw=7991 + [ "$(($vht_cap & 3))" -ge 2 -a 11454 -le "$vht_max_mpdu" ] && \ + vht_max_mpdu_hw=11454 + [ "$vht_max_mpdu_hw" != 3895 ] && \ + vht_capab="$vht_capab[MAX-MPDU-$vht_max_mpdu_hw]" + + # maximum A-MPDU length exponent + vht_max_a_mpdu_len_exp_hw=0 + [ "$(($vht_cap & 58720256))" -ge 8388608 -a 1 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=1 + [ "$(($vht_cap & 58720256))" -ge 16777216 -a 2 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=2 + [ "$(($vht_cap & 58720256))" -ge 25165824 -a 3 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=3 + [ "$(($vht_cap & 58720256))" -ge 33554432 -a 4 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=4 + [ "$(($vht_cap & 58720256))" -ge 41943040 -a 5 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=5 + [ "$(($vht_cap & 58720256))" -ge 50331648 -a 6 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=6 + [ "$(($vht_cap & 58720256))" -ge 58720256 -a 7 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=7 + vht_capab="$vht_capab[MAX-A-MPDU-LEN-EXP$vht_max_a_mpdu_len_exp_hw]" + + # whether or not the STA supports link adaptation using VHT variant + vht_link_adapt_hw=0 + [ "$(($vht_cap & 201326592))" -ge 134217728 -a 2 -le "$vht_link_adapt" ] && \ + vht_link_adapt_hw=2 + [ "$(($vht_cap & 201326592))" -ge 201326592 -a 3 -le "$vht_link_adapt" ] && \ + vht_link_adapt_hw=3 + [ "$vht_link_adapt_hw" != 0 ] && \ + vht_capab="$vht_capab[VHT-LINK-ADAPT-$vht_link_adapt_hw]" + + [ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" "$N" + fi + + # 802.11ax + enable_ax=0 + case "$htmode" in + HE*) enable_ax=1 ;; + esac + + if [ "$enable_ax" != "0" ]; then + json_get_vars \ + he_su_beamformer:1 \ + he_su_beamformee:0 \ + he_mu_beamformer:1 \ + he_twt_required:0 \ + he_spr_sr_control:0 \ + he_spr_non_srg_obss_pd_max_offset:1 \ + he_bss_color + + he_phy_cap=$(iw phy "$phy" info | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1) + he_phy_cap=${he_phy_cap:2} + he_mac_cap=$(iw phy "$phy" info | awk -F "[()]" '/HE MAC Capabilities/ { print $2 }' | head -1) + he_mac_cap=${he_mac_cap:2} + + append base_cfg "ieee80211ax=1" "$N" + [ -n "$he_bss_color" ] && append base_cfg "he_bss_color=$he_bss_color" "$N" + [ "$hwmode" = "a" ] && { + append base_cfg "he_oper_chwidth=$vht_oper_chwidth" "$N" + append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N" + } + + mac80211_add_he_capabilities \ + he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \ + he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \ + he_mu_beamformer:${he_phy_cap:8:2}:0x2:$he_mu_beamformer \ + he_spr_sr_control:${he_phy_cap:14:2}:0x1:$he_spr_sr_control \ + he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required + + [ "$he_spr_sr_control" -gt 0 ] && append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N" + + append base_cfg "he_default_pe_duration=4" "$N" + append base_cfg "he_rts_threshold=1023" "$N" + append base_cfg "he_mu_edca_qos_info_param_count=0" "$N" + append base_cfg "he_mu_edca_qos_info_q_ack=0" "$N" + append base_cfg "he_mu_edca_qos_info_queue_request=0" "$N" + append base_cfg "he_mu_edca_qos_info_txop_request=0" "$N" + append base_cfg "he_mu_edca_ac_be_aifsn=8" "$N" + append base_cfg "he_mu_edca_ac_be_aci=0" "$N" + append base_cfg "he_mu_edca_ac_be_ecwmin=9" "$N" + append base_cfg "he_mu_edca_ac_be_ecwmax=10" "$N" + append base_cfg "he_mu_edca_ac_be_timer=255" "$N" + append base_cfg "he_mu_edca_ac_bk_aifsn=15" "$N" + append base_cfg "he_mu_edca_ac_bk_aci=1" "$N" + append base_cfg "he_mu_edca_ac_bk_ecwmin=9" "$N" + append base_cfg "he_mu_edca_ac_bk_ecwmax=10" "$N" + append base_cfg "he_mu_edca_ac_bk_timer=255" "$N" + append base_cfg "he_mu_edca_ac_vi_ecwmin=5" "$N" + append base_cfg "he_mu_edca_ac_vi_ecwmax=7" "$N" + append base_cfg "he_mu_edca_ac_vi_aifsn=5" "$N" + append base_cfg "he_mu_edca_ac_vi_aci=2" "$N" + append base_cfg "he_mu_edca_ac_vi_timer=255" "$N" + append base_cfg "he_mu_edca_ac_vo_aifsn=5" "$N" + append base_cfg "he_mu_edca_ac_vo_aci=3" "$N" + append base_cfg "he_mu_edca_ac_vo_ecwmin=5" "$N" + append base_cfg "he_mu_edca_ac_vo_ecwmax=7" "$N" + append base_cfg "he_mu_edca_ac_vo_timer=255" "$N" + fi + + hostapd_prepare_device_config "$hostapd_conf_file" nl80211 + cat >> "$hostapd_conf_file" <> $hostapd_conf_file +} + +mac80211_hostapd_setup_bss() { + local phy="$1" + local ifname="$2" + local macaddr="$3" + local type="$4" + + hostapd_cfg= + append hostapd_cfg "$type=$ifname" "$N" + + hostapd_set_bss_options hostapd_cfg "$phy" "$vif" || return 1 + json_get_vars wds wds_bridge dtim_period max_listen_int start_disabled + + set_default wds 0 + set_default start_disabled 0 + + [ "$wds" -gt 0 ] && { + append hostapd_cfg "wds_sta=1" "$N" + [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N" + } + [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N" + + cat >> /var/run/hostapd-$phy.conf </dev/null); do + grep -i -q "$macaddr" "/sys/class/ieee80211/${phy}/macaddress" && return 0 + done + } + return 1 +} + +mac80211_check_ap() { + has_ap=1 +} + +mac80211_iw_interface_add() { + local phy="$1" + local ifname="$2" + local type="$3" + local wdsflag="$4" + local rc + local oldifname + + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag >/dev/null 2>&1 + rc="$?" + + [ "$rc" = 233 ] && { + # Device might have just been deleted, give the kernel some time to finish cleaning it up + sleep 1 + + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag >/dev/null 2>&1 + rc="$?" + } + + [ "$rc" = 233 ] && { + # Keep matching pre-existing interface + [ -d "/sys/class/ieee80211/${phy}/device/net/${ifname}" ] && \ + case "$(iw dev $ifname info | grep "^\ttype" | cut -d' ' -f2- 2>/dev/null)" in + "AP") + [ "$type" = "__ap" ] && rc=0 + ;; + "IBSS") + [ "$type" = "adhoc" ] && rc=0 + ;; + "managed") + [ "$type" = "managed" ] && rc=0 + ;; + "mesh point") + [ "$type" = "mp" ] && rc=0 + ;; + "monitor") + [ "$type" = "monitor" ] && rc=0 + ;; + esac + } + + [ "$rc" = 233 ] && { + iw dev "$ifname" del >/dev/null 2>&1 + [ "$?" = 0 ] && { + sleep 1 + + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag >/dev/null 2>&1 + rc="$?" + } + } + + [ "$rc" != 0 ] && { + # Device might not support virtual interfaces, so the interface never got deleted in the first place. + # Check if the interface already exists, and avoid failing in this case. + [ -d "/sys/class/ieee80211/${phy}/device/net/${ifname}" ] && rc=0 + } + + [ "$rc" != 0 ] && { + # Device doesn't support virtual interfaces and may have existing interface other than ifname. + oldifname="$(basename "/sys/class/ieee80211/${phy}/device/net"/* 2>/dev/null)" + [ "$oldifname" ] && ip link set "$oldifname" name "$ifname" 1>/dev/null 2>&1 + rc="$?" + } + + [ "$rc" != 0 ] && echo "Failed to create interface $ifname" + return $rc +} + +mac80211_prepare_vif() { + local multiple_bssid=$1 + json_select config + + json_get_vars ifname mode ssid wds powersave macaddr enable wpa_psk_file vlan_file + + [ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}" + if_idx=$((${if_idx:-0} + 1)) + + set_default wds 0 + set_default powersave 0 + + json_select .. + + [ -n "$macaddr" ] || { + macaddr="$(mac80211_generate_mac $phy $multiple_bssid)" + macidx="$(($macidx + 1))" + } + + json_add_object data + json_add_string ifname "$ifname" + json_close_object + + [ "$mode" == "ap" ] && { + [ -z "$wpa_psk_file" ] && hostapd_set_psk "$ifname" + [ -z "$vlan_file" ] && hostapd_set_vlan "$ifname" + } + + json_select config + + # It is far easier to delete and create the desired interface + case "$mode" in + adhoc) + mac80211_iw_interface_add "$phy" "$ifname" adhoc || return + ;; + ap) + # Hostapd will handle recreating the interface and + # subsequent virtual APs belonging to the same PHY + if [ -n "$hostapd_ctrl" ]; then + type=bss + else + type=interface + fi + + mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" "$type" || return + + NEWAPLIST="${NEWAPLIST}$ifname " + [ -n "$hostapd_ctrl" ] || { + ap_ifname="${ifname}" + hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}" + } + ;; + mesh) + mac80211_iw_interface_add "$phy" "$ifname" mp || return + ;; + monitor) + mac80211_iw_interface_add "$phy" "$ifname" monitor || return + ;; + sta) + local wdsflag= + [ "$enable" = 0 ] || staidx="$(($staidx + 1))" + [ "$wds" -gt 0 ] && wdsflag="4addr on" + mac80211_iw_interface_add "$phy" "$ifname" managed "$wdsflag" || return + if [ "$wds" -gt 0 ]; then + iw "$ifname" set 4addr on + else + iw "$ifname" set 4addr off + fi + [ "$powersave" -gt 0 ] && powersave="on" || powersave="off" + iw "$ifname" set power_save "$powersave" + ;; + esac + + case "$mode" in + monitor|mesh) + [ "$auto_channel" -gt 0 ] || iw dev "$ifname" set channel "$channel" $iw_htmode + ;; + esac + + if [ "$mode" != "ap" ]; then + # ALL ap functionality will be passed to hostapd + # All interfaces must have unique mac addresses + # which can either be explicitly set in the device + # section, or automatically generated + ip link set dev "$ifname" address "$macaddr" + fi + + json_select .. +} + +mac80211_setup_supplicant() { + local enable=$1 + local add_sp=0 + local spobj="$(ubus -S list | grep wpa_supplicant.${ifname})" + + [ "$enable" = 0 ] && { + ubus call wpa_supplicant.${phy} config_remove "{\"iface\":\"$ifname\"}" + ip link set dev "$ifname" down + iw dev "$ifname" del + return 0 + } + + wpa_supplicant_prepare_interface "$ifname" nl80211 || { + iw dev "$ifname" del + return 1 + } + if [ "$mode" = "sta" ]; then + wpa_supplicant_add_network "$ifname" + else + wpa_supplicant_add_network "$ifname" "$freq" "$htmode" "$noscan" + fi + + NEWSPLIST="${NEWSPLIST}$ifname " + + if [ "${NEWAPLIST%% *}" != "${OLDAPLIST%% *}" ]; then + [ "$spobj" ] && ubus call wpa_supplicant config_remove "{\"iface\":\"$ifname\"}" + add_sp=1 + fi + [ -z "$spobj" ] && add_sp=1 + + NEW_MD5_SP=$(test -e "${_config}" && md5sum ${_config}) + OLD_MD5_SP=$(uci -q -P /var/state get wireless._${phy}.md5_${ifname}) + if [ "$add_sp" = "1" ]; then + wpa_supplicant_run "$ifname" "$hostapd_ctrl" + else + [ "${NEW_MD5_SP}" == "${OLD_MD5_SP}" ] || ubus call $spobj reload + fi + uci -q -P /var/state set wireless._${phy}.md5_${ifname}="${NEW_MD5_SP}" + return 0 +} + +mac80211_setup_supplicant_noctl() { + local enable=$1 + local spobj="$(ubus -S list | grep wpa_supplicant.${ifname})" + wpa_supplicant_prepare_interface "$ifname" nl80211 || { + iw dev "$ifname" del + return 1 + } + + wpa_supplicant_add_network "$ifname" "$freq" "$htmode" "$noscan" + + NEWSPLIST="${NEWSPLIST}$ifname " + [ "$enable" = 0 ] && { + ubus call wpa_supplicant config_remove "{\"iface\":\"$ifname\"}" + ip link set dev "$ifname" down + return 0 + } + if [ -z "$spobj" ]; then + wpa_supplicant_run "$ifname" + else + ubus call $spobj reload + fi +} + +mac80211_prepare_iw_htmode() { + case "$htmode" in + VHT20|HT20) iw_htmode=HT20;; + HT40*|VHT40|VHT160) + case "$band" in + 2g) + case "$htmode" in + HT40+) iw_htmode="HT40+";; + HT40-) iw_htmode="HT40-";; + *) + if [ "$channel" -lt 7 ]; then + iw_htmode="HT40+" + else + iw_htmode="HT40-" + fi + ;; + esac + ;; + *) + case "$(( ($channel / 4) % 2 ))" in + 1) iw_htmode="HT40+" ;; + 0) iw_htmode="HT40-";; + esac + ;; + esac + [ "$auto_channel" -gt 0 ] && iw_htmode="HT40+" + ;; + VHT80) + iw_htmode="80MHZ" + ;; + NONE|NOHT) + iw_htmode="NOHT" + ;; + *) iw_htmode="" ;; + esac +} + +mac80211_setup_adhoc() { + local enable=$1 + json_get_vars bssid ssid key mcast_rate + + NEWUMLIST="${NEWUMLIST}$ifname " + + [ "$enable" = 0 ] && { + ip link set dev "$ifname" down + return 0 + } + + keyspec= + [ "$auth_type" = "wep" ] && { + set_default key 1 + case "$key" in + [1234]) + local idx + for idx in 1 2 3 4; do + json_get_var ikey "key$idx" + + [ -n "$ikey" ] && { + ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")" + [ $idx -eq $key ] && ikey="d:$ikey" + append keyspec "$ikey" + } + done + ;; + *) + append keyspec "d:0:$(prepare_key_wep "$key")" + ;; + esac + } + + brstr= + for br in $basic_rate_list; do + wpa_supplicant_add_rate brstr "$br" + done + + mcval= + [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate" + + iw dev "$ifname" ibss join "$ssid" $freq $iw_htmode fixed-freq $bssid \ + beacon-interval $beacon_int \ + ${brstr:+basic-rates $brstr} \ + ${mcval:+mcast-rate $mcval} \ + ${keyspec:+keys $keyspec} +} + +mac80211_setup_mesh() { + local enable=$1 + json_get_vars ssid mesh_id mcast_rate + + NEWUMLIST="${NEWUMLIST}$ifname " + + [ "$enable" = 0 ] && { + ip link set dev "$ifname" down + return 0 + } + + mcval= + [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate" + [ -n "$mesh_id" ] && ssid="$mesh_id" + + iw dev "$ifname" mesh join "$ssid" freq $freq $iw_htmode \ + ${mcval:+mcast-rate $mcval} \ + beacon-interval $beacon_int +} + +mac80211_setup_vif() { + local name="$1" + local failed + local action=up + + json_select data + json_get_vars ifname + json_select .. + + json_select config + json_get_vars mode + json_get_var vif_txpower + json_get_var vif_enable enable 1 + + [ "$vif_enable" = 1 ] || action=down + if [ "$mode" != "ap" ] || [ "$ifname" = "$ap_ifname" ]; then + ip link set dev "$ifname" "$action" || { + wireless_setup_vif_failed IFUP_ERROR + json_select .. + return + } + [ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00" + fi + + case "$mode" in + mesh) + wireless_vif_parse_encryption + [ -z "$htmode" ] && htmode="NOHT"; + if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then + mac80211_setup_supplicant $vif_enable || failed=1 + else + mac80211_setup_mesh $vif_enable + fi + for var in $MP_CONFIG_INT $MP_CONFIG_BOOL $MP_CONFIG_STRING; do + json_get_var mp_val "$var" + [ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val" + done + ;; + adhoc) + wireless_vif_parse_encryption + if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then + mac80211_setup_supplicant_noctl $vif_enable || failed=1 + else + mac80211_setup_adhoc $vif_enable + fi + ;; + sta) + mac80211_setup_supplicant $vif_enable || failed=1 + ;; + esac + + json_select .. + [ -n "$failed" ] || wireless_add_vif "$name" "$ifname" +} + +get_freq() { + local phy="$1" + local channel="$2" + local band="$3" + + case "$band" in + 2g) band="1:";; + 5g) band="2:";; + 60g) band="3:";; + 6g) band="4:";; + esac + + iw "$phy" info | awk -v band="$band" -v channel="[$channel]" ' + +$1 ~ /Band/ { + band_match = band == $2 +} + +band_match && $3 == "MHz" && $4 == channel { + print $2 + exit +} +' +} + + +chan_is_dfs() { + local phy="$1" + local chan="$2" + iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep -q "MHz.*radar detection" + return $! +} + +mac80211_vap_cleanup() { + local service="$1" + local vaps="$2" + + for wdev in $vaps; do + [ "$service" != "none" ] && ubus call ${service} config_remove "{\"iface\":\"$wdev\"}" + ip link set dev "$wdev" down 2>/dev/null + iw dev "$wdev" del + done +} + +mac80211_interface_cleanup() { + local phy="$1" + local primary_ap=$(uci -q -P /var/state get wireless._${phy}.aplist) + primary_ap=${primary_ap%% *} + + mac80211_vap_cleanup hostapd "${primary_ap}" + mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)" + mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)" +} + +mac80211_set_noscan() { + hostapd_noscan=1 +} + +drv_mac80211_cleanup() { + hostapd_common_cleanup +} + +drv_mac80211_setup() { + json_select config + json_get_vars \ + phy macaddr path \ + country chanbw distance \ + txpower antenna_gain \ + rxantenna txantenna \ + frag rts beacon_int:100 htmode \ + multiple_bssid:0 \ + num_global_macaddr + json_get_values basic_rate_list basic_rate + json_get_values scan_list scan_list + json_select .. + + find_phy || { + echo "Could not find PHY for device '$1'" + wireless_set_retry 0 + return 1 + } + + wireless_set_data phy="$phy" + [ -z "$(uci -q -P /var/state show wireless._${phy})" ] && uci -q -P /var/state set wireless._${phy}=phy + + OLDAPLIST=$(uci -q -P /var/state get wireless._${phy}.aplist) + OLDSPLIST=$(uci -q -P /var/state get wireless._${phy}.splist) + OLDUMLIST=$(uci -q -P /var/state get wireless._${phy}.umlist) + + local wdev + local cwdev + local found + + for wdev in $(list_phy_interfaces "$phy"); do + found=0 + for cwdev in $OLDAPLIST $OLDSPLIST $OLDUMLIST; do + if [ "$wdev" = "$cwdev" ]; then + found=1 + break + fi + done + if [ "$found" = "0" ]; then + ip link set dev "$wdev" down + iw dev "$wdev" del + fi + done + + # convert channel to frequency + [ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel" "$band")" + + [ -n "$country" ] && { + iw reg get | grep -q "^country $country:" || { + iw reg set "$country" + sleep 1 + } + } + + hostapd_conf_file="/var/run/hostapd-$phy.conf" + + no_ap=1 + macidx=0 + staidx=0 + + [ -n "$chanbw" ] && { + for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do + [ -f "$file" ] && echo "$chanbw" > "$file" + done + } + + set_default rxantenna 0xffffffff + set_default txantenna 0xffffffff + set_default distance 0 + set_default antenna_gain 0 + set_default num_global_macaddr 1 + + [ "$txantenna" = "all" ] && txantenna=0xffffffff + [ "$rxantenna" = "all" ] && rxantenna=0xffffffff + + iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1 + iw phy "$phy" set antenna_gain $antenna_gain >/dev/null 2>&1 + iw phy "$phy" set distance "$distance" >/dev/null 2>&1 + + if [ -n "$txpower" ]; then + iw phy "$phy" set txpower fixed "${txpower%%.*}00" + else + iw phy "$phy" set txpower auto + fi + + [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}" + [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}" + + has_ap= + hostapd_ctrl= + ap_ifname= + hostapd_noscan= + for_each_interface "ap" mac80211_check_ap + + rm -f "$hostapd_conf_file" + + for_each_interface "sta adhoc mesh" mac80211_set_noscan + [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy" + + mac80211_prepare_iw_htmode + for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif + NEWAPLIST= + for_each_interface "ap" mac80211_prepare_vif ${multiple_bssid} + NEW_MD5=$(test -e "${hostapd_conf_file}" && md5sum ${hostapd_conf_file}) + OLD_MD5=$(uci -q -P /var/state get wireless._${phy}.md5) + if [ "${NEWAPLIST}" != "${OLDAPLIST}" ]; then + mac80211_vap_cleanup hostapd "${OLDAPLIST}" + fi + [ -n "${NEWAPLIST}" ] && mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap + local add_ap=0 + local primary_ap=${NEWAPLIST%% *} + [ -n "$hostapd_ctrl" ] && { + local no_reload=1 + if [ -n "$(ubus list | grep hostapd.$primary_ap)" ]; then + no_reload=0 + [ "${NEW_MD5}" = "${OLD_MD5}" ] || { + ubus call hostapd.$primary_ap reload + no_reload=$? + if [ "$no_reload" != "0" ]; then + mac80211_vap_cleanup hostapd "${OLDAPLIST}" + mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)" + mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)" + sleep 2 + mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap + for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif + fi + } + fi + if [ "$no_reload" != "0" ]; then + add_ap=1 + ubus wait_for hostapd + local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")" + ret="$?" + [ "$ret" != 0 -o -z "$hostapd_res" ] && { + wireless_setup_failed HOSTAPD_START_FAILED + return + } + wireless_add_process "$(jsonfilter -s "$hostapd_res" -l 1 -e @.pid)" "/usr/sbin/hostapd" 1 1 + fi + } + uci -q -P /var/state set wireless._${phy}.aplist="${NEWAPLIST}" + uci -q -P /var/state set wireless._${phy}.md5="${NEW_MD5}" + + [ "${add_ap}" = 1 ] && sleep 1 + for_each_interface "ap" mac80211_setup_vif + + NEWSPLIST= + NEWUMLIST= + + for_each_interface "sta adhoc mesh monitor" mac80211_setup_vif + + uci -q -P /var/state set wireless._${phy}.splist="${NEWSPLIST}" + uci -q -P /var/state set wireless._${phy}.umlist="${NEWUMLIST}" + + local foundvap + local dropvap="" + for oldvap in $OLDSPLIST; do + foundvap=0 + for newvap in $NEWSPLIST; do + [ "$oldvap" = "$newvap" ] && foundvap=1 + done + [ "$foundvap" = "0" ] && dropvap="$dropvap $oldvap" + done + [ -n "$dropvap" ] && mac80211_vap_cleanup wpa_supplicant "$dropvap" + wireless_set_up +} + +_list_phy_interfaces() { + local phy="$1" + if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then + ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null; + else + ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g' + fi +} + +list_phy_interfaces() { + local phy="$1" + + for dev in $(_list_phy_interfaces "$phy"); do + readlink "/sys/class/net/${dev}/phy80211" | grep -q "/${phy}\$" || continue + echo "$dev" + done +} + +drv_mac80211_teardown() { + json_select data + json_get_vars phy + json_select .. + [ -n "$phy" ] || { + echo "Bug: PHY is undefined for device '$1'" + return 1 + } + + mac80211_interface_cleanup "$phy" + uci -q -P /var/state revert wireless._${phy} +} + +add_driver mac80211 diff --git a/feeds/wifi-ath10k/mac80211/files/lib/wifi/mac80211.sh b/feeds/wifi-ath10k/mac80211/files/lib/wifi/mac80211.sh new file mode 100644 index 000000000..6aa46b0c7 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/files/lib/wifi/mac80211.sh @@ -0,0 +1,190 @@ +#!/bin/sh + +append DRIVERS "mac80211" + +lookup_phy() { + [ -n "$phy" ] && { + [ -d /sys/class/ieee80211/$phy ] && return + } + + local devpath + config_get devpath "$device" path + [ -n "$devpath" ] && { + phy="$(iwinfo nl80211 phyname "path=$devpath")" + [ -n "$phy" ] && return + } + + local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" + [ -n "$macaddr" ] && { + for _phy in /sys/class/ieee80211/*; do + [ -e "$_phy" ] || continue + + [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue + phy="${_phy##*/}" + return + done + } + phy= + return +} + +find_mac80211_phy() { + local device="$1" + + config_get phy "$device" phy + lookup_phy + [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || { + echo "PHY for wifi device $1 not found" + return 1 + } + config_set "$device" phy "$phy" + + config_get macaddr "$device" macaddr + [ -z "$macaddr" ] && { + config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)" + } + + return 0 +} + +check_mac80211_device() { + config_get phy "$1" phy + [ -z "$phy" ] && { + find_mac80211_phy "$1" >/dev/null || return 0 + config_get phy "$1" phy + } + [ "$phy" = "$dev" ] && found=1 +} + + +__get_band_defaults() { + local phy="$1" + + ( iw phy "$phy" info; echo ) | awk ' +BEGIN { + bands = "" +} + +($1 == "Band" || $1 == "") && band { + if (channel) { + mode="NOHT" + if (ht) mode="HT20" + if (vht && band != "1:") mode="VHT80" + if (he) mode="HE80" + if (he && band == "1:") mode="HE20" + sub("\\[", "", channel) + sub("\\]", "", channel) + bands = bands band channel ":" mode " " + } + band="" +} + +$1 == "Band" { + band = $2 + channel = "" + vht = "" + ht = "" + he = "" +} + +$0 ~ "Capabilities:" { + ht=1 +} + +$0 ~ "VHT Capabilities" { + vht=1 +} + +$0 ~ "HE Iftypes" { + he=1 +} + +$1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel { + channel = $4 +} + +END { + print bands +}' +} + +get_band_defaults() { + local phy="$1" + + for c in $(__get_band_defaults "$phy"); do + local band="${c%%:*}" + c="${c#*:}" + local chan="${c%%:*}" + c="${c#*:}" + local mode="${c%%:*}" + + case "$band" in + 1) band=2g;; + 2) band=5g;; + 3) band=60g;; + 4) band=6g;; + *) band="";; + esac + + [ -n "$band" ] || continue + [ -n "$mode_band" -a "$band" = "6g" ] && return + + mode_band="$band" + channel="$chan" + htmode="$mode" + done +} + +detect_mac80211() { + devidx=0 + config_load wireless + while :; do + config_get type "radio$devidx" type + [ -n "$type" ] || break + devidx=$(($devidx + 1)) + done + + for _dev in /sys/class/ieee80211/*; do + [ -e "$_dev" ] || continue + + dev="${_dev##*/}" + + found=0 + config_foreach check_mac80211_device wifi-device + [ "$found" -gt 0 ] && continue + + mode_band="" + channel="" + htmode="" + ht_capab="" + + get_band_defaults "$dev" + + path="$(iwinfo nl80211 path "$dev")" + if [ -n "$path" ]; then + dev_id="set wireless.radio${devidx}.path='$path'" + else + dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" + fi + + uci -q batch <<-EOF + set wireless.radio${devidx}=wifi-device + set wireless.radio${devidx}.type=mac80211 + ${dev_id} + set wireless.radio${devidx}.channel=${channel} + set wireless.radio${devidx}.band=${mode_band} + set wireless.radio${devidx}.htmode=$htmode + set wireless.radio${devidx}.disabled=1 + + set wireless.default_radio${devidx}=wifi-iface + set wireless.default_radio${devidx}.device=radio${devidx} + set wireless.default_radio${devidx}.network=lan + set wireless.default_radio${devidx}.mode=ap + set wireless.default_radio${devidx}.ssid=OpenWrt + set wireless.default_radio${devidx}.encryption=none +EOF + uci -q commit wireless + + devidx=$(($devidx + 1)) + done +} diff --git a/feeds/wifi-ath10k/mac80211/files/mac80211.hotplug b/feeds/wifi-ath10k/mac80211/files/mac80211.hotplug new file mode 100644 index 000000000..b86555266 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/files/mac80211.hotplug @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "${ACTION}" = "add" ] && { + /sbin/wifi config +} diff --git a/feeds/wifi-ath10k/mac80211/intel.mk b/feeds/wifi-ath10k/mac80211/intel.mk new file mode 100644 index 000000000..a8ae4ff7c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/intel.mk @@ -0,0 +1,200 @@ +PKG_DRIVERS += \ + iwl-legacy iwl3945 iwl4965 iwlwifi \ + libipw ipw2100 ipw2200 \ + +config-$(call config_package,iwl-legacy) += IWLEGACY +config-$(call config_package,iwl3945) += IWL3945 +config-$(call config_package,iwl4965) += IWL4965 +config-$(call config_package,iwlwifi) += IWLWIFI IWLDVM IWLMVM +config-$(CONFIG_PACKAGE_IWLWIFI_DEBUG)+= IWLWIFI_DEBUG +config-$(CONFIG_PACKAGE_IWLWIFI_DEBUGFS)+= IWLWIFI_DEBUGFS + +config-$(call config_package,libipw) += LIBIPW +config-$(call config_package,ipw2100) += IPW2100 +config-$(call config_package,ipw2200) += IPW2200 + +define KernelPackage/iwlwifi + $(call KernelPackage/mac80211/Default) + DEPENDS:= +kmod-mac80211 @PCI_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11W_SUPPORT + TITLE:=Intel AGN Wireless support + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlwifi/dvm/iwldvm.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlwifi/mvm/iwlmvm.ko + AUTOLOAD:=$(call AutoProbe,iwlwifi iwldvm iwlmvm) + MENU:=1 +endef + +define KernelPackage/iwlwifi/description + iwlwifi kernel module for + Intel Wireless WiFi Link 6250AGN Adapter + Intel 6000 Series Wi-Fi Adapters (6200AGN and 6300AGN) + Intel WiFi Link 1000BGN + Intel Wireless WiFi 5150AGN + Intel Wireless WiFi 5100AGN, 5300AGN, and 5350AGN + Intel 6005 Series Wi-Fi Adapters + Intel 6030 Series Wi-Fi Adapters + Intel Wireless WiFi Link 6150BGN 2 Adapter + Intel 100 Series Wi-Fi Adapters (100BGN and 130BGN) + Intel 2000 Series Wi-Fi Adapters + Intel 7260 Wi-Fi Adapter + Intel 3160 Wi-Fi Adapter + Intel 7265 Wi-Fi Adapter + Intel 8260 Wi-Fi Adapter + Intel 3165 Wi-Fi Adapter +endef + +define KernelPackage/iwlwifi/config + if PACKAGE_kmod-iwlwifi + + config PACKAGE_IWLWIFI_DEBUG + bool "Enable full debugging output in the iwlwifi driver" + default n + help + This option will enable debug tracing output for the iwlwifi drivers + + This will result in the kernel module being ~100k larger. You can + control which debug output is sent to the kernel log by setting the + value in + + /sys/module/iwlwifi/parameters/debug + + This entry will only exist if this option is enabled. + + To set a value, simply echo an 8-byte hex value to the same file: + + % echo 0x43fff > /sys/module/iwlwifi/parameters/debug + + You can find the list of debug mask values in: + drivers/net/wireless/intel/iwlwifi/iwl-debug.h + + If this is your first time using this driver, you should say Y here + as the debug information can assist others in helping you resolve + any problems you may encounter. + + config PACKAGE_IWLWIFI_DEBUGFS + bool "iwlwifi debugfs support" + depends on PACKAGE_MAC80211_DEBUGFS + default n + help + Enable creation of debugfs files for the iwlwifi drivers. This + is a low-impact option that allows getting insight into the + driver's state at runtime. + + endif +endef + +define KernelPackage/iwl-legacy + $(call KernelPackage/mac80211/Default) + DEPENDS:= +kmod-mac80211 @PCI_SUPPORT + TITLE:=Intel legacy Wireless support + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlegacy/iwlegacy.ko + AUTOLOAD:=$(call AutoProbe,iwlegacy) +endef + +define KernelPackage/iwl-legacy/description + iwl-legacy kernel module for legacy Intel wireless support +endef + +define KernelPackage/iwl3945 + $(call KernelPackage/mac80211/Default) + DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy +iwl3945-firmware + TITLE:=Intel iwl3945 Wireless support + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlegacy/iwl3945.ko + AUTOLOAD:=$(call AutoProbe,iwl3945) +endef + +define KernelPackage/iwl3945/description + iwl3945 kernel module for Intel 3945 support +endef + +define KernelPackage/iwl4965 + $(call KernelPackage/mac80211/Default) + DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy +@DRIVER_11N_SUPPORT +iwl4965-firmware + TITLE:=Intel iwl4965 Wireless support + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlegacy/iwl4965.ko + AUTOLOAD:=$(call AutoProbe,iwl4965) +endef + +define KernelPackage/iwl4965/description + iwl4965 kernel module for Intel 4965 support +endef + + +define KernelPackage/libipw + $(call KernelPackage/mac80211/Default) + TITLE:=libipw for ipw2100 and ipw2200 + DEPENDS:=@PCI_SUPPORT +kmod-crypto-michael-mic +kmod-crypto-ecb +kmod-lib80211 +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT @!BIG_ENDIAN + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/ipw2x00/libipw.ko + AUTOLOAD:=$(call AutoProbe,libipw) +endef + +define KernelPackage/libipw/description + Hardware independent IEEE 802.11 networking stack for ipw2100 and ipw2200. +endef + +IPW2100_NAME:=ipw2100-fw +IPW2100_VERSION:=1.3 + +define Download/ipw2100 + URL:= \ + https://src.fedoraproject.org/repo/pkgs/ipw2100-firmware/ipw2100-fw-1.3.tgz/46aa75bcda1a00efa841f9707bbbd113/ \ + https://archlinux.mirror.pkern.at/other/packages/ipw2100-fw/ \ + http://mirror.ox.ac.uk/sites/ftp.openbsd.org/pub/OpenBSD/distfiles/firmware/ \ + http://firmware.openbsd.org/firmware-dist/ + FILE:=$(IPW2100_NAME)-$(IPW2100_VERSION).tgz + HASH:=e1107c455e48d324a616b47a622593bc8413dcce72026f72731c0b03dae3a7a2 +endef +$(eval $(call Download,ipw2100)) + +define KernelPackage/ipw2100 + $(call KernelPackage/mac80211/Default) + TITLE:=Intel IPW2100 driver + DEPENDS:=@PCI_SUPPORT +kmod-libipw + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/ipw2x00/ipw2100.ko + AUTOLOAD:=$(call AutoProbe,ipw2100) +endef + +define KernelPackage/ipw2100/description + Kernel support for Intel IPW2100 + Includes: + - ipw2100 +endef + +IPW2200_NAME:=ipw2200-fw +IPW2200_VERSION:=3.1 + +define Download/ipw2200 + URL:= \ + https://src.fedoraproject.org/repo/pkgs/ipw2200-firmware/ipw2200-fw-3.1.tgz/eaba788643c7cc7483dd67ace70f6e99/ \ + https://archlinux.mirror.pkern.at/other/packages/ipw2200-fw/ \ + http://mirror.ox.ac.uk/sites/ftp.openbsd.org/pub/OpenBSD/distfiles/firmware/ \ + http://firmware.openbsd.org/firmware-dist/ + FILE:=$(IPW2200_NAME)-$(IPW2200_VERSION).tgz + HASH:=c6818c11c18cc030d55ff83f64b2bad8feef485e7742f84f94a61d811a6258bd +endef +$(eval $(call Download,ipw2200)) + +define KernelPackage/ipw2200 + $(call KernelPackage/mac80211/Default) + TITLE:=Intel IPW2200 driver + DEPENDS:=@PCI_SUPPORT +kmod-libipw + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/intel/ipw2x00/ipw2200.ko + AUTOLOAD:=$(call AutoProbe,ipw2200) +endef + +define KernelPackage/ipw2200/description + Kernel support for Intel IPW2200 + Includes: + - ipw2200 +endef + +define KernelPackage/ipw2100/install + $(INSTALL_DIR) $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/ipw2100-$(IPW2100_VERSION)*.fw $(1)/lib/firmware +endef + +define KernelPackage/ipw2200/install + $(INSTALL_DIR) $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION)/ipw2200*.fw $(1)/lib/firmware +endef diff --git a/feeds/wifi-ath10k/mac80211/marvell.mk b/feeds/wifi-ath10k/mac80211/marvell.mk new file mode 100644 index 000000000..a0e67091e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/marvell.mk @@ -0,0 +1,90 @@ +PKG_DRIVERS += \ + libertas-sdio libertas-usb libertas-spi \ + mwl8k mwifiex-pcie mwifiex-sdio + +config-$(call config_package,libertas-sdio) += LIBERTAS LIBERTAS_SDIO +config-$(call config_package,libertas-usb) += LIBERTAS LIBERTAS_USB +config-$(call config_package,libertas-spi) += LIBERTAS LIBERTAS_SPI +config-$(call config_package,mwl8k) += MWL8K +config-$(call config_package,mwifiex-pcie) += MWIFIEX MWIFIEX_PCIE +config-$(call config_package,mwifiex-sdio) += MWIFIEX MWIFIEX_SDIO + +define KernelPackage/libertas-usb + $(call KernelPackage/mac80211/Default) + DEPENDS+= @USB_SUPPORT +kmod-cfg80211 +kmod-usb-core +kmod-lib80211 +@DRIVER_WEXT_SUPPORT +libertas-usb-firmware + TITLE:=Marvell 88W8015 Wireless Driver + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/libertas.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/usb8xxx.ko + AUTOLOAD:=$(call AutoProbe,libertas usb8xxx) +endef + +define KernelPackage/libertas-sdio + $(call KernelPackage/mac80211/Default) + DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +kmod-mmc +@DRIVER_WEXT_SUPPORT @!TARGET_uml +libertas-sdio-firmware + TITLE:=Marvell 88W8686 Wireless Driver + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/libertas.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/libertas_sdio.ko + AUTOLOAD:=$(call AutoProbe,libertas libertas_sdio) +endef + +define KernelPackage/libertas-spi + $(call KernelPackage/mac80211/Default) + SUBMENU:=Wireless Drivers + DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +@DRIVER_WEXT_SUPPORT @!TARGET_uml +libertas-spi-firmware + KCONFIG := \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + TITLE:=Marvell 88W8686 SPI Wireless Driver + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/libertas.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/libertas/libertas_spi.ko + AUTOLOAD:=$(call AutoProbe,libertas libertas_spi) +endef + + +define KernelPackage/mwl8k + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Marvell TOPDOG 802.11 Wireless cards + URL:=https://wireless.wiki.kernel.org/en/users/drivers/mwl8k + DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +@DRIVER_11N_SUPPORT +mwl8k-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwl8k.ko + AUTOLOAD:=$(call AutoProbe,mwl8k) +endef + +define KernelPackage/mwl8k/description + Kernel modules for Marvell TOPDOG 802.11 Wireless cards +endef + + +define KernelPackage/mwifiex-pcie + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Marvell 802.11n/802.11ac PCIe Wireless cards + URL:=https://wireless.wiki.kernel.org/en/users/drivers/mwifiex + DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +mwifiex-pcie-firmware + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwifiex/mwifiex.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwifiex/mwifiex_pcie.ko + AUTOLOAD:=$(call AutoProbe,mwifiex_pcie) +endef + +define KernelPackage/mwifiex-pcie/description + Kernel modules for Marvell 802.11n/802.11ac PCIe Wireless cards +endef + +define KernelPackage/mwifiex-sdio + $(call KernelPackage/mac80211/Default) + TITLE:=Driver for Marvell 802.11n/802.11ac SDIO Wireless cards + URL:=https://wireless.wiki.kernel.org/en/users/drivers/mwifiex + DEPENDS+= +kmod-mmc +kmod-mac80211 +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +mwifiex-sdio-firmware + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwifiex/mwifiex.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwifiex/mwifiex_sdio.ko + AUTOLOAD:=$(call AutoProbe,mwifiex_sdio) +endef + +define KernelPackage/mwifiex-sdio/description + Kernel modules for Marvell 802.11n/802.11ac SDIO Wireless cards +endef + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/070-ath_common_config.patch b/feeds/wifi-ath10k/mac80211/patches/ath/070-ath_common_config.patch new file mode 100644 index 000000000..3d0b4d6b1 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/070-ath_common_config.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/wireless/ath/Kconfig ++++ b/drivers/net/wireless/ath/Kconfig +@@ -1,6 +1,6 @@ + # SPDX-License-Identifier: ISC + config ATH_COMMON +- tristate ++ tristate "ath.ko" + depends on m + + config WLAN_VENDOR_ATH diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/080-ath10k_thermal_config.patch b/feeds/wifi-ath10k/mac80211/patches/ath/080-ath10k_thermal_config.patch new file mode 100644 index 000000000..de6f9d9bb --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/080-ath10k_thermal_config.patch @@ -0,0 +1,47 @@ +--- a/drivers/net/wireless/ath/ath10k/Kconfig ++++ b/drivers/net/wireless/ath/ath10k/Kconfig +@@ -86,6 +86,12 @@ config ATH10K_TRACING + help + Select this to ath10k use tracing infrastructure. + ++config ATH10K_THERMAL ++ bool "Atheros ath10k thermal monitoring support" ++ depends on THERMAL ++ ---help--- ++ Select this to ath10k use hwmon for thermal measurement. ++ + config ATH10K_DFS_CERTIFIED + bool "Atheros DFS support for certified platforms" + depends on ATH10K && CFG80211_CERTIFICATION_ONUS +--- a/drivers/net/wireless/ath/ath10k/Makefile ++++ b/drivers/net/wireless/ath/ath10k/Makefile +@@ -18,7 +18,7 @@ ath10k_core-y += mac.o \ + ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) += spectral.o + ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o + ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o +-ath10k_core-$(CONFIG_THERMAL) += thermal.o ++ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o + ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o + ath10k_core-$(CONFIG_PM) += wow.o + ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o +--- a/drivers/net/wireless/ath/ath10k/thermal.h ++++ b/drivers/net/wireless/ath/ath10k/thermal.h +@@ -25,7 +25,7 @@ struct ath10k_thermal { + int temperature; + }; + +-#if IS_REACHABLE(CONFIG_THERMAL) ++#if IS_REACHABLE(CPTCFG_ATH10K_THERMAL) + int ath10k_thermal_register(struct ath10k *ar); + void ath10k_thermal_unregister(struct ath10k *ar); + void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature); +--- a/local-symbols ++++ b/local-symbols +@@ -142,6 +142,7 @@ ATH10K_SNOC= + ATH10K_DEBUG= + ATH10K_DEBUGFS= + ATH10K_SPECTRAL= ++ATH10K_THERMAL= + ATH10K_TRACING= + ATH10K_DFS_CERTIFIED= + WCN36XX= diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/120-owl-loader-compat.patch b/feeds/wifi-ath10k/mac80211/patches/ath/120-owl-loader-compat.patch new file mode 100644 index 000000000..d1d6c9e2e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/120-owl-loader-compat.patch @@ -0,0 +1,53 @@ +From: Christian Lamparter +Date: Sat, 16 Nov 2019 19:25:24 +0100 +Subject: [PATCH] owl_loader: compatibility patch + +This patch includes OpenWrt specific changes that are +not included in the upstream owl-loader. + +This includes a platform data handling changes for ar71xx. + +Signed-off-by: Christian Lamparter + +--- a/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c ++++ b/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c +@@ -103,6 +103,7 @@ static void owl_fw_cb(const struct firmw + { + struct pci_dev *pdev = (struct pci_dev *)context; + struct owl_ctx *ctx = (struct owl_ctx *)pci_get_drvdata(pdev); ++ struct ath9k_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct pci_bus *bus; + + complete(&ctx->eeprom_load); +@@ -118,6 +119,16 @@ static void owl_fw_cb(const struct firmw + goto release; + } + ++ if (pdata) { ++ memcpy(pdata->eeprom_data, fw->data, fw->size); ++ ++ /* ++ * eeprom has been successfully loaded - pass the data to ath9k ++ * but remove the eeprom_name, so it doesn't try to load it too. ++ */ ++ pdata->eeprom_name = NULL; ++ } ++ + if (ath9k_pci_fixup(pdev, (const u16 *)fw->data, fw->size)) + goto release; + +@@ -137,8 +148,14 @@ release: + static const char *owl_get_eeprom_name(struct pci_dev *pdev) + { + struct device *dev = &pdev->dev; ++ struct ath9k_platform_data *pdata; + char *eeprom_name; + ++ /* try the existing platform data first */ ++ pdata = dev_get_platdata(dev); ++ if (pdata && pdata->eeprom_name) ++ return pdata->eeprom_name; ++ + dev_dbg(dev, "using auto-generated eeprom filename\n"); + + eeprom_name = devm_kzalloc(dev, EEPROM_FILENAME_LEN, GFP_KERNEL); diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/201-ath5k-WAR-for-AR71xx-PCI-bug.patch b/feeds/wifi-ath10k/mac80211/patches/ath/201-ath5k-WAR-for-AR71xx-PCI-bug.patch new file mode 100644 index 000000000..21516ffde --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/201-ath5k-WAR-for-AR71xx-PCI-bug.patch @@ -0,0 +1,38 @@ +--- a/drivers/net/wireless/ath/ath5k/initvals.c ++++ b/drivers/net/wireless/ath/ath5k/initvals.c +@@ -62,8 +62,14 @@ static const struct ath5k_ini ar5210_ini + { AR5K_IMR, 0 }, + { AR5K_IER, AR5K_IER_DISABLE }, + { AR5K_BSR, 0, AR5K_INI_READ }, ++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79) + { AR5K_TXCFG, AR5K_DMASIZE_128B }, + { AR5K_RXCFG, AR5K_DMASIZE_128B }, ++#else ++ /* WAR for AR71xx PCI bug */ ++ { AR5K_TXCFG, AR5K_DMASIZE_128B }, ++ { AR5K_RXCFG, AR5K_DMASIZE_4B }, ++#endif + { AR5K_CFG, AR5K_INIT_CFG }, + { AR5K_TOPS, 8 }, + { AR5K_RXNOFRM, 8 }, +--- a/drivers/net/wireless/ath/ath5k/dma.c ++++ b/drivers/net/wireless/ath/ath5k/dma.c +@@ -869,10 +869,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah) + * guess we can tweak it and see how it goes ;-) + */ + if (ah->ah_version != AR5K_AR5210) { ++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79) + AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG, + AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B); + AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG, + AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_128B); ++#else ++ /* WAR for AR71xx PCI bug */ ++ AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG, ++ AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B); ++ AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG, ++ AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_4B); ++#endif + } + + /* Pre-enable interrupts on 5211/5212*/ diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch b/feeds/wifi-ath10k/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch new file mode 100644 index 000000000..d648a3a3e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch @@ -0,0 +1,25 @@ +From: Felix Fietkau +Date: Sat, 9 Jul 2016 15:25:24 +0200 +Subject: [PATCH] ath9k_hw: reset AHB-WMAC interface on AR91xx + +Should fix a few stability issues + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1435,8 +1435,12 @@ static bool ath9k_hw_set_reset(struct at + if (!AR_SREV_9100(ah)) + REG_WRITE(ah, AR_RC, 0); + +- if (AR_SREV_9100(ah)) ++ if (AR_SREV_9100(ah)) { ++ /* Reset the AHB-WMAC interface */ ++ if (ah->external_reset) ++ ah->external_reset(); + udelay(50); ++ } + + return true; + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch b/feeds/wifi-ath10k/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch new file mode 100644 index 000000000..5f265b84c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch @@ -0,0 +1,129 @@ +From: Felix Fietkau +Date: Sat, 9 Jul 2016 15:26:44 +0200 +Subject: [PATCH] ath9k_hw: issue external reset for QCA955x + +The RTC interface on the SoC needs to be reset along with the rest of +the WMAC. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1312,39 +1312,56 @@ void ath9k_hw_get_delta_slope_vals(struc + *coef_exponent = coef_exp - 16; + } + +-/* AR9330 WAR: +- * call external reset function to reset WMAC if: +- * - doing a cold reset +- * - we have pending frames in the TX queues. +- */ +-static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type) ++static bool ath9k_hw_need_external_reset(struct ath_hw *ah, int type) + { +- int i, npend = 0; ++ int i; + +- for (i = 0; i < AR_NUM_QCU; i++) { +- npend = ath9k_hw_numtxpending(ah, i); +- if (npend) +- break; +- } +- +- if (ah->external_reset && +- (npend || type == ATH9K_RESET_COLD)) { +- int reset_err = 0; +- +- ath_dbg(ath9k_hw_common(ah), RESET, +- "reset MAC via external reset\n"); +- +- reset_err = ah->external_reset(); +- if (reset_err) { +- ath_err(ath9k_hw_common(ah), +- "External reset failed, err=%d\n", +- reset_err); +- return false; ++ if (type == ATH9K_RESET_COLD) ++ return true; ++ ++ if (AR_SREV_9550(ah)) ++ return true; ++ ++ /* AR9330 WAR: ++ * call external reset function to reset WMAC if: ++ * - doing a cold reset ++ * - we have pending frames in the TX queues. ++ */ ++ if (AR_SREV_9330(ah)) { ++ for (i = 0; i < AR_NUM_QCU; i++) { ++ if (ath9k_hw_numtxpending(ah, i)) ++ return true; + } ++ } ++ ++ return false; ++} ++ ++static bool ath9k_hw_external_reset(struct ath_hw *ah, int type) ++{ ++ int err; ++ ++ if (!ah->external_reset || !ath9k_hw_need_external_reset(ah, type)) ++ return true; ++ ++ ath_dbg(ath9k_hw_common(ah), RESET, ++ "reset MAC via external reset\n"); + +- REG_WRITE(ah, AR_RTC_RESET, 1); ++ err = ah->external_reset(); ++ if (err) { ++ ath_err(ath9k_hw_common(ah), ++ "External reset failed, err=%d\n", err); ++ return false; + } + ++ if (AR_SREV_9550(ah)) { ++ REG_WRITE(ah, AR_RTC_RESET, 0); ++ udelay(10); ++ } ++ ++ REG_WRITE(ah, AR_RTC_RESET, 1); ++ udelay(10); ++ + return true; + } + +@@ -1397,24 +1414,24 @@ static bool ath9k_hw_set_reset(struct at + rst_flags |= AR_RTC_RC_MAC_COLD; + } + +- if (AR_SREV_9330(ah)) { +- if (!ath9k_hw_ar9330_reset_war(ah, type)) +- return false; +- } +- + if (ath9k_hw_mci_is_enabled(ah)) + ar9003_mci_check_gpm_offset(ah); + + /* DMA HALT added to resolve ar9300 and ar9580 bus error during +- * RTC_RC reg read ++ * RTC_RC reg read. Also needed for AR9550 external reset + */ +- if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) { ++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9550(ah)) { + REG_SET_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); + ath9k_hw_wait(ah, AR_CFG, AR_CFG_HALT_ACK, AR_CFG_HALT_ACK, + 20 * AH_WAIT_TIMEOUT); +- REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); + } + ++ if (!AR_SREV_9100(ah)) ++ ath9k_hw_external_reset(ah, type); ++ ++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) ++ REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); ++ + REG_WRITE(ah, AR_RTC_RC, rst_flags); + + REGWRITE_BUFFER_FLUSH(ah); diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/354-ath9k-force-rx_clear-when-disabling-rx.patch b/feeds/wifi-ath10k/mac80211/patches/ath/354-ath9k-force-rx_clear-when-disabling-rx.patch new file mode 100644 index 000000000..8aaccf49b --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/354-ath9k-force-rx_clear-when-disabling-rx.patch @@ -0,0 +1,35 @@ +From: Felix Fietkau +Date: Sun, 7 Jun 2015 13:53:35 +0200 +Subject: [PATCH] ath9k: force rx_clear when disabling rx + +This makes stopping Rx more reliable and should reduce the frequency of +Rx related DMA stop warnings. Don't use rx_clear in TX99 mode. + +Cc: stable@vger.kernel.org +Signed-off-by: Felix Fietkau +Signed-off-by: Helmut Schaa +--- + +--- a/drivers/net/wireless/ath/ath9k/mac.c ++++ b/drivers/net/wireless/ath/ath9k/mac.c +@@ -678,13 +678,18 @@ void ath9k_hw_startpcureceive(struct ath + + ath9k_ani_reset(ah, is_scanning); + +- REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); ++ REG_CLR_BIT(ah, AR_DIAG_SW, ++ AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT | AR_DIAG_FORCE_RX_CLEAR); + } + EXPORT_SYMBOL(ath9k_hw_startpcureceive); + + void ath9k_hw_abortpcurecv(struct ath_hw *ah) + { +- REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS); ++ u32 reg = AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT; ++ ++ if (!IS_ENABLED(CPTCFG_ATH9K_TX99)) ++ reg |= AR_DIAG_FORCE_RX_CLEAR; ++ REG_SET_BIT(ah, AR_DIAG_SW, reg); + + ath9k_hw_disable_mib_counters(ah); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch b/feeds/wifi-ath10k/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch new file mode 100644 index 000000000..385eea011 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch @@ -0,0 +1,36 @@ +From: Felix Fietkau +Date: Sat, 14 May 2016 14:51:02 +0200 +Subject: [PATCH] Revert "ath9k: interpret requested txpower in EIRP + domain" + +This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411. +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -2977,7 +2977,8 @@ void ath9k_hw_apply_txpower(struct ath_h + { + struct ath_regulatory *reg = ath9k_hw_regulatory(ah); + struct ieee80211_channel *channel; +- int chan_pwr, new_pwr; ++ int chan_pwr, new_pwr, max_gain; ++ int ant_gain, ant_reduction = 0; + u16 ctl = NO_CTL; + + if (!chan) +@@ -2989,9 +2990,14 @@ void ath9k_hw_apply_txpower(struct ath_h + channel = chan->chan; + chan_pwr = min_t(int, channel->max_power * 2, MAX_COMBINED_POWER); + new_pwr = min_t(int, chan_pwr, reg->power_limit); ++ max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2; ++ ++ ant_gain = get_antenna_gain(ah, chan); ++ if (ant_gain > max_gain) ++ ant_reduction = ant_gain - max_gain; + + ah->eep_ops->set_txpower(ah, chan, ctl, +- get_antenna_gain(ah, chan), new_pwr, test); ++ ant_reduction, new_pwr, test); + } + + void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test) diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch b/feeds/wifi-ath10k/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch new file mode 100644 index 000000000..0c3edc126 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch @@ -0,0 +1,24 @@ +From: Felix Fietkau +Date: Wed, 19 Jul 2017 08:49:31 +0200 +Subject: [PATCH] ath9k: adjust tx power reduction for US regulatory + domain + +FCC regulatory rules allow for up to 6 dBi antenna gain. Account for +this in the EEPROM based tx power reduction code. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -2996,6 +2996,10 @@ void ath9k_hw_apply_txpower(struct ath_h + if (ant_gain > max_gain) + ant_reduction = ant_gain - max_gain; + ++ /* FCC allows maximum antenna gain of 6 dBi */ ++ if (reg->region == NL80211_DFS_FCC) ++ ant_reduction = max_t(int, ant_reduction - 12, 0); ++ + ah->eep_ops->set_txpower(ah, chan, ctl, + ant_reduction, new_pwr, test); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/400-ath_move_debug_code.patch b/feeds/wifi-ath10k/mac80211/patches/ath/400-ath_move_debug_code.patch new file mode 100644 index 000000000..db10c4510 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/400-ath_move_debug_code.patch @@ -0,0 +1,31 @@ +--- a/drivers/net/wireless/ath/Makefile ++++ b/drivers/net/wireless/ath/Makefile +@@ -15,10 +15,10 @@ ath-objs := main.o \ + regd.o \ + hw.o \ + key.o \ ++ debug.o \ + dfs_pattern_detector.o \ + dfs_pri_detector.o + +-ath-$(CPTCFG_ATH_DEBUG) += debug.o + ath-$(CPTCFG_ATH_TRACEPOINTS) += trace.o + + CFLAGS_trace.o := -I$(src) +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -316,14 +316,7 @@ void _ath_dbg(struct ath_common *common, + #endif /* CPTCFG_ATH_DEBUG */ + + /** Returns string describing opmode, or NULL if unknown mode. */ +-#ifdef CPTCFG_ATH_DEBUG + const char *ath_opmode_to_string(enum nl80211_iftype opmode); +-#else +-static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode) +-{ +- return "UNKNOWN"; +-} +-#endif + + extern const char *ath_bus_type_strings[]; + static inline const char *ath_bus_type_to_string(enum ath_bus_type bustype) diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/401-ath9k_blink_default.patch b/feeds/wifi-ath10k/mac80211/patches/ath/401-ath9k_blink_default.patch new file mode 100644 index 000000000..3eb57bb1c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/401-ath9k_blink_default.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -48,7 +48,7 @@ int ath9k_modparam_nohwcrypt; + module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444); + MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); + +-int ath9k_led_blink; ++int ath9k_led_blink = 1; + module_param_named(blink, ath9k_led_blink, int, 0444); + MODULE_PARM_DESC(blink, "Enable LED blink on activity"); + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/402-ath_regd_optional.patch b/feeds/wifi-ath10k/mac80211/patches/ath/402-ath_regd_optional.patch new file mode 100644 index 000000000..bf87d3551 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/402-ath_regd_optional.patch @@ -0,0 +1,92 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -24,6 +24,7 @@ + #include "regd_common.h" + + static int __ath_regd_init(struct ath_regulatory *reg); ++static struct reg_dmn_pair_mapping *ath_get_regpair(int regdmn); + + /* + * This is a set of common rules used by our world regulatory domains. +@@ -116,6 +117,9 @@ static const struct ieee80211_regdomain + + static bool dynamic_country_user_possible(struct ath_regulatory *reg) + { ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return true; ++ + if (IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_CERT_TESTING)) + return true; + +@@ -188,6 +192,8 @@ static bool dynamic_country_user_possibl + + static bool ath_reg_dyn_country_user_allow(struct ath_regulatory *reg) + { ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return true; + if (!IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_REG_HINTS)) + return false; + if (!dynamic_country_user_possible(reg)) +@@ -345,6 +351,9 @@ ath_reg_apply_beaconing_flags(struct wip + struct ieee80211_channel *ch; + unsigned int i; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + for (band = 0; band < NUM_NL80211_BANDS; band++) { + if (!wiphy->bands[band]) + continue; +@@ -378,6 +387,9 @@ ath_reg_apply_ir_flags(struct wiphy *wip + { + struct ieee80211_supported_band *sband; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + sband = wiphy->bands[NL80211_BAND_2GHZ]; + if (!sband) + return; +@@ -407,6 +419,9 @@ static void ath_reg_apply_radar_flags(st + struct ieee80211_channel *ch; + unsigned int i; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + if (!wiphy->bands[NL80211_BAND_5GHZ]) + return; + +@@ -639,6 +654,10 @@ ath_regd_init_wiphy(struct ath_regulator + const struct ieee80211_regdomain *regd; + + wiphy->reg_notifier = reg_notifier; ++ ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return 0; ++ + wiphy->regulatory_flags |= REGULATORY_STRICT_REG | + REGULATORY_CUSTOM_REG; + +--- a/drivers/net/wireless/ath/Kconfig ++++ b/drivers/net/wireless/ath/Kconfig +@@ -24,6 +24,9 @@ config WLAN_VENDOR_ATH + + if WLAN_VENDOR_ATH + ++config ATH_USER_REGD ++ bool "Do not enforce EEPROM regulatory restrictions" ++ + config ATH_DEBUG + bool "Atheros wireless debugging" + help +--- a/local-symbols ++++ b/local-symbols +@@ -85,6 +85,7 @@ ADM8211= + ATH_COMMON= + WLAN_VENDOR_ATH= + ATH_DEBUG= ++ATH_USER_REGD= + ATH_TRACEPOINTS= + ATH_REG_DYNAMIC_USER_REG_HINTS= + ATH_REG_DYNAMIC_USER_CERT_TESTING= diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/403-world_regd_fixup.patch b/feeds/wifi-ath10k/mac80211/patches/ath/403-world_regd_fixup.patch new file mode 100644 index 000000000..ed616b753 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/403-world_regd_fixup.patch @@ -0,0 +1,84 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -44,7 +44,8 @@ static struct reg_dmn_pair_mapping *ath_ + NL80211_RRF_NO_OFDM) + + /* We allow IBSS on these on a case by case basis by regulatory domain */ +-#define ATH_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 80, 0, 30,\ ++#define ATH_5GHZ_5150_5350 REG_RULE(5150-10, 5240+10, 80, 0, 30, 0),\ ++ REG_RULE(5260-10, 5350+10, 80, 0, 30,\ + NL80211_RRF_NO_IR) + #define ATH_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 80, 0, 30,\ + NL80211_RRF_NO_IR) +@@ -62,57 +63,56 @@ static struct reg_dmn_pair_mapping *ath_ + #define ATH_5GHZ_NO_MIDBAND ATH_5GHZ_5150_5350, \ + ATH_5GHZ_5725_5850 + ++#define REGD_RULES(...) \ ++ .reg_rules = { __VA_ARGS__ }, \ ++ .n_reg_rules = ARRAY_SIZE(((struct ieee80211_reg_rule[]) { __VA_ARGS__ })) ++ + /* Can be used for: + * 0x60, 0x61, 0x62 */ + static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = { +- .n_reg_rules = 5, + .alpha2 = "99", +- .reg_rules = { ++ REGD_RULES( + ATH_2GHZ_ALL, + ATH_5GHZ_ALL, +- } ++ ) + }; + + /* Can be used by 0x63 and 0x65 */ + static const struct ieee80211_regdomain ath_world_regdom_63_65 = { +- .n_reg_rules = 4, + .alpha2 = "99", +- .reg_rules = { ++ REGD_RULES( + ATH_2GHZ_CH01_11, + ATH_2GHZ_CH12_13, + ATH_5GHZ_NO_MIDBAND, +- } ++ ) + }; + + /* Can be used by 0x64 only */ + static const struct ieee80211_regdomain ath_world_regdom_64 = { +- .n_reg_rules = 3, + .alpha2 = "99", +- .reg_rules = { ++ REGD_RULES( + ATH_2GHZ_CH01_11, + ATH_5GHZ_NO_MIDBAND, +- } ++ ) + }; + + /* Can be used by 0x66 and 0x69 */ + static const struct ieee80211_regdomain ath_world_regdom_66_69 = { +- .n_reg_rules = 3, + .alpha2 = "99", +- .reg_rules = { ++ REGD_RULES( + ATH_2GHZ_CH01_11, + ATH_5GHZ_ALL, +- } ++ ) + }; + + /* Can be used by 0x67, 0x68, 0x6A and 0x6C */ + static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = { +- .n_reg_rules = 4, + .alpha2 = "99", +- .reg_rules = { ++ REGD_RULES( + ATH_2GHZ_CH01_11, + ATH_2GHZ_CH12_13, + ATH_5GHZ_ALL, +- } ++ ) + }; + + static bool dynamic_country_user_possible(struct ath_regulatory *reg) diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/404-regd_no_assoc_hints.patch b/feeds/wifi-ath10k/mac80211/patches/ath/404-regd_no_assoc_hints.patch new file mode 100644 index 000000000..89e26af76 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/404-regd_no_assoc_hints.patch @@ -0,0 +1,19 @@ +--- a/net/wireless/reg.c ++++ b/net/wireless/reg.c +@@ -3042,6 +3042,8 @@ void regulatory_hint_country_ie(struct w + enum environment_cap env = ENVIRON_ANY; + struct regulatory_request *request = NULL, *lr; + ++ return; ++ + /* IE len must be evenly divisible by 2 */ + if (country_ie_len & 0x01) + return; +@@ -3293,6 +3295,7 @@ static bool is_wiphy_all_set_reg_flag(en + + void regulatory_hint_disconnect(void) + { ++ return; + /* Restore of regulatory settings is not required when wiphy(s) + * ignore IE from connected access point but clearance of beacon hints + * is required when wiphy(s) supports beacon hints. diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/405-ath_regd_us.patch b/feeds/wifi-ath10k/mac80211/patches/ath/405-ath_regd_us.patch new file mode 100644 index 000000000..088833199 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/405-ath_regd_us.patch @@ -0,0 +1,26 @@ +--- a/drivers/net/wireless/ath/regd_common.h ++++ b/drivers/net/wireless/ath/regd_common.h +@@ -32,6 +32,7 @@ enum EnumRd { + FCC2_WORLD = 0x21, + FCC2_ETSIC = 0x22, + FCC6_WORLD = 0x23, ++ FCC3_FCCA_2 = 0x2A, + FRANCE_RES = 0x31, + FCC3_FCCA = 0x3A, + FCC3_WORLD = 0x3B, +@@ -172,6 +173,7 @@ static struct reg_dmn_pair_mapping regDo + {FCC2_WORLD, CTL_FCC, CTL_ETSI}, + {FCC2_ETSIC, CTL_FCC, CTL_ETSI}, + {FCC3_FCCA, CTL_FCC, CTL_FCC}, ++ {FCC3_FCCA_2, CTL_FCC, CTL_FCC}, + {FCC3_WORLD, CTL_FCC, CTL_ETSI}, + {FCC3_ETSIC, CTL_FCC, CTL_ETSI}, + {FCC4_FCCA, CTL_FCC, CTL_FCC}, +@@ -483,6 +485,7 @@ static struct country_code_to_enum_rd al + {CTRY_UAE, NULL1_WORLD, "AE"}, + {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB"}, + {CTRY_UNITED_STATES, FCC3_FCCA, "US"}, ++ {CTRY_UNITED_STATES, FCC3_FCCA_2, "US"}, + {CTRY_UNITED_STATES2, FCC3_FCCA, "US"}, + {CTRY_UNITED_STATES3, FCC3_FCCA, "US"}, + /* This "PS" is for US public safety actually... to support this we diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/406-ath_relax_default_regd.patch b/feeds/wifi-ath10k/mac80211/patches/ath/406-ath_relax_default_regd.patch new file mode 100644 index 000000000..35b0f2b76 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/406-ath_relax_default_regd.patch @@ -0,0 +1,51 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -115,6 +115,16 @@ static const struct ieee80211_regdomain + ) + }; + ++static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg) ++{ ++ return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG; ++} ++ ++static bool is_default_regd(struct ath_regulatory *reg) ++{ ++ return ath_regd_get_eepromRD(reg) == CTRY_DEFAULT; ++} ++ + static bool dynamic_country_user_possible(struct ath_regulatory *reg) + { + if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) +@@ -123,6 +133,9 @@ static bool dynamic_country_user_possibl + if (IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_CERT_TESTING)) + return true; + ++ if (is_default_regd(reg)) ++ return true; ++ + switch (reg->country_code) { + case CTRY_UNITED_STATES: + case CTRY_JAPAN1: +@@ -208,11 +221,6 @@ static inline bool is_wwr_sku(u16 regd) + (regd == WORLD)); + } + +-static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg) +-{ +- return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG; +-} +- + bool ath_is_world_regd(struct ath_regulatory *reg) + { + return is_wwr_sku(ath_regd_get_eepromRD(reg)); +@@ -658,6 +666,9 @@ ath_regd_init_wiphy(struct ath_regulator + if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) + return 0; + ++ if (is_default_regd(reg)) ++ return 0; ++ + wiphy->regulatory_flags |= REGULATORY_STRICT_REG | + REGULATORY_CUSTOM_REG; + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/410-ath9k_allow_adhoc_and_ap.patch b/feeds/wifi-ath10k/mac80211/patches/ath/410-ath9k_allow_adhoc_and_ap.patch new file mode 100644 index 000000000..bdf784968 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/410-ath9k_allow_adhoc_and_ap.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -831,6 +831,7 @@ static const struct ieee80211_iface_limi + BIT(NL80211_IFTYPE_AP) }, + { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_CLIENT) | + BIT(NL80211_IFTYPE_P2P_GO) }, ++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, + }; + + #ifdef CPTCFG_WIRELESS_WDS diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/411-ath5k_allow_adhoc_and_ap.patch b/feeds/wifi-ath10k/mac80211/patches/ath/411-ath5k_allow_adhoc_and_ap.patch new file mode 100644 index 000000000..9dbe047c9 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/411-ath5k_allow_adhoc_and_ap.patch @@ -0,0 +1,46 @@ +--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c ++++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c +@@ -86,13 +86,8 @@ ath5k_add_interface(struct ieee80211_hw + goto end; + } + +- /* Don't allow other interfaces if one ad-hoc is configured. +- * TODO: Fix the problems with ad-hoc and multiple other interfaces. +- * We would need to operate the HW in ad-hoc mode to allow TSF updates +- * for the IBSS, but this breaks with additional AP or STA interfaces +- * at the moment. */ +- if (ah->num_adhoc_vifs || +- (ah->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) { ++ /* Don't allow more than one ad-hoc interface */ ++ if (ah->num_adhoc_vifs && vif->type == NL80211_IFTYPE_ADHOC) { + ATH5K_ERR(ah, "Only one single ad-hoc interface is allowed.\n"); + ret = -ELNRNG; + goto end; +--- a/drivers/net/wireless/ath/ath5k/base.c ++++ b/drivers/net/wireless/ath/ath5k/base.c +@@ -1964,7 +1964,7 @@ ath5k_beacon_send(struct ath5k_hw *ah) + } + + if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + +- ah->num_mesh_vifs > 1) || ++ ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) || + ah->opmode == NL80211_IFTYPE_MESH_POINT) { + u64 tsf = ath5k_hw_get_tsf64(ah); + u32 tsftu = TSF_TO_TU(tsf); +@@ -2050,7 +2050,7 @@ ath5k_beacon_update_timers(struct ath5k_ + + intval = ah->bintval & AR5K_BEACON_PERIOD; + if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs +- + ah->num_mesh_vifs > 1) { ++ + ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) { + intval /= ATH_BCBUF; /* staggered multi-bss beacons */ + if (intval < 15) + ATH5K_WARN(ah, "intval %u is too low, min 15\n", +@@ -2516,6 +2516,7 @@ static const struct ieee80211_iface_limi + BIT(NL80211_IFTYPE_MESH_POINT) | + #endif + BIT(NL80211_IFTYPE_AP) }, ++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, + }; + + static const struct ieee80211_iface_combination if_comb = { diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/420-ath5k_disable_fast_cc.patch b/feeds/wifi-ath10k/mac80211/patches/ath/420-ath5k_disable_fast_cc.patch new file mode 100644 index 000000000..414f49508 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/420-ath5k_disable_fast_cc.patch @@ -0,0 +1,18 @@ +--- a/drivers/net/wireless/ath/ath5k/reset.c ++++ b/drivers/net/wireless/ath/ath5k/reset.c +@@ -1154,6 +1154,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum + tsf_lo = 0; + mode = 0; + ++#if 0 + /* + * Sanity check for fast flag + * Fast channel change only available +@@ -1161,6 +1162,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum + */ + if (fast && (ah->ah_radio != AR5K_RF2413) && + (ah->ah_radio != AR5K_RF5413)) ++#endif + fast = false; + + /* Disable sleep clock operation diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/430-add_ath5k_platform.patch b/feeds/wifi-ath10k/mac80211/patches/ath/430-add_ath5k_platform.patch new file mode 100644 index 000000000..b213e2a81 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/430-add_ath5k_platform.patch @@ -0,0 +1,33 @@ +--- /dev/null ++++ b/include/linux/ath5k_platform.h +@@ -0,0 +1,30 @@ ++/* ++ * Copyright (c) 2008 Atheros Communications Inc. ++ * Copyright (c) 2009 Gabor Juhos ++ * Copyright (c) 2009 Imre Kaloz ++ * Copyright (c) 2010 Daniel Golle ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#ifndef _LINUX_ATH5K_PLATFORM_H ++#define _LINUX_ATH5K_PLATFORM_H ++ ++#define ATH5K_PLAT_EEP_MAX_WORDS 2048 ++ ++struct ath5k_platform_data { ++ u16 *eeprom_data; ++ u8 *macaddr; ++}; ++ ++#endif /* _LINUX_ATH5K_PLATFORM_H */ diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/431-add_platform_eeprom_support_to_ath5k.patch b/feeds/wifi-ath10k/mac80211/patches/ath/431-add_platform_eeprom_support_to_ath5k.patch new file mode 100644 index 000000000..136be1989 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/431-add_platform_eeprom_support_to_ath5k.patch @@ -0,0 +1,56 @@ +--- a/drivers/net/wireless/ath/ath5k/pci.c ++++ b/drivers/net/wireless/ath/ath5k/pci.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include "../ath.h" + #include "ath5k.h" + #include "debug.h" +@@ -71,7 +72,7 @@ static void ath5k_pci_read_cachesize(str + } + + /* +- * Read from eeprom ++ * Read from eeprom or platform_data + */ + static bool + ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data) +@@ -79,6 +80,19 @@ ath5k_pci_eeprom_read(struct ath_common + struct ath5k_hw *ah = (struct ath5k_hw *) common->ah; + u32 status, timeout; + ++ struct ath5k_platform_data *pdata = NULL; ++ ++ if (ah->pdev) ++ pdata = ah->pdev->dev.platform_data; ++ ++ if (pdata && pdata->eeprom_data && pdata->eeprom_data[61] == AR5K_EEPROM_MAGIC_VALUE) { ++ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS) ++ return false; ++ ++ *data = pdata->eeprom_data[offset]; ++ return true; ++ } ++ + /* + * Initialize EEPROM access + */ +@@ -122,6 +136,16 @@ static int ath5k_pci_eeprom_read_mac(str + u16 data; + int octet; + ++ struct ath5k_platform_data *pdata = NULL; ++ ++ if (ah->pdev) ++ pdata = ah->pdev->dev.platform_data; ++ ++ if (pdata && pdata->macaddr) { ++ memcpy(mac, pdata->macaddr, ETH_ALEN); ++ return 0; ++ } ++ + AR5K_EEPROM_READ(0x20, data); + + for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) { diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/432-ath5k_add_pciids.patch b/feeds/wifi-ath10k/mac80211/patches/ath/432-ath5k_add_pciids.patch new file mode 100644 index 000000000..bd0e6707a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/432-ath5k_add_pciids.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ath/ath5k/pci.c ++++ b/drivers/net/wireless/ath/ath5k/pci.c +@@ -47,6 +47,8 @@ static const struct pci_device_id ath5k_ + { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ + { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ + { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */ ++ { PCI_VDEVICE(ATHEROS, 0xff16) }, /* 2413,2414 sx76x on lantiq_danube */ ++ { PCI_VDEVICE(ATHEROS, 0xff1a) }, /* 2417 arv45xx on lantiq_danube */ + { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */ + { 0 } + }; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/440-ath5k_channel_bw_debugfs.patch b/feeds/wifi-ath10k/mac80211/patches/ath/440-ath5k_channel_bw_debugfs.patch new file mode 100644 index 000000000..57d336327 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/440-ath5k_channel_bw_debugfs.patch @@ -0,0 +1,142 @@ +This adds a bwmode debugfs file which can be used to set alternate +channel operating bandwidths. Only tested with AR5413 and only at +5 and 20 mhz channels. + +Signed-off-by: Pat Erley +--- +Other devices will need to be added to the switch in write_file_bwmode + +drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++ + 1 files changed, 86 insertions(+), 0 deletions(-) + +--- a/drivers/net/wireless/ath/ath5k/debug.c ++++ b/drivers/net/wireless/ath/ath5k/debug.c +@@ -822,6 +822,97 @@ static const struct file_operations fops + .llseek = default_llseek, + }; + ++/* debugfs: bwmode */ ++ ++static ssize_t read_file_bwmode(struct file *file, char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath5k_hw *ah = file->private_data; ++ char buf[15]; ++ unsigned int len = 0; ++ ++ int cur_ah_bwmode = ah->ah_bwmode_debug; ++ ++#define print_selected(MODE, LABEL) \ ++ if (cur_ah_bwmode == MODE) \ ++ len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \ ++ else \ ++ len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \ ++ len += snprintf(buf+len, sizeof(buf)-len, " "); ++ ++ print_selected(AR5K_BWMODE_5MHZ, "5"); ++ print_selected(AR5K_BWMODE_10MHZ, "10"); ++ print_selected(AR5K_BWMODE_DEFAULT, "20"); ++ print_selected(AR5K_BWMODE_40MHZ, "40"); ++#undef print_selected ++ ++ len += snprintf(buf+len, sizeof(buf)-len, "\n"); ++ ++ return simple_read_from_buffer(user_buf, count, ppos, buf, len); ++} ++ ++static ssize_t write_file_bwmode(struct file *file, ++ const char __user *userbuf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath5k_hw *ah = file->private_data; ++ char buf[3]; ++ int bw = 20; ++ int tobwmode = AR5K_BWMODE_DEFAULT; ++ ++ if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) ++ return -EFAULT; ++ ++ /* TODO: Add check for active interface */ ++ ++ if(strncmp(buf, "5", 1) == 0 ) { ++ tobwmode = AR5K_BWMODE_5MHZ; ++ bw = 5; ++ } else if ( strncmp(buf, "10", 2) == 0 ) { ++ tobwmode = AR5K_BWMODE_10MHZ; ++ bw = 10; ++ } else if ( strncmp(buf, "20", 2) == 0 ) { ++ tobwmode = AR5K_BWMODE_DEFAULT; ++ bw = 20; ++ } else if ( strncmp(buf, "40", 2) == 0 ) { ++ tobwmode = AR5K_BWMODE_40MHZ; ++ bw = 40; ++ } else ++ return -EINVAL; ++ ++ ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n", ++ bw, tobwmode); ++ ++ switch (ah->ah_radio) { ++ /* TODO: only define radios that actually support 5/10mhz channels */ ++ case AR5K_RF5413: ++ case AR5K_RF5110: ++ case AR5K_RF5111: ++ case AR5K_RF5112: ++ case AR5K_RF2413: ++ case AR5K_RF2316: ++ case AR5K_RF2317: ++ case AR5K_RF2425: ++ if(ah->ah_bwmode_debug != tobwmode) { ++ mutex_lock(&ah->lock); ++ ah->ah_bwmode = tobwmode; ++ ah->ah_bwmode_debug = tobwmode; ++ mutex_unlock(&ah->lock); ++ } ++ break; ++ default: ++ return -EOPNOTSUPP; ++ } ++ return count; ++} ++ ++static const struct file_operations fops_bwmode = { ++ .read = read_file_bwmode, ++ .write = write_file_bwmode, ++ .open = simple_open, ++ .owner = THIS_MODULE, ++ .llseek = default_llseek, ++}; + + /* debugfs: queues etc */ + +@@ -1016,6 +1107,8 @@ ath5k_debug_init_device(struct ath5k_hw + debugfs_create_file("queue", 0600, phydir, ah, &fops_queue); + debugfs_create_bool("32khz_clock", 0600, phydir, + &ah->ah_use_32khz_clock); ++ debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah, ++ &fops_bwmode); + } + + /* functions used in other places */ +--- a/drivers/net/wireless/ath/ath5k/ath5k.h ++++ b/drivers/net/wireless/ath/ath5k/ath5k.h +@@ -1372,6 +1372,7 @@ struct ath5k_hw { + u8 ah_coverage_class; + bool ah_ack_bitrate_high; + u8 ah_bwmode; ++ u8 ah_bwmode_debug; + bool ah_short_slot; + + /* Antenna Control */ +--- a/drivers/net/wireless/ath/ath5k/base.c ++++ b/drivers/net/wireless/ath/ath5k/base.c +@@ -466,6 +466,9 @@ ath5k_chan_set(struct ath5k_hw *ah, stru + return -EINVAL; + } + ++ if (ah->ah_bwmode_debug != AR5K_BWMODE_DEFAULT) ++ ah->ah_bwmode = ah->ah_bwmode_debug; ++ + /* + * To switch channels clear any pending DMA operations; + * wait long enough for the RX fifo to drain, reset the diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/450-ath9k-enabled-MFP-capability-unconditionally.patch b/feeds/wifi-ath10k/mac80211/patches/ath/450-ath9k-enabled-MFP-capability-unconditionally.patch new file mode 100644 index 000000000..c75d6c798 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/450-ath9k-enabled-MFP-capability-unconditionally.patch @@ -0,0 +1,34 @@ +From d946085ff5a331de64e91a2e3c96b9ca79d740f5 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Mon, 15 Jun 2020 00:10:34 +0200 +Subject: [PATCH] ath9k: enabled MFP capability unconditionally + +ath9k will already fallback on software-crypto for chipsets not +supporting IEEE802.11w (MFP). So advertising MFP is not dependent +on disabling HW crypto for all traffic entirely. + +Signed-off-by: David Bauer +--- + drivers/net/wireless/ath/ath9k/init.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -928,6 +928,7 @@ static void ath9k_set_hw_capab(struct at + ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING); + ieee80211_hw_set(hw, SUPPORT_FAST_XMIT); + ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS); ++ ieee80211_hw_set(hw, MFP_CAPABLE); + + if (ath9k_ps_enable) + ieee80211_hw_set(hw, SUPPORTS_PS); +@@ -940,9 +941,6 @@ static void ath9k_set_hw_capab(struct at + IEEE80211_RADIOTAP_MCS_HAVE_STBC; + } + +- if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt) +- ieee80211_hw_set(hw, MFP_CAPABLE); +- + hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | + NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | + NL80211_FEATURE_P2P_GO_CTWIN; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/500-ath9k_eeprom_debugfs.patch b/feeds/wifi-ath10k/mac80211/patches/ath/500-ath9k_eeprom_debugfs.patch new file mode 100644 index 000000000..786a3ed3f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/500-ath9k_eeprom_debugfs.patch @@ -0,0 +1,65 @@ +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1361,6 +1361,53 @@ void ath9k_deinit_debug(struct ath_softc + ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); + } + ++static ssize_t read_file_eeprom(struct file *file, char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ struct ath_hw *ah = sc->sc_ah; ++ struct ath_common *common = ath9k_hw_common(ah); ++ int bytes = 0; ++ int pos = *ppos; ++ int size = 4096; ++ u16 val; ++ int i; ++ ++ if (AR_SREV_9300_20_OR_LATER(ah)) ++ size = 16384; ++ ++ if (*ppos < 0) ++ return -EINVAL; ++ ++ if (count > size - *ppos) ++ count = size - *ppos; ++ ++ for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) { ++ void *from = &val; ++ ++ if (!common->bus_ops->eeprom_read(common, i, &val)) ++ val = 0xffff; ++ ++ if (*ppos % 2) { ++ from++; ++ bytes = 1; ++ } else if (count == 1) { ++ bytes = 1; ++ } else { ++ bytes = 2; ++ } ++ copy_to_user(user_buf, from, bytes); ++ user_buf += bytes; ++ } ++ return *ppos - pos; ++} ++ ++static const struct file_operations fops_eeprom = { ++ .read = read_file_eeprom, ++ .open = simple_open, ++ .owner = THIS_MODULE ++}; ++ + int ath9k_init_debug(struct ath_hw *ah) + { + struct ath_common *common = ath9k_hw_common(ah); +@@ -1380,6 +1427,8 @@ int ath9k_init_debug(struct ath_hw *ah) + ath9k_tx99_init_debug(sc); + ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); + ++ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, ++ &fops_eeprom); + debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/501-ath9k_ahb_init.patch b/feeds/wifi-ath10k/mac80211/patches/ath/501-ath9k_ahb_init.patch new file mode 100644 index 000000000..b9c784eb2 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/501-ath9k_ahb_init.patch @@ -0,0 +1,34 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -1143,25 +1143,25 @@ static int __init ath9k_init(void) + { + int error; + +- error = ath_pci_init(); ++ error = ath_ahb_init(); + if (error < 0) { +- pr_err("No PCI devices found, driver not installed\n"); + error = -ENODEV; + goto err_out; + } + +- error = ath_ahb_init(); ++ error = ath_pci_init(); + if (error < 0) { ++ pr_err("No PCI devices found, driver not installed\n"); + error = -ENODEV; +- goto err_pci_exit; ++ goto err_ahb_exit; + } + + dmi_check_system(ath9k_quirks); + + return 0; + +- err_pci_exit: +- ath_pci_exit(); ++ err_ahb_exit: ++ ath_ahb_exit(); + err_out: + return error; + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch b/feeds/wifi-ath10k/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch new file mode 100644 index 000000000..75b48b480 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch @@ -0,0 +1,18 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -403,13 +403,8 @@ static void ath9k_hw_init_config(struct + + ah->config.rx_intr_mitigation = true; + +- if (AR_SREV_9300_20_OR_LATER(ah)) { +- ah->config.rimt_last = 500; +- ah->config.rimt_first = 2000; +- } else { +- ah->config.rimt_last = 250; +- ah->config.rimt_first = 700; +- } ++ ah->config.rimt_last = 250; ++ ah->config.rimt_first = 500; + + if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) + ah->config.pll_pwrsave = 7; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/511-ath9k_reduce_rxbuf.patch b/feeds/wifi-ath10k/mac80211/patches/ath/511-ath9k_reduce_rxbuf.patch new file mode 100644 index 000000000..15b8d7b86 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/511-ath9k_reduce_rxbuf.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -88,7 +88,7 @@ int ath_descdma_setup(struct ath_softc * + (_l) &= ((_sz) - 1); \ + } while (0) + +-#define ATH_RXBUF 512 ++#define ATH_RXBUF 256 + #define ATH_TXBUF 512 + #define ATH_TXBUF_RESERVE 5 + #define ATH_TXMAXTRY 13 diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/512-ath9k_channelbw_debugfs.patch b/feeds/wifi-ath10k/mac80211/patches/ath/512-ath9k_channelbw_debugfs.patch new file mode 100644 index 000000000..80e33182f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/512-ath9k_channelbw_debugfs.patch @@ -0,0 +1,125 @@ +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1408,6 +1408,52 @@ static const struct file_operations fops + .owner = THIS_MODULE + }; + ++ ++static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ struct ath_common *common = ath9k_hw_common(sc->sc_ah); ++ char buf[32]; ++ unsigned int len; ++ ++ len = sprintf(buf, "0x%08x\n", common->chan_bw); ++ return simple_read_from_buffer(user_buf, count, ppos, buf, len); ++} ++ ++static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ struct ath_common *common = ath9k_hw_common(sc->sc_ah); ++ unsigned long chan_bw; ++ char buf[32]; ++ ssize_t len; ++ ++ len = min(count, sizeof(buf) - 1); ++ if (copy_from_user(buf, user_buf, len)) ++ return -EFAULT; ++ ++ buf[len] = '\0'; ++ if (kstrtoul(buf, 0, &chan_bw)) ++ return -EINVAL; ++ ++ common->chan_bw = chan_bw; ++ if (!test_bit(ATH_OP_INVALID, &common->op_flags)) ++ ath9k_ops.config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL); ++ ++ return count; ++} ++ ++static const struct file_operations fops_chanbw = { ++ .read = read_file_chan_bw, ++ .write = write_file_chan_bw, ++ .open = simple_open, ++ .owner = THIS_MODULE, ++ .llseek = default_llseek, ++}; ++ ++ + int ath9k_init_debug(struct ath_hw *ah) + { + struct ath_common *common = ath9k_hw_common(ah); +@@ -1429,6 +1475,8 @@ int ath9k_init_debug(struct ath_hw *ah) + + debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, + &fops_eeprom); ++ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, ++ sc, &fops_chanbw); + debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -149,6 +149,7 @@ struct ath_common { + int debug_mask; + enum ath_device_state state; + unsigned long op_flags; ++ u32 chan_bw; + + struct ath_ani ani; + +--- a/drivers/net/wireless/ath/ath9k/common.c ++++ b/drivers/net/wireless/ath/ath9k/common.c +@@ -297,11 +297,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke + /* + * Update internal channel flags. + */ +-static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, ++static void ath9k_cmn_update_ichannel(struct ath_common *common, ++ struct ath9k_channel *ichan, + struct cfg80211_chan_def *chandef) + { + struct ieee80211_channel *chan = chandef->chan; + u16 flags = 0; ++ int width; + + ichan->channel = chan->center_freq; + ichan->chan = chan; +@@ -309,7 +311,19 @@ static void ath9k_cmn_update_ichannel(st + if (chan->band == NL80211_BAND_5GHZ) + flags |= CHANNEL_5GHZ; + +- switch (chandef->width) { ++ switch (common->chan_bw) { ++ case 5: ++ width = NL80211_CHAN_WIDTH_5; ++ break; ++ case 10: ++ width = NL80211_CHAN_WIDTH_10; ++ break; ++ default: ++ width = chandef->width; ++ break; ++ } ++ ++ switch (width) { + case NL80211_CHAN_WIDTH_5: + flags |= CHANNEL_QUARTER; + break; +@@ -342,10 +356,11 @@ struct ath9k_channel *ath9k_cmn_get_chan + struct cfg80211_chan_def *chandef) + { + struct ieee80211_channel *curchan = chandef->chan; ++ struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_channel *channel; + + channel = &ah->channels[curchan->hw_value]; +- ath9k_cmn_update_ichannel(channel, chandef); ++ ath9k_cmn_update_ichannel(common, channel, chandef); + + return channel; + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/513-ath9k_add_pci_ids.patch b/feeds/wifi-ath10k/mac80211/patches/ath/513-ath9k_add_pci_ids.patch new file mode 100644 index 000000000..113c35625 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/513-ath9k_add_pci_ids.patch @@ -0,0 +1,30 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -663,6 +663,7 @@ int ath9k_hw_init(struct ath_hw *ah) + + /* These are all the AR5008/AR9001/AR9002/AR9003 hardware family of chipsets */ + switch (ah->hw_version.devid) { ++ case AR9300_DEVID_INVALID: + case AR5416_DEVID_PCI: + case AR5416_DEVID_PCIE: + case AR5416_AR9100_DEVID: +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -36,6 +36,7 @@ + + #define ATHEROS_VENDOR_ID 0x168c + ++#define AR9300_DEVID_INVALID 0xabcd + #define AR5416_DEVID_PCI 0x0023 + #define AR5416_DEVID_PCIE 0x0024 + #define AR9160_DEVID_PCI 0x0027 +--- a/drivers/net/wireless/ath/ath9k/pci.c ++++ b/drivers/net/wireless/ath/ath9k/pci.c +@@ -774,6 +774,7 @@ static const struct pci_device_id ath_pc + .driver_data = ATH9K_PCI_BT_ANT_DIV }, + #endif + ++ { PCI_VDEVICE(ATHEROS, 0xabcd) }, /* PCI-E internal chip default ID */ + { 0 } + }; + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/530-ath9k_extra_leds.patch b/feeds/wifi-ath10k/mac80211/patches/ath/530-ath9k_extra_leds.patch new file mode 100644 index 000000000..1f1948306 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/530-ath9k_extra_leds.patch @@ -0,0 +1,267 @@ +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -843,6 +843,9 @@ static inline int ath9k_dump_btcoex(stru + #ifdef CPTCFG_MAC80211_LEDS + void ath_init_leds(struct ath_softc *sc); + void ath_deinit_leds(struct ath_softc *sc); ++int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name, ++ const char *trigger, bool active_low); ++ + #else + static inline void ath_init_leds(struct ath_softc *sc) + { +@@ -979,6 +982,13 @@ void ath_ant_comb_scan(struct ath_softc + + #define ATH9K_NUM_CHANCTX 2 /* supports 2 operating channels */ + ++struct ath_led { ++ struct list_head list; ++ struct ath_softc *sc; ++ const struct gpio_led *gpio; ++ struct led_classdev cdev; ++}; ++ + struct ath_softc { + struct ieee80211_hw *hw; + struct device *dev; +@@ -1032,9 +1042,8 @@ struct ath_softc { + spinlock_t chan_lock; + + #ifdef CPTCFG_MAC80211_LEDS +- bool led_registered; +- char led_name[32]; +- struct led_classdev led_cdev; ++ const char *led_default_trigger; ++ struct list_head leds; + #endif + + #ifdef CPTCFG_ATH9K_DEBUGFS +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -39,61 +39,111 @@ static void ath_fill_led_pin(struct ath_ + else + ah->led_pin = ATH_LED_PIN_DEF; + } ++} ++ ++static void ath_led_brightness(struct led_classdev *led_cdev, ++ enum led_brightness brightness) ++{ ++ struct ath_led *led = container_of(led_cdev, struct ath_led, cdev); ++ struct ath_softc *sc = led->sc; ++ ++ ath9k_ps_wakeup(sc); ++ ath9k_hw_set_gpio(sc->sc_ah, led->gpio->gpio, ++ (brightness != LED_OFF) ^ led->gpio->active_low); ++ ath9k_ps_restore(sc); ++} ++ ++static int ath_add_led(struct ath_softc *sc, struct ath_led *led) ++{ ++ const struct gpio_led *gpio = led->gpio; ++ int ret; ++ ++ led->cdev.name = gpio->name; ++ led->cdev.default_trigger = gpio->default_trigger; ++ led->cdev.brightness_set = ath_led_brightness; ++ ++ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->cdev); ++ if (ret < 0) ++ return ret; ++ ++ led->sc = sc; ++ list_add(&led->list, &sc->leds); + + /* Configure gpio for output */ +- ath9k_hw_gpio_request_out(ah, ah->led_pin, "ath9k-led", ++ ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name, + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + +- /* LED off, active low */ +- ath9k_hw_set_gpio(ah, ah->led_pin, ah->config.led_active_high ? 0 : 1); ++ /* LED off */ ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); ++ ++ return 0; + } + +-static void ath_led_brightness(struct led_classdev *led_cdev, +- enum led_brightness brightness) ++int ath_create_gpio_led(struct ath_softc *sc, int gpio_num, const char *name, ++ const char *trigger, bool active_low) + { +- struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); +- u32 val = (brightness == LED_OFF); ++ struct ath_led *led; ++ struct gpio_led *gpio; ++ char *_name; ++ int ret; + +- if (sc->sc_ah->config.led_active_high) +- val = !val; ++ led = kzalloc(sizeof(*led) + sizeof(*gpio) + strlen(name) + 1, ++ GFP_KERNEL); ++ if (!led) ++ return -ENOMEM; ++ ++ led->gpio = gpio = (struct gpio_led *) (led + 1); ++ _name = (char *) (led->gpio + 1); ++ ++ strcpy(_name, name); ++ gpio->name = _name; ++ gpio->gpio = gpio_num; ++ gpio->active_low = active_low; ++ gpio->default_trigger = trigger; ++ ++ ret = ath_add_led(sc, led); ++ if (unlikely(ret < 0)) ++ kfree(led); + +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val); ++ return ret; + } + + void ath_deinit_leds(struct ath_softc *sc) + { +- if (!sc->led_registered) +- return; ++ struct ath_led *led; + +- ath_led_brightness(&sc->led_cdev, LED_OFF); +- led_classdev_unregister(&sc->led_cdev); +- +- ath9k_hw_gpio_free(sc->sc_ah, sc->sc_ah->led_pin); ++ while (!list_empty(&sc->leds)) { ++ led = list_first_entry(&sc->leds, struct ath_led, list); ++ list_del(&led->list); ++ ath_led_brightness(&led->cdev, LED_OFF); ++ led_classdev_unregister(&led->cdev); ++ ath9k_hw_gpio_free(sc->sc_ah, led->gpio->gpio); ++ kfree(led); ++ } + } + + void ath_init_leds(struct ath_softc *sc) + { +- int ret; ++ char led_name[32]; ++ const char *trigger; ++ ++ INIT_LIST_HEAD(&sc->leds); + + if (AR_SREV_9100(sc->sc_ah)) + return; + + ath_fill_led_pin(sc); + +- if (!ath9k_led_blink) +- sc->led_cdev.default_trigger = +- ieee80211_get_radio_led_name(sc->hw); +- +- snprintf(sc->led_name, sizeof(sc->led_name), +- "ath9k-%s", wiphy_name(sc->hw->wiphy)); +- sc->led_cdev.name = sc->led_name; +- sc->led_cdev.brightness_set = ath_led_brightness; ++ snprintf(led_name, sizeof(led_name), "ath9k-%s", ++ wiphy_name(sc->hw->wiphy)); + +- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev); +- if (ret < 0) +- return; ++ if (ath9k_led_blink) ++ trigger = sc->led_default_trigger; ++ else ++ trigger = ieee80211_get_radio_led_name(sc->hw); + +- sc->led_registered = true; ++ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, ++ !sc->sc_ah->config.led_active_high); + } + #endif + +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -1055,7 +1055,7 @@ int ath9k_init_device(u16 devid, struct + + #ifdef CPTCFG_MAC80211_LEDS + /* must be initialized before ieee80211_register_hw */ +- sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, ++ sc->led_default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, + IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink, + ARRAY_SIZE(ath9k_tpt_blink)); + #endif +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1453,6 +1453,61 @@ static const struct file_operations fops + .llseek = default_llseek, + }; + ++#ifdef CONFIG_MAC80211_LEDS ++ ++static ssize_t write_file_gpio_led(struct file *file, const char __user *ubuf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ char buf[32], *str, *name, *c; ++ ssize_t len; ++ unsigned int gpio; ++ bool active_low = false; ++ ++ len = min(count, sizeof(buf) - 1); ++ if (copy_from_user(buf, ubuf, len)) ++ return -EFAULT; ++ ++ buf[len] = '\0'; ++ name = strchr(buf, ','); ++ if (!name) ++ return -EINVAL; ++ ++ *(name++) = 0; ++ if (!*name) ++ return -EINVAL; ++ ++ c = strchr(name, '\n'); ++ if (c) ++ *c = 0; ++ ++ str = buf; ++ if (*str == '!') { ++ str++; ++ active_low = true; ++ } ++ ++ if (kstrtouint(str, 0, &gpio) < 0) ++ return -EINVAL; ++ ++ if (gpio >= sc->sc_ah->caps.num_gpio_pins) ++ return -EINVAL; ++ ++ if (ath_create_gpio_led(sc, gpio, name, NULL, active_low) < 0) ++ return -EINVAL; ++ ++ return count; ++} ++ ++static const struct file_operations fops_gpio_led = { ++ .write = write_file_gpio_led, ++ .open = simple_open, ++ .owner = THIS_MODULE, ++ .llseek = default_llseek, ++}; ++ ++#endif ++ + + int ath9k_init_debug(struct ath_hw *ah) + { +@@ -1477,6 +1532,10 @@ int ath9k_init_debug(struct ath_hw *ah) + &fops_eeprom); + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, + sc, &fops_chanbw); ++#ifdef CONFIG_MAC80211_LEDS ++ debugfs_create_file("gpio_led", S_IWUSR, ++ sc->debug.debugfs_phy, sc, &fops_gpio_led); ++#endif + debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/531-ath9k_extra_platform_leds.patch b/feeds/wifi-ath10k/mac80211/patches/ath/531-ath9k_extra_platform_leds.patch new file mode 100644 index 000000000..8ed7ad8a0 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/531-ath9k_extra_platform_leds.patch @@ -0,0 +1,76 @@ +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -46,6 +46,9 @@ struct ath9k_platform_data { + int (*external_reset)(void); + + bool use_eeprom; ++ ++ int num_leds; ++ const struct gpio_led *leds; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -15,6 +15,7 @@ + */ + + #include "ath9k.h" ++#include + + /********************************/ + /* LED functions */ +@@ -108,6 +109,24 @@ int ath_create_gpio_led(struct ath_softc + return ret; + } + ++static int ath_create_platform_led(struct ath_softc *sc, ++ const struct gpio_led *gpio) ++{ ++ struct ath_led *led; ++ int ret; ++ ++ led = kzalloc(sizeof(*led), GFP_KERNEL); ++ if (!led) ++ return -ENOMEM; ++ ++ led->gpio = gpio; ++ ret = ath_add_led(sc, led); ++ if (ret < 0) ++ kfree(led); ++ ++ return ret; ++} ++ + void ath_deinit_leds(struct ath_softc *sc) + { + struct ath_led *led; +@@ -124,8 +143,10 @@ void ath_deinit_leds(struct ath_softc *s + + void ath_init_leds(struct ath_softc *sc) + { ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + char led_name[32]; + const char *trigger; ++ int i; + + INIT_LIST_HEAD(&sc->leds); + +@@ -134,6 +155,17 @@ void ath_init_leds(struct ath_softc *sc) + + ath_fill_led_pin(sc); + ++ if (pdata && pdata->leds && pdata->num_leds) ++ for (i = 0; i < pdata->num_leds; i++) { ++ if (pdata->leds[i].gpio == sc->sc_ah->led_pin) ++ sc->sc_ah->led_pin = -1; ++ ++ ath_create_platform_led(sc, &pdata->leds[i]); ++ } ++ ++ if (sc->sc_ah->led_pin < 0) ++ return; ++ + snprintf(led_name, sizeof(led_name), "ath9k-%s", + wiphy_name(sc->hw->wiphy)); + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/540-ath9k_reduce_ani_interval.patch b/feeds/wifi-ath10k/mac80211/patches/ath/540-ath9k_reduce_ani_interval.patch new file mode 100644 index 000000000..e89990347 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/540-ath9k_reduce_ani_interval.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ath/ath9k/ani.h ++++ b/drivers/net/wireless/ath/ath9k/ani.h +@@ -42,7 +42,7 @@ + #define ATH9K_ANI_PERIOD 300 + + /* in ms */ +-#define ATH9K_ANI_POLLINTERVAL 1000 ++#define ATH9K_ANI_POLLINTERVAL 300 + + #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0 + #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20 diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/542-ath9k_debugfs_diag.patch b/feeds/wifi-ath10k/mac80211/patches/ath/542-ath9k_debugfs_diag.patch new file mode 100644 index 000000000..5220157de --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/542-ath9k_debugfs_diag.patch @@ -0,0 +1,139 @@ +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1509,6 +1509,50 @@ static const struct file_operations fops + #endif + + ++static ssize_t read_file_diag(struct file *file, char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ struct ath_hw *ah = sc->sc_ah; ++ char buf[32]; ++ unsigned int len; ++ ++ len = sprintf(buf, "0x%08lx\n", ah->diag); ++ return simple_read_from_buffer(user_buf, count, ppos, buf, len); ++} ++ ++static ssize_t write_file_diag(struct file *file, const char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_softc *sc = file->private_data; ++ struct ath_hw *ah = sc->sc_ah; ++ unsigned long diag; ++ char buf[32]; ++ ssize_t len; ++ ++ len = min(count, sizeof(buf) - 1); ++ if (copy_from_user(buf, user_buf, len)) ++ return -EFAULT; ++ ++ buf[len] = '\0'; ++ if (kstrtoul(buf, 0, &diag)) ++ return -EINVAL; ++ ++ ah->diag = diag; ++ ath9k_hw_update_diag(ah); ++ ++ return count; ++} ++ ++static const struct file_operations fops_diag = { ++ .read = read_file_diag, ++ .write = write_file_diag, ++ .open = simple_open, ++ .owner = THIS_MODULE, ++ .llseek = default_llseek, ++}; ++ ++ + int ath9k_init_debug(struct ath_hw *ah) + { + struct ath_common *common = ath9k_hw_common(ah); +@@ -1536,6 +1580,8 @@ int ath9k_init_debug(struct ath_hw *ah) + debugfs_create_file("gpio_led", S_IWUSR, + sc->debug.debugfs_phy, sc, &fops_gpio_led); + #endif ++ debugfs_create_file("diag", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, ++ sc, &fops_diag); + debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -522,6 +522,12 @@ enum { + ATH9K_RESET_COLD, + }; + ++enum { ++ ATH_DIAG_DISABLE_RX, ++ ATH_DIAG_DISABLE_TX, ++ ATH_DIAG_TRIGGER_ERROR, ++}; ++ + struct ath9k_hw_version { + u32 magic; + u16 devid; +@@ -810,6 +816,8 @@ struct ath_hw { + u32 ah_flags; + s16 nf_override; + ++ unsigned long diag; ++ + bool reset_power_on; + bool htc_reset_init; + +@@ -1076,6 +1084,7 @@ void ath9k_hw_check_nav(struct ath_hw *a + bool ath9k_hw_check_alive(struct ath_hw *ah); + + bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode); ++void ath9k_hw_update_diag(struct ath_hw *ah); + + /* Generic hw timer primitives */ + struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1883,6 +1883,20 @@ u32 ath9k_hw_get_tsf_offset(struct times + } + EXPORT_SYMBOL(ath9k_hw_get_tsf_offset); + ++void ath9k_hw_update_diag(struct ath_hw *ah) ++{ ++ if (test_bit(ATH_DIAG_DISABLE_RX, &ah->diag)) ++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); ++ else ++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); ++ ++ if (test_bit(ATH_DIAG_DISABLE_TX, &ah->diag)) ++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK); ++ else ++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK); ++} ++EXPORT_SYMBOL(ath9k_hw_update_diag); ++ + int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, + struct ath9k_hw_cal_data *caldata, bool fastcc) + { +@@ -2091,6 +2105,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st + ar9003_hw_disable_phy_restart(ah); + + ath9k_hw_apply_gpio_override(ah); ++ ath9k_hw_update_diag(ah); + + if (AR_SREV_9565(ah) && common->bt_ant_diversity) + REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON); +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -528,6 +528,11 @@ irqreturn_t ath_isr(int irq, void *dev) + if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) + return IRQ_HANDLED; + ++ if (test_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag)) { ++ status |= ATH9K_INT_FATAL; ++ clear_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag); ++ } ++ + /* + * If there are no status bits set, then this interrupt was not + * for me (should have been caught above). diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/543-ath9k_entropy_from_adc.patch b/feeds/wifi-ath10k/mac80211/patches/ath/543-ath9k_entropy_from_adc.patch new file mode 100644 index 000000000..f59654e41 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/543-ath9k_entropy_from_adc.patch @@ -0,0 +1,186 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -723,6 +723,7 @@ struct ath_spec_scan { + * @config_pci_powersave: + * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC + * ++ * @get_adc_entropy: get entropy from the raw ADC I/Q output + * @spectral_scan_config: set parameters for spectral scan and enable/disable it + * @spectral_scan_trigger: trigger a spectral scan run + * @spectral_scan_wait: wait for a spectral scan run to finish +@@ -745,6 +746,7 @@ struct ath_hw_ops { + struct ath_hw_antcomb_conf *antconf); + void (*antdiv_comb_conf_set)(struct ath_hw *ah, + struct ath_hw_antcomb_conf *antconf); ++ void (*get_adc_entropy)(struct ath_hw *ah, u8 *buf, size_t len); + void (*spectral_scan_config)(struct ath_hw *ah, + struct ath_spec_scan *param); + void (*spectral_scan_trigger)(struct ath_hw *ah); +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -1927,6 +1927,26 @@ void ar9003_hw_init_rate_txpower(struct + } + } + ++static void ar9003_hw_get_adc_entropy(struct ath_hw *ah, u8 *buf, size_t len) ++{ ++ int i, j; ++ ++ REG_RMW_FIELD(ah, AR_PHY_TEST, AR_PHY_TEST_BBB_OBS_SEL, 1); ++ REG_CLR_BIT(ah, AR_PHY_TEST, AR_PHY_TEST_RX_OBS_SEL_BIT5); ++ REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS, AR_PHY_TEST_CTL_RX_OBS_SEL, 0); ++ ++ memset(buf, 0, len); ++ for (i = 0; i < len; i++) { ++ for (j = 0; j < 4; j++) { ++ u32 regval = REG_READ(ah, AR_PHY_TST_ADC); ++ ++ buf[i] <<= 2; ++ buf[i] |= (regval & 1) | ((regval & BIT(10)) >> 9); ++ udelay(1); ++ } ++ } ++} ++ + void ar9003_hw_attach_phy_ops(struct ath_hw *ah) + { + struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); +@@ -1963,6 +1983,7 @@ void ar9003_hw_attach_phy_ops(struct ath + priv_ops->set_radar_params = ar9003_hw_set_radar_params; + priv_ops->fast_chan_change = ar9003_hw_fast_chan_change; + ++ ops->get_adc_entropy = ar9003_hw_get_adc_entropy; + ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get; + ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set; + ops->spectral_scan_config = ar9003_hw_spectral_scan_config; +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -819,7 +819,8 @@ static void ath9k_init_txpower_limits(st + if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) + ath9k_init_band_txpower(sc, NL80211_BAND_5GHZ); + +- ah->curchan = curchan; ++ if (curchan) ++ ah->curchan = curchan; + } + + static const struct ieee80211_iface_limit if_limits[] = { +@@ -1015,6 +1016,18 @@ static void ath9k_set_hw_capab(struct at + NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS); + } + ++static void ath_get_initial_entropy(struct ath_softc *sc) ++{ ++ struct ath_hw *ah = sc->sc_ah; ++ char buf[256]; ++ ++ /* reuse last channel initialized by the tx power test */ ++ ath9k_hw_reset(ah, ah->curchan, NULL, false); ++ ++ ath9k_hw_get_adc_entropy(ah, buf, sizeof(buf)); ++ add_device_randomness(buf, sizeof(buf)); ++} ++ + int ath9k_init_device(u16 devid, struct ath_softc *sc, + const struct ath_bus_ops *bus_ops) + { +@@ -1060,6 +1073,8 @@ int ath9k_init_device(u16 devid, struct + ARRAY_SIZE(ath9k_tpt_blink)); + #endif + ++ ath_get_initial_entropy(sc); ++ + /* Register with mac80211 */ + error = ieee80211_register_hw(hw); + if (error) +--- a/drivers/net/wireless/ath/ath9k/hw-ops.h ++++ b/drivers/net/wireless/ath/ath9k/hw-ops.h +@@ -100,6 +100,12 @@ static inline void ath9k_hw_tx99_set_txp + ath9k_hw_ops(ah)->tx99_set_txpower(ah, power); + } + ++static inline void ath9k_hw_get_adc_entropy(struct ath_hw *ah, ++ u8 *buf, size_t len) ++{ ++ ath9k_hw_ops(ah)->get_adc_entropy(ah, buf, len); ++} ++ + #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT + + static inline void ath9k_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) +--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c +@@ -1320,9 +1320,30 @@ void ar5008_hw_init_rate_txpower(struct + } + } + ++static void ar5008_hw_get_adc_entropy(struct ath_hw *ah, u8 *buf, size_t len) ++{ ++ int i, j; ++ ++ REG_RMW_FIELD(ah, AR_PHY_TEST, AR_PHY_TEST_BBB_OBS_SEL, 1); ++ REG_CLR_BIT(ah, AR_PHY_TEST, AR_PHY_TEST_RX_OBS_SEL_BIT5); ++ REG_RMW_FIELD(ah, AR_PHY_TEST2, AR_PHY_TEST2_RX_OBS_SEL, 0); ++ ++ memset(buf, 0, len); ++ for (i = 0; i < len; i++) { ++ for (j = 0; j < 4; j++) { ++ u32 regval = REG_READ(ah, AR_PHY_TST_ADC); ++ ++ buf[i] <<= 2; ++ buf[i] |= (regval & 1) | ((regval & BIT(9)) >> 8); ++ udelay(1); ++ } ++ } ++} ++ + int ar5008_hw_attach_phy_ops(struct ath_hw *ah) + { + struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); ++ struct ath_hw_ops *ops = ath9k_hw_ops(ah); + static const u32 ar5416_cca_regs[6] = { + AR_PHY_CCA, + AR_PHY_CH1_CCA, +@@ -1337,6 +1358,8 @@ int ar5008_hw_attach_phy_ops(struct ath_ + if (ret) + return ret; + ++ ops->get_adc_entropy = ar5008_hw_get_adc_entropy; ++ + priv_ops->rf_set_freq = ar5008_hw_set_channel; + priv_ops->spur_mitigate_freq = ar5008_hw_spur_mitigate; + +--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h ++++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h +@@ -20,6 +20,12 @@ + #define PHY_AGC_CLR 0x10000000 + #define RFSILENT_BB 0x00002000 + ++#define AR_PHY_TEST_BBB_OBS_SEL 0x780000 ++#define AR_PHY_TEST_BBB_OBS_SEL_S 19 ++ ++#define AR_PHY_TEST_RX_OBS_SEL_BIT5_S 23 ++#define AR_PHY_TEST_RX_OBS_SEL_BIT5 (1 << AR_PHY_TEST_RX_OBS_SEL_BIT5_S) ++ + #define AR_PHY_TURBO 0x9804 + #define AR_PHY_FC_TURBO_MODE 0x00000001 + #define AR_PHY_FC_TURBO_SHORT 0x00000002 +@@ -36,6 +42,9 @@ + + #define AR_PHY_TEST2 0x9808 + ++#define AR_PHY_TEST2_RX_OBS_SEL 0x3C00 ++#define AR_PHY_TEST2_RX_OBS_SEL_S 10 ++ + #define AR_PHY_TIMING2 0x9810 + #define AR_PHY_TIMING3 0x9814 + #define AR_PHY_TIMING3_DSC_MAN 0xFFFE0000 +@@ -393,6 +402,8 @@ + #define AR_PHY_RFBUS_GRANT 0x9C20 + #define AR_PHY_RFBUS_GRANT_EN 0x00000001 + ++#define AR_PHY_TST_ADC 0x9C24 ++ + #define AR_PHY_CHAN_INFO_GAIN_DIFF 0x9CF4 + #define AR_PHY_CHAN_INFO_GAIN_DIFF_UPPER_LIMIT 320 + diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch b/feeds/wifi-ath10k/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch new file mode 100644 index 000000000..93eee34b6 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch @@ -0,0 +1,79 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -248,6 +248,19 @@ void ath9k_hw_get_channel_centers(struct + centers->synth_center + (extoff * HT40_CHANNEL_CENTER_SHIFT); + } + ++static inline void ath9k_hw_disable_pll_lock_detect(struct ath_hw *ah) ++{ ++ /* On AR9330 and AR9340 devices, some PHY registers must be ++ * tuned to gain better stability/performance. These registers ++ * might be changed while doing wlan reset so the registers must ++ * be reprogrammed after each reset. ++ */ ++ REG_CLR_BIT(ah, AR_PHY_USB_CTRL1, BIT(20)); ++ REG_RMW(ah, AR_PHY_USB_CTRL2, ++ (1 << 21) | (0xf << 22), ++ (1 << 21) | (0x3 << 22)); ++} ++ + /******************/ + /* Chip Revisions */ + /******************/ +@@ -1455,6 +1468,9 @@ static bool ath9k_hw_set_reset(struct at + udelay(50); + } + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return true; + } + +@@ -1554,6 +1570,9 @@ static bool ath9k_hw_chip_reset(struct a + ar9003_hw_internal_regulator_apply(ah); + ath9k_hw_init_pll(ah, chan); + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return true; + } + +@@ -1861,8 +1880,14 @@ static int ath9k_hw_do_fastcc(struct ath + if (AR_SREV_9271(ah)) + ar9002_hw_load_ani_reg(ah, chan); + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return 0; + fail: ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return -EINVAL; + } + +@@ -2116,6 +2141,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st + ath9k_hw_set_radar_params(ah); + } + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return 0; + } + EXPORT_SYMBOL(ath9k_hw_reset); +--- a/drivers/net/wireless/ath/ath9k/phy.h ++++ b/drivers/net/wireless/ath/ath9k/phy.h +@@ -48,6 +48,9 @@ + #define AR_PHY_PLL_CONTROL 0x16180 + #define AR_PHY_PLL_MODE 0x16184 + ++#define AR_PHY_USB_CTRL1 0x16c84 ++#define AR_PHY_USB_CTRL2 0x16c88 ++ + enum ath9k_ant_div_comb_lna_conf { + ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2, + ATH_ANT_DIV_COMB_LNA2, diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/545-ath9k_ani_ws_detect.patch b/feeds/wifi-ath10k/mac80211/patches/ath/545-ath9k_ani_ws_detect.patch new file mode 100644 index 000000000..48cc17113 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/545-ath9k_ani_ws_detect.patch @@ -0,0 +1,155 @@ +--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c +@@ -949,55 +949,6 @@ static bool ar5008_hw_ani_control_new(st + * on == 0 means more noise imm + */ + u32 on = param ? 1 : 0; +- /* +- * make register setting for default +- * (weak sig detect ON) come from INI file +- */ +- int m1ThreshLow = on ? +- aniState->iniDef.m1ThreshLow : m1ThreshLow_off; +- int m2ThreshLow = on ? +- aniState->iniDef.m2ThreshLow : m2ThreshLow_off; +- int m1Thresh = on ? +- aniState->iniDef.m1Thresh : m1Thresh_off; +- int m2Thresh = on ? +- aniState->iniDef.m2Thresh : m2Thresh_off; +- int m2CountThr = on ? +- aniState->iniDef.m2CountThr : m2CountThr_off; +- int m2CountThrLow = on ? +- aniState->iniDef.m2CountThrLow : m2CountThrLow_off; +- int m1ThreshLowExt = on ? +- aniState->iniDef.m1ThreshLowExt : m1ThreshLowExt_off; +- int m2ThreshLowExt = on ? +- aniState->iniDef.m2ThreshLowExt : m2ThreshLowExt_off; +- int m1ThreshExt = on ? +- aniState->iniDef.m1ThreshExt : m1ThreshExt_off; +- int m2ThreshExt = on ? +- aniState->iniDef.m2ThreshExt : m2ThreshExt_off; +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M1_THRESH_LOW, +- m1ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2_THRESH_LOW, +- m2ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M1_THRESH, m1Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2_THRESH, m2Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2COUNT_THR, m2CountThr); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW, +- m2CountThrLow); +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH_LOW, m1ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH_LOW, m2ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH, m1ThreshExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH, m2ThreshExt); + + if (on) + REG_SET_BIT(ah, AR_PHY_SFCORR_LOW, +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -42,20 +42,6 @@ static const int cycpwrThr1_table[] = + /* level: 0 1 2 3 4 5 6 7 8 */ + { -6, -4, -2, 0, 2, 4, 6, 8 }; /* lvl 0-7, default 3 */ + +-/* +- * register values to turn OFDM weak signal detection OFF +- */ +-static const int m1ThreshLow_off = 127; +-static const int m2ThreshLow_off = 127; +-static const int m1Thresh_off = 127; +-static const int m2Thresh_off = 127; +-static const int m2CountThr_off = 31; +-static const int m2CountThrLow_off = 63; +-static const int m1ThreshLowExt_off = 127; +-static const int m2ThreshLowExt_off = 127; +-static const int m1ThreshExt_off = 127; +-static const int m2ThreshExt_off = 127; +- + static const u8 ofdm2pwr[] = { + ALL_TARGET_LEGACY_6_24, + ALL_TARGET_LEGACY_6_24, +@@ -1077,11 +1063,6 @@ static bool ar9003_hw_ani_control(struct + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_channel *chan = ah->curchan; + struct ar5416AniState *aniState = &ah->ani; +- int m1ThreshLow, m2ThreshLow; +- int m1Thresh, m2Thresh; +- int m2CountThr, m2CountThrLow; +- int m1ThreshLowExt, m2ThreshLowExt; +- int m1ThreshExt, m2ThreshExt; + s32 value, value2; + + switch (cmd & ah->ani_function) { +@@ -1095,61 +1076,6 @@ static bool ar9003_hw_ani_control(struct + */ + u32 on = param ? 1 : 0; + +- if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) +- goto skip_ws_det; +- +- m1ThreshLow = on ? +- aniState->iniDef.m1ThreshLow : m1ThreshLow_off; +- m2ThreshLow = on ? +- aniState->iniDef.m2ThreshLow : m2ThreshLow_off; +- m1Thresh = on ? +- aniState->iniDef.m1Thresh : m1Thresh_off; +- m2Thresh = on ? +- aniState->iniDef.m2Thresh : m2Thresh_off; +- m2CountThr = on ? +- aniState->iniDef.m2CountThr : m2CountThr_off; +- m2CountThrLow = on ? +- aniState->iniDef.m2CountThrLow : m2CountThrLow_off; +- m1ThreshLowExt = on ? +- aniState->iniDef.m1ThreshLowExt : m1ThreshLowExt_off; +- m2ThreshLowExt = on ? +- aniState->iniDef.m2ThreshLowExt : m2ThreshLowExt_off; +- m1ThreshExt = on ? +- aniState->iniDef.m1ThreshExt : m1ThreshExt_off; +- m2ThreshExt = on ? +- aniState->iniDef.m2ThreshExt : m2ThreshExt_off; +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M1_THRESH_LOW, +- m1ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2_THRESH_LOW, +- m2ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M1_THRESH, +- m1Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2_THRESH, +- m2Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2COUNT_THR, +- m2CountThr); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW, +- m2CountThrLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH_LOW, +- m1ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH_LOW, +- m2ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH, +- m1ThreshExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH, +- m2ThreshExt); +-skip_ws_det: + if (on) + REG_SET_BIT(ah, AR_PHY_SFCORR_LOW, + AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW); diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/547-ath9k_led_defstate_fix.patch b/feeds/wifi-ath10k/mac80211/patches/ath/547-ath9k_led_defstate_fix.patch new file mode 100644 index 000000000..5d84cf0c4 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/547-ath9k_led_defstate_fix.patch @@ -0,0 +1,29 @@ +From: Michal Cieslakiewicz +Date: Sun, 31 Jan 2016 20:48:49 +0100 +Subject: [PATCH v4 2/8] mac80211: ath9k: set default state for platform LEDs + +Support default state for platform LEDs connected to ath9k device. +Now LEDs are correctly set on or off at ath9k module initialization. +Very useful if power LED is connected to wireless chip. + +Signed-off-by: Michal Cieslakiewicz +--- + gpio.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -74,8 +74,11 @@ static int ath_add_led(struct ath_softc + ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name, + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + +- /* LED off */ +- ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); ++ /* Set default LED state */ ++ if (gpio->default_state == LEDS_GPIO_DEFSTATE_ON) ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, !gpio->active_low); ++ else ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); + + return 0; + } diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/548-ath9k_enable_gpio_chip.patch b/feeds/wifi-ath10k/mac80211/patches/ath/548-ath9k_enable_gpio_chip.patch new file mode 100644 index 000000000..78206d286 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/548-ath9k_enable_gpio_chip.patch @@ -0,0 +1,251 @@ +From: Michal Cieslakiewicz +Date: Sun, 31 Jan 2016 21:01:31 +0100 +Subject: [PATCH v4 4/8] mac80211: ath9k: enable access to GPIO + +Enable access to GPIO chip and its pins for Atheros AR92xx +wireless devices. For now AR9285 and AR9287 are supported. + +Signed-off-by: Michal Cieslakiewicz +Signed-off-by: Felix Fietkau +--- +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include "common.h" + #include "debug.h" +@@ -989,6 +990,14 @@ struct ath_led { + struct led_classdev cdev; + }; + ++#ifdef CONFIG_GPIOLIB ++struct ath9k_gpio_chip { ++ struct ath_softc *sc; ++ char label[32]; ++ struct gpio_chip gchip; ++}; ++#endif ++ + struct ath_softc { + struct ieee80211_hw *hw; + struct device *dev; +@@ -1044,6 +1053,9 @@ struct ath_softc { + #ifdef CPTCFG_MAC80211_LEDS + const char *led_default_trigger; + struct list_head leds; ++#ifdef CONFIG_GPIOLIB ++ struct ath9k_gpio_chip *gpiochip; ++#endif + #endif + + #ifdef CPTCFG_ATH9K_DEBUGFS +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -16,13 +16,139 @@ + + #include "ath9k.h" + #include ++#include ++ ++#ifdef CPTCFG_MAC80211_LEDS ++ ++#ifdef CONFIG_GPIOLIB ++ ++/***************/ ++/* GPIO Chip */ ++/***************/ ++ ++/* gpio_chip handler : set GPIO to input */ ++static int ath9k_gpio_pin_cfg_input(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_gpio_request_in(gc->sc->sc_ah, offset, "ath9k-gpio"); ++ ++ return 0; ++} ++ ++/* gpio_chip handler : set GPIO to output */ ++static int ath9k_gpio_pin_cfg_output(struct gpio_chip *chip, unsigned offset, ++ int value) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_gpio_request_out(gc->sc->sc_ah, offset, "ath9k-gpio", ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_set_gpio(gc->sc->sc_ah, offset, value); ++ ++ return 0; ++} ++ ++/* gpio_chip handler : query GPIO direction (0=out, 1=in) */ ++static int ath9k_gpio_pin_get_dir(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ struct ath_hw *ah = gc->sc->sc_ah; ++ ++ return !((REG_READ(ah, AR_GPIO_OE_OUT) >> (offset * 2)) & 3); ++} ++ ++/* gpio_chip handler : get GPIO pin value */ ++static int ath9k_gpio_pin_get(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ return ath9k_hw_gpio_get(gc->sc->sc_ah, offset); ++} ++ ++/* gpio_chip handler : set GPIO pin to value */ ++static void ath9k_gpio_pin_set(struct gpio_chip *chip, unsigned offset, ++ int value) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_set_gpio(gc->sc->sc_ah, offset, value); ++} ++ ++/* register GPIO chip */ ++static void ath9k_register_gpio_chip(struct ath_softc *sc) ++{ ++ struct ath9k_gpio_chip *gc; ++ struct ath_hw *ah = sc->sc_ah; ++ ++ gc = kzalloc(sizeof(struct ath9k_gpio_chip), GFP_KERNEL); ++ if (!gc) ++ return; ++ ++ gc->sc = sc; ++ snprintf(gc->label, sizeof(gc->label), "ath9k-%s", ++ wiphy_name(sc->hw->wiphy)); ++#ifdef CONFIG_OF ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) ++ gc->gchip.parent = sc->dev; ++#else ++ gc->gchip.dev = sc->dev; ++#endif ++#endif ++ gc->gchip.label = gc->label; ++ gc->gchip.base = -1; /* determine base automatically */ ++ gc->gchip.ngpio = ah->caps.num_gpio_pins; ++ gc->gchip.direction_input = ath9k_gpio_pin_cfg_input; ++ gc->gchip.direction_output = ath9k_gpio_pin_cfg_output; ++ gc->gchip.get_direction = ath9k_gpio_pin_get_dir; ++ gc->gchip.get = ath9k_gpio_pin_get; ++ gc->gchip.set = ath9k_gpio_pin_set; ++ ++ if (gpiochip_add(&gc->gchip)) { ++ kfree(gc); ++ return; ++ } ++ ++#ifdef CONFIG_OF ++ gc->gchip.owner = NULL; ++#endif ++ sc->gpiochip = gc; ++} ++ ++/* remove GPIO chip */ ++static void ath9k_unregister_gpio_chip(struct ath_softc *sc) ++{ ++ struct ath9k_gpio_chip *gc = sc->gpiochip; ++ ++ if (!gc) ++ return; ++ ++ gpiochip_remove(&gc->gchip); ++ kfree(gc); ++ sc->gpiochip = NULL; ++} ++ ++#else /* CONFIG_GPIOLIB */ ++ ++static inline void ath9k_register_gpio_chip(struct ath_softc *sc) ++{ ++} ++ ++static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc) ++{ ++} ++ ++#endif /* CONFIG_GPIOLIB */ + + /********************************/ + /* LED functions */ + /********************************/ + +-#ifdef CPTCFG_MAC80211_LEDS +- + static void ath_fill_led_pin(struct ath_softc *sc) + { + struct ath_hw *ah = sc->sc_ah; +@@ -80,6 +206,12 @@ static int ath_add_led(struct ath_softc + else + ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); + ++#ifdef CONFIG_GPIOLIB ++ /* If there is GPIO chip configured, reserve LED pin */ ++ if (sc->gpiochip) ++ gpio_request(sc->gpiochip->gchip.base + gpio->gpio, gpio->name); ++#endif ++ + return 0; + } + +@@ -136,17 +268,24 @@ void ath_deinit_leds(struct ath_softc *s + + while (!list_empty(&sc->leds)) { + led = list_first_entry(&sc->leds, struct ath_led, list); ++#ifdef CONFIG_GPIOLIB ++ /* If there is GPIO chip configured, free LED pin */ ++ if (sc->gpiochip) ++ gpio_free(sc->gpiochip->gchip.base + led->gpio->gpio); ++#endif + list_del(&led->list); + ath_led_brightness(&led->cdev, LED_OFF); + led_classdev_unregister(&led->cdev); + ath9k_hw_gpio_free(sc->sc_ah, led->gpio->gpio); + kfree(led); + } ++ ath9k_unregister_gpio_chip(sc); + } + + void ath_init_leds(struct ath_softc *sc) + { + struct ath9k_platform_data *pdata = sc->dev->platform_data; ++ struct device_node *np = sc->dev->of_node; + char led_name[32]; + const char *trigger; + int i; +@@ -156,6 +295,15 @@ void ath_init_leds(struct ath_softc *sc) + if (AR_SREV_9100(sc->sc_ah)) + return; + ++ if (!np) ++ ath9k_register_gpio_chip(sc); ++ ++ /* setup gpio controller only if requested and skip the led_pin setup */ ++ if (of_property_read_bool(np, "gpio-controller")) { ++ ath9k_register_gpio_chip(sc); ++ return; ++ } ++ + ath_fill_led_pin(sc); + + if (pdata && pdata->leds && pdata->num_leds) +@@ -180,6 +328,7 @@ void ath_init_leds(struct ath_softc *sc) + ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, + !sc->sc_ah->config.led_active_high); + } ++ + #endif + + /*******************/ diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/549-ath9k_enable_gpio_buttons.patch b/feeds/wifi-ath10k/mac80211/patches/ath/549-ath9k_enable_gpio_buttons.patch new file mode 100644 index 000000000..716e09f35 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/549-ath9k_enable_gpio_buttons.patch @@ -0,0 +1,143 @@ +From: Michal Cieslakiewicz +Subject: [PATCH v5 5/8] mac80211: ath9k: enable GPIO buttons + +Enable platform-defined GPIO button support for ath9k device. +Key poller is activated for attached platform buttons. +Requires ath9k GPIO chip access. + +Signed-off-by: Michal Cieslakiewicz +Signed-off-by: Felix Fietkau +--- +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -1055,6 +1055,7 @@ struct ath_softc { + struct list_head leds; + #ifdef CONFIG_GPIOLIB + struct ath9k_gpio_chip *gpiochip; ++ struct platform_device *btnpdev; /* gpio-keys-polled */ + #endif + #endif + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -17,6 +17,8 @@ + #include "ath9k.h" + #include + #include ++#include ++#include + + #ifdef CPTCFG_MAC80211_LEDS + +@@ -133,6 +135,67 @@ static void ath9k_unregister_gpio_chip(s + sc->gpiochip = NULL; + } + ++/******************/ ++/* GPIO Buttons */ ++/******************/ ++ ++/* add GPIO buttons */ ++static void ath9k_init_buttons(struct ath_softc *sc) ++{ ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; ++ struct platform_device *pdev; ++ struct gpio_keys_platform_data gkpdata; ++ struct gpio_keys_button *bt; ++ int i; ++ ++ if (!sc->gpiochip) ++ return; ++ ++ if (!pdata || !pdata->btns || !pdata->num_btns) ++ return; ++ ++ bt = devm_kmemdup(sc->dev, pdata->btns, ++ pdata->num_btns * sizeof(struct gpio_keys_button), ++ GFP_KERNEL); ++ if (!bt) ++ return; ++ ++ for (i = 0; i < pdata->num_btns; i++) { ++ if (pdata->btns[i].gpio == sc->sc_ah->led_pin) ++ sc->sc_ah->led_pin = -1; ++ ++ ath9k_hw_gpio_request_in(sc->sc_ah, pdata->btns[i].gpio, ++ "ath9k-gpio"); ++ bt[i].gpio = sc->gpiochip->gchip.base + pdata->btns[i].gpio; ++ } ++ ++ memset(&gkpdata, 0, sizeof(struct gpio_keys_platform_data)); ++ gkpdata.buttons = bt; ++ gkpdata.nbuttons = pdata->num_btns; ++ gkpdata.poll_interval = pdata->btn_poll_interval; ++ ++ pdev = platform_device_register_data(sc->dev, "gpio-keys-polled", ++ PLATFORM_DEVID_AUTO, &gkpdata, ++ sizeof(gkpdata)); ++ if (!IS_ERR_OR_NULL(pdev)) ++ sc->btnpdev = pdev; ++ else { ++ sc->btnpdev = NULL; ++ devm_kfree(sc->dev, bt); ++ } ++} ++ ++/* remove GPIO buttons */ ++static void ath9k_deinit_buttons(struct ath_softc *sc) ++{ ++ if (!sc->gpiochip || !sc->btnpdev) ++ return; ++ ++ platform_device_unregister(sc->btnpdev); ++ ++ sc->btnpdev = NULL; ++} ++ + #else /* CONFIG_GPIOLIB */ + + static inline void ath9k_register_gpio_chip(struct ath_softc *sc) +@@ -143,6 +206,14 @@ static inline void ath9k_unregister_gpio + { + } + ++static inline void ath9k_init_buttons(struct ath_softc *sc) ++{ ++} ++ ++static inline void ath9k_deinit_buttons(struct ath_softc *sc) ++{ ++} ++ + #endif /* CONFIG_GPIOLIB */ + + /********************************/ +@@ -266,6 +337,7 @@ void ath_deinit_leds(struct ath_softc *s + { + struct ath_led *led; + ++ ath9k_deinit_buttons(sc); + while (!list_empty(&sc->leds)) { + led = list_first_entry(&sc->leds, struct ath_led, list); + #ifdef CONFIG_GPIOLIB +@@ -305,6 +377,7 @@ void ath_init_leds(struct ath_softc *sc) + } + + ath_fill_led_pin(sc); ++ ath9k_init_buttons(sc); + + if (pdata && pdata->leds && pdata->num_leds) + for (i = 0; i < pdata->num_leds; i++) { +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -49,6 +49,10 @@ struct ath9k_platform_data { + + int num_leds; + const struct gpio_led *leds; ++ ++ unsigned num_btns; ++ const struct gpio_keys_button *btns; ++ unsigned btn_poll_interval; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/550-ath9k-disable-bands-via-dt.patch b/feeds/wifi-ath10k/mac80211/patches/ath/550-ath9k-disable-bands-via-dt.patch new file mode 100644 index 000000000..7d3a334c4 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/550-ath9k-disable-bands-via-dt.patch @@ -0,0 +1,15 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -627,6 +627,12 @@ static int ath9k_of_init(struct ath_soft + + ath_dbg(common, CONFIG, "parsing configuration from OF node\n"); + ++ if (of_property_read_bool(np, "qca,disable-2ghz")) ++ ah->disable_2ghz = true; ++ ++ if (of_property_read_bool(np, "qca,disable-5ghz")) ++ ah->disable_5ghz = true; ++ + if (of_property_read_bool(np, "qca,no-eeprom")) { + /* ath9k-eeprom--.bin */ + scnprintf(eeprom_name, sizeof(eeprom_name), diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/551-ath9k_ubnt_uap_plus_hsr.patch b/feeds/wifi-ath10k/mac80211/patches/ath/551-ath9k_ubnt_uap_plus_hsr.patch new file mode 100644 index 000000000..4454baeef --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/551-ath9k_ubnt_uap_plus_hsr.patch @@ -0,0 +1,418 @@ +--- a/drivers/net/wireless/ath/ath9k/channel.c ++++ b/drivers/net/wireless/ath/ath9k/channel.c +@@ -15,6 +15,8 @@ + */ + + #include "ath9k.h" ++#include ++#include "hsr.h" + + /* Set/change channels. If the channel is really being changed, it's done + * by reseting the chip. To accomplish this we must first cleanup any pending +@@ -22,6 +24,7 @@ + */ + static int ath_set_channel(struct ath_softc *sc) + { ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + struct ieee80211_hw *hw = sc->hw; +@@ -42,6 +45,11 @@ static int ath_set_channel(struct ath_so + ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n", + chan->center_freq, chandef->width); + ++ if (pdata && pdata->ubnt_hsr) { ++ ath9k_hsr_enable(ah, chandef->width, chan->center_freq); ++ ath9k_hsr_status(ah); ++ } ++ + /* update survey stats for the old channel before switching */ + spin_lock_irqsave(&common->cc_lock, flags); + ath_update_survey_stats(sc); +--- /dev/null ++++ b/drivers/net/wireless/ath/ath9k/hsr.c +@@ -0,0 +1,247 @@ ++/* ++ * ++ * The MIT License (MIT) ++ * ++ * Copyright (c) 2015 Kirill Berezin ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ * ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "hw.h" ++#include "ath9k.h" ++ ++#define HSR_GPIO_CSN 8 ++#define HSR_GPIO_CLK 6 ++#define HSR_GPIO_DOUT 7 ++#define HSR_GPIO_DIN 5 ++ ++/* delays are in useconds */ ++#define HSR_DELAY_HALF_TICK 100 ++#define HSR_DELAY_PRE_WRITE 75 ++#define HSR_DELAY_FINAL 20000 ++#define HSR_DELAY_TRAILING 200 ++ ++void ath9k_hsr_init(struct ath_hw *ah) ++{ ++ ath9k_hw_gpio_request_in(ah, HSR_GPIO_DIN, NULL); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CSN, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CLK, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_DOUT, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1); ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, 0); ++ ++ udelay(HSR_DELAY_TRAILING); ++} ++ ++static u32 ath9k_hsr_write_byte(struct ath_hw *ah, int delay, u32 value) ++{ ++ struct ath_common *common = ath9k_hw_common(ah); ++ int i; ++ u32 rval = 0; ++ ++ udelay(delay); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ for (i = 0; i < 8; ++i) { ++ rval = rval << 1; ++ ++ /* pattern is left to right, that is 7-th bit runs first */ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, (value >> (7 - i)) & 0x1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ rval |= ath9k_hw_gpio_get(ah, HSR_GPIO_DIN); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ } ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath_dbg(common, CONFIG, "ath9k_hsr_write_byte: write byte %d return value is %d %c\n", ++ value, rval, rval > 32 ? rval : '-'); ++ ++ return rval & 0xff; ++} ++ ++static int ath9k_hsr_write_a_chain(struct ath_hw *ah, char *chain, int items) ++{ ++ int status = 0; ++ int i = 0; ++ int err; ++ ++ /* a preamble */ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ ++ /* clear HSR's reply buffer */ ++ if (status) { ++ int loop = 0; ++ ++ for (loop = 0; (loop < 42) && status; ++loop) ++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, ++ 0); ++ ++ if (loop >= 42) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_write_a_chain: can't clear an output buffer after a 42 cycles.\n"); ++ return -1; ++ } ++ } ++ ++ for (i = 0; (i < items) && (chain[i] != 0); ++i) ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, (u32)chain[i]); ++ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ mdelay(HSR_DELAY_FINAL / 1000); ++ ++ /* reply */ ++ memset(chain, 0, items); ++ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ udelay(HSR_DELAY_TRAILING); ++ ++ for (i = 0; i < (items - 1); ++i) { ++ u32 ret; ++ ++ ret = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ if (ret != 0) ++ chain[i] = (char)ret; ++ else ++ break; ++ ++ udelay(HSR_DELAY_TRAILING); ++ } ++ ++ if (i <= 1) ++ return 0; ++ ++ err = kstrtoint(chain + 1, 10, &i); ++ if (err) ++ return err; ++ ++ return i; ++} ++ ++int ath9k_hsr_disable(struct ath_hw *ah) ++{ ++ char cmd[10] = {'b', '4', '0', 0, 0, 0, 0, 0, 0, 0}; ++ int ret; ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((ret > 0) && (*cmd == 'B')) ++ return 0; ++ ++ return -1; ++} ++ ++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq) ++{ ++ char cmd[10]; ++ int ret; ++ ++ /* Bandwidth argument is 0 sometimes. Assume default 802.11bgn ++ * 20MHz on invalid values ++ */ ++ if ((bw != 5) && (bw != 10) && (bw != 20) && (bw != 40)) ++ bw = 20; ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'b'; ++ snprintf(cmd + 1, 3, "%02d", bw); ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((*cmd != 'B') || (ret != bw)) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed changing bandwidth -> set (%d,%d) reply (%d, %d)\n", ++ 'b', bw, *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'x'; ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'X') { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed 'x' command -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'm'; ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'M') { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed 'm' command -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'f'; ++ snprintf(cmd + 1, 6, "%05d", fq); ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((*cmd != 'F') && (ret != fq)) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed set frequency -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++int ath9k_hsr_status(struct ath_hw *ah) ++{ ++ char cmd[10] = {'s', 0, 0, 0, 0, 0, 0, 0, 0, 0}; ++ int ret; ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'S') { ++ ATH_DBG_WARN(1, "ath9k_hsr_status: returned %d,%d\n", *cmd, ++ ret); ++ return -1; ++ } ++ ++ return 0; ++} +--- /dev/null ++++ b/drivers/net/wireless/ath/ath9k/hsr.h +@@ -0,0 +1,48 @@ ++/* ++ * The MIT License (MIT) ++ * ++ * Copyright (c) 2015 Kirill Berezin ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ */ ++ ++#ifndef HSR_H ++#define HSR_H ++ ++#ifdef CPTCFG_ATH9K_UBNTHSR ++ ++void ath9k_hsr_init(struct ath_hw *ah); ++int ath9k_hsr_disable(struct ath_hw *ah); ++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq); ++int ath9k_hsr_status(struct ath_hw *ah); ++ ++#else ++static inline void ath9k_hsr_init(struct ath_hw *ah) {} ++ ++static inline int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq) ++{ ++ return 0; ++} ++ ++static inline int ath9k_hsr_disable(struct ath_hw *ah) { return 0; } ++static inline int ath9k_hsr_status(struct ath_hw *ah) { return 0; } ++ ++#endif ++ ++#endif /* HSR_H */ +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -16,8 +16,10 @@ + + #include + #include ++#include + #include "ath9k.h" + #include "btcoex.h" ++#include "hsr.h" + + u8 ath9k_parse_mpdudensity(u8 mpdudensity) + { +@@ -649,6 +651,7 @@ void ath_reset_work(struct work_struct * + static int ath9k_start(struct ieee80211_hw *hw) + { + struct ath_softc *sc = hw->priv; ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan; +@@ -727,6 +730,11 @@ static int ath9k_start(struct ieee80211_ + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + } + ++ if (pdata && pdata->ubnt_hsr) { ++ ath9k_hsr_init(ah); ++ ath9k_hsr_disable(ah); ++ } ++ + /* + * Reset key cache to sane defaults (all entries cleared) instead of + * semi-random values after suspend/resume. +--- a/drivers/net/wireless/ath/ath9k/Makefile ++++ b/drivers/net/wireless/ath/ath9k/Makefile +@@ -17,6 +17,7 @@ ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += d + ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o + ath9k-$(CPTCFG_ATH9K_WOW) += wow.o + ath9k-$(CPTCFG_ATH9K_HWRNG) += rng.o ++ath9k-$(CPTCFG_ATH9K_UBNTHSR) += hsr.o + + ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o + +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -53,6 +53,8 @@ struct ath9k_platform_data { + unsigned num_btns; + const struct gpio_keys_button *btns; + unsigned btn_poll_interval; ++ ++ bool ubnt_hsr; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ +--- a/local-symbols ++++ b/local-symbols +@@ -112,6 +112,7 @@ ATH9K_WOW= + ATH9K_RFKILL= + ATH9K_CHANNEL_CONTEXT= + ATH9K_PCOEM= ++ATH9K_UBNTHSR= + ATH9K_PCI_NO_EEPROM= + ATH9K_HTC= + ATH9K_HTC_DEBUGFS= +--- a/drivers/net/wireless/ath/ath9k/Kconfig ++++ b/drivers/net/wireless/ath/ath9k/Kconfig +@@ -60,6 +60,19 @@ config ATH9K_AHB + Say Y, if you have a SoC with a compatible built-in + wireless MAC. Say N if unsure. + ++config ATH9K_UBNTHSR ++ bool "Ubiquiti UniFi Outdoor Plus HSR support" ++ depends on ATH9K ++ ---help--- ++ This options enables code to control the HSR RF ++ filter in the receive path of the Ubiquiti UniFi ++ Outdoor Plus access point. ++ ++ Say Y if you want to use the access point. The ++ code will only be used if the device is detected, ++ so it does not harm other setup other than occupying ++ a bit of memory. ++ + config ATH9K_DEBUGFS + bool "Atheros ath9k debugging" + depends on ATH9K && DEBUG_FS diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/552-ahb_of.patch b/feeds/wifi-ath10k/mac80211/patches/ath/552-ahb_of.patch new file mode 100644 index 000000000..2552bbc7a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/552-ahb_of.patch @@ -0,0 +1,337 @@ +--- a/drivers/net/wireless/ath/ath9k/ahb.c ++++ b/drivers/net/wireless/ath/ath9k/ahb.c +@@ -20,7 +20,15 @@ + #include + #include + #include ++#include + #include "ath9k.h" ++#include ++ ++#ifdef CONFIG_OF ++#include ++#include ++#include ++#endif + + static const struct platform_device_id ath9k_platform_id_table[] = { + { +@@ -69,6 +77,242 @@ static const struct ath_bus_ops ath_ahb_ + .eeprom_read = ath_ahb_eeprom_read, + }; + ++#ifdef CONFIG_OF ++ ++#define QCA955X_DDR_CTL_CONFIG 0x108 ++#define QCA955X_DDR_CTL_CONFIG_ACT_WMAC BIT(23) ++ ++static int of_get_wifi_cal(struct device_node *np, struct ath9k_platform_data *pdata) ++{ ++#ifdef CONFIG_MTD ++ struct device_node *mtd_np = NULL; ++ size_t retlen; ++ int size, ret; ++ struct mtd_info *mtd; ++ const char *part; ++ const __be32 *list; ++ phandle phandle; ++ ++ list = of_get_property(np, "mtd-cal-data", &size); ++ if (!list) ++ return 0; ++ ++ if (size != (2 * sizeof(*list))) ++ return 1; ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return 1; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return 1; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), sizeof(pdata->eeprom_data), ++ &retlen, (u8*)pdata->eeprom_data); ++ put_mtd_device(mtd); ++ ++#endif ++ return 0; ++} ++ ++static int ar913x_wmac_reset(void) ++{ ++ ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); ++ mdelay(10); ++ ++ ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC); ++ mdelay(10); ++ ++ return 0; ++} ++ ++static int ar933x_wmac_reset(void) ++{ ++ int retries = 20; ++ ++ ath79_device_reset_set(AR933X_RESET_WMAC); ++ ath79_device_reset_clear(AR933X_RESET_WMAC); ++ ++ while (1) { ++ u32 bootstrap; ++ ++ bootstrap = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); ++ if ((bootstrap & AR933X_BOOTSTRAP_EEPBUSY) == 0) ++ return 0; ++ ++ if (retries-- == 0) ++ break; ++ ++ udelay(10000); ++ } ++ ++ pr_err("ar933x: WMAC reset timed out"); ++ return -ETIMEDOUT; ++} ++ ++static int qca955x_wmac_reset(void) ++{ ++ int i; ++ ++ /* Try to wait for WMAC DDR activity to stop */ ++ for (i = 0; i < 10; i++) { ++ if (!(__raw_readl(ath79_ddr_base + QCA955X_DDR_CTL_CONFIG) & ++ QCA955X_DDR_CTL_CONFIG_ACT_WMAC)) ++ break; ++ ++ udelay(10); ++ } ++ ++ ath79_device_reset_set(QCA955X_RESET_RTC); ++ udelay(10); ++ ath79_device_reset_clear(QCA955X_RESET_RTC); ++ udelay(10); ++ ++ return 0; ++} ++ ++enum { ++ AR913X_WMAC = 0, ++ AR933X_WMAC, ++ AR934X_WMAC, ++ QCA953X_WMAC, ++ QCA955X_WMAC, ++ QCA956X_WMAC, ++}; ++ ++static int ar9330_get_soc_revision(void) ++{ ++ if (ath79_soc_rev == 1) ++ return ath79_soc_rev; ++ ++ return 0; ++} ++ ++static int ath79_get_soc_revision(void) ++{ ++ return ath79_soc_rev; ++} ++ ++static const struct of_ath_ahb_data { ++ u16 dev_id; ++ u32 bootstrap_reg; ++ u32 bootstrap_ref; ++ ++ int (*soc_revision)(void); ++ int (*wmac_reset)(void); ++} of_ath_ahb_data[] = { ++ [AR913X_WMAC] = { ++ .dev_id = AR5416_AR9100_DEVID, ++ .wmac_reset = ar913x_wmac_reset, ++ ++ }, ++ [AR933X_WMAC] = { ++ .dev_id = AR9300_DEVID_AR9330, ++ .bootstrap_reg = AR933X_RESET_REG_BOOTSTRAP, ++ .bootstrap_ref = AR933X_BOOTSTRAP_REF_CLK_40, ++ .soc_revision = ar9330_get_soc_revision, ++ .wmac_reset = ar933x_wmac_reset, ++ }, ++ [AR934X_WMAC] = { ++ .dev_id = AR9300_DEVID_AR9340, ++ .bootstrap_reg = AR934X_RESET_REG_BOOTSTRAP, ++ .bootstrap_ref = AR934X_BOOTSTRAP_REF_CLK_40, ++ .soc_revision = ath79_get_soc_revision, ++ }, ++ [QCA953X_WMAC] = { ++ .dev_id = AR9300_DEVID_AR953X, ++ .bootstrap_reg = QCA953X_RESET_REG_BOOTSTRAP, ++ .bootstrap_ref = QCA953X_BOOTSTRAP_REF_CLK_40, ++ .soc_revision = ath79_get_soc_revision, ++ }, ++ [QCA955X_WMAC] = { ++ .dev_id = AR9300_DEVID_QCA955X, ++ .bootstrap_reg = QCA955X_RESET_REG_BOOTSTRAP, ++ .bootstrap_ref = QCA955X_BOOTSTRAP_REF_CLK_40, ++ .wmac_reset = qca955x_wmac_reset, ++ }, ++ [QCA956X_WMAC] = { ++ .dev_id = AR9300_DEVID_QCA956X, ++ .bootstrap_reg = QCA956X_RESET_REG_BOOTSTRAP, ++ .bootstrap_ref = QCA956X_BOOTSTRAP_REF_CLK_40, ++ .soc_revision = ath79_get_soc_revision, ++ }, ++}; ++ ++const struct of_device_id of_ath_ahb_match[] = { ++ { .compatible = "qca,ar9130-wmac", .data = &of_ath_ahb_data[AR913X_WMAC] }, ++ { .compatible = "qca,ar9330-wmac", .data = &of_ath_ahb_data[AR933X_WMAC] }, ++ { .compatible = "qca,ar9340-wmac", .data = &of_ath_ahb_data[AR934X_WMAC] }, ++ { .compatible = "qca,qca9530-wmac", .data = &of_ath_ahb_data[QCA953X_WMAC] }, ++ { .compatible = "qca,qca9550-wmac", .data = &of_ath_ahb_data[QCA955X_WMAC] }, ++ { .compatible = "qca,qca9560-wmac", .data = &of_ath_ahb_data[QCA956X_WMAC] }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, of_ath_ahb_match); ++ ++static int of_ath_ahb_probe(struct platform_device *pdev) ++{ ++ struct ath9k_platform_data *pdata; ++ const struct of_device_id *match; ++ const struct of_ath_ahb_data *data; ++ u8 led_pin; ++ ++ match = of_match_device(of_ath_ahb_match, &pdev->dev); ++ data = (const struct of_ath_ahb_data *)match->data; ++ ++ pdata = dev_get_platdata(&pdev->dev); ++ ++ if (!of_property_read_u8(pdev->dev.of_node, "qca,led-pin", &led_pin)) ++ pdata->led_pin = led_pin; ++ else ++ pdata->led_pin = -1; ++ ++ if (of_property_read_bool(pdev->dev.of_node, "qca,disable-2ghz")) ++ pdata->disable_2ghz = true; ++ ++ if (of_property_read_bool(pdev->dev.of_node, "qca,disable-5ghz")) ++ pdata->disable_5ghz = true; ++ ++ if (of_property_read_bool(pdev->dev.of_node, "qca,tx-gain-buffalo")) ++ pdata->tx_gain_buffalo = true; ++ ++ if (data->wmac_reset) { ++ data->wmac_reset(); ++ pdata->external_reset = data->wmac_reset; ++ } ++ ++ if (data->dev_id == AR9300_DEVID_AR953X) { ++ /* ++ * QCA953x only supports 25MHz refclk. ++ * Some vendors have an invalid bootstrap option ++ * set, which would break the WMAC here. ++ */ ++ pdata->is_clk_25mhz = true; ++ } else if (data->bootstrap_reg && data->bootstrap_ref) { ++ u32 t = ath79_reset_rr(data->bootstrap_reg); ++ if (t & data->bootstrap_ref) ++ pdata->is_clk_25mhz = false; ++ else ++ pdata->is_clk_25mhz = true; ++ } ++ ++ pdata->get_mac_revision = data->soc_revision; ++ ++ if (of_get_wifi_cal(pdev->dev.of_node, pdata)) ++ dev_err(&pdev->dev, "failed to load calibration data from mtd device\n"); ++ ++ return data->dev_id; ++} ++#endif ++ + static int ath_ahb_probe(struct platform_device *pdev) + { + void __iomem *mem; +@@ -80,6 +324,17 @@ static int ath_ahb_probe(struct platform + int ret = 0; + struct ath_hw *ah; + char hw_name[64]; ++ u16 dev_id; ++ ++ if (id) ++ dev_id = id->driver_data; ++ ++#ifdef CONFIG_OF ++ if (pdev->dev.of_node) ++ pdev->dev.platform_data = devm_kzalloc(&pdev->dev, ++ sizeof(struct ath9k_platform_data), ++ GFP_KERNEL); ++#endif + + if (!dev_get_platdata(&pdev->dev)) { + dev_err(&pdev->dev, "no platform data specified\n"); +@@ -122,13 +377,16 @@ static int ath_ahb_probe(struct platform + sc->mem = mem; + sc->irq = irq; + ++#ifdef CONFIG_OF ++ dev_id = of_ath_ahb_probe(pdev); ++#endif + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); + goto err_free_hw; + } + +- ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops); ++ ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops); + if (ret) { + dev_err(&pdev->dev, "failed to initialize device\n"); + goto err_irq; +@@ -159,6 +417,9 @@ static int ath_ahb_remove(struct platfor + free_irq(sc->irq, sc); + ieee80211_free_hw(sc->hw); + } ++#ifdef CONFIG_OF ++ pdev->dev.platform_data = NULL; ++#endif + + return 0; + } +@@ -168,6 +429,9 @@ static struct platform_driver ath_ahb_dr + .remove = ath_ahb_remove, + .driver = { + .name = "ath9k", ++#ifdef CONFIG_OF ++ .of_match_table = of_ath_ahb_match, ++#endif + }, + .id_table = ath9k_platform_id_table, + }; +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #include "common.h" + #include "debug.h" +@@ -1011,6 +1012,9 @@ struct ath_softc { + struct ath_hw *sc_ah; + void __iomem *mem; + int irq; ++#ifdef CONFIG_OF ++ struct reset_control *reset; ++#endif + spinlock_t sc_serial_rw; + spinlock_t sc_pm_lock; + spinlock_t sc_pcu_lock; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch b/feeds/wifi-ath10k/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch new file mode 100644 index 000000000..72b99050c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch @@ -0,0 +1,25 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -654,6 +654,12 @@ static int ath9k_of_init(struct ath_soft + return 0; + } + ++static void ath9k_of_gpio_mask(struct ath_softc *sc) ++{ ++ of_property_read_u32(sc->dev->of_node, "qca,gpio-mask", ++ &sc->sc_ah->caps.gpio_mask); ++} ++ + static int ath9k_init_softc(u16 devid, struct ath_softc *sc, + const struct ath_bus_ops *bus_ops) + { +@@ -758,6 +764,9 @@ static int ath9k_init_softc(u16 devid, s + if (ret) + goto err_hw; + ++ /* GPIO mask quirk */ ++ ath9k_of_gpio_mask(sc); ++ + ret = ath9k_init_queues(sc); + if (ret) + goto err_queues; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/921-ath10k_init_devices_synchronously.patch b/feeds/wifi-ath10k/mac80211/patches/ath/921-ath10k_init_devices_synchronously.patch new file mode 100644 index 000000000..4e59bb00e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/921-ath10k_init_devices_synchronously.patch @@ -0,0 +1,33 @@ +From: Sven Eckelmann +Date: Tue, 18 Nov 2014 12:29:28 +0100 +Subject: [PATCH] ath10k: Don't initialize devices asynchronously + +OpenWrt requires all PHYs to be initialized to create the configuration files +during bootup. ath10k violates this because it delays the creation of the PHY +to a not well defined point in the future. + +Forcing the work to be done immediately works around this problem but may also +delay the boot when firmware images cannot be found. + +Signed-off-by: Sven Eckelmann +--- + +--- a/drivers/net/wireless/ath/ath10k/core.c ++++ b/drivers/net/wireless/ath/ath10k/core.c +@@ -3172,6 +3172,16 @@ int ath10k_core_register(struct ath10k * + + queue_work(ar->workqueue, &ar->register_work); + ++ /* OpenWrt requires all PHYs to be initialized to create the ++ * configuration files during bootup. ath10k violates this ++ * because it delays the creation of the PHY to a not well defined ++ * point in the future. ++ * ++ * Forcing the work to be done immediately works around this problem ++ * but may also delay the boot when firmware images cannot be found. ++ */ ++ flush_workqueue(ar->workqueue); ++ + return 0; + } + EXPORT_SYMBOL(ath10k_core_register); diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/922-ath10k-increase-rx-buffer-size-to-2048.patch b/feeds/wifi-ath10k/mac80211/patches/ath/922-ath10k-increase-rx-buffer-size-to-2048.patch new file mode 100644 index 000000000..abce36167 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/922-ath10k-increase-rx-buffer-size-to-2048.patch @@ -0,0 +1,37 @@ +From: Linus Lüssing +Date: Wed, 5 Feb 2020 20:10:43 +0100 +Subject: ath10k: increase rx buffer size to 2048 + +Before, only frames with a maximum size of 1528 bytes could be +transmitted between two 802.11s nodes. + +For batman-adv for instance, which adds its own header to each frame, +we typically need an MTU of at least 1532 bytes to be able to transmit +without fragmentation. + +This patch now increases the maxmimum frame size from 1528 to 1656 +bytes. + +Tested with two ath10k devices in 802.11s mode, as well as with +batman-adv on top of 802.11s with forwarding disabled. + +Fix originally found and developed by Ben Greear. + +Link: https://github.com/greearb/ath10k-ct/issues/89 +Link: https://github.com/greearb/ath10k-ct/commit/9e5ab25027e0971fa24ccf93373324c08c4e992d +Cc: Ben Greear +Signed-off-by: Linus Lüssing + +Forwarded: https://patchwork.kernel.org/patch/11367055/ + +--- a/drivers/net/wireless/ath/ath10k/htt.h ++++ b/drivers/net/wireless/ath/ath10k/htt.h +@@ -2242,7 +2242,7 @@ struct htt_rx_chan_info { + * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size, + * rounded up to a cache line size. + */ +-#define HTT_RX_BUF_SIZE 1920 ++#define HTT_RX_BUF_SIZE 2048 + #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc)) + + /* Refill a bunch of RX buffers for each refill round so that FW/HW can handle diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/930-ath10k_add_tpt_led_trigger.patch b/feeds/wifi-ath10k/mac80211/patches/ath/930-ath10k_add_tpt_led_trigger.patch new file mode 100644 index 000000000..2b36a559d --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/930-ath10k_add_tpt_led_trigger.patch @@ -0,0 +1,37 @@ +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -9053,6 +9053,21 @@ static int ath10k_mac_init_rd(struct ath + return 0; + } + ++#ifdef CPTCFG_MAC80211_LEDS ++static const struct ieee80211_tpt_blink ath10k_tpt_blink[] = { ++ { .throughput = 0 * 1024, .blink_time = 334 }, ++ { .throughput = 1 * 1024, .blink_time = 260 }, ++ { .throughput = 2 * 1024, .blink_time = 220 }, ++ { .throughput = 5 * 1024, .blink_time = 190 }, ++ { .throughput = 10 * 1024, .blink_time = 170 }, ++ { .throughput = 25 * 1024, .blink_time = 150 }, ++ { .throughput = 54 * 1024, .blink_time = 130 }, ++ { .throughput = 120 * 1024, .blink_time = 110 }, ++ { .throughput = 265 * 1024, .blink_time = 80 }, ++ { .throughput = 586 * 1024, .blink_time = 50 }, ++}; ++#endif ++ + int ath10k_mac_register(struct ath10k *ar) + { + static const u32 cipher_suites[] = { +@@ -9380,6 +9395,12 @@ int ath10k_mac_register(struct ath10k *a + + ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; + ++#ifdef CPTCFG_MAC80211_LEDS ++ ieee80211_create_tpt_led_trigger(ar->hw, ++ IEEE80211_TPT_LEDTRIG_FL_RADIO, ath10k_tpt_blink, ++ ARRAY_SIZE(ath10k_tpt_blink)); ++#endif ++ + ret = ieee80211_register_hw(ar->hw); + if (ret) { + ath10k_err(ar, "failed to register ieee80211: %d\n", ret); diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch b/feeds/wifi-ath10k/mac80211/patches/ath/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch new file mode 100644 index 000000000..74a3028a8 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch @@ -0,0 +1,609 @@ +From: Sebastian Gottschall + +Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based +chipsets with on chipset connected led's using WMI Firmware API. The LED +device will get available named as "ath10k-phyX" at sysfs and can be controlled +with various triggers. adds also debugfs interface for gpio control. + +This patch is specific for OpenWRt base, as is use old backported package +with old wireless source. Support for QCA9984 is removed and a simbol +is added to local-simbol file to export the actually compile the code +with the ATH10K_LEDS simbol. + + +Signed-off-by: Sebastian Gottschall +Reviewed-by: Steve deRosier +[kvalo: major reorg and cleanup] +Signed-off-by: Kalle Valo +Signed-off-by: Ansuel Smith +--- + +v13: + +* only compile tested! + +* fix all checkpatch warnings + +* fix commit log + +* sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio) + +* unsigned -> unsigned int + +* remove GPIOLIB code, that should be added in a separate patch + +* rename gpio.c to leds.c + +* add leds.h + +* rename some functions: + + ath10k_attach_led() -> ath10k_leds_register() + ath10k_unregister_led() -> ath10k_leds_unregister() + ath10k_reset_led_pin() -> ath10k_leds_start() + +* call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering + +* call ath10k_leds_start() only from ath10k_core_start() and not from mac.c + +* rename struct ath10k_gpiocontrol as anonymous function under struct + ath10k::leds, no need for memory allocation + +* merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller + +* remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it + +* Kconfig help text improvement and move it lower in the menu, also don't enable it by default + +* switch to set_brightness_blocking() so that the callback can sleep, + then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex + to access ar->state + +* don't touch ath10k_wmi_pdev_get_temperature() + +* as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface + +* remove debugfs interface, that should be added in another patch + +* cleanup includes + + + drivers/net/wireless/ath/ath10k/Kconfig | 10 +++ + drivers/net/wireless/ath/ath10k/Makefile | 1 + + drivers/net/wireless/ath/ath10k/core.c | 22 +++++++ + drivers/net/wireless/ath/ath10k/core.h | 9 ++- + drivers/net/wireless/ath/ath10k/hw.h | 1 + + drivers/net/wireless/ath/ath10k/leds.c | 103 ++++++++++++++++++++++++++++++ + drivers/net/wireless/ath/ath10k/leds.h | 45 +++++++++++++ + drivers/net/wireless/ath/ath10k/mac.c | 1 + + drivers/net/wireless/ath/ath10k/wmi-ops.h | 32 ++++++++++ + drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 + + drivers/net/wireless/ath/ath10k/wmi.c | 54 ++++++++++++++++ + drivers/net/wireless/ath/ath10k/wmi.h | 35 ++++++++++ + 12 files changed, 314 insertions(+), 1 deletion(-) + create mode 100644 drivers/net/wireless/ath/ath10k/leds.c + create mode 100644 drivers/net/wireless/ath/ath10k/leds.h +--- a/drivers/net/wireless/ath/ath10k/Kconfig ++++ b/drivers/net/wireless/ath/ath10k/Kconfig +@@ -70,6 +70,16 @@ config ATH10K_DEBUGFS + + If unsure, say Y to make it easier to debug problems. + ++config ATH10K_LEDS ++ bool "Atheros ath10k LED support" ++ depends on ATH10K ++ select MAC80211_LEDS ++ select LEDS_CLASS ++ select NEW_LEDS ++ default y ++ ---help--- ++ This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N. ++ + config ATH10K_SPECTRAL + bool "Atheros ath10k spectral scan support" + depends on ATH10K_DEBUGFS +--- a/drivers/net/wireless/ath/ath10k/Makefile ++++ b/drivers/net/wireless/ath/ath10k/Makefile +@@ -19,6 +19,7 @@ ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) += + ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o + ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o + ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o ++ath10k_core-$(CPTCFG_ATH10K_LEDS) += leds.o + ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o + ath10k_core-$(CONFIG_PM) += wow.o + ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o +--- a/local-symbols ++++ b/local-symbols +@@ -145,6 +145,7 @@ ATH10K_DEBUG= + ATH10K_DEBUGFS= + ATH10K_SPECTRAL= + ATH10K_THERMAL= ++ATH10K_LEDS= + ATH10K_TRACING= + ATH10K_DFS_CERTIFIED= + WCN36XX= +--- a/drivers/net/wireless/ath/ath10k/core.c ++++ b/drivers/net/wireless/ath/ath10k/core.c +@@ -25,6 +25,7 @@ + #include "testmode.h" + #include "wmi-ops.h" + #include "coredump.h" ++#include "leds.h" + + unsigned int ath10k_debug_mask; + EXPORT_SYMBOL(ath10k_debug_mask); +@@ -61,6 +62,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA988X_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca988x hw2.0", ++ .led_pin = 1, + .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, +@@ -131,6 +133,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9887_1_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9887 hw1.0", ++ .led_pin = 1, + .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, +@@ -340,6 +343,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA99X0_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca99x0 hw2.0", ++ .led_pin = 17, + .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .otp_exe_param = 0x00000700, +@@ -381,6 +385,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9984_1_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9984/qca9994 hw1.0", ++ .led_pin = 17, + .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, +@@ -429,6 +434,7 @@ static const struct ath10k_hw_params ath + .dev_id = QCA9888_2_0_DEVICE_ID, + .bus = ATH10K_BUS_PCI, + .name = "qca9888 hw2.0", ++ .led_pin = 17, + .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR, + .uart_pin = 7, + .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, +@@ -2887,6 +2893,10 @@ int ath10k_core_start(struct ath10k *ar, + goto err_hif_stop; + } + ++ status = ath10k_leds_start(ar); ++ if (status) ++ goto err_hif_stop; ++ + return 0; + + err_hif_stop: +@@ -3145,9 +3155,18 @@ static void ath10k_core_register_work(st + goto err_spectral_destroy; + } + ++ status = ath10k_leds_register(ar); ++ if (status) { ++ ath10k_err(ar, "could not register leds: %d\n", ++ status); ++ goto err_thermal_unregister; ++ } ++ + set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags); + return; + ++err_thermal_unregister: ++ ath10k_thermal_unregister(ar); + err_spectral_destroy: + ath10k_spectral_destroy(ar); + err_debug_destroy: +@@ -3193,6 +3212,8 @@ void ath10k_core_unregister(struct ath10 + if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags)) + return; + ++ ath10k_leds_unregister(ar); ++ + ath10k_thermal_unregister(ar); + /* Stop spectral before unregistering from mac80211 to remove the + * relayfs debugfs file cleanly. Otherwise the parent debugfs tree +--- a/drivers/net/wireless/ath/ath10k/core.h ++++ b/drivers/net/wireless/ath/ath10k/core.h +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + #include "htt.h" + #include "htc.h" +@@ -1216,6 +1217,13 @@ struct ath10k { + } testmode; + + struct { ++ struct gpio_led wifi_led; ++ struct led_classdev cdev; ++ char label[48]; ++ u32 gpio_state_pin; ++ } leds; ++ ++ struct { + /* protected by data_lock */ + u32 rx_crc_err_drop; + u32 fw_crash_counter; +--- a/drivers/net/wireless/ath/ath10k/hw.h ++++ b/drivers/net/wireless/ath/ath10k/hw.h +@@ -517,6 +517,7 @@ struct ath10k_hw_params { + const char *name; + u32 patch_load_addr; + int uart_pin; ++ int led_pin; + u32 otp_exe_param; + + /* Type of hw cycle counter wraparound logic, for more info +--- /dev/null ++++ b/drivers/net/wireless/ath/ath10k/leds.c +@@ -0,0 +1,103 @@ ++/* ++ * Copyright (c) 2005-2011 Atheros Communications Inc. ++ * Copyright (c) 2011-2017 Qualcomm Atheros, Inc. ++ * Copyright (c) 2018 Sebastian Gottschall ++ * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++ ++#include "core.h" ++#include "wmi.h" ++#include "wmi-ops.h" ++ ++#include "leds.h" ++ ++static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev, ++ enum led_brightness brightness) ++{ ++ struct ath10k *ar = container_of(led_cdev, struct ath10k, ++ leds.cdev); ++ struct gpio_led *led = &ar->leds.wifi_led; ++ ++ mutex_lock(&ar->conf_mutex); ++ ++ if (ar->state != ATH10K_STATE_ON) ++ goto out; ++ ++ ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low; ++ ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin); ++ ++out: ++ mutex_unlock(&ar->conf_mutex); ++ ++ return 0; ++} ++ ++int ath10k_leds_start(struct ath10k *ar) ++{ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return 0; ++ ++ /* under some circumstances, the gpio pin gets reconfigured ++ * to default state by the firmware, so we need to ++ * reconfigure it this behaviour has only ben seen on ++ * QCA9984 and QCA99XX devices so far ++ */ ++ ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0, ++ WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE); ++ ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1); ++ ++ return 0; ++} ++ ++int ath10k_leds_register(struct ath10k *ar) ++{ ++ int ret; ++ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return 0; ++ ++ snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s", ++ wiphy_name(ar->hw->wiphy)); ++ ar->leds.wifi_led.active_low = 1; ++ ar->leds.wifi_led.gpio = ar->hw_params.led_pin; ++ ar->leds.wifi_led.name = ar->leds.label; ++ ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP; ++ ++ ar->leds.cdev.name = ar->leds.label; ++ ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking; ++ ++ /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */ ++ ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger; ++ ++ ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++void ath10k_leds_unregister(struct ath10k *ar) ++{ ++ if (ar->hw_params.led_pin == 0) ++ /* leds not supported */ ++ return; ++ ++ led_classdev_unregister(&ar->leds.cdev); ++} ++ +--- /dev/null ++++ b/drivers/net/wireless/ath/ath10k/leds.h +@@ -0,0 +1,41 @@ ++/* ++ * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++#ifndef _LEDS_H_ ++#define _LEDS_H_ ++ ++#include "core.h" ++ ++#ifdef CPTCFG_ATH10K_LEDS ++void ath10k_leds_unregister(struct ath10k *ar); ++int ath10k_leds_start(struct ath10k *ar); ++int ath10k_leds_register(struct ath10k *ar); ++#else ++static inline void ath10k_leds_unregister(struct ath10k *ar) ++{ ++} ++ ++static inline int ath10k_leds_start(struct ath10k *ar) ++{ ++ return 0; ++} ++ ++static inline int ath10k_leds_register(struct ath10k *ar) ++{ ++ return 0; ++} ++ ++#endif ++#endif /* _LEDS_H_ */ +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -24,6 +24,7 @@ + #include "wmi-tlv.h" + #include "wmi-ops.h" + #include "wow.h" ++#include "leds.h" + + /*********/ + /* Rates */ +--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h ++++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h +@@ -224,7 +224,10 @@ struct wmi_ops { + struct sk_buff *(*gen_bb_timing) + (struct ath10k *ar, + const struct wmi_bb_timing_cfg_arg *arg); ++ struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num, ++ u32 input, u32 pull_type, u32 intr_mode); + ++ struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set); + }; + + int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id); +@@ -1120,6 +1123,35 @@ ath10k_wmi_force_fw_hang(struct ath10k * + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); + } + ++static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num, ++ u32 input, u32 pull_type, u32 intr_mode) ++{ ++ struct sk_buff *skb; ++ ++ if (!ar->wmi.ops->gen_gpio_config) ++ return -EOPNOTSUPP; ++ ++ skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode); ++ if (IS_ERR(skb)) ++ return PTR_ERR(skb); ++ ++ return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid); ++} ++ ++static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set) ++{ ++ struct sk_buff *skb; ++ ++ if (!ar->wmi.ops->gen_gpio_config) ++ return -EOPNOTSUPP; ++ ++ skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set); ++ if (IS_ERR(skb)) ++ return PTR_ERR(skb); ++ ++ return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid); ++} ++ + static inline int + ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level) + { +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c +@@ -4583,6 +4583,8 @@ static const struct wmi_ops wmi_tlv_ops + .gen_echo = ath10k_wmi_tlv_op_gen_echo, + .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf, + .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable, ++ /* .gen_gpio_config not implemented */ ++ /* .gen_gpio_output not implemented */ + }; + + static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = { +--- a/drivers/net/wireless/ath/ath10k/wmi.c ++++ b/drivers/net/wireless/ath/ath10k/wmi.c +@@ -7471,6 +7471,49 @@ ath10k_wmi_op_gen_peer_set_param(struct + return skb; + } + ++static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar, ++ u32 gpio_num, u32 input, ++ u32 pull_type, u32 intr_mode) ++{ ++ struct wmi_gpio_config_cmd *cmd; ++ struct sk_buff *skb; ++ ++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); ++ if (!skb) ++ return ERR_PTR(-ENOMEM); ++ ++ cmd = (struct wmi_gpio_config_cmd *)skb->data; ++ cmd->pull_type = __cpu_to_le32(pull_type); ++ cmd->gpio_num = __cpu_to_le32(gpio_num); ++ cmd->input = __cpu_to_le32(input); ++ cmd->intr_mode = __cpu_to_le32(intr_mode); ++ ++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_config gpio_num 0x%08x input 0x%08x pull_type 0x%08x intr_mode 0x%08x\n", ++ gpio_num, input, pull_type, intr_mode); ++ ++ return skb; ++} ++ ++static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar, ++ u32 gpio_num, u32 set) ++{ ++ struct wmi_gpio_output_cmd *cmd; ++ struct sk_buff *skb; ++ ++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); ++ if (!skb) ++ return ERR_PTR(-ENOMEM); ++ ++ cmd = (struct wmi_gpio_output_cmd *)skb->data; ++ cmd->gpio_num = __cpu_to_le32(gpio_num); ++ cmd->set = __cpu_to_le32(set); ++ ++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n", ++ gpio_num, set); ++ ++ return skb; ++} ++ + static struct sk_buff * + ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id, + enum wmi_sta_ps_mode psmode) +@@ -9129,6 +9172,9 @@ static const struct wmi_ops wmi_ops = { + .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, + .gen_echo = ath10k_wmi_op_gen_echo, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, ++ + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -9199,6 +9245,8 @@ static const struct wmi_ops wmi_10_1_ops + .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, + .gen_echo = ath10k_wmi_op_gen_echo, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -9271,6 +9319,8 @@ static const struct wmi_ops wmi_10_2_ops + .gen_delba_send = ath10k_wmi_op_gen_delba_send, + .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill, + .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_pdev_enable_adaptive_cca not implemented */ + }; + +@@ -9342,6 +9392,8 @@ static const struct wmi_ops wmi_10_2_4_o + ath10k_wmi_op_gen_pdev_enable_adaptive_cca, + .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype, + .gen_bb_timing = ath10k_wmi_10_2_4_op_gen_bb_timing, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + /* .gen_bcn_tmpl not implemented */ + /* .gen_prb_tmpl not implemented */ + /* .gen_p2p_go_bcn_ie not implemented */ +@@ -9422,6 +9474,8 @@ static const struct wmi_ops wmi_10_4_ops + .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info, + .gen_echo = ath10k_wmi_op_gen_echo, + .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config, ++ .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, ++ .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + }; + + int ath10k_wmi_attach(struct ath10k *ar) +--- a/drivers/net/wireless/ath/ath10k/wmi.h ++++ b/drivers/net/wireless/ath/ath10k/wmi.h +@@ -3016,6 +3016,41 @@ enum wmi_10_4_feature_mask { + + }; + ++/* WMI_GPIO_CONFIG_CMDID */ ++enum { ++ WMI_GPIO_PULL_NONE, ++ WMI_GPIO_PULL_UP, ++ WMI_GPIO_PULL_DOWN, ++}; ++ ++enum { ++ WMI_GPIO_INTTYPE_DISABLE, ++ WMI_GPIO_INTTYPE_RISING_EDGE, ++ WMI_GPIO_INTTYPE_FALLING_EDGE, ++ WMI_GPIO_INTTYPE_BOTH_EDGE, ++ WMI_GPIO_INTTYPE_LEVEL_LOW, ++ WMI_GPIO_INTTYPE_LEVEL_HIGH ++}; ++ ++/* WMI_GPIO_CONFIG_CMDID */ ++struct wmi_gpio_config_cmd { ++ __le32 gpio_num; /* GPIO number to be setup */ ++ __le32 input; /* 0 - Output/ 1 - Input */ ++ __le32 pull_type; /* Pull type defined above */ ++ __le32 intr_mode; /* Interrupt mode defined above (Input) */ ++} __packed; ++ ++/* WMI_GPIO_OUTPUT_CMDID */ ++struct wmi_gpio_output_cmd { ++ __le32 gpio_num; /* GPIO number to be setup */ ++ __le32 set; /* Set the GPIO pin*/ ++} __packed; ++ ++/* WMI_GPIO_INPUT_EVENTID */ ++struct wmi_gpio_input_event { ++ __le32 gpio_num; /* GPIO number which changed state */ ++} __packed; ++ + struct wmi_ext_resource_config_10_4_cmd { + /* contains enum wmi_host_platform_type */ + __le32 host_platform_config; diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/975-ath10k-use-tpt-trigger-by-default.patch b/feeds/wifi-ath10k/mac80211/patches/ath/975-ath10k-use-tpt-trigger-by-default.patch new file mode 100644 index 000000000..db9a88e00 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/975-ath10k-use-tpt-trigger-by-default.patch @@ -0,0 +1,53 @@ +From 79c9d7aabae1d1da9eea97d83b61e1517a8a2221 Mon Sep 17 00:00:00 2001 +From: Mathias Kresin +Date: Fri, 22 Jun 2018 18:59:44 +0200 +Subject: [PATCH] ath10k: use tpt LED trigger by default + +Use the tpt LED trigger for each created phy led. Ths way LEDs attached +to the ath10k GPIO pins are indicating the phy status and blink on +traffic. + +Signed-off-by: Mathias Kresin +--- + drivers/net/wireless/ath/ath10k/core.h | 4 ++++ + drivers/net/wireless/ath/ath10k/leds.c | 4 +--- + drivers/net/wireless/ath/ath10k/mac.c | 2 +- + 3 files changed, 6 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath10k/core.h ++++ b/drivers/net/wireless/ath/ath10k/core.h +@@ -1269,6 +1269,10 @@ struct ath10k { + bool coex_support; + int coex_gpio_pin; + ++#ifdef CPTCFG_MAC80211_LEDS ++ const char *led_default_trigger; ++#endif ++ + /* must be last */ + u8 drv_priv[] __aligned(sizeof(void *)); + }; +--- a/drivers/net/wireless/ath/ath10k/leds.c ++++ b/drivers/net/wireless/ath/ath10k/leds.c +@@ -81,9 +81,7 @@ int ath10k_leds_register(struct ath10k * + + ar->leds.cdev.name = ar->leds.label; + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking; +- +- /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */ +- ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger; ++ ar->leds.cdev.default_trigger = ar->led_default_trigger; + + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev); + if (ret) +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -9397,7 +9397,7 @@ int ath10k_mac_register(struct ath10k *a + ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; + + #ifdef CPTCFG_MAC80211_LEDS +- ieee80211_create_tpt_led_trigger(ar->hw, ++ ar->led_default_trigger = ieee80211_create_tpt_led_trigger(ar->hw, + IEEE80211_TPT_LEDTRIG_FL_RADIO, ath10k_tpt_blink, + ARRAY_SIZE(ath10k_tpt_blink)); + #endif diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/980-ath10k-fix-max-antenna-gain-unit.patch b/feeds/wifi-ath10k/mac80211/patches/ath/980-ath10k-fix-max-antenna-gain-unit.patch new file mode 100644 index 000000000..9498e0246 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/980-ath10k-fix-max-antenna-gain-unit.patch @@ -0,0 +1,49 @@ +From: Sven Eckelmann +Date: Tue, 11 Jun 2019 13:58:35 +0200 +Subject: ath10k: fix max antenna gain unit + +Most of the txpower for the ath10k firmware is stored as twicepower (0.5 dB +steps). This isn't the case for max_antenna_gain - which is still expected +by the firmware as dB. + +The firmware is converting it from dB to the internal (twicepower) +representation when it calculates the limits of a channel. This can be seen +in tpc_stats when configuring "12" as max_antenna_gain. Instead of the +expected 12 (6 dB), the tpc_stats shows 24 (12 dB). + +Tested on QCA9888 and IPQ4019 with firmware 10.4-3.5.3-00057. + +Fixes: 02256930d9b8 ("ath10k: use proper tx power unit") +Signed-off-by: Sven Eckelmann + +Forwarded: https://patchwork.kernel.org/patch/10986723/ + +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -1043,7 +1043,7 @@ static int ath10k_monitor_vdev_start(str + arg.channel.min_power = 0; + arg.channel.max_power = channel->max_power * 2; + arg.channel.max_reg_power = channel->max_reg_power * 2; +- arg.channel.max_antenna_gain = channel->max_antenna_gain * 2; ++ arg.channel.max_antenna_gain = channel->max_antenna_gain; + + reinit_completion(&ar->vdev_setup_done); + reinit_completion(&ar->vdev_delete_done); +@@ -1489,7 +1489,7 @@ static int ath10k_vdev_start_restart(str + arg.channel.min_power = 0; + arg.channel.max_power = chandef->chan->max_power * 2; + arg.channel.max_reg_power = chandef->chan->max_reg_power * 2; +- arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2; ++ arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain; + + if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { + arg.ssid = arvif->u.ap.ssid; +@@ -3194,7 +3194,7 @@ static int ath10k_update_channel_list(st + ch->min_power = 0; + ch->max_power = channel->max_power * 2; + ch->max_reg_power = channel->max_reg_power * 2; +- ch->max_antenna_gain = channel->max_antenna_gain * 2; ++ ch->max_antenna_gain = channel->max_antenna_gain; + ch->reg_class_id = 0; /* FIXME */ + + /* FIXME: why use only legacy modes, why not any diff --git a/feeds/wifi-ath10k/mac80211/patches/ath/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch b/feeds/wifi-ath10k/mac80211/patches/ath/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch new file mode 100644 index 000000000..fbb6fad66 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/ath/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch @@ -0,0 +1,101 @@ +From: Sven Eckelmann +Date: Wed, 28 Nov 2018 16:16:27 +0100 +Subject: ath10k: adjust tx power reduction for US regulatory domain + +FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4): + +> (4) The conducted output power limit +> specified in paragraph (b) of this section +> is based on the use of antennas +> with directional gains that do not exceed +> 6 dBi. Except as shown in paragraph +> (c) of this section, if transmitting +> antennas of directional gain greater +> than 6 dBi are used, the conducted +> output power from the intentional radiator +> shall be reduced below the stated +> values in paragraphs (b)(1), (b)(2), +> and (b)(3) of this section, as appropriate, +> by the amount in dB that the +> directional gain of the antenna exceeds +> 6 dBi. + +https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf + +Signed-off-by: Sven Eckelmann + +Forwarded: no + +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -1011,6 +1011,40 @@ static inline int ath10k_vdev_setup_sync + return ar->last_wmi_vdev_start_status; + } + ++static u32 ath10k_get_max_antenna_gain(struct ath10k *ar, ++ u32 ch_max_antenna_gain) ++{ ++ u32 max_antenna_gain; ++ ++ if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) { ++ /* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4): ++ * ++ * > (4) The conducted output power limit ++ * > specified in paragraph (b) of this section ++ * > is based on the use of antennas ++ * > with directional gains that do not exceed ++ * > 6 dBi. Except as shown in paragraph ++ * > (c) of this section, if transmitting ++ * > antennas of directional gain greater ++ * > than 6 dBi are used, the conducted ++ * > output power from the intentional radiator ++ * > shall be reduced below the stated ++ * > values in paragraphs (b)(1), (b)(2), ++ * > and (b)(3) of this section, as appropriate, ++ * > by the amount in dB that the ++ * > directional gain of the antenna exceeds ++ * > 6 dBi. ++ * ++ * https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf ++ */ ++ max_antenna_gain = 6; ++ } else { ++ max_antenna_gain = 0; ++ } ++ ++ return max(ch_max_antenna_gain, max_antenna_gain); ++} ++ + static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id) + { + struct cfg80211_chan_def *chandef = NULL; +@@ -1043,7 +1077,8 @@ static int ath10k_monitor_vdev_start(str + arg.channel.min_power = 0; + arg.channel.max_power = channel->max_power * 2; + arg.channel.max_reg_power = channel->max_reg_power * 2; +- arg.channel.max_antenna_gain = channel->max_antenna_gain; ++ arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar, ++ channel->max_antenna_gain); + + reinit_completion(&ar->vdev_setup_done); + reinit_completion(&ar->vdev_delete_done); +@@ -1489,7 +1524,8 @@ static int ath10k_vdev_start_restart(str + arg.channel.min_power = 0; + arg.channel.max_power = chandef->chan->max_power * 2; + arg.channel.max_reg_power = chandef->chan->max_reg_power * 2; +- arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain; ++ arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar, ++ chandef->chan->max_antenna_gain); + + if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { + arg.ssid = arvif->u.ap.ssid; +@@ -3194,7 +3230,8 @@ static int ath10k_update_channel_list(st + ch->min_power = 0; + ch->max_power = channel->max_power * 2; + ch->max_reg_power = channel->max_reg_power * 2; +- ch->max_antenna_gain = channel->max_antenna_gain; ++ ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar, ++ channel->max_antenna_gain); + ch->reg_class_id = 0; /* FIXME */ + + /* FIXME: why use only legacy modes, why not any diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/040-brcmutil_option.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/040-brcmutil_option.patch new file mode 100644 index 000000000..3e8505b5b --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/040-brcmutil_option.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/wireless/broadcom/brcm80211/Kconfig ++++ b/drivers/net/wireless/broadcom/brcm80211/Kconfig +@@ -1,6 +1,6 @@ + # SPDX-License-Identifier: GPL-2.0-only + config BRCMUTIL +- tristate ++ tristate "Broadcom 802.11 driver utility functions" + depends on m + + config BRCMSMAC diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/810-b43-gpio-mask-module-option.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/810-b43-gpio-mask-module-option.patch new file mode 100644 index 000000000..b3f30943a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/810-b43-gpio-mask-module-option.patch @@ -0,0 +1,37 @@ +--- a/drivers/net/wireless/broadcom/b43/b43.h ++++ b/drivers/net/wireless/broadcom/b43/b43.h +@@ -840,6 +840,7 @@ struct b43_wldev { + bool qos_enabled; /* TRUE, if QoS is used. */ + bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */ + bool use_pio; /* TRUE if next init should use PIO */ ++ int gpiomask; /* GPIO LED mask as a module parameter */ + + /* PHY/Radio device. */ + struct b43_phy phy; +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -72,6 +72,11 @@ MODULE_FIRMWARE("b43/ucode40.fw"); + MODULE_FIRMWARE("b43/ucode42.fw"); + MODULE_FIRMWARE("b43/ucode9.fw"); + ++static int modparam_gpiomask = 0x000F; ++module_param_named(gpiomask, modparam_gpiomask, int, 0444); ++MODULE_PARM_DESC(gpiomask, ++ "GPIO mask for LED control (default 0x000F)"); ++ + static int modparam_bad_frames_preempt; + module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444); + MODULE_PARM_DESC(bad_frames_preempt, +@@ -2867,10 +2872,10 @@ static int b43_gpio_init(struct b43_wlde + u32 mask, set; + + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0); +- b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF); ++ b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, modparam_gpiomask); + + mask = 0x0000001F; +- set = 0x0000000F; ++ set = modparam_gpiomask; + if (dev->dev->chip_id == 0x4301) { + mask |= 0x0060; + set |= 0x0060; diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/811-b43_no_pio.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/811-b43_no_pio.patch new file mode 100644 index 000000000..a8dbefb5d --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/811-b43_no_pio.patch @@ -0,0 +1,86 @@ +--- a/drivers/net/wireless/broadcom/b43/Makefile ++++ b/drivers/net/wireless/broadcom/b43/Makefile +@@ -18,7 +18,7 @@ b43-$(CPTCFG_B43_PHY_AC) += phy_ac.o + b43-y += sysfs.o + b43-y += xmit.o + b43-y += dma.o +-b43-y += pio.o ++b43-$(CPTCFG_B43_PIO) += pio.o + b43-y += rfkill.o + b43-y += ppr.o + b43-$(CPTCFG_B43_LEDS) += leds.o +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -2000,10 +2000,12 @@ static void b43_do_interrupt_thread(stru + dma_reason[0], dma_reason[1], + dma_reason[2], dma_reason[3], + dma_reason[4], dma_reason[5]); ++#ifdef CPTCFG_B43_PIO + b43err(dev->wl, "This device does not support DMA " + "on your system. It will now be switched to PIO.\n"); + /* Fall back to PIO transfers if we get fatal DMA errors! */ + dev->use_pio = true; ++#endif + b43_controller_restart(dev, "DMA error"); + return; + } +--- a/drivers/net/wireless/broadcom/b43/pio.h ++++ b/drivers/net/wireless/broadcom/b43/pio.h +@@ -151,7 +151,7 @@ static inline void b43_piorx_write32(str + b43_write32(q->dev, q->mmio_base + offset, value); + } + +- ++#ifdef CPTCFG_B43_PIO + int b43_pio_init(struct b43_wldev *dev); + void b43_pio_free(struct b43_wldev *dev); + +@@ -162,5 +162,37 @@ void b43_pio_rx(struct b43_pio_rxqueue * + + void b43_pio_tx_suspend(struct b43_wldev *dev); + void b43_pio_tx_resume(struct b43_wldev *dev); ++#else ++static inline int b43_pio_init(struct b43_wldev *dev) ++{ ++ return 0; ++} ++ ++static inline void b43_pio_free(struct b43_wldev *dev) ++{ ++} ++ ++static inline int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb) ++{ ++ return 0; ++} ++ ++static inline void b43_pio_handle_txstatus(struct b43_wldev *dev, ++ const struct b43_txstatus *status) ++{ ++} ++ ++static inline void b43_pio_rx(struct b43_pio_rxqueue *q) ++{ ++} ++ ++static inline void b43_pio_tx_suspend(struct b43_wldev *dev) ++{ ++} ++ ++static inline void b43_pio_tx_resume(struct b43_wldev *dev) ++{ ++} ++#endif /* CPTCFG_B43_PIO */ + + #endif /* B43_PIO_H_ */ +--- a/drivers/net/wireless/broadcom/b43/Kconfig ++++ b/drivers/net/wireless/broadcom/b43/Kconfig +@@ -100,7 +100,7 @@ config B43_BCMA_PIO + default y + + config B43_PIO +- bool ++ bool "Broadcom 43xx PIO support" + depends on B43 && B43_SSB + depends on SSB_BLOCKIO + default y diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/812-b43-add-antenna-control.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/812-b43-add-antenna-control.patch new file mode 100644 index 000000000..cd7b7583c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/812-b43-add-antenna-control.patch @@ -0,0 +1,131 @@ +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -1642,7 +1642,7 @@ static void b43_write_beacon_template(st + len, ram_offset, shm_size_offset, rate); + + /* Write the PHY TX control parameters. */ +- antenna = B43_ANTENNA_DEFAULT; ++ antenna = dev->tx_antenna; + antenna = b43_antenna_to_phyctl(antenna); + ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL); + /* We can't send beacons with short preamble. Would get PHY errors. */ +@@ -3282,8 +3282,8 @@ static int b43_chip_init(struct b43_wlde + + /* Select the antennae */ + if (phy->ops->set_rx_antenna) +- phy->ops->set_rx_antenna(dev, B43_ANTENNA_DEFAULT); +- b43_mgmtframe_txantenna(dev, B43_ANTENNA_DEFAULT); ++ phy->ops->set_rx_antenna(dev, dev->rx_antenna); ++ b43_mgmtframe_txantenna(dev, dev->tx_antenna); + + if (phy->type == B43_PHYTYPE_B) { + value16 = b43_read16(dev, 0x005E); +@@ -3983,7 +3983,6 @@ static int b43_op_config(struct ieee8021 + struct b43_wldev *dev = wl->current_dev; + struct b43_phy *phy = &dev->phy; + struct ieee80211_conf *conf = &hw->conf; +- int antenna; + int err = 0; + + mutex_lock(&wl->mutex); +@@ -4026,11 +4025,9 @@ static int b43_op_config(struct ieee8021 + } + + /* Antennas for RX and management frame TX. */ +- antenna = B43_ANTENNA_DEFAULT; +- b43_mgmtframe_txantenna(dev, antenna); +- antenna = B43_ANTENNA_DEFAULT; ++ b43_mgmtframe_txantenna(dev, dev->tx_antenna); + if (phy->ops->set_rx_antenna) +- phy->ops->set_rx_antenna(dev, antenna); ++ phy->ops->set_rx_antenna(dev, dev->rx_antenna); + + if (wl->radio_enabled != phy->radio_on) { + if (wl->radio_enabled) { +@@ -5174,6 +5171,47 @@ static int b43_op_get_survey(struct ieee + return 0; + } + ++static int b43_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) ++{ ++ struct b43_wl *wl = hw_to_b43_wl(hw); ++ struct b43_wldev *dev = wl->current_dev; ++ ++ if (tx_ant == 1 && rx_ant == 1) { ++ dev->tx_antenna = B43_ANTENNA0; ++ dev->rx_antenna = B43_ANTENNA0; ++ } ++ else if (tx_ant == 2 && rx_ant == 2) { ++ dev->tx_antenna = B43_ANTENNA1; ++ dev->rx_antenna = B43_ANTENNA1; ++ } ++ else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) { ++ dev->tx_antenna = B43_ANTENNA_DEFAULT; ++ dev->rx_antenna = B43_ANTENNA_DEFAULT; ++ } ++ else { ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++ ++static int b43_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) ++{ ++ struct b43_wl *wl = hw_to_b43_wl(hw); ++ struct b43_wldev *dev = wl->current_dev; ++ ++ switch (dev->tx_antenna) { ++ case B43_ANTENNA0: ++ *tx_ant = 1; *rx_ant = 1; break; ++ case B43_ANTENNA1: ++ *tx_ant = 2; *rx_ant = 2; break; ++ case B43_ANTENNA_DEFAULT: ++ *tx_ant = 3; *rx_ant = 3; break; ++ } ++ return 0; ++} ++ + static const struct ieee80211_ops b43_hw_ops = { + .tx = b43_op_tx, + .conf_tx = b43_op_conf_tx, +@@ -5195,6 +5233,8 @@ static const struct ieee80211_ops b43_hw + .sw_scan_complete = b43_op_sw_scan_complete_notifier, + .get_survey = b43_op_get_survey, + .rfkill_poll = b43_rfkill_poll, ++ .set_antenna = b43_op_set_antenna, ++ .get_antenna = b43_op_get_antenna, + }; + + /* Hard-reset the chip. Do not call this directly. +@@ -5496,6 +5536,8 @@ static int b43_one_core_attach(struct b4 + if (!wldev) + goto out; + ++ wldev->rx_antenna = B43_ANTENNA_DEFAULT; ++ wldev->tx_antenna = B43_ANTENNA_DEFAULT; + wldev->use_pio = b43_modparam_pio; + wldev->dev = dev; + wldev->wl = wl; +@@ -5590,6 +5632,9 @@ static struct b43_wl *b43_wireless_init( + + wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); + ++ hw->wiphy->available_antennas_rx = 0x3; ++ hw->wiphy->available_antennas_tx = 0x3; ++ + wl->hw_registered = false; + hw->max_rates = 2; + SET_IEEE80211_DEV(hw, dev->dev); +--- a/drivers/net/wireless/broadcom/b43/b43.h ++++ b/drivers/net/wireless/broadcom/b43/b43.h +@@ -841,6 +841,8 @@ struct b43_wldev { + bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */ + bool use_pio; /* TRUE if next init should use PIO */ + int gpiomask; /* GPIO LED mask as a module parameter */ ++ int rx_antenna; /* Used RX antenna (B43_ANTENNAxxx) */ ++ int tx_antenna; /* Used TX antenna (B43_ANTENNAxxx) */ + + /* PHY/Radio device. */ + struct b43_phy phy; diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/813-b43-reduce-number-of-RX-slots.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/813-b43-reduce-number-of-RX-slots.patch new file mode 100644 index 000000000..85c52c028 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/813-b43-reduce-number-of-RX-slots.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/broadcom/b43/dma.h ++++ b/drivers/net/wireless/broadcom/b43/dma.h +@@ -170,7 +170,7 @@ struct b43_dmadesc_generic { + + /* DMA engine tuning knobs */ + #define B43_TXRING_SLOTS 256 +-#define B43_RXRING_SLOTS 256 ++#define B43_RXRING_SLOTS 32 + #define B43_DMA0_RX_FW598_BUFSIZE (B43_DMA0_RX_FW598_FO + IEEE80211_MAX_FRAME_LEN) + #define B43_DMA0_RX_FW351_BUFSIZE (B43_DMA0_RX_FW351_FO + IEEE80211_MAX_FRAME_LEN) + diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/814-b43-only-use-gpio-0-1-for-led.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/814-b43-only-use-gpio-0-1-for-led.patch new file mode 100644 index 000000000..2aa761287 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/814-b43-only-use-gpio-0-1-for-led.patch @@ -0,0 +1,17 @@ +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -2884,6 +2884,14 @@ static int b43_gpio_init(struct b43_wlde + } else if (dev->dev->chip_id == 0x5354) { + /* Don't allow overtaking buttons GPIOs */ + set &= 0x2; /* 0x2 is LED GPIO on BCM5354 */ ++ } else if (dev->dev->chip_id == BCMA_CHIP_ID_BCM4716 || ++ dev->dev->chip_id == BCMA_CHIP_ID_BCM47162 || ++ dev->dev->chip_id == BCMA_CHIP_ID_BCM5356 || ++ dev->dev->chip_id == BCMA_CHIP_ID_BCM5357 || ++ dev->dev->chip_id == BCMA_CHIP_ID_BCM53572) { ++ /* just use gpio 0 and 1 for 2.4 GHz wifi led */ ++ set &= 0x3; ++ mask &= 0x3; + } + + if (0 /* FIXME: conditional unknown */ ) { diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch new file mode 100644 index 000000000..a8eae1941 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -114,7 +114,7 @@ static int b43_modparam_pio = 0; + module_param_named(pio, b43_modparam_pio, int, 0644); + MODULE_PARM_DESC(pio, "Use PIO accesses by default: 0=DMA, 1=PIO"); + +-static int modparam_allhwsupport = !IS_ENABLED(CPTCFG_BRCMSMAC); ++static int modparam_allhwsupport = 1; + module_param_named(allhwsupport, modparam_allhwsupport, int, 0444); + MODULE_PARM_DESC(allhwsupport, "Enable support for all hardware (even it if overlaps with the brcmsmac driver)"); + diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/850-brcmsmac-remove-extra-regulation-restriction.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/850-brcmsmac-remove-extra-regulation-restriction.patch new file mode 100644 index 000000000..3c93386b3 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/850-brcmsmac-remove-extra-regulation-restriction.patch @@ -0,0 +1,27 @@ +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c +@@ -58,19 +58,12 @@ + (((c) < 149) ? 3 : 4)))) + + #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0) +-#define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \ +- NL80211_RRF_NO_IR) ++#define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, 0) + +-#define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \ +- NL80211_RRF_NO_IR) +-#define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \ +- NL80211_RRF_DFS | \ +- NL80211_RRF_NO_IR) +-#define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \ +- NL80211_RRF_DFS | \ +- NL80211_RRF_NO_IR) +-#define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \ +- NL80211_RRF_NO_IR) ++#define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, 0) ++#define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, 0) ++#define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, 0) ++#define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, 0) + + static const struct ieee80211_regdomain brcms_regdom_x2 = { + .n_reg_rules = 6, diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch new file mode 100644 index 000000000..1b965087d --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch @@ -0,0 +1,74 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Mon, 8 Jun 2015 16:11:40 +0200 +Subject: [PATCH] brcmfmac: register wiphy(s) during module_init +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is needed by OpenWrt which expects all PHYs to be created after +module loads successfully. + +Signed-off-by: Rafał Miłecki +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +@@ -1551,6 +1551,7 @@ int __init brcmf_core_init(void) + { + if (!schedule_work(&brcmf_driver_work)) + return -EBUSY; ++ flush_work(&brcmf_driver_work); + + return 0; + } +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -431,6 +431,7 @@ struct brcmf_fw { + struct brcmf_fw_request *req; + u32 curpos; + void (*done)(struct device *dev, int err, struct brcmf_fw_request *req); ++ struct completion *completion; + }; + + static void brcmf_fw_request_done(const struct firmware *fw, void *ctx); +@@ -638,6 +639,8 @@ static void brcmf_fw_request_done(const + fwctx->req = NULL; + } + fwctx->done(fwctx->dev, ret, fwctx->req); ++ if (fwctx->completion) ++ complete(fwctx->completion); + kfree(fwctx); + } + +@@ -662,6 +665,8 @@ int brcmf_fw_get_firmwares(struct device + { + struct brcmf_fw_item *first = &req->items[0]; + struct brcmf_fw *fwctx; ++ struct completion completion; ++ unsigned long time_left; + int ret; + + brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev)); +@@ -678,6 +683,9 @@ int brcmf_fw_get_firmwares(struct device + fwctx->dev = dev; + fwctx->req = req; + fwctx->done = fw_cb; ++ ++ init_completion(&completion); ++ fwctx->completion = &completion; + + ret = request_firmware_nowait(THIS_MODULE, true, first->path, + fwctx->dev, GFP_KERNEL, fwctx, +@@ -685,6 +693,12 @@ int brcmf_fw_get_firmwares(struct device + if (ret < 0) + brcmf_fw_request_done(NULL, fwctx); + ++ ++ time_left = wait_for_completion_timeout(&completion, ++ msecs_to_jiffies(5000)); ++ if (!time_left && fwctx) ++ fwctx->completion = NULL; ++ + return 0; + } + diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch new file mode 100644 index 000000000..069aab824 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch @@ -0,0 +1,49 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Thu, 9 Jul 2015 00:07:59 +0200 +Subject: [PATCH] brcmfmac: workaround bug with some inconsistent BSSes state +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Rafał Miłecki +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +@@ -712,8 +712,36 @@ static struct wireless_dev *brcmf_cfg802 + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); + struct brcmf_pub *drvr = cfg->pub; + struct wireless_dev *wdev; ++ struct net_device *dev; + int err; + ++ /* ++ * There is a bug with in-firmware BSS management. When adding virtual ++ * interface brcmfmac first tells firmware to create new BSS and then ++ * it creates new struct net_device. ++ * ++ * If creating/registering netdev(ice) fails, BSS remains in some bugged ++ * state. It conflicts with existing BSSes by overtaking their auth ++ * requests. ++ * ++ * It results in one BSS (addresss X) sending beacons and another BSS ++ * (address Y) replying to authentication requests. This makes interface ++ * unusable as AP. ++ * ++ * To workaround this bug we may try to guess if register_netdev(ice) ++ * will fail. The most obvious case is using interface name that already ++ * exists. This is actually quite likely with brcmfmac & some user space ++ * scripts as brcmfmac doesn't allow deleting virtual interfaces. ++ * So this bug can be triggered even by something trivial like: ++ * iw dev wlan0 delete ++ * iw phy phy0 interface add wlan0 type __ap ++ */ ++ dev = dev_get_by_name(&init_net, name); ++ if (dev) { ++ dev_put(dev); ++ return ERR_PTR(-ENFILE); ++ } ++ + brcmf_dbg(TRACE, "enter: %s type %d\n", name, type); + err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type); + if (err) { diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch new file mode 100644 index 000000000..8a20ae133 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch @@ -0,0 +1,27 @@ +From 66ae1b1750720a33e29792a177b1e696f4f005fb Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Wed, 9 Mar 2016 17:25:59 +0000 +Subject: [PATCH] brcmfmac: Disable power management + +Disable wireless power saving in the brcmfmac WLAN driver. This is a +temporary measure until the connectivity loss resulting from power +saving is resolved. + +Signed-off-by: Phil Elwell +--- + drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +@@ -2953,6 +2953,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip + * preference in cfg struct to apply this to + * FW later while initializing the dongle + */ ++#if defined(CONFIG_ARCH_BCM2835) ++ brcmf_dbg(INFO, "power management disabled\n"); ++ enabled = false; ++#endif + cfg->pwr_save = enabled; + if (!check_vif_up(ifp->vif)) { + diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch new file mode 100644 index 000000000..2613171a8 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch @@ -0,0 +1,60 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Subject: [PATCH] brcmfmac: add in-driver tables with country codes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This adds early support for changing region. Ideally this data should +be stored in DT as all these mappings are devices specific. + +Signed-off-by: Rafał Miłecki +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +@@ -12,6 +12,36 @@ + #include "common.h" + #include "of.h" + ++/* TODO: FIXME: Use DT */ ++static void brcmf_of_probe_cc(struct device *dev, ++ struct brcmf_mp_device *settings) ++{ ++ static struct brcmfmac_pd_cc_entry netgear_r8000_cc_ent[] = { ++ { "JP", "JP", 78 }, ++ { "US", "Q2", 86 }, ++ }; ++ struct brcmfmac_pd_cc_entry *cc_ent = NULL; ++ int table_size = 0; ++ ++ if (of_machine_is_compatible("netgear,r8000")) { ++ cc_ent = netgear_r8000_cc_ent; ++ table_size = ARRAY_SIZE(netgear_r8000_cc_ent); ++ } ++ ++ if (cc_ent && table_size) { ++ struct brcmfmac_pd_cc *cc; ++ size_t memsize; ++ ++ memsize = table_size * sizeof(struct brcmfmac_pd_cc_entry); ++ cc = devm_kzalloc(dev, sizeof(*cc) + memsize, GFP_KERNEL); ++ if (!cc) ++ return; ++ cc->table_size = table_size; ++ memcpy(cc->table, cc_ent, memsize); ++ settings->country_codes = cc; ++ } ++} ++ + void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, + struct brcmf_mp_device *settings) + { +@@ -30,6 +60,8 @@ void brcmf_of_probe(struct device *dev, + of_node_put(root); + } + ++ brcmf_of_probe_cc(dev, settings); ++ + if (!np || bus_type != BRCMF_BUSTYPE_SDIO || + !of_device_is_compatible(np, "brcm,bcm4329-fmac")) + return; diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch new file mode 100644 index 000000000..fe79c40c1 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch @@ -0,0 +1,23 @@ +brcmfmac: do not use internal roaming engine by default + +Some evidence of curing disconnects with this disabled, so make it a default. +Can be overridden with module parameter roamoff=0 +See: http://projectable.me/optimize-my-pi-wi-fi/ + +Signed-off-by: Phil Elwell +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +@@ -59,7 +59,11 @@ static int brcmf_fcmode; + module_param_named(fcmode, brcmf_fcmode, int, 0); + MODULE_PARM_DESC(fcmode, "Mode of firmware signalled flow control"); + ++#if defined(CONFIG_ARCH_BCM2835) ++static int brcmf_roamoff = 1; ++#else + static int brcmf_roamoff; ++#endif + module_param_named(roamoff, brcmf_roamoff, int, 0400); + MODULE_PARM_DESC(roamoff, "Do not use internal roaming engine"); + diff --git a/feeds/wifi-ath10k/mac80211/patches/brcm/998-survey.patch b/feeds/wifi-ath10k/mac80211/patches/brcm/998-survey.patch new file mode 100644 index 000000000..bcab2e3f3 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/brcm/998-survey.patch @@ -0,0 +1,148 @@ +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +@@ -2905,6 +2905,63 @@ done: + } + + static int ++brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev, ++ int idx, struct survey_info *survey) ++{ ++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); ++ struct brcmf_if *ifp = netdev_priv(ndev); ++ struct brcmu_chan ch; ++ enum nl80211_band band = 0; ++ s32 err = 0; ++ int noise; ++ u32 freq; ++ u32 chanspec; ++ ++ memset(survey, 0, sizeof(struct survey_info)); ++ if (idx != 0) { ++ if (idx >= cfg->pub->num_chan_stats || cfg->pub->chan_stats == NULL) ++ return -ENOENT; ++ if (cfg->pub->chan_stats[idx].freq == 0) ++ return -ENOENT; ++ survey->filled = SURVEY_INFO_NOISE_DBM; ++ survey->channel = ieee80211_get_channel(wiphy, cfg->pub->chan_stats[idx].freq); ++ survey->noise = cfg->pub->chan_stats[idx].noise; ++ return 0; ++ } ++ ++ err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec); ++ if (err) { ++ brcmf_err("chanspec failed (%d)\n", err); ++ return err; ++ } ++ ++ ch.chspec = chanspec; ++ cfg->d11inf.decchspec(&ch); ++ ++ switch (ch.band) { ++ case BRCMU_CHAN_BAND_2G: ++ band = NL80211_BAND_2GHZ; ++ break; ++ case BRCMU_CHAN_BAND_5G: ++ band = NL80211_BAND_5GHZ; ++ break; ++ } ++ ++ freq = ieee80211_channel_to_frequency(ch.control_ch_num, band); ++ survey->channel = ieee80211_get_channel(wiphy, freq); ++ ++ err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_PHY_NOISE, &noise); ++ if (err) { ++ brcmf_err("Could not get noise (%d)\n", err); ++ return err; ++ } ++ ++ survey->filled = SURVEY_INFO_NOISE_DBM | SURVEY_INFO_IN_USE; ++ survey->noise = le32_to_cpu(noise); ++ return 0; ++} ++ ++static int + brcmf_cfg80211_dump_station(struct wiphy *wiphy, struct net_device *ndev, + int idx, u8 *mac, struct station_info *sinfo) + { +@@ -2994,6 +3051,7 @@ static s32 brcmf_inform_single_bss(struc + struct brcmu_chan ch; + u16 channel; + u32 freq; ++ int i; + u16 notify_capability; + u16 notify_interval; + u8 *notify_ie; +@@ -3018,6 +3076,17 @@ static s32 brcmf_inform_single_bss(struc + band = NL80211_BAND_5GHZ; + + freq = ieee80211_channel_to_frequency(channel, band); ++ for (i = 0;i < cfg->pub->num_chan_stats;i++) { ++ if (freq == cfg->pub->chan_stats[i].freq) ++ break; ++ if (cfg->pub->chan_stats[i].freq == 0) ++ break; ++ } ++ if (i < cfg->pub->num_chan_stats) { ++ cfg->pub->chan_stats[i].freq = freq; ++ cfg->pub->chan_stats[i].noise = bi->phy_noise; ++ } ++ + bss_data.chan = ieee80211_get_channel(wiphy, freq); + bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20; + bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime()); +@@ -5470,6 +5539,7 @@ static struct cfg80211_ops brcmf_cfg8021 + .leave_ibss = brcmf_cfg80211_leave_ibss, + .get_station = brcmf_cfg80211_get_station, + .dump_station = brcmf_cfg80211_dump_station, ++ .dump_survey = brcmf_cfg80211_dump_survey, + .set_tx_power = brcmf_cfg80211_set_tx_power, + .get_tx_power = brcmf_cfg80211_get_tx_power, + .add_key = brcmf_cfg80211_add_key, +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +@@ -1349,6 +1349,8 @@ int brcmf_attach(struct device *dev) + + /* Link to bus module */ + drvr->hdrlen = 0; ++ drvr->chan_stats = vzalloc(256 * sizeof(struct brcmf_chan_stats)); ++ drvr->num_chan_stats = 256; + + /* Attach and link in the protocol */ + ret = brcmf_proto_attach(drvr); +@@ -1431,6 +1433,12 @@ void brcmf_detach(struct device *dev) + if (drvr == NULL) + return; + ++ drvr->num_chan_stats = 0; ++ if (drvr->chan_stats) { ++ vfree(drvr->chan_stats); ++ drvr->chan_stats = NULL; ++ } ++ + #ifdef CONFIG_INET + unregister_inetaddr_notifier(&drvr->inetaddr_notifier); + #endif +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +@@ -91,6 +91,11 @@ struct brcmf_rev_info { + u32 nvramrev; + }; + ++struct brcmf_chan_stats { ++ u32 freq; ++ int noise; ++}; ++ + /* Common structure for module and instance linkage */ + struct brcmf_pub { + /* Linkage ponters */ +@@ -100,6 +105,9 @@ struct brcmf_pub { + struct cfg80211_ops *ops; + struct brcmf_cfg80211_info *config; + ++ int num_chan_stats; ++ struct brcmf_chan_stats *chan_stats; ++ + /* Internal brcmf items */ + uint hdrlen; /* Total BRCMF header length (proto + bus) */ + diff --git a/feeds/wifi-ath10k/mac80211/patches/build/000-fix_kconfig.patch b/feeds/wifi-ath10k/mac80211/patches/build/000-fix_kconfig.patch new file mode 100644 index 000000000..3987aae4f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/000-fix_kconfig.patch @@ -0,0 +1,14 @@ +--- a/kconf/Makefile ++++ b/kconf/Makefile +@@ -1,9 +1,9 @@ +-CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer ++CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -DKBUILD_NO_NLS + + LXDIALOG := lxdialog/checklist.o lxdialog/inputbox.o lxdialog/menubox.o lxdialog/textbox.o lxdialog/util.o lxdialog/yesno.o + + conf: conf.o zconf.tab.o +-mconf_CFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ccflags) -DLOCALE ++mconf_CFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ccflags) + mconf_LDFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ldflags $(CC)) + mconf: CFLAGS += $(mconf_CFLAGS) + diff --git a/feeds/wifi-ath10k/mac80211/patches/build/001-fix_build.patch b/feeds/wifi-ath10k/mac80211/patches/build/001-fix_build.patch new file mode 100644 index 000000000..e57ca190e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/001-fix_build.patch @@ -0,0 +1,169 @@ +--- a/Makefile ++++ b/Makefile +@@ -5,7 +5,7 @@ + ifeq ($(KERNELRELEASE),) + + MAKEFLAGS += --no-print-directory +-SHELL := /bin/bash ++SHELL := /usr/bin/env bash + BACKPORT_DIR := $(shell pwd) + + KMODDIR ?= updates +@@ -19,6 +19,7 @@ KLIB_BUILD ?= $(KLIB)/build/ + KERNEL_CONFIG := $(KLIB_BUILD)/.config + KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile + CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//') ++STAMP_KERNEL_CONFIG := .kernel_config_md5_$(CONFIG_MD5) + + export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG + +@@ -36,7 +37,8 @@ mrproper: + @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel + @rm -f backport-include/backport/autoconf.h + +-.DEFAULT: ++.SILENT: $(STAMP_KERNEL_CONFIG) ++$(STAMP_KERNEL_CONFIG): + @set -e ; test -f local-symbols || ( \ + echo "/--------------" ;\ + echo "| You shouldn't run make in the backports tree, but only in" ;\ +@@ -60,58 +62,62 @@ mrproper: + echo "| (that isn't currently running.)" ;\ + echo "\\--" ;\ + false) +- @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\ +- then \ +- echo -n "Generating local configuration database from kernel ..." ;\ +- grep -v -f local-symbols $(KERNEL_CONFIG) | grep = | ( \ +- while read l ; do \ +- if [ "$${l:0:7}" != "CONFIG_" ] ; then \ +- continue ;\ +- fi ;\ +- l=$${l:7} ;\ +- n=$${l%%=*} ;\ +- v=$${l#*=} ;\ +- if [ "$$v" = "m" ] ; then \ +- echo config $$n ;\ +- echo ' tristate' ;\ +- elif [ "$$v" = "y" ] ; then \ +- echo config $$n ;\ +- echo ' bool' ;\ +- else \ +- continue ;\ +- fi ;\ +- echo " default $$v" ;\ +- echo "" ;\ +- done \ +- ) > Kconfig.kernel ;\ +- kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ +- sed 's/^\(\([3-5]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ +- test "$$kver" != "" || echo "Kernel version parse failed!" ;\ +- test "$$kver" != "" ;\ +- kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ +- kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\ +- kvers="$$kvers $$(seq 0 20 | sed 's/^/4./')" ;\ +- kvers="$$kvers $$(seq 0 99 | sed 's/^/5./')" ;\ +- print=0 ;\ +- for v in $$kvers ; do \ +- if [ "$$print" = "1" ] ; then \ +- echo config KERNEL_$$(echo $$v | tr . _) ;\ +- echo " def_bool y" ;\ +- fi ;\ +- if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ +- done > Kconfig.versions ;\ +- # RHEL as well, sadly we need to grep for it ;\ +- RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ +- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ +- RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ +- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ +- for v in $$(seq 0 $$RHEL_MINOR) ; do \ +- echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ +- echo " def_bool y" ;\ +- done >> Kconfig.versions ;\ +- echo " done." ;\ +- fi ;\ +- echo "$(CONFIG_MD5)" > .kernel_config_md5 ++ @rm -f .kernel_config_md5_* ++ @touch $@ ++ ++Kconfig.kernel: $(STAMP_KERNEL_CONFIG) local-symbols ++ @printf "Generating local configuration database from kernel ..." ++ @grep -v -f local-symbols $(KERNEL_CONFIG) | grep = | ( \ ++ while read l ; do \ ++ if [ "$${l:0:7}" != "CONFIG_" ] ; then \ ++ continue ;\ ++ fi ;\ ++ l=$${l:7} ;\ ++ n=$${l%%=*} ;\ ++ v=$${l#*=} ;\ ++ if [ "$$v" = "m" ] ; then \ ++ echo config $$n ;\ ++ echo ' tristate' ;\ ++ elif [ "$$v" = "y" ] ; then \ ++ echo config $$n ;\ ++ echo ' bool' ;\ ++ else \ ++ continue ;\ ++ fi ;\ ++ echo " default $$v" ;\ ++ echo "" ;\ ++ done \ ++ ) > $@ ++ @echo " done." ++ ++Kconfig.versions: Kconfig.kernel ++ @kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ ++ sed 's/^\(\([3-5]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ ++ test "$$kver" != "" || echo "Kernel version parse failed!" ;\ ++ test "$$kver" != "" ;\ ++ kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ ++ kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\ ++ kvers="$$kvers $$(seq 0 20 | sed 's/^/4./')" ;\ ++ kvers="$$kvers $$(seq 0 99 | sed 's/^/5./')" ;\ ++ print=0 ;\ ++ for v in $$kvers ; do \ ++ if [ "$$print" = "1" ] ; then \ ++ echo config KERNEL_$$(echo $$v | tr . _) ;\ ++ echo " def_bool y" ;\ ++ fi ;\ ++ if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ ++ done > $@ ++ @RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ ++ sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ ++ RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ ++ sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ ++ for v in $$(seq 0 $$RHEL_MINOR) ; do \ ++ echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ ++ echo " def_bool y" ;\ ++ done >> $@ ++ ++.DEFAULT: ++ @$(MAKE) Kconfig.versions + @$(MAKE) -f Makefile.real "$@" + + .PHONY: defconfig-help +--- a/Makefile.real ++++ b/Makefile.real +@@ -59,7 +59,7 @@ defconfig-%:: + + backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel + @$(MAKE) oldconfig +- @echo -n "Building backport-include/backport/autoconf.h ..." ++ @printf "Building backport-include/backport/autoconf.h ..." + @grep -f local-symbols .config | ( \ + echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\ + echo "#define COMPAT_AUTOCONF_INCLUDED" ;\ +@@ -80,7 +80,12 @@ backport-include/backport/autoconf.h: .c + esac ;\ + done ;\ + echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\ +- ) > backport-include/backport/autoconf.h ++ ) > $@.new ++ @if cmp -s $@ $@.new; then \ ++ rm -f $@.new; \ ++ else \ ++ mv $@.new $@; \ ++ fi + @echo " done." + + .PHONY: modules diff --git a/feeds/wifi-ath10k/mac80211/patches/build/002-change_allconfig.patch b/feeds/wifi-ath10k/mac80211/patches/build/002-change_allconfig.patch new file mode 100644 index 000000000..368725d0c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/002-change_allconfig.patch @@ -0,0 +1,64 @@ +--- a/kconf/conf.c ++++ b/kconf/conf.c +@@ -598,40 +598,12 @@ int main(int ac, char **av) + case oldconfig: + case listnewconfig: + case olddefconfig: +- conf_read(NULL); +- break; + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case randconfig: +- name = getenv("KCONFIG_ALLCONFIG"); +- if (!name) +- break; +- if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { +- if (conf_read_simple(name, S_DEF_USER)) { +- fprintf(stderr, +- _("*** Can't read seed configuration \"%s\"!\n"), +- name); +- exit(1); +- } +- break; +- } +- switch (input_mode) { +- case allnoconfig: name = "allno.config"; break; +- case allyesconfig: name = "allyes.config"; break; +- case allmodconfig: name = "allmod.config"; break; +- case alldefconfig: name = "alldef.config"; break; +- case randconfig: name = "allrandom.config"; break; +- default: break; +- } +- if (conf_read_simple(name, S_DEF_USER) && +- conf_read_simple("all.config", S_DEF_USER)) { +- fprintf(stderr, +- _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), +- name); +- exit(1); +- } ++ conf_read(NULL); + break; + default: + break; +--- a/kconf/confdata.c ++++ b/kconf/confdata.c +@@ -1170,6 +1170,8 @@ bool conf_set_all_new_symbols(enum conf_ + } + bool has_changed = false; + ++ sym_clear_all_valid(); ++ + for_all_symbols(i, sym) { + if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) + continue; +@@ -1213,8 +1215,6 @@ bool conf_set_all_new_symbols(enum conf_ + + } + +- sym_clear_all_valid(); +- + /* + * We have different type of choice blocks. + * If curr.tri equals to mod then we can select several diff --git a/feeds/wifi-ath10k/mac80211/patches/build/003-remove_bogus_modparams.patch b/feeds/wifi-ath10k/mac80211/patches/build/003-remove_bogus_modparams.patch new file mode 100644 index 000000000..8fa465a7e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/003-remove_bogus_modparams.patch @@ -0,0 +1,34 @@ +--- a/compat/main.c ++++ b/compat/main.c +@@ -20,31 +20,6 @@ MODULE_LICENSE("GPL"); + #error "You need a CPTCFG_VERSION" + #endif + +-static char *backported_kernel_name = CPTCFG_KERNEL_NAME; +- +-module_param(backported_kernel_name, charp, 0400); +-MODULE_PARM_DESC(backported_kernel_name, +- "The kernel tree name that was used for this backport (" CPTCFG_KERNEL_NAME ")"); +- +-#ifdef BACKPORTS_GIT_TRACKED +-static char *backports_tracker_id = BACKPORTS_GIT_TRACKED; +-module_param(backports_tracker_id, charp, 0400); +-MODULE_PARM_DESC(backports_tracker_id, +- "The version of the tree containing this backport (" BACKPORTS_GIT_TRACKED ")"); +-#else +-static char *backported_kernel_version = CPTCFG_KERNEL_VERSION; +-static char *backports_version = CPTCFG_VERSION; +- +-module_param(backported_kernel_version, charp, 0400); +-MODULE_PARM_DESC(backported_kernel_version, +- "The kernel version that was used for this backport (" CPTCFG_KERNEL_VERSION ")"); +- +-module_param(backports_version, charp, 0400); +-MODULE_PARM_DESC(backports_version, +- "The git version of the backports tree used to generate this backport (" CPTCFG_VERSION ")"); +- +-#endif +- + void backport_dependency_symbol(void) + { + } diff --git a/feeds/wifi-ath10k/mac80211/patches/build/004-kconfig_backport_fix.patch b/feeds/wifi-ath10k/mac80211/patches/build/004-kconfig_backport_fix.patch new file mode 100644 index 000000000..2c9572ec9 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/004-kconfig_backport_fix.patch @@ -0,0 +1,28 @@ +--- a/backport-include/linux/kconfig.h ++++ b/backport-include/linux/kconfig.h +@@ -5,6 +5,8 @@ + #include_next + #endif + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) ++ + #ifndef __ARG_PLACEHOLDER_1 + #define __ARG_PLACEHOLDER_1 0, + #define config_enabled(cfg) _config_enabled(cfg) +@@ -16,6 +18,7 @@ + * 3.1 - 3.3 had a broken version of this, so undef + * (they didn't have __ARG_PLACEHOLDER_1) + */ ++ + #undef IS_ENABLED + #define IS_ENABLED(option) \ + (config_enabled(option) || config_enabled(option##_MODULE)) +@@ -31,6 +34,8 @@ + #undef IS_BUILTIN + #define IS_BUILTIN(option) config_enabled(option) + ++#endif ++ + #ifndef IS_REACHABLE + /* + * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled diff --git a/feeds/wifi-ath10k/mac80211/patches/build/010-disable_rfkill.patch b/feeds/wifi-ath10k/mac80211/patches/build/010-disable_rfkill.patch new file mode 100644 index 000000000..d5253063c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/010-disable_rfkill.patch @@ -0,0 +1,15 @@ +--- a/backport-include/linux/rfkill.h ++++ b/backport-include/linux/rfkill.h +@@ -2,6 +2,12 @@ + #define __COMPAT_RFKILL_H + #include + ++#undef CONFIG_RFKILL ++#undef CONFIG_RFKILL_FULL ++#undef CONFIG_RFKILL_LEDS ++#undef CONFIG_RFKILL_MODULE ++#undef CONFIG_RFKILL_FULL_MODULE ++ + #if LINUX_VERSION_IS_GEQ(3,10,0) + #include_next + #else diff --git a/feeds/wifi-ath10k/mac80211/patches/build/012-kernel_build_check.patch b/feeds/wifi-ath10k/mac80211/patches/build/012-kernel_build_check.patch new file mode 100644 index 000000000..d225ba182 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/012-kernel_build_check.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -2,7 +2,7 @@ + # Makefile for the output source package + # + +-ifeq ($(KERNELRELEASE),) ++ifeq ($(KERNELVERSION),) + + MAKEFLAGS += --no-print-directory + SHELL := /usr/bin/env bash diff --git a/feeds/wifi-ath10k/mac80211/patches/build/015-ipw200-mtu.patch b/feeds/wifi-ath10k/mac80211/patches/build/015-ipw200-mtu.patch new file mode 100644 index 000000000..68db4f72d --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/015-ipw200-mtu.patch @@ -0,0 +1,34 @@ +--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c ++++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c +@@ -11470,6 +11470,15 @@ static const struct attribute_group ipw_ + .attrs = ipw_sysfs_entries, + }; + ++#if LINUX_VERSION_IS_LESS(4,10,0) ++static int __change_mtu(struct net_device *ndev, int new_mtu){ ++ if (new_mtu < 68 || new_mtu > LIBIPW_DATA_LEN) ++ return -EINVAL; ++ ndev->mtu = new_mtu; ++ return 0; ++} ++#endif ++ + #ifdef CPTCFG_IPW2200_PROMISCUOUS + static int ipw_prom_open(struct net_device *dev) + { +@@ -11518,15 +11527,6 @@ static netdev_tx_t ipw_prom_hard_start_x + return NETDEV_TX_OK; + } + +-#if LINUX_VERSION_IS_LESS(4,10,0) +-static int __change_mtu(struct net_device *ndev, int new_mtu){ +- if (new_mtu < 68 || new_mtu > LIBIPW_DATA_LEN) +- return -EINVAL; +- ndev->mtu = new_mtu; +- return 0; +-} +-#endif +- + static const struct net_device_ops ipw_prom_netdev_ops = { + #if LINUX_VERSION_IS_LESS(4,10,0) + .ndo_change_mtu = __change_mtu, diff --git a/feeds/wifi-ath10k/mac80211/patches/build/050-lib80211_option.patch b/feeds/wifi-ath10k/mac80211/patches/build/050-lib80211_option.patch new file mode 100644 index 000000000..c6174449c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/050-lib80211_option.patch @@ -0,0 +1,33 @@ +--- a/net/wireless/Kconfig ++++ b/net/wireless/Kconfig +@@ -187,7 +187,7 @@ config CFG80211_WEXT_EXPORT + endif # CFG80211 + + config LIB80211 +- tristate ++ tristate "lib80211" + depends on m + default n + help +@@ -197,18 +197,18 @@ config LIB80211 + Drivers should select this themselves if needed. + + config LIB80211_CRYPT_WEP +- tristate ++ tristate "lib80211 WEP support" + depends on m + select BPAUTO_CRYPTO_LIB_ARC4 + + config LIB80211_CRYPT_CCMP +- tristate ++ tristate "lib80211 CCMP support" + depends on m + depends on CRYPTO_AES + depends on CRYPTO_CCM + + config LIB80211_CRYPT_TKIP +- tristate ++ tristate "lib80211 TKIP support" + depends on m + select BPAUTO_CRYPTO_LIB_ARC4 + diff --git a/feeds/wifi-ath10k/mac80211/patches/build/060-no_local_ssb_bcma.patch b/feeds/wifi-ath10k/mac80211/patches/build/060-no_local_ssb_bcma.patch new file mode 100644 index 000000000..c00ab7c78 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/build/060-no_local_ssb_bcma.patch @@ -0,0 +1,335 @@ +--- a/local-symbols ++++ b/local-symbols +@@ -424,43 +424,6 @@ USB_SIERRA_NET= + USB_VL600= + USB_NET_CH9200= + USB_NET_AQC111= +-SSB_POSSIBLE= +-SSB= +-SSB_SPROM= +-SSB_BLOCKIO= +-SSB_PCIHOST_POSSIBLE= +-SSB_PCIHOST= +-SSB_B43_PCI_BRIDGE= +-SSB_PCMCIAHOST_POSSIBLE= +-SSB_PCMCIAHOST= +-SSB_SDIOHOST_POSSIBLE= +-SSB_SDIOHOST= +-SSB_HOST_SOC= +-SSB_SERIAL= +-SSB_DRIVER_PCICORE_POSSIBLE= +-SSB_DRIVER_PCICORE= +-SSB_PCICORE_HOSTMODE= +-SSB_DRIVER_MIPS= +-SSB_SFLASH= +-SSB_EMBEDDED= +-SSB_DRIVER_EXTIF= +-SSB_DRIVER_GIGE= +-SSB_DRIVER_GPIO= +-BCMA_POSSIBLE= +-BCMA= +-BCMA_BLOCKIO= +-BCMA_HOST_PCI_POSSIBLE= +-BCMA_HOST_PCI= +-BCMA_HOST_SOC= +-BCMA_DRIVER_PCI= +-BCMA_DRIVER_PCI_HOSTMODE= +-BCMA_DRIVER_MIPS= +-BCMA_PFLASH= +-BCMA_SFLASH= +-BCMA_NFLASH= +-BCMA_DRIVER_GMAC_CMN= +-BCMA_DRIVER_GPIO= +-BCMA_DEBUG= + USB_ACM= + USB_PRINTER= + USB_WDM= +--- a/drivers/net/wireless/broadcom/b43/Kconfig ++++ b/drivers/net/wireless/broadcom/b43/Kconfig +@@ -63,21 +63,21 @@ endchoice + config B43_PCI_AUTOSELECT + bool + depends on B43 && SSB_PCIHOST_POSSIBLE +- select SSB_PCIHOST +- select SSB_B43_PCI_BRIDGE ++ depends on SSB_PCIHOST ++ depends on SSB_B43_PCI_BRIDGE + default y + + # Auto-select SSB PCICORE driver, if possible + config B43_PCICORE_AUTOSELECT + bool + depends on B43 && SSB_DRIVER_PCICORE_POSSIBLE +- select SSB_DRIVER_PCICORE ++ depends on SSB_DRIVER_PCICORE + default y + + config B43_SDIO + bool "Broadcom 43xx SDIO device support" + depends on B43 && B43_SSB && SSB_SDIOHOST_POSSIBLE +- select SSB_SDIOHOST ++ depends on SSB_SDIOHOST + help + Broadcom 43xx device support for Soft-MAC SDIO devices. + +@@ -96,13 +96,13 @@ config B43_SDIO + config B43_BCMA_PIO + bool + depends on B43 && B43_BCMA +- select BCMA_BLOCKIO ++ depends on BCMA_BLOCKIO + default y + + config B43_PIO + bool + depends on B43 && B43_SSB +- select SSB_BLOCKIO ++ depends on SSB_BLOCKIO + default y + + config B43_PHY_G +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -2851,7 +2851,7 @@ static struct ssb_device *b43_ssb_gpio_d + { + struct ssb_bus *bus = dev->dev->sdev->bus; + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev); + #else + return bus->chipco.dev; +@@ -4868,7 +4868,7 @@ static int b43_wireless_core_init(struct + } + if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW) + hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */ +-#if defined(CPTCFG_B43_SSB) && defined(CPTCFG_SSB_DRIVER_PCICORE) ++#if defined(CPTCFG_B43_SSB) && defined(CONFIG_SSB_DRIVER_PCICORE) + if (dev->dev->bus_type == B43_BUS_SSB && + dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI && + dev->dev->sdev->bus->pcicore.dev->id.revision <= 10) +--- a/drivers/net/wireless/broadcom/b43legacy/Kconfig ++++ b/drivers/net/wireless/broadcom/b43legacy/Kconfig +@@ -3,7 +3,7 @@ config B43LEGACY + tristate "Broadcom 43xx-legacy wireless support (mac80211 stack)" + depends on m + depends on SSB_POSSIBLE && MAC80211 && HAS_DMA +- select SSB ++ depends on SSB + depends on FW_LOADER + help + b43legacy is a driver for 802.11b devices from Broadcom (BCM4301 and +@@ -25,15 +25,15 @@ config B43LEGACY + config B43LEGACY_PCI_AUTOSELECT + bool + depends on B43LEGACY && SSB_PCIHOST_POSSIBLE +- select SSB_PCIHOST +- select SSB_B43_PCI_BRIDGE ++ depends on SSB_PCIHOST ++ depends on SSB_B43_PCI_BRIDGE + default y + + # Auto-select SSB PCICORE driver, if possible + config B43LEGACY_PCICORE_AUTOSELECT + bool + depends on B43LEGACY && SSB_DRIVER_PCICORE_POSSIBLE +- select SSB_DRIVER_PCICORE ++ depends on SSB_DRIVER_PCICORE + default y + + # LED support +--- a/drivers/net/wireless/broadcom/b43legacy/main.c ++++ b/drivers/net/wireless/broadcom/b43legacy/main.c +@@ -1906,7 +1906,7 @@ static int b43legacy_gpio_init(struct b4 + if (dev->dev->id.revision >= 2) + mask |= 0x0010; /* FIXME: This is redundant. */ + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + pcidev = bus->pcicore.dev; + #endif + gpiodev = bus->chipco.dev ? : pcidev; +@@ -1925,7 +1925,7 @@ static void b43legacy_gpio_cleanup(struc + struct ssb_bus *bus = dev->dev->bus; + struct ssb_device *gpiodev, *pcidev = NULL; + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + pcidev = bus->pcicore.dev; + #endif + gpiodev = bus->chipco.dev ? : pcidev; +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.h +@@ -22,7 +22,7 @@ struct brcms_led { + bool active_low; + }; + +-#ifdef CPTCFG_BCMA_DRIVER_GPIO ++#ifdef CONFIG_BCMA_DRIVER_GPIO + void brcms_led_unregister(struct brcms_info *wl); + int brcms_led_register(struct brcms_info *wl); + #else +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile +@@ -42,6 +42,6 @@ brcmsmac-y := \ + brcms_trace_events.o \ + debug.o + +-brcmsmac-$(CPTCFG_BCMA_DRIVER_GPIO) += led.o ++brcmsmac-$(CONFIG_BCMA_DRIVER_GPIO) += led.o + + obj-$(CPTCFG_BRCMSMAC) += brcmsmac.o +--- a/drivers/net/wireless/broadcom/brcm80211/Kconfig ++++ b/drivers/net/wireless/broadcom/brcm80211/Kconfig +@@ -8,7 +8,7 @@ config BRCMSMAC + depends on m + depends on MAC80211 + depends on BCMA_POSSIBLE +- select BCMA ++ depends on BCMA + select NEW_LEDS if BCMA_DRIVER_GPIO + select LEDS_CLASS if BCMA_DRIVER_GPIO + select BRCMUTIL +--- a/Kconfig.local ++++ b/Kconfig.local +@@ -1276,117 +1276,6 @@ config BACKPORTED_USB_NET_CH9200 + config BACKPORTED_USB_NET_AQC111 + tristate + default USB_NET_AQC111 +-config BACKPORTED_SSB_POSSIBLE +- tristate +- default SSB_POSSIBLE +-config BACKPORTED_SSB +- tristate +- default SSB +-config BACKPORTED_SSB_SPROM +- tristate +- default SSB_SPROM +-config BACKPORTED_SSB_BLOCKIO +- tristate +- default SSB_BLOCKIO +-config BACKPORTED_SSB_PCIHOST_POSSIBLE +- tristate +- default SSB_PCIHOST_POSSIBLE +-config BACKPORTED_SSB_PCIHOST +- tristate +- default SSB_PCIHOST +-config BACKPORTED_SSB_B43_PCI_BRIDGE +- tristate +- default SSB_B43_PCI_BRIDGE +-config BACKPORTED_SSB_PCMCIAHOST_POSSIBLE +- tristate +- default SSB_PCMCIAHOST_POSSIBLE +-config BACKPORTED_SSB_PCMCIAHOST +- tristate +- default SSB_PCMCIAHOST +-config BACKPORTED_SSB_SDIOHOST_POSSIBLE +- tristate +- default SSB_SDIOHOST_POSSIBLE +-config BACKPORTED_SSB_SDIOHOST +- tristate +- default SSB_SDIOHOST +-config BACKPORTED_SSB_HOST_SOC +- tristate +- default SSB_HOST_SOC +-config BACKPORTED_SSB_SERIAL +- tristate +- default SSB_SERIAL +-config BACKPORTED_SSB_DRIVER_PCICORE_POSSIBLE +- tristate +- default SSB_DRIVER_PCICORE_POSSIBLE +-config BACKPORTED_SSB_DRIVER_PCICORE +- tristate +- default SSB_DRIVER_PCICORE +-config BACKPORTED_SSB_PCICORE_HOSTMODE +- tristate +- default SSB_PCICORE_HOSTMODE +-config BACKPORTED_SSB_DRIVER_MIPS +- tristate +- default SSB_DRIVER_MIPS +-config BACKPORTED_SSB_SFLASH +- tristate +- default SSB_SFLASH +-config BACKPORTED_SSB_EMBEDDED +- tristate +- default SSB_EMBEDDED +-config BACKPORTED_SSB_DRIVER_EXTIF +- tristate +- default SSB_DRIVER_EXTIF +-config BACKPORTED_SSB_DRIVER_GIGE +- tristate +- default SSB_DRIVER_GIGE +-config BACKPORTED_SSB_DRIVER_GPIO +- tristate +- default SSB_DRIVER_GPIO +-config BACKPORTED_BCMA_POSSIBLE +- tristate +- default BCMA_POSSIBLE +-config BACKPORTED_BCMA +- tristate +- default BCMA +-config BACKPORTED_BCMA_BLOCKIO +- tristate +- default BCMA_BLOCKIO +-config BACKPORTED_BCMA_HOST_PCI_POSSIBLE +- tristate +- default BCMA_HOST_PCI_POSSIBLE +-config BACKPORTED_BCMA_HOST_PCI +- tristate +- default BCMA_HOST_PCI +-config BACKPORTED_BCMA_HOST_SOC +- tristate +- default BCMA_HOST_SOC +-config BACKPORTED_BCMA_DRIVER_PCI +- tristate +- default BCMA_DRIVER_PCI +-config BACKPORTED_BCMA_DRIVER_PCI_HOSTMODE +- tristate +- default BCMA_DRIVER_PCI_HOSTMODE +-config BACKPORTED_BCMA_DRIVER_MIPS +- tristate +- default BCMA_DRIVER_MIPS +-config BACKPORTED_BCMA_PFLASH +- tristate +- default BCMA_PFLASH +-config BACKPORTED_BCMA_SFLASH +- tristate +- default BCMA_SFLASH +-config BACKPORTED_BCMA_NFLASH +- tristate +- default BCMA_NFLASH +-config BACKPORTED_BCMA_DRIVER_GMAC_CMN +- tristate +- default BCMA_DRIVER_GMAC_CMN +-config BACKPORTED_BCMA_DRIVER_GPIO +- tristate +- default BCMA_DRIVER_GPIO +-config BACKPORTED_BCMA_DEBUG +- tristate +- default BCMA_DEBUG + config BACKPORTED_USB_ACM + tristate + default USB_ACM +--- a/Kconfig.sources ++++ b/Kconfig.sources +@@ -7,9 +7,6 @@ source "$BACKPORT_DIR/net/mac80211/Kconf + source "$BACKPORT_DIR/drivers/net/wireless/Kconfig" + source "$BACKPORT_DIR/drivers/net/usb/Kconfig" + +-source "$BACKPORT_DIR/drivers/ssb/Kconfig" +-source "$BACKPORT_DIR/drivers/bcma/Kconfig" +- + source "$BACKPORT_DIR/drivers/usb/class/Kconfig" + + source "$BACKPORT_DIR/drivers/staging/Kconfig" +--- a/Makefile.kernel ++++ b/Makefile.kernel +@@ -40,8 +40,6 @@ obj-y += compat/ + obj-$(CPTCFG_CFG80211) += net/wireless/ + obj-$(CPTCFG_MAC80211) += net/mac80211/ + obj-$(CPTCFG_WLAN) += drivers/net/wireless/ +-obj-$(CPTCFG_SSB) += drivers/ssb/ +-obj-$(CPTCFG_BCMA) += drivers/bcma/ + obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/ + + obj-$(CPTCFG_USB_WDM) += drivers/usb/class/ diff --git a/feeds/wifi-ath10k/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch b/feeds/wifi-ath10k/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch new file mode 100644 index 000000000..cfa40e1bd --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/wireless/marvell/mwl8k.c ++++ b/drivers/net/wireless/marvell/mwl8k.c +@@ -5694,6 +5694,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw") + MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API)); + + static const struct pci_device_id mwl8k_pci_id_table[] = { ++ { PCI_VDEVICE(MARVELL, 0x2a02), .driver_data = MWL8363, }, + { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, }, + { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, }, + { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, }, diff --git a/feeds/wifi-ath10k/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch b/feeds/wifi-ath10k/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch new file mode 100644 index 000000000..dfa0e502f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch @@ -0,0 +1,21 @@ +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -2053,6 +2053,8 @@ struct wireless_dev *lbs_cfg_alloc(struc + goto err_wiphy_new; + } + ++ set_wiphy_dev(wdev->wiphy, dev); ++ + return wdev; + + err_wiphy_new: +--- a/drivers/net/wireless/marvell/libertas/main.c ++++ b/drivers/net/wireless/marvell/libertas/main.c +@@ -935,6 +935,7 @@ struct lbs_private *lbs_add_card(void *c + goto err_adapter; + } + ++ dev_net_set(dev, wiphy_net(wdev->wiphy)); + dev->ieee80211_ptr = wdev; + dev->ml_priv = priv; + SET_NETDEV_DEV(dev, dmdev); diff --git a/feeds/wifi-ath10k/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch b/feeds/wifi-ath10k/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch new file mode 100644 index 000000000..c2d0a5890 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -2129,6 +2129,8 @@ int lbs_cfg_register(struct lbs_private + wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); + wdev->wiphy->reg_notifier = lbs_reg_notifier; + ++ memcpy(wdev->wiphy->perm_addr, priv->current_addr, ETH_ALEN); ++ + ret = wiphy_register(wdev->wiphy); + if (ret < 0) + pr_err("cannot register wiphy device\n"); diff --git a/feeds/wifi-ath10k/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch b/feeds/wifi-ath10k/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch new file mode 100644 index 000000000..f3130f7ae --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch @@ -0,0 +1,20 @@ +--- a/drivers/net/wireless/marvell/mwl8k.c ++++ b/drivers/net/wireless/marvell/mwl8k.c +@@ -6279,6 +6279,8 @@ static int mwl8k_probe(struct pci_dev *p + + priv->running_bsses = 0; + ++ wait_for_completion(&priv->firmware_loading_complete); ++ + return rc; + + err_stop_firmware: +@@ -6312,8 +6314,6 @@ static void mwl8k_remove(struct pci_dev + return; + priv = hw->priv; + +- wait_for_completion(&priv->firmware_loading_complete); +- + if (priv->fw_state == FW_STATE_ERROR) { + mwl8k_hw_reset(priv); + goto unmap; diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch new file mode 100644 index 000000000..a50a19528 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch @@ -0,0 +1,51 @@ +From patchwork Thu Dec 27 14:05:26 2018 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Patchwork-Submitter: Tom Psyborg +X-Patchwork-Id: 10743707 +X-Patchwork-Delegate: kvalo@adurom.com +From: =?utf-8?q?Tomislav_Po=C5=BEega?= +To: linux-wireless@vger.kernel.org +Cc: kvalo@codeaurora.org, hauke@hauke-m.de, nbd@nbd.name, + john@phrozen.org, sgruszka@redhat.com, daniel@makrotopia.org +Subject: [PATCH 2/2] rt2x00: define RF5592 in init_eeprom routine +Date: Thu, 27 Dec 2018 15:05:26 +0100 +Message-Id: <1545919526-4074-2-git-send-email-pozega.tomislav@gmail.com> +X-Mailer: git-send-email 1.7.0.4 +In-Reply-To: <1545919526-4074-1-git-send-email-pozega.tomislav@gmail.com> +References: <1545919526-4074-1-git-send-email-pozega.tomislav@gmail.com> +MIME-Version: 1.0 +Sender: linux-wireless-owner@vger.kernel.org +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org +X-Virus-Scanned: ClamAV using ClamSMTP + +This patch fixes following crash on Linksys EA2750 during 5GHz wifi +init: + +[ 7.955153] rt2800pci 0000:01:00.0: card - bus=0x1, slot = 0x0 irq=4 +[ 7.962259] rt2800pci 0000:01:00.0: loaded eeprom from mtd device "Factory" +[ 7.969435] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5592, rev 0222 detected +[ 7.977348] ieee80211 phy0: rt2800_init_eeprom: Error - Invalid RF chipset 0x0000 detected +[ 7.985793] ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device +[ 7.993569] CPU 0 Unable to handle kernel paging request at virtual address 00000024, epc == 800c8f54, ra == 80249ff8 +[ 8.004408] Oops[#1]: + +Signed-off-by: Tomislav Požega +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9416,6 +9416,8 @@ static int rt2800_init_eeprom(struct rt2 + rf = RF3853; + else if (rt2x00_rt(rt2x00dev, RT5350)) + rf = RF5350; ++ else if (rt2x00_rt(rt2x00dev, RT5592)) ++ rf = RF5592; + else + rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); + diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/100-rt2x00_options.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/100-rt2x00_options.patch new file mode 100644 index 000000000..295904c64 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/100-rt2x00_options.patch @@ -0,0 +1,47 @@ +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -226,36 +226,37 @@ config RT2800SOC + + + config RT2800_LIB +- tristate ++ tristate "RT2800 USB/PCI support" + depends on m + + config RT2800_LIB_MMIO +- tristate ++ tristate "RT2800 MMIO support" + depends on m + select RT2X00_LIB_MMIO + select RT2800_LIB + + config RT2X00_LIB_MMIO +- tristate ++ tristate "RT2x00 MMIO support" + depends on m + + config RT2X00_LIB_PCI +- tristate ++ tristate "RT2x00 PCI support" + depends on m + select RT2X00_LIB + + config RT2X00_LIB_SOC +- tristate ++ tristate "RT2x00 SoC support" ++ depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 + depends on m + select RT2X00_LIB + + config RT2X00_LIB_USB +- tristate ++ tristate "RT2x00 USB support" + depends on m + select RT2X00_LIB + + config RT2X00_LIB +- tristate ++ tristate "RT2x00 support" + depends on m + + config RT2X00_LIB_FIRMWARE diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch new file mode 100644 index 000000000..b4106b019 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch @@ -0,0 +1,30 @@ +From 91094ed065f7794886b4a5490fd6de942f036bb4 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: allow to build rt2800soc module for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -211,7 +211,7 @@ endif + config RT2800SOC + tristate "Ralink WiSoC support" + depends on m +- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 ++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 + select RT2X00_LIB_SOC + select RT2X00_LIB_MMIO + select RT2X00_LIB_CRYPTO +@@ -246,7 +246,7 @@ config RT2X00_LIB_PCI + + config RT2X00_LIB_SOC + tristate "RT2x00 SoC support" +- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 ++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 + depends on m + select RT2X00_LIB + diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/601-rt2x00-introduce-rt2x00_platform_h.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/601-rt2x00-introduce-rt2x00_platform_h.patch new file mode 100644 index 000000000..1e6211a47 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/601-rt2x00-introduce-rt2x00_platform_h.patch @@ -0,0 +1,32 @@ +--- /dev/null ++++ b/include/linux/rt2x00_platform.h +@@ -0,0 +1,19 @@ ++/* ++ * Platform data definition for the rt2x00 driver ++ * ++ * Copyright (C) 2011 Gabor Juhos ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 as published ++ * by the Free Software Foundation. ++ * ++ */ ++ ++#ifndef _RT2X00_PLATFORM_H ++#define _RT2X00_PLATFORM_H ++ ++struct rt2x00_platform_data { ++ char *eeprom_file_name; ++}; ++ ++#endif /* _RT2X00_PLATFORM_H */ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #include + diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch new file mode 100644 index 000000000..da76b34fa --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch @@ -0,0 +1,296 @@ +--- a/local-symbols ++++ b/local-symbols +@@ -321,6 +321,7 @@ RT2X00_LIB_FIRMWARE= + RT2X00_LIB_CRYPTO= + RT2X00_LIB_LEDS= + RT2X00_LIB_DEBUGFS= ++RT2X00_LIB_EEPROM= + RT2X00_DEBUG= + WLAN_VENDOR_REALTEK= + RTL8180= +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -70,6 +70,7 @@ config RT2800PCI + select RT2X00_LIB_MMIO + select RT2X00_LIB_PCI + select RT2X00_LIB_FIRMWARE ++ select RT2X00_LIB_EEPROM + select RT2X00_LIB_CRYPTO + depends on CRC_CCITT + depends on EEPROM_93CX6 +@@ -216,6 +217,7 @@ config RT2800SOC + select RT2X00_LIB_MMIO + select RT2X00_LIB_CRYPTO + select RT2X00_LIB_FIRMWARE ++ select RT2X00_LIB_EEPROM + select RT2800_LIB + select RT2800_LIB_MMIO + help +@@ -266,6 +268,9 @@ config RT2X00_LIB_FIRMWARE + config RT2X00_LIB_CRYPTO + bool + ++config RT2X00_LIB_EEPROM ++ bool ++ + config RT2X00_LIB_LEDS + bool + default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n) +--- a/drivers/net/wireless/ralink/rt2x00/Makefile ++++ b/drivers/net/wireless/ralink/rt2x00/Makefile +@@ -8,6 +8,7 @@ rt2x00lib-$(CPTCFG_RT2X00_LIB_DEBUGFS) + + rt2x00lib-$(CPTCFG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o + rt2x00lib-$(CPTCFG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o + rt2x00lib-$(CPTCFG_RT2X00_LIB_LEDS) += rt2x00leds.o ++rt2x00lib-$(CPTCFG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o + + obj-$(CPTCFG_RT2X00_LIB) += rt2x00lib.o + obj-$(CPTCFG_RT2X00_LIB_MMIO) += rt2x00mmio.o +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +@@ -37,6 +37,8 @@ struct rt2800_drv_data { + struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE]; + }; + ++#include "rt2800.h" ++ + struct rt2800_ops { + u32 (*register_read)(struct rt2x00_dev *rt2x00dev, + const unsigned int offset); +@@ -135,6 +137,15 @@ static inline int rt2800_read_eeprom(str + { + const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; + ++ if (rt2x00dev->eeprom_file) { ++ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, ++ EEPROM_SIZE); ++ return 0; ++ } ++ ++ if (!rt2800ops->read_eeprom) ++ return -EINVAL; ++ + return rt2800ops->read_eeprom(rt2x00dev); + } + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +@@ -90,19 +90,6 @@ static int rt2800soc_set_device_state(st + return retval; + } + +-static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev) +-{ +- void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); +- +- if (!base_addr) +- return -ENOMEM; +- +- memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); +- +- iounmap(base_addr); +- return 0; +-} +- + /* Firmware functions */ + static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev) + { +@@ -167,7 +154,6 @@ static const struct rt2800_ops rt2800soc + .register_multiread = rt2x00mmio_register_multiread, + .register_multiwrite = rt2x00mmio_register_multiwrite, + .regbusy_read = rt2x00mmio_regbusy_read, +- .read_eeprom = rt2800soc_read_eeprom, + .hwcrypt_disabled = rt2800soc_hwcrypt_disabled, + .drv_write_firmware = rt2800soc_write_firmware, + .drv_init_registers = rt2800mmio_init_registers, +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -694,6 +694,7 @@ enum rt2x00_capability_flags { + REQUIRE_HT_TX_DESC, + REQUIRE_PS_AUTOWAKE, + REQUIRE_DELAYED_RFKILL, ++ REQUIRE_EEPROM_FILE, + + /* + * Capabilities +@@ -970,6 +971,11 @@ struct rt2x00_dev { + const struct firmware *fw; + + /* ++ * EEPROM image. ++ */ ++ const struct firmware *eeprom_file; ++ ++ /* + * FIFO for storing tx status reports between isr and tasklet. + */ + DECLARE_KFIFO_PTR(txstatus_fifo, u32); +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1407,6 +1407,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de + INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); + INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep); + ++ retval = rt2x00lib_load_eeprom_file(rt2x00dev); ++ if (retval) ++ goto exit; ++ + /* + * Let the driver probe the device to detect the capabilities. + */ +@@ -1550,6 +1554,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ + * Free the driver data. + */ + kfree(rt2x00dev->drv_data); ++ ++ /* ++ * Free EEPROM image. ++ */ ++ rt2x00lib_free_eeprom_file(rt2x00dev); + } + EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); + +--- /dev/null ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -0,0 +1,106 @@ ++/* ++ Copyright (C) 2004 - 2009 Ivo van Doorn ++ Copyright (C) 2004 - 2009 Gertjan van Wingerde ++ ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the ++ Free Software Foundation, Inc., ++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++/* ++ Module: rt2x00lib ++ Abstract: rt2x00 eeprom file loading routines. ++ */ ++ ++#include ++#include ++ ++#include "rt2x00.h" ++#include "rt2x00lib.h" ++ ++static const char * ++rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) ++{ ++ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data; ++ ++ if (pdata && pdata->eeprom_file_name) ++ return pdata->eeprom_file_name; ++ ++ return NULL ++} ++ ++static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ const struct firmware *ee; ++ const char *ee_name; ++ int retval; ++ ++ ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev); ++ if (!ee_name && test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) { ++ rt2x00_err(rt2x00dev, "Required EEPROM name is missing."); ++ return -EINVAL; ++ } ++ ++ if (!ee_name) ++ return 0; ++ ++ rt2x00_info(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name); ++ ++ retval = request_firmware(&ee, ee_name, rt2x00dev->dev); ++ if (retval) { ++ rt2x00_err(rt2x00dev, "Failed to request EEPROM.\n"); ++ return retval; ++ } ++ ++ if (!ee || !ee->size || !ee->data) { ++ rt2x00_err(rt2x00dev, "Failed to read EEPROM file.\n"); ++ retval = -ENOENT; ++ goto err_exit; ++ } ++ ++ if (ee->size != rt2x00dev->ops->eeprom_size) { ++ rt2x00_err(rt2x00dev, ++ "EEPROM file size is invalid, it should be %d bytes\n", ++ rt2x00dev->ops->eeprom_size); ++ retval = -EINVAL; ++ goto err_release_ee; ++ } ++ ++ rt2x00dev->eeprom_file = ee; ++ return 0; ++ ++err_release_ee: ++ release_firmware(ee); ++err_exit: ++ return retval; ++} ++ ++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ int retval; ++ ++ retval = rt2x00lib_request_eeprom_file(rt2x00dev); ++ if (retval) ++ return retval; ++ ++ return 0; ++} ++ ++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ if (rt2x00dev->eeprom_file && rt2x00dev->eeprom_file->size) ++ release_firmware(rt2x00dev->eeprom_file); ++ rt2x00dev->eeprom_file = NULL; ++} +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h +@@ -286,6 +286,22 @@ static inline void rt2x00lib_free_firmwa + #endif /* CPTCFG_RT2X00_LIB_FIRMWARE */ + + /* ++ * EEPROM file handlers. ++ */ ++#ifdef CPTCFG_RT2X00_LIB_EEPROM ++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev); ++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev); ++#else ++static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ return 0; ++} ++static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++} ++#endif /* CPTCFG_RT2X00_LIB_EEPROM */ ++ ++/* + * Debugfs handlers. + */ + #ifdef CPTCFG_RT2X00_LIB_DEBUGFS +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c +@@ -86,6 +86,7 @@ int rt2x00soc_probe(struct platform_devi + if (IS_ERR(rt2x00dev->clk)) + rt2x00dev->clk = NULL; + ++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags); + rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); + + retval = rt2x00soc_alloc_reg(rt2x00dev); diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch new file mode 100644 index 000000000..9dffef181 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch @@ -0,0 +1,33 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -26,6 +26,7 @@ + + #include + #include ++#include + + #include "rt2x00.h" + #include "rt2x00lib.h" +@@ -34,11 +35,21 @@ static const char * + rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) + { + struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data; ++#ifdef CONFIG_OF ++ struct device_node *np; ++ const char *eep; ++#endif + + if (pdata && pdata->eeprom_file_name) + return pdata->eeprom_file_name; + +- return NULL ++#ifdef CONFIG_OF ++ np = rt2x00dev->dev->of_node; ++ if (np && of_property_read_string(np, "ralink,eeprom", &eep) == 0) ++ return eep; ++#endif ++ ++ return NULL; + } + + static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev) diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch new file mode 100644 index 000000000..7338eb15b --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch @@ -0,0 +1,113 @@ +From 339fe73f340161a624cc08e738d2244814852c3e Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Sun, 17 Mar 2013 00:55:04 +0100 +Subject: [PATCH] rt2x00: load eeprom on SoC from a mtd device defines inside + OF + +Signed-off-by: John Crispin +--- + drivers/net/wireless/ralink/rt2x00/Kconfig | 1 + + drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 65 +++++++++++++++++++++++ + 2 files changed, 66 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -220,6 +220,7 @@ config RT2800SOC + select RT2X00_LIB_EEPROM + select RT2800_LIB + select RT2800_LIB_MMIO ++ select MTD if SOC_RT288X || SOC_RT305X + help + This adds support for Ralink WiSoC devices. + Supported chips: RT2880, RT3050, RT3052, RT3350, RT3352. +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -26,11 +26,76 @@ + + #include + #include ++#if IS_ENABLED(CONFIG_MTD) ++#include ++#include ++#endif + #include + + #include "rt2x00.h" + #include "rt2x00lib.h" + ++#if IS_ENABLED(CONFIG_MTD) ++static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev) ++{ ++ int ret = -EINVAL; ++#ifdef CONFIG_OF ++ static struct firmware mtd_fw; ++ struct device_node *np = rt2x00dev->dev->of_node, *mtd_np = NULL; ++ size_t retlen, len = rt2x00dev->ops->eeprom_size; ++ int i, size, offset = 0; ++ struct mtd_info *mtd; ++ const char *part; ++ const __be32 *list; ++ phandle phandle; ++ ++ list = of_get_property(np, "ralink,mtd-eeprom", &size); ++ if (!list) ++ return -ENOENT; ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ if (!mtd_np) { ++ dev_err(rt2x00dev->dev, "failed to load mtd phandle\n"); ++ return -EINVAL; ++ } ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) { ++ dev_err(rt2x00dev->dev, "failed to get mtd device \"%s\"\n", part); ++ return PTR_ERR(mtd); ++ } ++ ++ if (size > sizeof(*list)) ++ offset = be32_to_cpup(list); ++ ++ ret = mtd_read(mtd, offset, len, &retlen, (u_char *) rt2x00dev->eeprom); ++ put_mtd_device(mtd); ++ ++ if ((retlen != rt2x00dev->ops->eeprom_size) || ret) { ++ dev_err(rt2x00dev->dev, "failed to load eeprom from device \"%s\"\n", part); ++ return ret; ++ } ++ ++ if (of_find_property(np, "ralink,mtd-eeprom-swap", NULL)) ++ for (i = 0; i < len/sizeof(u16); i++) ++ rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]); ++ ++ rt2x00dev->eeprom_file = &mtd_fw; ++ mtd_fw.data = (const u8 *) rt2x00dev->eeprom; ++ ++ dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part); ++#endif ++ ++ return ret; ++} ++#endif ++ + static const char * + rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) + { +@@ -58,6 +123,11 @@ static int rt2x00lib_request_eeprom_file + const char *ee_name; + int retval; + ++#if IS_ENABLED(CONFIG_MTD) ++ if (!rt2800lib_read_eeprom_mtd(rt2x00dev)) ++ return 0; ++#endif ++ + ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev); + if (!ee_name && test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) { + rt2x00_err(rt2x00dev, "Required EEPROM name is missing."); diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch new file mode 100644 index 000000000..6a8e594d5 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch @@ -0,0 +1,47 @@ +--- a/include/linux/rt2x00_platform.h ++++ b/include/linux/rt2x00_platform.h +@@ -14,6 +14,9 @@ + + struct rt2x00_platform_data { + char *eeprom_file_name; ++ ++ int disable_2ghz; ++ int disable_5ghz; + }; + + #endif /* _RT2X00_PLATFORM_H */ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1012,6 +1012,22 @@ static int rt2x00lib_probe_hw_modes(stru + unsigned int num_rates; + unsigned int i; + ++ if (rt2x00dev->dev->platform_data) { ++ struct rt2x00_platform_data *pdata; ++ ++ pdata = rt2x00dev->dev->platform_data; ++ if (pdata->disable_2ghz) ++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ; ++ if (pdata->disable_5ghz) ++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ; ++ } ++ ++ if ((spec->supported_bands & SUPPORT_BAND_BOTH) == 0) { ++ rt2x00_err(rt2x00dev, "No supported bands\n"); ++ return -EINVAL; ++ } ++ ++ + num_rates = 0; + if (spec->supported_rates & SUPPORT_RATE_CCK) + num_rates += 4; +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -399,6 +399,7 @@ struct hw_mode_spec { + unsigned int supported_bands; + #define SUPPORT_BAND_2GHZ 0x00000001 + #define SUPPORT_BAND_5GHZ 0x00000002 ++#define SUPPORT_BAND_BOTH (SUPPORT_BAND_2GHZ | SUPPORT_BAND_5GHZ) + + unsigned int supported_rates; + #define SUPPORT_RATE_CCK 0x00000001 diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch new file mode 100644 index 000000000..b5b2c6103 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch @@ -0,0 +1,26 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -990,8 +990,13 @@ static void rt2x00lib_rate(struct ieee80 + + void rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr) + { ++ struct rt2x00_platform_data *pdata; + const char *mac_addr; + ++ pdata = rt2x00dev->dev->platform_data; ++ if (pdata && pdata->mac_address) ++ ether_addr_copy(eeprom_mac_addr, pdata->mac_address); ++ + mac_addr = of_get_mac_address(rt2x00dev->dev->of_node); + if (!IS_ERR(mac_addr)) + ether_addr_copy(eeprom_mac_addr, mac_addr); +--- a/include/linux/rt2x00_platform.h ++++ b/include/linux/rt2x00_platform.h +@@ -14,6 +14,7 @@ + + struct rt2x00_platform_data { + char *eeprom_file_name; ++ const u8 *mac_address; + + int disable_2ghz; + int disable_5ghz; diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch new file mode 100644 index 000000000..ff8b2c947 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch @@ -0,0 +1,19 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1016,6 +1016,16 @@ static int rt2x00lib_probe_hw_modes(stru + struct ieee80211_rate *rates; + unsigned int num_rates; + unsigned int i; ++#ifdef CONFIG_OF ++ struct device_node *np = rt2x00dev->dev->of_node; ++ unsigned int enabled; ++ if (!of_property_read_u32(np, "ralink,2ghz", ++ &enabled) && !enabled) ++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ; ++ if (!of_property_read_u32(np, "ralink,5ghz", ++ &enabled) && !enabled) ++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ; ++#endif /* CONFIG_OF */ + + if (rt2x00dev->dev->platform_data) { + struct rt2x00_platform_data *pdata; diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch new file mode 100644 index 000000000..38f8b7717 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch @@ -0,0 +1,33 @@ +From 04dbd87265f6ba4a373b211ba324b437d224fb2d Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Sun, 17 Mar 2013 00:03:31 +0100 +Subject: [PATCH 21/38] rt2x00: make wmac loadable via OF on rt288x/305x SoC + +This patch ads the match table to allow loading the wmac support from a +devicetree. + +Signed-off-by: John Crispin +--- + drivers/net/wireless/ralink/rt2x00/rt2800pci.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +@@ -224,10 +224,17 @@ static int rt2800soc_probe(struct platfo + return rt2x00soc_probe(pdev, &rt2800soc_ops); + } + ++static const struct of_device_id rt2880_wmac_match[] = { ++ { .compatible = "ralink,rt2880-wmac" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, rt2880_wmac_match); ++ + static struct platform_driver rt2800soc_driver = { + .driver = { + .name = "rt2800_wmac", + .mod_name = KBUILD_MODNAME, ++ .of_match_table = rt2880_wmac_match, + }, + .probe = rt2800soc_probe, + .remove = rt2x00soc_remove, diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch new file mode 100644 index 000000000..039c6f6af --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch @@ -0,0 +1,40 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #include "rt2x00.h" + #include "rt2800lib.h" +@@ -9530,6 +9531,17 @@ static int rt2800_init_eeprom(struct rt2 + rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); + rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); + ++ { ++ struct device_node *np = rt2x00dev->dev->of_node; ++ unsigned int led_polarity; ++ ++ /* Allow overriding polarity from OF */ ++ if (!of_property_read_u32(np, "ralink,led-polarity", ++ &led_polarity)) ++ rt2x00_set_field16(&eeprom, EEPROM_FREQ_LED_POLARITY, ++ led_polarity); ++ } ++ + rt2x00dev->led_mcu_reg = eeprom; + #endif /* CPTCFG_RT2X00_LIB_LEDS */ + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c +@@ -98,6 +98,9 @@ static int rt2x00leds_register_led(struc + led->led_dev.name = name; + led->led_dev.brightness = LED_OFF; + ++ if (rt2x00_is_soc(rt2x00dev)) ++ led->led_dev.brightness_set(&led->led_dev, LED_OFF); ++ + retval = led_classdev_register(device, &led->led_dev); + if (retval) { + rt2x00_err(rt2x00dev, "Failed to register led handler\n"); diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch new file mode 100644 index 000000000..15f46fc98 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1345,7 +1345,7 @@ static inline void rt2x00lib_set_if_comb + */ + if_limit = &rt2x00dev->if_limits_ap; + if_limit->max = rt2x00dev->ops->max_ap_intf; +- if_limit->types = BIT(NL80211_IFTYPE_AP); ++ if_limit->types = BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_STATION); + #ifdef CPTCFG_MAC80211_MESH + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT); + #endif diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch new file mode 100644 index 000000000..70f8d06e2 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch @@ -0,0 +1,44 @@ +From: David Bauer +Date: Mon, 16 Dec 2019 20:47:06 +0100 +Subject: [PATCH] rt2x00: add throughput LED trigger + +This adds a (currently missing) throughput LED trigger for the rt2x00 +driver. Previously, LED triggers had to be assigned to the netdev, which +was limited to a single VAP. + +Signed-off-by: David Bauer +Tested-by: Christoph Krapp + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1129,6 +1129,19 @@ static void rt2x00lib_remove_hw(struct r + kfree(rt2x00dev->spec.channels_info); + } + ++static const struct ieee80211_tpt_blink rt2x00_tpt_blink[] = { ++ { .throughput = 0 * 1024, .blink_time = 334 }, ++ { .throughput = 1 * 1024, .blink_time = 260 }, ++ { .throughput = 2 * 1024, .blink_time = 220 }, ++ { .throughput = 5 * 1024, .blink_time = 190 }, ++ { .throughput = 10 * 1024, .blink_time = 170 }, ++ { .throughput = 25 * 1024, .blink_time = 150 }, ++ { .throughput = 54 * 1024, .blink_time = 130 }, ++ { .throughput = 120 * 1024, .blink_time = 110 }, ++ { .throughput = 265 * 1024, .blink_time = 80 }, ++ { .throughput = 586 * 1024, .blink_time = 50 }, ++}; ++ + static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) + { + struct hw_mode_spec *spec = &rt2x00dev->spec; +@@ -1211,6 +1224,10 @@ static int rt2x00lib_probe_hw(struct rt2 + + #undef RT2X00_TASKLET_INIT + ++ ieee80211_create_tpt_led_trigger(rt2x00dev->hw, ++ IEEE80211_TPT_LEDTRIG_FL_RADIO, rt2x00_tpt_blink, ++ ARRAY_SIZE(rt2x00_tpt_blink)); ++ + /* + * Register HW. + */ diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch new file mode 100644 index 000000000..20452cd8a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch @@ -0,0 +1,107 @@ +From 9782a7f7488443568fa4d6088b73c9aff7eb8510 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 19 Apr 2017 16:14:53 +0200 +Subject: [PATCH] rt2x00: add support for external PA on MT7620 +To: Stanislaw Gruszka +Cc: Helmut Schaa , + linux-wireless@vger.kernel.org, + Kalle Valo +Content-Type: text/plain; charset="UTF-8" +Content-Transfer-Encoding: quoted-printable + +Signed-off-by: Daniel Golle +Signed-off-by: Tomislav Po=C5=BEega +[pozega.tomislav@gmail.com: use chanreg and dccal helpers.] + +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 + + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 70 +++++++++++++++++++++++++- + 2 files changed, 70 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -2739,6 +2739,7 @@ enum rt2800_eeprom_word { + #define EEPROM_NIC_CONF2_RX_STREAM FIELD16(0x000f) + #define EEPROM_NIC_CONF2_TX_STREAM FIELD16(0x00f0) + #define EEPROM_NIC_CONF2_CRYSTAL FIELD16(0x0600) ++#define EEPROM_NIC_CONF2_EXTERNAL_PA FIELD16(0xc000) + + /* + * EEPROM LNA +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -4356,6 +4356,45 @@ static void rt2800_config_channel(struct + rt2800_iq_calibrate(rt2x00dev, rf->channel); + } + ++ if (rt2x00_rt(rt2x00dev, RT6352)) { ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, ++ &rt2x00dev->cap_flags)) { ++ rt2x00_warn(rt2x00dev, "Using incomplete support for " \ ++ "external PA\n"); ++ reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ reg |= 0x00000101; ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, reg); ++ ++ reg = rt2800_register_read(rt2x00dev, RF_BYPASS3); ++ reg |= 0x00000101; ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); ++ ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0xC8); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xA4); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x05); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xC8); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xA4); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x05); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x27); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0xC8); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xA4); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x05); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00); ++ ++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, ++ 0x36303636); ++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, ++ 0x6C6C6B6C); ++ rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, ++ 0x6C6C6B6C); ++ } ++ } ++ + bbp = rt2800_bbp_read(rt2x00dev, 4); + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf)); + rt2800_bbp_write(rt2x00dev, 4, bbp); +@@ -9559,7 +9598,8 @@ static int rt2800_init_eeprom(struct rt2 + */ + eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1); + +- if (rt2x00_rt(rt2x00dev, RT3352)) { ++ if (rt2x00_rt(rt2x00dev, RT3352) || ++ rt2x00_rt(rt2x00dev, RT6352)) { + if (rt2x00_get_field16(eeprom, + EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352)) + __set_bit(CAPABILITY_EXTERNAL_PA_TX0, +@@ -9570,6 +9610,18 @@ static int rt2800_init_eeprom(struct rt2 + &rt2x00dev->cap_flags); + } + ++ eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF2); ++ ++ if (rt2x00_rt(rt2x00dev, RT6352) && eeprom != 0 && eeprom != 0xffff) { ++ if (rt2x00_get_field16(eeprom, ++ EEPROM_NIC_CONF2_EXTERNAL_PA)) { ++ __set_bit(CAPABILITY_EXTERNAL_PA_TX0, ++ &rt2x00dev->cap_flags); ++ __set_bit(CAPABILITY_EXTERNAL_PA_TX1, ++ &rt2x00dev->cap_flags); ++ } ++ } ++ + return 0; + } + diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch new file mode 100644 index 000000000..6be847478 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch @@ -0,0 +1,67 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8419,6 +8419,56 @@ static void rt2800_init_rfcsr_5592(struc + rt2800_led_open_drain_enable(rt2x00dev); + } + ++static void rt2800_rf_self_txdc_cal(struct rt2x00_dev *rt2x00dev) ++{ ++ u8 rfb5r1_org, rfb7r1_org, rfvalue; ++ u32 mac0518, mac051c, mac0528, mac052c; ++ u8 i; ++ ++ rt2x00_info(rt2x00dev, "RF Tx self calibration start\n"); ++ mac0518 = rt2800_register_read(rt2x00dev, RF_CONTROL0); ++ mac051c = rt2800_register_read(rt2x00dev, RF_BYPASS0); ++ mac0528 = rt2800_register_read(rt2x00dev, RF_CONTROL2); ++ mac052c = rt2800_register_read(rt2x00dev, RF_BYPASS2); ++ ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x0); ++ rt2800_register_write(rt2x00dev, RF_BYPASS2, 0x0); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0xC); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x3306); ++ rt2800_register_write(rt2x00dev, RF_CONTROL2, 0x3330); ++ rt2800_register_write(rt2x00dev, RF_BYPASS2, 0xfffff); ++ rfb5r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); ++ rfb7r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, 0x4); ++ for (i = 0; i < 100; i = i + 1) { ++ udelay(50); ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); ++ if((rfvalue & 0x04) != 0x4) ++ break; ++ } ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, rfb5r1_org); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 1, 0x4); ++ for (i = 0; i < 100; i = i + 1) { ++ udelay(50); ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1); ++ if((rfvalue & 0x04) != 0x4) ++ break; ++ } ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 1, rfb7r1_org); ++ ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x0); ++ rt2800_register_write(rt2x00dev, RF_BYPASS2, 0x0); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, mac0518); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, mac051c); ++ rt2800_register_write(rt2x00dev, RF_CONTROL2, mac0528); ++ rt2800_register_write(rt2x00dev, RF_BYPASS2, mac052c); ++ ++ rt2x00_info(rt2x00dev, "RF Tx self calibration end\n"); ++} ++ + static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, + bool set_bw, bool is_ht40) + { +@@ -9026,6 +9076,7 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); + ++ rt2800_rf_self_txdc_cal(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch new file mode 100644 index 000000000..3ed0ff7ef --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch @@ -0,0 +1,166 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8469,6 +8469,155 @@ static void rt2800_rf_self_txdc_cal(stru + rt2x00_info(rt2x00dev, "RF Tx self calibration end\n"); + } + ++static int rt2800_calcrcalibrationcode(struct rt2x00_dev *rt2x00dev, int d1, int d2) ++{ ++ int calcode; ++ calcode = ((d2 - d1) * 1000) / 43; ++ if ((calcode%10) >= 5) ++ calcode += 10; ++ calcode = (calcode / 10); ++ ++ return calcode; ++} ++ ++static void rt2800_r_calibration(struct rt2x00_dev *rt2x00dev) ++{ ++ u32 savemacsysctrl; ++ u8 saverfb0r1, saverfb0r34, saverfb0r35; ++ u8 saverfb5r4, saverfb5r17, saverfb5r18; ++ u8 saverfb5r19, saverfb5r20; ++ u8 savebbpr22, savebbpr47, savebbpr49; ++ u8 bytevalue = 0; ++ int rcalcode; ++ u8 r_cal_code = 0; ++ char d1 = 0, d2 = 0; ++ u8 rfvalue; ++ u32 MAC_RF_BYPASS0, MAC_RF_CONTROL0, MAC_PWR_PIN_CFG; ++ u32 maccfg, macstatus; ++ int i; ++ ++ saverfb0r1 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 1); ++ saverfb0r34 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 34); ++ saverfb0r35 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 35); ++ saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); ++ saverfb5r17 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); ++ saverfb5r18 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); ++ saverfb5r19 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); ++ saverfb5r20 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); ++ ++ savebbpr22 = rt2800_bbp_read(rt2x00dev, 22); ++ savebbpr47 = rt2800_bbp_read(rt2x00dev, 47); ++ savebbpr49 = rt2800_bbp_read(rt2x00dev, 49); ++ ++ savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ MAC_RF_BYPASS0 = rt2800_register_read(rt2x00dev, RF_BYPASS0); ++ MAC_RF_CONTROL0 = rt2800_register_read(rt2x00dev, RF_CONTROL0); ++ MAC_PWR_PIN_CFG = rt2800_register_read(rt2x00dev, PWR_PIN_CFG); ++ ++ maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ maccfg &= (~0x04); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); ++ ++ for (i = 0; i < 10000; i++) { ++ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macstatus & 0x1) ++ udelay(50); ++ else ++ break; ++ } ++ ++ if (i == 10000) ++ rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n"); ++ ++ maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ maccfg &= (~0x04); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); ++ ++ for (i = 0; i < 10000; i++) { ++ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macstatus & 0x2) ++ udelay(50); ++ else ++ break; ++ } ++ ++ if (i == 10000) ++ rt2x00_warn(rt2x00dev, "Wait MAC Rx Status to MAX !!!\n"); ++ ++ rfvalue = (MAC_RF_BYPASS0 | 0x3004); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, rfvalue); ++ rfvalue = (MAC_RF_CONTROL0 | (~0x3002)); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, rfvalue); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, 0x27); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, 0x80); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0x83); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0x00); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x20); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, 0x00); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 34, 0x13); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 35, 0x00); ++ ++ rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x1); ++ ++ rt2800_bbp_write(rt2x00dev, 47, 0x04); ++ rt2800_bbp_write(rt2x00dev, 22, 0x80); ++ udelay(100); ++ bytevalue = rt2800_bbp_read(rt2x00dev, 49); ++ if (bytevalue > 128) ++ d1 = bytevalue - 256; ++ else ++ d1 = (char)bytevalue; ++ rt2800_bbp_write(rt2x00dev, 22, 0x0); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 35, 0x01); ++ ++ rt2800_bbp_write(rt2x00dev, 22, 0x80); ++ udelay(100); ++ bytevalue = rt2800_bbp_read(rt2x00dev, 49); ++ if (bytevalue > 128) ++ d2 = bytevalue - 256; ++ else ++ d2 = (char)bytevalue; ++ rt2800_bbp_write(rt2x00dev, 22, 0x0); ++ ++ rcalcode = rt2800_calcrcalibrationcode(rt2x00dev, d1, d2); ++ if (rcalcode < 0) ++ r_cal_code = 256 + rcalcode; ++ else ++ r_cal_code = (u8)rcalcode; ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 7, r_cal_code); ++ ++ rt2800_bbp_write(rt2x00dev, 22, 0x0); ++ ++ bytevalue = rt2800_bbp_read(rt2x00dev, 21); ++ bytevalue |= 0x1; ++ rt2800_bbp_write(rt2x00dev, 21, bytevalue); ++ bytevalue = rt2800_bbp_read(rt2x00dev, 21); ++ bytevalue &= (~0x1); ++ rt2800_bbp_write(rt2x00dev, 21, bytevalue); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, saverfb0r1); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 34, saverfb0r34); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 35, saverfb0r35); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, saverfb5r17); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, saverfb5r18); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, saverfb5r19); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, saverfb5r20); ++ ++ rt2800_bbp_write(rt2x00dev, 22, savebbpr22); ++ rt2800_bbp_write(rt2x00dev, 47, savebbpr47); ++ rt2800_bbp_write(rt2x00dev, 49, savebbpr49); ++ ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, MAC_RF_BYPASS0); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, MAC_RF_CONTROL0); ++ ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); ++ rt2800_register_write(rt2x00dev, PWR_PIN_CFG, MAC_PWR_PIN_CFG); ++} ++ + static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, + bool set_bw, bool is_ht40) + { +@@ -9076,6 +9225,7 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); + ++ rt2800_r_calibration(rt2x00dev); + rt2800_rf_self_txdc_cal(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch new file mode 100644 index 000000000..77be986d1 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch @@ -0,0 +1,81 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8618,6 +8618,70 @@ static void rt2800_r_calibration(struct + rt2800_register_write(rt2x00dev, PWR_PIN_CFG, MAC_PWR_PIN_CFG); + } + ++static void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev) ++{ ++ u8 bbpreg = 0; ++ u32 macvalue = 0, macvalue1 = 0; ++ u8 saverfb0r2, saverfb5r4, saverfb7r4, rfvalue; ++ int i; ++ ++ saverfb0r2 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 2); ++ rfvalue = saverfb0r2; ++ rfvalue |= 0x03; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, rfvalue); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 141); ++ bbpreg = rt2800_bbp_read(rt2x00dev, 159); ++ bbpreg |= 0x10; ++ rt2800_bbp_write(rt2x00dev, 159, bbpreg); ++ ++ macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x8); ++ ++ for (i = 0; i < 10000; i++) { ++ macvalue1 = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macvalue1 & 0x1) ++ udelay(50); ++ else ++ break; ++ } ++ ++ saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0); ++ saverfb7r4 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4); ++ saverfb5r4 = saverfb5r4 & (~0x40); ++ saverfb7r4 = saverfb7r4 & (~0x40); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x64); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 4, saverfb7r4); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 141); ++ bbpreg = rt2800_bbp_read(rt2x00dev, 159); ++ bbpreg = bbpreg & (~0x40); ++ rt2800_bbp_write(rt2x00dev, 159, bbpreg); ++ bbpreg |= 0x48; ++ rt2800_bbp_write(rt2x00dev, 159, bbpreg); ++ ++ for (i = 0; i < 10000; i++) { ++ bbpreg = rt2800_bbp_read(rt2x00dev, 159); ++ if ((bbpreg & 0x40)==0) ++ break; ++ udelay(50); ++ } ++ ++ bbpreg = rt2800_bbp_read(rt2x00dev, 159); ++ bbpreg = bbpreg & (~0x40); ++ rt2800_bbp_write(rt2x00dev, 159, bbpreg); ++ ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 141); ++ bbpreg = rt2800_bbp_read(rt2x00dev, 159); ++ bbpreg &= (~0x10); ++ rt2800_bbp_write(rt2x00dev, 159, bbpreg); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, saverfb0r2); ++} ++ + static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, + bool set_bw, bool is_ht40) + { +@@ -9227,6 +9291,7 @@ static void rt2800_init_rfcsr_6352(struc + + rt2800_r_calibration(rt2x00dev); + rt2800_rf_self_txdc_cal(rt2x00dev); ++ rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch new file mode 100644 index 000000000..7352ad036 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch @@ -0,0 +1,395 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8682,6 +8682,384 @@ static void rt2800_rxdcoc_calibration(st + rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, saverfb0r2); + } + ++static u32 rt2800_do_sqrt_accumulation(u32 si) { ++ u32 root, root_pre, bit; ++ char i; ++ bit = 1 << 15; ++ root = 0; ++ for (i = 15; i >= 0; i = i - 1) { ++ root_pre = root + bit; ++ if ((root_pre*root_pre) <= si) ++ root = root_pre; ++ bit = bit >> 1; ++ } ++ ++ return root; ++} ++ ++static void rt2800_rxiq_calibration(struct rt2x00_dev *rt2x00dev) { ++ u8 rfb0r1, rfb0r2, rfb0r42; ++ u8 rfb4r0, rfb4r19; ++ u8 rfb5r3, rfb5r4, rfb5r17, rfb5r18, rfb5r19, rfb5r20; ++ u8 rfb6r0, rfb6r19; ++ u8 rfb7r3, rfb7r4, rfb7r17, rfb7r18, rfb7r19, rfb7r20; ++ ++ u8 bbp1, bbp4; ++ u8 bbpr241, bbpr242; ++ u32 i; ++ u8 ch_idx; ++ u8 bbpval; ++ u8 rfval, vga_idx = 0; ++ int mi = 0, mq = 0, si = 0, sq = 0, riq = 0; ++ int sigma_i, sigma_q, r_iq, g_rx; ++ int g_imb; ++ int ph_rx; ++ u32 savemacsysctrl = 0; ++ u32 orig_RF_CONTROL0 = 0; ++ u32 orig_RF_BYPASS0 = 0; ++ u32 orig_RF_CONTROL1 = 0; ++ u32 orig_RF_BYPASS1 = 0; ++ u32 orig_RF_CONTROL3 = 0; ++ u32 orig_RF_BYPASS3 = 0; ++ u32 macstatus, bbpval1 = 0; ++ u8 rf_vga_table[] = {0x20, 0x21, 0x22, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}; ++ ++ savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ orig_RF_CONTROL0 = rt2800_register_read(rt2x00dev, RF_CONTROL0); ++ orig_RF_BYPASS0 = rt2800_register_read(rt2x00dev, RF_BYPASS0); ++ orig_RF_CONTROL1 = rt2800_register_read(rt2x00dev, RF_CONTROL1); ++ orig_RF_BYPASS1 = rt2800_register_read(rt2x00dev, RF_BYPASS1); ++ orig_RF_CONTROL3 = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ orig_RF_BYPASS3 = rt2800_register_read(rt2x00dev, RF_BYPASS3); ++ ++ bbp1 = rt2800_bbp_read(rt2x00dev, 1); ++ bbp4 = rt2800_bbp_read(rt2x00dev, 4); ++ ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x0); ++ ++ for (i = 0; i < 10000; i++) { ++ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macstatus & 0x3) ++ udelay(50); ++ else ++ break; ++ } ++ ++ if (i == 10000) ++ rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n"); ++ ++ bbpval = bbp4 & (~0x18); ++ bbpval = bbp4 | 0x00; ++ rt2800_bbp_write(rt2x00dev, 4, bbpval); ++ ++ bbpval = rt2800_bbp_read(rt2x00dev, 21); ++ bbpval = bbpval | 1; ++ rt2800_bbp_write(rt2x00dev, 21, bbpval); ++ bbpval = bbpval & 0xfe; ++ rt2800_bbp_write(rt2x00dev, 21, bbpval); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL1, 0x00000202); ++ rt2800_register_write(rt2x00dev, RF_BYPASS1, 0x00000303); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0101); ++ else ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0000); ++ ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, 0xf1f1); ++ ++ rfb0r1 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 1); ++ rfb0r2 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 2); ++ rfb0r42 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 42); ++ rfb4r0 = rt2800_rfcsr_read_bank(rt2x00dev, 4, 0); ++ rfb4r19 = rt2800_rfcsr_read_bank(rt2x00dev, 4, 19); ++ rfb5r3 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); ++ rfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); ++ rfb5r17 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); ++ rfb5r18 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); ++ rfb5r19 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); ++ rfb5r20 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); ++ ++ rfb6r0 = rt2800_rfcsr_read_bank(rt2x00dev, 6, 0); ++ rfb6r19 = rt2800_rfcsr_read_bank(rt2x00dev, 6, 19); ++ rfb7r3 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 3); ++ rfb7r4 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4); ++ rfb7r17 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 17); ++ rfb7r18 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 18); ++ rfb7r19 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 19); ++ rfb7r20 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 20); ++ ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 0, 0x87); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0x27); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x38); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x38); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x80); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 18, 0xC1); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 19, 0x60); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 20, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 23, 0x0); ++ rt2800_bbp_write(rt2x00dev, 24, 0x0); ++ ++ rt2800_bbp_dcoc_write(rt2x00dev, 5, 0x0); ++ ++ bbpr241 = rt2800_bbp_read(rt2x00dev, 241); ++ bbpr242 = rt2800_bbp_read(rt2x00dev, 242); ++ ++ rt2800_bbp_write(rt2x00dev, 241, 0x10); ++ rt2800_bbp_write(rt2x00dev, 242, 0x84); ++ rt2800_bbp_write(rt2x00dev, 244, 0x31); ++ ++ bbpval = rt2800_bbp_dcoc_read(rt2x00dev, 3); ++ bbpval = bbpval & (~0x7); ++ rt2800_bbp_dcoc_write(rt2x00dev, 3, bbpval); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000004); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000006); ++ usleep_range(1, 200); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x00003376); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00001006); ++ udelay(1); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_bbp_write(rt2x00dev, 23, 0x06); ++ rt2800_bbp_write(rt2x00dev, 24, 0x06); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 23, 0x02); ++ rt2800_bbp_write(rt2x00dev, 24, 0x02); ++ } ++ ++ for (ch_idx = 0; ch_idx < 2; ch_idx = ch_idx + 1) { ++ if (ch_idx == 0) { ++ rfval = rfb0r1 & (~0x3); ++ rfval = rfb0r1 | 0x1; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, rfval); ++ rfval = rfb0r2 & (~0x33); ++ rfval = rfb0r2 | 0x11; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, rfval); ++ rfval = rfb0r42 & (~0x50); ++ rfval = rfb0r42 | 0x10; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, rfval); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00001006); ++ udelay(1); ++ ++ bbpval = bbp1 & (~ 0x18); ++ bbpval = bbpval | 0x00; ++ rt2800_bbp_write(rt2x00dev, 1, bbpval); ++ ++ rt2800_bbp_dcoc_write(rt2x00dev, 1, 0x00); ++ } else { ++ rfval = rfb0r1 & (~0x3); ++ rfval = rfb0r1 | 0x2; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, rfval); ++ rfval = rfb0r2 & (~0x33); ++ rfval = rfb0r2 | 0x22; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, rfval); ++ rfval = rfb0r42 & (~0x50); ++ rfval = rfb0r42 | 0x40; ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, rfval); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00002006); ++ udelay(1); ++ ++ bbpval = bbp1 & (~ 0x18); ++ bbpval = bbpval | 0x08; ++ rt2800_bbp_write(rt2x00dev, 1, bbpval); ++ ++ rt2800_bbp_dcoc_write(rt2x00dev, 1, 0x01); ++ } ++ udelay(500); ++ ++ vga_idx = 0; ++ while (vga_idx < 11) { ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rf_vga_table[vga_idx]); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rf_vga_table[vga_idx]); ++ ++ rt2800_bbp_dcoc_write(rt2x00dev, 0, 0x93); ++ ++ for (i = 0; i < 10000; i++) { ++ bbpval = rt2800_bbp_read(rt2x00dev, 159); ++ if ((bbpval & 0xff) == 0x93) ++ udelay(50); ++ else ++ break; ++ } ++ ++ if ((bbpval & 0xff) == 0x93) { ++ rt2x00_warn(rt2x00dev, "Fatal Error: Calibration doesn't finish"); ++ goto restore_value; ++ } ++ ++ for (i = 0; i < 5; i++) { ++ u32 bbptemp = 0; ++ u8 value = 0; ++ int result = 0; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x1e); ++ rt2800_bbp_write(rt2x00dev, 159, i); ++ rt2800_bbp_write(rt2x00dev, 158, 0x22); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 24); ++ rt2800_bbp_write(rt2x00dev, 158, 0x21); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 16); ++ rt2800_bbp_write(rt2x00dev, 158, 0x20); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 8); ++ rt2800_bbp_write(rt2x00dev, 158, 0x1f); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + value; ++ ++ if ((i < 2) && (bbptemp & 0x800000)) ++ result = (bbptemp & 0xffffff) - 0x1000000; ++ else if (i == 4) ++ result = bbptemp; ++ else ++ result = bbptemp; ++ ++ if (i == 0) ++ mi = result/4096; ++ else if (i == 1) ++ mq = result/4096; ++ else if (i == 2) ++ si = bbptemp/4096; ++ else if (i == 3) ++ sq = bbptemp/4096; ++ else ++ riq = result/4096; ++ } ++ ++ bbpval1 = si - mi*mi; ++ rt2x00_dbg(rt2x00dev, "RXIQ si=%d, sq=%d, riq=%d, bbpval %d, vga_idx %d", si, sq, riq, bbpval1, vga_idx); ++ ++ if (bbpval1 >= (100*100)) ++ break; ++ ++ if (bbpval1 <= 100) ++ vga_idx = vga_idx + 9; ++ else if (bbpval1 <= 158) ++ vga_idx = vga_idx + 8; ++ else if (bbpval1 <= 251) ++ vga_idx = vga_idx + 7; ++ else if (bbpval1 <= 398) ++ vga_idx = vga_idx + 6; ++ else if (bbpval1 <= 630) ++ vga_idx = vga_idx + 5; ++ else if (bbpval1 <= 1000) ++ vga_idx = vga_idx + 4; ++ else if (bbpval1 <= 1584) ++ vga_idx = vga_idx + 3; ++ else if (bbpval1 <= 2511) ++ vga_idx = vga_idx + 2; ++ else ++ vga_idx = vga_idx + 1; ++ } ++ ++ sigma_i = rt2800_do_sqrt_accumulation(100*(si - mi*mi)); ++ sigma_q = rt2800_do_sqrt_accumulation(100*(sq - mq*mq)); ++ r_iq = 10*(riq-(mi*mq)); ++ ++ rt2x00_dbg(rt2x00dev, "Sigma_i=%d, Sigma_q=%d, R_iq=%d", sigma_i, sigma_q, r_iq); ++ ++ if (((sigma_i <= 1400 ) && (sigma_i >= 1000)) ++ && ((sigma_i - sigma_q) <= 112) ++ && ((sigma_i - sigma_q) >= -112) ++ && ((mi <= 32) && (mi >= -32)) ++ && ((mq <= 32) && (mq >= -32))) { ++ r_iq = 10*(riq-(mi*mq)); ++ rt2x00_dbg(rt2x00dev, "RXIQ Sigma_i=%d, Sigma_q=%d, R_iq=%d\n", sigma_i, sigma_q, r_iq); ++ ++ g_rx = (1000 * sigma_q) / sigma_i; ++ g_imb = ((-2) * 128 * (1000 - g_rx)) / (1000 + g_rx); ++ ph_rx = (r_iq * 2292) / (sigma_i * sigma_q); ++ rt2x00_info(rt2x00dev, "RXIQ G_imb=%d, Ph_rx=%d\n", g_imb, ph_rx); ++ ++ if ((ph_rx > 20) || (ph_rx < -20)) { ++ ph_rx = 0; ++ rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); ++ } ++ ++ if ((g_imb > 12) || (g_imb < -12)) { ++ g_imb = 0; ++ rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); ++ } ++ } ++ else { ++ g_imb = 0; ++ ph_rx = 0; ++ rt2x00_dbg(rt2x00dev, "RXIQ Sigma_i=%d, Sigma_q=%d, R_iq=%d\n", sigma_i, sigma_q, r_iq); ++ rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); ++ } ++ ++ if (ch_idx == 0) { ++ rt2800_bbp_write(rt2x00dev, 158, 0x37); ++ rt2800_bbp_write(rt2x00dev, 159, g_imb & 0x3f); ++ rt2800_bbp_write(rt2x00dev, 158, 0x35); ++ rt2800_bbp_write(rt2x00dev, 159, ph_rx & 0x3f); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 158, 0x55); ++ rt2800_bbp_write(rt2x00dev, 159, g_imb & 0x3f); ++ rt2800_bbp_write(rt2x00dev, 158, 0x53); ++ rt2800_bbp_write(rt2x00dev, 159, ph_rx & 0x3f); ++ } ++ } ++ ++restore_value: ++ rt2800_bbp_write(rt2x00dev, 158, 0x3); ++ bbpval = rt2800_bbp_read(rt2x00dev, 159); ++ rt2800_bbp_write(rt2x00dev, 159, (bbpval | 0x07)); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x00); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ rt2800_bbp_write(rt2x00dev, 1, bbp1); ++ rt2800_bbp_write(rt2x00dev, 4, bbp4); ++ rt2800_bbp_write(rt2x00dev, 241, bbpr241); ++ rt2800_bbp_write(rt2x00dev, 242, bbpr242); ++ ++ rt2800_bbp_write(rt2x00dev, 244, 0x00); ++ bbpval = rt2800_bbp_read(rt2x00dev, 21); ++ bbpval |= 0x1; ++ rt2800_bbp_write(rt2x00dev, 21, bbpval); ++ usleep_range(10, 200); ++ bbpval &= 0xfe; ++ rt2800_bbp_write(rt2x00dev, 21, bbpval); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, rfb0r1); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, rfb0r2); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, rfb0r42); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 4, 0, rfb4r0); ++ rt2800_rfcsr_write_bank(rt2x00dev, 4, 19, rfb4r19); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, rfb5r3); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, rfb5r4); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, rfb5r17); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, rfb5r18); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, rfb5r19); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, rfb5r20); ++ ++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 0, rfb6r0); ++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 19, rfb6r19); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 3, rfb7r3); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 4, rfb7r4); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 17, rfb7r17); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 18, rfb7r18); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 19, rfb7r19); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 20, rfb7r20); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000006); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000004); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, orig_RF_CONTROL0); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, orig_RF_BYPASS0); ++ rt2800_register_write(rt2x00dev, RF_CONTROL1, orig_RF_CONTROL1); ++ rt2800_register_write(rt2x00dev, RF_BYPASS1, orig_RF_BYPASS1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, orig_RF_CONTROL3); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, orig_RF_BYPASS3); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); ++} ++ + static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, + bool set_bw, bool is_ht40) + { +@@ -9294,6 +9672,7 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); ++ rt2800_rxiq_calibration(rt2x00dev); + } + + static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) diff --git a/feeds/wifi-ath10k/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch b/feeds/wifi-ath10k/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch new file mode 100644 index 000000000..fe0961baa --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch @@ -0,0 +1,973 @@ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9060,6 +9060,943 @@ restore_value: + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); + } + ++static void rt2800_rf_configstore(struct rt2x00_dev *rt2x00dev, rf_reg_pair rf_reg_record[][13], u8 chain) ++{ ++ u8 rfvalue = 0; ++ ++ if (chain == CHAIN_0) { ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 1); ++ rf_reg_record[CHAIN_0][0].bank = 0; ++ rf_reg_record[CHAIN_0][0].reg = 1; ++ rf_reg_record[CHAIN_0][0].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 2); ++ rf_reg_record[CHAIN_0][1].bank = 0; ++ rf_reg_record[CHAIN_0][1].reg = 2; ++ rf_reg_record[CHAIN_0][1].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 35); ++ rf_reg_record[CHAIN_0][2].bank = 0; ++ rf_reg_record[CHAIN_0][2].reg = 35; ++ rf_reg_record[CHAIN_0][2].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 42); ++ rf_reg_record[CHAIN_0][3].bank = 0; ++ rf_reg_record[CHAIN_0][3].reg = 42; ++ rf_reg_record[CHAIN_0][3].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 4, 0); ++ rf_reg_record[CHAIN_0][4].bank = 4; ++ rf_reg_record[CHAIN_0][4].reg = 0; ++ rf_reg_record[CHAIN_0][4].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 4, 2); ++ rf_reg_record[CHAIN_0][5].bank = 4; ++ rf_reg_record[CHAIN_0][5].reg = 2; ++ rf_reg_record[CHAIN_0][5].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 4, 34); ++ rf_reg_record[CHAIN_0][6].bank = 4; ++ rf_reg_record[CHAIN_0][6].reg = 34; ++ rf_reg_record[CHAIN_0][6].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); ++ rf_reg_record[CHAIN_0][7].bank = 5; ++ rf_reg_record[CHAIN_0][7].reg = 3; ++ rf_reg_record[CHAIN_0][7].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); ++ rf_reg_record[CHAIN_0][8].bank = 5; ++ rf_reg_record[CHAIN_0][8].reg = 4; ++ rf_reg_record[CHAIN_0][8].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); ++ rf_reg_record[CHAIN_0][9].bank = 5; ++ rf_reg_record[CHAIN_0][9].reg = 17; ++ rf_reg_record[CHAIN_0][9].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); ++ rf_reg_record[CHAIN_0][10].bank = 5; ++ rf_reg_record[CHAIN_0][10].reg = 18; ++ rf_reg_record[CHAIN_0][10].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); ++ rf_reg_record[CHAIN_0][11].bank = 5; ++ rf_reg_record[CHAIN_0][11].reg = 19; ++ rf_reg_record[CHAIN_0][11].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); ++ rf_reg_record[CHAIN_0][12].bank = 5; ++ rf_reg_record[CHAIN_0][12].reg = 20; ++ rf_reg_record[CHAIN_0][12].value = rfvalue; ++ } else if (chain == CHAIN_1) { ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 1); ++ rf_reg_record[CHAIN_1][0].bank = 0; ++ rf_reg_record[CHAIN_1][0].reg = 1; ++ rf_reg_record[CHAIN_1][0].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 2); ++ rf_reg_record[CHAIN_1][1].bank = 0; ++ rf_reg_record[CHAIN_1][1].reg = 2; ++ rf_reg_record[CHAIN_1][1].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 35); ++ rf_reg_record[CHAIN_1][2].bank = 0; ++ rf_reg_record[CHAIN_1][2].reg = 35; ++ rf_reg_record[CHAIN_1][2].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 0, 42); ++ rf_reg_record[CHAIN_1][3].bank = 0; ++ rf_reg_record[CHAIN_1][3].reg = 42; ++ rf_reg_record[CHAIN_1][3].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 6, 0); ++ rf_reg_record[CHAIN_1][4].bank = 6; ++ rf_reg_record[CHAIN_1][4].reg = 0; ++ rf_reg_record[CHAIN_1][4].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 6, 2); ++ rf_reg_record[CHAIN_1][5].bank = 6; ++ rf_reg_record[CHAIN_1][5].reg = 2; ++ rf_reg_record[CHAIN_1][5].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 6, 34); ++ rf_reg_record[CHAIN_1][6].bank = 6; ++ rf_reg_record[CHAIN_1][6].reg = 34; ++ rf_reg_record[CHAIN_1][6].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 3); ++ rf_reg_record[CHAIN_1][7].bank = 7; ++ rf_reg_record[CHAIN_1][7].reg = 3; ++ rf_reg_record[CHAIN_1][7].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4); ++ rf_reg_record[CHAIN_1][8].bank = 7; ++ rf_reg_record[CHAIN_1][8].reg = 4; ++ rf_reg_record[CHAIN_1][8].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 17); ++ rf_reg_record[CHAIN_1][9].bank = 7; ++ rf_reg_record[CHAIN_1][9].reg = 17; ++ rf_reg_record[CHAIN_1][9].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 18); ++ rf_reg_record[CHAIN_1][10].bank = 7; ++ rf_reg_record[CHAIN_1][10].reg = 18; ++ rf_reg_record[CHAIN_1][10].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 19); ++ rf_reg_record[CHAIN_1][11].bank = 7; ++ rf_reg_record[CHAIN_1][11].reg = 19; ++ rf_reg_record[CHAIN_1][11].value = rfvalue; ++ rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 20); ++ rf_reg_record[CHAIN_1][12].bank = 7; ++ rf_reg_record[CHAIN_1][12].reg = 20; ++ rf_reg_record[CHAIN_1][12].value = rfvalue; ++ } else { ++ rt2x00_warn(rt2x00dev, "Unknown chain = %u\n", chain); ++ return; ++ } ++ ++ return; ++} ++ ++static void rt2800_rf_configrecover(struct rt2x00_dev *rt2x00dev, rf_reg_pair rf_record[][13]) ++{ ++ u8 chain_index = 0, record_index = 0; ++ u8 bank = 0, rf_register = 0, value = 0; ++ ++ for (chain_index = 0; chain_index < 2; chain_index++) { ++ for (record_index = 0; record_index < 13; record_index++) { ++ bank = rf_record[chain_index][record_index].bank; ++ rf_register = rf_record[chain_index][record_index].reg; ++ value = rf_record[chain_index][record_index].value; ++ rt2800_rfcsr_write_bank(rt2x00dev, bank, rf_register, value); ++ rt2x00_dbg(rt2x00dev, "bank: %d, rf_register: %d, value: %x\n", bank, rf_register, value); ++ } ++ } ++ ++ return; ++} ++ ++static void rt2800_setbbptonegenerator(struct rt2x00_dev *rt2x00dev) ++{ ++ rt2800_bbp_write(rt2x00dev, 158, 0xAA); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xAB); ++ rt2800_bbp_write(rt2x00dev, 159, 0x0A); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xAC); ++ rt2800_bbp_write(rt2x00dev, 159, 0x3F); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xAD); ++ rt2800_bbp_write(rt2x00dev, 159, 0x3F); ++ ++ rt2800_bbp_write(rt2x00dev, 244, 0x40); ++ ++ return; ++} ++ ++static u32 rt2800_do_fft_accumulation(struct rt2x00_dev *rt2x00dev, u8 tidx, u8 read_neg) ++{ ++ u32 macvalue = 0; ++ int fftout_i = 0, fftout_q = 0; ++ u32 ptmp=0, pint = 0; ++ u8 bbp = 0; ++ u8 tidxi; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x00); ++ rt2800_bbp_write(rt2x00dev, 159, 0x9b); ++ ++ bbp = 0x9b; ++ ++ while (bbp == 0x9b) { ++ udelay(10); ++ bbp = rt2800_bbp_read(rt2x00dev, 159); ++ bbp = bbp & 0xff; ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xba); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ ++ macvalue = rt2800_register_read(rt2x00dev, 0x057C); ++ ++ fftout_i = (macvalue >> 16); ++ fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; ++ fftout_q = (macvalue & 0xffff); ++ fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; ++ ptmp = (fftout_i * fftout_i); ++ ptmp = ptmp + (fftout_q * fftout_q); ++ pint = ptmp; ++ rt2x00_dbg(rt2x00dev, "I = %d, Q = %d, power = %x\n", fftout_i, fftout_q, pint); ++ if (read_neg) { ++ pint = pint >> 1; ++ tidxi = 0x40 - tidx; ++ tidxi = tidxi & 0x3f; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xba); ++ rt2800_bbp_write(rt2x00dev, 159, tidxi); ++ rt2800_bbp_write(rt2x00dev, 159, tidxi); ++ rt2800_bbp_write(rt2x00dev, 159, tidxi); ++ ++ macvalue = rt2800_register_read(rt2x00dev, 0x057C); ++ ++ fftout_i = (macvalue >> 16); ++ fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; ++ fftout_q = (macvalue & 0xffff); ++ fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; ++ ptmp = (fftout_i * fftout_i); ++ ptmp = ptmp + (fftout_q * fftout_q); ++ ptmp = ptmp >> 1; ++ pint = pint + ptmp; ++ } ++ ++ return pint; ++} ++ ++static u32 rt2800_read_fft_accumulation(struct rt2x00_dev *rt2x00dev, u8 tidx) { ++ u32 macvalue = 0; ++ int fftout_i = 0, fftout_q = 0; ++ u32 ptmp=0, pint = 0; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xBA); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ rt2800_bbp_write(rt2x00dev, 159, tidx); ++ ++ macvalue = rt2800_register_read(rt2x00dev, 0x057C); ++ ++ fftout_i = (macvalue >> 16); ++ fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; ++ fftout_q = (macvalue & 0xffff); ++ fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; ++ ptmp = (fftout_i * fftout_i); ++ ptmp = ptmp + (fftout_q * fftout_q); ++ pint = ptmp; ++ rt2x00_info(rt2x00dev, "I = %d, Q = %d, power = %x\n", fftout_i, fftout_q, pint); ++ ++ return pint; ++} ++ ++static void rt2800_write_dc(struct rt2x00_dev *rt2x00dev, u8 ch_idx, u8 alc, u8 iorq, u8 dc) ++{ ++ u8 bbp = 0; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb0); ++ bbp = alc | 0x80; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ if (ch_idx == 0) ++ bbp = (iorq == 0) ? 0xb1: 0xb2; ++ else ++ bbp = (iorq == 0) ? 0xb8: 0xb9; ++ ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ bbp = dc; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ return; ++} ++ ++static void rt2800_loft_search(struct rt2x00_dev *rt2x00dev, u8 ch_idx, u8 alc_idx, u8 dc_result[][RF_ALC_NUM][2]) ++{ ++ u32 p0 = 0, p1 = 0, pf = 0; ++ char idx0 = 0, idx1 = 0; ++ u8 idxf[] = {0x00, 0x00}; ++ u8 ibit = 0x20; ++ u8 iorq; ++ char bidx; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb0); ++ rt2800_bbp_write(rt2x00dev, 159, 0x80); ++ ++ for (bidx = 5; bidx >= 0; bidx--) { ++ for (iorq = 0; iorq <= 1; iorq++) { ++ rt2x00_dbg(rt2x00dev, "\n========================================================\n"); ++ ++ if (idxf[iorq] == 0x20) { ++ idx0 = 0x20; ++ p0 = pf; ++ } else { ++ idx0 = idxf[iorq] - ibit; ++ idx0 = idx0 & 0x3F; ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, iorq, idx0); ++ p0 = rt2800_do_fft_accumulation(rt2x00dev, 0x0A, 0); ++ } ++ ++ idx1 = idxf[iorq] + ((bidx == 5) ? 0 : ibit); ++ idx1 = idx1 & 0x3F; ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, iorq, idx1); ++ p1 = rt2800_do_fft_accumulation(rt2x00dev, 0x0A, 0); ++ ++ rt2x00_dbg(rt2x00dev, "alc=%u, IorQ=%u, idx_final=%2x\n", alc_idx, iorq, idxf[iorq]); ++ rt2x00_dbg(rt2x00dev, "p0=%x, p1=%x, pf=%x, idx_0=%x, idx_1=%x, ibit=%x !\n", p0, p1, pf, idx0, idx1, ibit); ++ ++ if ((bidx != 5) && (pf <= p0) && (pf < p1)) { ++ pf = pf; ++ idxf[iorq] = idxf[iorq]; ++ } else if (p0 < p1) { ++ pf = p0; ++ idxf[iorq] = idx0 & 0x3F; ++ } else { ++ pf = p1; ++ idxf[iorq] = idx1 & 0x3F; ++ } ++ rt2x00_dbg(rt2x00dev, "IorQ=%u, idx_final[%u]:%x, pf:%8x\n", iorq, iorq, idxf[iorq], pf); ++ ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, iorq, idxf[iorq]); ++ ++ } ++ ibit = ibit >> 1; ++ } ++ dc_result[ch_idx][alc_idx][0] = idxf[0]; ++ dc_result[ch_idx][alc_idx][1] = idxf[1]; ++ ++ return; ++} ++ ++static void rt2800_iq_search(struct rt2x00_dev *rt2x00dev, u8 ch_idx, u8 *ges, u8 *pes) ++{ ++ u32 p0 = 0, p1 = 0, pf = 0; ++ char perr = 0, gerr = 0, iq_err = 0; ++ char pef = 0, gef = 0; ++ char psta, pend; ++ char gsta, gend; ++ ++ u8 ibit = 0x20; ++ u8 first_search = 0x00, touch_neg_max = 0x00; ++ char idx0 = 0, idx1 = 0; ++ u8 gop; ++ u8 bbp = 0; ++ char bidx; ++ ++ rt2x00_info(rt2x00dev, "IQCalibration Start!\n"); ++ for (bidx = 5; bidx >= 1; bidx--) { ++ for (gop = 0; gop < 2; gop++) { ++ rt2x00_dbg(rt2x00dev, "\n========================================================\n"); ++ ++ if ((gop == 1) || (bidx < 4)) { ++ if (gop == 0) ++ iq_err = gerr; ++ else ++ iq_err = perr; ++ ++ first_search = (gop == 0) ? (bidx == 3) : (bidx == 5); ++ touch_neg_max = (gop) ? ((iq_err & 0x0F) == 0x08) : ((iq_err & 0x3F) == 0x20); ++ ++ if (touch_neg_max) { ++ p0 = pf; ++ idx0 = iq_err; ++ } else { ++ idx0 = iq_err - ibit; ++ bbp = (ch_idx == 0) ? ((gop == 0) ? 0x28 : 0x29): ((gop == 0) ? 0x46 : 0x47); ++ ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, idx0); ++ ++ p0 = rt2800_do_fft_accumulation(rt2x00dev, 0x14, 1); ++ } ++ ++ idx1 = iq_err + (first_search ? 0 : ibit); ++ idx1 = (gop == 0) ? (idx1 & 0x0F) : (idx1 & 0x3F); ++ ++ bbp = (ch_idx == 0) ? (gop == 0) ? 0x28 : 0x29 : (gop == 0) ? 0x46 : 0x47; ++ ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, idx1); ++ ++ p1 = rt2800_do_fft_accumulation(rt2x00dev, 0x14, 1); ++ ++ rt2x00_dbg(rt2x00dev, "p0=%x, p1=%x, pwer_final=%x, idx0=%x, idx1=%x, iq_err=%x, gop=%d, ibit=%x !\n", p0, p1, pf, idx0, idx1, iq_err, gop, ibit); ++ ++ if ((!first_search) && (pf <= p0) && (pf < p1)) { ++ pf = pf; ++ } else if (p0 < p1) { ++ pf = p0; ++ iq_err = idx0; ++ } else { ++ pf = p1; ++ iq_err = idx1; ++ } ++ ++ bbp = (ch_idx == 0) ? (gop == 0) ? 0x28 : 0x29 : (gop == 0) ? 0x46 : 0x47; ++ ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, iq_err); ++ ++ if (gop == 0) ++ gerr = iq_err; ++ else ++ perr = iq_err; ++ ++ rt2x00_dbg(rt2x00dev, "IQCalibration pf=%8x (%2x, %2x) !\n", pf, gerr & 0x0F, perr & 0x3F); ++ ++ } ++ } ++ ++ if (bidx > 0) ++ ibit = (ibit >> 1); ++ } ++ gerr = (gerr & 0x08) ? (gerr & 0x0F) - 0x10 : (gerr & 0x0F); ++ perr = (perr & 0x20) ? (perr & 0x3F) - 0x40 : (perr & 0x3F); ++ ++ gerr = (gerr < -0x07) ? -0x07 : (gerr > 0x05) ? 0x05 : gerr; ++ gsta = gerr - 1; ++ gend = gerr + 2; ++ ++ perr = (perr < -0x1f) ? -0x1f : (perr > 0x1d) ? 0x1d : perr; ++ psta = perr - 1; ++ pend = perr + 2; ++ ++ for (gef = gsta; gef <= gend; gef = gef + 1) ++ for (pef = psta; pef <= pend; pef = pef + 1) { ++ bbp = (ch_idx == 0) ? 0x28 : 0x46; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, gef & 0x0F); ++ ++ bbp = (ch_idx == 0) ? 0x29 : 0x47; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, pef & 0x3F); ++ ++ p1 = rt2800_do_fft_accumulation(rt2x00dev, 0x14, 1); ++ if ((gef == gsta) && (pef == psta)) { ++ pf = p1; ++ gerr = gef; ++ perr = pef; ++ } ++ else if (pf > p1){ ++ pf = p1; ++ gerr = gef; ++ perr = pef; ++ } ++ rt2x00_dbg(rt2x00dev, "Fine IQCalibration p1=%8x pf=%8x (%2x, %2x) !\n", p1, pf, gef & 0x0F, pef & 0x3F); ++ } ++ ++ ges[ch_idx] = gerr & 0x0F; ++ pes[ch_idx] = perr & 0x3F; ++ ++ rt2x00_info(rt2x00dev, "IQCalibration Done! CH = %u, (gain=%2x, phase=%2x)\n", ch_idx, gerr & 0x0F, perr & 0x3F); ++ ++ return; ++} ++ ++static void rt2800_rf_aux_tx0_loopback(struct rt2x00_dev *rt2x00dev) ++{ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, 0x21); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, 0x10); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 35, 0x00); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, 0x1b); ++ rt2800_rfcsr_write_bank(rt2x00dev, 4, 0, 0x81); ++ rt2800_rfcsr_write_bank(rt2x00dev, 4, 2, 0x81); ++ rt2800_rfcsr_write_bank(rt2x00dev, 4, 34, 0xee); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, 0x2d); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, 0x2d); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, 0x80); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0xd7); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0xa2); ++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x20); ++} ++ ++static void rt2800_rf_aux_tx1_loopback(struct rt2x00_dev *rt2x00dev) ++{ ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 1, 0x22); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, 0x20); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 35, 0x00); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, 0x4b); ++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 0, 0x81); ++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 2, 0x81); ++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 34, 0xee); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 3, 0x2d); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 4, 0x2d); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 17, 0x80); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 18, 0xd7); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 19, 0xa2); ++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 20, 0x20); ++} ++ ++void rt2800_loft_iq_calibration(struct rt2x00_dev *rt2x00dev) ++{ ++ rf_reg_pair rf_store[CHAIN_NUM][13]; ++ u32 macorg1 = 0; ++ u32 macorg2 = 0; ++ u32 macorg3 = 0; ++ u32 macorg4 = 0; ++ u32 macorg5 = 0; ++ u32 orig528 = 0; ++ u32 orig52c = 0; ++ ++ u32 savemacsysctrl = 0, mtxcycle = 0; ++ u32 macvalue = 0; ++ u32 mac13b8 = 0; ++ u32 p0 = 0, p1 = 0; ++ u32 p0_idx10 = 0, p1_idx10 = 0; ++ ++ u8 rfvalue; ++ u8 loft_dc_search_result[CHAIN_NUM][RF_ALC_NUM][2]; ++ u8 ger[CHAIN_NUM], per[CHAIN_NUM]; ++ u8 rf_gain[] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x0c}; ++ u8 rfvga_gain_table[] = {0x24, 0x25, 0x26, 0x27, 0x28, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3F}; ++ ++ u8 vga_gain[] = {14, 14}; ++ u8 bbp_2324gain[] = {0x16, 0x14, 0x12, 0x10, 0x0c, 0x08}; ++ u8 bbp = 0, ch_idx = 0, rf_alc_idx = 0, idx = 0; ++ u8 bbpr30, rfb0r39, rfb0r42; ++ u8 bbpr1; ++ u8 bbpr4; ++ u8 bbpr241, bbpr242; ++ u8 count_step; ++ ++ savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macorg1 = rt2800_register_read(rt2x00dev, TX_PIN_CFG); ++ macorg2 = rt2800_register_read(rt2x00dev, RF_CONTROL0); ++ macorg3 = rt2800_register_read(rt2x00dev, RF_BYPASS0); ++ macorg4 = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ macorg5 = rt2800_register_read(rt2x00dev, RF_BYPASS3); ++ mac13b8 = rt2800_register_read(rt2x00dev, 0x13b8); ++ orig528 = rt2800_register_read(rt2x00dev, RF_CONTROL2); ++ orig52c = rt2800_register_read(rt2x00dev, RF_BYPASS2); ++ ++ macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macvalue &= (~0x04); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); ++ ++ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { ++ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macvalue & 0x01) ++ udelay(50); ++ else ++ break; ++ } ++ ++ macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macvalue &= (~0x08); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); ++ ++ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { ++ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macvalue & 0x02) ++ udelay(50); ++ else ++ break; ++ } ++ ++ for (ch_idx = 0; ch_idx < 2; ch_idx++) { ++ rt2800_rf_configstore(rt2x00dev, rf_store, ch_idx); ++ } ++ ++ bbpr30 = rt2800_bbp_read(rt2x00dev, 30); ++ rfb0r39 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 39); ++ rfb0r42 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 42); ++ ++ rt2800_bbp_write(rt2x00dev, 30, 0x1F); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 39, 0x80); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, 0x5B); ++ ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ ++ rt2800_setbbptonegenerator(rt2x00dev); ++ ++ for (ch_idx = 0; ch_idx < 2; ch_idx ++) { ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00); ++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x0000000F); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000004); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x00003306); ++ rt2800_register_write(rt2x00dev, 0x13b8, 0x10); ++ udelay(1); ++ ++ if (ch_idx == 0) { ++ rt2800_rf_aux_tx0_loopback(rt2x00dev); ++ } else { ++ rt2800_rf_aux_tx1_loopback(rt2x00dev); ++ } ++ udelay(1); ++ ++ if (ch_idx == 0) { ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00001004); ++ } else { ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00002004); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x05); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x01); ++ if (ch_idx == 0) ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ else ++ rt2800_bbp_write(rt2x00dev, 159, 0x01); ++ ++ vga_gain[ch_idx] = 18; ++ for (rf_alc_idx = 0; rf_alc_idx < 3; rf_alc_idx++) { ++ rt2800_bbp_write(rt2x00dev, 23, bbp_2324gain[rf_alc_idx]); ++ rt2800_bbp_write(rt2x00dev, 24, bbp_2324gain[rf_alc_idx]); ++ ++ macvalue = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ macvalue &= (~0x0000F1F1); ++ macvalue |= (rf_gain[rf_alc_idx] << 4); ++ macvalue |= (rf_gain[rf_alc_idx] << 12); ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, macvalue); ++ macvalue = (0x0000F1F1); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, macvalue); ++ ++ if (rf_alc_idx == 0) { ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 1, 0x21); ++ for (;vga_gain[ch_idx] > 0;vga_gain[ch_idx] = vga_gain[ch_idx] - 2) { ++ rfvalue = rfvga_gain_table[vga_gain[ch_idx]]; ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rfvalue); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rfvalue); ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 1, 0x00); ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 0, 0x00); ++ p0 = rt2800_do_fft_accumulation(rt2x00dev, 0x0A, 0); ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 0, 0x21); ++ p1 = rt2800_do_fft_accumulation(rt2x00dev, 0x0A, 0); ++ rt2x00_dbg(rt2x00dev, "LOFT AGC %d %d\n", p0, p1); ++ if ((p0 < 7000*7000) && (p1 < (7000*7000))) { ++ break; ++ } ++ } ++ ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 0, 0x00); ++ rt2800_write_dc(rt2x00dev, ch_idx, 0, 1, 0x00); ++ ++ rt2x00_dbg(rt2x00dev, "Used VGA %d %x\n",vga_gain[ch_idx], rfvga_gain_table[vga_gain[ch_idx]]); ++ ++ if (vga_gain[ch_idx] < 0) ++ vga_gain[ch_idx] = 0; ++ } ++ ++ rfvalue = rfvga_gain_table[vga_gain[ch_idx]]; ++ ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rfvalue); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rfvalue); ++ ++ rt2800_loft_search(rt2x00dev, ch_idx, rf_alc_idx, loft_dc_search_result); ++ } ++ } ++ ++ for (rf_alc_idx = 0; rf_alc_idx < 3; rf_alc_idx++) { ++ for (idx = 0; idx < 4; idx++) { ++ rt2800_bbp_write(rt2x00dev, 158, 0xB0); ++ bbp = (idx<<2) + rf_alc_idx; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ rt2x00_dbg(rt2x00dev, " ALC %2x,", bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb1); ++ bbp = loft_dc_search_result[CHAIN_0][rf_alc_idx][0x00]; ++ bbp = bbp & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ rt2x00_dbg(rt2x00dev, " I0 %2x,", bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb2); ++ bbp = loft_dc_search_result[CHAIN_0][rf_alc_idx][0x01]; ++ bbp = bbp & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ rt2x00_dbg(rt2x00dev, " Q0 %2x,", bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb8); ++ bbp = loft_dc_search_result[CHAIN_1][rf_alc_idx][0x00]; ++ bbp = bbp & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ rt2x00_dbg(rt2x00dev, " I1 %2x,", bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0xb9); ++ bbp = loft_dc_search_result[CHAIN_1][rf_alc_idx][0x01]; ++ bbp = bbp & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ rt2x00_dbg(rt2x00dev, " Q1 %2x\n", bbp); ++ } ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x04); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x00); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ bbp = 0x00; ++ rt2800_bbp_write(rt2x00dev, 244, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 21, 0x01); ++ udelay(1); ++ rt2800_bbp_write(rt2x00dev, 21, 0x00); ++ ++ rt2800_rf_configrecover(rt2x00dev, rf_store); ++ ++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, macorg1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x04); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x00); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, macorg2); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, macorg3); ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, macorg4); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, macorg5); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); ++ rt2800_register_write(rt2x00dev, RF_CONTROL2, orig528); ++ rt2800_register_write(rt2x00dev, RF_BYPASS2, orig52c); ++ rt2800_register_write(rt2x00dev, 0x13b8, mac13b8); ++ ++ rt2x00_info(rt2x00dev, "LOFT Calibration Done!\n"); ++ ++ savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macorg1 = rt2800_register_read(rt2x00dev, TX_PIN_CFG); ++ macorg2 = rt2800_register_read(rt2x00dev, RF_CONTROL0); ++ macorg3 = rt2800_register_read(rt2x00dev, RF_BYPASS0); ++ macorg4 = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ macorg5 = rt2800_register_read(rt2x00dev, RF_BYPASS3); ++ ++ bbpr1 = rt2800_bbp_read(rt2x00dev, 1); ++ bbpr4 = rt2800_bbp_read(rt2x00dev, 4); ++ bbpr241 = rt2800_bbp_read(rt2x00dev, 241); ++ bbpr242 = rt2800_bbp_read(rt2x00dev, 242); ++ mac13b8 = rt2800_register_read(rt2x00dev, 0x13b8); ++ ++ macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macvalue &= (~0x04); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); ++ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { ++ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macvalue & 0x01) ++ udelay(50); ++ else ++ break; ++ } ++ ++ macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); ++ macvalue &= (~0x08); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); ++ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { ++ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (macvalue & 0x02) ++ udelay(50); ++ else ++ break; ++ } ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x00000101); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0000F1F1); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_bbp_write(rt2x00dev, 4, bbpr4 & (~0x18)); ++ rt2800_bbp_write(rt2x00dev, 21, 0x01); ++ udelay(1); ++ rt2800_bbp_write(rt2x00dev, 21, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 241, 0x14); ++ rt2800_bbp_write(rt2x00dev, 242, 0x80); ++ rt2800_bbp_write(rt2x00dev, 244, 0x31); ++ } else { ++ rt2800_setbbptonegenerator(rt2x00dev); ++ } ++ ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00000004); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x00003306); ++ udelay(1); ++ ++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x0000000F); ++ ++ if (!test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x00000000); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0000F1F1); ++ } ++ ++ rt2800_register_write(rt2x00dev, 0x13b8, 0x00000010); ++ ++ for (ch_idx = 0; ch_idx < 2; ch_idx++) { ++ rt2800_rf_configstore(rt2x00dev, rf_store, ch_idx); ++ } ++ ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x3B); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x3B); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x03); ++ rt2800_bbp_write(rt2x00dev, 159, 0x60); ++ rt2800_bbp_write(rt2x00dev, 158, 0xB0); ++ rt2800_bbp_write(rt2x00dev, 159, 0x80); ++ ++ for (ch_idx = 0; ch_idx < 2; ch_idx ++) { ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ ++ if (ch_idx == 0) { ++ rt2800_bbp_write(rt2x00dev, 158, 0x01); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ bbp = bbpr1 & (~0x18); ++ bbp = bbp | 0x00; ++ rt2800_bbp_write(rt2x00dev, 1, bbp); ++ } ++ rt2800_rf_aux_tx0_loopback(rt2x00dev); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00001004); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 158, 0x01); ++ rt2800_bbp_write(rt2x00dev, 159, 0x01); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) { ++ bbp = bbpr1 & (~0x18); ++ bbp = bbp | 0x08; ++ rt2800_bbp_write(rt2x00dev, 1, bbp); ++ } ++ rt2800_rf_aux_tx1_loopback(rt2x00dev); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00002004); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x05); ++ rt2800_bbp_write(rt2x00dev, 159, 0x04); ++ ++ bbp = (ch_idx == 0) ? 0x28 : 0x46; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_bbp_write(rt2x00dev, 23, 0x06); ++ rt2800_bbp_write(rt2x00dev, 24, 0x06); ++ count_step = 1; ++ } else { ++ rt2800_bbp_write(rt2x00dev, 23, 0x1F); ++ rt2800_bbp_write(rt2x00dev, 24, 0x1F); ++ count_step = 2; ++ } ++ ++ for (;vga_gain[ch_idx] < 19; vga_gain[ch_idx]=(vga_gain[ch_idx] + count_step)) { ++ rfvalue = rfvga_gain_table[vga_gain[ch_idx]]; ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rfvalue); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rfvalue); ++ ++ bbp = (ch_idx == 0) ? 0x29 : 0x47; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ p0 = rt2800_do_fft_accumulation(rt2x00dev, 0x14, 0); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ p0_idx10 = rt2800_read_fft_accumulation(rt2x00dev, 0x0A); ++ } ++ ++ bbp = (ch_idx == 0) ? 0x29 : 0x47; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, 0x21); ++ p1 = rt2800_do_fft_accumulation(rt2x00dev, 0x14, 0); ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) { ++ p1_idx10 = rt2800_read_fft_accumulation(rt2x00dev, 0x0A); ++ } ++ ++ rt2x00_dbg(rt2x00dev, "IQ AGC %d %d\n", p0, p1); ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2x00_dbg(rt2x00dev, "IQ AGC IDX 10 %d %d\n", p0_idx10, p1_idx10); ++ if ((p0_idx10 > 7000*7000) || (p1_idx10 > 7000*7000)) { ++ if (vga_gain[ch_idx]!=0) ++ vga_gain[ch_idx] = vga_gain[ch_idx]-1; ++ break; ++ } ++ } ++ ++ if ((p0 > 2500*2500) || (p1 > 2500*2500)) { ++ break; ++ } ++ } ++ ++ if (vga_gain[ch_idx] > 18) ++ vga_gain[ch_idx] = 18; ++ rt2x00_dbg(rt2x00dev, "Used VGA %d %x\n",vga_gain[ch_idx], rfvga_gain_table[vga_gain[ch_idx]]); ++ ++ bbp = (ch_idx == 0) ? 0x29 : 0x47; ++ rt2800_bbp_write(rt2x00dev, 158, bbp); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ rt2800_iq_search(rt2x00dev, ch_idx, ger, per); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 23, 0x00); ++ rt2800_bbp_write(rt2x00dev, 24, 0x00); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x04); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x28); ++ bbp = ger[CHAIN_0] & 0x0F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x29); ++ bbp = per[CHAIN_0] & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x46); ++ bbp = ger[CHAIN_1] & 0x0F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x47); ++ bbp = per[CHAIN_1] & 0x3F; ++ rt2800_bbp_write(rt2x00dev, 159, bbp); ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_bbp_write(rt2x00dev, 1, bbpr1); ++ rt2800_bbp_write(rt2x00dev, 241, bbpr241); ++ rt2800_bbp_write(rt2x00dev, 242, bbpr242); ++ } ++ rt2800_bbp_write(rt2x00dev, 244, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x00); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ rt2800_bbp_write(rt2x00dev, 158, 0xB0); ++ rt2800_bbp_write(rt2x00dev, 159, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 30, bbpr30); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 39, rfb0r39); ++ rt2800_rfcsr_write_bank(rt2x00dev, 0, 42, rfb0r42); ++ ++ if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { ++ rt2800_bbp_write(rt2x00dev, 4, bbpr4); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 21, 0x01); ++ udelay(1); ++ rt2800_bbp_write(rt2x00dev, 21, 0x00); ++ ++ rt2800_rf_configrecover(rt2x00dev, rf_store); ++ ++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, macorg1); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, 0x00); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x00); ++ rt2800_register_write(rt2x00dev, RF_CONTROL0, macorg2); ++ udelay(1); ++ rt2800_register_write(rt2x00dev, RF_BYPASS0, macorg3); ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, macorg4); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, macorg5); ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); ++ rt2800_register_write(rt2x00dev, 0x13b8, mac13b8); ++ ++ rt2x00_info(rt2x00dev, "TX IQ Calibration Done!\n"); ++ ++ return; ++} ++ + static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, + bool set_bw, bool is_ht40) + { +@@ -9672,6 +10609,7 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); ++ rt2800_loft_iq_calibration(rt2x00dev); + rt2800_rxiq_calibration(rt2x00dev); + } + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +@@ -17,6 +17,16 @@ + #define WCID_START 33 + #define WCID_END 222 + #define STA_IDS_SIZE (WCID_END - WCID_START + 2) ++#define CHAIN_0 0x0 ++#define CHAIN_1 0x1 ++#define RF_ALC_NUM 6 ++#define CHAIN_NUM 2 ++ ++typedef struct rf_reg_pair { ++ u8 bank; ++ u8 reg; ++ u8 value; ++} rf_reg_pair; + + /* RT2800 driver data structure */ + struct rt2800_drv_data { diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/070-backports-add-netif_receive_skb_list.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/070-backports-add-netif_receive_skb_list.patch new file mode 100644 index 000000000..b26a6bc38 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/070-backports-add-netif_receive_skb_list.patch @@ -0,0 +1,30 @@ +From: Felix Fietkau +Date: Fri, 14 Aug 2020 16:13:45 +0200 +Subject: [PATCH] backports: add netif_receive_skb_list + +It will be needed by pending mac80211 changes + +Signed-off-by: Felix Fietkau +--- + +--- a/backport-include/linux/netdevice.h ++++ b/backport-include/linux/netdevice.h +@@ -372,6 +372,18 @@ static inline int _bp_netdev_upper_dev_l + macro_dispatcher(netdev_upper_dev_link, __VA_ARGS__)(__VA_ARGS__) + #endif + ++#if LINUX_VERSION_IS_LESS(4,19,0) ++static inline void netif_receive_skb_list(struct list_head *head) ++{ ++ struct sk_buff *skb, *next; ++ ++ list_for_each_entry_safe(skb, next, head, list) { ++ skb_list_del_init(skb); ++ netif_receive_skb(skb); ++ } ++} ++#endif ++ + #if LINUX_VERSION_IS_LESS(5,0,0) + static inline int backport_dev_open(struct net_device *dev, struct netlink_ext_ack *extack) + { diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/071-backports-add-skb_list_del_init.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/071-backports-add-skb_list_del_init.patch new file mode 100644 index 000000000..ee7e63498 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/071-backports-add-skb_list_del_init.patch @@ -0,0 +1,24 @@ +From: Felix Fietkau +Date: Fri, 14 Aug 2020 16:13:55 +0200 +Subject: [PATCH] backports: add skb_list_del_init + +It will be needed by pending mac80211 changes + +Signed-off-by: Felix Fietkau +--- + +--- a/backport-include/linux/skbuff.h ++++ b/backport-include/linux/skbuff.h +@@ -384,6 +384,12 @@ static inline void skb_mark_not_on_list( + { + skb->next = NULL; + } ++ ++static inline void skb_list_del_init(struct sk_buff *skb) ++{ ++ __list_del_entry(&skb->list); ++ skb_mark_not_on_list(skb); ++} + #endif /* 4.19.10 <= x < 4.20 */ + #endif + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/100-remove-cryptoapi-dependencies.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/100-remove-cryptoapi-dependencies.patch new file mode 100644 index 000000000..a94f9d8fd --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/100-remove-cryptoapi-dependencies.patch @@ -0,0 +1,698 @@ +--- a/net/mac80211/Makefile ++++ b/net/mac80211/Makefile +@@ -7,7 +7,6 @@ mac80211-y := \ + driver-ops.o \ + sta_info.o \ + wep.o \ +- aead_api.o \ + wpa.o \ + scan.o offchannel.o \ + ht.o agg-tx.o agg-rx.o \ +@@ -18,8 +17,8 @@ mac80211-y := \ + rate.o \ + michael.o \ + tkip.o \ ++ aes_ccm.o \ + aes_cmac.o \ +- aes_gmac.o \ + fils_aead.o \ + cfg.o \ + ethtool.o \ +--- a/net/mac80211/aead_api.c ++++ /dev/null +@@ -1,112 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0-only +-/* +- * Copyright 2003-2004, Instant802 Networks, Inc. +- * Copyright 2005-2006, Devicescape Software, Inc. +- * Copyright 2014-2015, Qualcomm Atheros, Inc. +- * +- * Rewrite: Copyright (C) 2013 Linaro Ltd +- */ +- +-#include +-#include +-#include +-#include +-#include +- +-#include "aead_api.h" +- +-int aead_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, size_t aad_len, +- u8 *data, size_t data_len, u8 *mic) +-{ +- size_t mic_len = crypto_aead_authsize(tfm); +- struct scatterlist sg[3]; +- struct aead_request *aead_req; +- int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm); +- u8 *__aad; +- +- aead_req = kzalloc(reqsize + aad_len, GFP_ATOMIC); +- if (!aead_req) +- return -ENOMEM; +- +- __aad = (u8 *)aead_req + reqsize; +- memcpy(__aad, aad, aad_len); +- +- sg_init_table(sg, 3); +- sg_set_buf(&sg[0], __aad, aad_len); +- sg_set_buf(&sg[1], data, data_len); +- sg_set_buf(&sg[2], mic, mic_len); +- +- aead_request_set_tfm(aead_req, tfm); +- aead_request_set_crypt(aead_req, sg, sg, data_len, b_0); +- aead_request_set_ad(aead_req, sg[0].length); +- +- crypto_aead_encrypt(aead_req); +- kzfree(aead_req); +- +- return 0; +-} +- +-int aead_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, size_t aad_len, +- u8 *data, size_t data_len, u8 *mic) +-{ +- size_t mic_len = crypto_aead_authsize(tfm); +- struct scatterlist sg[3]; +- struct aead_request *aead_req; +- int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm); +- u8 *__aad; +- int err; +- +- if (data_len == 0) +- return -EINVAL; +- +- aead_req = kzalloc(reqsize + aad_len, GFP_ATOMIC); +- if (!aead_req) +- return -ENOMEM; +- +- __aad = (u8 *)aead_req + reqsize; +- memcpy(__aad, aad, aad_len); +- +- sg_init_table(sg, 3); +- sg_set_buf(&sg[0], __aad, aad_len); +- sg_set_buf(&sg[1], data, data_len); +- sg_set_buf(&sg[2], mic, mic_len); +- +- aead_request_set_tfm(aead_req, tfm); +- aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0); +- aead_request_set_ad(aead_req, sg[0].length); +- +- err = crypto_aead_decrypt(aead_req); +- kzfree(aead_req); +- +- return err; +-} +- +-struct crypto_aead * +-aead_key_setup_encrypt(const char *alg, const u8 key[], +- size_t key_len, size_t mic_len) +-{ +- struct crypto_aead *tfm; +- int err; +- +- tfm = crypto_alloc_aead(alg, 0, CRYPTO_ALG_ASYNC); +- if (IS_ERR(tfm)) +- return tfm; +- +- err = crypto_aead_setkey(tfm, key, key_len); +- if (err) +- goto free_aead; +- err = crypto_aead_setauthsize(tfm, mic_len); +- if (err) +- goto free_aead; +- +- return tfm; +- +-free_aead: +- crypto_free_aead(tfm); +- return ERR_PTR(err); +-} +- +-void aead_key_free(struct crypto_aead *tfm) +-{ +- crypto_free_aead(tfm); +-} +--- a/net/mac80211/aead_api.h ++++ /dev/null +@@ -1,23 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0-only */ +- +-#ifndef _AEAD_API_H +-#define _AEAD_API_H +- +-#include +-#include +- +-struct crypto_aead * +-aead_key_setup_encrypt(const char *alg, const u8 key[], +- size_t key_len, size_t mic_len); +- +-int aead_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, +- size_t aad_len, u8 *data, +- size_t data_len, u8 *mic); +- +-int aead_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, +- size_t aad_len, u8 *data, +- size_t data_len, u8 *mic); +- +-void aead_key_free(struct crypto_aead *tfm); +- +-#endif /* _AEAD_API_H */ +--- a/net/mac80211/aes_ccm.h ++++ b/net/mac80211/aes_ccm.h +@@ -7,39 +7,17 @@ + #ifndef AES_CCM_H + #define AES_CCM_H + +-#include "aead_api.h" ++#include + +-#define CCM_AAD_LEN 32 +- +-static inline struct crypto_aead * +-ieee80211_aes_key_setup_encrypt(const u8 key[], size_t key_len, size_t mic_len) +-{ +- return aead_key_setup_encrypt("ccm(aes)", key, key_len, mic_len); +-} +- +-static inline int +-ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, +- u8 *b_0, u8 *aad, u8 *data, +- size_t data_len, u8 *mic) +-{ +- return aead_encrypt(tfm, b_0, aad + 2, +- be16_to_cpup((__be16 *)aad), +- data, data_len, mic); +-} +- +-static inline int +-ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, +- u8 *b_0, u8 *aad, u8 *data, +- size_t data_len, u8 *mic) +-{ +- return aead_decrypt(tfm, b_0, aad + 2, +- be16_to_cpup((__be16 *)aad), +- data, data_len, mic); +-} +- +-static inline void ieee80211_aes_key_free(struct crypto_aead *tfm) +-{ +- return aead_key_free(tfm); +-} ++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[], ++ size_t key_len, ++ size_t mic_len); ++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic, ++ size_t mic_len); ++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic, ++ size_t mic_len); ++void ieee80211_aes_key_free(struct crypto_cipher *tfm); + + #endif /* AES_CCM_H */ +--- /dev/null ++++ b/net/mac80211/aes_gcm.c +@@ -0,0 +1,109 @@ ++/* ++ * Copyright 2014-2015, Qualcomm Atheros, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include "key.h" ++#include "aes_gcm.h" ++ ++int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) ++{ ++ struct scatterlist sg[3]; ++ struct aead_request *aead_req; ++ int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm); ++ u8 *__aad; ++ ++ aead_req = kzalloc(reqsize + GCM_AAD_LEN, GFP_ATOMIC); ++ if (!aead_req) ++ return -ENOMEM; ++ ++ __aad = (u8 *)aead_req + reqsize; ++ memcpy(__aad, aad, GCM_AAD_LEN); ++ ++ sg_init_table(sg, 3); ++ sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad)); ++ sg_set_buf(&sg[1], data, data_len); ++ sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); ++ ++ aead_request_set_tfm(aead_req, tfm); ++ aead_request_set_crypt(aead_req, sg, sg, data_len, j_0); ++ aead_request_set_ad(aead_req, sg[0].length); ++ ++ crypto_aead_encrypt(aead_req); ++ kzfree(aead_req); ++ return 0; ++} ++ ++int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) ++{ ++ struct scatterlist sg[3]; ++ struct aead_request *aead_req; ++ int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm); ++ u8 *__aad; ++ int err; ++ ++ if (data_len == 0) ++ return -EINVAL; ++ ++ aead_req = kzalloc(reqsize + GCM_AAD_LEN, GFP_ATOMIC); ++ if (!aead_req) ++ return -ENOMEM; ++ ++ __aad = (u8 *)aead_req + reqsize; ++ memcpy(__aad, aad, GCM_AAD_LEN); ++ ++ sg_init_table(sg, 3); ++ sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad)); ++ sg_set_buf(&sg[1], data, data_len); ++ sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); ++ ++ aead_request_set_tfm(aead_req, tfm); ++ aead_request_set_crypt(aead_req, sg, sg, ++ data_len + IEEE80211_GCMP_MIC_LEN, j_0); ++ aead_request_set_ad(aead_req, sg[0].length); ++ ++ err = crypto_aead_decrypt(aead_req); ++ kzfree(aead_req); ++ ++ return err; ++} ++ ++struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], ++ size_t key_len) ++{ ++ struct crypto_aead *tfm; ++ int err; ++ ++ tfm = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC); ++ if (IS_ERR(tfm)) ++ return tfm; ++ ++ err = crypto_aead_setkey(tfm, key, key_len); ++ if (err) ++ goto free_aead; ++ err = crypto_aead_setauthsize(tfm, IEEE80211_GCMP_MIC_LEN); ++ if (err) ++ goto free_aead; ++ ++ return tfm; ++ ++free_aead: ++ crypto_free_aead(tfm); ++ return ERR_PTR(err); ++} ++ ++void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm) ++{ ++ crypto_free_aead(tfm); ++} +--- a/net/mac80211/aes_gcm.h ++++ b/net/mac80211/aes_gcm.h +@@ -6,38 +6,30 @@ + #ifndef AES_GCM_H + #define AES_GCM_H + +-#include "aead_api.h" ++#include + +-#define GCM_AAD_LEN 32 +- +-static inline int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, +- u8 *j_0, u8 *aad, u8 *data, +- size_t data_len, u8 *mic) ++static inline void ++ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) + { +- return aead_encrypt(tfm, j_0, aad + 2, +- be16_to_cpup((__be16 *)aad), +- data, data_len, mic); + } + +-static inline int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, +- u8 *j_0, u8 *aad, u8 *data, +- size_t data_len, u8 *mic) ++static inline int ++ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) + { +- return aead_decrypt(tfm, j_0, aad + 2, +- be16_to_cpup((__be16 *)aad), +- data, data_len, mic); ++ return -EOPNOTSUPP; + } + + static inline struct crypto_aead * + ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len) + { +- return aead_key_setup_encrypt("gcm(aes)", key, +- key_len, IEEE80211_GCMP_MIC_LEN); ++ return NULL; + } + +-static inline void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm) ++static inline void ++ieee80211_aes_gcm_key_free(struct crypto_aead *tfm) + { +- return aead_key_free(tfm); + } + + #endif /* AES_GCM_H */ +--- a/net/mac80211/wpa.c ++++ b/net/mac80211/wpa.c +@@ -311,7 +311,8 @@ ieee80211_crypto_tkip_decrypt(struct iee + } + + +-static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad) ++static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad, ++ u16 data_len) + { + __le16 mask_fc; + int a4_included, mgmt; +@@ -341,14 +342,8 @@ static void ccmp_special_blocks(struct s + else + qos_tid = 0; + +- /* In CCM, the initial vectors (IV) used for CTR mode encryption and CBC +- * mode authentication are not allowed to collide, yet both are derived +- * from this vector b_0. We only set L := 1 here to indicate that the +- * data size can be represented in (L+1) bytes. The CCM layer will take +- * care of storing the data length in the top (L+1) bytes and setting +- * and clearing the other bits as is required to derive the two IVs. +- */ +- b_0[0] = 0x1; ++ /* First block, b_0 */ ++ b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */ + + /* Nonce: Nonce Flags | A2 | PN + * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7) +@@ -356,6 +351,8 @@ static void ccmp_special_blocks(struct s + b_0[1] = qos_tid | (mgmt << 4); + memcpy(&b_0[2], hdr->addr2, ETH_ALEN); + memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN); ++ /* l(m) */ ++ put_unaligned_be16(data_len, &b_0[14]); + + /* AAD (extra authenticate-only data) / masked 802.11 header + * FC | A1 | A2 | A3 | SC | [A4] | [QC] */ +@@ -412,7 +409,7 @@ static int ccmp_encrypt_skb(struct ieee8 + u8 *pos; + u8 pn[6]; + u64 pn64; +- u8 aad[CCM_AAD_LEN]; ++ u8 aad[2 * AES_BLOCK_SIZE]; + u8 b_0[AES_BLOCK_SIZE]; + + if (info->control.hw_key && +@@ -467,9 +464,11 @@ static int ccmp_encrypt_skb(struct ieee8 + return 0; + + pos += IEEE80211_CCMP_HDR_LEN; +- ccmp_special_blocks(skb, pn, b_0, aad); +- return ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len, +- skb_put(skb, mic_len)); ++ ccmp_special_blocks(skb, pn, b_0, aad, len); ++ ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len, ++ skb_put(skb, mic_len), mic_len); ++ ++ return 0; + } + + +@@ -542,13 +541,13 @@ ieee80211_crypto_ccmp_decrypt(struct iee + u8 aad[2 * AES_BLOCK_SIZE]; + u8 b_0[AES_BLOCK_SIZE]; + /* hardware didn't decrypt/verify MIC */ +- ccmp_special_blocks(skb, pn, b_0, aad); ++ ccmp_special_blocks(skb, pn, b_0, aad, data_len); + + if (ieee80211_aes_ccm_decrypt( + key->u.ccmp.tfm, b_0, aad, + skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN, + data_len, +- skb->data + skb->len - mic_len)) ++ skb->data + skb->len - mic_len, mic_len)) + return RX_DROP_UNUSABLE; + } + +@@ -643,7 +642,7 @@ static int gcmp_encrypt_skb(struct ieee8 + u8 *pos; + u8 pn[6]; + u64 pn64; +- u8 aad[GCM_AAD_LEN]; ++ u8 aad[2 * AES_BLOCK_SIZE]; + u8 j_0[AES_BLOCK_SIZE]; + + if (info->control.hw_key && +@@ -700,8 +699,10 @@ static int gcmp_encrypt_skb(struct ieee8 + + pos += IEEE80211_GCMP_HDR_LEN; + gcmp_special_blocks(skb, pn, j_0, aad); +- return ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len, +- skb_put(skb, IEEE80211_GCMP_MIC_LEN)); ++ ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len, ++ skb_put(skb, IEEE80211_GCMP_MIC_LEN)); ++ ++ return 0; + } + + ieee80211_tx_result +@@ -1128,9 +1129,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct + struct ieee80211_key *key = tx->key; + struct ieee80211_mmie_16 *mmie; + struct ieee80211_hdr *hdr; +- u8 aad[GMAC_AAD_LEN]; ++ u8 aad[20]; + u64 pn64; +- u8 nonce[GMAC_NONCE_LEN]; ++ u8 nonce[12]; + + if (WARN_ON(skb_queue_len(&tx->skbs) != 1)) + return TX_DROP; +@@ -1176,7 +1177,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); + struct ieee80211_key *key = rx->key; + struct ieee80211_mmie_16 *mmie; +- u8 aad[GMAC_AAD_LEN], *mic, ipn[6], nonce[GMAC_NONCE_LEN]; ++ u8 aad[20], *mic, ipn[6], nonce[12]; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + + if (!ieee80211_is_mgmt(hdr->frame_control)) +--- /dev/null ++++ b/net/mac80211/aes_ccm.c +@@ -0,0 +1,144 @@ ++/* ++ * Copyright 2003-2004, Instant802 Networks, Inc. ++ * Copyright 2005-2006, Devicescape Software, Inc. ++ * ++ * Rewrite: Copyright (C) 2013 Linaro Ltd ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include "key.h" ++#include "aes_ccm.h" ++ ++static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, u8 *s_0, ++ u8 *a, u8 *b) ++{ ++ int i; ++ ++ crypto_cipher_encrypt_one(tfm, b, b_0); ++ ++ /* Extra Authenticate-only data (always two AES blocks) */ ++ for (i = 0; i < AES_BLOCK_SIZE; i++) ++ aad[i] ^= b[i]; ++ crypto_cipher_encrypt_one(tfm, b, aad); ++ ++ aad += AES_BLOCK_SIZE; ++ ++ for (i = 0; i < AES_BLOCK_SIZE; i++) ++ aad[i] ^= b[i]; ++ crypto_cipher_encrypt_one(tfm, a, aad); ++ ++ /* Mask out bits from auth-only-b_0 */ ++ b_0[0] &= 0x07; ++ ++ /* S_0 is used to encrypt T (= MIC) */ ++ b_0[14] = 0; ++ b_0[15] = 0; ++ crypto_cipher_encrypt_one(tfm, s_0, b_0); ++} ++ ++ ++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic, ++ size_t mic_len) ++{ ++ int i, j, last_len, num_blocks; ++ u8 b[AES_BLOCK_SIZE]; ++ u8 s_0[AES_BLOCK_SIZE]; ++ u8 e[AES_BLOCK_SIZE]; ++ u8 *pos, *cpos; ++ ++ num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE); ++ last_len = data_len % AES_BLOCK_SIZE; ++ aes_ccm_prepare(tfm, b_0, aad, s_0, b, b); ++ ++ /* Process payload blocks */ ++ pos = data; ++ cpos = data; ++ for (j = 1; j <= num_blocks; j++) { ++ int blen = (j == num_blocks && last_len) ? ++ last_len : AES_BLOCK_SIZE; ++ ++ /* Authentication followed by encryption */ ++ for (i = 0; i < blen; i++) ++ b[i] ^= pos[i]; ++ crypto_cipher_encrypt_one(tfm, b, b); ++ ++ b_0[14] = (j >> 8) & 0xff; ++ b_0[15] = j & 0xff; ++ crypto_cipher_encrypt_one(tfm, e, b_0); ++ for (i = 0; i < blen; i++) ++ *cpos++ = *pos++ ^ e[i]; ++ } ++ ++ for (i = 0; i < mic_len; i++) ++ mic[i] = b[i] ^ s_0[i]; ++} ++ ++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic, ++ size_t mic_len) ++{ ++ int i, j, last_len, num_blocks; ++ u8 *pos, *cpos; ++ u8 a[AES_BLOCK_SIZE]; ++ u8 b[AES_BLOCK_SIZE]; ++ u8 s_0[AES_BLOCK_SIZE]; ++ ++ num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE); ++ last_len = data_len % AES_BLOCK_SIZE; ++ aes_ccm_prepare(tfm, b_0, aad, s_0, a, b); ++ ++ /* Process payload blocks */ ++ cpos = data; ++ pos = data; ++ for (j = 1; j <= num_blocks; j++) { ++ int blen = (j == num_blocks && last_len) ? ++ last_len : AES_BLOCK_SIZE; ++ ++ /* Decryption followed by authentication */ ++ b_0[14] = (j >> 8) & 0xff; ++ b_0[15] = j & 0xff; ++ crypto_cipher_encrypt_one(tfm, b, b_0); ++ for (i = 0; i < blen; i++) { ++ *pos = *cpos++ ^ b[i]; ++ a[i] ^= *pos++; ++ } ++ crypto_cipher_encrypt_one(tfm, a, a); ++ } ++ ++ for (i = 0; i < mic_len; i++) { ++ if ((mic[i] ^ s_0[i]) != a[i]) ++ return -1; ++ } ++ ++ return 0; ++} ++ ++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[], ++ size_t key_len, ++ size_t mic_len) ++{ ++ struct crypto_cipher *tfm; ++ ++ tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); ++ if (!IS_ERR(tfm)) ++ crypto_cipher_setkey(tfm, key, key_len); ++ ++ return tfm; ++} ++ ++ ++void ieee80211_aes_key_free(struct crypto_cipher *tfm) ++{ ++ crypto_free_cipher(tfm); ++} +--- a/net/mac80211/Kconfig ++++ b/net/mac80211/Kconfig +@@ -6,8 +6,6 @@ config MAC80211 + depends on CRYPTO + select BPAUTO_CRYPTO_LIB_ARC4 + depends on CRYPTO_AES +- depends on CRYPTO_CCM +- depends on CRYPTO_GCM + depends on CRYPTO_CMAC + depends on CRC32 + help +--- a/net/mac80211/aes_gmac.h ++++ b/net/mac80211/aes_gmac.h +@@ -12,10 +12,22 @@ + #define GMAC_MIC_LEN 16 + #define GMAC_NONCE_LEN 12 + +-struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[], +- size_t key_len); +-int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, +- const u8 *data, size_t data_len, u8 *mic); +-void ieee80211_aes_gmac_key_free(struct crypto_aead *tfm); ++static inline struct crypto_aead * ++ieee80211_aes_gmac_key_setup(const u8 key[], size_t key_len) ++{ ++ return NULL; ++} ++ ++static inline int ++ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, ++ const u8 *data, size_t data_len, u8 *mic) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static inline void ++ieee80211_aes_gmac_key_free(struct crypto_aead *tfm) ++{ ++} + + #endif /* AES_GMAC_H */ +--- a/net/mac80211/key.h ++++ b/net/mac80211/key.h +@@ -89,7 +89,7 @@ struct ieee80211_key { + * Management frames. + */ + u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN]; +- struct crypto_aead *tfm; ++ struct crypto_cipher *tfm; + u32 replays; /* dot11RSNAStatsCCMPReplays */ + } ccmp; + struct { diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch new file mode 100644 index 000000000..e56055caf --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch @@ -0,0 +1,12 @@ +Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnects + +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1197,7 +1197,6 @@ static int ieee80211_stop_ap(struct wiph + sdata->vif.bss_conf.ftmr_params = NULL; + + __sta_info_flush(sdata, true); +- ieee80211_free_keys(sdata, true); + + sdata->vif.bss_conf.enable_beacon = false; + sdata->beacon_rate_set = false; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch new file mode 100644 index 000000000..172e5b04f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch @@ -0,0 +1,43 @@ +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -23,18 +23,35 @@ static inline struct cfg80211_registered + return container_of(dev, struct cfg80211_registered_device, wiphy.dev); + } + +-#define SHOW_FMT(name, fmt, member) \ ++#define SHOW_FMT(name, fmt, member, mode) \ + static ssize_t name ## _show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ + } \ +-static DEVICE_ATTR_RO(name) ++static DEVICE_ATTR_##mode(name) + +-SHOW_FMT(index, "%d", wiphy_idx); +-SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); +-SHOW_FMT(address_mask, "%pM", wiphy.addr_mask); ++static ssize_t macaddress_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, size_t len) ++{ ++ u8 mac[ETH_ALEN]; ++ ++ if (!mac_pton(buf, mac)) ++ return -EINVAL; ++ ++ if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') ++ return -EINVAL; ++ ++ memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN); ++ ++ return strnlen(buf, len); ++} ++ ++SHOW_FMT(index, "%d", wiphy_idx, RO); ++SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW); ++SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO); + + static ssize_t name_show(struct device *dev, + struct device_attribute *attr, diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/131-Revert-mac80211-aes-cmac-switch-to-shash-CMAC-driver.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/131-Revert-mac80211-aes-cmac-switch-to-shash-CMAC-driver.patch new file mode 100644 index 000000000..c3bf7ccc7 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/131-Revert-mac80211-aes-cmac-switch-to-shash-CMAC-driver.patch @@ -0,0 +1,230 @@ +From: Felix Fietkau +Date: Sat, 7 Oct 2017 09:37:28 +0200 +Subject: [PATCH] Revert "mac80211: aes-cmac: switch to shash CMAC + driver" + +This reverts commit 26717828b75dd5c46e97f7f4a9b937d038bb2852. +Reduces mac80211 dependencies for LEDE + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/aes_cmac.c ++++ b/net/mac80211/aes_cmac.c +@@ -19,67 +19,151 @@ + #define CMAC_TLEN_256 16 /* CMAC TLen = 128 bits (16 octets) */ + #define AAD_LEN 20 + +-static const u8 zero[CMAC_TLEN_256]; + +-void ieee80211_aes_cmac(struct crypto_shash *tfm, const u8 *aad, ++void gf_mulx(u8 *pad) ++{ ++ int i, carry; ++ ++ carry = pad[0] & 0x80; ++ for (i = 0; i < AES_BLOCK_SIZE - 1; i++) ++ pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7); ++ pad[AES_BLOCK_SIZE - 1] <<= 1; ++ if (carry) ++ pad[AES_BLOCK_SIZE - 1] ^= 0x87; ++} ++ ++void aes_cmac_vector(struct crypto_cipher *tfm, size_t num_elem, ++ const u8 *addr[], const size_t *len, u8 *mac, ++ size_t mac_len) ++{ ++ u8 cbc[AES_BLOCK_SIZE], pad[AES_BLOCK_SIZE]; ++ const u8 *pos, *end; ++ size_t i, e, left, total_len; ++ ++ memset(cbc, 0, AES_BLOCK_SIZE); ++ ++ total_len = 0; ++ for (e = 0; e < num_elem; e++) ++ total_len += len[e]; ++ left = total_len; ++ ++ e = 0; ++ pos = addr[0]; ++ end = pos + len[0]; ++ ++ while (left >= AES_BLOCK_SIZE) { ++ for (i = 0; i < AES_BLOCK_SIZE; i++) { ++ cbc[i] ^= *pos++; ++ if (pos >= end) { ++ e++; ++ pos = addr[e]; ++ end = pos + len[e]; ++ } ++ } ++ if (left > AES_BLOCK_SIZE) ++ crypto_cipher_encrypt_one(tfm, cbc, cbc); ++ left -= AES_BLOCK_SIZE; ++ } ++ ++ memset(pad, 0, AES_BLOCK_SIZE); ++ crypto_cipher_encrypt_one(tfm, pad, pad); ++ gf_mulx(pad); ++ ++ if (left || total_len == 0) { ++ for (i = 0; i < left; i++) { ++ cbc[i] ^= *pos++; ++ if (pos >= end) { ++ e++; ++ pos = addr[e]; ++ end = pos + len[e]; ++ } ++ } ++ cbc[left] ^= 0x80; ++ gf_mulx(pad); ++ } ++ ++ for (i = 0; i < AES_BLOCK_SIZE; i++) ++ pad[i] ^= cbc[i]; ++ crypto_cipher_encrypt_one(tfm, pad, pad); ++ memcpy(mac, pad, mac_len); ++} ++ ++ ++void ieee80211_aes_cmac(struct crypto_cipher *tfm, const u8 *aad, + const u8 *data, size_t data_len, u8 *mic) + { +- SHASH_DESC_ON_STACK(desc, tfm); +- u8 out[AES_BLOCK_SIZE]; ++ const u8 *addr[4]; ++ size_t len[4]; ++ u8 zero[CMAC_TLEN]; + const __le16 *fc; + +- desc->tfm = tfm; +- +- crypto_shash_init(desc); +- crypto_shash_update(desc, aad, AAD_LEN); ++ memset(zero, 0, CMAC_TLEN); ++ addr[0] = aad; ++ len[0] = AAD_LEN; + fc = (const __le16 *)aad; + if (ieee80211_is_beacon(*fc)) { + /* mask Timestamp field to zero */ +- crypto_shash_update(desc, zero, 8); +- crypto_shash_update(desc, data + 8, data_len - 8 - CMAC_TLEN); ++ addr[1] = zero; ++ len[1] = 8; ++ addr[2] = data + 8; ++ len[2] = data_len - 8 - CMAC_TLEN; ++ addr[3] = zero; ++ len[3] = CMAC_TLEN; ++ aes_cmac_vector(tfm, 4, addr, len, mic, CMAC_TLEN); + } else { +- crypto_shash_update(desc, data, data_len - CMAC_TLEN); ++ addr[1] = data; ++ len[1] = data_len - CMAC_TLEN; ++ addr[2] = zero; ++ len[2] = CMAC_TLEN; ++ aes_cmac_vector(tfm, 3, addr, len, mic, CMAC_TLEN); + } +- crypto_shash_finup(desc, zero, CMAC_TLEN, out); +- +- memcpy(mic, out, CMAC_TLEN); + } + +-void ieee80211_aes_cmac_256(struct crypto_shash *tfm, const u8 *aad, ++void ieee80211_aes_cmac_256(struct crypto_cipher *tfm, const u8 *aad, + const u8 *data, size_t data_len, u8 *mic) + { +- SHASH_DESC_ON_STACK(desc, tfm); ++ const u8 *addr[4]; ++ size_t len[4]; ++ u8 zero[CMAC_TLEN_256]; + const __le16 *fc; + +- desc->tfm = tfm; +- +- crypto_shash_init(desc); +- crypto_shash_update(desc, aad, AAD_LEN); ++ memset(zero, 0, CMAC_TLEN_256); ++ addr[0] = aad; ++ len[0] = AAD_LEN; ++ addr[1] = data; + fc = (const __le16 *)aad; + if (ieee80211_is_beacon(*fc)) { + /* mask Timestamp field to zero */ +- crypto_shash_update(desc, zero, 8); +- crypto_shash_update(desc, data + 8, +- data_len - 8 - CMAC_TLEN_256); ++ addr[1] = zero; ++ len[1] = 8; ++ addr[2] = data + 8; ++ len[2] = data_len - 8 - CMAC_TLEN_256; ++ addr[3] = zero; ++ len[3] = CMAC_TLEN_256; ++ aes_cmac_vector(tfm, 4, addr, len, mic, CMAC_TLEN_256); + } else { +- crypto_shash_update(desc, data, data_len - CMAC_TLEN_256); ++ addr[1] = data; ++ len[1] = data_len - CMAC_TLEN_256; ++ addr[2] = zero; ++ len[2] = CMAC_TLEN_256; ++ aes_cmac_vector(tfm, 3, addr, len, mic, CMAC_TLEN_256); + } +- crypto_shash_finup(desc, zero, CMAC_TLEN_256, mic); + } + +-struct crypto_shash *ieee80211_aes_cmac_key_setup(const u8 key[], +- size_t key_len) ++struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[], ++ size_t key_len) + { +- struct crypto_shash *tfm; ++ struct crypto_cipher *tfm; + +- tfm = crypto_alloc_shash("cmac(aes)", 0, 0); ++ tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + if (!IS_ERR(tfm)) +- crypto_shash_setkey(tfm, key, key_len); ++ crypto_cipher_setkey(tfm, key, key_len); + + return tfm; + } + +-void ieee80211_aes_cmac_key_free(struct crypto_shash *tfm) ++ ++void ieee80211_aes_cmac_key_free(struct crypto_cipher *tfm) + { +- crypto_free_shash(tfm); ++ crypto_free_cipher(tfm); + } +--- a/net/mac80211/aes_cmac.h ++++ b/net/mac80211/aes_cmac.h +@@ -7,14 +7,13 @@ + #define AES_CMAC_H + + #include +-#include + +-struct crypto_shash *ieee80211_aes_cmac_key_setup(const u8 key[], +- size_t key_len); +-void ieee80211_aes_cmac(struct crypto_shash *tfm, const u8 *aad, ++struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[], ++ size_t key_len); ++void ieee80211_aes_cmac(struct crypto_cipher *tfm, const u8 *aad, + const u8 *data, size_t data_len, u8 *mic); +-void ieee80211_aes_cmac_256(struct crypto_shash *tfm, const u8 *aad, ++void ieee80211_aes_cmac_256(struct crypto_cipher *tfm, const u8 *aad, + const u8 *data, size_t data_len, u8 *mic); +-void ieee80211_aes_cmac_key_free(struct crypto_shash *tfm); ++void ieee80211_aes_cmac_key_free(struct crypto_cipher *tfm); + + #endif /* AES_CMAC_H */ +--- a/net/mac80211/key.h ++++ b/net/mac80211/key.h +@@ -94,7 +94,7 @@ struct ieee80211_key { + } ccmp; + struct { + u8 rx_pn[IEEE80211_CMAC_PN_LEN]; +- struct crypto_shash *tfm; ++ struct crypto_cipher *tfm; + u32 replays; /* dot11RSNAStatsCMACReplays */ + u32 icverrors; /* dot11RSNAStatsCMACICVErrors */ + } aes_cmac; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/132-mac80211-remove-cmac-dependency.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/132-mac80211-remove-cmac-dependency.patch new file mode 100644 index 000000000..df67d2f10 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/132-mac80211-remove-cmac-dependency.patch @@ -0,0 +1,10 @@ +--- a/net/mac80211/Kconfig ++++ b/net/mac80211/Kconfig +@@ -6,7 +6,6 @@ config MAC80211 + depends on CRYPTO + select BPAUTO_CRYPTO_LIB_ARC4 + depends on CRYPTO_AES +- depends on CRYPTO_CMAC + depends on CRC32 + help + This option enables the hardware independent IEEE 802.11 diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/150-disable_addr_notifier.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/150-disable_addr_notifier.patch new file mode 100644 index 000000000..8a717558a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/150-disable_addr_notifier.patch @@ -0,0 +1,67 @@ +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -321,7 +321,7 @@ void ieee80211_restart_hw(struct ieee802 + } + EXPORT_SYMBOL(ieee80211_restart_hw); + +-#ifdef CONFIG_INET ++#ifdef __disabled__CONFIG_INET + static int ieee80211_ifa_changed(struct notifier_block *nb, + unsigned long data, void *arg) + { +@@ -380,7 +380,7 @@ static int ieee80211_ifa_changed(struct + } + #endif + +-#if IS_ENABLED(CONFIG_IPV6) ++#if IS_ENABLED(__disabled__CONFIG_IPV6) + static int ieee80211_ifa6_changed(struct notifier_block *nb, + unsigned long data, void *arg) + { +@@ -1301,14 +1301,14 @@ int ieee80211_register_hw(struct ieee802 + + rtnl_unlock(); + +-#ifdef CONFIG_INET ++#ifdef __disabled__CONFIG_INET + local->ifa_notifier.notifier_call = ieee80211_ifa_changed; + result = register_inetaddr_notifier(&local->ifa_notifier); + if (result) + goto fail_ifa; + #endif + +-#if IS_ENABLED(CONFIG_IPV6) ++#if IS_ENABLED(__disabled__CONFIG_IPV6) + local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed; + result = register_inet6addr_notifier(&local->ifa6_notifier); + if (result) +@@ -1317,13 +1317,13 @@ int ieee80211_register_hw(struct ieee802 + + return 0; + +-#if IS_ENABLED(CONFIG_IPV6) ++#if IS_ENABLED(__disabled__CONFIG_IPV6) + fail_ifa6: +-#ifdef CONFIG_INET ++#ifdef __disabled__CONFIG_INET + unregister_inetaddr_notifier(&local->ifa_notifier); + #endif + #endif +-#if defined(CONFIG_INET) || defined(CONFIG_IPV6) ++#if defined(__disabled__CONFIG_INET) || defined(__disabled__CONFIG_IPV6) + fail_ifa: + #endif + wiphy_unregister(local->hw.wiphy); +@@ -1351,10 +1351,10 @@ void ieee80211_unregister_hw(struct ieee + tasklet_kill(&local->tx_pending_tasklet); + tasklet_kill(&local->tasklet); + +-#ifdef CONFIG_INET ++#ifdef __disabled__CONFIG_INET + unregister_inetaddr_notifier(&local->ifa_notifier); + #endif +-#if IS_ENABLED(CONFIG_IPV6) ++#if IS_ENABLED(__disabled__CONFIG_IPV6) + unregister_inet6addr_notifier(&local->ifa6_notifier); + #endif + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/210-ap_scan.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/210-ap_scan.patch new file mode 100644 index 000000000..8ccab8cf6 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/210-ap_scan.patch @@ -0,0 +1,11 @@ +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2345,7 +2345,7 @@ static int ieee80211_scan(struct wiphy * + * the frames sent while scanning on other channel will be + * lost) + */ +- if (sdata->u.ap.beacon && ++ if (0 && sdata->u.ap.beacon && + (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || + !(req->flags & NL80211_SCAN_FLAG_AP))) + return -EOPNOTSUPP; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/300-mac80211-optimize-skb-resizing.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/300-mac80211-optimize-skb-resizing.patch new file mode 100644 index 000000000..bcdfa22ff --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/300-mac80211-optimize-skb-resizing.patch @@ -0,0 +1,201 @@ +From: Felix Fietkau +Date: Sun, 17 Mar 2019 18:11:30 +0100 +Subject: [PATCH] mac80211: optimize skb resizing + +When forwarding unicast packets from ethernet to batman-adv over 802.11s +(with forwarding disabled), the typical required headroom to transmit +encrypted packets on mt76 is 32 (802.11) + 6 (802.11s) + 8 (CCMP) + +2 (padding) + 6 (LLC) + 18 (batman-adv) - 14 (old ethernet header) = 58 bytes. + +On systems where NET_SKB_PAD is 64 this leads to a call to pskb_expand_head +for every packet, since mac80211 also tries to allocate 16 bytes status +headroom for radiotap headers. + +This patch fixes these unnecessary reallocations by only requiring the extra +status headroom in ieee80211_tx_monitor() +If however a reallocation happens before that call, the status headroom gets +added there as well, in order to avoid double reallocation. + +The patch also cleans up the code by moving the headroom calculation to +ieee80211_skb_resize. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -1809,6 +1809,9 @@ int ieee80211_tx_control_port(struct wip + u64 *cookie); + int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev, + const u8 *buf, size_t len); ++int ieee80211_skb_resize(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata, ++ struct sk_buff *skb, int hdrlen, int hdr_add); + + /* HT */ + void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -843,6 +843,11 @@ void ieee80211_tx_monitor(struct ieee802 + struct net_device *prev_dev = NULL; + int rtap_len; + ++ if (ieee80211_skb_resize(local, NULL, skb, 0, 0)) { ++ dev_kfree_skb(skb); ++ return; ++ } ++ + /* send frame to monitor interfaces now */ + rtap_len = ieee80211_tx_radiotap_len(info, status); + if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) { +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -1937,37 +1937,53 @@ static bool ieee80211_tx(struct ieee8021 + } + + /* device xmit handlers */ +- +-static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, +- struct sk_buff *skb, +- int head_need, bool may_encrypt) ++int ieee80211_skb_resize(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata, ++ struct sk_buff *skb, int hdr_len, int hdr_extra) + { +- struct ieee80211_local *local = sdata->local; ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr; +- bool enc_tailroom; +- int tail_need = 0; +- +- hdr = (struct ieee80211_hdr *) skb->data; +- enc_tailroom = may_encrypt && +- (sdata->crypto_tx_tailroom_needed_cnt || +- ieee80211_is_mgmt(hdr->frame_control)); +- +- if (enc_tailroom) { +- tail_need = IEEE80211_ENCRYPT_TAILROOM; +- tail_need -= skb_tailroom(skb); +- tail_need = max_t(int, tail_need, 0); ++ int head_need, head_max; ++ int tail_need, tail_max; ++ bool enc_tailroom = false; ++ ++ if (sdata && !hdr_len && ++ !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) { ++ hdr = (struct ieee80211_hdr *) skb->data; ++ enc_tailroom = (sdata->crypto_tx_tailroom_needed_cnt || ++ ieee80211_is_mgmt(hdr->frame_control)); ++ hdr_len += sdata->encrypt_headroom; ++ } ++ ++ head_need = head_max = hdr_len; ++ tail_need = tail_max = 0; ++ if (!sdata) { ++ head_need = head_max = local->tx_headroom; ++ } else { ++ head_max += hdr_extra; ++ head_max += max_t(int, local->tx_headroom, ++ local->hw.extra_tx_headroom); ++ head_need += local->hw.extra_tx_headroom; ++ ++ tail_max = IEEE80211_ENCRYPT_TAILROOM; ++ if (enc_tailroom) ++ tail_need = tail_max; + } + + if (skb_cloned(skb) && + (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || + !skb_clone_writable(skb, ETH_HLEN) || enc_tailroom)) + I802_DEBUG_INC(local->tx_expand_skb_head_cloned); +- else if (head_need || tail_need) ++ else if (head_need > skb_headroom(skb) || ++ tail_need > skb_tailroom(skb)) + I802_DEBUG_INC(local->tx_expand_skb_head); + else + return 0; + +- if (pskb_expand_head(skb, head_need, tail_need, GFP_ATOMIC)) { ++ head_max = max_t(int, 0, head_max - skb_headroom(skb)); ++ tail_max = max_t(int, 0, tail_max - skb_tailroom(skb)); ++ ++ if (pskb_expand_head(skb, head_max, tail_max, GFP_ATOMIC)) { + wiphy_debug(local->hw.wiphy, + "failed to reallocate TX buffer\n"); + return -ENOMEM; +@@ -1983,18 +1999,8 @@ void ieee80211_xmit(struct ieee80211_sub + struct ieee80211_local *local = sdata->local; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr; +- int headroom; +- bool may_encrypt; +- +- may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); + +- headroom = local->tx_headroom; +- if (may_encrypt) +- headroom += sdata->encrypt_headroom; +- headroom -= skb_headroom(skb); +- headroom = max_t(int, 0, headroom); +- +- if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { ++ if (ieee80211_skb_resize(local, sdata, skb, 0, 0)) { + ieee80211_free_txskb(&local->hw, skb); + return; + } +@@ -2809,29 +2815,13 @@ static struct sk_buff *ieee80211_build_h + } + + skb_pull(skb, skip_header_bytes); +- head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); ++ head_need = hdrlen + encaps_len + meshhdrlen; + +- /* +- * So we need to modify the skb header and hence need a copy of +- * that. The head_need variable above doesn't, so far, include +- * the needed header space that we don't need right away. If we +- * can, then we don't reallocate right now but only after the +- * frame arrives at the master device (if it does...) +- * +- * If we cannot, however, then we will reallocate to include all +- * the ever needed space. Also, if we need to reallocate it anyway, +- * make it big enough for everything we may ever need. +- */ +- +- if (head_need > 0 || skb_cloned(skb)) { +- head_need += sdata->encrypt_headroom; +- head_need += local->tx_headroom; +- head_need = max_t(int, 0, head_need); +- if (ieee80211_skb_resize(sdata, skb, head_need, true)) { +- ieee80211_free_txskb(&local->hw, skb); +- skb = NULL; +- return ERR_PTR(-ENOMEM); +- } ++ if (ieee80211_skb_resize(local, sdata, skb, head_need, ++ sdata->encrypt_headroom)) { ++ ieee80211_free_txskb(&local->hw, skb); ++ skb = NULL; ++ return ERR_PTR(-ENOMEM); + } + + if (encaps_data) +@@ -3446,7 +3436,6 @@ static bool ieee80211_xmit_fast(struct i + struct ieee80211_local *local = sdata->local; + u16 ethertype = (skb->data[12] << 8) | skb->data[13]; + int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); +- int hw_headroom = sdata->local->hw.extra_tx_headroom; + struct ethhdr eth; + struct ieee80211_tx_info *info; + struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; +@@ -3498,10 +3487,7 @@ static bool ieee80211_xmit_fast(struct i + * as the may-encrypt argument for the resize to not account for + * more room than we already have in 'extra_head' + */ +- if (unlikely(ieee80211_skb_resize(sdata, skb, +- max_t(int, extra_head + hw_headroom - +- skb_headroom(skb), 0), +- false))) { ++ if (unlikely(ieee80211_skb_resize(local, sdata, skb, extra_head, 0))) { + kfree_skb(skb); + return true; + } diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch new file mode 100644 index 000000000..10d8ad8d7 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch @@ -0,0 +1,38 @@ +From b478e06a16a8baa00c5ecc87c1d636981f2206d5 Mon Sep 17 00:00:00 2001 +From: Johannes Berg +Date: Tue, 29 Oct 2019 10:25:25 +0100 +Subject: [PATCH] mac80211: sta: randomize BA session dialog token allocator + +We currently always start the dialog token generator at zero, +so the first dialog token we use is always 1. This would be +OK if we had a perfect guarantee that we always do a proper +deauth/re-auth handshake, but in IBSS mode this doesn't always +happen properly. + +To make problems with block ack (aggregation) sessions getting +stuck less likely, randomize the dialog token so if we start a +new session but the peer still has old state for us, it can +better detect this. + +This is really just a workaround to make things a bit more +robust than they are now - a better fix would be to do a full +authentication handshake in IBSS mode upon having discovered a +new station, and on the receiver resetting the state (removing +and re-adding the station) on receiving the authentication +packet. + +Signed-off-by: Johannes Berg +--- + net/mac80211/sta_info.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -339,6 +339,7 @@ struct sta_info *sta_info_alloc(struct i + INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); + INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); + mutex_init(&sta->ampdu_mlme.mtx); ++ sta->ampdu_mlme.dialog_token_allocator = prandom_u32_max(U8_MAX); + #ifdef CPTCFG_MAC80211_MESH + if (ieee80211_vif_is_mesh(&sdata->vif)) { + sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/305-mac80211-improve-AQL-tx-airtime-estimation.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/305-mac80211-improve-AQL-tx-airtime-estimation.patch new file mode 100644 index 000000000..bee43a60f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/305-mac80211-improve-AQL-tx-airtime-estimation.patch @@ -0,0 +1,81 @@ +From: Felix Fietkau +Date: Fri, 24 Jul 2020 20:25:07 +0200 +Subject: [PATCH] mac80211: improve AQL tx airtime estimation + +AQL does not take into account that most HT/VHT/HE traffic is A-MPDU aggregated. +Because of that, the per-packet airtime overhead is vastly overestimated. +Improve it by assuming an average aggregation length of 16 for non-legacy +traffic if not using the VO AC queue. +This should improve performance with high data rates, especially with multiple +stations + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(ieee80211_calc_tx_airt + u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *pubsta, +- int len) ++ int len, bool ampdu) + { + struct ieee80211_supported_band *sband; + struct ieee80211_chanctx_conf *conf; +@@ -572,10 +572,26 @@ u32 ieee80211_calc_expected_tx_airtime(s + if (pubsta) { + struct sta_info *sta = container_of(pubsta, struct sta_info, + sta); ++ struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate; ++ u32 airtime; + +- return ieee80211_calc_tx_airtime_rate(hw, +- &sta->tx_stats.last_rate, +- band, len); ++ if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS | ++ IEEE80211_TX_RC_MCS))) ++ ampdu = false; ++ ++ /* ++ * Assume that HT/VHT transmission on any AC except VO will ++ * use aggregation. Since we don't have reliable reporting ++ * of aggregation length, assume an average of 16. ++ * This will not be very accurate, but much better than simply ++ * assuming un-aggregated tx. ++ */ ++ airtime = ieee80211_calc_tx_airtime_rate(hw, rate, band, ++ ampdu ? len * 16 : len); ++ if (ampdu) ++ airtime /= 16; ++ ++ return airtime; + } + + if (!conf) +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -2294,7 +2294,7 @@ extern const struct ethtool_ops ieee8021 + u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *pubsta, +- int len); ++ int len, bool ampdu); + #ifdef CPTCFG_MAC80211_NOINLINE + #define debug_noinline noinline + #else +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3707,10 +3707,11 @@ encap_out: + + if (vif && + wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { ++ bool ampdu = txq->ac != IEEE80211_AC_VO; + u32 airtime; + + airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, +- skb->len); ++ skb->len, ampdu); + if (airtime) { + airtime = ieee80211_info_set_tx_time_est(info, airtime); + ieee80211_sta_update_pending_airtime(local, tx.sta, diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/307-mac80211-add-a-function-for-running-rx-without-passi.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/307-mac80211-add-a-function-for-running-rx-without-passi.patch new file mode 100644 index 000000000..1bcb41461 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/307-mac80211-add-a-function-for-running-rx-without-passi.patch @@ -0,0 +1,186 @@ +From: Felix Fietkau +Date: Sat, 25 Jul 2020 20:53:23 +0200 +Subject: [PATCH] mac80211: add a function for running rx without passing skbs + to the stack + +This can be used to run mac80211 rx processing on a batch of frames in NAPI +poll before passing them to the network stack in a large batch. +This can improve icache footprint, or it can be used to pass frames via +netif_receive_skb_list. + +Signed-off-by: Felix Fietkau +--- + +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -4358,6 +4358,31 @@ void ieee80211_free_hw(struct ieee80211_ + void ieee80211_restart_hw(struct ieee80211_hw *hw); + + /** ++ * ieee80211_rx_list - receive frame and store processed skbs in a list ++ * ++ * Use this function to hand received frames to mac80211. The receive ++ * buffer in @skb must start with an IEEE 802.11 header. In case of a ++ * paged @skb is used, the driver is recommended to put the ieee80211 ++ * header of the frame on the linear part of the @skb to avoid memory ++ * allocation and/or memcpy by the stack. ++ * ++ * This function may not be called in IRQ context. Calls to this function ++ * for a single hardware must be synchronized against each other. Calls to ++ * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be ++ * mixed for a single hardware. Must not run concurrently with ++ * ieee80211_tx_status() or ieee80211_tx_status_ni(). ++ * ++ * This function must be called with BHs disabled and RCU read lock ++ * ++ * @hw: the hardware this frame came in on ++ * @sta: the station the frame was received from, or %NULL ++ * @skb: the buffer to receive, owned by mac80211 after this call ++ * @list: the destination list ++ */ ++void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta, ++ struct sk_buff *skb, struct list_head *list); ++ ++/** + * ieee80211_rx_napi - receive frame from NAPI context + * + * Use this function to hand received frames to mac80211. The receive +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -218,7 +218,7 @@ enum ieee80211_rx_flags { + }; + + struct ieee80211_rx_data { +- struct napi_struct *napi; ++ struct list_head *list; + struct sk_buff *skb; + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -2578,8 +2578,8 @@ static void ieee80211_deliver_skb_to_loc + memset(skb->cb, 0, sizeof(skb->cb)); + + /* deliver to local stack */ +- if (rx->napi) +- napi_gro_receive(rx->napi, skb); ++ if (rx->list) ++ list_add_tail(&skb->list, rx->list); + else + netif_receive_skb(skb); + } +@@ -3869,7 +3869,6 @@ void ieee80211_release_reorder_timeout(s + /* This is OK -- must be QoS data frame */ + .security_idx = tid, + .seqno_idx = tid, +- .napi = NULL, /* must be NULL to not have races */ + }; + struct tid_ampdu_rx *tid_agg_rx; + +@@ -4479,8 +4478,8 @@ static bool ieee80211_invoke_fast_rx(str + /* deliver to local stack */ + skb->protocol = eth_type_trans(skb, fast_rx->dev); + memset(skb->cb, 0, sizeof(skb->cb)); +- if (rx->napi) +- napi_gro_receive(rx->napi, skb); ++ if (rx->list) ++ list_add_tail(&skb->list, rx->list); + else + netif_receive_skb(skb); + +@@ -4547,7 +4546,7 @@ static bool ieee80211_prepare_and_rx_han + static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, + struct ieee80211_sta *pubsta, + struct sk_buff *skb, +- struct napi_struct *napi) ++ struct list_head *list) + { + struct ieee80211_local *local = hw_to_local(hw); + struct ieee80211_sub_if_data *sdata; +@@ -4562,7 +4561,7 @@ static void __ieee80211_rx_handle_packet + memset(&rx, 0, sizeof(rx)); + rx.skb = skb; + rx.local = local; +- rx.napi = napi; ++ rx.list = list; + + if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) + I802_DEBUG_INC(local->dot11ReceivedFragmentCount); +@@ -4670,8 +4669,8 @@ static void __ieee80211_rx_handle_packet + * This is the receive path handler. It is called by a low level driver when an + * 802.11 MPDU is received from the hardware. + */ +-void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, +- struct sk_buff *skb, struct napi_struct *napi) ++void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, ++ struct sk_buff *skb, struct list_head *list) + { + struct ieee80211_local *local = hw_to_local(hw); + struct ieee80211_rate *rate = NULL; +@@ -4763,36 +4762,53 @@ void ieee80211_rx_napi(struct ieee80211_ + status->rx_flags = 0; + + /* +- * key references and virtual interfaces are protected using RCU +- * and this requires that we are in a read-side RCU section during +- * receive processing +- */ +- rcu_read_lock(); +- +- /* + * Frames with failed FCS/PLCP checksum are not returned, + * all other frames are returned without radiotap header + * if it was previously present. + * Also, frames with less than 16 bytes are dropped. + */ + skb = ieee80211_rx_monitor(local, skb, rate); +- if (!skb) { +- rcu_read_unlock(); ++ if (!skb) + return; +- } + + ieee80211_tpt_led_trig_rx(local, + ((struct ieee80211_hdr *)skb->data)->frame_control, + skb->len); + +- __ieee80211_rx_handle_packet(hw, pubsta, skb, napi); +- +- rcu_read_unlock(); ++ __ieee80211_rx_handle_packet(hw, pubsta, skb, list); + + return; + drop: + kfree_skb(skb); + } ++EXPORT_SYMBOL(ieee80211_rx_list); ++ ++void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, ++ struct sk_buff *skb, struct napi_struct *napi) ++{ ++ struct sk_buff *tmp; ++ LIST_HEAD(list); ++ ++ ++ /* ++ * key references and virtual interfaces are protected using RCU ++ * and this requires that we are in a read-side RCU section during ++ * receive processing ++ */ ++ rcu_read_lock(); ++ ieee80211_rx_list(hw, pubsta, skb, &list); ++ rcu_read_unlock(); ++ ++ if (!napi) { ++ netif_receive_skb_list(&list); ++ return; ++ } ++ ++ list_for_each_entry_safe(skb, tmp, &list, list) { ++ skb_list_del_init(skb); ++ napi_gro_receive(napi, skb); ++ } ++} + EXPORT_SYMBOL(ieee80211_rx_napi); + + /* This is a version of the rx handler that can be called from hard irq diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/308-net-fq_impl-use-skb_get_hash-instead-of-skb_get_hash.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/308-net-fq_impl-use-skb_get_hash-instead-of-skb_get_hash.patch new file mode 100644 index 000000000..77ecc8230 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/308-net-fq_impl-use-skb_get_hash-instead-of-skb_get_hash.patch @@ -0,0 +1,55 @@ +From: Felix Fietkau +Date: Sun, 26 Jul 2020 14:37:02 +0200 +Subject: [PATCH] net/fq_impl: use skb_get_hash instead of + skb_get_hash_perturb + +This avoids unnecessary regenerating of the skb flow hash + +Signed-off-by: Felix Fietkau +--- + +--- a/include/net/fq.h ++++ b/include/net/fq.h +@@ -69,15 +69,6 @@ struct fq { + struct list_head backlogs; + spinlock_t lock; + u32 flows_cnt; +-#if LINUX_VERSION_IS_GEQ(5,3,10) || \ +- LINUX_VERSION_IN_RANGE(4,19,83, 4,20,0) || \ +- LINUX_VERSION_IN_RANGE(4,14,153, 4,15,0) || \ +- LINUX_VERSION_IN_RANGE(4,9,200, 4,10,0) || \ +- LINUX_VERSION_IN_RANGE(4,4,200, 4,5,0) +- siphash_key_t perturbation; +-#else +- u32 perturbation; +-#endif + u32 limit; + u32 memory_limit; + u32 memory_usage; +--- a/include/net/fq_impl.h ++++ b/include/net/fq_impl.h +@@ -108,15 +108,7 @@ begin: + + static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb) + { +-#if LINUX_VERSION_IS_GEQ(5,3,10) || \ +- LINUX_VERSION_IN_RANGE(4,19,83, 4,20,0) || \ +- LINUX_VERSION_IN_RANGE(4,14,153, 4,15,0) || \ +- LINUX_VERSION_IN_RANGE(4,9,200, 4,10,0) || \ +- LINUX_VERSION_IN_RANGE(4,4,200, 4,5,0) +- u32 hash = skb_get_hash_perturb(skb, &fq->perturbation); +-#else +- u32 hash = skb_get_hash_perturb(skb, fq->perturbation); +-#endif ++ u32 hash = skb_get_hash(skb); + + return reciprocal_scale(hash, fq->flows_cnt); + } +@@ -316,7 +308,6 @@ static int fq_init(struct fq *fq, int fl + INIT_LIST_HEAD(&fq->backlogs); + spin_lock_init(&fq->lock); + fq->flows_cnt = max_t(u32, flows_cnt, 1); +- get_random_bytes(&fq->perturbation, sizeof(fq->perturbation)); + fq->quantum = 300; + fq->limit = 8192; + fq->memory_limit = 16 << 20; /* 16 MBytes */ diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/309-mac80211-calculcate-skb-hash-early-when-using-itxq.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/309-mac80211-calculcate-skb-hash-early-when-using-itxq.patch new file mode 100644 index 000000000..92b136279 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/309-mac80211-calculcate-skb-hash-early-when-using-itxq.patch @@ -0,0 +1,19 @@ +From: Felix Fietkau +Date: Sun, 26 Jul 2020 14:42:58 +0200 +Subject: [PATCH] mac80211: calculcate skb hash early when using itxq + +This avoids flow separation issues when using software encryption + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3937,6 +3937,7 @@ void __ieee80211_subif_start_xmit(struct + if (local->ops->wake_tx_queue) { + u16 queue = __ieee80211_select_queue(sdata, sta, skb); + skb_set_queue_mapping(skb, queue); ++ skb_get_hash(skb); + } + + if (sta) { diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/310-mac80211-reduce-packet-loss-event-false-positives.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/310-mac80211-reduce-packet-loss-event-false-positives.patch new file mode 100644 index 000000000..62f2419dd --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/310-mac80211-reduce-packet-loss-event-false-positives.patch @@ -0,0 +1,116 @@ +From: Felix Fietkau +Date: Sat, 8 Aug 2020 19:20:02 +0200 +Subject: [PATCH] mac80211: reduce packet loss event false positives + +When running a large number of packets per second with a high data rate +and long A-MPDUs, the packet loss threshold can be reached very quickly +when the link conditions change. This frequently shows up as spurious +disconnects. +Mitigate false positives by using a similar logic for regular stations +as the one being used for TDLS, though with a more aggressive timeout. +Packet loss events are only reported if no ACK was received for a second. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/sta_info.h ++++ b/net/mac80211/sta_info.h +@@ -522,7 +522,7 @@ struct ieee80211_sta_rx_stats { + * @status_stats.retry_failed: # of frames that failed after retry + * @status_stats.retry_count: # of retries attempted + * @status_stats.lost_packets: # of lost packets +- * @status_stats.last_tdls_pkt_time: timestamp of last TDLS packet ++ * @status_stats.last_pkt_time: timestamp of last ACKed packet + * @status_stats.msdu_retries: # of MSDU retries + * @status_stats.msdu_failed: # of failed MSDUs + * @status_stats.last_ack: last ack timestamp (jiffies) +@@ -595,7 +595,7 @@ struct sta_info { + unsigned long filtered; + unsigned long retry_failed, retry_count; + unsigned int lost_packets; +- unsigned long last_tdls_pkt_time; ++ unsigned long last_pkt_time; + u64 msdu_retries[IEEE80211_NUM_TIDS + 1]; + u64 msdu_failed[IEEE80211_NUM_TIDS + 1]; + unsigned long last_ack; +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -757,12 +757,16 @@ static void ieee80211_report_used_skb(st + * - current throughput (higher value for higher tpt)? + */ + #define STA_LOST_PKT_THRESHOLD 50 ++#define STA_LOST_PKT_TIME HZ /* 1 sec since last ACK */ + #define STA_LOST_TDLS_PKT_THRESHOLD 10 + #define STA_LOST_TDLS_PKT_TIME (10*HZ) /* 10secs since last ACK */ + + static void ieee80211_lost_packet(struct sta_info *sta, + struct ieee80211_tx_info *info) + { ++ unsigned long pkt_time = STA_LOST_PKT_TIME; ++ unsigned int pkt_thr = STA_LOST_PKT_THRESHOLD; ++ + /* If driver relies on its own algorithm for station kickout, skip + * mac80211 packet loss mechanism. + */ +@@ -775,21 +779,20 @@ static void ieee80211_lost_packet(struct + return; + + sta->status_stats.lost_packets++; +- if (!sta->sta.tdls && +- sta->status_stats.lost_packets < STA_LOST_PKT_THRESHOLD) +- return; ++ if (sta->sta.tdls) { ++ pkt_time = STA_LOST_TDLS_PKT_TIME; ++ pkt_thr = STA_LOST_PKT_THRESHOLD; ++ } + + /* + * If we're in TDLS mode, make sure that all STA_LOST_TDLS_PKT_THRESHOLD + * of the last packets were lost, and that no ACK was received in the + * last STA_LOST_TDLS_PKT_TIME ms, before triggering the CQM packet-loss + * mechanism. ++ * For non-TDLS, use STA_LOST_PKT_THRESHOLD and STA_LOST_PKT_TIME + */ +- if (sta->sta.tdls && +- (sta->status_stats.lost_packets < STA_LOST_TDLS_PKT_THRESHOLD || +- time_before(jiffies, +- sta->status_stats.last_tdls_pkt_time + +- STA_LOST_TDLS_PKT_TIME))) ++ if (sta->status_stats.lost_packets < pkt_thr || ++ !time_after(jiffies, sta->status_stats.last_pkt_time + pkt_time)) + return; + + cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr, +@@ -1042,9 +1045,7 @@ static void __ieee80211_tx_status(struct + sta->status_stats.lost_packets = 0; + + /* Track when last TDLS packet was ACKed */ +- if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) +- sta->status_stats.last_tdls_pkt_time = +- jiffies; ++ sta->status_stats.last_pkt_time = jiffies; + } else if (noack_success) { + /* nothing to do here, do not account as lost */ + } else { +@@ -1177,9 +1178,8 @@ void ieee80211_tx_status_ext(struct ieee + if (sta->status_stats.lost_packets) + sta->status_stats.lost_packets = 0; + +- /* Track when last TDLS packet was ACKed */ +- if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) +- sta->status_stats.last_tdls_pkt_time = jiffies; ++ /* Track when last packet was ACKed */ ++ sta->status_stats.last_pkt_time = jiffies; + } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) { + return; + } else if (noack_success) { +@@ -1268,8 +1268,7 @@ void ieee80211_tx_status_8023(struct iee + if (sta->status_stats.lost_packets) + sta->status_stats.lost_packets = 0; + +- if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) +- sta->status_stats.last_tdls_pkt_time = jiffies; ++ sta->status_stats.last_pkt_time = jiffies; + } else { + ieee80211_lost_packet(sta, info); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/311-mac80211-use-rate-provided-via-status-rate-on-ieee80.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/311-mac80211-use-rate-provided-via-status-rate-on-ieee80.patch new file mode 100644 index 000000000..ee1db716e --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/311-mac80211-use-rate-provided-via-status-rate-on-ieee80.patch @@ -0,0 +1,151 @@ +From: Felix Fietkau +Date: Wed, 12 Aug 2020 17:04:22 +0200 +Subject: [PATCH] mac80211: use rate provided via status->rate on + ieee80211_tx_status_ext for AQL + +Since ieee80211_tx_info does not have enough room to encode HE rates, HE +drivers use status->rate to provide rate info. +Store it in struct sta_info and use it for AQL. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -487,14 +487,61 @@ u32 ieee80211_calc_rx_airtime(struct iee + } + EXPORT_SYMBOL_GPL(ieee80211_calc_rx_airtime); + ++static bool ieee80211_fill_rate_info(struct ieee80211_hw *hw, ++ struct ieee80211_rx_status *stat, u8 band, ++ struct rate_info *ri) ++{ ++ struct ieee80211_supported_band *sband = hw->wiphy->bands[band]; ++ int i; ++ ++ if (!ri || !sband) ++ return false; ++ ++ stat->bw = ri->bw; ++ stat->nss = ri->nss; ++ stat->rate_idx = ri->mcs; ++ ++ if (ri->flags & RATE_INFO_FLAGS_HE_MCS) ++ stat->encoding = RX_ENC_HE; ++ else if (ri->flags & RATE_INFO_FLAGS_VHT_MCS) ++ stat->encoding = RX_ENC_VHT; ++ else if (ri->flags & RATE_INFO_FLAGS_MCS) ++ stat->encoding = RX_ENC_HT; ++ else ++ stat->encoding = RX_ENC_LEGACY; ++ ++ if (ri->flags & RATE_INFO_FLAGS_SHORT_GI) ++ stat->enc_flags |= RX_ENC_FLAG_SHORT_GI; ++ ++ stat->he_gi = ri->he_gi; ++ ++ if (stat->encoding != RX_ENC_LEGACY) ++ return true; ++ ++ stat->rate_idx = 0; ++ for (i = 0; i < sband->n_bitrates; i++) { ++ if (ri->legacy != sband->bitrates[i].bitrate) ++ continue; ++ ++ stat->rate_idx = i; ++ return true; ++ } ++ ++ return false; ++} ++ + static u32 ieee80211_calc_tx_airtime_rate(struct ieee80211_hw *hw, + struct ieee80211_tx_rate *rate, ++ struct rate_info *ri, + u8 band, int len) + { + struct ieee80211_rx_status stat = { + .band = band, + }; + ++ if (ieee80211_fill_rate_info(hw, &stat, band, ri)) ++ goto out; ++ + if (rate->idx < 0 || !rate->count) + return 0; + +@@ -522,6 +569,7 @@ static u32 ieee80211_calc_tx_airtime_rat + stat.encoding = RX_ENC_LEGACY; + } + ++out: + return ieee80211_calc_rx_airtime(hw, &stat, len); + } + +@@ -536,7 +584,7 @@ u32 ieee80211_calc_tx_airtime(struct iee + struct ieee80211_tx_rate *rate = &info->status.rates[i]; + u32 cur_duration; + +- cur_duration = ieee80211_calc_tx_airtime_rate(hw, rate, ++ cur_duration = ieee80211_calc_tx_airtime_rate(hw, rate, NULL, + info->band, len); + if (!cur_duration) + break; +@@ -573,6 +621,7 @@ u32 ieee80211_calc_expected_tx_airtime(s + struct sta_info *sta = container_of(pubsta, struct sta_info, + sta); + struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate; ++ struct rate_info *ri = &sta->tx_stats.last_rate_info; + u32 airtime; + + if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS | +@@ -586,7 +635,7 @@ u32 ieee80211_calc_expected_tx_airtime(s + * This will not be very accurate, but much better than simply + * assuming un-aggregated tx. + */ +- airtime = ieee80211_calc_tx_airtime_rate(hw, rate, band, ++ airtime = ieee80211_calc_tx_airtime_rate(hw, rate, ri, band, + ampdu ? len * 16 : len); + if (ampdu) + airtime /= 16; +--- a/net/mac80211/sta_info.h ++++ b/net/mac80211/sta_info.h +@@ -609,6 +609,7 @@ struct sta_info { + u64 packets[IEEE80211_NUM_ACS]; + u64 bytes[IEEE80211_NUM_ACS]; + struct ieee80211_tx_rate last_rate; ++ struct rate_info last_rate_info; + u64 msdu[IEEE80211_NUM_TIDS + 1]; + } tx_stats; + u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -1147,9 +1147,17 @@ void ieee80211_tx_status_ext(struct ieee + struct ieee80211_tx_info *info = status->info; + struct ieee80211_sta *pubsta = status->sta; + struct ieee80211_supported_band *sband; ++ struct sta_info *sta; + int retry_count; + bool acked, noack_success; + ++ if (pubsta) { ++ sta = container_of(pubsta, struct sta_info, sta); ++ ++ if (status->rate) ++ sta->tx_stats.last_rate_info = *status->rate; ++ } ++ + if (status->skb) + return __ieee80211_tx_status(hw, status); + +@@ -1164,10 +1172,6 @@ void ieee80211_tx_status_ext(struct ieee + noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED); + + if (pubsta) { +- struct sta_info *sta; +- +- sta = container_of(pubsta, struct sta_info, sta); +- + if (!acked && !noack_success) + sta->status_stats.retry_failed++; + sta->status_stats.retry_count += retry_count; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/312-mac80211-factor-out-code-to-look-up-the-average-pack.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/312-mac80211-factor-out-code-to-look-up-the-average-pack.patch new file mode 100644 index 000000000..06db852c3 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/312-mac80211-factor-out-code-to-look-up-the-average-pack.patch @@ -0,0 +1,187 @@ +From: Felix Fietkau +Date: Wed, 12 Aug 2020 17:06:12 +0200 +Subject: [PATCH] mac80211: factor out code to look up the average packet + length duration for a rate + +This will be used to enhance AQL estimated aggregation length + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -405,18 +405,14 @@ ieee80211_calc_legacy_rate_duration(u16 + return duration; + } + +-u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw, +- struct ieee80211_rx_status *status, +- int len) ++static u32 ieee80211_get_rate_duration(struct ieee80211_hw *hw, ++ struct ieee80211_rx_status *status, ++ u32 *overhead) + { +- struct ieee80211_supported_band *sband; +- const struct ieee80211_rate *rate; + bool sgi = status->enc_flags & RX_ENC_FLAG_SHORT_GI; +- bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE; + int bw, streams; + int group, idx; + u32 duration; +- bool cck; + + switch (status->bw) { + case RATE_INFO_BW_20: +@@ -437,20 +433,6 @@ u32 ieee80211_calc_rx_airtime(struct iee + } + + switch (status->encoding) { +- case RX_ENC_LEGACY: +- if (WARN_ON_ONCE(status->band > NL80211_BAND_5GHZ)) +- return 0; +- +- sband = hw->wiphy->bands[status->band]; +- if (!sband || status->rate_idx >= sband->n_bitrates) +- return 0; +- +- rate = &sband->bitrates[status->rate_idx]; +- cck = rate->flags & IEEE80211_RATE_MANDATORY_B; +- +- return ieee80211_calc_legacy_rate_duration(rate->bitrate, sp, +- cck, len); +- + case RX_ENC_VHT: + streams = status->nss; + idx = status->rate_idx; +@@ -477,13 +459,47 @@ u32 ieee80211_calc_rx_airtime(struct iee + + duration = airtime_mcs_groups[group].duration[idx]; + duration <<= airtime_mcs_groups[group].shift; ++ *overhead = 36 + (streams << 2); ++ ++ return duration; ++} ++ ++ ++u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw, ++ struct ieee80211_rx_status *status, ++ int len) ++{ ++ struct ieee80211_supported_band *sband; ++ u32 duration, overhead = 0; ++ ++ if (status->encoding == RX_ENC_LEGACY) { ++ const struct ieee80211_rate *rate; ++ bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE; ++ bool cck; ++ ++ if (WARN_ON_ONCE(status->band > NL80211_BAND_5GHZ)) ++ return 0; ++ ++ sband = hw->wiphy->bands[status->band]; ++ if (!sband || status->rate_idx >= sband->n_bitrates) ++ return 0; ++ ++ rate = &sband->bitrates[status->rate_idx]; ++ cck = rate->flags & IEEE80211_RATE_MANDATORY_B; ++ ++ return ieee80211_calc_legacy_rate_duration(rate->bitrate, sp, ++ cck, len); ++ } ++ ++ duration = ieee80211_get_rate_duration(hw, status, &overhead); ++ if (!duration) ++ return 0; ++ + duration *= len; + duration /= AVG_PKT_SIZE; + duration /= 1024; + +- duration += 36 + (streams << 2); +- +- return duration; ++ return duration + overhead; + } + EXPORT_SYMBOL_GPL(ieee80211_calc_rx_airtime); + +@@ -530,46 +546,57 @@ static bool ieee80211_fill_rate_info(str + return false; + } + +-static u32 ieee80211_calc_tx_airtime_rate(struct ieee80211_hw *hw, +- struct ieee80211_tx_rate *rate, +- struct rate_info *ri, +- u8 band, int len) ++static int ieee80211_fill_rx_status(struct ieee80211_rx_status *stat, ++ struct ieee80211_hw *hw, ++ struct ieee80211_tx_rate *rate, ++ struct rate_info *ri, u8 band, int len) + { +- struct ieee80211_rx_status stat = { +- .band = band, +- }; ++ memset(stat, 0, sizeof(*stat)); ++ stat->band = band; + +- if (ieee80211_fill_rate_info(hw, &stat, band, ri)) +- goto out; ++ if (ieee80211_fill_rate_info(hw, stat, band, ri)) ++ return 0; + + if (rate->idx < 0 || !rate->count) +- return 0; ++ return -1; + + if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) +- stat.bw = RATE_INFO_BW_80; ++ stat->bw = RATE_INFO_BW_80; + else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) +- stat.bw = RATE_INFO_BW_40; ++ stat->bw = RATE_INFO_BW_40; + else +- stat.bw = RATE_INFO_BW_20; ++ stat->bw = RATE_INFO_BW_20; + +- stat.enc_flags = 0; ++ stat->enc_flags = 0; + if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) +- stat.enc_flags |= RX_ENC_FLAG_SHORTPRE; ++ stat->enc_flags |= RX_ENC_FLAG_SHORTPRE; + if (rate->flags & IEEE80211_TX_RC_SHORT_GI) +- stat.enc_flags |= RX_ENC_FLAG_SHORT_GI; ++ stat->enc_flags |= RX_ENC_FLAG_SHORT_GI; + +- stat.rate_idx = rate->idx; ++ stat->rate_idx = rate->idx; + if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { +- stat.encoding = RX_ENC_VHT; +- stat.rate_idx = ieee80211_rate_get_vht_mcs(rate); +- stat.nss = ieee80211_rate_get_vht_nss(rate); ++ stat->encoding = RX_ENC_VHT; ++ stat->rate_idx = ieee80211_rate_get_vht_mcs(rate); ++ stat->nss = ieee80211_rate_get_vht_nss(rate); + } else if (rate->flags & IEEE80211_TX_RC_MCS) { +- stat.encoding = RX_ENC_HT; ++ stat->encoding = RX_ENC_HT; + } else { +- stat.encoding = RX_ENC_LEGACY; ++ stat->encoding = RX_ENC_LEGACY; + } + +-out: ++ return 0; ++} ++ ++static u32 ieee80211_calc_tx_airtime_rate(struct ieee80211_hw *hw, ++ struct ieee80211_tx_rate *rate, ++ struct rate_info *ri, ++ u8 band, int len) ++{ ++ struct ieee80211_rx_status stat; ++ ++ if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len)) ++ return 0; ++ + return ieee80211_calc_rx_airtime(hw, &stat, len); + } + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/313-mac80211-improve-AQL-aggregation-estimation-for-low-.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/313-mac80211-improve-AQL-aggregation-estimation-for-low-.patch new file mode 100644 index 000000000..7f7c75db5 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/313-mac80211-improve-AQL-aggregation-estimation-for-low-.patch @@ -0,0 +1,67 @@ +From: Felix Fietkau +Date: Wed, 12 Aug 2020 17:07:10 +0200 +Subject: [PATCH] mac80211: improve AQL aggregation estimation for low data + rates + +Links with low data rates use much smaller aggregates and are much more +sensitive to latency added by bufferbloat. +Tune the assumed aggregation length based on the tx rate duration. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -647,27 +647,41 @@ u32 ieee80211_calc_expected_tx_airtime(s + if (pubsta) { + struct sta_info *sta = container_of(pubsta, struct sta_info, + sta); ++ struct ieee80211_rx_status stat; + struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate; + struct rate_info *ri = &sta->tx_stats.last_rate_info; +- u32 airtime; ++ u32 duration, overhead; ++ u8 agg_shift; + +- if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS | +- IEEE80211_TX_RC_MCS))) +- ampdu = false; ++ if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len)) ++ return 0; + ++ if (stat.encoding == RX_ENC_LEGACY || !ampdu) ++ return ieee80211_calc_rx_airtime(hw, &stat, len); ++ ++ duration = ieee80211_get_rate_duration(hw, &stat, &overhead); + /* + * Assume that HT/VHT transmission on any AC except VO will + * use aggregation. Since we don't have reliable reporting +- * of aggregation length, assume an average of 16. ++ * of aggregation length, assume an average size based on the ++ * tx rate. + * This will not be very accurate, but much better than simply +- * assuming un-aggregated tx. ++ * assuming un-aggregated tx in all cases. + */ +- airtime = ieee80211_calc_tx_airtime_rate(hw, rate, ri, band, +- ampdu ? len * 16 : len); +- if (ampdu) +- airtime /= 16; ++ if (duration > 400) /* <= VHT20 MCS2 1S */ ++ agg_shift = 1; ++ else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */ ++ agg_shift = 2; ++ else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */ ++ agg_shift = 3; ++ else ++ agg_shift = 4; + +- return airtime; ++ duration *= len; ++ duration /= AVG_PKT_SIZE; ++ duration /= 1024; ++ ++ return duration + (overhead >> agg_shift); + } + + if (!conf) diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/314-mac80211-add-missing-queue-hash-initialization-to-80.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/314-mac80211-add-missing-queue-hash-initialization-to-80.patch new file mode 100644 index 000000000..eb56a2cac --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/314-mac80211-add-missing-queue-hash-initialization-to-80.patch @@ -0,0 +1,25 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:55:56 +0200 +Subject: [PATCH] mac80211: add missing queue/hash initialization to + 802.3 xmit + +Fixes AQL for encap-offloaded tx + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4200,6 +4200,12 @@ static void ieee80211_8023_xmit(struct i + if (is_zero_ether_addr(ra)) + goto out_free; + ++ if (local->ops->wake_tx_queue) { ++ u16 queue = __ieee80211_select_queue(sdata, sta, skb); ++ skb_set_queue_mapping(skb, queue); ++ skb_get_hash(skb); ++ } ++ + multicast = is_multicast_ether_addr(ra); + + if (sta) diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/315-mac80211-check-and-refresh-aggregation-session-in-en.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/315-mac80211-check-and-refresh-aggregation-session-in-en.patch new file mode 100644 index 000000000..e411d5972 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/315-mac80211-check-and-refresh-aggregation-session-in-en.patch @@ -0,0 +1,45 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 21:11:25 +0200 +Subject: [PATCH] mac80211: check and refresh aggregation session in + encap offload tx + +Update the last_tx timestamp to avoid tearing down the aggregation session +early. Fall back to the slow path if the session setup is still running + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4189,6 +4189,8 @@ static void ieee80211_8023_xmit(struct i + bool authorized = false; + bool multicast; + unsigned char *ra = ehdr->h_dest; ++ struct tid_ampdu_tx *tid_tx; ++ u8 tid; + + if (IS_ERR(sta) || (sta && !sta->uploaded)) + sta = NULL; +@@ -4226,6 +4228,22 @@ static void ieee80211_8023_xmit(struct i + + memset(info, 0, sizeof(*info)); + ++ if (sta) { ++ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; ++ tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); ++ if (tid_tx) { ++ if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { ++ /* fall back to non-offload slow path */ ++ __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL); ++ return; ++ } ++ ++ info->flags |= IEEE80211_TX_CTL_AMPDU; ++ if (tid_tx->timeout) ++ tid_tx->last_tx = jiffies; ++ } ++ } ++ + if (unlikely(!multicast && skb->sk && + skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) + info->ack_frame_id = ieee80211_store_ack_skb(local, skb, diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/316-mac80211-skip-encap-offload-for-tx-multicast-control.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/316-mac80211-skip-encap-offload-for-tx-multicast-control.patch new file mode 100644 index 000000000..6dce21db1 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/316-mac80211-skip-encap-offload-for-tx-multicast-control.patch @@ -0,0 +1,136 @@ +From: Felix Fietkau +Date: Fri, 21 Aug 2020 05:54:10 +0200 +Subject: [PATCH] mac80211: skip encap offload for tx multicast/control + packets + +This simplifies the checks in the encap offload tx handler and allows using +it in cases where software crypto is used for multicast packets, e.g. when +using an AP_VLAN. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4184,88 +4184,47 @@ static void ieee80211_8023_xmit(struct i + struct sk_buff *skb) + { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- struct ethhdr *ehdr = (struct ethhdr *)skb->data; + struct ieee80211_local *local = sdata->local; +- bool authorized = false; +- bool multicast; +- unsigned char *ra = ehdr->h_dest; + struct tid_ampdu_tx *tid_tx; + u8 tid; + +- if (IS_ERR(sta) || (sta && !sta->uploaded)) +- sta = NULL; +- +- if (sdata->vif.type == NL80211_IFTYPE_STATION && +- (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER))) +- ra = sdata->u.mgd.bssid; +- +- if (is_zero_ether_addr(ra)) +- goto out_free; +- + if (local->ops->wake_tx_queue) { + u16 queue = __ieee80211_select_queue(sdata, sta, skb); + skb_set_queue_mapping(skb, queue); + skb_get_hash(skb); + } + +- multicast = is_multicast_ether_addr(ra); +- +- if (sta) +- authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); +- +- if (!multicast && !authorized && +- (ehdr->h_proto != sdata->control_port_protocol || +- !ether_addr_equal(sdata->vif.addr, ehdr->h_source))) +- goto out_free; +- +- if (multicast && sdata->vif.type == NL80211_IFTYPE_AP && +- !atomic_read(&sdata->u.ap.num_mcast_sta)) +- goto out_free; +- + if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && + test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) + goto out_free; + + memset(info, 0, sizeof(*info)); + +- if (sta) { +- tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; +- tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); +- if (tid_tx) { +- if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { +- /* fall back to non-offload slow path */ +- __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL); +- return; +- } +- +- info->flags |= IEEE80211_TX_CTL_AMPDU; +- if (tid_tx->timeout) +- tid_tx->last_tx = jiffies; ++ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; ++ tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); ++ if (tid_tx) { ++ if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { ++ /* fall back to non-offload slow path */ ++ __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL); ++ return; + } ++ ++ info->flags |= IEEE80211_TX_CTL_AMPDU; ++ if (tid_tx->timeout) ++ tid_tx->last_tx = jiffies; + } + +- if (unlikely(!multicast && skb->sk && ++ if (unlikely(skb->sk && + skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) + info->ack_frame_id = ieee80211_store_ack_skb(local, skb, + &info->flags, NULL); + +- if (unlikely(sdata->control_port_protocol == ehdr->h_proto)) { +- if (sdata->control_port_no_encrypt) +- info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; +- info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; +- } +- +- if (multicast) +- info->flags |= IEEE80211_TX_CTL_NO_ACK; +- + info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; + + ieee80211_tx_stats(dev, skb->len); + +- if (sta) { +- sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; +- sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; +- } ++ sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; ++ sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; + + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) + sdata = container_of(sdata->bss, +@@ -4286,6 +4245,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8 + struct net_device *dev) + { + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ struct ethhdr *ehdr = (struct ethhdr *)skb->data; + struct sta_info *sta; + + if (WARN_ON(!sdata->hw_80211_encap)) { +@@ -4302,6 +4262,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8 + + if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) + kfree_skb(skb); ++ else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || ++ !test_sta_flag(sta, WLAN_STA_AUTHORIZED) || ++ sdata->control_port_protocol == ehdr->h_proto)) ++ ieee80211_subif_start_xmit(skb, dev); + else + ieee80211_8023_xmit(sdata, dev, sta, skb); + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/317-mac80211-set-info-control.hw_key-for-encap-offload-p.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/317-mac80211-set-info-control.hw_key-for-encap-offload-p.patch new file mode 100644 index 000000000..cb5a98631 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/317-mac80211-set-info-control.hw_key-for-encap-offload-p.patch @@ -0,0 +1,31 @@ +From: Felix Fietkau +Date: Fri, 21 Aug 2020 06:03:45 +0200 +Subject: [PATCH] mac80211: set info->control.hw_key for encap offload + packets + +This is needed for drivers that don't do the key lookup themselves + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4185,6 +4185,7 @@ static void ieee80211_8023_xmit(struct i + { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_local *local = sdata->local; ++ struct ieee80211_key *key; + struct tid_ampdu_tx *tid_tx; + u8 tid; + +@@ -4233,6 +4234,10 @@ static void ieee80211_8023_xmit(struct i + info->control.flags |= IEEE80211_TX_CTRL_HW_80211_ENCAP; + info->control.vif = &sdata->vif; + ++ key = rcu_dereference(sta->ptk[sta->ptk_idx]); ++ if (key) ++ info->control.hw_key = &key->conf; ++ + ieee80211_tx_8023(sdata, skb, skb->len, sta, false); + + return; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/318-mac80211-rework-tx-encapsulation-offload-API.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/318-mac80211-rework-tx-encapsulation-offload-API.patch new file mode 100644 index 000000000..7593c41da --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/318-mac80211-rework-tx-encapsulation-offload-API.patch @@ -0,0 +1,613 @@ +From: Felix Fietkau +Date: Thu, 13 Aug 2020 15:37:11 +0200 +Subject: [PATCH] mac80211: rework tx encapsulation offload API + +The current API (which lets the driver turn on/off per vif directly) has a +number of limitations: +- it does not deal with AP_VLAN +- conditions for enabling (no tkip, no monitor) are only checked at + add_interface time +- no way to indicate 4-addr support + +In order to address this, store offload flags in struct ieee80211_vif +(easy to extend for decap offload later). mac80211 initially sets the enable +flag, but gives the driver a chance to modify it before its settings are +applied. In addition to the .add_interface op, a .update_vif_offload op is +introduced, which can be used for runtime changes. + +If a driver can't disable encap offload at runtime, or if it has some extra +limitations, it can simply override the flags within those ops. + +Support for encap offload with 4-address mode interfaces can be enabled +by setting a flag from .add_interface or .update_vif_offload. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -4150,6 +4150,35 @@ static int ath11k_set_he_mu_sounding_mod + return ret; + } + ++static void ath11k_mac_op_update_vif_offload(struct ieee80211_hw *hw, ++ struct ieee80211_vif *vif) ++{ ++ struct ath11k *ar = hw->priv; ++ struct ath11k_base *ab = ar->ab; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); ++ u32 param_id, param_value; ++ int ret; ++ ++ param_id = WMI_VDEV_PARAM_TX_ENCAP_TYPE; ++ if (ath11k_frame_mode != ATH11K_HW_TXRX_ETHERNET || ++ (vif->type != NL80211_IFTYPE_STATION && ++ vif->type != NL80211_IFTYPE_AP)) ++ vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ ++ if (vif->offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) ++ param_value = ATH11K_HW_TXRX_ETHERNET; ++ else ++ param_value = ATH11K_HW_TXRX_NATIVE_WIFI; ++ ++ ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, ++ param_id, param_value); ++ if (ret) { ++ ath11k_warn(ab, "failed to set vdev %d tx encap mode: %d\n", ++ arvif->vdev_id, ret); ++ vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ } ++} ++ + static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) + { +@@ -4159,7 +4188,6 @@ static int ath11k_mac_op_add_interface(s + struct vdev_create_params vdev_param = {0}; + struct peer_create_params peer_param; + u32 param_id, param_value; +- int hw_encap = 0; + u16 nss; + int i; + int ret; +@@ -4253,30 +4281,7 @@ static int ath11k_mac_op_add_interface(s + list_add(&arvif->list, &ar->arvifs); + spin_unlock_bh(&ar->data_lock); + +- param_id = WMI_VDEV_PARAM_TX_ENCAP_TYPE; +- if (ath11k_frame_mode == ATH11K_HW_TXRX_ETHERNET) +- switch (vif->type) { +- case NL80211_IFTYPE_STATION: +- case NL80211_IFTYPE_AP_VLAN: +- case NL80211_IFTYPE_AP: +- hw_encap = 1; +- break; +- default: +- break; +- } +- +- if (ieee80211_set_hw_80211_encap(vif, hw_encap)) +- param_value = ATH11K_HW_TXRX_ETHERNET; +- else +- param_value = ATH11K_HW_TXRX_NATIVE_WIFI; +- +- ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, +- param_id, param_value); +- if (ret) { +- ath11k_warn(ab, "failed to set vdev %d tx encap mode: %d\n", +- arvif->vdev_id, ret); +- goto err_vdev_del; +- } ++ ath11k_mac_op_update_vif_offload(hw, vif); + + nss = get_num_chains(ar->cfg_tx_chainmask) ? : 1; + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, +@@ -5599,6 +5604,7 @@ static const struct ieee80211_ops ath11k + .reconfig_complete = ath11k_mac_op_reconfig_complete, + .add_interface = ath11k_mac_op_add_interface, + .remove_interface = ath11k_mac_op_remove_interface, ++ .update_vif_offload = ath11k_mac_op_update_vif_offload, + .config = ath11k_mac_op_config, + .bss_info_changed = ath11k_mac_op_bss_info_changed, + .configure_filter = ath11k_mac_op_configure_filter, +@@ -5852,6 +5858,7 @@ static int __ath11k_mac_register(struct + ieee80211_hw_set(ar->hw, QUEUE_CONTROL); + ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG); + ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK); ++ ieee80211_hw_set(ar->hw, SUPPORTS_TX_ENCAP_OFFLOAD); + if (ht_cap & WMI_HT_CAP_ENABLED) { + ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION); + ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW); +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -1603,6 +1603,21 @@ enum ieee80211_vif_flags { + IEEE80211_VIF_GET_NOA_UPDATE = BIT(3), + }; + ++ ++/** ++ * enum ieee80211_offload_flags - virtual interface offload flags ++ * ++ * @IEEE80211_OFFLOAD_ENCAP_ENABLED: tx encapsulation offload is enabled ++ * The driver supports sending frames passed as 802.3 frames by mac80211. ++ * It must also support sending 802.11 packets for the same interface. ++ * @IEEE80211_OFFLOAD_ENCAP_4ADDR: support 4-address mode encapsulation offload ++ */ ++ ++enum ieee80211_offload_flags { ++ IEEE80211_OFFLOAD_ENCAP_ENABLED = BIT(0), ++ IEEE80211_OFFLOAD_ENCAP_4ADDR = BIT(1), ++}; ++ + /** + * struct ieee80211_vif - per-interface data + * +@@ -1623,6 +1638,11 @@ enum ieee80211_vif_flags { + * these need to be set (or cleared) when the interface is added + * or, if supported by the driver, the interface type is changed + * at runtime, mac80211 will never touch this field ++ * @offloaad_flags: hardware offload capabilities/flags for this interface. ++ * These are initialized by mac80211 before calling .add_interface, ++ * .change_interface or .update_vif_offload and updated by the driver ++ * within these ops, based on supported features or runtime change ++ * restrictions. + * @hw_queue: hardware queue for each AC + * @cab_queue: content-after-beacon (DTIM beacon really) queue, AP mode only + * @chanctx_conf: The channel context this interface is assigned to, or %NULL +@@ -1659,6 +1679,7 @@ struct ieee80211_vif { + struct ieee80211_chanctx_conf __rcu *chanctx_conf; + + u32 driver_flags; ++ u32 offload_flags; + + #ifdef CPTCFG_MAC80211_DEBUGFS + struct dentry *debugfs_dir; +@@ -2325,6 +2346,9 @@ struct ieee80211_txq { + * aggregating MPDUs with the same keyid, allowing mac80211 to keep Tx + * A-MPDU sessions active while rekeying with Extended Key ID. + * ++ * @IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD: Hardware supports tx encapsulation ++ * offload ++ * + * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays + */ + enum ieee80211_hw_flags { +@@ -2377,6 +2401,7 @@ enum ieee80211_hw_flags { + IEEE80211_HW_SUPPORTS_MULTI_BSSID, + IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID, + IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT, ++ IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD, + + /* keep last, obviously */ + NUM_IEEE80211_HW_FLAGS +@@ -3811,6 +3836,8 @@ enum ieee80211_reconfig_type { + * @set_tid_config: Apply TID specific configurations. This callback may sleep. + * @reset_tid_config: Reset TID specific configuration for the peer. + * This callback may sleep. ++ * @update_vif_config: Update virtual interface offload flags ++ * This callback may sleep. + */ + struct ieee80211_ops { + void (*tx)(struct ieee80211_hw *hw, +@@ -4122,6 +4149,8 @@ struct ieee80211_ops { + int (*reset_tid_config)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u8 tids); ++ void (*update_vif_offload)(struct ieee80211_hw *hw, ++ struct ieee80211_vif *vif); + }; + + /** +--- a/net/mac80211/debugfs.c ++++ b/net/mac80211/debugfs.c +@@ -408,6 +408,7 @@ static const char *hw_flag_names[] = { + FLAG(SUPPORTS_MULTI_BSSID), + FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID), + FLAG(AMPDU_KEYBORDER_SUPPORT), ++ FLAG(SUPPORTS_TX_ENCAP_OFFLOAD), + #undef FLAG + }; + +--- a/net/mac80211/driver-ops.h ++++ b/net/mac80211/driver-ops.h +@@ -1385,4 +1385,19 @@ static inline int drv_reset_tid_config(s + + return ret; + } ++ ++static inline void drv_update_vif_offload(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata) ++{ ++ might_sleep(); ++ check_sdata_in_driver(sdata); ++ ++ if (!local->ops->update_vif_offload) ++ return; ++ ++ trace_drv_update_vif_offload(local, sdata); ++ local->ops->update_vif_offload(&local->hw, &sdata->vif); ++ trace_drv_return_void(local); ++} ++ + #endif /* __MAC80211_DRIVER_OPS */ +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -990,8 +990,6 @@ struct ieee80211_sub_if_data { + } debugfs; + #endif + +- bool hw_80211_encap; +- + /* must be last, dynamically sized area in this! */ + struct ieee80211_vif vif; + }; +@@ -1769,6 +1767,7 @@ void ieee80211_del_virtual_monitor(struc + bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); + void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata, + bool update_bss); ++void ieee80211_recalc_offload(struct ieee80211_local *local); + + static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) + { +--- a/net/mac80211/iface.c ++++ b/net/mac80211/iface.c +@@ -43,6 +43,7 @@ + */ + + static void ieee80211_iface_work(struct work_struct *work); ++static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata); + + bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata) + { +@@ -348,6 +349,85 @@ static int ieee80211_check_queues(struct + return 0; + } + ++static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype) ++{ ++ switch (iftype) { ++ /* P2P GO and client are mapped to AP/STATION types */ ++ case NL80211_IFTYPE_AP: ++ case NL80211_IFTYPE_STATION: ++ return true; ++ default: ++ return false; ++ } ++} ++ ++static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdata) ++{ ++ struct ieee80211_local *local = sdata->local; ++ u32 flags; ++ ++ flags = sdata->vif.offload_flags; ++ ++ if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) && ++ ieee80211_iftype_supports_encap_offload(sdata->vif.type)) { ++ flags |= IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ ++ if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG) && ++ local->hw.wiphy->frag_threshold != (u32)-1) ++ flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ ++ if (local->monitors) ++ flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ } else { ++ flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ } ++ ++ if (sdata->vif.offload_flags == flags) ++ return false; ++ ++ sdata->vif.offload_flags = flags; ++ return true; ++} ++ ++ ++static void ieee80211_recalc_sdata_offload(struct ieee80211_sub_if_data *sdata) ++{ ++ struct ieee80211_local *local = sdata->local; ++ struct ieee80211_sub_if_data *vsdata; ++ ++ if (ieee80211_set_sdata_offload_flags(sdata)) { ++ drv_update_vif_offload(local, sdata); ++ ieee80211_set_vif_encap_ops(sdata); ++ } ++ ++ list_for_each_entry(vsdata, &local->interfaces, list) { ++ if (vsdata->vif.type != NL80211_IFTYPE_AP_VLAN || ++ vsdata->bss != &sdata->u.ap) ++ continue; ++ ++ ieee80211_set_vif_encap_ops(vsdata); ++ } ++} ++ ++void ieee80211_recalc_offload(struct ieee80211_local *local) ++{ ++ struct ieee80211_sub_if_data *sdata; ++ ++ if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD)) ++ return; ++ ++ mutex_lock(&local->iflist_mtx); ++ ++ list_for_each_entry(sdata, &local->interfaces, list) { ++ if (!ieee80211_sdata_running(sdata)) ++ continue; ++ ++ ieee80211_recalc_sdata_offload(sdata); ++ } ++ ++ mutex_unlock(&local->iflist_mtx); ++} ++ + void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata, + const int offset) + { +@@ -587,6 +667,7 @@ int ieee80211_do_open(struct wireless_de + if (rtnl_dereference(sdata->bss->beacon)) { + ieee80211_vif_vlan_copy_chanctx(sdata); + netif_carrier_on(dev); ++ ieee80211_set_vif_encap_ops(sdata); + } else { + netif_carrier_off(dev); + } +@@ -616,6 +697,7 @@ int ieee80211_do_open(struct wireless_de + + ieee80211_adjust_monitor_flags(sdata, 1); + ieee80211_configure_filter(local); ++ ieee80211_recalc_offload(local); + mutex_lock(&local->mtx); + ieee80211_recalc_idle(local); + mutex_unlock(&local->mtx); +@@ -625,10 +707,13 @@ int ieee80211_do_open(struct wireless_de + default: + if (coming_up) { + ieee80211_del_virtual_monitor(local); ++ ieee80211_set_sdata_offload_flags(sdata); + + res = drv_add_interface(local, sdata); + if (res) + goto err_stop; ++ ++ ieee80211_set_vif_encap_ops(sdata); + res = ieee80211_check_queues(sdata, + ieee80211_vif_type_p2p(&sdata->vif)); + if (res) +@@ -1286,61 +1371,6 @@ static const struct net_device_ops ieee8 + + }; + +-static void __ieee80211_set_hw_80211_encap(struct ieee80211_sub_if_data *sdata, +- bool enable) +-{ +- sdata->dev->netdev_ops = enable ? &ieee80211_dataif_8023_ops : +- &ieee80211_dataif_ops; +- sdata->hw_80211_encap = enable; +-} +- +-bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable) +-{ +- struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); +- struct ieee80211_local *local = sdata->local; +- struct ieee80211_sub_if_data *iter; +- struct ieee80211_key *key; +- +- mutex_lock(&local->iflist_mtx); +- list_for_each_entry(iter, &local->interfaces, list) { +- struct ieee80211_sub_if_data *disable = NULL; +- +- if (vif->type == NL80211_IFTYPE_MONITOR) { +- disable = iter; +- __ieee80211_set_hw_80211_encap(iter, false); +- } else if (iter->vif.type == NL80211_IFTYPE_MONITOR) { +- disable = sdata; +- enable = false; +- } +- if (disable) +- sdata_dbg(disable, +- "disable hw 80211 encap due to mon co-exist\n"); +- } +- mutex_unlock(&local->iflist_mtx); +- +- if (enable == sdata->hw_80211_encap) +- return enable; +- +- if (!sdata->dev) +- return false; +- +- if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG) && +- (local->hw.wiphy->frag_threshold != (u32)-1)) +- enable = false; +- +- mutex_lock(&sdata->local->key_mtx); +- list_for_each_entry(key, &sdata->key_list, list) { +- if (key->conf.cipher == WLAN_CIPHER_SUITE_TKIP) +- enable = false; +- } +- mutex_unlock(&sdata->local->key_mtx); +- +- __ieee80211_set_hw_80211_encap(sdata, enable); +- +- return enable; +-} +-EXPORT_SYMBOL(ieee80211_set_hw_80211_encap); +- + static void ieee80211_if_free(struct net_device *dev) + { + free_percpu(netdev_tstats(dev)); +@@ -1371,6 +1401,32 @@ static void ieee80211_if_setup_no_queue( + #endif + } + ++static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata) ++{ ++ struct ieee80211_local *local = sdata->local; ++ struct ieee80211_sub_if_data *bss = sdata; ++ bool enabled; ++ ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { ++ if (!sdata->bss) ++ return; ++ ++ bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); ++ } ++ ++ if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) || ++ !ieee80211_iftype_supports_encap_offload(bss->vif.type)) ++ return; ++ ++ enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ if (sdata->wdev.use_4addr && ++ !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR)) ++ enabled = false; ++ ++ sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops : ++ &ieee80211_dataif_ops; ++} ++ + static void ieee80211_iface_work(struct work_struct *work) + { + struct ieee80211_sub_if_data *sdata = +@@ -1553,7 +1609,6 @@ static void ieee80211_setup_sdata(struct + sdata->vif.bss_conf.txpower = INT_MIN; /* unset */ + + sdata->noack_map = 0; +- sdata->hw_80211_encap = false; + + /* only monitor/p2p-device differ */ + if (sdata->dev) { +@@ -1688,6 +1743,7 @@ static int ieee80211_runtime_change_ifty + + ieee80211_teardown_sdata(sdata); + ++ ieee80211_set_sdata_offload_flags(sdata); + ret = drv_change_interface(local, sdata, internal_type, p2p); + if (ret) + type = ieee80211_vif_type_p2p(&sdata->vif); +@@ -1700,6 +1756,7 @@ static int ieee80211_runtime_change_ifty + ieee80211_check_queues(sdata, type); + + ieee80211_setup_sdata(sdata, type); ++ ieee80211_set_vif_encap_ops(sdata); + + err = ieee80211_do_open(&sdata->wdev, false); + WARN(err, "type change: do_open returned %d", err); +--- a/net/mac80211/key.c ++++ b/net/mac80211/key.c +@@ -177,13 +177,6 @@ static int ieee80211_key_enable_hw_accel + } + } + +- /* TKIP countermeasures don't work in encap offload mode */ +- if (key->conf.cipher == WLAN_CIPHER_SUITE_TKIP && +- sdata->hw_80211_encap) { +- sdata_dbg(sdata, "TKIP is not allowed in hw 80211 encap mode\n"); +- return -EINVAL; +- } +- + ret = drv_set_key(key->local, SET_KEY, sdata, + sta ? &sta->sta : NULL, &key->conf); + +@@ -219,14 +212,6 @@ static int ieee80211_key_enable_hw_accel + case WLAN_CIPHER_SUITE_CCMP_256: + case WLAN_CIPHER_SUITE_GCMP: + case WLAN_CIPHER_SUITE_GCMP_256: +- /* We cannot do software crypto of data frames with +- * encapsulation offload enabled. However for 802.11w to +- * function properly we need cmac/gmac keys. +- */ +- if (sdata->hw_80211_encap) +- return -EINVAL; +- /* Fall through */ +- + case WLAN_CIPHER_SUITE_AES_CMAC: + case WLAN_CIPHER_SUITE_BIP_CMAC_256: + case WLAN_CIPHER_SUITE_BIP_GMAC_128: +--- a/net/mac80211/trace.h ++++ b/net/mac80211/trace.h +@@ -2733,6 +2733,12 @@ TRACE_EVENT(drv_get_ftm_responder_stats, + ) + ); + ++DEFINE_EVENT(local_sdata_addr_evt, drv_update_vif_offload, ++ TP_PROTO(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata), ++ TP_ARGS(local, sdata) ++); ++ + #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ + + #undef TRACE_INCLUDE_PATH +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4181,11 +4181,10 @@ static bool ieee80211_tx_8023(struct iee + + static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, + struct net_device *dev, struct sta_info *sta, +- struct sk_buff *skb) ++ struct ieee80211_key *key, struct sk_buff *skb) + { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_local *local = sdata->local; +- struct ieee80211_key *key; + struct tid_ampdu_tx *tid_tx; + u8 tid; + +@@ -4234,7 +4233,6 @@ static void ieee80211_8023_xmit(struct i + info->control.flags |= IEEE80211_TX_CTRL_HW_80211_ENCAP; + info->control.vif = &sdata->vif; + +- key = rcu_dereference(sta->ptk[sta->ptk_idx]); + if (key) + info->control.hw_key = &key->conf; + +@@ -4251,12 +4249,9 @@ netdev_tx_t ieee80211_subif_start_xmit_8 + { + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ethhdr *ehdr = (struct ethhdr *)skb->data; ++ struct ieee80211_key *key; + struct sta_info *sta; +- +- if (WARN_ON(!sdata->hw_80211_encap)) { +- kfree_skb(skb); +- return NETDEV_TX_OK; +- } ++ bool offload = true; + + if (unlikely(skb->len < ETH_HLEN)) { + kfree_skb(skb); +@@ -4265,15 +4260,26 @@ netdev_tx_t ieee80211_subif_start_xmit_8 + + rcu_read_lock(); + +- if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) ++ if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) { + kfree_skb(skb); +- else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || +- !test_sta_flag(sta, WLAN_STA_AUTHORIZED) || +- sdata->control_port_protocol == ehdr->h_proto)) +- ieee80211_subif_start_xmit(skb, dev); ++ goto out; ++ } ++ ++ if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || ++ !test_sta_flag(sta, WLAN_STA_AUTHORIZED) || ++ sdata->control_port_protocol == ehdr->h_proto)) ++ offload = false; ++ else if ((key = rcu_dereference(sta->ptk[sta->ptk_idx])) && ++ (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || ++ key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) ++ offload = false; ++ ++ if (offload) ++ ieee80211_8023_xmit(sdata, dev, sta, key, skb); + else +- ieee80211_8023_xmit(sdata, dev, sta, skb); ++ ieee80211_subif_start_xmit(skb, dev); + ++out: + rcu_read_unlock(); + + return NETDEV_TX_OK; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/319-mac80211-reduce-duplication-in-tx-status-functions.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/319-mac80211-reduce-duplication-in-tx-status-functions.patch new file mode 100644 index 000000000..8b664d689 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/319-mac80211-reduce-duplication-in-tx-status-functions.patch @@ -0,0 +1,197 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:16:59 +0200 +Subject: [PATCH] mac80211: reduce duplication in tx status functions + +Move redundant functionality from __ieee80211_tx_status into +ieee80211_tx_status_ext. Preparation for unifying with the 802.3 tx status +codepath. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -184,18 +184,6 @@ static void ieee80211_frame_acked(struct + struct ieee80211_mgmt *mgmt = (void *) skb->data; + struct ieee80211_local *local = sta->local; + struct ieee80211_sub_if_data *sdata = sta->sdata; +- struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb); +- +- if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { +- sta->status_stats.last_ack = jiffies; +- if (txinfo->status.is_valid_ack_signal) { +- sta->status_stats.last_ack_signal = +- (s8)txinfo->status.ack_signal; +- sta->status_stats.ack_signal_filled = true; +- ewma_avg_signal_add(&sta->status_stats.avg_ack_signal, +- -txinfo->status.ack_signal); +- } +- } + + if (ieee80211_is_data_qos(mgmt->frame_control)) { + struct ieee80211_hdr *hdr = (void *) skb->data; +@@ -899,7 +887,8 @@ void ieee80211_tx_monitor(struct ieee802 + } + + static void __ieee80211_tx_status(struct ieee80211_hw *hw, +- struct ieee80211_tx_status *status) ++ struct ieee80211_tx_status *status, ++ int rates_idx, int retry_count) + { + struct sk_buff *skb = status->skb; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; +@@ -908,8 +897,6 @@ static void __ieee80211_tx_status(struct + struct sta_info *sta; + __le16 fc; + struct ieee80211_supported_band *sband; +- int retry_count; +- int rates_idx; + bool send_to_cooked; + bool acked; + bool noack_success; +@@ -918,8 +905,6 @@ static void __ieee80211_tx_status(struct + int tid = IEEE80211_NUM_TIDS; + u16 tx_time_est; + +- rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count); +- + sband = local->hw.wiphy->bands[info->band]; + fc = hdr->frame_control; + +@@ -996,24 +981,14 @@ static void __ieee80211_tx_status(struct + if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) { + ieee80211_handle_filtered_frame(local, sta, skb); + return; +- } else { ++ } else if (ieee80211_is_data_present(fc)) { + if (!acked && !noack_success) +- sta->status_stats.retry_failed++; +- sta->status_stats.retry_count += retry_count; +- +- if (ieee80211_is_data_present(fc)) { +- if (!acked && !noack_success) +- sta->status_stats.msdu_failed[tid]++; ++ sta->status_stats.msdu_failed[tid]++; + +- sta->status_stats.msdu_retries[tid] += +- retry_count; +- } ++ sta->status_stats.msdu_retries[tid] += ++ retry_count; + } + +- rate_control_tx_status(local, sband, status); +- if (ieee80211_vif_is_mesh(&sta->sdata->vif)) +- ieee80211s_update_metric(local, sta, status); +- + if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked) + ieee80211_frame_acked(sta, skb); + +@@ -1038,20 +1013,6 @@ static void __ieee80211_tx_status(struct + true); + ieee80211_info_set_tx_time_est(info, 0); + } +- +- if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { +- if (acked) { +- if (sta->status_stats.lost_packets) +- sta->status_stats.lost_packets = 0; +- +- /* Track when last TDLS packet was ACKed */ +- sta->status_stats.last_pkt_time = jiffies; +- } else if (noack_success) { +- /* nothing to do here, do not account as lost */ +- } else { +- ieee80211_lost_packet(sta, info); +- } +- } + } + + /* SNMP counters +@@ -1135,7 +1096,7 @@ void ieee80211_tx_status(struct ieee8021 + if (sta) + status.sta = &sta->sta; + +- __ieee80211_tx_status(hw, &status); ++ ieee80211_tx_status_ext(hw, &status); + rcu_read_unlock(); + } + EXPORT_SYMBOL(ieee80211_tx_status); +@@ -1148,7 +1109,7 @@ void ieee80211_tx_status_ext(struct ieee + struct ieee80211_sta *pubsta = status->sta; + struct ieee80211_supported_band *sband; + struct sta_info *sta; +- int retry_count; ++ int rates_idx, retry_count; + bool acked, noack_success; + + if (pubsta) { +@@ -1158,13 +1119,7 @@ void ieee80211_tx_status_ext(struct ieee + sta->tx_stats.last_rate_info = *status->rate; + } + +- if (status->skb) +- return __ieee80211_tx_status(hw, status); +- +- if (!status->sta) +- return; +- +- ieee80211_tx_get_rates(hw, info, &retry_count); ++ rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count); + + sband = hw->wiphy->bands[info->band]; + +@@ -1176,20 +1131,30 @@ void ieee80211_tx_status_ext(struct ieee + sta->status_stats.retry_failed++; + sta->status_stats.retry_count += retry_count; + +- if (acked) { +- sta->status_stats.last_ack = jiffies; ++ if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { ++ if (acked) { ++ sta->status_stats.last_ack = jiffies; + +- if (sta->status_stats.lost_packets) +- sta->status_stats.lost_packets = 0; ++ if (sta->status_stats.lost_packets) ++ sta->status_stats.lost_packets = 0; + +- /* Track when last packet was ACKed */ +- sta->status_stats.last_pkt_time = jiffies; +- } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) { +- return; +- } else if (noack_success) { +- /* nothing to do here, do not account as lost */ +- } else { +- ieee80211_lost_packet(sta, info); ++ /* Track when last packet was ACKed */ ++ sta->status_stats.last_pkt_time = jiffies; ++ ++ if (info->status.is_valid_ack_signal) { ++ sta->status_stats.last_ack_signal = ++ (s8)info->status.ack_signal; ++ sta->status_stats.ack_signal_filled = true; ++ ewma_avg_signal_add(&sta->status_stats.avg_ack_signal, ++ -info->status.ack_signal); ++ } ++ } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) { ++ return; ++ } else if (noack_success) { ++ /* nothing to do here, do not account as lost */ ++ } else { ++ ieee80211_lost_packet(sta, info); ++ } + } + + rate_control_tx_status(local, sband, status); +@@ -1197,6 +1162,10 @@ void ieee80211_tx_status_ext(struct ieee + ieee80211s_update_metric(local, sta, status); + } + ++ if (status->skb) ++ return __ieee80211_tx_status(hw, status, rates_idx, ++ retry_count); ++ + if (acked || noack_success) { + I802_DEBUG_INC(local->dot11TransmittedFrameCount); + if (!pubsta) diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/320-mac80211-remove-tx-status-call-to-ieee80211_sta_regi.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/320-mac80211-remove-tx-status-call-to-ieee80211_sta_regi.patch new file mode 100644 index 000000000..168d6458a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/320-mac80211-remove-tx-status-call-to-ieee80211_sta_regi.patch @@ -0,0 +1,26 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:29:12 +0200 +Subject: [PATCH] mac80211: remove tx status call to + ieee80211_sta_register_airtime + +All drivers using airtime fairness are calling ieee80211_sta_register_airtime +directly + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -997,12 +997,6 @@ static void __ieee80211_tx_status(struct + ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data, + acked, info->status.tx_time); + +- if (info->status.tx_time && +- wiphy_ext_feature_isset(local->hw.wiphy, +- NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) +- ieee80211_sta_register_airtime(&sta->sta, tid, +- info->status.tx_time, 0); +- + if ((tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) { + /* Do this here to avoid the expensive lookup of the sta + * in ieee80211_report_used_skb(). diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/321-mac80211-optimize-station-connection-monitor.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/321-mac80211-optimize-station-connection-monitor.patch new file mode 100644 index 000000000..ed9efb2b0 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/321-mac80211-optimize-station-connection-monitor.patch @@ -0,0 +1,174 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:29:56 +0200 +Subject: [PATCH] mac80211: optimize station connection monitor + +Calling mod_timer for every rx/tx packet can be quite expensive. +Instead of constantly updating the timer, we can simply let it run out +and check the timestamp of the last ACK or rx packet to re-arm it. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -2045,8 +2045,6 @@ void ieee80211_dynamic_ps_timer(struct t + void ieee80211_send_nullfunc(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + bool powersave); +-void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, +- struct ieee80211_hdr *hdr); + void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, + struct ieee80211_hdr *hdr, bool ack, u16 tx_time); + +--- a/net/mac80211/mlme.c ++++ b/net/mac80211/mlme.c +@@ -2432,23 +2432,6 @@ static void ieee80211_set_disassoc(struc + sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; + } + +-void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, +- struct ieee80211_hdr *hdr) +-{ +- /* +- * We can postpone the mgd.timer whenever receiving unicast frames +- * from AP because we know that the connection is working both ways +- * at that time. But multicast frames (and hence also beacons) must +- * be ignored here, because we need to trigger the timer during +- * data idle periods for sending the periodic probe request to the +- * AP we're connected to. +- */ +- if (is_multicast_ether_addr(hdr->addr1)) +- return; +- +- ieee80211_sta_reset_conn_monitor(sdata); +-} +- + static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata) + { + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; +@@ -2521,21 +2504,13 @@ void ieee80211_sta_tx_notify(struct ieee + { + ieee80211_sta_tx_wmm_ac_notify(sdata, hdr, tx_time); + +- if (!ieee80211_is_data(hdr->frame_control)) +- return; +- +- if (ieee80211_is_any_nullfunc(hdr->frame_control) && +- sdata->u.mgd.probe_send_count > 0) { +- if (ack) +- ieee80211_sta_reset_conn_monitor(sdata); +- else +- sdata->u.mgd.nullfunc_failed = true; +- ieee80211_queue_work(&sdata->local->hw, &sdata->work); ++ if (!ieee80211_is_any_nullfunc(hdr->frame_control) || ++ !sdata->u.mgd.probe_send_count) + return; +- } + +- if (ack) +- ieee80211_sta_reset_conn_monitor(sdata); ++ if (!ack) ++ sdata->u.mgd.nullfunc_failed = true; ++ ieee80211_queue_work(&sdata->local->hw, &sdata->work); + } + + static void ieee80211_mlme_send_probe_req(struct ieee80211_sub_if_data *sdata, +@@ -3600,8 +3575,8 @@ static bool ieee80211_assoc_success(stru + * Start timer to probe the connection to the AP now. + * Also start the timer that will detect beacon loss. + */ +- ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); + ieee80211_sta_reset_beacon_monitor(sdata); ++ ieee80211_sta_reset_conn_monitor(sdata); + + ret = true; + out: +@@ -4569,10 +4544,26 @@ static void ieee80211_sta_conn_mon_timer + from_timer(sdata, t, u.mgd.conn_mon_timer); + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_local *local = sdata->local; ++ struct sta_info *sta; ++ unsigned long timeout; + + if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) + return; + ++ sta = sta_info_get(sdata, ifmgd->bssid); ++ if (!sta) ++ return; ++ ++ timeout = sta->status_stats.last_ack; ++ if (time_before(sta->status_stats.last_ack, sta->rx_stats.last_rx)) ++ timeout = sta->rx_stats.last_rx; ++ timeout += IEEE80211_CONNECTION_IDLE_TIME; ++ ++ if (time_is_before_jiffies(timeout)) { ++ mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout)); ++ return; ++ } ++ + ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); + } + +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -1811,9 +1811,6 @@ ieee80211_rx_h_sta_process(struct ieee80 + sta->rx_stats.last_rate = sta_stats_encode_rate(status); + } + +- if (rx->sdata->vif.type == NL80211_IFTYPE_STATION) +- ieee80211_sta_rx_notify(rx->sdata, hdr); +- + sta->rx_stats.fragments++; + + u64_stats_update_begin(&rx->sta->rx_stats.syncp); +@@ -4148,7 +4145,6 @@ void ieee80211_check_fast_rx(struct sta_ + fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr2); + fastrx.expected_ds_bits = 0; + } else { +- fastrx.sta_notify = sdata->u.mgd.probe_send_count > 0; + fastrx.da_offs = offsetof(struct ieee80211_hdr, addr1); + fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr3); + fastrx.expected_ds_bits = +@@ -4378,11 +4374,6 @@ static bool ieee80211_invoke_fast_rx(str + pskb_trim(skb, skb->len - fast_rx->icv_len)) + goto drop; + +- if (unlikely(fast_rx->sta_notify)) { +- ieee80211_sta_rx_notify(rx->sdata, hdr); +- fast_rx->sta_notify = false; +- } +- + /* statistics part of ieee80211_rx_h_sta_process() */ + if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { + stats->last_signal = status->signal; +--- a/net/mac80211/sta_info.h ++++ b/net/mac80211/sta_info.h +@@ -336,7 +336,6 @@ struct ieee80211_fast_tx { + * @expected_ds_bits: from/to DS bits expected + * @icv_len: length of the MIC if present + * @key: bool indicating encryption is expected (key is set) +- * @sta_notify: notify the MLME code (once) + * @internal_forward: forward froms internally on AP/VLAN type interfaces + * @uses_rss: copy of USES_RSS hw flag + * @da_offs: offset of the DA in the header (for header conversion) +@@ -352,7 +351,6 @@ struct ieee80211_fast_rx { + __le16 expected_ds_bits; + u8 icv_len; + u8 key:1, +- sta_notify:1, + internal_forward:1, + uses_rss:1; + u8 da_offs, sa_offs; +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -1227,9 +1227,6 @@ void ieee80211_tx_status_8023(struct iee + sta->status_stats.retry_count += retry_count; + + if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) { +- if (acked && vif->type == NL80211_IFTYPE_STATION) +- ieee80211_sta_reset_conn_monitor(sdata); +- + sta->status_stats.last_ack = jiffies; + if (info->flags & IEEE80211_TX_STAT_ACK) { + if (sta->status_stats.lost_packets) diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/322-mac80211-swap-NEED_TXPROCESSING-and-HW_80211_ENCAP-t.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/322-mac80211-swap-NEED_TXPROCESSING-and-HW_80211_ENCAP-t.patch new file mode 100644 index 000000000..b9069ef9b --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/322-mac80211-swap-NEED_TXPROCESSING-and-HW_80211_ENCAP-t.patch @@ -0,0 +1,227 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:35:32 +0200 +Subject: [PATCH] mac80211: swap NEED_TXPROCESSING and HW_80211_ENCAP tx + flags + +In order to unify the tx status path, the hw 802.11 encapsulation flag +needs to survive the trip to the tx status call. +Since we don't have any free bits in info->flags, we need to move one. +IEEE80211_TX_INTFL_NEED_TXPROCESSING is only used internally in mac80211, +and only before the call into the driver. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -14,7 +14,7 @@ ath11k_dp_tx_get_encap_type(struct ath11 + { + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + +- if (tx_info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) ++ if (tx_info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) + return HAL_TCL_ENCAP_TYPE_ETHERNET; + + return HAL_TCL_ENCAP_TYPE_NATIVE_WIFI; +@@ -93,7 +93,7 @@ int ath11k_dp_tx(struct ath11k *ar, stru + if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) + return -ESHUTDOWN; + +- if (!(info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) && ++ if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && + !ieee80211_is_data(hdr->frame_control)) + return -ENOTSUPP; + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -3749,7 +3749,7 @@ static int ath11k_mac_mgmt_tx_wmi(struct + return -ENOSPC; + + info = IEEE80211_SKB_CB(skb); +- if (!(info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP)) { ++ if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) { + if ((ieee80211_is_action(hdr->frame_control) || + ieee80211_is_deauth(hdr->frame_control) || + ieee80211_is_disassoc(hdr->frame_control)) && +@@ -3876,7 +3876,7 @@ static void ath11k_mac_op_tx(struct ieee + bool is_prb_rsp; + int ret; + +- if (info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) { ++ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { + skb_cb->flags |= ATH11K_SKB_HW_80211_ENCAP; + } else if (ieee80211_is_mgmt(hdr->frame_control)) { + is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -720,9 +720,8 @@ struct ieee80211_bss_conf { + * @IEEE80211_TX_INTFL_OFFCHAN_TX_OK: Internal to mac80211. Used to indicate + * that a frame can be transmitted while the queues are stopped for + * off-channel operation. +- * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211, +- * used to indicate that a pending frame requires TX processing before +- * it can be sent out. ++ * @IEEE80211_TX_CTL_HW_80211_ENCAP: This frame uses hardware encapsulation ++ * (header conversion) + * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211, + * used to indicate that a frame was already retried due to PS + * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211, +@@ -791,7 +790,7 @@ enum mac80211_tx_info_flags { + IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11), + IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12), + IEEE80211_TX_INTFL_OFFCHAN_TX_OK = BIT(13), +- IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14), ++ IEEE80211_TX_CTL_HW_80211_ENCAP = BIT(14), + IEEE80211_TX_INTFL_RETRIED = BIT(15), + IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16), + IEEE80211_TX_CTL_NO_PS_BUFFER = BIT(17), +@@ -823,8 +822,9 @@ enum mac80211_tx_info_flags { + * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame + * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path + * @IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP: This frame skips mesh path lookup +- * @IEEE80211_TX_CTRL_HW_80211_ENCAP: This frame uses hardware encapsulation +- * (header conversion) ++ * @IEEE80211_TX_INTCFL_NEED_TXPROCESSING: completely internal to mac80211, ++ * used to indicate that a pending frame requires TX processing before ++ * it can be sent out. + * + * These flags are used in tx_info->control.flags. + */ +@@ -835,7 +835,7 @@ enum mac80211_tx_control_flags { + IEEE80211_TX_CTRL_AMSDU = BIT(3), + IEEE80211_TX_CTRL_FAST_XMIT = BIT(4), + IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP = BIT(5), +- IEEE80211_TX_CTRL_HW_80211_ENCAP = BIT(6), ++ IEEE80211_TX_INTCFL_NEED_TXPROCESSING = BIT(6), + }; + + /* +--- a/net/mac80211/mesh_hwmp.c ++++ b/net/mac80211/mesh_hwmp.c +@@ -212,7 +212,7 @@ static void prepare_frame_for_deferred_t + skb->priority = 7; + + info->control.vif = &sdata->vif; +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + ieee80211_set_qos_hdr(sdata, skb); + ieee80211_mps_set_frame_flags(sdata, NULL, hdr); + } +@@ -1163,7 +1163,7 @@ int mesh_nexthop_resolve(struct ieee8021 + if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) + skb_to_free = skb_dequeue(&mpath->frame_queue); + +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + ieee80211_set_qos_hdr(sdata, skb); + skb_queue_tail(&mpath->frame_queue, skb); + if (skb_to_free) +--- a/net/mac80211/mesh_ps.c ++++ b/net/mac80211/mesh_ps.c +@@ -432,7 +432,7 @@ static void mpsp_qos_null_append(struct + + info = IEEE80211_SKB_CB(new_skb); + info->control.vif = &sdata->vif; +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + + __skb_queue_tail(frames, new_skb); + } +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -2896,7 +2896,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80 + fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY); + info = IEEE80211_SKB_CB(fwd_skb); + memset(info, 0, sizeof(*info)); +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + info->control.vif = &rx->sdata->vif; + info->control.jiffies = jiffies; + if (is_multicast_ether_addr(fwd_hdr->addr1)) { +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -66,8 +66,8 @@ static void ieee80211_handle_filtered_fr + + info->control.jiffies = jiffies; + info->control.vif = &sta->sdata->vif; +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING | +- IEEE80211_TX_INTFL_RETRANSMISSION; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; ++ info->flags |= IEEE80211_TX_INTFL_RETRANSMISSION; + info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; + + sta->status_stats.filtered++; +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -530,7 +530,7 @@ ieee80211_tx_h_unicast_ps_buf(struct iee + + info->control.jiffies = jiffies; + info->control.vif = &tx->sdata->vif; +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; + skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); + spin_unlock(&sta->ps_lock); +@@ -1132,7 +1132,7 @@ static bool ieee80211_tx_prep_agg(struct + tx->sta->sta.addr, tx->sta->sta.aid); + } + info->control.vif = &tx->sdata->vif; +- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; + __skb_queue_tail(&tid_tx->pending, skb); + if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) +@@ -1177,7 +1177,7 @@ ieee80211_tx_prepare(struct ieee80211_su + * we are doing the needed processing, so remove the flag + * now. + */ +- info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING; ++ info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; + + hdr = (struct ieee80211_hdr *) skb->data; + +@@ -1256,7 +1256,7 @@ static struct txq_info *ieee80211_get_tx + (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) + return NULL; + +- if (!(info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) && ++ if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && + unlikely(!ieee80211_is_data_present(hdr->frame_control))) { + if ((!ieee80211_is_mgmt(hdr->frame_control) || + ieee80211_is_bufferable_mmpdu(hdr->frame_control) || +@@ -3640,7 +3640,7 @@ begin: + else + info->flags &= ~IEEE80211_TX_CTL_AMPDU; + +- if (info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) ++ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) + goto encap_out; + + if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { +@@ -4230,7 +4230,7 @@ static void ieee80211_8023_xmit(struct i + sdata = container_of(sdata->bss, + struct ieee80211_sub_if_data, u.ap); + +- info->control.flags |= IEEE80211_TX_CTRL_HW_80211_ENCAP; ++ info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; + info->control.vif = &sdata->vif; + + if (key) +@@ -4355,7 +4355,7 @@ static bool ieee80211_tx_pending_skb(str + + sdata = vif_to_sdata(info->control.vif); + +- if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { ++ if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); + if (unlikely(!chanctx_conf)) { + dev_kfree_skb(skb); +@@ -4363,7 +4363,7 @@ static bool ieee80211_tx_pending_skb(str + } + info->band = chanctx_conf->def.chan->band; + result = ieee80211_tx(sdata, NULL, skb, true, 0); +- } else if (info->control.flags & IEEE80211_TX_CTRL_HW_80211_ENCAP) { ++ } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { + if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) { + dev_kfree_skb(skb); + return true; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/323-mac80211-unify-802.3-offload-and-802.11-tx-status-co.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/323-mac80211-unify-802.3-offload-and-802.11-tx-status-co.patch new file mode 100644 index 000000000..7bb54f499 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/323-mac80211-unify-802.3-offload-and-802.11-tx-status-co.patch @@ -0,0 +1,159 @@ +From: Felix Fietkau +Date: Mon, 17 Aug 2020 13:54:19 +0200 +Subject: [PATCH] mac80211: unify 802.3 (offload) and 802.11 tx status + codepath + +Make ieee80211_tx_status_8023 call ieee80211_tx_status_ext, similar to +ieee80211_tx_status. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -903,7 +903,6 @@ static void __ieee80211_tx_status(struct + struct ieee80211_bar *bar; + int shift = 0; + int tid = IEEE80211_NUM_TIDS; +- u16 tx_time_est; + + sband = local->hw.wiphy->bands[info->band]; + fc = hdr->frame_control; +@@ -996,17 +995,6 @@ static void __ieee80211_tx_status(struct + ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) + ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data, + acked, info->status.tx_time); +- +- if ((tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) { +- /* Do this here to avoid the expensive lookup of the sta +- * in ieee80211_report_used_skb(). +- */ +- ieee80211_sta_update_pending_airtime(local, sta, +- skb_get_queue_mapping(skb), +- tx_time_est, +- true); +- ieee80211_info_set_tx_time_est(info, 0); +- } + } + + /* SNMP counters +@@ -1102,9 +1090,11 @@ void ieee80211_tx_status_ext(struct ieee + struct ieee80211_tx_info *info = status->info; + struct ieee80211_sta *pubsta = status->sta; + struct ieee80211_supported_band *sband; +- struct sta_info *sta; ++ struct sk_buff *skb = status->skb; ++ struct sta_info *sta = NULL; + int rates_idx, retry_count; + bool acked, noack_success; ++ u16 tx_time_est; + + if (pubsta) { + sta = container_of(pubsta, struct sta_info, sta); +@@ -1156,7 +1146,18 @@ void ieee80211_tx_status_ext(struct ieee + ieee80211s_update_metric(local, sta, status); + } + +- if (status->skb) ++ if (skb && (tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) { ++ /* Do this here to avoid the expensive lookup of the sta ++ * in ieee80211_report_used_skb(). ++ */ ++ ieee80211_sta_update_pending_airtime(local, sta, ++ skb_get_queue_mapping(skb), ++ tx_time_est, ++ true); ++ ieee80211_info_set_tx_time_est(info, 0); ++ } ++ ++ if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) + return __ieee80211_tx_status(hw, status, rates_idx, + retry_count); + +@@ -1171,6 +1172,12 @@ void ieee80211_tx_status_ext(struct ieee + } else { + I802_DEBUG_INC(local->dot11FailedCount); + } ++ ++ if (!skb) ++ return; ++ ++ ieee80211_report_used_skb(local, skb, false); ++ dev_kfree_skb(skb); + } + EXPORT_SYMBOL(ieee80211_tx_status_ext); + +@@ -1197,66 +1204,23 @@ void ieee80211_tx_status_8023(struct iee + struct ieee80211_vif *vif, + struct sk_buff *skb) + { +- struct ieee80211_local *local = hw_to_local(hw); + struct ieee80211_sub_if_data *sdata; +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); ++ struct ieee80211_tx_status status = { ++ .skb = skb, ++ .info = IEEE80211_SKB_CB(skb), ++ }; + struct sta_info *sta; +- int retry_count; +- int rates_idx; +- bool acked; + + sdata = vif_to_sdata(vif); + +- acked = info->flags & IEEE80211_TX_STAT_ACK; +- rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count); +- + rcu_read_lock(); + +- if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) +- goto counters_update; +- +- if (IS_ERR(sta)) +- goto counters_update; +- +- if (!acked) +- sta->status_stats.retry_failed++; +- +- if (rates_idx != -1) +- sta->tx_stats.last_rate = info->status.rates[rates_idx]; +- +- sta->status_stats.retry_count += retry_count; +- +- if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) { +- sta->status_stats.last_ack = jiffies; +- if (info->flags & IEEE80211_TX_STAT_ACK) { +- if (sta->status_stats.lost_packets) +- sta->status_stats.lost_packets = 0; ++ if (!ieee80211_lookup_ra_sta(sdata, skb, &sta) && !IS_ERR(sta)) ++ status.sta = &sta->sta; + +- sta->status_stats.last_pkt_time = jiffies; +- } else { +- ieee80211_lost_packet(sta, info); +- } +- } ++ ieee80211_tx_status_ext(hw, &status); + +-counters_update: + rcu_read_unlock(); +- ieee80211_led_tx(local); +- +- if (!(info->flags & IEEE80211_TX_STAT_ACK) && +- !(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED)) +- goto skip_stats_update; +- +- I802_DEBUG_INC(local->dot11TransmittedFrameCount); +- if (is_multicast_ether_addr(skb->data)) +- I802_DEBUG_INC(local->dot11MulticastTransmittedFrameCount); +- if (retry_count > 0) +- I802_DEBUG_INC(local->dot11RetryCount); +- if (retry_count > 1) +- I802_DEBUG_INC(local->dot11MultipleRetryCount); +- +-skip_stats_update: +- ieee80211_report_used_skb(local, skb, false); +- dev_kfree_skb(skb); + } + EXPORT_SYMBOL(ieee80211_tx_status_8023); + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/324-mac80211-support-using-ieee80211_tx_status_ext-to-fr.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/324-mac80211-support-using-ieee80211_tx_status_ext-to-fr.patch new file mode 100644 index 000000000..5469a419b --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/324-mac80211-support-using-ieee80211_tx_status_ext-to-fr.patch @@ -0,0 +1,63 @@ +From: Felix Fietkau +Date: Thu, 20 Aug 2020 17:27:00 +0200 +Subject: [PATCH] mac80211: support using ieee80211_tx_status_ext to free + skbs without status info + +For encap-offloaded packets, ieee80211_free_txskb cannot be used, since it +does not have the vif pointer. +Using ieee80211_tx_status_ext for this purpose has the advantage of being able +avoid an extra station lookup for AQL + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -1103,6 +1103,21 @@ void ieee80211_tx_status_ext(struct ieee + sta->tx_stats.last_rate_info = *status->rate; + } + ++ if (skb && (tx_time_est = ++ ieee80211_info_get_tx_time_est(IEEE80211_SKB_CB(skb))) > 0) { ++ /* Do this here to avoid the expensive lookup of the sta ++ * in ieee80211_report_used_skb(). ++ */ ++ ieee80211_sta_update_pending_airtime(local, sta, ++ skb_get_queue_mapping(skb), ++ tx_time_est, ++ true); ++ ieee80211_info_set_tx_time_est(IEEE80211_SKB_CB(skb), 0); ++ } ++ ++ if (!status->info) ++ goto free; ++ + rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count); + + sband = hw->wiphy->bands[info->band]; +@@ -1146,17 +1161,6 @@ void ieee80211_tx_status_ext(struct ieee + ieee80211s_update_metric(local, sta, status); + } + +- if (skb && (tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) { +- /* Do this here to avoid the expensive lookup of the sta +- * in ieee80211_report_used_skb(). +- */ +- ieee80211_sta_update_pending_airtime(local, sta, +- skb_get_queue_mapping(skb), +- tx_time_est, +- true); +- ieee80211_info_set_tx_time_est(info, 0); +- } +- + if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) + return __ieee80211_tx_status(hw, status, rates_idx, + retry_count); +@@ -1173,6 +1177,7 @@ void ieee80211_tx_status_ext(struct ieee + I802_DEBUG_INC(local->dot11FailedCount); + } + ++free: + if (!skb) + return; + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/325-mac80211-extend-ieee80211_tx_status_ext-to-support-b.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/325-mac80211-extend-ieee80211_tx_status_ext-to-support-b.patch new file mode 100644 index 000000000..e8b29bb4c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/325-mac80211-extend-ieee80211_tx_status_ext-to-support-b.patch @@ -0,0 +1,53 @@ +From: Felix Fietkau +Date: Fri, 21 Aug 2020 05:49:07 +0200 +Subject: [PATCH] mac80211: extend ieee80211_tx_status_ext to support + bulk free + +Store processed skbs ready to be freed in a list so the driver bulk free them + +Signed-off-by: Felix Fietkau +--- + +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -1092,12 +1092,14 @@ ieee80211_info_get_tx_time_est(struct ie + * @info: Basic tx status information + * @skb: Packet skb (can be NULL if not provided by the driver) + * @rate: The TX rate that was used when sending the packet ++ * @free_list: list where processed skbs are stored to be free'd by the driver + */ + struct ieee80211_tx_status { + struct ieee80211_sta *sta; + struct ieee80211_tx_info *info; + struct sk_buff *skb; + struct rate_info *rate; ++ struct list_head *free_list; + }; + + /** +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -1053,7 +1053,10 @@ static void __ieee80211_tx_status(struct + * with this test... + */ + if (!local->monitors && (!send_to_cooked || !local->cooked_mntrs)) { +- dev_kfree_skb(skb); ++ if (status->free_list) ++ list_add_tail(&skb->list, status->free_list); ++ else ++ dev_kfree_skb(skb); + return; + } + +@@ -1182,7 +1185,10 @@ free: + return; + + ieee80211_report_used_skb(local, skb, false); +- dev_kfree_skb(skb); ++ if (status->free_list) ++ list_add_tail(&skb->list, status->free_list); ++ else ++ dev_kfree_skb(skb); + } + EXPORT_SYMBOL(ieee80211_tx_status_ext); + diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/326-mac80211-notify-the-driver-when-a-sta-uses-4-address.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/326-mac80211-notify-the-driver-when-a-sta-uses-4-address.patch new file mode 100644 index 000000000..5ad5ac6a7 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/326-mac80211-notify-the-driver-when-a-sta-uses-4-address.patch @@ -0,0 +1,109 @@ +From: Felix Fietkau +Date: Fri, 21 Aug 2020 05:51:58 +0200 +Subject: [PATCH] mac80211: notify the driver when a sta uses 4-address + mode + +This is needed for encapsulation offload of 4-address mode packets + +Signed-off-by: Felix Fietkau +--- + +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -3840,6 +3840,8 @@ enum ieee80211_reconfig_type { + * This callback may sleep. + * @update_vif_config: Update virtual interface offload flags + * This callback may sleep. ++ * @sta_set_4addr: Called to notify the driver when a station starts/stops using ++ * 4-address mode + */ + struct ieee80211_ops { + void (*tx)(struct ieee80211_hw *hw, +@@ -4153,6 +4155,8 @@ struct ieee80211_ops { + struct ieee80211_sta *sta, u8 tids); + void (*update_vif_offload)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); ++ void (*sta_set_4addr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ++ struct ieee80211_sta *sta, bool enabled); + }; + + /** +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1693,6 +1693,7 @@ static int ieee80211_change_station(stru + + rcu_assign_pointer(vlansdata->u.vlan.sta, sta); + __ieee80211_check_fast_rx_iface(vlansdata); ++ drv_sta_set_4addr(local, sta->sdata, &sta->sta, true); + } + + if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && +--- a/net/mac80211/driver-ops.h ++++ b/net/mac80211/driver-ops.h +@@ -1400,4 +1400,18 @@ static inline void drv_update_vif_offloa + trace_drv_return_void(local); + } + ++static inline void drv_sta_set_4addr(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata, ++ struct ieee80211_sta *sta, bool enabled) ++{ ++ sdata = get_bss_sdata(sdata); ++ if (!check_sdata_in_driver(sdata)) ++ return; ++ ++ trace_drv_sta_set_4addr(local, sdata, sta, enabled); ++ if (local->ops->sta_set_4addr) ++ local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled); ++ trace_drv_return_void(local); ++} ++ + #endif /* __MAC80211_DRIVER_OPS */ +--- a/net/mac80211/mlme.c ++++ b/net/mac80211/mlme.c +@@ -3518,6 +3518,9 @@ static bool ieee80211_assoc_success(stru + goto out; + } + ++ if (sdata->wdev.use_4addr) ++ drv_sta_set_4addr(local, sdata, &sta->sta, true); ++ + mutex_unlock(&sdata->local->sta_mtx); + + /* +--- a/net/mac80211/trace.h ++++ b/net/mac80211/trace.h +@@ -2739,6 +2739,33 @@ DEFINE_EVENT(local_sdata_addr_evt, drv_u + TP_ARGS(local, sdata) + ); + ++TRACE_EVENT(drv_sta_set_4addr, ++ TP_PROTO(struct ieee80211_local *local, ++ struct ieee80211_sub_if_data *sdata, ++ struct ieee80211_sta *sta, bool enabled), ++ ++ TP_ARGS(local, sdata, sta, enabled), ++ ++ TP_STRUCT__entry( ++ LOCAL_ENTRY ++ VIF_ENTRY ++ STA_ENTRY ++ __field(bool, enabled) ++ ), ++ ++ TP_fast_assign( ++ LOCAL_ASSIGN; ++ VIF_ASSIGN; ++ STA_ASSIGN; ++ __entry->enabled = enabled; ++ ), ++ ++ TP_printk( ++ LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " enabled:%d", ++ LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->enabled ++ ) ++); ++ + #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ + + #undef TRACE_INCLUDE_PATH diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/327-mac80211-reorganize-code-to-remove-a-forward-declara.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/327-mac80211-reorganize-code-to-remove-a-forward-declara.patch new file mode 100644 index 000000000..a3d600152 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/327-mac80211-reorganize-code-to-remove-a-forward-declara.patch @@ -0,0 +1,1110 @@ +From: Felix Fietkau +Date: Tue, 8 Sep 2020 12:16:26 +0200 +Subject: [PATCH] mac80211: reorganize code to remove a forward + declaration + +Remove the newly added ieee80211_set_vif_encap_ops declaration. +No further code changes + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/iface.c ++++ b/net/mac80211/iface.c +@@ -43,7 +43,6 @@ + */ + + static void ieee80211_iface_work(struct work_struct *work); +-static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata); + + bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata) + { +@@ -349,6 +348,511 @@ static int ieee80211_check_queues(struct + return 0; + } + ++static int ieee80211_open(struct net_device *dev) ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ int err; ++ ++ /* fail early if user set an invalid address */ ++ if (!is_valid_ether_addr(dev->dev_addr)) ++ return -EADDRNOTAVAIL; ++ ++ err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type); ++ if (err) ++ return err; ++ ++ return ieee80211_do_open(&sdata->wdev, true); ++} ++ ++static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, ++ bool going_down) ++{ ++ struct ieee80211_local *local = sdata->local; ++ unsigned long flags; ++ struct sk_buff *skb, *tmp; ++ u32 hw_reconf_flags = 0; ++ int i, flushed; ++ struct ps_data *ps; ++ struct cfg80211_chan_def chandef; ++ bool cancel_scan; ++ struct cfg80211_nan_func *func; ++ ++ clear_bit(SDATA_STATE_RUNNING, &sdata->state); ++ ++ cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata; ++ if (cancel_scan) ++ ieee80211_scan_cancel(local); ++ ++ /* ++ * Stop TX on this interface first. ++ */ ++ if (sdata->dev) ++ netif_tx_stop_all_queues(sdata->dev); ++ ++ ieee80211_roc_purge(local, sdata); ++ ++ switch (sdata->vif.type) { ++ case NL80211_IFTYPE_STATION: ++ ieee80211_mgd_stop(sdata); ++ break; ++ case NL80211_IFTYPE_ADHOC: ++ ieee80211_ibss_stop(sdata); ++ break; ++ case NL80211_IFTYPE_MONITOR: ++ if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) ++ break; ++ list_del_rcu(&sdata->u.mntr.list); ++ break; ++ default: ++ break; ++ } ++ ++ /* ++ * Remove all stations associated with this interface. ++ * ++ * This must be done before calling ops->remove_interface() ++ * because otherwise we can later invoke ops->sta_notify() ++ * whenever the STAs are removed, and that invalidates driver ++ * assumptions about always getting a vif pointer that is valid ++ * (because if we remove a STA after ops->remove_interface() ++ * the driver will have removed the vif info already!) ++ * ++ * In WDS mode a station must exist here and be flushed, for ++ * AP_VLANs stations may exist since there's nothing else that ++ * would have removed them, but in other modes there shouldn't ++ * be any stations. ++ */ ++ flushed = sta_info_flush(sdata); ++ WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN && ++ ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || ++ (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1))); ++ ++ /* don't count this interface for allmulti while it is down */ ++ if (sdata->flags & IEEE80211_SDATA_ALLMULTI) ++ atomic_dec(&local->iff_allmultis); ++ ++ if (sdata->vif.type == NL80211_IFTYPE_AP) { ++ local->fif_pspoll--; ++ local->fif_probe_req--; ++ } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { ++ local->fif_probe_req--; ++ } ++ ++ if (sdata->dev) { ++ netif_addr_lock_bh(sdata->dev); ++ spin_lock_bh(&local->filter_lock); ++ __hw_addr_unsync(&local->mc_list, &sdata->dev->mc, ++ sdata->dev->addr_len); ++ spin_unlock_bh(&local->filter_lock); ++ netif_addr_unlock_bh(sdata->dev); ++ } ++ ++ del_timer_sync(&local->dynamic_ps_timer); ++ cancel_work_sync(&local->dynamic_ps_enable_work); ++ ++ cancel_work_sync(&sdata->recalc_smps); ++ sdata_lock(sdata); ++ mutex_lock(&local->mtx); ++ sdata->vif.csa_active = false; ++ if (sdata->vif.type == NL80211_IFTYPE_STATION) ++ sdata->u.mgd.csa_waiting_bcn = false; ++ if (sdata->csa_block_tx) { ++ ieee80211_wake_vif_queues(local, sdata, ++ IEEE80211_QUEUE_STOP_REASON_CSA); ++ sdata->csa_block_tx = false; ++ } ++ mutex_unlock(&local->mtx); ++ sdata_unlock(sdata); ++ ++ cancel_work_sync(&sdata->csa_finalize_work); ++ ++ cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); ++ ++ if (sdata->wdev.cac_started) { ++ chandef = sdata->vif.bss_conf.chandef; ++ WARN_ON(local->suspended); ++ mutex_lock(&local->mtx); ++ ieee80211_vif_release_channel(sdata); ++ mutex_unlock(&local->mtx); ++ cfg80211_cac_event(sdata->dev, &chandef, ++ NL80211_RADAR_CAC_ABORTED, ++ GFP_KERNEL); ++ } ++ ++ /* APs need special treatment */ ++ if (sdata->vif.type == NL80211_IFTYPE_AP) { ++ struct ieee80211_sub_if_data *vlan, *tmpsdata; ++ ++ /* down all dependent devices, that is VLANs */ ++ list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, ++ u.vlan.list) ++ dev_close(vlan->dev); ++ WARN_ON(!list_empty(&sdata->u.ap.vlans)); ++ } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { ++ /* remove all packets in parent bc_buf pointing to this dev */ ++ ps = &sdata->bss->ps; ++ ++ spin_lock_irqsave(&ps->bc_buf.lock, flags); ++ skb_queue_walk_safe(&ps->bc_buf, skb, tmp) { ++ if (skb->dev == sdata->dev) { ++ __skb_unlink(skb, &ps->bc_buf); ++ local->total_ps_buffered--; ++ ieee80211_free_txskb(&local->hw, skb); ++ } ++ } ++ spin_unlock_irqrestore(&ps->bc_buf.lock, flags); ++ } ++ ++ if (going_down) ++ local->open_count--; ++ ++ switch (sdata->vif.type) { ++ case NL80211_IFTYPE_AP_VLAN: ++ mutex_lock(&local->mtx); ++ list_del(&sdata->u.vlan.list); ++ mutex_unlock(&local->mtx); ++ RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); ++ /* see comment in the default case below */ ++ ieee80211_free_keys(sdata, true); ++ /* no need to tell driver */ ++ break; ++ case NL80211_IFTYPE_MONITOR: ++ if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) { ++ local->cooked_mntrs--; ++ break; ++ } ++ ++ local->monitors--; ++ if (local->monitors == 0) { ++ local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; ++ hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR; ++ } ++ ++ ieee80211_adjust_monitor_flags(sdata, -1); ++ break; ++ case NL80211_IFTYPE_NAN: ++ /* clean all the functions */ ++ spin_lock_bh(&sdata->u.nan.func_lock); ++ ++ idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, i) { ++ idr_remove(&sdata->u.nan.function_inst_ids, i); ++ cfg80211_free_nan_func(func); ++ } ++ idr_destroy(&sdata->u.nan.function_inst_ids); ++ ++ spin_unlock_bh(&sdata->u.nan.func_lock); ++ break; ++ case NL80211_IFTYPE_P2P_DEVICE: ++ /* relies on synchronize_rcu() below */ ++ RCU_INIT_POINTER(local->p2p_sdata, NULL); ++ /* fall through */ ++ default: ++ cancel_work_sync(&sdata->work); ++ /* ++ * When we get here, the interface is marked down. ++ * Free the remaining keys, if there are any ++ * (which can happen in AP mode if userspace sets ++ * keys before the interface is operating, and maybe ++ * also in WDS mode) ++ * ++ * Force the key freeing to always synchronize_net() ++ * to wait for the RX path in case it is using this ++ * interface enqueuing frames at this very time on ++ * another CPU. ++ */ ++ ieee80211_free_keys(sdata, true); ++ skb_queue_purge(&sdata->skb_queue); ++ } ++ ++ spin_lock_irqsave(&local->queue_stop_reason_lock, flags); ++ for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { ++ skb_queue_walk_safe(&local->pending[i], skb, tmp) { ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); ++ if (info->control.vif == &sdata->vif) { ++ __skb_unlink(skb, &local->pending[i]); ++ ieee80211_free_txskb(&local->hw, skb); ++ } ++ } ++ } ++ spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); ++ ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) ++ ieee80211_txq_remove_vlan(local, sdata); ++ ++ sdata->bss = NULL; ++ ++ if (local->open_count == 0) ++ ieee80211_clear_tx_pending(local); ++ ++ sdata->vif.bss_conf.beacon_int = 0; ++ ++ /* ++ * If the interface goes down while suspended, presumably because ++ * the device was unplugged and that happens before our resume, ++ * then the driver is already unconfigured and the remainder of ++ * this function isn't needed. ++ * XXX: what about WoWLAN? If the device has software state, e.g. ++ * memory allocated, it might expect teardown commands from ++ * mac80211 here? ++ */ ++ if (local->suspended) { ++ WARN_ON(local->wowlan); ++ WARN_ON(rtnl_dereference(local->monitor_sdata)); ++ return; ++ } ++ ++ switch (sdata->vif.type) { ++ case NL80211_IFTYPE_AP_VLAN: ++ break; ++ case NL80211_IFTYPE_MONITOR: ++ if (local->monitors == 0) ++ ieee80211_del_virtual_monitor(local); ++ ++ mutex_lock(&local->mtx); ++ ieee80211_recalc_idle(local); ++ mutex_unlock(&local->mtx); ++ ++ if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) ++ break; ++ ++ /* fall through */ ++ default: ++ if (going_down) ++ drv_remove_interface(local, sdata); ++ } ++ ++ ieee80211_recalc_ps(local); ++ ++ if (cancel_scan) ++ flush_delayed_work(&local->scan_work); ++ ++ if (local->open_count == 0) { ++ ieee80211_stop_device(local); ++ ++ /* no reconfiguring after stop! */ ++ return; ++ } ++ ++ /* do after stop to avoid reconfiguring when we stop anyway */ ++ ieee80211_configure_filter(local); ++ ieee80211_hw_config(local, hw_reconf_flags); ++ ++ if (local->monitors == local->open_count) ++ ieee80211_add_virtual_monitor(local); ++} ++ ++static int ieee80211_stop(struct net_device *dev) ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ ++ ieee80211_do_stop(sdata, true); ++ ++ return 0; ++} ++ ++static void ieee80211_set_multicast_list(struct net_device *dev) ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ struct ieee80211_local *local = sdata->local; ++ int allmulti, sdata_allmulti; ++ ++ allmulti = !!(dev->flags & IFF_ALLMULTI); ++ sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI); ++ ++ if (allmulti != sdata_allmulti) { ++ if (dev->flags & IFF_ALLMULTI) ++ atomic_inc(&local->iff_allmultis); ++ else ++ atomic_dec(&local->iff_allmultis); ++ sdata->flags ^= IEEE80211_SDATA_ALLMULTI; ++ } ++ ++ spin_lock_bh(&local->filter_lock); ++ __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len); ++ spin_unlock_bh(&local->filter_lock); ++ ieee80211_queue_work(&local->hw, &local->reconfig_filter); ++} ++ ++/* ++ * Called when the netdev is removed or, by the code below, before ++ * the interface type changes. ++ */ ++static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata) ++{ ++ int i; ++ ++ /* free extra data */ ++ ieee80211_free_keys(sdata, false); ++ ++ ieee80211_debugfs_remove_netdev(sdata); ++ ++ for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) ++ __skb_queue_purge(&sdata->fragments[i].skb_list); ++ sdata->fragment_next = 0; ++ ++ if (ieee80211_vif_is_mesh(&sdata->vif)) ++ ieee80211_mesh_teardown_sdata(sdata); ++} ++ ++static void ieee80211_uninit(struct net_device *dev) ++{ ++ ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev)); ++} ++ ++#if LINUX_VERSION_IS_GEQ(5,2,0) ++static u16 ieee80211_netdev_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ struct net_device *sb_dev) ++#elif LINUX_VERSION_IS_GEQ(4,19,0) ++static u16 ieee80211_netdev_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ struct net_device *sb_dev, ++ select_queue_fallback_t fallback) ++#elif LINUX_VERSION_IS_GEQ(3,14,0) || \ ++ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30) ++static u16 ieee80211_netdev_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ void *accel_priv, ++ select_queue_fallback_t fallback) ++#elif LINUX_VERSION_IS_GEQ(3,13,0) ++static u16 ieee80211_netdev_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ void *accel_priv) ++#else ++static u16 ieee80211_netdev_select_queue(struct net_device *dev, ++ struct sk_buff *skb) ++#endif ++{ ++ return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb); ++} ++ ++static void ++ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ++{ ++ int i; ++ ++ for_each_possible_cpu(i) { ++ const struct pcpu_sw_netstats *tstats; ++ u64 rx_packets, rx_bytes, tx_packets, tx_bytes; ++ unsigned int start; ++ ++ tstats = per_cpu_ptr(netdev_tstats(dev), i); ++ ++ do { ++ start = u64_stats_fetch_begin_irq(&tstats->syncp); ++ rx_packets = tstats->rx_packets; ++ tx_packets = tstats->tx_packets; ++ rx_bytes = tstats->rx_bytes; ++ tx_bytes = tstats->tx_bytes; ++ } while (u64_stats_fetch_retry_irq(&tstats->syncp, start)); ++ ++ stats->rx_packets += rx_packets; ++ stats->tx_packets += tx_packets; ++ stats->rx_bytes += rx_bytes; ++ stats->tx_bytes += tx_bytes; ++ } ++} ++#if LINUX_VERSION_IS_LESS(4,11,0) ++/* Just declare it here to keep sparse happy */ ++struct rtnl_link_stats64 *bp_ieee80211_get_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats); ++struct rtnl_link_stats64 * ++bp_ieee80211_get_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats){ ++ ieee80211_get_stats64(dev, stats); ++ return stats; ++} ++#endif ++ ++static const struct net_device_ops ieee80211_dataif_ops = { ++ .ndo_open = ieee80211_open, ++ .ndo_stop = ieee80211_stop, ++ .ndo_uninit = ieee80211_uninit, ++ .ndo_start_xmit = ieee80211_subif_start_xmit, ++ .ndo_set_rx_mode = ieee80211_set_multicast_list, ++ .ndo_set_mac_address = ieee80211_change_mac, ++ .ndo_select_queue = ieee80211_netdev_select_queue, ++#if LINUX_VERSION_IS_GEQ(4,11,0) ++ .ndo_get_stats64 = ieee80211_get_stats64, ++#else ++ .ndo_get_stats64 = bp_ieee80211_get_stats64, ++#endif ++ ++}; ++ ++#if LINUX_VERSION_IS_GEQ(5,2,0) ++static u16 ieee80211_monitor_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ struct net_device *sb_dev) ++#elif LINUX_VERSION_IS_GEQ(4,19,0) ++static u16 ieee80211_monitor_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ struct net_device *sb_dev, ++ select_queue_fallback_t fallback) ++#elif LINUX_VERSION_IS_GEQ(3,14,0) || \ ++ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30) ++static u16 ieee80211_monitor_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ void *accel_priv, ++ select_queue_fallback_t fallback) ++#elif LINUX_VERSION_IS_GEQ(3,13,0) ++static u16 ieee80211_monitor_select_queue(struct net_device *dev, ++ struct sk_buff *skb, ++ void *accel_priv) ++#else ++static u16 ieee80211_monitor_select_queue(struct net_device *dev, ++ struct sk_buff *skb) ++#endif ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ struct ieee80211_local *local = sdata->local; ++ struct ieee80211_hdr *hdr; ++ struct ieee80211_radiotap_header *rtap = (void *)skb->data; ++ ++ if (local->hw.queues < IEEE80211_NUM_ACS) ++ return 0; ++ ++ if (skb->len < 4 || ++ skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */) ++ return 0; /* doesn't matter, frame will be dropped */ ++ ++ hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len)); ++ ++ return ieee80211_select_queue_80211(sdata, skb, hdr); ++} ++ ++static const struct net_device_ops ieee80211_monitorif_ops = { ++ .ndo_open = ieee80211_open, ++ .ndo_stop = ieee80211_stop, ++ .ndo_uninit = ieee80211_uninit, ++ .ndo_start_xmit = ieee80211_monitor_start_xmit, ++ .ndo_set_rx_mode = ieee80211_set_multicast_list, ++ .ndo_set_mac_address = ieee80211_change_mac, ++ .ndo_select_queue = ieee80211_monitor_select_queue, ++#if LINUX_VERSION_IS_GEQ(4,11,0) ++ .ndo_get_stats64 = ieee80211_get_stats64, ++#else ++ .ndo_get_stats64 = bp_ieee80211_get_stats64, ++#endif ++ ++}; ++ ++static const struct net_device_ops ieee80211_dataif_8023_ops = { ++ .ndo_open = ieee80211_open, ++ .ndo_stop = ieee80211_stop, ++ .ndo_uninit = ieee80211_uninit, ++ .ndo_start_xmit = ieee80211_subif_start_xmit_8023, ++ .ndo_set_rx_mode = ieee80211_set_multicast_list, ++ .ndo_set_mac_address = ieee80211_change_mac, ++ .ndo_select_queue = ieee80211_netdev_select_queue, ++#if LINUX_VERSION_IS_GEQ(4,11,0) ++ .ndo_get_stats64 = ieee80211_get_stats64, ++#else ++ .ndo_get_stats64 = bp_ieee80211_get_stats64, ++#endif ++ ++}; ++ + static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype) + { + switch (iftype) { +@@ -389,6 +893,31 @@ static bool ieee80211_set_sdata_offload_ + return true; + } + ++static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata) ++{ ++ struct ieee80211_local *local = sdata->local; ++ struct ieee80211_sub_if_data *bss = sdata; ++ bool enabled; ++ ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { ++ if (!sdata->bss) ++ return; ++ ++ bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); ++ } ++ ++ if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) || ++ !ieee80211_iftype_supports_encap_offload(bss->vif.type)) ++ return; ++ ++ enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ if (sdata->wdev.use_4addr && ++ !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR)) ++ enabled = false; ++ ++ sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops : ++ &ieee80211_dataif_ops; ++} + + static void ieee80211_recalc_sdata_offload(struct ieee80211_sub_if_data *sdata) + { +@@ -866,511 +1395,6 @@ int ieee80211_do_open(struct wireless_de + return res; + } + +-static int ieee80211_open(struct net_device *dev) +-{ +- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); +- int err; +- +- /* fail early if user set an invalid address */ +- if (!is_valid_ether_addr(dev->dev_addr)) +- return -EADDRNOTAVAIL; +- +- err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type); +- if (err) +- return err; +- +- return ieee80211_do_open(&sdata->wdev, true); +-} +- +-static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, +- bool going_down) +-{ +- struct ieee80211_local *local = sdata->local; +- unsigned long flags; +- struct sk_buff *skb, *tmp; +- u32 hw_reconf_flags = 0; +- int i, flushed; +- struct ps_data *ps; +- struct cfg80211_chan_def chandef; +- bool cancel_scan; +- struct cfg80211_nan_func *func; +- +- clear_bit(SDATA_STATE_RUNNING, &sdata->state); +- +- cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata; +- if (cancel_scan) +- ieee80211_scan_cancel(local); +- +- /* +- * Stop TX on this interface first. +- */ +- if (sdata->dev) +- netif_tx_stop_all_queues(sdata->dev); +- +- ieee80211_roc_purge(local, sdata); +- +- switch (sdata->vif.type) { +- case NL80211_IFTYPE_STATION: +- ieee80211_mgd_stop(sdata); +- break; +- case NL80211_IFTYPE_ADHOC: +- ieee80211_ibss_stop(sdata); +- break; +- case NL80211_IFTYPE_MONITOR: +- if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) +- break; +- list_del_rcu(&sdata->u.mntr.list); +- break; +- default: +- break; +- } +- +- /* +- * Remove all stations associated with this interface. +- * +- * This must be done before calling ops->remove_interface() +- * because otherwise we can later invoke ops->sta_notify() +- * whenever the STAs are removed, and that invalidates driver +- * assumptions about always getting a vif pointer that is valid +- * (because if we remove a STA after ops->remove_interface() +- * the driver will have removed the vif info already!) +- * +- * In WDS mode a station must exist here and be flushed, for +- * AP_VLANs stations may exist since there's nothing else that +- * would have removed them, but in other modes there shouldn't +- * be any stations. +- */ +- flushed = sta_info_flush(sdata); +- WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN && +- ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || +- (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1))); +- +- /* don't count this interface for allmulti while it is down */ +- if (sdata->flags & IEEE80211_SDATA_ALLMULTI) +- atomic_dec(&local->iff_allmultis); +- +- if (sdata->vif.type == NL80211_IFTYPE_AP) { +- local->fif_pspoll--; +- local->fif_probe_req--; +- } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { +- local->fif_probe_req--; +- } +- +- if (sdata->dev) { +- netif_addr_lock_bh(sdata->dev); +- spin_lock_bh(&local->filter_lock); +- __hw_addr_unsync(&local->mc_list, &sdata->dev->mc, +- sdata->dev->addr_len); +- spin_unlock_bh(&local->filter_lock); +- netif_addr_unlock_bh(sdata->dev); +- } +- +- del_timer_sync(&local->dynamic_ps_timer); +- cancel_work_sync(&local->dynamic_ps_enable_work); +- +- cancel_work_sync(&sdata->recalc_smps); +- sdata_lock(sdata); +- mutex_lock(&local->mtx); +- sdata->vif.csa_active = false; +- if (sdata->vif.type == NL80211_IFTYPE_STATION) +- sdata->u.mgd.csa_waiting_bcn = false; +- if (sdata->csa_block_tx) { +- ieee80211_wake_vif_queues(local, sdata, +- IEEE80211_QUEUE_STOP_REASON_CSA); +- sdata->csa_block_tx = false; +- } +- mutex_unlock(&local->mtx); +- sdata_unlock(sdata); +- +- cancel_work_sync(&sdata->csa_finalize_work); +- +- cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); +- +- if (sdata->wdev.cac_started) { +- chandef = sdata->vif.bss_conf.chandef; +- WARN_ON(local->suspended); +- mutex_lock(&local->mtx); +- ieee80211_vif_release_channel(sdata); +- mutex_unlock(&local->mtx); +- cfg80211_cac_event(sdata->dev, &chandef, +- NL80211_RADAR_CAC_ABORTED, +- GFP_KERNEL); +- } +- +- /* APs need special treatment */ +- if (sdata->vif.type == NL80211_IFTYPE_AP) { +- struct ieee80211_sub_if_data *vlan, *tmpsdata; +- +- /* down all dependent devices, that is VLANs */ +- list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, +- u.vlan.list) +- dev_close(vlan->dev); +- WARN_ON(!list_empty(&sdata->u.ap.vlans)); +- } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { +- /* remove all packets in parent bc_buf pointing to this dev */ +- ps = &sdata->bss->ps; +- +- spin_lock_irqsave(&ps->bc_buf.lock, flags); +- skb_queue_walk_safe(&ps->bc_buf, skb, tmp) { +- if (skb->dev == sdata->dev) { +- __skb_unlink(skb, &ps->bc_buf); +- local->total_ps_buffered--; +- ieee80211_free_txskb(&local->hw, skb); +- } +- } +- spin_unlock_irqrestore(&ps->bc_buf.lock, flags); +- } +- +- if (going_down) +- local->open_count--; +- +- switch (sdata->vif.type) { +- case NL80211_IFTYPE_AP_VLAN: +- mutex_lock(&local->mtx); +- list_del(&sdata->u.vlan.list); +- mutex_unlock(&local->mtx); +- RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); +- /* see comment in the default case below */ +- ieee80211_free_keys(sdata, true); +- /* no need to tell driver */ +- break; +- case NL80211_IFTYPE_MONITOR: +- if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) { +- local->cooked_mntrs--; +- break; +- } +- +- local->monitors--; +- if (local->monitors == 0) { +- local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; +- hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR; +- } +- +- ieee80211_adjust_monitor_flags(sdata, -1); +- break; +- case NL80211_IFTYPE_NAN: +- /* clean all the functions */ +- spin_lock_bh(&sdata->u.nan.func_lock); +- +- idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, i) { +- idr_remove(&sdata->u.nan.function_inst_ids, i); +- cfg80211_free_nan_func(func); +- } +- idr_destroy(&sdata->u.nan.function_inst_ids); +- +- spin_unlock_bh(&sdata->u.nan.func_lock); +- break; +- case NL80211_IFTYPE_P2P_DEVICE: +- /* relies on synchronize_rcu() below */ +- RCU_INIT_POINTER(local->p2p_sdata, NULL); +- /* fall through */ +- default: +- cancel_work_sync(&sdata->work); +- /* +- * When we get here, the interface is marked down. +- * Free the remaining keys, if there are any +- * (which can happen in AP mode if userspace sets +- * keys before the interface is operating, and maybe +- * also in WDS mode) +- * +- * Force the key freeing to always synchronize_net() +- * to wait for the RX path in case it is using this +- * interface enqueuing frames at this very time on +- * another CPU. +- */ +- ieee80211_free_keys(sdata, true); +- skb_queue_purge(&sdata->skb_queue); +- } +- +- spin_lock_irqsave(&local->queue_stop_reason_lock, flags); +- for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { +- skb_queue_walk_safe(&local->pending[i], skb, tmp) { +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- if (info->control.vif == &sdata->vif) { +- __skb_unlink(skb, &local->pending[i]); +- ieee80211_free_txskb(&local->hw, skb); +- } +- } +- } +- spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); +- +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) +- ieee80211_txq_remove_vlan(local, sdata); +- +- sdata->bss = NULL; +- +- if (local->open_count == 0) +- ieee80211_clear_tx_pending(local); +- +- sdata->vif.bss_conf.beacon_int = 0; +- +- /* +- * If the interface goes down while suspended, presumably because +- * the device was unplugged and that happens before our resume, +- * then the driver is already unconfigured and the remainder of +- * this function isn't needed. +- * XXX: what about WoWLAN? If the device has software state, e.g. +- * memory allocated, it might expect teardown commands from +- * mac80211 here? +- */ +- if (local->suspended) { +- WARN_ON(local->wowlan); +- WARN_ON(rtnl_dereference(local->monitor_sdata)); +- return; +- } +- +- switch (sdata->vif.type) { +- case NL80211_IFTYPE_AP_VLAN: +- break; +- case NL80211_IFTYPE_MONITOR: +- if (local->monitors == 0) +- ieee80211_del_virtual_monitor(local); +- +- mutex_lock(&local->mtx); +- ieee80211_recalc_idle(local); +- mutex_unlock(&local->mtx); +- +- if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) +- break; +- +- /* fall through */ +- default: +- if (going_down) +- drv_remove_interface(local, sdata); +- } +- +- ieee80211_recalc_ps(local); +- +- if (cancel_scan) +- flush_delayed_work(&local->scan_work); +- +- if (local->open_count == 0) { +- ieee80211_stop_device(local); +- +- /* no reconfiguring after stop! */ +- return; +- } +- +- /* do after stop to avoid reconfiguring when we stop anyway */ +- ieee80211_configure_filter(local); +- ieee80211_hw_config(local, hw_reconf_flags); +- +- if (local->monitors == local->open_count) +- ieee80211_add_virtual_monitor(local); +-} +- +-static int ieee80211_stop(struct net_device *dev) +-{ +- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); +- +- ieee80211_do_stop(sdata, true); +- +- return 0; +-} +- +-static void ieee80211_set_multicast_list(struct net_device *dev) +-{ +- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); +- struct ieee80211_local *local = sdata->local; +- int allmulti, sdata_allmulti; +- +- allmulti = !!(dev->flags & IFF_ALLMULTI); +- sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI); +- +- if (allmulti != sdata_allmulti) { +- if (dev->flags & IFF_ALLMULTI) +- atomic_inc(&local->iff_allmultis); +- else +- atomic_dec(&local->iff_allmultis); +- sdata->flags ^= IEEE80211_SDATA_ALLMULTI; +- } +- +- spin_lock_bh(&local->filter_lock); +- __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len); +- spin_unlock_bh(&local->filter_lock); +- ieee80211_queue_work(&local->hw, &local->reconfig_filter); +-} +- +-/* +- * Called when the netdev is removed or, by the code below, before +- * the interface type changes. +- */ +-static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata) +-{ +- int i; +- +- /* free extra data */ +- ieee80211_free_keys(sdata, false); +- +- ieee80211_debugfs_remove_netdev(sdata); +- +- for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) +- __skb_queue_purge(&sdata->fragments[i].skb_list); +- sdata->fragment_next = 0; +- +- if (ieee80211_vif_is_mesh(&sdata->vif)) +- ieee80211_mesh_teardown_sdata(sdata); +-} +- +-static void ieee80211_uninit(struct net_device *dev) +-{ +- ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev)); +-} +- +-#if LINUX_VERSION_IS_GEQ(5,2,0) +-static u16 ieee80211_netdev_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- struct net_device *sb_dev) +-#elif LINUX_VERSION_IS_GEQ(4,19,0) +-static u16 ieee80211_netdev_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- struct net_device *sb_dev, +- select_queue_fallback_t fallback) +-#elif LINUX_VERSION_IS_GEQ(3,14,0) || \ +- (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30) +-static u16 ieee80211_netdev_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- void *accel_priv, +- select_queue_fallback_t fallback) +-#elif LINUX_VERSION_IS_GEQ(3,13,0) +-static u16 ieee80211_netdev_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- void *accel_priv) +-#else +-static u16 ieee80211_netdev_select_queue(struct net_device *dev, +- struct sk_buff *skb) +-#endif +-{ +- return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb); +-} +- +-static void +-ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) +-{ +- int i; +- +- for_each_possible_cpu(i) { +- const struct pcpu_sw_netstats *tstats; +- u64 rx_packets, rx_bytes, tx_packets, tx_bytes; +- unsigned int start; +- +- tstats = per_cpu_ptr(netdev_tstats(dev), i); +- +- do { +- start = u64_stats_fetch_begin_irq(&tstats->syncp); +- rx_packets = tstats->rx_packets; +- tx_packets = tstats->tx_packets; +- rx_bytes = tstats->rx_bytes; +- tx_bytes = tstats->tx_bytes; +- } while (u64_stats_fetch_retry_irq(&tstats->syncp, start)); +- +- stats->rx_packets += rx_packets; +- stats->tx_packets += tx_packets; +- stats->rx_bytes += rx_bytes; +- stats->tx_bytes += tx_bytes; +- } +-} +-#if LINUX_VERSION_IS_LESS(4,11,0) +-/* Just declare it here to keep sparse happy */ +-struct rtnl_link_stats64 *bp_ieee80211_get_stats64(struct net_device *dev, +- struct rtnl_link_stats64 *stats); +-struct rtnl_link_stats64 * +-bp_ieee80211_get_stats64(struct net_device *dev, +- struct rtnl_link_stats64 *stats){ +- ieee80211_get_stats64(dev, stats); +- return stats; +-} +-#endif +- +-static const struct net_device_ops ieee80211_dataif_ops = { +- .ndo_open = ieee80211_open, +- .ndo_stop = ieee80211_stop, +- .ndo_uninit = ieee80211_uninit, +- .ndo_start_xmit = ieee80211_subif_start_xmit, +- .ndo_set_rx_mode = ieee80211_set_multicast_list, +- .ndo_set_mac_address = ieee80211_change_mac, +- .ndo_select_queue = ieee80211_netdev_select_queue, +-#if LINUX_VERSION_IS_GEQ(4,11,0) +- .ndo_get_stats64 = ieee80211_get_stats64, +-#else +- .ndo_get_stats64 = bp_ieee80211_get_stats64, +-#endif +- +-}; +- +-#if LINUX_VERSION_IS_GEQ(5,2,0) +-static u16 ieee80211_monitor_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- struct net_device *sb_dev) +-#elif LINUX_VERSION_IS_GEQ(4,19,0) +-static u16 ieee80211_monitor_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- struct net_device *sb_dev, +- select_queue_fallback_t fallback) +-#elif LINUX_VERSION_IS_GEQ(3,14,0) || \ +- (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30) +-static u16 ieee80211_monitor_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- void *accel_priv, +- select_queue_fallback_t fallback) +-#elif LINUX_VERSION_IS_GEQ(3,13,0) +-static u16 ieee80211_monitor_select_queue(struct net_device *dev, +- struct sk_buff *skb, +- void *accel_priv) +-#else +-static u16 ieee80211_monitor_select_queue(struct net_device *dev, +- struct sk_buff *skb) +-#endif +-{ +- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); +- struct ieee80211_local *local = sdata->local; +- struct ieee80211_hdr *hdr; +- struct ieee80211_radiotap_header *rtap = (void *)skb->data; +- +- if (local->hw.queues < IEEE80211_NUM_ACS) +- return 0; +- +- if (skb->len < 4 || +- skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */) +- return 0; /* doesn't matter, frame will be dropped */ +- +- hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len)); +- +- return ieee80211_select_queue_80211(sdata, skb, hdr); +-} +- +-static const struct net_device_ops ieee80211_monitorif_ops = { +- .ndo_open = ieee80211_open, +- .ndo_stop = ieee80211_stop, +- .ndo_uninit = ieee80211_uninit, +- .ndo_start_xmit = ieee80211_monitor_start_xmit, +- .ndo_set_rx_mode = ieee80211_set_multicast_list, +- .ndo_set_mac_address = ieee80211_change_mac, +- .ndo_select_queue = ieee80211_monitor_select_queue, +-#if LINUX_VERSION_IS_GEQ(4,11,0) +- .ndo_get_stats64 = ieee80211_get_stats64, +-#else +- .ndo_get_stats64 = bp_ieee80211_get_stats64, +-#endif +- +-}; +- +-static const struct net_device_ops ieee80211_dataif_8023_ops = { +- .ndo_open = ieee80211_open, +- .ndo_stop = ieee80211_stop, +- .ndo_uninit = ieee80211_uninit, +- .ndo_start_xmit = ieee80211_subif_start_xmit_8023, +- .ndo_set_rx_mode = ieee80211_set_multicast_list, +- .ndo_set_mac_address = ieee80211_change_mac, +- .ndo_select_queue = ieee80211_netdev_select_queue, +-#if LINUX_VERSION_IS_GEQ(4,11,0) +- .ndo_get_stats64 = ieee80211_get_stats64, +-#else +- .ndo_get_stats64 = bp_ieee80211_get_stats64, +-#endif +- +-}; +- + static void ieee80211_if_free(struct net_device *dev) + { + free_percpu(netdev_tstats(dev)); +@@ -1401,32 +1425,6 @@ static void ieee80211_if_setup_no_queue( + #endif + } + +-static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata) +-{ +- struct ieee80211_local *local = sdata->local; +- struct ieee80211_sub_if_data *bss = sdata; +- bool enabled; +- +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { +- if (!sdata->bss) +- return; +- +- bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); +- } +- +- if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) || +- !ieee80211_iftype_supports_encap_offload(bss->vif.type)) +- return; +- +- enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED; +- if (sdata->wdev.use_4addr && +- !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR)) +- enabled = false; +- +- sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops : +- &ieee80211_dataif_ops; +-} +- + static void ieee80211_iface_work(struct work_struct *work) + { + struct ieee80211_sub_if_data *sdata = diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/328-mac80211-extend-AQL-aggregation-estimation-to-HE-and.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/328-mac80211-extend-AQL-aggregation-estimation-to-HE-and.patch new file mode 100644 index 000000000..3d687f834 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/328-mac80211-extend-AQL-aggregation-estimation-to-HE-and.patch @@ -0,0 +1,49 @@ +From: Felix Fietkau +Date: Thu, 27 Aug 2020 12:44:36 +0200 +Subject: [PATCH] mac80211: extend AQL aggregation estimation to HE and fix + unit mismatch + +The unit of the return value of ieee80211_get_rate_duration is nanoseconds, not +milliseconds. Adjust the duration checks to account for that. +For higher data rates, allow larger estimated aggregation sizes, and add some +values for HE as well, which can use much larger aggregates. +Since small packets with high data rates can now lead to duration values too +small for info->tx_time_est, return a minimum of 4us. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -668,20 +668,26 @@ u32 ieee80211_calc_expected_tx_airtime(s + * This will not be very accurate, but much better than simply + * assuming un-aggregated tx in all cases. + */ +- if (duration > 400) /* <= VHT20 MCS2 1S */ ++ if (duration > 400 * 1024) /* <= VHT20 MCS2 1S */ + agg_shift = 1; +- else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */ ++ else if (duration > 250 * 1024) /* <= VHT20 MCS3 1S or MCS1 2S */ + agg_shift = 2; +- else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */ ++ else if (duration > 150 * 1024) /* <= VHT20 MCS5 1S or MCS2 2S */ + agg_shift = 3; +- else ++ else if (duration > 70 * 1024) /* <= VHT20 MCS5 2S */ + agg_shift = 4; ++ else if (stat.encoding != RX_ENC_HE || ++ duration > 20 * 1024) /* <= HE40 MCS6 2S */ ++ agg_shift = 5; ++ else ++ agg_shift = 6; + + duration *= len; + duration /= AVG_PKT_SIZE; + duration /= 1024; ++ duration += (overhead >> agg_shift); + +- return duration + (overhead >> agg_shift); ++ return max_t(u32, duration, 4); + } + + if (!conf) diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/329-mac80211-add-AQL-support-for-VHT160-tx-rates.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/329-mac80211-add-AQL-support-for-VHT160-tx-rates.patch new file mode 100644 index 000000000..e22a09e71 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/329-mac80211-add-AQL-support-for-VHT160-tx-rates.patch @@ -0,0 +1,23 @@ +From: Felix Fietkau +Date: Thu, 27 Aug 2020 12:47:48 +0200 +Subject: [PATCH] mac80211: add AQL support for VHT160 tx rates + +When converting from struct ieee80211_tx_rate to ieee80211_rx_status, +there was one check missing to fill in the bandwidth for 160 MHz + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/airtime.c ++++ b/net/mac80211/airtime.c +@@ -560,7 +560,9 @@ static int ieee80211_fill_rx_status(stru + if (rate->idx < 0 || !rate->count) + return -1; + +- if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) ++ if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) ++ stat->bw = RATE_INFO_BW_160; ++ else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) + stat->bw = RATE_INFO_BW_80; + else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + stat->bw = RATE_INFO_BW_40; diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/370-mac80211-fix-misplaced-while-instead-of-if.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/370-mac80211-fix-misplaced-while-instead-of-if.patch new file mode 100644 index 000000000..38144013f --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/370-mac80211-fix-misplaced-while-instead-of-if.patch @@ -0,0 +1,31 @@ +From 5981fe5b0529ba25d95f37d7faa434183ad618c5 Mon Sep 17 00:00:00 2001 +From: Johannes Berg +Date: Mon, 3 Aug 2020 11:02:10 +0200 +Subject: [PATCH] mac80211: fix misplaced while instead of if + +This never was intended to be a 'while' loop, it should've +just been an 'if' instead of 'while'. Fix this. + +I noticed this while applying another patch from Ben that +intended to fix a busy loop at this spot. + +Cc: stable@vger.kernel.org +Fixes: b16798f5b907 ("mac80211: mark station unauthorized before key removal") +Reported-by: Ben Greear +Link: https://lore.kernel.org/r/20200803110209.253009ae41ff.I3522aad099392b31d5cf2dcca34cbac7e5832dde@changeid +Signed-off-by: Johannes Berg +--- + net/mac80211/sta_info.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -1051,7 +1051,7 @@ static void __sta_info_destroy_part2(str + might_sleep(); + lockdep_assert_held(&local->sta_mtx); + +- while (sta->sta_state == IEEE80211_STA_AUTHORIZED) { ++ if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { + ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); + WARN_ON_ONCE(ret); + } diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/400-allow-ibss-mixed.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/400-allow-ibss-mixed.patch new file mode 100644 index 000000000..feb6b5b11 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/400-allow-ibss-mixed.patch @@ -0,0 +1,29 @@ +ath10k-ct starting with version 5.2 allows the combination of +NL80211_IFTYPE_ADHOC and beacon_int_min_gcd in ath10k_10x_ct_if_comb +which triggers this warning. Ben told me that this is not a big problem +and we should ignore this. + +--- a/net/wireless/core.c ++++ b/net/wireless/core.c +@@ -612,21 +612,6 @@ static int wiphy_verify_combinations(str + c->limits[j].max > 1)) + return -EINVAL; + +- /* +- * This isn't well-defined right now. If you have an +- * IBSS interface, then its beacon interval may change +- * by joining other networks, and nothing prevents it +- * from doing that. +- * So technically we probably shouldn't even allow AP +- * and IBSS in the same interface, but it seems that +- * some drivers support that, possibly only with fixed +- * beacon intervals for IBSS. +- */ +- if (WARN_ON(types & BIT(NL80211_IFTYPE_ADHOC) && +- c->beacon_int_min_gcd)) { +- return -EINVAL; +- } +- + cnt += c->limits[j].max; + /* + * Don't advertise an unsupported type diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch new file mode 100644 index 000000000..8db3a758a --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch @@ -0,0 +1,160 @@ +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -3610,6 +3610,7 @@ struct mgmt_frame_regs { + * (as advertised by the nl80211 feature flag.) + * @get_tx_power: store the current TX power into the dbm variable; + * return 0 if successful ++ * @set_antenna_gain: set antenna gain to reduce maximum tx power if necessary + * + * @set_wds_peer: set the WDS peer for a WDS interface + * +@@ -3932,6 +3933,7 @@ struct cfg80211_ops { + enum nl80211_tx_power_setting type, int mbm); + int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev, + int *dbm); ++ int (*set_antenna_gain)(struct wiphy *wiphy, int dbi); + + int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, + const u8 *addr); +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -1521,6 +1521,7 @@ enum ieee80211_smps_mode { + * + * @power_level: requested transmit power (in dBm), backward compatibility + * value only that is set to the minimum of all interfaces ++ * @max_antenna_gain: maximum antenna gain adjusted by user config (in dBi) + * + * @chandef: the channel definition to tune to + * @radar_enabled: whether radar detection is enabled +@@ -1541,6 +1542,7 @@ enum ieee80211_smps_mode { + struct ieee80211_conf { + u32 flags; + int power_level, dynamic_ps_timeout; ++ int max_antenna_gain; + + u16 listen_interval; + u8 ps_dtim_period; +--- a/include/uapi/linux/nl80211.h ++++ b/include/uapi/linux/nl80211.h +@@ -2505,6 +2505,9 @@ enum nl80211_commands { + * @NL80211_ATTR_HE_6GHZ_CAPABILITY: HE 6 GHz Band Capability element (from + * association request when used with NL80211_CMD_NEW_STATION). + * ++ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce ++ * transmit power to stay within regulatory limits. u32, dBi. ++ * + * @NUM_NL80211_ATTR: total number of nl80211_attrs available + * @NL80211_ATTR_MAX: highest attribute number currently defined + * @__NL80211_ATTR_AFTER_LAST: internal use +@@ -2987,6 +2990,8 @@ enum nl80211_attrs { + + NL80211_ATTR_HE_6GHZ_CAPABILITY, + ++ NL80211_ATTR_WIPHY_ANTENNA_GAIN, ++ + /* add attributes here, update the policy in nl80211.c */ + + __NL80211_ATTR_AFTER_LAST, +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2611,6 +2611,19 @@ static int ieee80211_get_tx_power(struct + return 0; + } + ++static int ieee80211_set_antenna_gain(struct wiphy *wiphy, int dbi) ++{ ++ struct ieee80211_local *local = wiphy_priv(wiphy); ++ ++ if (dbi < 0) ++ return -EINVAL; ++ ++ local->user_antenna_gain = dbi; ++ ieee80211_hw_config(local, 0); ++ ++ return 0; ++} ++ + static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, + const u8 *addr) + { +@@ -4041,6 +4054,7 @@ const struct cfg80211_ops mac80211_confi + .set_wiphy_params = ieee80211_set_wiphy_params, + .set_tx_power = ieee80211_set_tx_power, + .get_tx_power = ieee80211_get_tx_power, ++ .set_antenna_gain = ieee80211_set_antenna_gain, + .set_wds_peer = ieee80211_set_wds_peer, + .rfkill_poll = ieee80211_rfkill_poll, + CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -1383,6 +1383,7 @@ struct ieee80211_local { + int dynamic_ps_forced_timeout; + + int user_power_level; /* in dBm, for all interfaces */ ++ int user_antenna_gain; /* in dBi */ + + enum ieee80211_smps_mode smps_mode; + +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -96,7 +96,7 @@ static u32 ieee80211_hw_conf_chan(struct + struct ieee80211_sub_if_data *sdata; + struct cfg80211_chan_def chandef = {}; + u32 changed = 0; +- int power; ++ int power, max_power; + u32 offchannel_flag; + + offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; +@@ -157,6 +157,12 @@ static u32 ieee80211_hw_conf_chan(struct + } + rcu_read_unlock(); + ++ max_power = chandef.chan->max_reg_power; ++ if (local->user_antenna_gain > 0) { ++ max_power -= local->user_antenna_gain; ++ power = min(power, max_power); ++ } ++ + if (local->hw.conf.power_level != power) { + changed |= IEEE80211_CONF_CHANGE_POWER; + local->hw.conf.power_level = power; +@@ -665,6 +671,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_ + IEEE80211_RADIOTAP_MCS_HAVE_BW; + local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI | + IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH; ++ local->user_antenna_gain = 0; + local->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; + local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; + local->hw.max_mtu = IEEE80211_MAX_DATA_LEN; +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -658,6 +658,7 @@ static const struct nla_policy nl80211_p + .type = NLA_EXACT_LEN, + .len = sizeof(struct ieee80211_he_6ghz_capa), + }, ++ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 }, + }; + + /* policy for the key attributes */ +@@ -3136,6 +3137,20 @@ static int nl80211_set_wiphy(struct sk_b + if (result) + return result; + } ++ ++ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_GAIN]) { ++ int idx, dbi = 0; ++ ++ if (!rdev->ops->set_antenna_gain) ++ return -EOPNOTSUPP; ++ ++ idx = NL80211_ATTR_WIPHY_ANTENNA_GAIN; ++ dbi = nla_get_u32(info->attrs[idx]); ++ ++ result = rdev->ops->set_antenna_gain(&rdev->wiphy, dbi); ++ if (result) ++ return result; ++ } + + if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] && + info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) { diff --git a/feeds/wifi-ath10k/mac80211/patches/subsys/800-oom.patch b/feeds/wifi-ath10k/mac80211/patches/subsys/800-oom.patch new file mode 100644 index 000000000..401a8bf32 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/patches/subsys/800-oom.patch @@ -0,0 +1,71 @@ +From a8295e2c06e1aa313b4624df9dedf599df382eef Mon Sep 17 00:00:00 2001 +From: Ben Greear +Date: Thu, 9 May 2013 11:56:22 -0700 +Subject: mac80211: Limit number of pending skbs. + +Current code will allow any number of pending skbs, and +this can OOM the system when used with something like +the pktgen tool (which may not back off properly if +queue is stopped). + +Possibly this is just a bug in our version of pktgen, +but either way, it seems reasonable to add a limit +so that it is not possible to go OOM in this manner. + +Signed-off-by: Ben Greear + +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c +index 3529d1368068..5eb60a50641e 100644 +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -35,6 +35,17 @@ + #include "wpa.h" + #include "wme.h" + #include "rate.h" ++#include ++ ++/* ++ * Maximum number of skbs that may be queued in a pending ++ * queue. After that, packets will just be dropped. ++ */ ++static int max_pending_qsize = 1000; ++module_param(max_pending_qsize, int, 0644); ++MODULE_PARM_DESC(max_pending_qsize, ++ "Maximum number of skbs that may be queued in a pending queue."); ++ + + /* misc utils */ + +@@ -1671,15 +1682,28 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local, + * later transmission from the tx-pending + * tasklet when the queue is woken again. + */ +- if (txpending) ++ bool do_free = false; ++ if (txpending) { + skb_queue_splice_init(skbs, + &local->pending[q]); +- else +- skb_queue_splice_tail_init(skbs, +- &local->pending[q]); ++ } else { ++ u32 len = skb_queue_len(&local->pending[q]); ++ if (len >= max_pending_qsize) { ++ __skb_unlink(skb, skbs); ++ do_free = true; ++ } else { ++ skb_queue_splice_tail_init(skbs, ++ &local->pending[q]); ++ } ++ } + + spin_unlock_irqrestore(&local->queue_stop_reason_lock, + flags); ++ if (do_free) { ++ dev_kfree_skb_any(skb); ++ /* TODO: Add counter for this */ ++ } ++ + return false; + } + } diff --git a/feeds/wifi-ath10k/mac80211/ralink.mk b/feeds/wifi-ath10k/mac80211/ralink.mk new file mode 100644 index 000000000..6aca17077 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/ralink.mk @@ -0,0 +1,172 @@ +PKG_DRIVERS += \ + rt2x00-lib rt2x00-pci rt2x00-usb rt2x00-mmio \ + rt2400-pci rt2500-pci rt2500-usb \ + rt2800-lib rt2800-mmio rt2800-pci rt2800-soc rt2800-usb \ + rt61-pci rt73-usb + +PKG_CONFIG_DEPENDS += \ + CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS \ + CONFIG_PACKAGE_RT2X00_DEBUG + +config-$(call config_package,rt2x00-lib) += RT2X00 RT2X00_LIB +config-$(call config_package,rt2x00-pci) += RT2X00_LIB_PCI +config-$(call config_package,rt2x00-mmio) += RT2X00_LIB_MMIO +config-$(call config_package,rt2x00-usb) += RT2X00_LIB_USB +config-$(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS) += RT2X00_LIB_DEBUGFS +config-$(CONFIG_PACKAGE_RT2X00_DEBUG) += RT2X00_DEBUG + +config-$(call config_package,rt2400-pci) += RT2400PCI +config-$(call config_package,rt2500-pci) += RT2500PCI +config-$(call config_package,rt2500-usb) += RT2500USB +config-$(call config_package,rt61-pci) += RT61PCI +config-$(call config_package,rt73-usb) += RT73USB + +config-$(call config_package,rt2800-lib) += RT2800_LIB + +config-$(call config_package,rt2800-soc) += RT2800SOC +config-$(call config_package,rt2800-pci) += RT2800PCI +config-y += RT2800PCI_RT33XX RT2800PCI_RT35XX RT2800PCI_RT53XX RT2800PCI_RT3290 + +config-$(call config_package,rt2800-usb) += RT2800USB +config-y += RT2800USB_RT33XX RT2800USB_RT35XX RT2800USB_RT3573 RT2800USB_RT53XX RT2800USB_RT55XX RT2800USB_UNKNOWN + +define KernelPackage/rt2x00/Default + $(call KernelPackage/mac80211/Default) + TITLE:=Ralink Drivers for RT2x00 cards +endef + +define KernelPackage/rt2x00-lib +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-mac80211 + TITLE+= (LIB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2x00lib.ko + MENU:=1 +endef + +define KernelPackage/rt2x00-lib/config + if PACKAGE_kmod-rt2x00-lib + + config PACKAGE_RT2X00_LIB_DEBUGFS + bool "Enable rt2x00 debugfs support" + depends on PACKAGE_MAC80211_DEBUGFS + help + Enable creation of debugfs files for the rt2x00 drivers. + These debugfs files support both reading and writing of the + most important register types of the rt2x00 hardware. + + config PACKAGE_RT2X00_DEBUG + bool "Enable rt2x00 debug output" + help + Enable debugging output for all rt2x00 modules + + endif +endef + +define KernelPackage/rt2x00-mmio +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @(PCI_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib + HIDDEN:=1 + TITLE+= (MMIO) + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2x00mmio.ko +endef + +define KernelPackage/rt2x00-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-mmio +kmod-rt2x00-lib + HIDDEN:=1 + TITLE+= (PCI) + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2x00pci.ko + AUTOLOAD:=$(call AutoProbe,rt2x00pci) +endef + +define KernelPackage/rt2x00-usb +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-lib +kmod-usb-core + HIDDEN:=1 + TITLE+= (USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2x00usb.ko + AUTOLOAD:=$(call AutoProbe,rt2x00usb) +endef + +define KernelPackage/rt2800-lib +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +kmod-lib-crc-ccitt +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + HIDDEN:=1 + TITLE+= (rt2800 LIB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2800lib.ko +endef + +define KernelPackage/rt2400-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci +kmod-eeprom-93cx6 + TITLE+= (RT2400 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2400pci.ko + AUTOLOAD:=$(call AutoProbe,rt2400pci) +endef + +define KernelPackage/rt2500-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci +kmod-eeprom-93cx6 + TITLE+= (RT2500 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2500pci.ko + AUTOLOAD:=$(call AutoProbe,rt2500pci) +endef + +define KernelPackage/rt2500-usb +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb + TITLE+= (RT2500 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2500usb.ko + AUTOLOAD:=$(call AutoProbe,rt2500usb) +endef + +define KernelPackage/rt2800-mmio +$(call KernelPackage/rt2x00/Default) + TITLE += (RT28xx/RT3xxx MMIO) + DEPENDS += +kmod-rt2800-lib +kmod-rt2x00-mmio + HIDDEN:=1 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2800mmio.ko +endef + +define KernelPackage/rt2800-soc +$(call KernelPackage/rt2x00/Default) + DEPENDS += @(TARGET_ramips_rt288x||TARGET_ramips_rt305x||TARGET_ramips_rt3883||TARGET_ramips_mt7620) +kmod-rt2800-mmio +kmod-rt2800-lib + TITLE += (RT28xx/RT3xxx SoC) + FILES := \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2x00soc.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2800soc.ko + AUTOLOAD:=$(call AutoProbe,rt2800soc) +endef + +define KernelPackage/rt2800-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci +kmod-rt2800-lib +kmod-rt2800-mmio +kmod-eeprom-93cx6 +rt2800-pci-firmware + TITLE+= (RT2860 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2800pci.ko + AUTOLOAD:=$(call AutoProbe,rt2800pci) +endef + +define KernelPackage/rt2800-usb +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb +kmod-rt2800-lib +kmod-lib-crc-ccitt +rt2800-usb-firmware + TITLE+= (RT2870 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt2800usb.ko + AUTOLOAD:=$(call AutoProbe,rt2800usb) +endef + + +define KernelPackage/rt61-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci +kmod-eeprom-93cx6 +kmod-lib-crc-itu-t +rt61-pci-firmware + TITLE+= (RT2x61 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt61pci.ko + AUTOLOAD:=$(call AutoProbe,rt61pci) +endef + +define KernelPackage/rt73-usb + $(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb +kmod-lib-crc-itu-t +rt73-usb-firmware + TITLE+= (RT73 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ralink/rt2x00/rt73usb.ko + AUTOLOAD:=$(call AutoProbe,rt73usb) +endef diff --git a/feeds/wifi-ath10k/mac80211/realtek.mk b/feeds/wifi-ath10k/mac80211/realtek.mk new file mode 100644 index 000000000..bcf35e35c --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/realtek.mk @@ -0,0 +1,206 @@ +PKG_DRIVERS += \ + rtl8180 rtl8187 \ + rtlwifi rtlwifi-pci rtlwifi-btcoexist rtlwifi-usb rtl8192c-common \ + rtl8192ce rtl8192se rtl8192de rtl8192cu rtl8723bs rtl8821ae \ + rtl8xxxu rtw88 + +config-$(call config_package,rtl8180) += RTL8180 +config-$(call config_package,rtl8187) += RTL8187 + +config-$(call config_package,rtlwifi) += RTL_CARDS RTLWIFI +config-$(call config_package,rtlwifi-pci) += RTLWIFI_PCI +config-$(call config_package,rtlwifi-btcoexist) += RTLBTCOEXIST +config-$(call config_package,rtlwifi-usb) += RTLWIFI_USB +config-$(call config_package,rtl8192c-common) += RTL8192C_COMMON +config-$(call config_package,rtl8192ce) += RTL8192CE +config-$(call config_package,rtl8192se) += RTL8192SE +config-$(call config_package,rtl8192de) += RTL8192DE +config-$(call config_package,rtl8192cu) += RTL8192CU +config-$(call config_package,rtl8821ae) += RTL8821AE +config-$(CONFIG_PACKAGE_RTLWIFI_DEBUG) += RTLWIFI_DEBUG + +config-$(call config_package,rtl8xxxu) += RTL8XXXU +config-y += RTL8XXXU_UNTESTED + +config-$(call config_package,rtl8723bs) += RTL8723BS +config-y += STAGING + +config-$(call config_package,rtw88) += RTW88 RTW88_CORE RTW88_PCI +config-y += RTW88_8822BE RTW88_8822CE RTW88_8723DE + +define KernelPackage/rtl818x/Default + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek Drivers for RTL818x devices + URL:=https://wireless.wiki.kernel.org/en/users/drivers/rtl8187 + DEPENDS+= +kmod-eeprom-93cx6 +kmod-mac80211 +endef + +define KernelPackage/rtl8180 + $(call KernelPackage/rtl818x/Default) + DEPENDS+= @PCI_SUPPORT + TITLE+= (RTL8180 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtl818x/rtl8180/rtl818x_pci.ko + AUTOLOAD:=$(call AutoProbe,rtl818x_pci) +endef + +define KernelPackage/rtl8187 +$(call KernelPackage/rtl818x/Default) + DEPENDS+= @USB_SUPPORT +kmod-usb-core + TITLE+= (RTL8187 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8187.ko + AUTOLOAD:=$(call AutoProbe,rtl8187) +endef + +define KernelPackage/rtlwifi/config + config PACKAGE_RTLWIFI_DEBUG + bool "Realtek wireless debugging" + depends on PACKAGE_kmod-rtlwifi + help + Say Y, if you want to debug realtek wireless drivers. + +endef + +define KernelPackage/rtlwifi + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek common driver part + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT) +kmod-mac80211 +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtlwifi.ko + HIDDEN:=1 +endef + +define KernelPackage/rtlwifi-pci + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek common driver part (PCI support) + DEPENDS+= @PCI_SUPPORT +kmod-rtlwifi + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl_pci.ko + AUTOLOAD:=$(call AutoProbe,rtl_pci) + HIDDEN:=1 +endef + +define KernelPackage/rtlwifi-btcoexist + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek BT coexist support + DEPENDS+= +kmod-rtlwifi + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/btcoexist/btcoexist.ko + AUTOLOAD:=$(call AutoProbe,btcoexist) + HIDDEN:=1 +endef + +define KernelPackage/rtlwifi-usb + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek common driver part (USB support) + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-rtlwifi + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl_usb.ko + AUTOLOAD:=$(call AutoProbe,rtl_usb) + HIDDEN:=1 +endef + +define KernelPackage/rtl8192c-common + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8192CE/RTL8192CU common support module + DEPENDS+= +kmod-rtlwifi + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8192c/rtl8192c-common.ko + HIDDEN:=1 +endef + +define KernelPackage/rtl8192ce + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8192CE/RTL8188CE support + DEPENDS+= +kmod-rtlwifi-pci +kmod-rtl8192c-common +rtl8192ce-firmware + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/rtl8192ce.ko + AUTOLOAD:=$(call AutoProbe,rtl8192ce) +endef + +define KernelPackage/rtl8192se + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8192SE/RTL8191SE support + DEPENDS+= +kmod-rtlwifi-pci +rtl8192se-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8192se/rtl8192se.ko + AUTOLOAD:=$(call AutoProbe,rtl8192se) +endef + +define KernelPackage/rtl8192de + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8192DE/RTL8188DE support + DEPENDS+= +kmod-rtlwifi-pci +rtl8192de-firmware + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8192de/rtl8192de.ko + AUTOLOAD:=$(call AutoProbe,rtl8192de) +endef + +define KernelPackage/rtl8192cu + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8192CU/RTL8188CU support + DEPENDS+= +kmod-rtlwifi-usb +kmod-rtl8192c-common +rtl8192cu-firmware + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.ko + AUTOLOAD:=$(call AutoProbe,rtl8192cu) +endef + +define KernelPackage/rtl8821ae + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8821AE support + DEPENDS+= +kmod-rtlwifi-btcoexist +kmod-rtlwifi-pci +rtl8821ae-firmware + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/rtl8821ae.ko + AUTOLOAD:=$(call AutoProbe,rtl8821ae) +endef + +define KernelPackage/rtl8xxxu + $(call KernelPackage/mac80211/Default) + TITLE:=alternative Realtek RTL8XXXU support + DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-mac80211 + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.ko + AUTOLOAD:=$(call AutoProbe,rtl8xxxu) +endef + +define KernelPackage/rtl8xxxu/description + This is an alternative driver for various Realtek RTL8XXX + parts written to utilize the Linux mac80211 stack. + The driver is known to work with a number of RTL8723AU, + RL8188CU, RTL8188RU, RTL8191CU, and RTL8192CU devices + + This driver is under development and has a limited feature + set. In particular it does not yet support 40MHz channels + and power management. However it should have a smaller + memory footprint than the vendor drivers and benetifs + from the in kernel mac80211 stack. + + It can coexist with drivers from drivers/staging/rtl8723au, + drivers/staging/rtl8192u, and drivers/net/wireless/rtlwifi, + but you will need to control which module you wish to load. + + RTL8XXXU_UNTESTED is enabled + This option enables detection of Realtek 8723/8188/8191/8192 WiFi + USB devices which have not been tested directly by the driver + author or reported to be working by third parties. + + Please report your results! +endef + +define KernelPackage/rtw88 + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822BE/RTL8822CE/RTL8723DE + DEPENDS+= @(PCI_SUPPORT) +kmod-mac80211 +@DRIVER_11AC_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT + FILES:=\ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822be.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822b.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822ce.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822c.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8723de.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8723d.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_core.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_pci.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822be rtw88_8822ce rtw88_8723de) +endef + +define KernelPackage/rtl8723bs + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8723BS SDIO Wireless LAN NIC driver (staging) + DEPENDS+=+kmod-mmc +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/staging/rtl8723bs/r8723bs.ko + AUTOLOAD:=$(call AutoProbe,r8723bs) +endef + +define KernelPackage/rtl8723bs/description + This option enables support for RTL8723BS SDIO drivers, such as the wifi found + on the 1st gen Intel Compute Stick, the CHIP and many other Intel Atom and ARM + based devices. +endef diff --git a/feeds/wifi-ath10k/mac80211/scripts/import-backports.sh b/feeds/wifi-ath10k/mac80211/scripts/import-backports.sh new file mode 100755 index 000000000..35aa411e6 --- /dev/null +++ b/feeds/wifi-ath10k/mac80211/scripts/import-backports.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +BASE=$1; shift + +usage() { + echo "Usage: $0 NNN ..." + exit 1 +} + +check_number() { + case "$1" in + [0-9][0-9][0-9]) return 0;; + esac + return 1; +} + +patch_header() +{ + awk ' + /^(---|\*\*\*|Index:)[ \t][^ \t]|^diff -/ \ + { exit } + { print } + ' +} + +strip_diffstat() +{ + awk ' + /#? .* \| / \ + { eat = eat $0 "\n" + next } + /^#? .* files? changed(, .* insertions?\(\+\))?(, .* deletions?\(-\))?/ \ + { eat = "" + next } + { print eat $0 + eat = "" } + ' +} + +strip_trailing_whitespace() { + sed -e 's:[ '$'\t'']*$::' +} + +fixup_header() { + awk ' + /^From / { next } + /^Subject: / { + sub("Subject: \\[[^\]]*\\]", "Subject: [PATCH]") + } + { print } + ' +} + +check_number "$BASE" || usage + +quilt series > /dev/null || { + echo "Not in quilt directory" + exit 2 +} + +get_next() { + NEW=$BASE + quilt series | while read CUR; do + [ -n "$CUR" ] || break + CUR=${CUR%%-*} + check_number "$CUR" || continue + [ "$CUR" -lt "$NEW" ] && continue + [ "$CUR" -ge "$(($BASE + 100))" ] && continue + NEW="$(($CUR + 1))" + echo $NEW + done | tail -n1 +} + +CUR=$(get_next) +CUR="${CUR:-$BASE}" + +while [ -n "$1" ]; do + FILE="$1"; shift + NAME="$(basename $FILE)" + NAME="${NAME#[0-9]*-}" + echo -n "Processing patch $NAME: " + + [ -e "$FILE" ] || { + echo "file $FILE not found" + exit 1 + } + + grep -qE "$NAME$" patches/series && { + echo "already applied" + continue + } + + quilt new "$CUR-$NAME" || exit 1 + patch_header < "$FILE" | + strip_diffstat | + strip_trailing_whitespace | + fixup_header > "patches/$CUR-$NAME" + + quilt fold < "$FILE" || { + cp "$FILE" ./cur_patch + echo "patch $FILE failed to apply, copied to ./cur_patch" + exit 1 + } + + quilt refresh -p ab --no-index --no-timestamps + + CUR="$(($CUR + 1))" +done + +exit 0 diff --git a/patches/0055-ipq40xx-add-packet_steering-script-from-19.07.patch b/patches/0055-ipq40xx-add-packet_steering-script-from-19.07.patch new file mode 100644 index 000000000..f6f7d515b --- /dev/null +++ b/patches/0055-ipq40xx-add-packet_steering-script-from-19.07.patch @@ -0,0 +1,87 @@ +From 954975fbc48c2273051ba2b83e85e2e462130725 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Tue, 14 Dec 2021 07:20:25 +0100 +Subject: [PATCH] ipq40xx: add packet_steering script from 19.07 + +Signed-off-by: John Crispin +--- + .../base-files/etc/hotplug.d/net/20-smp-tune | 67 +++++++++++++++++++ + 1 file changed, 67 insertions(+) + create mode 100644 target/linux/ipq40xx/base-files/etc/hotplug.d/net/20-smp-tune + +diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/net/20-smp-tune b/target/linux/ipq40xx/base-files/etc/hotplug.d/net/20-smp-tune +new file mode 100644 +index 0000000000..ab9a90418e +--- /dev/null ++++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/net/20-smp-tune +@@ -0,0 +1,67 @@ ++#!/bin/sh ++[ "$ACTION" = add ] || exit ++ ++NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)" ++[ "$NPROCS" -gt 1 ] || exit ++ ++PROC_MASK="$(( (1 << $NPROCS) - 1 ))" ++ ++find_irq_cpu() { ++ local dev="$1" ++ local match="$(grep -m 1 "$dev\$" /proc/interrupts)" ++ local cpu=0 ++ ++ [ -n "$match" ] && { ++ set -- $match ++ shift ++ for cur in `seq 1 $NPROCS`; do ++ [ "$1" -gt 0 ] && { ++ cpu=$(($cur - 1)) ++ break ++ } ++ shift ++ done ++ } ++ ++ echo "$cpu" ++} ++ ++set_hex_val() { ++ local file="$1" ++ local val="$2" ++ val="$(printf %x "$val")" ++ [ -n "$DEBUG" ] && echo "$file = $val" ++ echo "$val" > "$file" ++} ++ ++default_ps="$(uci get "network.@globals[0].default_ps")" ++[ -n "$default_ps" -a "$default_ps" != 1 ] && exit 0 ++ ++exec 512>/var/lock/smp_tune.lock ++flock 512 || exit 1 ++ ++for dev in /sys/class/net/*; do ++ [ -d "$dev" ] || continue ++ ++ # ignore virtual interfaces ++ [ -n "$(ls "${dev}/" | grep '^lower_')" ] && continue ++ [ -d "${dev}/device" ] || continue ++ ++ device="$(readlink "${dev}/device")" ++ device="$(basename "$device")" ++ irq_cpu="$(find_irq_cpu "$device")" ++ irq_cpu_mask="$((1 << $irq_cpu))" ++ ++ for q in ${dev}/queues/rx-*; do ++ set_hex_val "$q/rps_cpus" "$(($PROC_MASK & ~$irq_cpu_mask))" ++ done ++ ++ ntxq="$(ls -d ${dev}/queues/tx-* | wc -l)" ++ ++ idx=$(($irq_cpu + 1)) ++ for q in ${dev}/queues/tx-*; do ++ set_hex_val "$q/xps_cpus" "$((1 << $idx))" ++ let "idx = idx + 1" ++ [ "$idx" -ge "$NPROCS" ] && idx=0 ++ done ++done +-- +2.25.1 + diff --git a/patches/0056-ipq40xx-enable-napi-threading.patch b/patches/0056-ipq40xx-enable-napi-threading.patch new file mode 100644 index 000000000..df10fa792 --- /dev/null +++ b/patches/0056-ipq40xx-enable-napi-threading.patch @@ -0,0 +1,27 @@ +From 0bd80d71774ab01df2c150c85cb6ea2b94f3928c Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Tue, 14 Dec 2021 11:04:27 +0100 +Subject: [PATCH] ipq40xx: enable napi threading + +Signed-off-by: John Crispin +--- + .../ipq40xx/base-files/lib/preinit/05_set_threading.sh | 7 +++++++ + 1 file changed, 7 insertions(+) + create mode 100644 target/linux/ipq40xx/base-files/lib/preinit/05_set_threading.sh + +diff --git a/target/linux/ipq40xx/base-files/lib/preinit/05_set_threading.sh b/target/linux/ipq40xx/base-files/lib/preinit/05_set_threading.sh +new file mode 100644 +index 0000000000..66c865bc62 +--- /dev/null ++++ b/target/linux/ipq40xx/base-files/lib/preinit/05_set_threading.sh +@@ -0,0 +1,7 @@ ++. /lib/functions.sh ++ ++preinit_set_threading() { ++ echo 1 > /sys/class/net/eth0/threaded ++} ++ ++boot_hook_add preinit_main preinit_set_threading +-- +2.25.1 + diff --git a/profiles/cig_wf160d.yml b/profiles/cig_wf160d.yml index a8819a2fe..bc79fb886 100644 --- a/profiles/cig_wf160d.yml +++ b/profiles/cig_wf160d.yml @@ -6,11 +6,4 @@ description: Build image for the CIG WF160D image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-cig_wf610d-squashfs-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/edgecore_ecw5211.yml b/profiles/edgecore_ecw5211.yml index 92b003a1e..8bd044ba7 100644 --- a/profiles/edgecore_ecw5211.yml +++ b/profiles/edgecore_ecw5211.yml @@ -6,11 +6,9 @@ description: Build image for the Edgecore ECW5211 image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-edgecore_ecw5211-squashfs-nand-sysupgrade.bin include: - ucentral-ap + - wifi-ath10k - container packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt - kmod-bluetooth - kmod-usb-serial - kmod-usb-serial-option @@ -18,7 +16,3 @@ packages: - bluez-daemon - bluez-utils - usbutils -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set diff --git a/profiles/edgecore_ecw5410.yml b/profiles/edgecore_ecw5410.yml index d80d49d0c..792e3cb5c 100644 --- a/profiles/edgecore_ecw5410.yml +++ b/profiles/edgecore_ecw5410.yml @@ -6,11 +6,4 @@ description: Build image for the EdgeCore ECW5410 image: bin/targets/ipq806x/generic/openwrt-ipq806x-generic-edgecore_ecw5410-squashfs-nand-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/edgecore_oap100.yml b/profiles/edgecore_oap100.yml index 9a4377f40..ab81e0ad5 100644 --- a/profiles/edgecore_oap100.yml +++ b/profiles/edgecore_oap100.yml @@ -6,12 +6,6 @@ description: Build image for the Edgecore OPA100 image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-edgecore_oap100-squashfs-nand-sysupgrade.bin include: - ucentral-ap + - wifi-ath10k packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt - ugps -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set diff --git a/profiles/edgecore_spw2ac1200-lan-poe.yml b/profiles/edgecore_spw2ac1200-lan-poe.yml index c99c86dcb..a0ec887b4 100644 --- a/profiles/edgecore_spw2ac1200-lan-poe.yml +++ b/profiles/edgecore_spw2ac1200-lan-poe.yml @@ -7,11 +7,4 @@ image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-edgecore_spw2ac1200-l include: - ucentral-ap - container -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/edgecore_spw2ac1200.yml b/profiles/edgecore_spw2ac1200.yml index 9f0358cf1..6d8e5b860 100644 --- a/profiles/edgecore_spw2ac1200.yml +++ b/profiles/edgecore_spw2ac1200.yml @@ -7,11 +7,4 @@ image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-edgecore_spw2ac1200-s include: - ucentral-ap - container -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/edgecore_ssw2ac2600.yml b/profiles/edgecore_ssw2ac2600.yml index cfbc04738..c21659fab 100644 --- a/profiles/edgecore_ssw2ac2600.yml +++ b/profiles/edgecore_ssw2ac2600.yml @@ -6,11 +6,4 @@ description: Build image for the EdgeCore SSW2AC2600 image: bin/targets/ipq806x/generic/openwrt-ipq806x-generic-edgecore_ssw2ac2600-squashfs-nand-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/hfcl_ion4.yml b/profiles/hfcl_ion4.yml index 9d8a17c09..6ef4aa87d 100644 --- a/profiles/hfcl_ion4.yml +++ b/profiles/hfcl_ion4.yml @@ -6,11 +6,4 @@ description: Build image for the HFCL ION4 image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-hfcl_ion4-squashfs-nand-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/linksys_ea8300.yml b/profiles/linksys_ea8300.yml index 8edabd7e5..39440424d 100644 --- a/profiles/linksys_ea8300.yml +++ b/profiles/linksys_ea8300.yml @@ -6,11 +6,4 @@ description: Build image for the Linksys ea8300 image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-linksys_ea8300-squashfs-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/tp-link_ec420-g1.yml b/profiles/tp-link_ec420-g1.yml index 665879679..d0ac21005 100644 --- a/profiles/tp-link_ec420-g1.yml +++ b/profiles/tp-link_ec420-g1.yml @@ -7,11 +7,4 @@ image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-tp-link_ec420_g1-squa include: - ucentral-ap - container -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/wallys_dr40x9.yml b/profiles/wallys_dr40x9.yml index 912c39ab7..a08a3040b 100644 --- a/profiles/wallys_dr40x9.yml +++ b/profiles/wallys_dr40x9.yml @@ -6,11 +6,4 @@ description: Build image for the wallys dr40x9 image: bin/targets/ipq40xx/generic/openwrt-ipq40xx-generic-wallys_dr40x9-squashfs-nand-sysupgrade.bin include: - ucentral-ap -packages: - - ath10k-firmware-qca4019-ct-htt - - ath10k-firmware-qca9888-ct-htt - - ath10k-firmware-qca9984-ct-htt -diffconfig: | - # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set - # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set + - wifi-ath10k diff --git a/profiles/wifi-ath10k.yml b/profiles/wifi-ath10k.yml new file mode 100644 index 000000000..39ab16686 --- /dev/null +++ b/profiles/wifi-ath10k.yml @@ -0,0 +1,13 @@ +--- +description: Add the wifi ath10k support +feeds: + - name: wifi_ath10k + path: ../../feeds/wifi-ath10k +packages: + - ath10k-firmware-qca4019-ct-htt + - ath10k-firmware-qca9888-ct-htt + - ath10k-firmware-qca9984-ct-htt +diffconfig: | + # CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set + # CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set + # CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set