diff options
Diffstat (limited to 'package/kernel')
464 files changed, 26739 insertions, 21573 deletions
diff --git a/package/kernel/acx-mac80211/Makefile b/package/kernel/acx-mac80211/Makefile deleted file mode 100644 index 8bb84e5a6ae..00000000000 --- a/package/kernel/acx-mac80211/Makefile +++ /dev/null @@ -1,253 +0,0 @@ -# -# Copyright (C) 2007-2012 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:=acx-mac80211 -PKG_RELEASE:=1 - -PKG_SOURCE_URL:=http://git.code.sf.net/p/acx100/acx-mac80211 -PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2014-02-16 -PKG_SOURCE_VERSION:=b6fc31491020cb01d2cd1acc170cfa03ced7e726 -PKG_MIRROR_HASH:=58590245715f0e5fb4b57aab6d91071dfb6a97d3273f5aee0b97b1edee030ed0 - -PKG_CONFIG_DEPENDS:= \ - CONFIG_PACKAGE_MAC80211_DEBUGFS \ - CONFIG_PACKAGE_MAC80211_MESH \ - -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/acx-mac80211 - SUBMENU:=Wireless Drivers - TITLE:=ACX1xx mac80211 driver - DEPENDS:=@PCI_SUPPORT @mipsel +kmod-mac80211 - FILES:=$(PKG_BUILD_DIR)/acx-mac80211.ko - AUTOLOAD:=$(call AutoProbe,acx-mac80211) - MENU:=1 -endef - -define KernelPackage/acx-mac80211/config - menu "Configuration" - depends on PACKAGE_kmod-acx-mac80211 - - config ACX_ID_0D - bool "ACX1xx Radio ID 0D firmware" - help - Download and install firmware for: - ACX1xx cards with Radio ID 0D into /lib/firmware. - - config ACX_ID_11 - bool "ACX1xx Radio ID 11 firmware" - help - Download and install firmware for: - ACX1xx cards with Radio ID 11 into /lib/firmware. - - config ACX_ID_15 - bool "ACX1xx Radio ID 15 firmware" - help - Download and install firmware for: - ACX1xx cards with Radio ID 15 into /lib/firmware. - - config ACX_ID_16 - bool "ACX1xx Radio ID 16 firmware" - default y - help - Download and install firmware for: - ACX1xx cards with Radio ID 16 into /lib/firmware. - - choice - prompt "ACX111 firmware version" - depends on ACX_ID_16 - default ACX_DEFAULT - help - This option allows you to select the version of the acx firmware. - - config ACX_DEFAULT - bool "Default" - help - Default firmware for ACX111 devices. - - If unsure, select this. - - config ACX_1_2_1_34 - bool "1.2.1_34" - help - 1.2.1_34 firmware for ACX111 devices. Works with Zyxel P-334WT. - - If unsure, select the "default" firmware. - - endchoice - - config ACX_ID_17 - bool "ACX1xx Radio ID 17 firmware" - help - Download and install firmware for: - ACX1xx cards with Radio ID 17 into /lib/firmware. - - config ACX_ID_19 - bool "ACX1xx Radio ID 19 firmware" - default y - help - Download and install firmware for: - ACX1xx cards with Radio ID 19 into /lib/firmware. - - config ACX_ID_1B - bool "ACX1xx Radio ID 1B firmware" - help - Download and install firmware for: - ACX1xx cards with Radio ID 1b into /lib/firmware. - - endmenu -endef - -define KernelPackage/acx-mac80211/description - Driver for acx111 cards (mac80211 version) -endef - -define Download/tiacx100 - FILE:=tiacx100 - URL:=@OPENWRT - HASH:=4f05913c940c2455b267545b12d93ad81fa5eebb0cbee22a2c7588c50525b4f0 -endef - -define Download/tiacx100r0d - FILE:=tiacx100r0D - URL:=@OPENWRT - HASH:=6a4a7fbb24a328a88261bc2a507b2a0bf63c91e831e3f1a8caa4f6599b2215e6 -endef - -define Download/tiacx100r11 - FILE:=tiacx100r11 - URL:=@OPENWRT - HASH:=e005a93a0b463e01edba2b79038b54c29a7932efee61c851a2ac644b8a4e5dd4 -endef - -define Download/tiacx100r15 - FILE:=tiacx100r15 - URL:=@OPENWRT - HASH:=c6f40bead5ef45720e2d72bbe4d998367c2c7857eb7716234aedeb2ad98bcdde -endef - -define Download/tiacx111c16 - FILE:=tiacx111c16 - URL:=@OPENWRT - HASH:=cc6108d577ebc55b924ff6bab44eeee3456d284c63819277cb5460338b2f1bd7 -endef - -define Download/tiacx111c16_1 - FILE:=tiacx111c16_1.2.1_34 - URL:=@OPENWRT - HASH:=672ed9d02565ab44da450c52f0ced3be99a3a3901f73454455da8e1f98ada220 -endef - -define Download/tiacx111c17 - FILE:=tiacx111c17 - URL:=@OPENWRT - HASH:=2bb900a5886dbea2d3504623d9f3ac8abbb2e9fdfcf0fe233e77951dff748a40 -endef - -define Download/tiacx111c19 - FILE:=tiacx111c19 - URL:=@OPENWRT - HASH:=383d86a8cfddf92400d661b4e43a9b855350fa656edd4f75b4aff7fab2d00e90 -endef - -define Download/tiacx111usbc1b - FILE:=tiacx111usbc1B - URL:=@OPENWRT - HASH:=f3c9e574de7073014ab6eef9a0f6412c53ae521b67723360af753c41401ed4d5 -endef - -PKG_EXTRA_KCONFIG:= \ - CONFIG_ACX_MAC80211=m \ - CONFIG_ACX_MAC80211_PCI=m \ - -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)))) \ - $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS) \ - $(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS), -DCONFIG_CFG80211_DEBUGFS -DCONFIG_MAC80211_DEBUGFS) \ - $(if $(CONFIG_PACKAGE_MAC80211_MESH), -DCONFIG_MAC80211_MESH) \ - -DBACKPORTED_KERNEL_NAME=\\\"$(PKG_SOURCE)\\\" \ - -DBACKPORTED_KERNEL_VERSION=\\\"$(PKG_SOURCE_VERSION)\\\" \ - -DBACKPORTS_VERSION=\\\"unknown\\\" \ - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ - M="$(PKG_BUILD_DIR)" \ - $(PKG_EXTRA_KCONFIG) \ - EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -DCONFIG_ACX_MAC80211_VERSION=\"KERNEL_VERSION(4,2,0)\"" \ - LINUXINCLUDE="-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 \ - -I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/$(LINUX_UAPI_DIR) \ - -I$(LINUX_DIR)/include/generated/uapi/ -Iarch/$(LINUX_KARCH)/include \ - -Iarch/$(LINUX_KARCH)/include/$(LINUX_UAPI_DIR) \ - -Iarch/$(LINUX_KARCH)/include/generated \ - -Iarch/$(LINUX_KARCH)/include/generated/$(LINUX_UAPI_DIR) \ - -include generated/autoconf.h \ - -include backport/backport.h " \ - V="$(V)" \ - modules -endef - -define Build/Configure -endef - -define KernelPackage/acx-mac80211/install - $(INSTALL_DIR) $(1)/lib/firmware - -ifneq ($(CONFIG_ACX_ID_0D)$(CONFIG_ACX_ID_11)$(CONFIG_ACX_ID_15),) - $(INSTALL_DATA) $(DL_DIR)/tiacx100 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_ID_0D),) - $(INSTALL_DATA) $(DL_DIR)/tiacx100r0D $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_ID_11),) - $(INSTALL_DATA) $(DL_DIR)/tiacx100r11 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_ID_15),) - $(INSTALL_DATA) $(DL_DIR)/tiacx100r15 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_DEFAULT),) - $(INSTALL_DATA) $(DL_DIR)/tiacx111c16 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_1_2_1_34),) - $(INSTALL_DATA) $(DL_DIR)/tiacx111c16_1.2.1_34 $(1)/lib/firmware/tiacx111c16 -endif - -ifneq ($(CONFIG_ACX_ID_17),) - $(INSTALL_DATA) $(DL_DIR)/tiacx111c17 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_ID_19),) - $(INSTALL_DATA) $(DL_DIR)/tiacx111c19 $(1)/lib/firmware/ -endif - -ifneq ($(CONFIG_ACX_ID_1B),) - $(INSTALL_DATA) $(DL_DIR)/tiacx111usbc1B $(1)/lib/firmware/ -endif - -endef - -$(eval $(call KernelPackage,acx-mac80211)) -$(eval $(call Download,tiacx100)) -$(eval $(call Download,tiacx100r0d)) -$(eval $(call Download,tiacx100r11)) -$(eval $(call Download,tiacx100r15)) -$(eval $(call Download,tiacx111c16)) -$(eval $(call Download,tiacx111c16_1)) -$(eval $(call Download,tiacx111c17)) -$(eval $(call Download,tiacx111c19)) -$(eval $(call Download,tiacx111usbc1b)) diff --git a/package/kernel/acx-mac80211/patches/100-compat.patch b/package/kernel/acx-mac80211/patches/100-compat.patch deleted file mode 100644 index 6fcab5ea43f..00000000000 --- a/package/kernel/acx-mac80211/patches/100-compat.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/pci.c b/pci.c -index ae07f5a..72d542f 100644 ---- a/pci.c -+++ b/pci.c -@@ -1495,7 +1495,11 @@ static struct acxpci_device_info acxpci_info_tbl[] __devinitdata = { - #endif - - #ifdef CONFIG_PCI -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) - static DEFINE_PCI_DEVICE_TABLE(acxpci_id_tbl) = { -+#else -+static const struct pci_device_id acxpci_id_tbl[] = { -+#endif - { PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_TNETW1100A), - .driver_data = CHIPTYPE_ACX100, - }, diff --git a/package/kernel/acx-mac80211/patches/200-initial-macaddr.patch b/package/kernel/acx-mac80211/patches/200-initial-macaddr.patch deleted file mode 100644 index c0fdd433b35..00000000000 --- a/package/kernel/acx-mac80211/patches/200-initial-macaddr.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/cardsetting.c -+++ b/cardsetting.c -@@ -715,10 +715,25 @@ int acx1xx_get_station_id(acx_device_t * - u8 *stationID = adev->ie_cmd_buf; - const u8 *paddr; - int i, res; -+ const char *prom_addr; -+ char *prom_getenv(const char *name); - - res = acx_interrogate(adev, stationID, ACX1xx_IE_DOT11_STATION_ID); - paddr = &stationID[4]; -- for (i = 0; i < ETH_ALEN; i++) { -+ prom_addr = NULL; -+#ifdef CONFIG_VLYNQ -+ prom_addr = prom_getenv("macwlan"); -+ if (prom_addr == NULL) -+ prom_addr = prom_getenv("mac_ap"); -+#endif -+ if (prom_addr) -+ sscanf(prom_addr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", adev->dev_addr, -+ adev->dev_addr + 1, -+ adev->dev_addr + 2, -+ adev->dev_addr + 3, -+ adev->dev_addr + 4, -+ adev->dev_addr + 5); -+ else for (i = 0; i < ETH_ALEN; i++) { - /* we copy the MAC address (reversed in the card) to - * the netdevice's MAC address, and on ifup it will be - * copied into iwadev->dev_addr */ diff --git a/package/kernel/acx-mac80211/patches/300-api_sync.patch b/package/kernel/acx-mac80211/patches/300-api_sync.patch deleted file mode 100644 index d055271f600..00000000000 --- a/package/kernel/acx-mac80211/patches/300-api_sync.patch +++ /dev/null @@ -1,112 +0,0 @@ ---- a/main.c -+++ b/main.c -@@ -497,7 +497,7 @@ int acx_free_mechanics(acx_device_t *ade - - int acx_init_ieee80211(acx_device_t *adev, struct ieee80211_hw *hw) - { -- hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS; -+ __clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, hw->flags); - hw->queues = 1; - hw->wiphy->max_scan_ssids = 1; - -@@ -525,14 +525,14 @@ int acx_init_ieee80211(acx_device_t *ade - /* We base signal quality on winlevel approach of previous driver - * TODO OW 20100615 This should into a common init code - */ -- hw->flags |= IEEE80211_HW_SIGNAL_UNSPEC; -+ __set_bit(IEEE80211_HW_SIGNAL_UNSPEC, hw->flags); - hw->max_signal = 100; - - if (IS_ACX100(adev)) { -- adev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = -+ adev->hw->wiphy->bands[NL80211_BAND_2GHZ] = - &acx100_band_2GHz; - } else if (IS_ACX111(adev)) -- adev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = -+ adev->hw->wiphy->bands[NL80211_BAND_2GHZ] = - &acx111_band_2GHz; - else { - log(L_ANY, "Error: Unknown device"); -@@ -945,8 +945,8 @@ void acx_op_configure_filter(struct ieee - changed_flags, *total_flags); - - /* OWI TODO: Set also FIF_PROBE_REQ ? */ -- *total_flags &= (FIF_PROMISC_IN_BSS | FIF_ALLMULTI | FIF_FCSFAIL -- | FIF_CONTROL | FIF_OTHER_BSS); -+ *total_flags &= (FIF_ALLMULTI | FIF_FCSFAIL | FIF_CONTROL -+ | FIF_OTHER_BSS); - - logf1(L_DEBUG, "2: *total_flags=0x%08x\n", *total_flags); - -@@ -1045,9 +1045,10 @@ void acx_op_tx(struct ieee80211_hw *hw, - } - - int acx_op_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, -- struct cfg80211_scan_request *req) -+ struct ieee80211_scan_request *hw_req) - { - acx_device_t *adev = hw2adev(hw); -+ struct cfg80211_scan_request *req = &hw_req->req; - struct sk_buff *skb; - size_t ssid_len = 0; - u8 *ssid = NULL; -@@ -1082,7 +1083,7 @@ int acx_op_hw_scan(struct ieee80211_hw * - goto out; - } - #else -- skb = ieee80211_probereq_get(adev->hw, adev->vif, ssid, ssid_len, -+ skb = ieee80211_probereq_get(adev->hw, vif->addr, ssid, ssid_len, - req->ie_len); - if (!skb) { - ret = -ENOMEM; ---- a/main.h -+++ b/main.h -@@ -62,7 +62,7 @@ void acx_op_tx(struct ieee80211_hw *hw, - #endif - - int acx_op_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, -- struct cfg80211_scan_request *req); -+ struct ieee80211_scan_request *req); - - int acx_recover_hw(acx_device_t *adev); - ---- a/cardsetting.c -+++ b/cardsetting.c -@@ -159,7 +159,7 @@ int acx_set_channel(acx_device_t *adev, - int res = 0; - - adev->rx_status.freq = freq; -- adev->rx_status.band = IEEE80211_BAND_2GHZ; -+ adev->rx_status.band = NL80211_BAND_2GHZ; - - adev->channel = channel; - ---- a/merge.c -+++ b/merge.c -@@ -2776,7 +2776,10 @@ void acx_irq_work(struct work_struct *wo - /* HOST_INT_SCAN_COMPLETE */ - if (irqmasked & HOST_INT_SCAN_COMPLETE) { - if (test_bit(ACX_FLAG_SCANNING, &adev->flags)) { -- ieee80211_scan_completed(adev->hw, false); -+ struct cfg80211_scan_info info = { -+ .aborted = false -+ }; -+ ieee80211_scan_completed(adev->hw, &info); - log(L_INIT, "scan completed\n"); - clear_bit(ACX_FLAG_SCANNING, &adev->flags); - } -@@ -3138,10 +3141,13 @@ int acx_op_start(struct ieee80211_hw *hw - - void acx_stop(acx_device_t *adev) - { -+ struct cfg80211_scan_info info = { -+ .aborted = true -+ }; - acxmem_lock_flags; - - if (test_bit(ACX_FLAG_SCANNING, &adev->flags)) { -- ieee80211_scan_completed(adev->hw, true); -+ ieee80211_scan_completed(adev->hw, &info); - acx_issue_cmd(adev, ACX1xx_CMD_STOP_SCAN, NULL, 0); - clear_bit(ACX_FLAG_SCANNING, &adev->flags); - } diff --git a/package/kernel/ath10k-ct/Makefile b/package/kernel/ath10k-ct/Makefile index 5681c5c2cdc..9c0029d3bdb 100644 --- a/package/kernel/ath10k-ct/Makefile +++ b/package/kernel/ath10k-ct/Makefile @@ -1,21 +1,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ath10k-ct -PKG_RELEASE:=$(AUTORELEASE) +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-06-03 -PKG_SOURCE_VERSION:=b44cd7b2e7b0df5995ece18f358d4dfc40834ba1 -PKG_MIRROR_HASH:=59f961ad425eb1a48fa9c391a325cc0f23845daec9d12673445d3077f9756cf0 +PKG_SOURCE_DATE:=2023-06-05 +PKG_SOURCE_VERSION:=fadd0768cbd22248a60efbb219ccefc9d86cd78c +PKG_MIRROR_HASH:=513f62765ba3a2f423099426fbba86b854f3de0ab13ec2ab6e2780577ea75f95 -# Build the 5.10 ath10k-ct driver version. +# Build the 6.4 ath10k-ct driver version. # Probably this should match as closely as # possible to whatever mac80211 backports version is being used. -CT_KVER="-5.10" +CT_KVER="-6.4" PKG_MAINTAINER:=Ben Greear <greearb@candelatech.com> PKG_BUILD_PARALLEL:=1 @@ -29,7 +29,7 @@ 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 @PCI_SUPPORT +kmod-hwmon-core + DEPENDS:=+kmod-mac80211 +kmod-ath +@DRIVER_11AC_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 @@ -111,8 +111,7 @@ ifneq ($(findstring c,$(OPENWRT_VERBOSE)),) endif define Build/Compile - +$(MAKE) $(CT_MAKEDEFS) $(PKG_JOBS) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ + +$(KERNEL_MAKE) $(CT_MAKEDEFS) $(PKG_JOBS) \ M="$(PKG_BUILD_DIR)/ath10k$(CT_KVER)" \ NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ modules diff --git a/package/kernel/ath10k-ct/patches/100-ath10k-ct-port-compilation-warning-for-debug-level-t.patch b/package/kernel/ath10k-ct/patches/100-ath10k-ct-port-compilation-warning-for-debug-level-t.patch new file mode 100644 index 00000000000..f4522c87b43 --- /dev/null +++ b/package/kernel/ath10k-ct/patches/100-ath10k-ct-port-compilation-warning-for-debug-level-t.patch @@ -0,0 +1,111 @@ +From a227621b46df8a7a5c276131b245f40eac7513fb Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Fri, 3 Nov 2023 04:03:08 +0100 +Subject: [PATCH] ath10k-ct: port compilation warning for debug level to kernel + 6.4 + +Port compilation warning for debug level previously fixed in other +kernel to kernel version 6.4. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + ath10k-6.4/debug.c | 85 ++++++++++++++++++++++++++-------------------- + 1 file changed, 48 insertions(+), 37 deletions(-) + +--- a/ath10k-6.4/debug.c ++++ b/ath10k-6.4/debug.c +@@ -1345,47 +1345,58 @@ static const struct file_operations fops + .llseek = default_llseek, + }; + ++static const char debug_level_buf[] = ++ "To change debug level, set value adding up desired flags:\n" ++ "PCI: 0x1\n" ++ "WMI: 0x2\n" ++ "HTC: 0x4\n" ++ "HTT: 0x8\n" ++ "MAC: 0x10\n" ++ "BOOT: 0x20\n" ++ "PCI-DUMP: 0x40\n" ++ "HTT-DUMP: 0x80\n" ++ "MGMT: 0x100\n" ++ "DATA: 0x200\n" ++ "BMI: 0x400\n" ++ "REGULATORY: 0x800\n" ++ "TESTMODE: 0x1000\n" ++ "WMI-PRINT: 0x2000\n" ++ "PCI-PS: 0x4000\n" ++ "AHB: 0x8000\n" ++ "SDIO: 0x10000\n" ++ "SDIO_DUMP: 0x20000\n" ++ "USB: 0x40000\n" ++ "USB_BULK: 0x80000\n" ++ "SNOC: 0x100000\n" ++ "QMI: 0x200000\n" ++ "BEACONS: 0x8000000\n" ++ "NO-FW-DBGLOG:0x10000000\n" ++ "MAC2: 0x20000000\n" ++ "INFO-AS-DBG: 0x40000000\n" ++ "FW: 0x80000000\n" ++ "ALL: 0xEFFFFFFF\n"; ++ ++#define READ_DEBUG_LEVEL_SIZE sizeof(debug_level_buf) + 60 ++ + static ssize_t ath10k_read_debug_level(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) + { +- int sz; +- const char buf[] = +- "To change debug level, set value adding up desired flags:\n" +- "PCI: 0x1\n" +- "WMI: 0x2\n" +- "HTC: 0x4\n" +- "HTT: 0x8\n" +- "MAC: 0x10\n" +- "BOOT: 0x20\n" +- "PCI-DUMP: 0x40\n" +- "HTT-DUMP: 0x80\n" +- "MGMT: 0x100\n" +- "DATA: 0x200\n" +- "BMI: 0x400\n" +- "REGULATORY: 0x800\n" +- "TESTMODE: 0x1000\n" +- "WMI-PRINT: 0x2000\n" +- "PCI-PS: 0x4000\n" +- "AHB: 0x8000\n" +- "SDIO: 0x10000\n" +- "SDIO_DUMP: 0x20000\n" +- "USB: 0x40000\n" +- "USB_BULK: 0x80000\n" +- "SNOC: 0x100000\n" +- "QMI: 0x200000\n" +- "BEACONS: 0x8000000\n" +- "NO-FW-DBGLOG:0x10000000\n" +- "MAC2: 0x20000000\n" +- "INFO-AS-DBG: 0x40000000\n" +- "FW: 0x80000000\n" +- "ALL: 0xEFFFFFFF\n"; +- char wbuf[sizeof(buf) + 60]; +- sz = snprintf(wbuf, sizeof(wbuf), "Current debug level: 0x%x\n\n%s", +- ath10k_debug_mask, buf); +- wbuf[sizeof(wbuf) - 1] = 0; ++ int sz, ret; ++ char *wbuf; ++ ++ wbuf = kcalloc(READ_DEBUG_LEVEL_SIZE, sizeof(char), GFP_KERNEL); ++ if (!wbuf) ++ return -ENOMEM; ++ ++ sz = snprintf(wbuf, READ_DEBUG_LEVEL_SIZE, ++ "Current debug level: 0x%x\n\n%s", ++ ath10k_debug_mask, debug_level_buf); ++ ++ ret = simple_read_from_buffer(user_buf, count, ppos, wbuf, sz); ++ kfree(wbuf); + +- return simple_read_from_buffer(user_buf, count, ppos, wbuf, sz); ++ return ret; + } + + /* Set logging level. diff --git a/package/kernel/ath10k-ct/patches/130-ath10k-read-qcom-coexist-support-as-a-u32.patch b/package/kernel/ath10k-ct/patches/130-ath10k-read-qcom-coexist-support-as-a-u32.patch new file mode 100644 index 00000000000..891973f38db --- /dev/null +++ b/package/kernel/ath10k-ct/patches/130-ath10k-read-qcom-coexist-support-as-a-u32.patch @@ -0,0 +1,60 @@ +From 630df9786fdaeb78c21f1e28c9b70ac83a1b482c Mon Sep 17 00:00:00 2001 +From: Vincent Tremblay <vincent@vtremblay.dev> +Date: Sat, 31 Dec 2022 09:24:00 -0500 +Subject: [PATCH] ath10k: read qcom,coexist-support as a u32 + +Read qcom,coexist-support as a u32 instead of a u8 + +When we set the property to <1> in the DT (as specified in the doc), +"of_property_read_u8" read 0 instead of 1. This is because of the data format. + +By default <1> is written with 32 bits. +The problem is that the driver is trying to read a u8. + +The difference can be visualized using hexdump in a running device: +Default 32 bits output: +======================= +0000000 0000 0100 +0000004 + +8 bits output: +============== +0000000 0001 +0000001 + +By changing "of_property_read_u8" by "of_property_read_u32", the driver +is aligned with the documentation and is able to read the value without +modifying the DT. + +The other solution would be to force the value in the DT to be saved as +an 8 bits value (qcom,coexist-support = /bits/ 8 <1>), +which is against the doc and less intuitive. + +Validation: +=========== +The patch was tested on a real device and we can see in the debug logs +that the feature is properly initialized: + +[ 109.102097] ath10k_ahb a000000.wifi: boot coex_support 1 coex_gpio_pin 52 + +Signed-off-by: Vincent Tremblay <vincent@vtremblay.dev> + +--- a/ath10k-6.4/core.c ++++ b/ath10k-6.4/core.c +@@ -2869,14 +2869,14 @@ done: + static void ath10k_core_fetch_btcoex_dt(struct ath10k *ar) + { + struct device_node *node; +- u8 coex_support = 0; ++ u32 coex_support = 0; + int ret; + + node = ar->dev->of_node; + if (!node) + goto out; + +- ret = of_property_read_u8(node, "qcom,coexist-support", &coex_support); ++ ret = of_property_read_u32(node, "qcom,coexist-support", &coex_support); + if (ret) { + ar->coex_support = true; + goto out; diff --git a/package/kernel/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch b/package/kernel/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch index 691b504c0f6..8eb587b877b 100644 --- a/package/kernel/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch +++ b/package/kernel/ath10k-ct/patches/201-ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets.patch @@ -66,25 +66,25 @@ v13: * cleanup includes - ath10k-5.10/Kconfig | 10 +++ - ath10k-5.10/Makefile | 1 + - ath10k-5.10/core.c | 22 +++++++ - ath10k-5.10/core.h | 9 ++- - ath10k-5.10/hw.h | 1 + - ath10k-5.10/leds.c | 103 ++++++++++++++++++++++++++++++ - ath10k-5.10/leds.h | 45 +++++++++++++ - ath10k-5.10/mac.c | 1 + - ath10k-5.10/wmi-ops.h | 32 ++++++++++ - ath10k-5.10/wmi-tlv.c | 2 + - ath10k-5.10/wmi.c | 54 ++++++++++++++++ - ath10k-5.10/wmi.h | 35 ++++++++++ + ath10k-6.4/Kconfig | 10 +++ + ath10k-6.4/Makefile | 1 + + ath10k-6.4/core.c | 22 +++++++ + ath10k-6.4/core.h | 9 ++- + ath10k-6.4/hw.h | 1 + + ath10k-6.4/leds.c | 103 ++++++++++++++++++++++++++++++ + ath10k-6.4/leds.h | 45 +++++++++++++ + ath10k-6.4/mac.c | 1 + + ath10k-6.4/wmi-ops.h | 32 ++++++++++ + ath10k-6.4/wmi-tlv.c | 2 + + ath10k-6.4/wmi.c | 54 ++++++++++++++++ + ath10k-6.4/wmi.h | 35 ++++++++++ 12 files changed, 314 insertions(+), 1 deletion(-) - create mode 100644 ath10k-5.10/leds.c - create mode 100644 ath10k-5.10/leds.h + create mode 100644 ath10k-6.4/leds.c + create mode 100644 ath10k-6.4/leds.h ---- a/ath10k-5.10/Kconfig -+++ b/ath10k-5.10/Kconfig -@@ -65,6 +65,16 @@ config ATH10K_DEBUGFS +--- a/ath10k-6.4/Kconfig ++++ b/ath10k-6.4/Kconfig +@@ -67,6 +67,16 @@ config ATH10K_DEBUGFS If unsure, say Y to make it easier to debug problems. @@ -101,8 +101,8 @@ v13: config ATH10K_SPECTRAL bool "Atheros ath10k spectral scan support" depends on ATH10K_DEBUGFS ---- a/ath10k-5.10/Makefile -+++ b/ath10k-5.10/Makefile +--- a/ath10k-6.4/Makefile ++++ b/ath10k-6.4/Makefile @@ -20,6 +20,7 @@ ath10k_core-$(CONFIG_ATH10K_SPECTRAL) += ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o @@ -111,9 +111,9 @@ v13: ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o ath10k_core-$(CONFIG_PM) += wow.o ath10k_core-$(CONFIG_ATH10K_CE) += ce.o ---- a/ath10k-5.10/core.c -+++ b/ath10k-5.10/core.c -@@ -26,6 +26,7 @@ +--- a/ath10k-6.4/core.c ++++ b/ath10k-6.4/core.c +@@ -28,6 +28,7 @@ #include "testmode.h" #include "wmi-ops.h" #include "coredump.h" @@ -121,7 +121,7 @@ v13: /* Disable ath10k-ct DBGLOG output by default */ unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG; -@@ -68,6 +69,7 @@ static const struct ath10k_hw_params ath +@@ -78,6 +79,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA988X_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca988x hw2.0", @@ -129,7 +129,7 @@ v13: .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 +@@ -159,6 +161,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9887_1_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9887 hw1.0", @@ -137,7 +137,7 @@ v13: .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, -@@ -342,6 +345,7 @@ static const struct ath10k_hw_params ath +@@ -400,6 +403,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA99X0_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca99x0 hw2.0", @@ -145,7 +145,7 @@ v13: .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .otp_exe_param = 0x00000700, -@@ -382,6 +386,7 @@ static const struct ath10k_hw_params ath +@@ -446,6 +450,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9984_1_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9984/qca9994 hw1.0", @@ -153,7 +153,7 @@ v13: .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 +@@ -499,6 +504,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9888_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9888 hw2.0", @@ -161,7 +161,7 @@ v13: .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, -@@ -3705,6 +3711,10 @@ int ath10k_core_start(struct ath10k *ar, +@@ -4080,6 +4086,10 @@ int ath10k_core_start(struct ath10k *ar, ath10k_wmi_check_apply_board_power_ctl_table(ar); } @@ -172,7 +172,7 @@ v13: return 0; err_hif_stop: -@@ -3963,9 +3973,18 @@ static void ath10k_core_register_work(st +@@ -4341,9 +4351,18 @@ static void ath10k_core_register_work(st goto err_spectral_destroy; } @@ -191,7 +191,7 @@ v13: err_spectral_destroy: ath10k_spectral_destroy(ar); err_debug_destroy: -@@ -4025,6 +4044,8 @@ void ath10k_core_unregister(struct ath10 +@@ -4403,6 +4422,8 @@ void ath10k_core_unregister(struct ath10 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags)) return; @@ -200,8 +200,8 @@ v13: 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.10/core.h -+++ b/ath10k-5.10/core.h +--- a/ath10k-6.4/core.h ++++ b/ath10k-6.4/core.h @@ -14,6 +14,7 @@ #include <linux/pci.h> #include <linux/uuid.h> @@ -210,7 +210,7 @@ v13: #include "htt.h" #include "htc.h" -@@ -1557,6 +1558,13 @@ struct ath10k { +@@ -1586,6 +1587,13 @@ struct ath10k { } testmode; struct { @@ -224,9 +224,9 @@ v13: /* protected by data_lock */ u32 rx_crc_err_drop; u32 fw_crash_counter; ---- a/ath10k-5.10/hw.h -+++ b/ath10k-5.10/hw.h -@@ -521,6 +521,7 @@ struct ath10k_hw_params { +--- a/ath10k-6.4/hw.h ++++ b/ath10k-6.4/hw.h +@@ -523,6 +523,7 @@ struct ath10k_hw_params { const char *name; u32 patch_load_addr; int uart_pin; @@ -235,7 +235,7 @@ v13: /* Type of hw cycle counter wraparound logic, for more info --- /dev/null -+++ b/ath10k-5.10/leds.c ++++ b/ath10k-6.4/leds.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2005-2011 Atheros Communications Inc. @@ -341,7 +341,7 @@ v13: +} + --- /dev/null -+++ b/ath10k-5.10/leds.h ++++ b/ath10k-6.4/leds.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018, The Linux Foundation. All rights reserved. @@ -384,8 +384,8 @@ v13: + +#endif +#endif /* _LEDS_H_ */ ---- a/ath10k-5.10/mac.c -+++ b/ath10k-5.10/mac.c +--- a/ath10k-6.4/mac.c ++++ b/ath10k-6.4/mac.c @@ -25,6 +25,7 @@ #include "wmi-tlv.h" #include "wmi-ops.h" @@ -394,8 +394,8 @@ v13: /*********/ /* Rates */ ---- a/ath10k-5.10/wmi-ops.h -+++ b/ath10k-5.10/wmi-ops.h +--- a/ath10k-6.4/wmi-ops.h ++++ b/ath10k-6.4/wmi-ops.h @@ -228,7 +228,10 @@ struct wmi_ops { const struct wmi_bb_timing_cfg_arg *arg); struct sk_buff *(*gen_per_peer_per_tid_cfg)(struct ath10k *ar, @@ -443,9 +443,9 @@ v13: static inline int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level) { ---- a/ath10k-5.10/wmi-tlv.c -+++ b/ath10k-5.10/wmi-tlv.c -@@ -4594,6 +4594,8 @@ static const struct wmi_ops wmi_tlv_ops +--- a/ath10k-6.4/wmi-tlv.c ++++ b/ath10k-6.4/wmi-tlv.c +@@ -4601,6 +4601,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, @@ -454,9 +454,9 @@ v13: }; static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = { ---- a/ath10k-5.10/wmi.c -+++ b/ath10k-5.10/wmi.c -@@ -8409,6 +8409,49 @@ ath10k_wmi_op_gen_peer_set_param(struct +--- a/ath10k-6.4/wmi.c ++++ b/ath10k-6.4/wmi.c +@@ -8438,6 +8438,49 @@ ath10k_wmi_op_gen_peer_set_param(struct return skb; } @@ -506,7 +506,7 @@ v13: static struct sk_buff * ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id, enum wmi_sta_ps_mode psmode) -@@ -10238,6 +10281,9 @@ static const struct wmi_ops wmi_ops = { +@@ -10269,6 +10312,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, @@ -516,7 +516,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -10308,6 +10354,8 @@ static const struct wmi_ops wmi_10_1_ops +@@ -10339,6 +10385,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, @@ -525,7 +525,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -10387,6 +10435,8 @@ static const struct wmi_ops wmi_10_2_ops +@@ -10418,6 +10466,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, @@ -534,7 +534,7 @@ v13: /* .gen_pdev_enable_adaptive_cca not implemented */ }; -@@ -10458,6 +10508,8 @@ static const struct wmi_ops wmi_10_2_4_o +@@ -10489,6 +10539,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, @@ -543,7 +543,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -10540,6 +10592,8 @@ static const struct wmi_ops wmi_10_4_ops +@@ -10571,6 +10623,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, @@ -552,8 +552,8 @@ v13: }; int ath10k_wmi_attach(struct ath10k *ar) ---- a/ath10k-5.10/wmi.h -+++ b/ath10k-5.10/wmi.h +--- a/ath10k-6.4/wmi.h ++++ b/ath10k-6.4/wmi.h @@ -3133,6 +3133,41 @@ enum wmi_10_4_feature_mask { }; diff --git a/package/kernel/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch b/package/kernel/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch index 6205c9b6614..4f9cf83c488 100644 --- a/package/kernel/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch +++ b/package/kernel/ath10k-ct/patches/202-ath10k-use-tpt-trigger-by-default.patch @@ -9,14 +9,14 @@ traffic. Signed-off-by: Mathias Kresin <dev@kresin.me> --- - ath10k-5.10/core.h | 4 ++++ - ath10k-5.10/leds.c | 4 +--- - ath10k-5.10/mac.c | 2 +- + ath10k-6.4/core.h | 4 ++++ + ath10k-6.4/leds.c | 4 +--- + ath10k-6.4/mac.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) ---- a/ath10k-5.10/core.h -+++ b/ath10k-5.10/core.h -@@ -1665,6 +1665,10 @@ struct ath10k { +--- a/ath10k-6.4/core.h ++++ b/ath10k-6.4/core.h +@@ -1701,6 +1701,10 @@ struct ath10k { u8 csi_data[4096]; u16 csi_data_len; @@ -27,8 +27,8 @@ Signed-off-by: Mathias Kresin <dev@kresin.me> /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; ---- a/ath10k-5.10/leds.c -+++ b/ath10k-5.10/leds.c +--- a/ath10k-6.4/leds.c ++++ b/ath10k-6.4/leds.c @@ -81,9 +81,7 @@ int ath10k_leds_register(struct ath10k * ar->leds.cdev.name = ar->leds.label; @@ -40,9 +40,9 @@ Signed-off-by: Mathias Kresin <dev@kresin.me> ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev); if (ret) ---- a/ath10k-5.10/mac.c -+++ b/ath10k-5.10/mac.c -@@ -11403,7 +11403,7 @@ int ath10k_mac_register(struct ath10k *a +--- a/ath10k-6.4/mac.c ++++ b/ath10k-6.4/mac.c +@@ -11616,7 +11616,7 @@ int ath10k_mac_register(struct ath10k *a ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; #ifdef CPTCFG_MAC80211_LEDS diff --git a/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch b/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch deleted file mode 100644 index b5c53baf67e..00000000000 --- a/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 22fb5991a44c78ff18ec0082dc90c809356eb893 Mon Sep 17 00:00:00 2001 -From: Ansuel Smith <ansuelsmth@gmail.com> -Date: Sun, 27 Sep 2020 19:23:35 +0200 -Subject: [PATCH 1/2] ath10k: Try to get mac-address from dts - -Most of embedded device that have the ath10k wifi integrated store the -mac-address in nvmem partitions. Try to fetch the mac-address using the -standard 'of_get_mac_address' than in all the check also try to fetch the -address using the nvmem api searching for a defined 'mac-address' cell. -Mac-address defined in the dts have priority than any other address found. - -Tested-on: QCA9984 hw1.0 PCI 10.4 - -Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> ---- - ath10k-5.10/core.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/ath10k-5.10/core.c b/ath10k-5.10/core.c -index 5f4e12196..9ed7b9883 100644 ---- a/ath10k-5.10/core.c -+++ b/ath10k-5.10/core.c -@@ -8,6 +8,9 @@ - #include <linux/module.h> - #include <linux/firmware.h> - #include <linux/of.h> -+#include <linux/of_net.h> -+#include <linux/of_platform.h> -+#include <linux/property.h> - #include <linux/property.h> - #include <linux/dmi.h> - #include <linux/ctype.h> -@@ -2961,8 +2963,14 @@ EXPORT_SYMBOL(ath10k_core_stop); - static int ath10k_core_probe_fw(struct ath10k *ar) - { - struct bmi_target_info target_info; -+ const char *mac; - int ret = 0; - -+#ifdef CONFIG_OF -+ /* register the platform to be found by the of api */ -+ of_platform_device_create(ar->dev->of_node, NULL, NULL); -+#endif -+ - ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL); - if (ret) { - ath10k_err(ar, "could not power on hif bus (%d)\n", ret); -@@ -3062,6 +3068,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar) - - device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr)); - -+ mac = of_get_mac_address(ar->dev->of_node); -+ if (!IS_ERR(mac)) -+ ether_addr_copy(ar->mac_addr, mac); -+ - ret = ath10k_core_init_firmware_features(ar); - if (ret) { - ath10k_err(ar, "fatal problem with firmware features: %d\n", --- -2.27.0 - diff --git a/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch index af9c3d455b5..b0e6ef76fa4 100644 --- a/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch +++ b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch @@ -1,5 +1,5 @@ ---- a/ath10k-5.10/htt.h -+++ b/ath10k-5.10/htt.h +--- a/ath10k-6.4/htt.h ++++ b/ath10k-6.4/htt.h @@ -237,7 +237,11 @@ enum htt_rx_ring_flags { }; diff --git a/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch index 1fc2566f9c8..82109995d99 100644 --- a/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch +++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch @@ -1,5 +1,5 @@ ---- a/ath10k-5.10/pci.c -+++ b/ath10k-5.10/pci.c +--- a/ath10k-6.4/pci.c ++++ b/ath10k-6.4/pci.c @@ -131,7 +131,11 @@ static const struct ce_attr pci_host_ce_ .flags = CE_ATTR_FLAGS, .src_nentries = 0, diff --git a/package/kernel/ath10k-ct/patches/988-ath10k-always-use-mac80211-loss-detection.patch b/package/kernel/ath10k-ct/patches/988-ath10k-always-use-mac80211-loss-detection.patch new file mode 100644 index 00000000000..8aef577debc --- /dev/null +++ b/package/kernel/ath10k-ct/patches/988-ath10k-always-use-mac80211-loss-detection.patch @@ -0,0 +1,28 @@ +From f7d6edafe4358e3880a26775cfde4cd5c71ba063 Mon Sep 17 00:00:00 2001 +From: David Bauer <mail@david-bauer.net> +Date: Wed, 5 Jul 2023 01:30:29 +0200 +Subject: [PATCH] ath10k: always use mac80211 loss detection + +ath10k does not report excessive loss in case of broken block-ack +sessions. The loss is communicated to the host-os, but ath10k does not +trigger a low-ack events by itself. + +The mac80211 framework for loss detection however detects this +circumstance well in case of ath10k. So use it regardless of ath10k's +own loss detection mechanism. + +Signed-off-by: David Bauer <mail@david-bauer.net> +--- + ath10k-6.4/mac.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/ath10k-6.4/mac.c ++++ b/ath10k-6.4/mac.c +@@ -11305,7 +11305,6 @@ int ath10k_mac_register(struct ath10k *a + ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA); + ieee80211_hw_set(ar->hw, QUEUE_CONTROL); + ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG); +- ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK); + + if (!test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) + ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL); diff --git a/package/kernel/bcm27xx-gpu-fw/Makefile b/package/kernel/bcm27xx-gpu-fw/Makefile index d34a48d11d6..048dd0d3a9d 100644 --- a/package/kernel/bcm27xx-gpu-fw/Makefile +++ b/package/kernel/bcm27xx-gpu-fw/Makefile @@ -2,8 +2,8 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=bcm27xx-gpu-fw -PKG_VERSION:=2021-02-16 -PKG_RELEASE:=ba6259246c702b04ea56ff1034325e476d460ae8 +PKG_VERSION:=2024-01-11 +PKG_RELEASE:=0968de28716a9b1f106b8492646d0ed0a2800152 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)/rpi-firmware-$(PKG_RELEASE) @@ -26,7 +26,7 @@ define Download/bootcode_bin FILE:=$(RPI_FIRMWARE_FILE)-bootcode.bin URL:=$(RPI_FIRMWARE_URL) URL_FILE:=bootcode.bin - HASH:=92fd15eb2468187b69d15a9482d7e8cee3704993c53bb5ba55afe550723c5975 + HASH:=af603ebd97e7b692c30195563f7b25656eb05d57838cf1a715ebb470d1614ce4 endef $(eval $(call Download,bootcode_bin)) @@ -34,7 +34,7 @@ define Download/fixup_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup.dat - HASH:=3daaf175decee44347fb97ece7738edf230b6fe3a86a8f521652e0052d5b3d6a + HASH:=c28ea955e672e374016dca61d63afa026490f0473a98115908586ab48e324aeb endef $(eval $(call Download,fixup_dat)) @@ -42,7 +42,7 @@ define Download/fixup_cd_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup_cd.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup_cd.dat - HASH:=399b10509877cc7cbbaae25757ff44ee9f666931dd5c0996b48d170735a668b0 + HASH:=3cf1aef5f596ca106203ed5dac9ad45e85929ec55ce44c813588645e174442ec endef $(eval $(call Download,fixup_cd_dat)) @@ -50,7 +50,7 @@ define Download/fixup_x_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup_x.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup_x.dat - HASH:=3c2a71f349bbc97bc3d9f7592bdd3f06d3d67e1ccd581cbdbb91b67a16304d76 + HASH:=56525c8feabde1ab86f36bb09bc55171659b2993f94132cf81ffc4293d62269d endef $(eval $(call Download,fixup_x_dat)) @@ -58,7 +58,7 @@ define Download/fixup4_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4.dat - HASH:=68e9112ac7907af51cbf7f458d241e6136af1be4e968909e34cbffb70f9536b4 + HASH:=615f8595801bf52373039f73ad5ad9513f83400d355eb1b2c075c7ae907e927c endef $(eval $(call Download,fixup4_dat)) @@ -66,7 +66,7 @@ define Download/fixup4cd_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4cd.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4cd.dat - HASH:=399b10509877cc7cbbaae25757ff44ee9f666931dd5c0996b48d170735a668b0 + HASH:=3cf1aef5f596ca106203ed5dac9ad45e85929ec55ce44c813588645e174442ec endef $(eval $(call Download,fixup4cd_dat)) @@ -74,7 +74,7 @@ define Download/fixup4x_dat FILE:=$(RPI_FIRMWARE_FILE)-fixup4x.dat URL:=$(RPI_FIRMWARE_URL) URL_FILE:=fixup4x.dat - HASH:=62c0ff21c06a28c24fc537bd1d23625b3452170fbb9fbd950b67a393929c2768 + HASH:=6d27a4b8ecb78cef9e1f03751b4aaec5ce8749d36988f381145a8a41dbf164ae endef $(eval $(call Download,fixup4x_dat)) @@ -82,7 +82,7 @@ define Download/start_elf FILE:=$(RPI_FIRMWARE_FILE)-start.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start.elf - HASH:=3cc30fc07a6ad99bdd14e6319ed84b6c8813e8cb08bc5fff488c33abb163f746 + HASH:=e8348e88522e7a1d0e2b0944ab66d7d8f4f30da98f326e2b3c123522e45f71b2 endef $(eval $(call Download,start_elf)) @@ -90,7 +90,7 @@ define Download/start_cd_elf FILE:=$(RPI_FIRMWARE_FILE)-start_cd.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start_cd.elf - HASH:=a4ae5a07b036bd82136373f2ce8a9ad01e41938884568b57c53e4be4c08d0dda + HASH:=c9b4de3f12bec7808868b898c49f656b5378ddc315f12ccab83d6519bad51680 endef $(eval $(call Download,start_cd_elf)) @@ -98,7 +98,7 @@ define Download/start_x_elf FILE:=$(RPI_FIRMWARE_FILE)-start_x.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start_x.elf - HASH:=b566fc8bc4cd1699f40fc73aa72910915421764933f2f2a7ba517b6b14339d09 + HASH:=0b5c06c109984361eeed0ab14d146f686d8aa8da2025689b887e9cb098636db9 endef $(eval $(call Download,start_x_elf)) @@ -106,7 +106,7 @@ define Download/start4_elf FILE:=$(RPI_FIRMWARE_FILE)-start4.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4.elf - HASH:=abafb4d39c2708389e1421443fdd5e8a86e03bef6ad5282c0b5836587860cc5c + HASH:=fedc4ecd72c9d21018e210240dcd2e41a8bb5f936fb5674c3351f2a447a22203 endef $(eval $(call Download,start4_elf)) @@ -114,7 +114,7 @@ define Download/start4cd_elf FILE:=$(RPI_FIRMWARE_FILE)-start4cd.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4cd.elf - HASH:=6df423f4fa82c58efef6db1cf20c4fcbd92465a7fe91f40548c8534c1b5ef7fd + HASH:=ea22282a77666801378137a651e7e0b17cc186f63cdbdc8b9bb98749cd12b256 endef $(eval $(call Download,start4cd_elf)) @@ -122,7 +122,7 @@ define Download/start4x_elf FILE:=$(RPI_FIRMWARE_FILE)-start4x.elf URL:=$(RPI_FIRMWARE_URL) URL_FILE:=start4x.elf - HASH:=4060e9fedfa99ff91549c8f4324a18417db785d99054ac7fe7d1b5dd5ef232f1 + HASH:=c509e73a9cba7af3223dea885f58294bd04845e822aa3d6278500fa4dcdb112f endef $(eval $(call Download,start4x_elf)) diff --git a/package/kernel/bpf-headers/Makefile b/package/kernel/bpf-headers/Makefile new file mode 100644 index 00000000000..5efd2e1cf0f --- /dev/null +++ b/package/kernel/bpf-headers/Makefile @@ -0,0 +1,113 @@ +# +# Copyright (C) 2006-2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +override QUILT:= +override HOST_QUILT:= + +include $(INCLUDE_DIR)/kernel.mk + + +PKG_NAME:=linux +PKG_PATCHVER:=5.15 +# Manually include kernel version and hash from kernel details file +include $(INCLUDE_DIR)/kernel-$(PKG_PATCHVER) + +PKG_VERSION:=$(PKG_PATCHVER)$(strip $(LINUX_VERSION-$(PKG_PATCHVER))) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/kernel/v$(word 1,$(subst ., ,$(PKG_PATCHVER))).x +PKG_HASH:=$(LINUX_KERNEL_HASH-$(strip $(PKG_VERSION))) +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/bpf-headers/$(PKG_NAME)-$(PKG_VERSION) + +GENERIC_PLATFORM_DIR := $(CURDIR)/../../../target/linux/generic +GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) +GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) +GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) +GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(PKG_PATCHVER)),"$(dir)") +PATCH_DIR := $(CURDIR)/patches +FILES_DIR := + +REAL_LINUX_DIR := $(LINUX_DIR) +LINUX_DIR := $(PKG_BUILD_DIR) + +include $(INCLUDE_DIR)/bpf.mk +include $(INCLUDE_DIR)/package.mk + +define Package/bpf-headers + SECTION:=kernel + CATEGORY:=Kernel modules + TITLE:=eBPF kernel headers + BUILDONLY:=1 + HIDDEN:=1 +endef + +PKG_CONFIG_PATH:= + +export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include + +KERNEL_MAKE := \ + $(MAKE) -C $(PKG_BUILD_DIR) \ + ARCH=$(BPF_KARCH) \ + CROSS_COMPILE=$(BPF_ARCH)-linux- \ + LLVM=1 CC="$(CLANG)" LD="$(TARGET_CROSS)ld" \ + HOSTCC="$(HOSTCC)" \ + HOSTCXX="$(HOSTCXX)" \ + KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \ + CONFIG_SHELL="$(BASH)" \ + INSTALL_HDR_PATH="$(PKG_BUILD_DIR)/user_headers" + +define Build/Patch + $(Kernel/Patch/Default) +endef + +BPF_DOC = $(PKG_BUILD_DIR)/scripts/bpf_doc.py + +define Build/Configure/64 + echo 'CONFIG_CPU_MIPS64_R2=y' >> $(PKG_BUILD_DIR)/.config + echo 'CONFIG_64BIT=y' >> $(PKG_BUILD_DIR)/.config +endef + +define Build/Configure + grep -vE 'CONFIG_(CPU_.*ENDIAN|HZ)' $(PKG_BUILD_DIR)/arch/mips/configs/generic_defconfig > $(PKG_BUILD_DIR)/.config + echo 'CONFIG_CPU_$(if $(CONFIG_BIG_ENDIAN),BIG,LITTLE)_ENDIAN=y' >> $(PKG_BUILD_DIR)/.config + $(if $(CONFIG_ARCH_64BIT),$(Build/Configure/64)) + grep CONFIG_HZ $(REAL_LINUX_DIR)/.config >> $(PKG_BUILD_DIR)/.config + yes '' | $(KERNEL_MAKE) oldconfig + grep 'CONFIG_HZ=' $(REAL_LINUX_DIR)/.config | \ + cut -d= -f2 | \ + bc -q $(LINUX_DIR)/kernel/time/timeconst.bc \ + > $(LINUX_DIR)/include/generated/timeconst.h + $(BPF_DOC) --header \ + --file $(LINUX_DIR)/tools/include/uapi/linux/bpf.h \ + > $(PKG_BUILD_DIR)/tools/lib/bpf/bpf_helper_defs.h +endef + +define Build/Compile + $(KERNEL_MAKE) archprepare headers_install +endef + +define Build/InstallDev + mkdir -p $(1)/bpf-headers/arch $(1)/bpf-headers/tools + $(CP) \ + $(PKG_BUILD_DIR)/arch/$(BPF_KARCH) \ + $(1)/bpf-headers/arch/ + $(CP) \ + $(PKG_BUILD_DIR)/tools/lib \ + $(PKG_BUILD_DIR)/tools/testing \ + $(1)/bpf-headers/tools/ + $(CP) \ + $(PKG_BUILD_DIR)/include \ + $(PKG_BUILD_DIR)/samples \ + $(PKG_BUILD_DIR)/scripts \ + $(PKG_BUILD_DIR)/user_headers \ + $(1)/bpf-headers + $(CP) \ + $(CURDIR)/files/stdarg.h \ + $(1)/bpf-headers/include +endef + +$(eval $(call BuildPackage,bpf-headers)) diff --git a/package/kernel/bpf-headers/files/stdarg.h b/package/kernel/bpf-headers/files/stdarg.h new file mode 100644 index 00000000000..603057f6e75 --- /dev/null +++ b/package/kernel/bpf-headers/files/stdarg.h @@ -0,0 +1,19 @@ +#ifndef _STDARG_H +#define _STDARG_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef __builtin_va_list va_list; + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_copy(d,s) __builtin_va_copy(d,s) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/package/kernel/bpf-headers/patches/100-support_hz_300.patch b/package/kernel/bpf-headers/patches/100-support_hz_300.patch new file mode 100644 index 00000000000..9629958598e --- /dev/null +++ b/package/kernel/bpf-headers/patches/100-support_hz_300.patch @@ -0,0 +1,20 @@ +--- a/arch/mips/Kconfig ++++ b/arch/mips/Kconfig +@@ -2988,6 +2988,9 @@ choice + config HZ_256 + bool "256 HZ" if SYS_SUPPORTS_256HZ || SYS_SUPPORTS_ARBIT_HZ + ++ config HZ_300 ++ bool "300 HZ" if SYS_SUPPORTS_ARBIT_HZ ++ + config HZ_1000 + bool "1000 HZ" if SYS_SUPPORTS_1000HZ || SYS_SUPPORTS_ARBIT_HZ + +@@ -3039,6 +3042,7 @@ config HZ + default 128 if HZ_128 + default 250 if HZ_250 + default 256 if HZ_256 ++ default 300 if HZ_300 + default 1000 if HZ_1000 + default 1024 if HZ_1024 + diff --git a/package/kernel/bpf-headers/src/include/generated/bounds.h b/package/kernel/bpf-headers/src/include/generated/bounds.h new file mode 100644 index 00000000000..82ff01043c7 --- /dev/null +++ b/package/kernel/bpf-headers/src/include/generated/bounds.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_BOUNDS_H__ +#define __LINUX_BOUNDS_H__ +/* + * DO NOT MODIFY. + * + * This file was generated by Kbuild + */ + +#define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS */ +#define MAX_NR_ZONES 4 /* __MAX_NR_ZONES */ +#define NR_CPUS_BITS 1 /* ilog2(CONFIG_NR_CPUS) */ +#define SPINLOCK_SIZE 64 /* sizeof(spinlock_t) */ + +#endif diff --git a/package/kernel/broadcom-wl/Makefile b/package/kernel/broadcom-wl/Makefile deleted file mode 100644 index 7188c4900ea..00000000000 --- a/package/kernel/broadcom-wl/Makefile +++ /dev/null @@ -1,184 +0,0 @@ -# -# Copyright (C) 2006-2014 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:=broadcom-wl -PKG_VERSION:=5.10.56.27.3 -PKG_RELEASE:=10 - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2 -PKG_SOURCE_URL:=@OPENWRT - -ifeq ($(ARCH),mipsel) -PKG_HASH:=26a8c370f48fc129d0731cfd751c36cae1419b0bc8ca35781126744e60eae009 -endif -ifeq ($(ARCH),mips) -PKG_HASH:=ca6a86ca3e3e9c85b6dbb665b35bcbf338c37829c1b2f1994487d55664886045 -endif - -PKG_EXTMOD_SUBDIRS:=driver driver-mini glue - -PKG_USE_MIPS16:=0 -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/broadcom-wl/Default - SECTION:=kernel - CATEGORY:=Kernel modules - DEPENDS:=@(PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini) - SUBMENU:=Proprietary BCM43xx WiFi driver - SUBMENUDEP:=(TARGET_bcm47xx||TARGET_bcm63xx) -endef - -define KernelPackage/brcm-wl/Default - $(call Package/broadcom-wl/Default) - SECTION:=kernel - DEPENDS:=@(TARGET_bcm47xx||TARGET_bcm63xx) +wireless-tools - TITLE:=Kernel driver for BCM43xx chipsets - FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko - AUTOLOAD:=$(call AutoProbe,wl) -endef - -define KernelPackage/brcm-wl/Default/description - This package contains the proprietary wireless driver for the Broadcom - BCM43xx chipset. -endef - -define KernelPackage/brcm-wl -$(call KernelPackage/brcm-wl/Default,) - TITLE+= (normal version) -endef - -define KernelPackage/brcm-wl/description -$(call KernelPackage/brcm-wl/Default/description) -endef - -define KernelPackage/brcm-wl-mini -$(call KernelPackage/brcm-wl/Default,-mini) - TITLE+= (Legacy version) -endef - -define KernelPackage/brcm-wl-mini/description -$(call KernelPackage/brcm-wl/Default/description) -endef - -define Package/wlc -$(call Package/broadcom-wl/Default) - TITLE:=wl driver setup utility -endef - -define Package/wlc/description - This package contains an utility for initializing the proprietary Broadcom - wl driver. -endef - -define Package/wl -$(call Package/broadcom-wl/Default) - TITLE:=Proprietary Broadcom wl driver config utility -endef - -define Package/wl/description - This package contains the proprietary utility (wl) for configuring the - proprietary Broadcom wl driver. -endef - -define Package/nas -$(call Package/broadcom-wl/Default) - TITLE:=Proprietary Broadcom WPA/WPA2 authenticator -endef - -define Package/nas/description - This package contains the proprietary WPA/WPA2 authenticator (nas) for the - proprietary Broadcom wl driver. -endef - -MAKE_KMOD := $(MAKE) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ - PATH="$(TARGET_PATH)" \ - M="$(PKG_BUILD_DIR)/kmod" \ - -define Build/Prepare - $(call Build/Prepare/Default) - $(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini - $(CP) ./src/glue $(PKG_BUILD_DIR)/glue -endef - -define Build/Compile - # Compile glue driver - $(MAKE_KMOD) -C "$(LINUX_DIR)" \ - M="$(PKG_BUILD_DIR)/glue" \ - modules - - # Compile the kernel part - $(MAKE_KMOD) \ - M="$(PKG_BUILD_DIR)/driver" \ - MODFLAGS="-DMODULE -mlong-calls" \ - KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \ - modules - - $(MAKE_KMOD) \ - M="$(PKG_BUILD_DIR)/driver-mini" \ - MODFLAGS="-DMODULE -mlong-calls" \ - BUILD_TYPE="wl_apsta_mini" \ - KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \ - modules - - # Compile libshared - $(MAKE) -C $(PKG_BUILD_DIR)/shared \ - $(TARGET_CONFIGURE_OPTS) \ - CFLAGS="$(TARGET_CFLAGS) -I. -I$(PKG_BUILD_DIR)/driver/include" \ - all - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/wlc \ - -I$(PKG_BUILD_DIR)/shared -I$(PKG_BUILD_DIR)/driver/include \ - ./src/wlc.c $(PKG_BUILD_DIR)/shared/libshared.a - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/nas \ - $(PKG_BUILD_DIR)/nas_exe.o \ - $(PKG_BUILD_DIR)/shared/libshared.a - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/wl \ - $(PKG_BUILD_DIR)/wl_exe.o \ - $(PKG_BUILD_DIR)/shared/libshared.a -endef - -define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_BUILD_DIR)/shared/libshared.a $(1)/usr/lib/ -endef - -define Package/wlc/install - $(CP) ./files/* $(1)/ - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/wlc $(1)/sbin/ -endef - -define Package/wlc/postinst -#!/bin/sh -[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/wlunbind enable || true -endef - -define Package/wl/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/ -endef - -define Package/nas/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/ - $(LN) nas $(1)/usr/sbin/nas4not - $(LN) nas $(1)/usr/sbin/nas4wds -endef - -$(eval $(call KernelPackage,brcm-wl)) -$(eval $(call KernelPackage,brcm-wl-mini)) -$(eval $(call BuildPackage,wlc)) -$(eval $(call BuildPackage,wl)) -$(eval $(call BuildPackage,nas)) diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect deleted file mode 100644 index a63d6bce60f..00000000000 --- a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -[ "${ACTION}" = "add" ] && [ "${INTERFACE%%[0-9]}" = "wl" ] && { - /sbin/wifi config -} diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds deleted file mode 100644 index 35c4218e03a..00000000000 --- a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds +++ /dev/null @@ -1,61 +0,0 @@ -include /lib/wifi - -setup_broadcom_wds() { - local iface="$1" - local remote="$(wlc ifname "$iface" wdsmac)" - - [ -z "$remote" ] && return - - config_cb() { - [ -z "$CONFIG_SECTION" ] && return - - config_get type "$CONFIG_SECTION" TYPE - [ "$type" = "wifi-iface" ] || return - - config_get network "$CONFIG_SECTION" network - [ -z "$network" ] && return - - config_get addr "$CONFIG_SECTION" bssid - addr=$(echo "$addr" | tr 'A-F' 'a-f') - [ "$addr" = "$remote" ] && { - local cfg="$CONFIG_SECTION" - - include /lib/network - scan_interfaces - - for network in $network; do - setup_interface "$iface" "$network" - done - - config_get encryption "$cfg" encryption - config_get key "$cfg" key - config_get ssid "$cfg" ssid - - [ "$encryption" != "none" ] && { - sleep 5 - case "$encryption" in - psk|PSK) - nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid" - ;; - psk2|PSK2) - nas4not "$network" "$iface" up auto aes psk "$key" "$ssid" - ;; - psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK) - nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid" - ;; - *) - nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid" - ;; - esac - } - } - } - - config_load wireless -} - -case "$ACTION" in - add|register) - [ "${INTERFACE%%[0-1]-*}" = wds ] && setup_broadcom_wds "$INTERFACE" - ;; -esac diff --git a/package/kernel/broadcom-wl/files/etc/init.d/wlunbind b/package/kernel/broadcom-wl/files/etc/init.d/wlunbind deleted file mode 100755 index 0a29db565fb..00000000000 --- a/package/kernel/broadcom-wl/files/etc/init.d/wlunbind +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2010-2011 OpenWrt.org - -START=09 - -unbind_driver() { - local driver="$1" - local sysfs="/sys/bus/pci/drivers/$driver" - if [ -d "$sysfs" ]; then - local lnk - for lnk in $sysfs/*; do - [ -h "$lnk" ] || continue - case "${lnk##*/}" in - *:*:*.*) - logger "Unbinding WL PCI device ${lnk##*/} from $driver" - echo -n "${lnk##*/}" > "$sysfs/unbind" - ;; - esac - done - fi -} - -boot() { - unbind_driver b43-pci-bridge - unbind_driver bcma-pci-bridge -} - -start() { :; } -stop() { :; } diff --git a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh deleted file mode 100644 index 352c365f275..00000000000 --- a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh +++ /dev/null @@ -1,480 +0,0 @@ -append DRIVERS "broadcom" - -scan_broadcom() { - local device="$1" - local vif vifs wds - local adhoc sta apmode mon disabled - local adhoc_if sta_if ap_if mon_if - - config_get vifs "$device" vifs - for vif in $vifs; do - config_get_bool disabled "$vif" disabled 0 - [ $disabled -eq 0 ] || continue - - local mode - config_get mode "$vif" mode - case "$mode" in - adhoc) - adhoc=1 - adhoc_if="$vif" - ;; - sta) - sta=1 - sta_if="$vif" - ;; - ap) - apmode=1 - ap_if="${ap_if:+$ap_if }$vif" - ;; - wds) - local addr - config_get addr "$vif" bssid - [ -z "$addr" ] || { - addr=$(echo "$addr" | tr 'A-F' 'a-f') - append wds "$addr" - } - ;; - monitor) - mon=1 - mon_if="$vif" - ;; - *) echo "$device($vif): Invalid mode";; - esac - done - config_set "$device" wds "$wds" - - local _c= - for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do - config_set "$vif" ifname "${device}${_c:+-$_c}" - _c=$((${_c:-0} + 1)) - done - config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}" - - ap=1 - infra=1 - if [ "$_c" -gt 1 ]; then - mssid=1 - else - mssid= - fi - apsta=0 - radio=1 - monitor=0 - case "$adhoc:$sta:$apmode:$mon" in - 1*) - ap=0 - mssid= - infra=0 - ;; - :1:1:) - apsta=1 - wet=1 - ;; - :1::) - wet=1 - ap=0 - mssid= - ;; - :::1) - wet=1 - ap=0 - mssid= - monitor=1 - ;; - ::) - radio=0 - ;; - esac -} - -disable_broadcom() { - local device="$1" - set_wifi_down "$device" - ( - include /lib/network - - local pid_file=/var/run/nas.$device.pid - [ -e $pid_file ] && start-stop-daemon -K -q -s SIGKILL -p $pid_file && rm $pid_file - - # make sure the interfaces are down and removed from all bridges - local dev ifname - for dev in /sys/class/net/wds${device##wl}-* /sys/class/net/${device}-* /sys/class/net/${device}; do - if [ -e "$dev" ]; then - ifname=${dev##/sys/class/net/} - ip link set dev "$ifname" down - unbridge "$ifname" - fi - done - - # make sure all of the devices are disabled in the driver - local ifdown= - local bssmax=$(wlc ifname "$device" bssmax) - local vif=$((${bssmax:-4} - 1)) - append ifdown "down" "$N" - append ifdown "wds none" "$N" - while [ $vif -ge 0 ]; do - append ifdown "vif $vif" "$N" - append ifdown "enabled 0" "$N" - vif=$(($vif - 1)) - done - - wlc ifname "$device" stdin <<EOF -$ifdown -leddc 0xffff -EOF - ) - true -} - -enable_broadcom() { - local device="$1" - local channel country maxassoc wds vifs distance slottime rxantenna txantenna - local frameburst macfilter maclist macaddr txpower frag rts hwmode htmode - config_get channel "$device" channel - config_get country "$device" country - config_get maxassoc "$device" maxassoc - config_get wds "$device" wds - config_get vifs "$device" vifs - config_get distance "$device" distance - config_get slottime "$device" slottime - config_get rxantenna "$device" rxantenna - config_get txantenna "$device" txantenna - config_get_bool frameburst "$device" frameburst - config_get macfilter "$device" macfilter - config_get maclist "$device" maclist - config_get macaddr "$device" macaddr $(wlc ifname "$device" default_bssid) - config_get txpower "$device" txpower - config_get frag "$device" frag - config_get rts "$device" rts - config_get hwmode "$device" hwmode - config_get htmode "$device" htmode - local doth=0 - local wmm=1 - - [ -z "$slottime" ] && { - [ -n "$distance" ] && { - # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0) - slottime="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))" - } - } || { - slottime="${slottime:--1}" - } - - case "$macfilter" in - allow|2) - macfilter=2; - ;; - deny|1) - macfilter=1; - ;; - disable|none|0) - macfilter=0; - ;; - esac - - local gmode=2 nmode=0 nreqd= - case "$hwmode" in - *a) gmode=;; - *b) gmode=0;; - *bg) gmode=1;; - *g) gmode=2;; - *gst) gmode=4;; - *lrs) gmode=5;; - *) nmode=1; nreqd=0;; - esac - - case "$hwmode" in - n|11n) nmode=1; nreqd=1;; - *n*) nmode=1; nreqd=0;; - esac - - # Use 'nmode' for N-Phy only - [ "$(wlc ifname "$device" phytype)" = 4 ] || nmode= - - local band chanspec - [ ${channel:-0} -ge 1 -a ${channel:-0} -le 14 ] && band=2 - [ ${channel:-0} -ge 36 ] && { - band=1 - gmode= - } - - # Use 'chanspec' instead of 'channel' for 'N' modes (See bcmwifi.h) - [ -n "$nmode" -a -n "$band" -a -n "$channel" ] && { - case "$htmode" in - HT40) - if [ -n "$gmode" ]; then - [ $channel -lt 7 ] && htmode="HT40+" || htmode="HT40-" - else - [ $(( ($channel / 4) % 2 )) -eq 1 ] && htmode="HT40+" || htmode="HT40-" - fi - ;; - esac - case "$htmode" in - HT40-) chanspec=$(printf 0x%x%x%02x $band 0xe $(($channel - 2))); nmode=1; channel=;; - HT40+) chanspec=$(printf 0x%x%x%02x $band 0xd $(($channel + 2))); nmode=1; channel=;; - HT20) chanspec=$(printf 0x%x%x%02x $band 0xb $channel); nmode=1; channel=;; - *) ;; - esac - } - - local leddc=$(wlc ifname "$device" leddc) - [ $((leddc)) -eq $((0xffff)) ] && { - leddc=0x005a000a; - } - - local _c=0 - local nas="$(command -v nas)" - local if_pre_up if_up nas_cmd - local vif vif_pre_up vif_post_up vif_do_up vif_txpower - local bssmax=$(wlc ifname "$device" bssmax) - bssmax=${bssmax:-4} - - for vif in $vifs; do - [ $_c -ge $bssmax ] && break - - config_get vif_txpower "$vif" txpower - - local mode - config_get mode "$vif" mode - append vif_pre_up "vif $_c" "$N" - append vif_post_up "vif $_c" "$N" - append vif_do_up "vif $_c" "$N" - - config_get_bool wmm "$vif" wmm "$wmm" - config_get_bool doth "$vif" doth "$doth" - - [ "$mode" = "sta" ] || { - local hidden isolate - config_get_bool hidden "$vif" hidden 0 - append vif_pre_up "closed $hidden" "$N" - config_get_bool isolate "$vif" isolate 0 - append vif_pre_up "ap_isolate $isolate" "$N" - } - - local wsec_r=0 - local eap_r=0 - local wsec=0 - local auth=0 - local nasopts= - local enc key rekey - - config_get enc "$vif" encryption - case "$enc" in - *wep*) - local def defkey k knr - wsec_r=1 - wsec=1 - defkey=1 - config_get key "$vif" key - case "$enc" in - *shared*) append vif_do_up "wepauth 1" "$N";; - *) append vif_do_up "wepauth 0" "$N";; - esac - case "$key" in - [1234]) - defkey="$key" - for knr in 1 2 3 4; do - config_get k "$vif" key$knr - [ -n "$k" ] || continue - [ "$defkey" = "$knr" ] && def="=" || def="" - append vif_do_up "wepkey $def$knr,$k" "$N" - done - ;; - "");; - *) append vif_do_up "wepkey =1,$key" "$N";; - esac - ;; - *psk*) - wsec_r=1 - config_get key "$vif" key - - # psk version + default cipher - case "$enc" in - *mixed*|*psk+psk2*) auth=132; wsec=6;; - *psk2*) auth=128; wsec=4;; - *) auth=4; wsec=2;; - esac - - # cipher override - case "$enc" in - *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;; - *aes*|*ccmp*) wsec=4;; - *tkip*) wsec=2;; - esac - - # group rekey interval - config_get rekey "$vif" wpa_group_rekey - - eval "${vif}_key=\"\$key\"" - nasopts="-k \"\$${vif}_key\"${rekey:+ -g $rekey}" - ;; - *wpa*) - local auth_port auth_secret auth_server - wsec_r=1 - eap_r=1 - config_get auth_server "$vif" auth_server - [ -z "$auth_server" ] && config_get auth_server "$vif" server - config_get auth_port "$vif" auth_port - [ -z "$auth_port" ] && config_get auth_port "$vif" port - config_get auth_secret "$vif" auth_secret - [ -z "$auth_secret" ] && config_get auth_secret "$vif" key - - # wpa version + default cipher - case "$enc" in - *mixed*|*wpa+wpa2*) auth=66; wsec=6;; - *wpa2*) auth=64; wsec=4;; - *) auth=2; wsec=2;; - esac - - # cipher override - case "$enc" in - *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;; - *aes*|*ccmp*) wsec=4;; - *tkip*) wsec=2;; - esac - - # group rekey interval - config_get rekey "$vif" wpa_group_rekey - - eval "${vif}_key=\"\$auth_secret\"" - nasopts="-r \"\$${vif}_key\" -h $auth_server -p ${auth_port:-1812}${rekey:+ -g $rekey}" - ;; - esac - append vif_do_up "wsec $wsec" "$N" - append vif_do_up "wpa_auth $auth" "$N" - append vif_do_up "wsec_restrict $wsec_r" "$N" - append vif_do_up "eap_restrict $eap_r" "$N" - - local ssid - config_get ssid "$vif" ssid - append vif_post_up "vlan_mode 0" "$N" - append vif_pre_up "ssid $ssid" "$N" - - [ "$mode" = "monitor" ] && { - append vif_post_up "monitor $monitor" "$N" - } - - [ "$mode" = "adhoc" ] && { - local bssid - config_get bssid "$vif" bssid - [ -n "$bssid" ] && { - append vif_pre_up "bssid $bssid" "$N" - append vif_pre_up "ibss_merge 0" "$N" - } || { - append vif_pre_up "ibss_merge 1" "$N" - } - } - - append vif_post_up "enabled 1" "$N" - - local ifname - config_get ifname "$vif" ifname - local if_cmd="if_pre_up" - [ "$ifname" != "${ifname##${device}-}" ] && if_cmd="if_up" - append $if_cmd "macaddr=\$(wlc ifname '$ifname' cur_etheraddr)" ";$N" - append $if_cmd "ip link set dev '$ifname' address \$macaddr" ";$N" - append if_up "ip link set dev '$ifname' up" ";$N" - - local net_cfg="$(find_net_config "$vif")" - [ -z "$net_cfg" ] || { - ubus -t 30 wait_for network.interface."$net_cfg" - append if_up "set_wifi_up '$vif' '$ifname'" ";$N" - append if_up "start_net '$ifname' '$net_cfg'" ";$N" - } - [ -z "$nas" -o -z "$nasopts" ] || { - eval "${vif}_ssid=\"\$ssid\"" - local nas_mode="-A" - [ "$mode" = "sta" ] && nas_mode="-S" - [ -z "$nas_cmd" ] && { - local pid_file=/var/run/nas.$device.pid - nas_cmd="start-stop-daemon -S -b -p $pid_file -x $nas -- -P $pid_file -H 34954" - } - append nas_cmd "-i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 -F $nasopts" - } - _c=$(($_c + 1)) - done - wlc ifname "$device" stdin <<EOF -${macaddr:+bssid $macaddr} -${macaddr:+cur_etheraddr $macaddr} -band ${band:-0} -${nmode:+nmode $nmode} -${nmode:+${nreqd:+nreqd $nreqd}} -${gmode:+gmode $gmode} -leddc $leddc -apsta $apsta -ap $ap -${mssid:+mssid $mssid} -infra $infra -${wet:+wet 1} -802.11d 0 -802.11h ${doth:-0} -wme ${wmm:-1} -rxant ${rxantenna:-3} -txant ${txantenna:-3} -fragthresh ${frag:-2346} -rtsthresh ${rts:-2347} -monitor ${monitor:-0} - -radio ${radio:-1} -macfilter ${macfilter:-0} -maclist ${maclist:-none} -${wds:+wds $wds} -country ${country:-US} -${channel:+channel $channel} -${chanspec:+chanspec $chanspec} -maxassoc ${maxassoc:-128} -slottime ${slottime:--1} -${frameburst:+frameburst $frameburst} - -$vif_pre_up -EOF - eval "$if_pre_up" - wlc ifname "$device" stdin <<EOF -up -$vif_post_up -EOF - eval "$if_up" - wlc ifname "$device" stdin <<EOF -$vif_do_up -EOF - - # use vif_txpower (from last wifi-iface) instead of txpower (from - # wifi-device) if the latter does not exist - txpower=${txpower:-$vif_txpower} - [ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm - - # fd 1000 is an inherited lock file descriptor for preventing concurrent - # init script executions. Close it here to prevent the nas daemon from - # inheriting it further to avoid holding the lock indefinitely. - eval "$nas_cmd 1000>&-" -} - - -detect_broadcom() { - local i=-1 - - while grep -qs "^ *wl$((++i)):" /proc/net/dev; do - local channel type - - config_get type wl${i} type - [ "$type" = broadcom ] && continue - channel=`wlc ifname wl${i} channel` - - uci -q batch <<-EOF - set wireless.wl${i}=wifi-device - set wireless.wl${i}.type=broadcom - set wireless.wl${i}.channel=${channel:-11} - set wireless.wl${i}.txantenna=3 - set wireless.wl${i}.rxantenna=3 - set wireless.wl${i}.disabled=1 - - set wireless.default_wl${i}=wifi-iface - set wireless.default_wl${i}.device=wl${i} - set wireless.default_wl${i}.network=lan - set wireless.default_wl${i}.mode=ap - set wireless.default_wl${i}.ssid=OpenWrt${i#0} - set wireless.default_wl${i}.encryption=none -EOF - uci -q commit wireless - done -} diff --git a/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch b/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch deleted file mode 100644 index 89b665371d1..00000000000 --- a/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -2082,7 +2082,11 @@ static void - _wl_set_multicast_list(struct net_device *dev) - { - wl_info_t *wl; -+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) - struct dev_mc_list *mclist; -+#else -+ struct netdev_hw_addr *ha; -+#endif - int i; - - if (!dev) -@@ -2098,14 +2102,24 @@ _wl_set_multicast_list(struct net_device - wl->pub->allmulti = (dev->flags & IFF_ALLMULTI)? TRUE: FALSE; - - /* copy the list of multicasts into our private table */ -+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) - for (i = 0, mclist = dev->mc_list; mclist && (i < dev->mc_count); - i++, mclist = mclist->next) { -+#else -+ i = 0; -+ netdev_for_each_mc_addr(ha, dev) { -+#endif - if (i >= MAXMULTILIST) { - wl->pub->allmulti = TRUE; - i = 0; - break; - } -+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) - wl->pub->multicast[i] = *((struct ether_addr*) mclist->dmi_addr); -+#else -+ wl->pub->multicast[i] = *((struct ether_addr*) ha->addr); -+ i++; -+#endif - } - wl->pub->nmulticast = i; - wlc_set(wl->wlc, WLC_SET_PROMISC, (dev->flags & IFF_PROMISC)); diff --git a/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch b/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch deleted file mode 100644 index 36dda47e10a..00000000000 --- a/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/driver/include/linuxver.h -+++ b/driver/include/linuxver.h -@@ -111,7 +111,7 @@ typedef irqreturn_t(*FN_ISR) (int irq, v - #endif /* not SANDGATE2G */ - #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */ - --#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) -+#if 0 - - #include <pcmcia/cs_types.h> - #include <pcmcia/cs.h> ---- a/driver/linux_osl.c -+++ b/driver/linux_osl.c -@@ -62,7 +62,7 @@ struct osl_info { - }; - - /* PCMCIA attribute space access macros */ --#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) -+#if 0 - struct pcmcia_dev { - dev_link_t link; /* PCMCIA device pointer */ - dev_node_t node; /* PCMCIA node structure */ diff --git a/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch b/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch deleted file mode 100644 index 41c246ff804..00000000000 --- a/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: George Kashperko <george@znau.edu.ua> - -Release nvram variables buffer. -Prevent block reserved by alloc_etherdev from being freed. -Signed-off-by: George Kashperko <george@znau.edu.ua> ---- ---- ---- a/driver/siutils.c -+++ b/driver/siutils.c -@@ -647,7 +647,10 @@ si_detach(si_t *sih) - #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS) - if (sii != &ksii) - #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */ -- MFREE(sii->osh, sii, sizeof(si_info_t)); -+ do { -+ MFREE(sii->osh, sii, sizeof(si_info_t)); -+ nvram_exit((void *)&(sii->pub)); -+ } while (0); - } - - void * ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif) - free_netdev(wlif->dev); - #endif - } -- MFREE(wl->osh, wlif, sizeof(wl_if_t)); - } - - #ifdef AP diff --git a/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch b/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch deleted file mode 100644 index d6dd5f0aaea..00000000000 --- a/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch +++ /dev/null @@ -1,88 +0,0 @@ -From: George Kashperko <george@znau.edu.ua> - -broadcom-wl driver bound to ssb device with ssb driver probe -have osh handle struct pdev pointer value initialized with -ssb_device pointer. Later on pdev is used with legacy pci -dma api as pci_dev thus causing oops sometimes. - -The patch replaces legacy pci dma api and pass relevant -device struct pointer to avoid crashes. -Signed-off-by: George Kashperko <george@znau.edu.ua> ---- - driver/linux_osl.c | 28 +++++++++++++++++++++++----- - 1 file changed, 23 insertions(+), 5 deletions(-) ---- a/driver/linux_osl.c -+++ b/driver/linux_osl.c -@@ -25,6 +25,9 @@ - #include <asm/paccess.h> - #endif /* mips */ - #include <pcicfg.h> -+#ifdef CONFIG_SSB -+#include <linux/ssb/ssb.h> -+#endif - - #define PCI_CFG_RETRY 10 - -@@ -364,12 +367,27 @@ osl_dma_consistent_align(void) - return (PAGE_SIZE); - } - -+static struct device * -+osl_get_dmadev(osl_t *osh) -+{ -+#ifdef CONFIG_SSB -+ if (osh->bustype == SI_BUS) { -+ /* This can be SiliconBackplane emulated as pci with Broadcom or -+ * ssb device. Less harmful is to check for pci_bus_type and if -+ * no match then assume we got ssb */ -+ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type) -+ return ((struct ssb_device *)osh->pdev)->dma_dev; -+ } -+#endif -+ return &((struct pci_dev *)osh->pdev)->dev; -+} -+ - void* - osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap) - { - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - -- return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap)); -+ return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC)); - } - - void -@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void - { - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - -- pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa); -+ dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa); - } - - uint BCMFASTPATH -@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - - if (direction == DMA_TX) -- return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE)); -+ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE)); - else { - #ifdef mips - dma_cache_inv((uint)va, size); - return (virt_to_phys(va)); - #else /* mips */ -- return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE)); -+ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE)); - #endif /* mips */ - } - } -@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint - - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE; -- pci_unmap_single(osh->pdev, (uint32)pa, size, dir); -+ dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir); - } - - diff --git a/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch b/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch deleted file mode 100644 index a30dcc4edf3..00000000000 --- a/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch +++ /dev/null @@ -1,188 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t; - #include <bcmjtag.h> - #endif /* BCMJTAG */ - -- --#ifdef CONFIG_SSB --#include <linux/ssb/ssb.h> --#endif -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+#include <wl_glue.h> -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - - /* Linux wireless extension support */ - #ifdef CONFIG_WIRELESS_EXT -@@ -997,62 +996,32 @@ static struct pci_driver wl_pci_driver = - #endif /* CONFIG_PCI */ - #endif - -+#ifdef BCMJTAG -+static bcmjtag_driver_t wl_jtag_driver = { -+ wl_jtag_probe, -+ wl_jtag_detach, -+ wl_jtag_poll, -+ }; -+#endif /* BCMJTAG */ - --static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+static void * glue_attach_cb(u16 vendor, u16 device, -+ ulong mmio, void *dev, u32 irq) - { -- wl_info_t *wl; -- void *mmio; -- -- if (dev->bus->bustype != SSB_BUSTYPE_SSB) { -- printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n"); -- return -EINVAL; -- } -- -- mmio = (void *) 0x18000000 + dev->core_index * 0x1000; -- wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq); -- if (!wl) { -- printk("wl_attach failed\n"); -- return -ENODEV; -- } -- -- ssb_set_drvdata(dev, wl); -- -- return 0; -+ return wl_attach(vendor, device, mmio, SI_BUS, dev, irq); - } - --static void wl_ssb_remove(struct ssb_device *dev) -+static void glue_remove_cb(void *wldev) - { -- wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev); -+ wl_info_t *wl = (wl_info_t *)wldev; - - WL_LOCK(wl); - WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name)); - wl_down(wl); - WL_UNLOCK(wl); - wl_free(wl); -- ssb_set_drvdata(dev, NULL); - } -- --static const struct ssb_device_id wl_ssb_tbl[] = { -- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV), -- SSB_DEVTABLE_END --}; -- --#ifdef CONFIG_SSB --static struct ssb_driver wl_ssb_driver = { -- .name = KBUILD_MODNAME, -- .id_table = wl_ssb_tbl, -- .probe = wl_ssb_probe, -- .remove = wl_ssb_remove, --}; --#endif -- --#ifdef BCMJTAG --static bcmjtag_driver_t wl_jtag_driver = { -- wl_jtag_probe, -- wl_jtag_detach, -- wl_jtag_poll, -- }; --#endif /* BCMJTAG */ -+#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - - - /** -@@ -1067,11 +1036,13 @@ wl_module_init(void) - { - int error = -ENODEV; - --#ifdef CONFIG_SSB -- error = ssb_driver_register(&wl_ssb_driver); -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+ wl_glue_set_attach_callback(&glue_attach_cb); -+ wl_glue_set_remove_callback(&glue_remove_cb); -+ error = wl_glue_register(); - if (error) - return error; --#endif /* CONFIG_SSB */ -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - - #ifdef CONFIG_PCI - error = pci_register_driver(&wl_pci_driver); -@@ -1082,7 +1053,11 @@ wl_module_init(void) - return 0; - - error_pci: -- ssb_driver_unregister(&wl_ssb_driver); -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+ wl_glue_unregister(); -+ wl_glue_set_attach_callback(NULL); -+ wl_glue_set_remove_callback(NULL); -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - return error; - } - -@@ -1099,9 +1074,11 @@ wl_module_exit(void) - #ifdef CONFIG_PCI - pci_unregister_driver(&wl_pci_driver); - #endif /* CONFIG_PCI */ --#ifdef CONFIG_SSB -- ssb_driver_unregister(&wl_ssb_driver); --#endif /* CONFIG_SSB */ -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+ wl_glue_unregister(); -+ wl_glue_set_attach_callback(NULL); -+ wl_glue_set_remove_callback(NULL); -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - } - - module_init(wl_module_init); ---- a/driver/linux_osl.c -+++ b/driver/linux_osl.c -@@ -25,9 +25,9 @@ - #include <asm/paccess.h> - #endif /* mips */ - #include <pcicfg.h> --#ifdef CONFIG_SSB --#include <linux/ssb/ssb.h> --#endif -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) -+#include <wl_glue.h> -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - - #define PCI_CFG_RETRY 10 - -@@ -370,15 +370,17 @@ osl_dma_consistent_align(void) - static struct device * - osl_get_dmadev(osl_t *osh) - { --#ifdef CONFIG_SSB -+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) - if (osh->bustype == SI_BUS) { -- /* This can be SiliconBackplane emulated as pci with Broadcom or -- * ssb device. Less harmful is to check for pci_bus_type and if -- * no match then assume we got ssb */ -+ /* This can be SiliconBackplane emulated as pci with Broadcom, -+ * ssb or bcma device. Less harmful is to check for pci_bus_type and if -+ * no match then assume we got either ssb or bcma */ - if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type) -- return ((struct ssb_device *)osh->pdev)->dma_dev; -+ { -+ return wl_glue_get_dmadev(osh->pdev); -+ } - } --#endif -+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ - return &((struct pci_dev *)osh->pdev)->dev; - } - ---- a/driver/Makefile -+++ b/driver/Makefile -@@ -1,7 +1,7 @@ - BUILD_TYPE=wl_apsta - include $(src)/$(BUILD_TYPE)/buildflags.mk - --EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS) -+EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS) - - wl-objs := $(BUILD_TYPE)/wl_prebuilt.o wl_iw.o wl_linux.o linux_osl.o siutils.o aiutils.o hndpmu.o bcmutils.o sbutils.o nicpci.o hnddma.o bcmsrom.o nvram_stub.o - diff --git a/package/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch b/package/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch deleted file mode 100644 index 23831df5ba6..00000000000 --- a/package/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch +++ /dev/null @@ -1,132 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -354,6 +354,7 @@ static int wl_read_proc(char *buffer, ch - static int wl_dump(wl_info_t *wl, struct bcmstrbuf *b); - #endif /* BCMDBG */ - struct wl_if *wl_alloc_if(wl_info_t *wl, int iftype, uint unit, struct wlc_if* wlc_if); -+static void wl_link_if(wl_info_t *wl, wl_if_t *wlif); - static void wl_free_if(wl_info_t *wl, wl_if_t *wlif); - - -@@ -566,6 +567,9 @@ wl_attach(uint16 vendor, uint16 device, - wl->dev = dev; - wl_if_setup(dev); - -+ /* add the interface to the interface linked list */ -+ wl_link_if(wl, wlif); -+ - /* map chip registers (47xx: and sprom) */ - dev->base_addr = regs; - -@@ -1106,10 +1110,14 @@ wl_free(wl_info_t *wl) - free_irq(wl->dev->irq, wl); - } - -- if (wl->dev) { -- wl_free_if(wl, WL_DEV_IF(wl->dev)); -- wl->dev = NULL; -+ /* free all interfaces */ -+ while (wl->if_list) { -+ if ((wl->if_list->dev != wl->dev) || wl->if_list->next == NULL) -+ wl_free_if(wl, wl->if_list); -+ else -+ wl_free_if(wl, wl->if_list->next); - } -+ wl->dev = NULL; - - #ifdef TOE - wl_toe_detach(wl->toei); -@@ -1355,10 +1363,12 @@ wl_txflowcontrol(wl_info_t *wl, bool sta - - ASSERT(prio == ALLPRIO); - for (wlif = wl->if_list; wlif != NULL; wlif = wlif->next) { -- if (state == ON) -- netif_stop_queue(wlif->dev); -- else -- netif_wake_queue(wlif->dev); -+ if (wlif->dev_registed) { -+ if (state == ON) -+ netif_stop_queue(wlif->dev); -+ else -+ netif_wake_queue(wlif->dev); -+ } - } - } - -@@ -1398,7 +1408,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u - { - struct net_device *dev; - wl_if_t *wlif; -- wl_if_t *p; - - dev = alloc_etherdev(sizeof(wl_if_t)); - wlif = netdev_priv(dev); -@@ -1411,9 +1420,13 @@ wl_alloc_if(wl_info_t *wl, int iftype, u - wlif->wlcif = wlcif; - wlif->subunit = subunit; - -- /* match current flow control state */ -- if (iftype != WL_IFTYPE_MON && wl->dev && netif_queue_stopped(wl->dev)) -- netif_stop_queue(dev); -+ return wlif; -+} -+ -+static void -+wl_link_if(wl_info_t *wl, wl_if_t *wlif) -+{ -+ wl_if_t *p; - - /* add the interface to the interface linked list */ - if (wl->if_list == NULL) -@@ -1424,7 +1437,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u - p = p->next; - p->next = wlif; - } -- return wlif; - } - - static void -@@ -1504,6 +1516,9 @@ _wl_add_if(wl_task_t *task) - wl_info_t *wl = wlif->wl; - struct net_device *dev = wlif->dev; - -+ /* add the interface to the interface linked list */ -+ wl_link_if(wl, wlif); -+ - if (wlif->type == WL_IFTYPE_WDS) - dev->netdev_ops = &wl_wds_ops; - -@@ -1516,6 +1531,14 @@ _wl_add_if(wl_task_t *task) - } - wlif->dev_registed = TRUE; - -+ /* match current flow control state */ -+ if (wl->dev) { -+ if (netif_queue_stopped(wl->dev)) -+ netif_stop_queue(dev); -+ else -+ netif_wake_queue(dev); -+ } -+ - done: - MFREE(wl->osh, task, sizeof(wl_task_t)); - atomic_dec(&wl->callbacks); -@@ -1545,6 +1568,8 @@ wl_add_if(wl_info_t *wl, struct wlc_if* - return NULL; - } - -+ wl_if_setup(wlif->dev); -+ - sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit); - if (remote) - bcopy(remote, &wlif->remote, ETHER_ADDR_LEN); -@@ -2778,6 +2803,9 @@ wl_add_monitor(wl_task_t *task) - dev = wlif->dev; - wl->monitor = dev; - -+ /* add the interface to the interface linked list */ -+ wl_link_if(wl, wlif); -+ - /* override some fields */ - sprintf(dev->name, "prism%d", wl->pub->unit); - bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN); diff --git a/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch b/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch deleted file mode 100644 index cb388a11255..00000000000 --- a/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -463,6 +463,16 @@ wl_schedule_fn(wl_info_t *wl, void (*fn) - } - #endif /* DSLCPE_DELAY */ - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) -+#define WL_DEFAULT_OPS \ -+ .ndo_open = wl_open, \ -+ .ndo_stop = wl_close, \ -+ .ndo_start_xmit = wl_start, \ -+ .ndo_get_stats = wl_get_stats, \ -+ .ndo_set_mac_address = wl_set_mac_address, \ -+ .ndo_set_rx_mode = wl_set_multicast_list, \ -+ .ndo_do_ioctl = wl_ioctl -+#else - #define WL_DEFAULT_OPS \ - .ndo_open = wl_open, \ - .ndo_stop = wl_close, \ -@@ -471,6 +481,7 @@ wl_schedule_fn(wl_info_t *wl, void (*fn) - .ndo_set_mac_address = wl_set_mac_address, \ - .ndo_set_multicast_list = wl_set_multicast_list, \ - .ndo_do_ioctl = wl_ioctl -+#endif - - static const struct net_device_ops wl_ops = { - WL_DEFAULT_OPS, diff --git a/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch b/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch deleted file mode 100644 index 7b60873ebb8..00000000000 --- a/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -695,7 +695,7 @@ wl_attach(uint16 vendor, uint16 device, - if (wl->bustype != JTAG_BUS) - #endif /* BCMJTAG */ - { -- if (request_irq(irq, wl_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, dev->name, wl)) { -+ if (request_irq(irq, wl_isr, IRQF_SHARED, dev->name, wl)) { - WL_ERROR(("wl%d: request_irq() failed\n", unit)); - goto fail; - } diff --git a/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch b/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch deleted file mode 100644 index 585d53c7df2..00000000000 --- a/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -49,7 +49,9 @@ - #include <linux/ieee80211.h> - #endif - -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) - #include <asm/system.h> -+#endif - #include <asm/io.h> - #include <asm/irq.h> - #include <asm/pgtable.h> diff --git a/package/kernel/broadcom-wl/patches/012-compat-3.10.patch b/package/kernel/broadcom-wl/patches/012-compat-3.10.patch deleted file mode 100644 index e36028a634a..00000000000 --- a/package/kernel/broadcom-wl/patches/012-compat-3.10.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -349,7 +349,7 @@ static void wl_mic_error(wl_info_t *wl, - defined(WL_MONITOR) - static int wl_schedule_task(wl_info_t *wl, void (*fn)(struct wl_task *), void *context); - #endif --#if defined(CONFIG_PROC_FS) -+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - static int wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); - #endif /* defined(CONFIG_PROC_FS) */ - #ifdef BCMDBG -@@ -517,7 +517,7 @@ wl_attach(uint16 vendor, uint16 device, - struct net_device *dev; - wl_if_t *wlif; - wl_info_t *wl; --#if defined(CONFIG_PROC_FS) -+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - char tmp[128]; - #endif - osl_t *osh; -@@ -664,7 +664,7 @@ wl_attach(uint16 vendor, uint16 device, - WL_ERROR(("wl%d: Error setting MPC variable to 0\n", unit)); - } - } --#if defined(CONFIG_PROC_FS) -+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - /* create /proc/net/wl<unit> */ - sprintf(tmp, "net/wl%d", wl->pub->unit); - create_proc_read_entry(tmp, 0, 0, wl_read_proc, (void*)wl); -@@ -810,7 +810,7 @@ wl_dbus_disconnect_cb(void *arg) - } - #endif /* BCMDBUS */ - --#if defined(CONFIG_PROC_FS) -+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - static int - wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) - { -@@ -1149,7 +1149,7 @@ wl_free(wl_info_t *wl) - - /* free common resources */ - if (wl->wlc) { --#if defined(CONFIG_PROC_FS) -+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - char tmp[128]; - /* remove /proc/net/wl<unit> */ - sprintf(tmp, "net/wl%d", wl->pub->unit); diff --git a/package/kernel/broadcom-wl/patches/013-interface-name.patch b/package/kernel/broadcom-wl/patches/013-interface-name.patch deleted file mode 100644 index dbe1bdb89a6..00000000000 --- a/package/kernel/broadcom-wl/patches/013-interface-name.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -1583,7 +1583,7 @@ wl_add_if(wl_info_t *wl, struct wlc_if* - - wl_if_setup(wlif->dev); - -- sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit); -+ sprintf(wlif->dev->name, "%s%d-%d", devname, wl->pub->unit, wlif->subunit); - if (remote) - bcopy(remote, &wlif->remote, ETHER_ADDR_LEN); - diff --git a/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch b/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch deleted file mode 100644 index b231fed98db..00000000000 --- a/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/driver/wl_iw.c -+++ b/driver/wl_iw.c -@@ -314,7 +314,7 @@ wl_iw_get_name( - ) - { - int phytype, err; -- uint band[3]; -+ uint i, band[3], bands; - char cap[5]; - - WL_TRACE(("%s: SIOCGIWNAME\n", dev->name)); -@@ -335,16 +335,20 @@ wl_iw_get_name( - break; - case WLC_PHY_TYPE_LP: - case WLC_PHY_TYPE_G: -- if (band[0] >= 2) -- strcpy(cap, "abg"); -- else -- strcpy(cap, "bg"); -- break; - case WLC_PHY_TYPE_N: -- if (band[0] >= 2) -- strcpy(cap, "abgn"); -- else -- strcpy(cap, "bgn"); -+ bands = 0; -+ for (i = 1; i <= band[0]; i++) { -+ bands |= dtoh32(band[i]); -+ } -+ strcpy(cap, ""); -+ if (bands & WLC_BAND_5G) -+ strcat(cap, "a"); -+ if (bands & WLC_BAND_2G) -+ strcat(cap, "bg"); -+ if (phytype == WLC_PHY_TYPE_N) -+ strcat(cap, "n"); -+ break; -+ default: - break; - } - done: diff --git a/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch b/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch deleted file mode 100644 index f44921a9547..00000000000 --- a/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/shared/wl.c -+++ b/shared/wl.c -@@ -27,7 +27,7 @@ wl_probe(char *name) - { - int ret, val; - -- if ((name[0] != 'w') || (name[1] != 'l')) -+ if ((name[0] != 'w') || ((name[1] != 'l') && ((name[1] != 'd') || (name[2] != 's')))) - return -1; - - /* Check interface */ diff --git a/package/kernel/broadcom-wl/patches/020-musl-fixes.patch b/package/kernel/broadcom-wl/patches/020-musl-fixes.patch deleted file mode 100644 index a985b9c24a4..00000000000 --- a/package/kernel/broadcom-wl/patches/020-musl-fixes.patch +++ /dev/null @@ -1,75 +0,0 @@ ---- a/shared/wl_linux.c -+++ b/shared/wl_linux.c -@@ -13,6 +13,7 @@ - */ - - #include <stdio.h> -+#include <stdint.h> - #include <unistd.h> - #include <string.h> - #include <errno.h> -@@ -20,10 +21,10 @@ - #include <net/if.h> - #include <linux/types.h> - --typedef u_int64_t u64; --typedef u_int32_t u32; --typedef u_int16_t u16; --typedef u_int8_t u8; -+typedef uint64_t u64; -+typedef uint32_t u32; -+typedef uint16_t u16; -+typedef uint8_t u8; - #include <linux/sockios.h> - #include <linux/ethtool.h> - ---- a/shared/linux_timer.c -+++ b/shared/linux_timer.c -@@ -125,7 +125,7 @@ void unblock_timer(); - - static struct event *event_queue = NULL; - static struct event *event_freelist; --static uint g_granularity; -+static unsigned int g_granularity; - static int g_maxevents = 0; - - uclock_t uclock() ---- a/shared/wl.c -+++ b/shared/wl.c -@@ -14,6 +14,7 @@ - #include <typedefs.h> - #include <string.h> - #include <stdio.h> -+#include <stdlib.h> - #include <unistd.h> - #include <errno.h> - #include <sys/ioctl.h> -@@ -263,3 +264,28 @@ wl_printlasterror(char *name) - fprintf(stderr, err_buf); - } - */ -+ -+static int in_assert; /* bss inits to 0. */ -+ -+void __assert(const char *assertion, const char * filename, -+ unsigned int linenumber, register const char * function) -+{ -+ if (!in_assert) { -+ in_assert = 1; -+ -+ fprintf(stderr, -+#ifdef ASSERT_SHOW_PROGNAME -+ "%s: %s: %d: %s: Assertion `%s' failed.\n", __uclibc_progname, -+#else -+ "%s: %d: %s: Assertion `%s' failed.\n", -+#endif -+ filename, -+ linenumber, -+ /* Function name isn't available with some compilers. */ -+ ((function == NULL) ? "?function?" : function), -+ assertion -+ ); -+ } -+ /* shouldn't we? fflush(stderr); */ -+ abort(); -+} diff --git a/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch b/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch deleted file mode 100644 index ead108e5b2c..00000000000 --- a/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch +++ /dev/null @@ -1,74 +0,0 @@ ---- a/driver/include/linuxver.h -+++ b/driver/include/linuxver.h -@@ -139,22 +139,6 @@ typedef struct pcmcia_device dev_link_t; - - #endif /* CONFIG_PCMCIA */ - --#ifndef __exit --#define __exit --#endif --#ifndef __devexit --#define __devexit --#endif --#ifndef __devinit --#define __devinit __init --#endif --#ifndef __devinitdata --#define __devinitdata --#endif --#ifndef __devexit_p --#define __devexit_p(x) x --#endif -- - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)) - - #define pci_get_drvdata(dev) (dev)->sysdata ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -854,7 +854,7 @@ wl_read_proc(char *buffer, char **start, - */ - #if !defined(BCMJTAG) - #ifdef CONFIG_PCI --static void __devexit wl_remove(struct pci_dev *pdev); -+static void wl_remove(struct pci_dev *pdev); - /** - * determines if a device is a WL device, and if so, attaches it. - * -@@ -862,7 +862,7 @@ static void __devexit wl_remove(struct p - * and if so, performs a wl_attach() on it. - * - */ --int __devinit -+int - wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - { - int rc; -@@ -976,7 +976,7 @@ wl_resume(struct pci_dev *pdev) - } - #endif /* LINUXSTA_PS */ - --static void __devexit -+static void - wl_remove(struct pci_dev *pdev) - { - wl_info_t *wl = (wl_info_t *) pci_get_drvdata(pdev); -@@ -1007,7 +1007,7 @@ static struct pci_driver wl_pci_driver = - suspend: wl_suspend, - resume: wl_resume, - #endif /* LINUXSTA_PS */ -- remove: __devexit_p(wl_remove), -+ remove: wl_remove, - id_table: wl_id_table, - }; - #endif /* CONFIG_PCI */ ---- a/driver/wl_linux.h -+++ b/driver/wl_linux.h -@@ -33,7 +33,7 @@ extern irqreturn_t wl_isr(int irq, void - extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs); - #endif - --extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent); -+extern int wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent); - extern void wl_free(wl_info_t *wl); - extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - extern struct net_device * wl_netdev_get(wl_info_t *wl); diff --git a/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch b/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch deleted file mode 100644 index 9f4b0b01b3a..00000000000 --- a/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- broadcom-wl-5.10.56.27.3/driver/wl_linux.c.orig 2018-01-13 18:25:14.944667645 +0100 -+++ broadcom-wl-5.10.56.27.3/driver/wl_linux.c 2018-01-13 18:25:25.836667888 +0100 -@@ -2762,7 +2762,6 @@ - bcopy(oskb->data + D11_PHY_HDR_LEN, pdata, oskb->len - D11_PHY_HDR_LEN); - - skb->dev = wl->monitor; -- skb->dev->last_rx = jiffies; - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) - skb_reset_mac_header(skb); - #else diff --git a/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch b/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch deleted file mode 100644 index 6cf6faeddd1..00000000000 --- a/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/driver/nvram_stub.c -+++ b/driver/nvram_stub.c -@@ -22,6 +22,7 @@ typedef struct _vars { - #define VARS_T_OH sizeof(vars_t) - - static vars_t *vars = NULL; -+static int nvram_init_done = 0; - extern char *nvram_buf[]; - - int -@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si) - uint nvs, bufsz; - vars_t *new; - -+ nvram_init_done++; -+ if (nvram_init_done != 1) -+ return 0; -+ - osh = si_osh(sih); - - nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header); -@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si) - vars_t *this, *next; - si_t *sih; - -+ nvram_init_done--; -+ if (nvram_init_done != 0) -+ return; -+ - sih = (si_t *)si; - this = vars; - while (this) { diff --git a/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch b/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch deleted file mode 100644 index 95f0beb73c9..00000000000 --- a/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -1425,7 +1425,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u - dev = alloc_etherdev(sizeof(wl_if_t)); - wlif = netdev_priv(dev); - bzero(wlif, sizeof(wl_if_t)); -- strncpy(dev->name, name, IFNAMSIZ); -+ snprintf(dev->name, IFNAMSIZ, name, subunit); - - wlif->type = iftype; - wlif->dev = dev; diff --git a/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch b/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch deleted file mode 100644 index 422f7f784f5..00000000000 --- a/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch +++ /dev/null @@ -1,93 +0,0 @@ ---- a/driver/nvram_stub.c -+++ b/driver/nvram_stub.c -@@ -5,6 +5,8 @@ - #include <siutils.h> - #include <bcmendian.h> - #include <bcmnvram.h> -+#include <proto/ethernet.h> -+#include <linux/errno.h> - - #ifdef BCMDBG_ERR - #define NVR_MSG(x) printf x -@@ -24,6 +26,7 @@ typedef struct _vars { - static vars_t *vars = NULL; - static int nvram_init_done = 0; - extern char *nvram_buf[]; -+static void fixup_mac_addr(vars_t *new); - - int - BCMATTACHFN(nvram_init)(void *si) -@@ -55,6 +58,7 @@ BCMATTACHFN(nvram_init)(void *si) - vars = new; - - bcopy((char *)(&nvh[1]), new->vars, nvs); -+ fixup_mac_addr(new); - return 0; - } - -@@ -164,3 +168,65 @@ nvram_getall(char *buf, int count) - *buf = '\0'; - return 0; - } -+ -+static bool nvram_is_valid_mac(struct ether_addr *mac) -+{ -+ return mac && !(mac->octet[0] == 0x00 && mac->octet[1] == 0x90 && mac->octet[2] == 0x4c); -+} -+ -+static int nvram_increase_mac_addr(struct ether_addr *mac, u8 num) -+{ -+ u8 *oui = mac->octet + ETHER_ADDR_LEN/2 - 1; -+ u8 *p = mac->octet + ETHER_ADDR_LEN - 1; -+ -+ do { -+ (*p) += num; -+ if (*p > num) -+ break; -+ p--; -+ num = 1; -+ } while (p != oui); -+ -+ if (p == oui) { -+ pr_err("unable to fetch mac address\n"); -+ return -ENOENT; -+ } -+ return 0; -+} -+ -+static void nvram_change_mac_addr(vars_t *new, struct ether_addr *valid, const char *name) -+{ -+ char *macaddr_c; -+ struct ether_addr macaddr; -+ -+ macaddr_c = findvar(new->vars, new->vars + new->size, name); -+ if (!macaddr_c) -+ return; -+ -+ bcm_ether_atoe(macaddr_c, &macaddr); -+ if (nvram_is_valid_mac(&macaddr)) -+ return; -+ nvram_increase_mac_addr(valid, 1); -+ bcm_ether_ntoa(valid, macaddr_c); -+} -+ -+static void fixup_mac_addr(vars_t *new) -+{ -+ char *macaddr_base_c; -+ struct ether_addr macaddr_base; -+ -+ macaddr_base_c = findvar(new->vars, new->vars + new->size, "et0macaddr"); -+ if (!macaddr_base_c) -+ return; -+ -+ bcm_ether_atoe(macaddr_base_c, &macaddr_base); -+ if (!nvram_is_valid_mac(&macaddr_base)) -+ return; -+ -+ /* jump over the first free address so it can be used for wan */ -+ nvram_increase_mac_addr(&macaddr_base, 1); -+ nvram_change_mac_addr(new, &macaddr_base, "sb/1/macaddr"); -+ nvram_change_mac_addr(new, &macaddr_base, "pci/1/1/macaddr"); -+ nvram_change_mac_addr(new, &macaddr_base, "pci/1/2/macaddr"); -+ nvram_change_mac_addr(new, &macaddr_base, "pci/2/1/macaddr"); -+} diff --git a/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch b/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch deleted file mode 100644 index c1d13440032..00000000000 --- a/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -876,7 +876,8 @@ wl_pci_probe(struct pci_dev *pdev, const - - if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || - (((pdev->device & 0xff00) != 0x4300) && -- ((pdev->device & 0xff00) != 0x4700))) -+ ((pdev->device & 0xff00) != 0x4700) && -+ ((pdev->device & 0xff00) != 0xa800))) - return (-ENODEV); - - rc = pci_enable_device(pdev); diff --git a/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch b/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch deleted file mode 100644 index a85e40bc140..00000000000 --- a/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch +++ /dev/null @@ -1,78 +0,0 @@ ---- a/driver/bcmsrom.c -+++ b/driver/bcmsrom.c -@@ -39,6 +39,11 @@ - #include <sbsdpcmdev.h> - #endif - -+#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX) -+#include <linux/ssb/ssb.h> -+extern int bcm63xx_get_fallback_sprom(uint pci_bus, uint pci_slot, struct ssb_sprom *out); -+#endif -+ - #ifdef WLTEST - #include <sbsprom.h> - #endif /* WLTEST */ -@@ -2120,6 +2125,63 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih - goto varscont; - } - -+#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX) -+ base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS); -+ -+ if( base != NULL ) -+ { -+ char eabuf[18]; -+ struct ssb_sprom bcm63xx_sprom; -+ uint pci_bus = osl_pci_bus(osh), pci_slot = osl_pci_slot(osh); -+ -+ bcm63xx_get_fallback_sprom(pci_bus, pci_slot, &bcm63xx_sprom); -+ printk("BCM%X(%02x:%02x) using sprom version %i\n", sih->chip, pci_bus, pci_slot, bcm63xx_sprom.revision); -+ -+ varbuf_init(&b, base, MAXSZ_NVRAM_VARS); -+ -+ varbuf_append(&b, vstr_sromrev, bcm63xx_sprom.revision); -+ varbuf_append(&b, vstr_boardrev, bcm63xx_sprom.board_rev); -+ -+ /* ToDo: map bcm63xx_sprom.country_code */ -+ varbuf_append(&b, vstr_noccode); -+ -+ varbuf_append(&b, vstr_aa2g, bcm63xx_sprom.ant_available_bg); -+ -+ varbuf_append(&b, vstr_pa0b[0], bcm63xx_sprom.pa0b0); -+ varbuf_append(&b, vstr_pa1b[0], bcm63xx_sprom.pa1b0); -+ varbuf_append(&b, vstr_pa0b[1], bcm63xx_sprom.pa0b1); -+ varbuf_append(&b, vstr_pa1b[1], bcm63xx_sprom.pa1b1); -+ varbuf_append(&b, vstr_pa0b[2], bcm63xx_sprom.pa0b2); -+ varbuf_append(&b, vstr_pa1b[2], bcm63xx_sprom.pa1b2); -+ -+ varbuf_append(&b, vstr_pa0maxpwr, bcm63xx_sprom.maxpwr_bg); -+ varbuf_append(&b, vstr_pa0itssit, bcm63xx_sprom.itssi_bg); -+ -+ varbuf_append(&b, vstr_boardflags, (bcm63xx_sprom.boardflags_hi << 16) | bcm63xx_sprom.boardflags_lo); -+ varbuf_append(&b, vstr_boardflags2, (bcm63xx_sprom.boardflags2_hi << 16) | bcm63xx_sprom.boardflags2_lo); -+ -+ snprintf(eabuf, sizeof(eabuf), "%02x:%02x:%02x:%02x:%02x:%02x", -+ bcm63xx_sprom.il0mac[0], bcm63xx_sprom.il0mac[1], bcm63xx_sprom.il0mac[2], -+ bcm63xx_sprom.il0mac[3], bcm63xx_sprom.il0mac[4], bcm63xx_sprom.il0mac[5] -+ ); -+ -+ varbuf_append(&b, vstr_macaddr, eabuf); -+ -+ /* final nullbyte terminator */ -+ ASSERT(b.size >= 1); -+ vp = b.buf; -+ *vp++ = '\0'; -+ -+ ASSERT((vp - base) <= MAXSZ_NVRAM_VARS); -+ goto varsdone; -+ } -+ else -+ { -+ err = -2; -+ goto errout; -+ } -+#endif -+ - BS_ERROR(("SROM CRC Error\n")); - - #if defined(WLTEST) diff --git a/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch b/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch deleted file mode 100644 index 65e8bd39580..00000000000 --- a/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/driver/siutils.c -+++ b/driver/siutils.c -@@ -1859,7 +1859,7 @@ BCMINITFN(si_devpath)(si_t *sih, char *p - case PCI_BUS: - ASSERT((SI_INFO(sih))->osh != NULL); - slen = snprintf(path, (size_t)size, "pci/%u/%u/", -- OSL_PCI_BUS((SI_INFO(sih))->osh), -+ OSL_PCI_BUS((SI_INFO(sih))->osh) + 1, - OSL_PCI_SLOT((SI_INFO(sih))->osh)); - break; - case PCMCIA_BUS: diff --git a/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch b/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch deleted file mode 100644 index 412bce92c83..00000000000 --- a/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/driver/linux_osl.c -+++ b/driver/linux_osl.c -@@ -723,6 +723,9 @@ osl_readl(volatile uint32 *r) - uint16 - osl_readw(volatile uint16 *r) - { -+ uint32 addr = (uintptr)r & 0xffff3fff; -+ if (addr == 0xa8000688) /* ifs_ctl */ -+ readl(r); - return (readw(r)); - } - diff --git a/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch b/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch deleted file mode 100644 index 394a06d98c1..00000000000 --- a/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -762,7 +762,7 @@ wl_attach(uint16 vendor, uint16 device, - dev->name, device); - - #ifdef BCMDBG -- printf(" (Compiled in " SRCBASE " at " __TIME__ " on " __DATE__ ")"); -+ printf(" (Compiled in " SRCBASE ")"); - #endif /* BCMDBG */ - printf("\n"); - -@@ -2298,8 +2298,7 @@ wl_sendup(wl_info_t *wl, wl_if_t *wlif, - void - wl_dump_ver(wl_info_t *wl, struct bcmstrbuf *b) - { -- bcm_bprintf(b, "wl%d: %s %s version %s\n", wl->pub->unit, -- __DATE__, __TIME__, EPI_VERSION_STR); -+ bcm_bprintf(b, "wl%d: version %s\n", wl->pub->unit, EPI_VERSION_STR); - } - - #ifdef BCMDBG diff --git a/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch b/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch deleted file mode 100644 index daf3160952e..00000000000 --- a/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -235,7 +235,11 @@ - - }; - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) -+static void wl_timer(struct timer_list *tl); -+#else - static void wl_timer(ulong data); -+#endif - static void _wl_timer(wl_timer_t *t); - - #ifdef WLC_HIGH_ONLY -@@ -2512,6 +2517,18 @@ - } - #endif /* WLC_HIGH_ONLY */ - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) -+static void -+wl_timer(struct timer_list *tl) -+{ -+ wl_timer_t *t = from_timer(t, tl, timer); -+#ifndef WLC_HIGH_ONLY -+ _wl_timer(t); -+#else -+ wl_schedule_task(t->wl, wl_timer_task, t); -+#endif /* WLC_HIGH_ONLY */ -+} -+#else - static void - wl_timer(ulong data) - { -@@ -2522,6 +2539,7 @@ - wl_schedule_task(t->wl, wl_timer_task, t); - #endif /* WLC_HIGH_ONLY */ - } -+#endif /* linux >= 4.15.0 */ - - static void - _wl_timer(wl_timer_t *t) -@@ -2573,9 +2591,13 @@ - - bzero(t, sizeof(wl_timer_t)); - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) -+ timer_setup(&t->timer, wl_timer, 0); -+#else - init_timer(&t->timer); - t->timer.data = (ulong) t; - t->timer.function = wl_timer; -+#endif - t->wl = wl; - t->fn = fn; - t->arg = arg; diff --git a/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch b/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch deleted file mode 100644 index bc7b63df083..00000000000 --- a/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/driver/wl_iw.c -+++ b/driver/wl_iw.c -@@ -112,10 +112,14 @@ - ifr.ifr_data = (caddr_t) &ioc; - - /* Must be up for virtually all useful ioctls */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) -+ dev_open(dev, NULL); -+#else - dev_open(dev); -+#endif - - fs = get_fs(); -- set_fs(get_ds()); -+ set_fs(KERNEL_DS); - ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE); - set_fs(fs); - diff --git a/package/kernel/broadcom-wl/src/glue/Makefile b/package/kernel/broadcom-wl/src/glue/Makefile deleted file mode 100644 index f434d2430e1..00000000000 --- a/package/kernel/broadcom-wl/src/glue/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# Makefile for wl_glue driver -# -# Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io> -# -# 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. -# - -obj-m := wl_glue.o - -ifeq ($(MAKING_MODULES),1) --include $(TOPDIR)/Rules.make -endif - diff --git a/package/kernel/broadcom-wl/src/glue/wl_glue.c b/package/kernel/broadcom-wl/src/glue/wl_glue.c deleted file mode 100644 index 7851f414dbc..00000000000 --- a/package/kernel/broadcom-wl/src/glue/wl_glue.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * wl_glue.c: Broadcom WL support module providing a unified SSB/BCMA handling. - * Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io> - */ - -#include "wl_glue.h" - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/init.h> - -#ifdef CONFIG_BCM47XX -#include <bcm47xx.h> -#endif - -#ifdef CONFIG_SSB -#include <linux/ssb/ssb.h> -#endif - -#ifdef CONFIG_BCMA -#include <linux/bcma/bcma.h> -#endif - -MODULE_AUTHOR("Jo-Philipp Wich (jo@mein.io)"); -MODULE_DESCRIPTION("Broadcom WL SSB/BCMA compatibility layer"); -MODULE_LICENSE("GPL"); - -static wl_glue_attach_cb_t attach_cb = NULL; -static wl_glue_remove_cb_t remove_cb = NULL; -static enum wl_glue_bus_type active_bus_type = WL_GLUE_BUS_TYPE_UNSPEC; -static int wl_glue_attached = 0; - - -#ifdef CONFIG_SSB -static int wl_glue_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) -{ - void *mmio; - void *wldev; - - if (!attach_cb) - { - pr_err("No attach callback registered\n"); - return -ENOSYS; - } - - if (dev->bus->bustype != SSB_BUSTYPE_SSB) - { - pr_err("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n"); - return -EINVAL; - } - - mmio = (void *) 0x18000000 + dev->core_index * 0x1000; - wldev = attach_cb(id->vendor, id->coreid, (ulong)mmio, dev, dev->irq); - - if (!wldev) - { - pr_err("The attach callback failed, SSB probe aborted\n"); - return -ENODEV; - } - - ssb_set_drvdata(dev, wldev); - return 0; -} - -static void wl_glue_ssb_remove(struct ssb_device *dev) -{ - void *wldev = ssb_get_drvdata(dev); - - if (remove_cb) - remove_cb(wldev); - - ssb_set_drvdata(dev, NULL); -} - -static const struct ssb_device_id wl_glue_ssb_tbl[] = { - SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV), - {}, -}; - -static struct ssb_driver wl_glue_ssb_driver = { - .name = KBUILD_MODNAME, - .id_table = wl_glue_ssb_tbl, - .probe = wl_glue_ssb_probe, - .remove = wl_glue_ssb_remove, -}; -#endif /* CONFIG_SSB */ - -#ifdef CONFIG_BCMA -static int wl_glue_bcma_probe(struct bcma_device *dev) -{ - void *wldev; - - if (!attach_cb) - { - pr_err("No attach callback registered\n"); - return -ENOSYS; - } - - if (dev->bus->hosttype != BCMA_HOSTTYPE_SOC) - { - pr_err("Unsupported BCMA bus type %d\n", dev->bus->hosttype); - return -EINVAL; - } - - /* - * NB: - * 0x18000000 = BCMA_ADDR_BASE - * 0x1000 = BCMA_CORE_SIZE - */ - - wldev = attach_cb(dev->id.manuf, dev->id.id, (ulong)dev->addr, dev, dev->irq); - - if (!wldev) - { - pr_err("The attach callback failed, BCMA probe aborted\n"); - return -ENODEV; - } - - bcma_set_drvdata(dev, wldev); - return 0; -} - -static void wl_glue_bcma_remove(struct bcma_device *dev) -{ - void *wldev = bcma_get_drvdata(dev); - - if (remove_cb) - remove_cb(wldev); - - bcma_set_drvdata(dev, NULL); -} - -static const struct bcma_device_id wl_glue_bcma_tbl[] = { - BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, BCMA_ANY_REV, BCMA_ANY_CLASS), - {}, -}; - -static struct bcma_driver wl_glue_bcma_driver = { - .name = KBUILD_MODNAME, - .id_table = wl_glue_bcma_tbl, - .probe = wl_glue_bcma_probe, - .remove = wl_glue_bcma_remove, -}; -#endif /* CONFIG_BCMA */ - - -void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb) -{ - attach_cb = cb; -} -EXPORT_SYMBOL(wl_glue_set_attach_callback); - -void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb) -{ - remove_cb = cb; -} -EXPORT_SYMBOL(wl_glue_set_remove_callback); - -int wl_glue_register(void) -{ - int err; - - switch(active_bus_type) - { -#ifdef CONFIG_SSB - case WL_GLUE_BUS_TYPE_SSB: - err = ssb_driver_register(&wl_glue_ssb_driver); - break; -#endif /* CONFIG_SSB */ - -#ifdef CONFIG_BCMA - case WL_GLUE_BUS_TYPE_BCMA: - err = bcma_driver_register(&wl_glue_bcma_driver); - break; -#endif /* CONFIG_BCMA */ - - default: - pr_err("Not attaching through glue driver due to unsupported bus\n"); - err = -ENOSYS; - break; - } - - if (!err) - { - pr_info("SSB/BCMA glue driver successfully attached\n"); - wl_glue_attached = 1; - } - - return err; -} -EXPORT_SYMBOL(wl_glue_register); - -int wl_glue_unregister(void) -{ - int err; - - if (!wl_glue_attached) - return -ENOSYS; - - switch (active_bus_type) - { -#ifdef CONFIG_SSB - case WL_GLUE_BUS_TYPE_SSB: - ssb_driver_unregister(&wl_glue_ssb_driver); - err = 0; - break; -#endif /* CONFIG_SSB */ - -#ifdef CONFIG_BCMA - case WL_GLUE_BUS_TYPE_BCMA: - bcma_driver_unregister(&wl_glue_bcma_driver); - err = 0; - break; -#endif /* CONFIG_BCMA */ - - default: - pr_err("Not removing glue driver due to unsupported bus\n"); - err = -ENOSYS; - break; - } - - if (!err) - { - pr_info("SSB/BCMA glue driver successfully detached\n"); - wl_glue_attached = 0; - } - - return err; -} -EXPORT_SYMBOL(wl_glue_unregister); - -struct device * wl_glue_get_dmadev(void *dev) -{ - struct device *dma_dev; - - switch (active_bus_type) - { -#ifdef CONFIG_SSB - case WL_GLUE_BUS_TYPE_SSB: - dma_dev = ((struct ssb_device *)dev)->dma_dev; - break; -#endif /* CONFIG_SSB */ - -#ifdef CONFIG_BCMA - case WL_GLUE_BUS_TYPE_BCMA: - dma_dev = ((struct bcma_device *)dev)->dma_dev; - break; -#endif /* CONFIG_BCMA */ - - default: - BUG(); - dma_dev = NULL; - break; - } - - return dma_dev; -} -EXPORT_SYMBOL(wl_glue_get_dmadev); - - -static int __init wl_glue_init(void) -{ -#ifdef CONFIG_BCM47XX - /* - * BCM47xx currently supports either SSB or BCMA bus, - * determine the used one from the info set by the - * platform setup code. - */ - switch (bcm47xx_bus_type) - { -#ifdef CONFIG_BCM47XX_SSB - case BCM47XX_BUS_TYPE_SSB: - active_bus_type = WL_GLUE_BUS_TYPE_SSB; - break; -#endif /* CONFIG_BCM47XX_SSB */ - -#ifdef CONFIG_BCM47XX_BCMA - case BCM47XX_BUS_TYPE_BCMA: - active_bus_type = WL_GLUE_BUS_TYPE_BCMA; - break; -#endif /* CONFIG_BCM47XX_BCMA */ - } -#endif /* CONFIG_BCM47XX */ - -#ifdef CONFIG_BCM63XX -#ifdef CONFIG_SSB - /* - * BCM63xx currently only uses SSB, so assume that. - */ - active_bus_type = WL_GLUE_BUS_TYPE_SSB; -#endif /* CONFIG_SSB */ -#endif /* CONFIG_BCM63XX */ - - /* do not fail here, let wl_glue_register() return -ENOSYS later */ - if (active_bus_type == WL_GLUE_BUS_TYPE_UNSPEC) - pr_err("Unable to determine used system bus type\n"); - - return 0; -} - -static void __exit wl_glue_exit(void) -{ - if (wl_glue_attached) - { - if (wl_glue_unregister()) - pr_err("Failed to unregister glue driver\n"); - - wl_glue_attached = 0; - } - - return; -} - -module_init(wl_glue_init); -module_exit(wl_glue_exit); diff --git a/package/kernel/broadcom-wl/src/glue/wl_glue.h b/package/kernel/broadcom-wl/src/glue/wl_glue.h deleted file mode 100644 index 49610ab9093..00000000000 --- a/package/kernel/broadcom-wl/src/glue/wl_glue.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * wl_glue.h: Broadcom WL support module providing a unified SSB/BCMA handling. - * Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io> - */ - -#include <linux/types.h> - -typedef void * (*wl_glue_attach_cb_t)(u16, u16, ulong, void *, u32); -typedef void (*wl_glue_remove_cb_t)(void *); - -enum wl_glue_bus_type { - WL_GLUE_BUS_TYPE_UNSPEC, - WL_GLUE_BUS_TYPE_SSB, - WL_GLUE_BUS_TYPE_BCMA -}; - -extern void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb); -extern void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb); -extern int wl_glue_register(void); -extern int wl_glue_unregister(void); -extern struct device * wl_glue_get_dmadev(void *); - diff --git a/package/kernel/broadcom-wl/src/wlc.c b/package/kernel/broadcom-wl/src/wlc.c deleted file mode 100644 index 46ccf94bffd..00000000000 --- a/package/kernel/broadcom-wl/src/wlc.c +++ /dev/null @@ -1,1181 +0,0 @@ -/* - * wlc - Broadcom Wireless Driver Control Utility - * - * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name> - * - * 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. - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <glob.h> -#include <ctype.h> - -#include <typedefs.h> -#include <wlutils.h> -#include <proto/802.11.h> - -#define VERSION "0.1" -#define BUFSIZE 8192 -#define PTABLE_MAGIC 0xbadc0ded -#define PTABLE_SLT1 1 -#define PTABLE_SLT2 2 -#define PTABLE_ACKW 3 -#define PTABLE_ADHM 4 -#define PTABLE_END 0xffffffff - -/* - * Copy each token in wordlist delimited by space into word - * Taken from Broadcom shutils.h - */ -#define foreach(word, wordlist, next) \ - for (next = &wordlist[strspn(wordlist, " ")], \ - strncpy(word, next, sizeof(word)), \ - word[strcspn(word, " ")] = '\0', \ - word[sizeof(word) - 1] = '\0', \ - next = strchr(next, ' '); \ - strlen(word); \ - next = next ? &next[strspn(next, " ")] : "", \ - strncpy(word, next, sizeof(word)), \ - word[strcspn(word, " ")] = '\0', \ - word[sizeof(word) - 1] = '\0', \ - next = strchr(next, ' ')) - -static char wlbuf[8192]; -static char interface[16] = "wl0"; -static unsigned long kmem_offset = 0; -static int vif = 0, debug = 1, fromstdin = 0; - -typedef enum { - NONE = 0x00, - - /* types */ - PARAM_TYPE = 0x00f, - INT = 0x001, - STRING = 0x002, - MAC = 0x003, - - /* options */ - PARAM_OPTIONS = 0x0f0, - NOARG = 0x010, - - /* modes */ - PARAM_MODE = 0xf00, - GET = 0x100, - SET = 0x200, -} wlc_param; - -struct wlc_call { - const char *name; - wlc_param param; - int (*handler)(wlc_param param, void *data, void *value); - union { - int num; - char *str; - void *ptr; - } data; - const char *desc; -}; - -/* can't use the system include because of the stupid broadcom header files */ -extern struct ether_addr *ether_aton(const char *asc); -static inline int my_ether_ntoa(unsigned char *ea, char *buf) -{ - return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", - ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]); -} - -static int wlc_ioctl(wlc_param param, void *data, void *value) -{ - unsigned int *var = ((unsigned int *) data); - unsigned int ioc = *var; - - if (param & NOARG) { - return wl_ioctl(interface, ioc, NULL, 0); - } - switch(param & PARAM_TYPE) { - case MAC: - return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, 6); - case INT: - return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, sizeof(int)); - case STRING: - return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, BUFSIZE); - } - return 0; -} - -static int wlc_iovar(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - char *iov = *((char **) data); - int ret = 0; - - if (param & SET) { - switch(param & PARAM_TYPE) { - case INT: - ret = wl_iovar_setint(interface, iov, *val); - break; - case MAC: - ret = wl_iovar_set(interface, iov, value, 6); - break; - } - } - if (param & GET) { - switch(param & PARAM_TYPE) { - case INT: - ret = wl_iovar_get(interface, iov, val, sizeof(int)); - break; - case MAC: - ret = wl_iovar_get(interface, iov, value, 6); - break; - } - } - - return ret; -} - -static int wlc_bssiovar(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - char *iov = *((char **) data); - int ret = 0; - - if (param & SET) { - switch(param & PARAM_TYPE) { - case INT: - ret = wl_bssiovar_setint(interface, iov, vif, *val); - } - } - if (param & GET) { - switch(param & PARAM_TYPE) { - case INT: - ret = wl_bssiovar_get(interface, iov, vif, val, sizeof(int)); - } - } - - return ret; -} - -static int wlc_vif_enabled(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - int buf[3]; - int ret = 0; - - sprintf((char *) buf, "bss"); - buf[1] = vif; - if (param & SET) { - buf[2] = (*val ? 1 : 0); - ret = wl_ioctl(interface, WLC_SET_VAR, buf, sizeof(buf)); - } else if (param & GET) { - ret = wl_ioctl(interface, WLC_GET_VAR, buf, sizeof(buf)); - *val = buf[0]; - } - - return ret; -} - -static int wlc_ssid(wlc_param param, void *data, void *value) -{ - int ret = -1, ret2 = -1; - char *dest = (char *) value; - wlc_ssid_t ssid; - - if ((param & PARAM_MODE) == GET) { - ret = wl_bssiovar_get(interface, "ssid", vif, &ssid, sizeof(ssid)); - - if (ret) - /* if we can't get the ssid through the bssiovar, try WLC_GET_SSID */ - ret = wl_ioctl(interface, WLC_GET_SSID, &ssid, sizeof(ssid)); - - if (!ret) { - memcpy(dest, ssid.SSID, ssid.SSID_len); - dest[ssid.SSID_len] = 0; - } - } else if ((param & PARAM_MODE) == SET) { - strncpy(ssid.SSID, value, 32); - ssid.SSID_len = strlen(value); - - if (ssid.SSID_len > 32) - ssid.SSID_len = 32; - - if (vif == 0) { - /* for the main interface, also try the WLC_SET_SSID call */ - ret2 = wl_ioctl(interface, WLC_SET_SSID, &ssid, sizeof(ssid)); - } - - ret = wl_bssiovar_set(interface, "ssid", vif, &ssid, sizeof(ssid)); - ret = (!ret2 ? 0 : ret); - } - - return ret; -} - -static int wlc_int(wlc_param param, void *data, void *value) -{ - int *var = *((int **) data); - int *val = (int *) value; - - if ((param & PARAM_MODE) == SET) { - *var = *val; - } else if ((param & PARAM_MODE) == GET) { - *val = *var; - } - - return 0; -} - -static int wlc_flag(wlc_param param, void *data, void *value) -{ - int *var = *((int **) data); - - *var = 1; - - return 0; -} - -static int wlc_string(wlc_param param, void *data, void *value) -{ - char *var = *((char **) data); - - if ((param & PARAM_MODE) == GET) { - strcpy(value, var); - } - - return 0; -} - -static int wlc_afterburner(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - int ret = 0; - - if ((param & PARAM_MODE) == GET) { - ret = wl_iovar_get(interface, "afterburner", val, sizeof(int)); - } else { - wl_iovar_setint(interface, "wlfeatureflag", (*val ? 3 : 0)); - ret = wl_iovar_setint(interface, "afterburner", (*val ? 1 : 0)); - wl_iovar_setint(interface, "afterburner_override", *val); - } - - return ret; -} - -static int wlc_maclist(wlc_param param, void *data, void *value) -{ - unsigned int *var = ((unsigned int *) data); - unsigned int ioc = *var; - int limit = (sizeof(wlbuf) - 4) / sizeof(struct ether_addr); - struct maclist *list = (struct maclist *) wlbuf; - char *str = (char *) value; - char astr[30], *p; - struct ether_addr *addr; - int isset = 0; - int ret; - - if ((param & PARAM_MODE) == GET) { - list->count = limit; - ret = wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf)); - - if (!ret) - while (list->count) { - str += sprintf(str, "%s", ((((char *) value) == str) ? "" : " ")); - str += my_ether_ntoa((unsigned char *) &list->ea[list->count-- - 1], str); - } - - return ret; - } else { - while (*str && isspace(*str)) - *str++; - - if (*str == '+') { - str++; - - list->count = limit; - if (wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf)) == 0) - isset = 1; - - while (*str && isspace(*str)) - str++; - } - - if (!isset) - memset(wlbuf, 0, sizeof(wlbuf)); - - foreach(astr, str, p) { - if (list->count >= limit) - break; - - if ((addr = ether_aton(astr)) != NULL) - memcpy(&list->ea[list->count++], addr, sizeof(struct ether_addr)); - } - - return wl_ioctl(interface, ioc & 0xffff, wlbuf, sizeof(wlbuf)); - } -} - -static int wlc_radio(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - int ret; - - if ((param & PARAM_MODE) == GET) { - ret = wl_ioctl(interface, WLC_GET_RADIO, val, sizeof(int)); - *val = ((*val & 1) ? 0 : 1); - } else { - *val = (1 << 16) | (*val ? 0 : 1); - ret = wl_ioctl(interface, WLC_SET_RADIO, val, sizeof(int)); - } - - return ret; -} - -static int wlc_wsec_key(wlc_param param, void *null, void *value) -{ - wl_wsec_key_t wsec_key; - unsigned char *index = value; - unsigned char *key; - unsigned char *data; - unsigned char hex[3]; - - if ((param & PARAM_MODE) != SET) - return 0; - - memset(&wsec_key, 0, sizeof(wsec_key)); - if (index[0] == '=') { - wsec_key.flags = WL_PRIMARY_KEY; - index++; - } - - if ((index[0] < '1') || (index[0] > '4') || (index[1] != ',')) - return -1; - - key = index + 2; - if (strncmp(key, "d:", 2) == 0) { /* delete key */ - } else if (strncmp(key, "s:", 2) == 0) { /* ascii key */ - key += 2; - wsec_key.len = strlen(key); - - if ((wsec_key.len != 5) && (wsec_key.len != 13)) - return -1; - - strcpy(wsec_key.data, key); - } else { /* hex key */ - wsec_key.len = strlen(key); - if ((wsec_key.len != 10) && (wsec_key.len != 26)) - return -1; - - wsec_key.len /= 2; - data = wsec_key.data; - hex[2] = 0; - do { - hex[0] = *(key++); - hex[1] = *(key++); - *(data++) = (unsigned char) strtoul(hex, NULL, 16); - } while (*key != 0); - } - - return wl_bssiovar_set(interface, "wsec_key", vif, &wsec_key, sizeof(wsec_key)); -} - -static int wlc_cap(wlc_param param, void *data, void *value) -{ - char *iov = *((char **) data); - - if (param & GET) - return wl_iovar_get(interface, iov, value, BUFSIZE); - - return -1; -} - -static int wlc_bssmax(wlc_param param, void *data, void *value) -{ - int *val = (int *) value; - char *iov = *((char **) data); - int ret = -1; - - if (param & GET) { - ret = wl_iovar_get(interface, iov, wlbuf, BUFSIZE); - if (!ret) { - if (strstr(wlbuf, "mbss4")) - *val = 4; - else if (strstr(wlbuf, "mbss16")) - *val = 16; - else - *val = 1; - } - } - - return ret; -} - -static inline int cw2ecw(int cw) -{ - int i; - for (cw++, i = 0; cw; i++) cw >>=1; - return i - 1; -} - -static int wlc_wme_ac(wlc_param param, void *data, void *value) -{ - char *type = *((char **) data); - char *settings = (char *) value; - char cmd[100], *p, *val; - edcf_acparam_t params[AC_COUNT]; - int ret; - int intval; - int cur = -1; - char *buf = wlbuf; - - if ((param & PARAM_MODE) != SET) - return -1; - - memset(params, 0, sizeof(params)); - ret = wl_iovar_get(interface, type, params, sizeof(params)); - memset(buf, 0, BUFSIZE); - strcpy(buf, type); - buf += strlen(buf) + 1; - - foreach(cmd, settings, p) { - val = strchr(cmd, '='); - if (val == NULL) { - if (strcmp(cmd, "be") == 0) - cur = AC_BE; - else if (strcmp(cmd, "bk") == 0) - cur = AC_BK; - else if (strcmp(cmd, "vi") == 0) - cur = AC_VI; - else if (strcmp(cmd, "vo") == 0) - cur = AC_VO; - else - return -1; - - /* just in case */ - params[cur].ACI = (params[cur].ACI & (0x3 << 5)) | (cur << 5); - } else { - *(val++) = 0; - - intval = strtoul(val, NULL, 10); - if (strcmp(cmd, "cwmin") == 0) - params[cur].ECW = (params[cur].ECW & ~(0xf)) | cw2ecw(intval); - else if (strcmp(cmd, "ecwmin") == 0) - params[cur].ECW = (params[cur].ECW & ~(0xf)) | (intval & 0xf); - else if (strcmp(cmd, "cwmax") == 0) - params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | (cw2ecw(intval) << 4); - else if (strcmp(cmd, "ecwmax") == 0) - params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | ((intval & 0xf) << 4); - else if (strcmp(cmd, "aifsn") == 0) - params[cur].ACI = (params[cur].ACI & ~(0xf)) | (intval & 0xf); - else if (strcmp(cmd, "txop") == 0) - params[cur].TXOP = intval >> 5; - else if (strcmp(cmd, "force") == 0) - params[cur].ACI = (params[cur].ACI & ~(1 << 4)) | ((intval) ? (1 << 4) : 0); - else return -1; - - memcpy(buf, ¶ms[cur], sizeof(edcf_acparam_t)); - wl_ioctl(interface, WLC_SET_VAR, wlbuf, BUFSIZE); - } - } - return ret; -} - -static int wlc_ifname(wlc_param param, void *data, void *value) -{ - char *val = (char *) value; - int ret = 0; - - if (param & SET) { - if (strlen(val) < 16) - strcpy(interface, val); - else ret = -1; - } - if (param & GET) { - strcpy(val, interface); - } - - return ret; -} - -static int wlc_wdsmac(wlc_param param, void *data, void *value) -{ - unsigned char mac[6]; - int ret = 0; - - ret = wl_ioctl(interface, WLC_WDS_GET_REMOTE_HWADDR, &mac, 6); - if (ret == 0) - my_ether_ntoa(mac, value); - - return ret; -} - -static int wlc_pmk(wlc_param param, void *data, void *value) -{ - int ret = -1; - char *str = (char *) value; - wsec_pmk_t pmk; - - /* driver doesn't support GET */ - - if ((param & PARAM_MODE) == SET) { - strncpy(pmk.key, str, WSEC_MAX_PSK_LEN); - pmk.key_len = strlen(str); - - if (pmk.key_len > WSEC_MAX_PSK_LEN) - pmk.key_len = WSEC_MAX_PSK_LEN; - - pmk.flags = WSEC_PASSPHRASE; - - ret = wl_ioctl(interface, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk)); - } - - return ret; -} - -static const struct wlc_call wlc_calls[] = { - { - .name = "version", - .param = STRING|NOARG, - .handler = wlc_string, - .data.str = VERSION, - .desc = "Version of this program" - }, - { - .name = "debug", - .param = INT, - .handler = wlc_int, - .data.ptr = &debug, - .desc = "wlc debug level" - }, - { - .name = "stdin", - .param = NOARG, - .handler = wlc_flag, - .data.ptr = &fromstdin, - .desc = "Accept input from stdin" - }, - { - .name = "ifname", - .param = STRING, - .handler = wlc_ifname, - .desc = "interface to send commands to" - }, - { - .name = "up", - .param = NOARG, - .handler = wlc_ioctl, - .data.num = WLC_UP, - .desc = "Bring the interface up" - }, - { - .name = "down", - .param = NOARG, - .handler = wlc_ioctl, - .data.num = WLC_DOWN, - .desc = "Bring the interface down" - }, - { - .name = "radio", - .param = INT, - .handler = wlc_radio, - .desc = "Radio enabled flag" - }, - { - .name = "ap", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_AP << 16) | WLC_SET_AP), - .desc = "Access Point mode" - }, - { - .name = "mssid", - .param = INT, - .handler = wlc_iovar, - .data.str = "mbss", - .desc = "Multi-ssid mode" - }, - { - .name = "apsta", - .param = INT, - .handler = wlc_iovar, - .data.str = "apsta", - .desc = "AP+STA mode" - }, - { - .name = "infra", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_INFRA << 16) | WLC_SET_INFRA), - .desc = "Infrastructure mode" - }, - { - .name = "wet", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_WET << 16) | WLC_SET_WET), - .desc = "Wireless repeater mode", - }, - { - .name = "statimeout", - .param = INT, - .handler = wlc_iovar, - .data.str = "sta_retry_time", - .desc = "STA connection timeout" - }, - { - .name = "country", - .param = STRING, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_COUNTRY << 16) | WLC_SET_COUNTRY), - .desc = "Country code" - }, - { - .name = "channel", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_CHANNEL << 16) | WLC_SET_CHANNEL), - .desc = "Channel", - }, - { - .name = "vlan_mode", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "vlan_mode", - .desc = "Parse 802.1Q tags", - }, - { - .name = "vif", - .param = INT, - .handler = wlc_int, - .data.ptr = &vif, - .desc = "Current vif index" - }, - { - .name = "enabled", - .param = INT, - .handler = wlc_vif_enabled, - .desc = "vif enabled flag" - }, - { - .name = "ssid", - .param = STRING, - .handler = wlc_ssid, - .desc = "Interface ESSID" - }, - { - .name = "closed", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "closednet", - .desc = "Hidden ESSID flag" - }, - { - .name = "wsec", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "wsec", - .desc = "Security mode flags" - }, - { - .name = "wepkey", - .param = STRING, - .handler = wlc_wsec_key, - .desc = "Set/Remove WEP keys" - }, - { - .name = "wepauth", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_AUTH << 16) | WLC_SET_AUTH), - .desc = "WEP authentication type. 0 = OpenSystem, 1 = SharedKey" - }, - { - .name = "wsec_restrict", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "wsec_restrict", - .desc = "Drop unencrypted traffic" - }, - { - .name = "eap_restrict", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "eap_restrict", - .desc = "Only allow 802.1X traffic until 802.1X authorized" - }, - { - .name = "wpa_auth", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "wpa_auth", - .desc = "WPA authentication modes" - }, - { - .name = "ap_isolate", - .param = INT, - .handler = wlc_bssiovar, - .data.str = "ap_isolate", - .desc = "Isolate connected clients" - }, - { - .name = "supplicant", - .param = INT, - .handler = wlc_iovar, - .data.str = "sup_wpa", - .desc = "Built-in WPA supplicant" - }, - { - .name = "passphrase", - .param = STRING, - .handler = wlc_pmk, - .desc = "Passphrase for built-in WPA supplicant", - }, - { - .name = "maxassoc", - .param = INT, - .handler = wlc_iovar, - .data.str = "maxassoc", - .desc = "Max. number of associated clients", - }, - { - .name = "wme", - .param = INT, - .handler = wlc_iovar, - .data.str = "wme", - .desc = "WME enabled" - }, - { - .name = "wme_ac_ap", - .param = STRING, - .handler = wlc_wme_ac, - .data.str = "wme_ac_ap", - .desc = "Set WME AC options for AP mode", - }, - { - .name = "wme_ac_sta", - .param = STRING, - .handler = wlc_wme_ac, - .data.str = "wme_ac_sta", - .desc = "Set WME AC options for STA mode", - }, - { - .name = "wme_noack", - .param = INT, - .handler = wlc_iovar, - .data.str = "wme_noack", - .desc = "WME ACK disable request", - }, - { - .name = "802.11d", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_REGULATORY << 16) | WLC_SET_REGULATORY), - .desc = "Enable/disable 802.11d regulatory management", - }, - { - .name = "802.11h", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_SPECT_MANAGMENT << 16) | WLC_SET_SPECT_MANAGMENT), - .desc = "Enable/disable 802.11h spectrum management", - }, - { - .name = "fragthresh", - .param = INT, - .handler = wlc_iovar, - .data.str = "fragthresh", - .desc = "Fragmentation threshold", - }, - { - .name = "rtsthresh", - .param = INT, - .handler = wlc_iovar, - .data.str = "rtsthresh", - .desc = "RTS threshold" - }, - { - .name = "slottime", - .param = INT, - .handler = wlc_iovar, - .data.str = "acktiming", - .desc = "Slot time" - }, - { - .name = "rxant", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_ANTDIV << 16) | WLC_SET_ANTDIV), - .desc = "Rx antenna selection" - }, - { - .name = "txant", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_TXANT << 16) | WLC_SET_TXANT), - .desc = "Tx antenna selection" - }, - { - .name = "dtim", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_DTIMPRD << 16) | WLC_SET_DTIMPRD), - .desc = "DTIM period", - }, - { - .name = "bcn", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_BCNPRD << 16) | WLC_SET_BCNPRD), - .desc = "Beacon interval" - }, - { - .name = "frameburst", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_FAKEFRAG << 16) | WLC_SET_FAKEFRAG), - .desc = "Framebursting" - }, - { - .name = "monitor", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_MONITOR << 16) | WLC_SET_MONITOR), - .desc = "Monitor mode" - }, - { - .name = "passive_scan", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_PASSIVE_SCAN << 16) | WLC_SET_PASSIVE_SCAN), - .desc = "Passive scan mode" - }, - { - .name = "macfilter", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_MACMODE << 16) | WLC_SET_MACMODE), - .desc = "MAC filter mode (0:disabled, 1:deny, 2:allow)" - }, - { - .name = "maclist", - .param = STRING, - .data.num = ((WLC_GET_MACLIST << 16) | WLC_SET_MACLIST), - .handler = wlc_maclist, - .desc = "MAC filter list" - }, - { - .name = "autowds", - .param = INT, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_LAZYWDS << 16) | WLC_SET_LAZYWDS), - .desc = "Automatic WDS" - }, - { - .name = "wds", - .param = STRING, - .data.num = ((WLC_GET_WDSLIST << 16) | WLC_SET_WDSLIST), - .handler = wlc_maclist, - .desc = "WDS connection list" - }, - { - .name = "wdstimeout", - .param = INT, - .handler = wlc_iovar, - .data.str = "wdstimeout", - .desc = "WDS link detection timeout" - }, - { - .name = "wdsmac", - .param = STRING|NOARG, - .handler = wlc_wdsmac, - .desc = "MAC of the remote WDS endpoint (only with wds0.* interfaces)" - }, - { - .name = "afterburner", - .param = INT, - .handler = wlc_afterburner, - .desc = "Broadcom Afterburner" - }, - { - .name = "ibss_merge", - .param = INT, - .handler = wlc_iovar, - .data.str = "ibss_coalesce_allowed", - .desc = "Allow IBSS merges" - }, - { - .name = "bssid", - .param = MAC, - .handler = wlc_ioctl, - .data.num = ((WLC_GET_BSSID << 16) | WLC_SET_BSSID), - .desc = "BSSID" - }, - { - .name = "cur_etheraddr", - .param = MAC, - .handler = wlc_iovar, - .data.str = "cur_etheraddr", - .desc = "Current MAC Address" - }, - { - .name = "default_bssid", - .param = MAC, - .handler = wlc_iovar, - .data.str = "perm_etheraddr", - .desc = "Default BSSID (read-only)" - }, - { - .name = "assoclist", - .param = STRING, - .data.num = (WLC_GET_ASSOCLIST << 16), - .handler = wlc_maclist, - .desc = "MACs of associated stations" - }, - { - .name = "gmode", - .param = INT, - .data.num = ((WLC_GET_GMODE << 16) | WLC_SET_GMODE), - .handler = wlc_ioctl, - .desc = "G Mode" - }, - { - .name = "phytype", - .param = INT, - .data.num = (WLC_GET_PHYTYPE << 16), - .handler = wlc_ioctl, - .desc = "PHY Type (read-only)" - }, - { - .name = "nmode", - .param = INT, - .handler = wlc_iovar, - .data.str = "nmode", - .desc = "N Mode" - }, - { - .name = "nreqd", - .param = INT, - .handler = wlc_iovar, - .data.str = "nreqd", - .desc = "N Mode required" - }, - { - .name = "chanspec", - .param = INT, - .handler = wlc_iovar, - .data.str = "chanspec", - .desc = "Channel Spec (See bcmwifi.h)" - }, - { - .name = "band", - .param = INT, - .data.num = ((WLC_GET_BAND << 16) | WLC_SET_BAND), - .handler = wlc_ioctl, - .desc = "Band (0=auto, 1=5Ghz, 2=2.4GHz)" - }, - { - .name = "cap", - .param = STRING|NOARG, - .handler = wlc_cap, - .data.str = "cap", - .desc = "Capabilities" - }, - { - .name = "bssmax", - .param = INT|NOARG, - .handler = wlc_bssmax, - .data.str = "cap", - .desc = "Number of VIF's supported" - }, - { - .name = "leddc", - .param = INT, - .handler = wlc_iovar, - .data.str = "leddc", - .desc = "LED Duty Cycle" - }, - -}; -#define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call)) - -static void usage(char *cmd) -{ - int i; - fprintf(stderr, "Usage: %s <command> [<argument> ...]\n" - "\n" - "Available commands:\n", cmd); - for (i = 0; i < wlc_calls_size; i++) { - fprintf(stderr, "\t%-16s\t%s\n", wlc_calls[i].name ?: "", wlc_calls[i].desc ?: ""); - } - fprintf(stderr, "\n"); - exit(1); -} - -static int do_command(const struct wlc_call *cmd, char *arg) -{ - static char buf[BUFSIZE]; - int set; - int ret = 0; - char *format, *end; - int intval; - void *ptr = (void *) buf; - - if (debug >= 10) { - fprintf(stderr, "do_command %-16s\t'%s'\n", cmd->name, arg); - } - - if ((arg == NULL) && ((cmd->param & PARAM_TYPE) != NONE)) { - set = 0; - ret = cmd->handler(cmd->param | GET, (void *) &cmd->data, (void *) buf); - if (ret == 0) { - switch(cmd->param & PARAM_TYPE) { - case INT: - intval = *((int *) buf); - - if (intval > 65535) - format = "0x%08x\n"; - else if (intval > 255) - format = "0x%04x\n"; - else - format = "%d\n"; - - fprintf(stdout, format, intval); - break; - case STRING: - fprintf(stdout, "%s\n", buf); - break; - case MAC: - my_ether_ntoa(buf, buf + 6); - fprintf(stdout, "%s\n", buf + 6); - break; - } - } - } else { /* SET */ - set = 1; - switch(cmd->param & PARAM_TYPE) { - case INT: - intval = strtoul(arg, &end, 0); - if (end && !(*end)) { - memcpy(buf, &intval, sizeof(intval)); - } else { - fprintf(stderr, "%s: Invalid argument\n", cmd->name); - return -1; - } - break; - case STRING: - strncpy(buf, arg, BUFSIZE); - buf[BUFSIZE - 1] = 0; - break; - case MAC: - ptr = ether_aton(arg); - if (!ptr) { - fprintf(stderr, "%s: Invalid mac address '%s'\n", cmd->name, arg); - return -1; - } - break; - } - - ret = cmd->handler(cmd->param | SET, (void *) &cmd->data, ptr); - } - - if ((debug > 0) && (ret != 0)) - fprintf(stderr, "Command '%s %s' failed: %d\n", (set == 1 ? "set" : "get"), cmd->name, ret); - - return ret; -} - -static struct wlc_call *find_cmd(char *name) -{ - int found = 0, i = 0; - - while (!found && (i < wlc_calls_size)) { - if (strcmp(name, wlc_calls[i].name) == 0) - found = 1; - else - i++; - } - - return (struct wlc_call *) (found ? &wlc_calls[i] : NULL); -} - -int main(int argc, char **argv) -{ - static char buf[BUFSIZE]; - char *s, *s2; - char *cmd = argv[0]; - struct wlc_call *call; - int ret = 0; - - if (argc < 2) - usage(argv[0]); - - for(interface[2] = '0'; (interface[2] < '3') && (wl_probe(interface) != 0); interface[2]++); - if (interface[2] == '3') { - fprintf(stderr, "No Broadcom wl interface found!\n"); - return -1; - } - - argv++; - argc--; - while ((argc > 0) && (argv[0] != NULL)) { - if ((call = find_cmd(argv[0])) == NULL) { - fprintf(stderr, "Invalid command: %s\n\n", argv[0]); - usage(cmd); - } - if ((argc > 1) && (!(call->param & NOARG))) { - ret = do_command(call, argv[1]); - argv += 2; - argc -= 2; - } else { - ret = do_command(call, NULL); - argv++; - argc--; - } - } - - while (fromstdin && !feof(stdin)) { - *buf = 0; - fgets(buf, BUFSIZE - 1, stdin); - - if (*buf == 0) - continue; - - if ((s = strchr(buf, '\r')) != NULL) - *s = 0; - if ((s = strchr(buf, '\n')) != NULL) - *s = 0; - - s = buf; - while (isspace(*s)) - s++; - - if (!*s) - continue; - - if ((s2 = strchr(s, ' ')) != NULL) - *(s2++) = 0; - - while (s2 && isspace(*s2)) - s2++; - - if ((call = find_cmd(s)) == NULL) { - fprintf(stderr, "Invalid command: %s\n", s); - ret = -1; - } else - ret = do_command(call, ((call->param & NOARG) ? NULL : s2)); - } - - return ret; -} diff --git a/package/kernel/button-hotplug/Makefile b/package/kernel/button-hotplug/Makefile index 55412e56854..8e8c02609c8 100644 --- a/package/kernel/button-hotplug/Makefile +++ b/package/kernel/button-hotplug/Makefile @@ -28,23 +28,8 @@ define KernelPackage/button-hotplug/description If your device uses GPIO buttons, see gpio-button-hotplug. endef -EXTRA_KCONFIG:= \ - CONFIG_BUTTON_HOTPLUG=m - -EXTRA_CFLAGS:= \ - $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \ - $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \ - -MAKE_OPTS:= \ - $(KERNEL_MAKE_FLAGS) \ - M="$(PKG_BUILD_DIR)" \ - EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ - $(EXTRA_KCONFIG) - define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules endef $(eval $(call KernelPackage,button-hotplug)) diff --git a/package/kernel/button-hotplug/src/Kconfig b/package/kernel/button-hotplug/src/Kconfig deleted file mode 100644 index aa292e9c13c..00000000000 --- a/package/kernel/button-hotplug/src/Kconfig +++ /dev/null @@ -1,2 +0,0 @@ -config BUTTON_HOTPLUG - tristate "Button Hotplug driver" diff --git a/package/kernel/button-hotplug/src/Makefile b/package/kernel/button-hotplug/src/Makefile index 230d604f8c4..e38fa40bb43 100644 --- a/package/kernel/button-hotplug/src/Makefile +++ b/package/kernel/button-hotplug/src/Makefile @@ -1 +1 @@ -obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o
\ No newline at end of file +obj-m := button-hotplug.o diff --git a/package/kernel/cryptodev-linux/Makefile b/package/kernel/cryptodev-linux/Makefile index 85065e4eeb6..0c1f63a6055 100644 --- a/package/kernel/cryptodev-linux/Makefile +++ b/package/kernel/cryptodev-linux/Makefile @@ -10,12 +10,12 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=cryptodev-linux -PKG_VERSION:=1.11 +PKG_VERSION:=1.12 PKG_RELEASE:=1 PKG_SOURCE_URL:=https://codeload.github.com/$(PKG_NAME)/$(PKG_NAME)/tar.gz/$(PKG_NAME)-$(PKG_VERSION)? PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_HASH:=d71fd8dafc40147586f5bc6acca8fce5088d9c576d1142fe5aeb7b0813186a11 +PKG_HASH:=f51c2254749233b1b1d7ec9445158bd709f124f88e1c650fe2faac83c3a81938 PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING diff --git a/package/kernel/cryptodev-linux/patches/010-fix-build-for-kernel-v5.9-rc1.patch b/package/kernel/cryptodev-linux/patches/010-fix-build-for-kernel-v5.9-rc1.patch deleted file mode 100644 index 09768a1f3aa..00000000000 --- a/package/kernel/cryptodev-linux/patches/010-fix-build-for-kernel-v5.9-rc1.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2f5e08aebf9229599aae7f25db752f74221cd71d Mon Sep 17 00:00:00 2001 -From: Joan Bruguera <joanbrugueram@gmail.com> -Date: Fri, 14 Aug 2020 00:13:38 +0200 -Subject: [PATCH] Fix build for Linux 5.9-rc1 - -See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=64019a2e467a288a16b65ab55ddcbf58c1b00187 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bce617edecada007aee8610fbe2c14d10b8de2f6 - https://lore.kernel.org/lkml/CAHk-=wj_V2Tps2QrMn20_W0OJF9xqNh52XSGA42s-ZJ8Y+GyKw@mail.gmail.com/ - -Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com> ---- - zc.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - ---- a/zc.c -+++ b/zc.c -@@ -76,10 +76,14 @@ int __get_userbuf(uint8_t __user *addr, - ret = get_user_pages_remote(task, mm, - (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, - pg, NULL); --#else -+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)) - ret = get_user_pages_remote(task, mm, - (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, - pg, NULL, NULL); -+#else -+ ret = get_user_pages_remote(mm, -+ (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, -+ pg, NULL, NULL); - #endif - #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)) - up_read(&mm->mmap_sem); diff --git a/package/kernel/gpio-button-hotplug/Makefile b/package/kernel/gpio-button-hotplug/Makefile index 09f9c00e990..04cbb69ada9 100644 --- a/package/kernel/gpio-button-hotplug/Makefile +++ b/package/kernel/gpio-button-hotplug/Makefile @@ -15,7 +15,7 @@ PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk define KernelPackage/gpio-button-hotplug - SUBMENU:=Other modules + SUBMENU:=GPIO support TITLE:=Simple GPIO Button Hotplug driver FILES:=$(PKG_BUILD_DIR)/gpio-button-hotplug.ko AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug,1) @@ -32,14 +32,8 @@ define KernelPackage/gpio-button-hotplug/description an overkill for OpenWrt simple needs. endef -MAKE_OPTS:= \ - $(KERNEL_MAKE_FLAGS) \ - M="$(PKG_BUILD_DIR)" - define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules endef $(eval $(call KernelPackage,gpio-button-hotplug)) diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c index 9575c6245b7..522085bb2fa 100644 --- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c @@ -107,7 +107,7 @@ static struct bh_map button_map[] = { static __printf(3, 4) int bh_event_add_var(struct bh_event *event, int argv, const char *format, ...) { - static char buf[128]; + char buf[128]; char *s; va_list args; int len; @@ -242,11 +242,11 @@ static int gpio_button_get_value(struct gpio_keys_button_data *bdata) int val; if (bdata->can_sleep) - val = !!gpio_get_value_cansleep(bdata->b->gpio); + val = !!gpiod_get_value_cansleep(bdata->gpiod); else - val = !!gpio_get_value(bdata->b->gpio); + val = !!gpiod_get_value(bdata->gpiod); - return val ^ bdata->b->active_low; + return val; } static void gpio_keys_handle_button(struct gpio_keys_button_data *bdata) @@ -365,7 +365,6 @@ gpio_keys_get_devtree_pdata(struct device *dev) struct device_node *node, *pp; struct gpio_keys_platform_data *pdata; struct gpio_keys_button *button; - int error; int nbuttons; int i = 0; @@ -375,14 +374,12 @@ gpio_keys_get_devtree_pdata(struct device *dev) nbuttons = of_get_child_count(node); if (nbuttons == 0) - return NULL; + return ERR_PTR(-EINVAL); pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * (sizeof *button), GFP_KERNEL); - if (!pdata) { - error = -ENOMEM; - goto err_out; - } + if (!pdata) + return ERR_PTR(-ENOMEM); pdata->buttons = (struct gpio_keys_button *)(pdata + 1); pdata->nbuttons = nbuttons; @@ -391,37 +388,13 @@ gpio_keys_get_devtree_pdata(struct device *dev) of_property_read_u32(node, "poll-interval", &pdata->poll_interval); for_each_child_of_node(node, pp) { - enum of_gpio_flags flags; - - if (!of_find_property(pp, "gpios", NULL)) { - pdata->nbuttons--; - dev_warn(dev, "Found button without gpios\n"); - continue; - } - button = (struct gpio_keys_button *)(&pdata->buttons[i++]); - button->irq = irq_of_parse_and_map(pp, 0); - - button->gpio = of_get_gpio_flags(pp, 0, &flags); - if (button->gpio < 0) { - error = button->gpio; - if (error != -ENOENT) { - if (error != -EPROBE_DEFER) - dev_err(dev, - "Failed to get gpio flags, error: %d\n", - error); - return ERR_PTR(error); - } - } else { - button->active_low = !!(flags & OF_GPIO_ACTIVE_LOW); - } - if (of_property_read_u32(pp, "linux,code", &button->code)) { - dev_err(dev, "Button without keycode: 0x%x\n", - button->gpio); - error = -EINVAL; - goto err_out; + dev_err(dev, "Button node '%s' without keycode\n", + pp->full_name); + of_node_put(pp); + return ERR_PTR(-EINVAL); } button->desc = of_get_property(pp, "label", NULL); @@ -434,17 +407,12 @@ gpio_keys_get_devtree_pdata(struct device *dev) if (of_property_read_u32(pp, "debounce-interval", &button->debounce_interval)) button->debounce_interval = 5; - } - if (pdata->nbuttons == 0) { - error = -EINVAL; - goto err_out; + button->irq = irq_of_parse_and_map(pp, 0); + button->gpio = -ENOENT; /* mark this as device-tree */ } return pdata; - -err_out: - return ERR_PTR(error); } static struct of_device_id gpio_keys_of_match[] = { @@ -471,11 +439,12 @@ gpio_keys_get_devtree_pdata(struct device *dev) static int gpio_keys_button_probe(struct platform_device *pdev, struct gpio_keys_button_dev **_bdev, int polled) { - struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct device *dev = &pdev->dev; + struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); struct gpio_keys_button_dev *bdev; struct gpio_keys_button *buttons; - int error; + struct device_node *prev = NULL; + int error = 0; int i; if (!pdata) { @@ -514,46 +483,74 @@ static int gpio_keys_button_probe(struct platform_device *pdev, for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &buttons[i]; struct gpio_keys_button_data *bdata = &bdev->data[i]; - unsigned int gpio = button->gpio; + const char *desc = button->desc ? button->desc : DRV_NAME; if (button->wakeup) { dev_err(dev, "does not support wakeup\n"); - return -EINVAL; + error = -EINVAL; + goto out; } bdata->map_entry = button_get_index(button->code); if (bdata->map_entry < 0) { - dev_warn(dev, "does not support key code:%u\n", + dev_err(dev, "does not support key code:%u\n", button->code); - continue; + error = -EINVAL; + goto out; } if (!(button->type == 0 || button->type == EV_KEY || button->type == EV_SW)) { - dev_warn(dev, "only supports buttons or switches\n"); + dev_err(dev, "only supports buttons or switches\n"); + error = -EINVAL; + goto out; + } + + if (button->irq) { + dev_err(dev, "skipping button %s (only gpio buttons supported)\n", + button->desc); + bdata->b = &pdata->buttons[i]; continue; } - error = devm_gpio_request(dev, gpio, - button->desc ? button->desc : DRV_NAME); - if (error) { - dev_err(dev, "unable to claim gpio %u, err=%d\n", - gpio, error); - return error; + if (gpio_is_valid(button->gpio)) { + /* legacy platform data... but is it the lookup table? */ + bdata->gpiod = devm_gpiod_get_index(dev, desc, i, + GPIOD_IN); + if (IS_ERR(bdata->gpiod)) { + /* or the legacy (button->gpio is good) way? */ + error = devm_gpio_request_one(dev, + button->gpio, GPIOF_IN | ( + button->active_low ? GPIOF_ACTIVE_LOW : + 0), desc); + if (error) { + if (error != -EPROBE_DEFER) { + dev_err(dev, "unable to claim gpio %d, err=%d\n", + button->gpio, error); + } + goto out; + } + + bdata->gpiod = gpio_to_desc(button->gpio); + } + } else { + /* Device-tree */ + struct device_node *child = + of_get_next_child(dev->of_node, prev); + + bdata->gpiod = devm_gpiod_get_from_of_node(dev, + child, "gpios", 0, GPIOD_IN, desc); + + prev = child; } - bdata->gpiod = gpio_to_desc(gpio); - if (!bdata->gpiod) - return -EINVAL; - error = gpio_direction_input(gpio); - if (error) { - dev_err(dev, - "unable to set direction on gpio %u, err=%d\n", - gpio, error); - return error; + if (IS_ERR_OR_NULL(bdata->gpiod)) { + error = IS_ERR(bdata->gpiod) ? PTR_ERR(bdata->gpiod) : + -EINVAL; + goto out; } - bdata->can_sleep = gpio_cansleep(gpio); + bdata->can_sleep = gpiod_cansleep(bdata->gpiod); bdata->last_state = -1; /* Unknown state on boot */ if (bdev->polled) { @@ -584,8 +581,11 @@ static int gpio_keys_button_probe(struct platform_device *pdev, platform_set_drvdata(pdev, bdev); *_bdev = bdev; + error = 0; - return 0; +out: + of_node_put(prev); + return error; } static int gpio_keys_probe(struct platform_device *pdev) @@ -594,9 +594,7 @@ static int gpio_keys_probe(struct platform_device *pdev) struct gpio_keys_button_dev *bdev; int ret, i; - ret = gpio_keys_button_probe(pdev, &bdev, 0); - if (ret) return ret; @@ -608,12 +606,8 @@ static int gpio_keys_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&bdata->work, gpio_keys_irq_work_func); - if (!bdata->gpiod) - continue; - if (!button->irq) { - bdata->irq = gpio_to_irq(button->gpio); - + bdata->irq = gpiod_to_irq(bdata->gpiod); if (bdata->irq < 0) { dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", button->gpio); @@ -631,7 +625,6 @@ static int gpio_keys_probe(struct platform_device *pdev) ret = devm_request_threaded_irq(&pdev->dev, bdata->irq, NULL, button_handle_irq, irqflags, dev_name(&pdev->dev), bdata); - if (ret < 0) { bdata->irq = 0; dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", @@ -653,14 +646,12 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) int ret; ret = gpio_keys_button_probe(pdev, &bdev, 1); - if (ret) return ret; INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll); pdata = bdev->pdata; - if (pdata->enable) pdata->enable(bdev->dev); diff --git a/package/kernel/gpio-nct5104d/Makefile b/package/kernel/gpio-nct5104d/Makefile index e85639c94af..bb6010d2d02 100644 --- a/package/kernel/gpio-nct5104d/Makefile +++ b/package/kernel/gpio-nct5104d/Makefile @@ -17,7 +17,7 @@ PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk define KernelPackage/gpio-nct5104d - SUBMENU:=Other modules + SUBMENU:=GPIO support TITLE:= GPIO nct5104d support DEPENDS:= @GPIO_SUPPORT @TARGET_x86 FILES:=$(PKG_BUILD_DIR)/gpio-nct5104d.ko @@ -36,15 +36,11 @@ EXTRA_CFLAGS:= \ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \ -MAKE_OPTS:= \ - $(KERNEL_MAKE_FLAGS) \ - M="$(PKG_BUILD_DIR)" \ - EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ - $(EXTRA_KCONFIG) - define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ + $(KERNEL_MAKE) \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + $(EXTRA_KCONFIG) \ modules endef diff --git a/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c b/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c index 8f180edd33f..5343d6e3a8d 100644 --- a/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c +++ b/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c @@ -409,8 +409,6 @@ static int __init nct5104d_gpio_init(void) { int err; struct nct5104d_sio sio; - const char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); - const char *board_name = dmi_get_system_info(DMI_BOARD_NAME); if (nct5104d_find(0x2e, &sio) && nct5104d_find(0x4e, &sio)) diff --git a/package/kernel/gpio-nxp-74hc153/Makefile b/package/kernel/gpio-nxp-74hc153/Makefile deleted file mode 100644 index e275a9a856b..00000000000 --- a/package/kernel/gpio-nxp-74hc153/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2020 Mauri Sandberg <sandberg@mailfence.com> -# -# 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:=gpio-nxp-74hc153 -PKG_RELEASE:=1 -PKG_LICENSE:=GPL-2.0 - -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/gpio-nxp-74hc153 - SUBMENU:=Other modules - TITLE:= NXP 74HC153 GPIO expander - FILES:=$(PKG_BUILD_DIR)/gpio-nxp-74hc153.ko - AUTOLOAD:=$(call AutoLoad,30,gpio-nxp-74hc153,1) - KCONFIG:= - DEPENDS:= @GPIO_SUPPORT @TARGET_ath79 -endef - -define KernelPackage/gpio-nxp-74hc153/description - Platform driver for NXP 74HC153 Dual 4-input Multiplexer. - This provides a GPIO interface supporting input mode only. -endef - -define Build/Compile - $(KERNEL_MAKE) M=$(PKG_BUILD_DIR) modules -endef - -$(eval $(call KernelPackage,gpio-nxp-74hc153)) diff --git a/package/kernel/gpio-nxp-74hc153/src/Makefile b/package/kernel/gpio-nxp-74hc153/src/Makefile deleted file mode 100644 index 0a5cc2fdda3..00000000000 --- a/package/kernel/gpio-nxp-74hc153/src/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m += gpio-nxp-74hc153.o diff --git a/package/kernel/gpio-nxp-74hc153/src/gpio-nxp-74hc153.c b/package/kernel/gpio-nxp-74hc153/src/gpio-nxp-74hc153.c deleted file mode 100644 index f683547cfd6..00000000000 --- a/package/kernel/gpio-nxp-74hc153/src/gpio-nxp-74hc153.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * NXP 74HC153 - Dual 4-input multiplexer GPIO driver - * - * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> - * Copyright (C) 2020 Mauri Sandberg <sandberg@mailfence.com> - * - * 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. - * - * Example device tree definition: - * - * gpio-extender { - * compatible = "nxp,74hc153-gpio"; - * gpio-controller; - * #gpio-cells = <2>; - * - * // GPIOs used by this node - * gpio-s0 = <&gpio 9 GPIO_ACTIVE_HIGH>; - * gpio-s1 = <&gpio 11 GPIO_ACTIVE_HIGH>; - * gpio-1y = <&gpio 12 GPIO_ACTIVE_HIGH>; - * gpio-2y = <&gpio 14 GPIO_ACTIVE_HIGH>; - * }; - * - */ - -#include <linux/version.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/gpio.h> -#include <linux/slab.h> -#include <linux/platform_device.h> -#include <linux/of_gpio.h> - -#define NXP_74HC153_NUM_GPIOS 8 -#define NXP_74HC153_S0_MASK 0x1 -#define NXP_74HC153_S1_MASK 0x2 -#define NXP_74HC153_BANK_MASK 0x4 - -#define NXP_74HC153_DRIVER_NAME "nxp-74hc153" - -struct nxp_74hc153_config { - unsigned gpio_pin_s0; - unsigned gpio_pin_s1; - unsigned gpio_pin_1y; - unsigned gpio_pin_2y; -}; - -struct nxp_74hc153_chip { - struct device *parent; - struct gpio_chip gpio_chip; - struct mutex lock; - struct nxp_74hc153_config config; -}; - -static struct nxp_74hc153_chip *gpio_to_nxp(struct gpio_chip *gc) -{ - return container_of(gc, struct nxp_74hc153_chip, gpio_chip); -} - -static int nxp_74hc153_direction_input(struct gpio_chip *gc, unsigned offset) -{ - return 0; -} - -static int nxp_74hc153_direction_output(struct gpio_chip *gc, - unsigned offset, int val) -{ - return -EINVAL; -} - -static int nxp_74hc153_get_value(struct gpio_chip *gc, unsigned offset) -{ - struct nxp_74hc153_chip *nxp; - struct nxp_74hc153_platform_data *pdata; - unsigned s0; - unsigned s1; - unsigned pin; - int ret; - - nxp = gpio_to_nxp(gc); - pdata = nxp->parent->platform_data; - - s0 = !!(offset & NXP_74HC153_S0_MASK); - s1 = !!(offset & NXP_74HC153_S1_MASK); - pin = (offset & NXP_74HC153_BANK_MASK) ? nxp->config.gpio_pin_2y - : nxp->config.gpio_pin_1y; - - mutex_lock(&nxp->lock); - gpio_set_value(nxp->config.gpio_pin_s0, s0); - gpio_set_value(nxp->config.gpio_pin_s1, s1); - ret = gpio_get_value(pin); - mutex_unlock(&nxp->lock); - - return ret; -} - -static void nxp_74hc153_set_value(struct gpio_chip *gc, - unsigned offset, int val) -{ - /* not supported */ -} - -static int nxp_74hc153_probe(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - struct nxp_74hc153_chip *nxp; - struct gpio_chip *gc; - int err; - unsigned gpio_s0; - unsigned gpio_s1; - unsigned gpio_1y; - unsigned gpio_2y; - - nxp = kzalloc(sizeof(struct nxp_74hc153_chip), GFP_KERNEL); - if (nxp == NULL) { - dev_err(&pdev->dev, "no memory for private data\n"); - return -ENOMEM; - } - - gpio_s0 = of_get_named_gpio(np, "gpio-s0", 0); - gpio_s1 = of_get_named_gpio(np, "gpio-s1", 0); - gpio_1y = of_get_named_gpio(np, "gpio-1y", 0); - gpio_2y = of_get_named_gpio(np, "gpio-2y", 0); - - if (!gpio_is_valid(gpio_s0) || !gpio_is_valid(gpio_s1) || - !gpio_is_valid(gpio_1y) || !gpio_is_valid(gpio_2y)) { - - dev_err(&pdev->dev, "control GPIO(s) are missing\n"); - err = -EINVAL; - goto err_free_nxp; - } else { - nxp->config.gpio_pin_s0 = gpio_s0; - nxp->config.gpio_pin_s1 = gpio_s1; - nxp->config.gpio_pin_1y = gpio_1y; - nxp->config.gpio_pin_2y = gpio_2y; - } - - // apply pin configuration - err = gpio_request(nxp->config.gpio_pin_s0, dev_name(&pdev->dev)); - if (err) { - dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", - nxp->config.gpio_pin_s0, err); - goto err_free_nxp; - } - - err = gpio_request(nxp->config.gpio_pin_s1, dev_name(&pdev->dev)); - if (err) { - dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", - nxp->config.gpio_pin_s1, err); - goto err_free_s0; - } - - err = gpio_request(nxp->config.gpio_pin_1y, dev_name(&pdev->dev)); - if (err) { - dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", - nxp->config.gpio_pin_1y, err); - goto err_free_s1; - } - - err = gpio_request(nxp->config.gpio_pin_2y, dev_name(&pdev->dev)); - if (err) { - dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", - nxp->config.gpio_pin_2y, err); - goto err_free_1y; - } - - err = gpio_direction_output(nxp->config.gpio_pin_s0, 0); - if (err) { - dev_err(&pdev->dev, - "unable to set direction of gpio %u, err=%d\n", - nxp->config.gpio_pin_s0, err); - goto err_free_2y; - } - - err = gpio_direction_output(nxp->config.gpio_pin_s1, 0); - if (err) { - dev_err(&pdev->dev, - "unable to set direction of gpio %u, err=%d\n", - nxp->config.gpio_pin_s1, err); - goto err_free_2y; - } - - err = gpio_direction_input(nxp->config.gpio_pin_1y); - if (err) { - dev_err(&pdev->dev, - "unable to set direction of gpio %u, err=%d\n", - nxp->config.gpio_pin_1y, err); - goto err_free_2y; - } - - err = gpio_direction_input(nxp->config.gpio_pin_2y); - if (err) { - dev_err(&pdev->dev, - "unable to set direction of gpio %u, err=%d\n", - nxp->config.gpio_pin_2y, err); - goto err_free_2y; - } - - nxp->parent = &pdev->dev; - mutex_init(&nxp->lock); - - gc = &nxp->gpio_chip; - - gc->direction_input = nxp_74hc153_direction_input; - gc->direction_output = nxp_74hc153_direction_output; - gc->get = nxp_74hc153_get_value; - gc->set = nxp_74hc153_set_value; - gc->can_sleep = 1; - - gc->base = -1; - gc->ngpio = NXP_74HC153_NUM_GPIOS; - gc->label = dev_name(nxp->parent); - gc->parent = nxp->parent; - gc->owner = THIS_MODULE; - gc->of_node = np; - - err = gpiochip_add(&nxp->gpio_chip); - if (err) { - dev_err(&pdev->dev, "unable to add gpio chip, err=%d\n", err); - goto err_free_2y; - } - - platform_set_drvdata(pdev, nxp); - return 0; - -err_free_2y: - gpio_free(nxp->config.gpio_pin_2y); -err_free_1y: - gpio_free(nxp->config.gpio_pin_1y); -err_free_s1: - gpio_free(nxp->config.gpio_pin_s1); -err_free_s0: - gpio_free(nxp->config.gpio_pin_s0); -err_free_nxp: - kfree(nxp); - return err; -} - -static int nxp_74hc153_remove(struct platform_device *pdev) -{ - struct nxp_74hc153_chip *nxp = platform_get_drvdata(pdev); - - if (nxp) { - gpiochip_remove(&nxp->gpio_chip); - gpio_free(nxp->config.gpio_pin_2y); - gpio_free(nxp->config.gpio_pin_1y); - gpio_free(nxp->config.gpio_pin_s1); - gpio_free(nxp->config.gpio_pin_s0); - - kfree(nxp); - platform_set_drvdata(pdev, NULL); - } - - return 0; -} - -static struct of_device_id nxp_74hc153_id[] = { - { - .compatible = "nxp,74hc153-gpio", - .data = NULL, - }, { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, nxp_74hc153_id); - -static struct platform_driver nxp_74hc153_driver = { - .probe = nxp_74hc153_probe, - .remove = nxp_74hc153_remove, - .driver = { - .name = NXP_74HC153_DRIVER_NAME, - .owner = THIS_MODULE, - .of_match_table = nxp_74hc153_id, - }, -}; - -static int __init nxp_74hc153_init(void) -{ - return platform_driver_register(&nxp_74hc153_driver); -} -subsys_initcall(nxp_74hc153_init); - -static void __exit nxp_74hc153_exit(void) -{ - platform_driver_unregister(&nxp_74hc153_driver); -} -module_exit(nxp_74hc153_exit); - -MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>"); -MODULE_DESCRIPTION("GPIO expander driver for NXP 74HC153"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:" NXP_74HC153_DRIVER_NAME); diff --git a/package/kernel/hwmon-gsc/Makefile b/package/kernel/hwmon-gsc/Makefile deleted file mode 100644 index 8cf4e0ee796..00000000000 --- a/package/kernel/hwmon-gsc/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -include $(TOPDIR)/rules.mk -include $(INCLUDE_DIR)/kernel.mk - -PKG_NAME:=hwmon-gsc -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/hwmon-gsc - SUBMENU:=Hardware Monitoring Support - DEPENDS:=@TARGET_imx6 +kmod-hwmon-core +kmod-i2c-core - TITLE:=Driver for the Gateworks System Controller - AUTOLOAD:=$(call AutoLoad,60,gsc) - FILES:=$(PKG_BUILD_DIR)/gsc.ko -endef - -define KernelPackage/hwmon-gsc/description - Kernel module for the Gateworks System Controller chips. -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ - M="$(PKG_BUILD_DIR)" \ - EXTRA_CFLAGS="$(BUILDFLAGS)" \ - modules -endef - -$(eval $(call KernelPackage,hwmon-gsc)) diff --git a/package/kernel/hwmon-gsc/src/Makefile b/package/kernel/hwmon-gsc/src/Makefile deleted file mode 100644 index 0e54aed2e37..00000000000 --- a/package/kernel/hwmon-gsc/src/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m := gsc.o diff --git a/package/kernel/hwmon-gsc/src/gsc.c b/package/kernel/hwmon-gsc/src/gsc.c deleted file mode 100644 index 737cc599b4e..00000000000 --- a/package/kernel/hwmon-gsc/src/gsc.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * A hwmon driver for the Gateworks System Controller - * Copyright (C) 2009 Gateworks Corporation - * - * Author: Chris Lang <clang@gateworks.com> - * - * 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 - version 2. - */ - -#include <linux/module.h> -#include <linux/i2c.h> -#include <linux/hwmon.h> -#include <linux/hwmon-sysfs.h> -#include <linux/err.h> -#include <linux/slab.h> - -#define DRV_VERSION "0.2" - -enum chips { gsp }; - -/* AD7418 registers */ -#define GSP_REG_TEMP_IN 0x00 -#define GSP_REG_VIN 0x02 -#define GSP_REG_3P3 0x05 -#define GSP_REG_BAT 0x08 -#define GSP_REG_5P0 0x0b -#define GSP_REG_CORE 0x0e -#define GSP_REG_CPU1 0x11 -#define GSP_REG_CPU2 0x14 -#define GSP_REG_DRAM 0x17 -#define GSP_REG_EXT_BAT 0x1a -#define GSP_REG_IO1 0x1d -#define GSP_REG_IO2 0x20 -#define GSP_REG_PCIE 0x23 -#define GSP_REG_CURRENT 0x26 -#define GSP_FAN_0 0x2C -#define GSP_FAN_1 0x2E -#define GSP_FAN_2 0x30 -#define GSP_FAN_3 0x32 -#define GSP_FAN_4 0x34 -#define GSP_FAN_5 0x36 - -struct gsp_sensor_info { - const char* name; - int reg; -}; - -static const struct gsp_sensor_info gsp_sensors[] = { - {"temp", GSP_REG_TEMP_IN}, - {"vin", GSP_REG_VIN}, - {"3p3", GSP_REG_3P3}, - {"bat", GSP_REG_BAT}, - {"5p0", GSP_REG_5P0}, - {"core", GSP_REG_CORE}, - {"cpu1", GSP_REG_CPU1}, - {"cpu2", GSP_REG_CPU2}, - {"dram", GSP_REG_DRAM}, - {"ext_bat", GSP_REG_EXT_BAT}, - {"io1", GSP_REG_IO1}, - {"io2", GSP_REG_IO2}, - {"pci2", GSP_REG_PCIE}, - {"current", GSP_REG_CURRENT}, - {"fan_point0", GSP_FAN_0}, - {"fan_point1", GSP_FAN_1}, - {"fan_point2", GSP_FAN_2}, - {"fan_point3", GSP_FAN_3}, - {"fan_point4", GSP_FAN_4}, - {"fan_point5", GSP_FAN_5}, -}; - -struct gsp_data { - struct device *hwmon_dev; - struct attribute_group attrs; - enum chips type; -}; - -static int gsp_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int gsp_remove(struct i2c_client *client); - -static const struct i2c_device_id gsp_id[] = { - { "gsp", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, gsp_id); - -static struct i2c_driver gsp_driver = { - .driver = { - .name = "gsp", - }, - .probe = gsp_probe, - .remove = gsp_remove, - .id_table = gsp_id, -}; - -/* All registers are word-sized, except for the configuration registers. - * AD7418 uses a high-byte first convention. Do NOT use those functions to - * access the configuration registers CONF and CONF2, as they are byte-sized. - */ -static inline int gsp_read(struct i2c_client *client, u8 reg) -{ - unsigned int adc = 0; - if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT) - { - adc |= i2c_smbus_read_byte_data(client, reg); - adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; - return adc; - } - else - { - adc |= i2c_smbus_read_byte_data(client, reg); - adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; - adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16; - return adc; - } -} - -static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value) -{ - i2c_smbus_write_byte_data(client, reg, value & 0xff); - i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff)); - return 1; -} - -static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_client *client = to_i2c_client(dev); - return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg)); -} - -static ssize_t show_label(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - - return sprintf(buf, "%s\n", gsp_sensors[attr->index].name); -} - -static ssize_t store_fan(struct device *dev, - struct device_attribute *devattr, const char *buf, size_t count) -{ - u16 val; - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_client *client = to_i2c_client(dev); - val = simple_strtoul(buf, NULL, 10); - gsp_write(client, gsp_sensors[attr->index].reg, val); - return count; -} - -static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0); -static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0); - -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1); -static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1); -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2); -static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3); -static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4); -static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5); -static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6); -static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6); -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7); -static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8); -static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8); -static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9); -static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9); -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10); -static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10); -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11); -static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11); -static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12); -static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12); -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13); -static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13); - -static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14); -static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15); -static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16); -static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17); -static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18); -static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19); - -static struct attribute *gsp_attributes[] = { - &sensor_dev_attr_temp0_input.dev_attr.attr, - &sensor_dev_attr_in0_input.dev_attr.attr, - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_in5_input.dev_attr.attr, - &sensor_dev_attr_in6_input.dev_attr.attr, - &sensor_dev_attr_in7_input.dev_attr.attr, - &sensor_dev_attr_in8_input.dev_attr.attr, - &sensor_dev_attr_in9_input.dev_attr.attr, - &sensor_dev_attr_in10_input.dev_attr.attr, - &sensor_dev_attr_in11_input.dev_attr.attr, - &sensor_dev_attr_in12_input.dev_attr.attr, - - &sensor_dev_attr_temp0_label.dev_attr.attr, - &sensor_dev_attr_in0_label.dev_attr.attr, - &sensor_dev_attr_in1_label.dev_attr.attr, - &sensor_dev_attr_in2_label.dev_attr.attr, - &sensor_dev_attr_in3_label.dev_attr.attr, - &sensor_dev_attr_in4_label.dev_attr.attr, - &sensor_dev_attr_in5_label.dev_attr.attr, - &sensor_dev_attr_in6_label.dev_attr.attr, - &sensor_dev_attr_in7_label.dev_attr.attr, - &sensor_dev_attr_in8_label.dev_attr.attr, - &sensor_dev_attr_in9_label.dev_attr.attr, - &sensor_dev_attr_in10_label.dev_attr.attr, - &sensor_dev_attr_in11_label.dev_attr.attr, - &sensor_dev_attr_in12_label.dev_attr.attr, - - &sensor_dev_attr_fan0_point0.dev_attr.attr, - &sensor_dev_attr_fan0_point1.dev_attr.attr, - &sensor_dev_attr_fan0_point2.dev_attr.attr, - &sensor_dev_attr_fan0_point3.dev_attr.attr, - &sensor_dev_attr_fan0_point4.dev_attr.attr, - &sensor_dev_attr_fan0_point5.dev_attr.attr, - NULL -}; - - -static int gsp_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adapter = client->adapter; - struct gsp_data *data; - int err; - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | - I2C_FUNC_SMBUS_WORD_DATA)) { - err = -EOPNOTSUPP; - goto exit; - } - - if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - - data->type = id->driver_data; - - switch (data->type) { - case 0: - data->attrs.attrs = gsp_attributes; - break; - } - - dev_info(&client->dev, "%s chip found\n", client->name); - - /* Register sysfs hooks */ - if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) - goto exit_free; - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - err = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &data->attrs); -exit_free: - kfree(data); -exit: - return err; -} - -static int gsp_remove(struct i2c_client *client) -{ - struct gsp_data *data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->attrs); - kfree(data); - return 0; -} - -static int __init gsp_init(void) -{ - return i2c_add_driver(&gsp_driver); -} - -static void __exit gsp_exit(void) -{ - i2c_del_driver(&gsp_driver); -} - -module_init(gsp_init); -module_exit(gsp_exit); - -MODULE_AUTHOR("Chris Lang <clang@gateworks.com>"); -MODULE_DESCRIPTION("GSC HWMON driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c index df04de73e03..8ccfb443ed1 100644 --- a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c +++ b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c @@ -28,6 +28,7 @@ #include <linux/kernel.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/version.h> #include <generated/utsrelease.h> #include <linux/types.h> @@ -1619,7 +1620,9 @@ DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf, IFX_MEI_EMSG ("Firmware size is too small!\n"); return retval; } - copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp)); + if (copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp))) + return -EFAULT; + // header of image_size and crc are not included. DSL_DEV_PRIVATE(pDev)->image_size = le32_to_cpu (img_hdr_tmp.size) + 8; @@ -1697,7 +1700,9 @@ DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf, nCopy = SDRAM_SEGMENT_SIZE - offset; else nCopy = size - nRead; - copy_from_user (mem_ptr, buf + nRead, nCopy); + if (copy_from_user (mem_ptr, buf + nRead, nCopy)) + return -EFAULT; + for (offset = 0; offset < (nCopy / 4); offset++) { ((unsigned long *) mem_ptr)[offset] = le32_to_cpu (((unsigned long *) mem_ptr)[offset]); } diff --git a/package/kernel/lantiq/ltq-adsl/Makefile b/package/kernel/lantiq/ltq-adsl/Makefile index 31874acaca4..ac966749338 100644 --- a/package/kernel/lantiq/ltq-adsl/Makefile +++ b/package/kernel/lantiq/ltq-adsl/Makefile @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-adsl PKG_VERSION:=3.24.4.4 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=drv_dsl_cpe_api_danube-$(PKG_VERSION).tar.gz PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-dsl-$(BUILD_VARIANT)/drv_dsl_cpe_api-$(PKG_VERSION) PKG_SOURCE_URL:=@OPENWRT diff --git a/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch b/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch new file mode 100644 index 00000000000..42ec2143715 --- /dev/null +++ b/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch @@ -0,0 +1,122 @@ +--- a/src/include/drv_dsl_cpe_pm_core.h ++++ b/src/include/drv_dsl_cpe_pm_core.h +@@ -1525,9 +1525,9 @@ typedef struct + DSL_boolean_t bShowtimeProcessingStart; + /** Showtime reached flag*/ + DSL_boolean_t bShowtimeInvTrigger; +- /** Current Showtime synchronization time to be used, (msec) */ ++ /** Current Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nCurrShowtimeTime; +- /** Showtime synchronization time to be used, (msec) */ ++ /** Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nElapsedShowtimeTime; + /** Actual Line state*/ + DSL_LineStateValue_t nLineState; +--- a/src/pm/drv_dsl_cpe_api_pm.c ++++ b/src/pm/drv_dsl_cpe_api_pm.c +@@ -1445,7 +1445,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -1501,7 +1501,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersEx + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL_EXT(pCounters->nChannel); + +@@ -2418,7 +2418,7 @@ DSL_Error_t DSL_DRV_PM_DataPathCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -3190,7 +3190,7 @@ DSL_Error_t DSL_DRV_PM_DataPathFailureCo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_FAILURE_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -3950,7 +3950,7 @@ DSL_Error_t DSL_DRV_PM_LineSecCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLineCounters = DSL_DRV_PM_PTR_LINE_SEC_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -4602,7 +4602,7 @@ DSL_Error_t DSL_DRV_PM_LineInitCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLinitCounters = DSL_DRV_PM_PTR_LINE_INIT_COUNTERS_TOTAL(); + +@@ -5131,7 +5131,7 @@ DSL_Error_t DSL_DRV_PM_LineEventShowtime + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLfCounters = DSL_DRV_PM_PTR_LINE_EVENT_SHOWTIME_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -5670,7 +5670,7 @@ DSL_Error_t DSL_DRV_PM_ReTxCountersTotal + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pReTxCounters = DSL_DRV_PM_PTR_RETX_COUNTERS_TOTAL(pCounters->nDirection); + +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -61,6 +61,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + DSL_Error_t nErrCode = DSL_SUCCESS; + DSL_uint32_t msecTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE, ++ secTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE/DSL_PM_MSEC, + nCurrMsTime = 0; + #ifdef INCLUDE_DSL_CPE_PM_HISTORY + DSL_uint32_t nCurrSysTime = 0, nPrevElapsedTime = 0; +@@ -100,10 +101,13 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + /* Get elapsed time [msec] since the last entry*/ + msecTimeFrame = nCurrMsTime - DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck; ++ ++ /* Get elapsed time [sec] since the last entry*/ ++ secTimeFrame = (nCurrMsTime/DSL_PM_MSEC) - (DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck/DSL_PM_MSEC); + } + + /* Get Total Elapsed Time Since the PM module startup*/ +- DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += msecTimeFrame; ++ DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += secTimeFrame; + + /* Set last time check to the current time*/ + DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck = nCurrMsTime; +@@ -141,7 +145,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + else + { + /* Update current showtime elapsed time*/ +- DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += (msecTimeFrame/DSL_PM_MSEC); ++ DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += secTimeFrame; + DSL_DRV_PM_CONTEXT(pContext)->nElapsedShowtimeTime = + DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime; + } diff --git a/package/kernel/lantiq/ltq-adsl/patches/201-fix-compilation-warning-fallthrough.patch b/package/kernel/lantiq/ltq-adsl/patches/201-fix-compilation-warning-fallthrough.patch new file mode 100644 index 00000000000..dfaf29f4498 --- /dev/null +++ b/package/kernel/lantiq/ltq-adsl/patches/201-fix-compilation-warning-fallthrough.patch @@ -0,0 +1,36 @@ +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -2274,16 +2274,18 @@ DSL_Error_t DSL_DRV_PM_CountersReset( + } + #endif /* #ifdef INCLUDE_DSL_CPE_PM_HISTORY*/ + +- if (ResetType == DSL_PM_RESET_HISTORY) +- break; ++ if (ResetType == DSL_PM_RESET_HISTORY) ++ break; + ++ fallthrough; + case DSL_PM_RESET_TOTAL: + #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS + memset(EpData.pRecTotal, 0x0, EpData.nEpRecElementSize); + #endif /* #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS*/ +- if (ResetType == DSL_PM_RESET_TOTAL) +- break; ++ if (ResetType == DSL_PM_RESET_TOTAL) ++ break; + ++ fallthrough; + case DSL_PM_RESET_HISTORY_SHOWTIME: + #ifdef INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS + nErrCode = DSL_DRV_PM_HistoryDelete(pContext, EpData.pHistShowtime ); +--- a/src/device/drv_dsl_cpe_device_danube.c ++++ b/src/device/drv_dsl_cpe_device_danube.c +@@ -3193,7 +3193,7 @@ DSL_Error_t DSL_DRV_DEV_AutobootHandleTraining( + DSL_DEV_NUM(pContext))); + } + #endif /* INCLUDE_DSL_DELT*/ +- /* Pass through */ ++ fallthrough ; + case DSL_LINESTATE_IDLE: + #if defined(INCLUDE_DSL_PM) && defined(INCLUDE_DSL_CPE_PM_LINE_COUNTERS) + if ( (pContext->bGotFullInit == DSL_TRUE) && diff --git a/package/kernel/lantiq/ltq-adsl/patches/202-g997_danube-dynamically-allocate-hlogdata.patch b/package/kernel/lantiq/ltq-adsl/patches/202-g997_danube-dynamically-allocate-hlogdata.patch new file mode 100644 index 00000000000..c3b1047a2ab --- /dev/null +++ b/package/kernel/lantiq/ltq-adsl/patches/202-g997_danube-dynamically-allocate-hlogdata.patch @@ -0,0 +1,65 @@ +--- a/src/g997/drv_dsl_cpe_api_g997_danube.c ++++ b/src/g997/drv_dsl_cpe_api_g997_danube.c +@@ -1984,41 +1984,53 @@ DSL_Error_t DSL_DRV_DEV_G997_DeltHlogGet( + { + if (nDirection == DSL_DOWNSTREAM) + { +- DSL_G997_DeltHlogData_t HlogData; ++ DSL_G997_DeltHlogData_t *HlogData; + +- memset(&HlogData, 0x0, sizeof(DSL_G997_DeltHlogData_t)); ++ HlogData = kzalloc(sizeof(*HlogData), GFP_KERNEL); ++ if (!HlogData) ++ { ++ DSL_DEBUG(DSL_DBG_ERR, ++ (pContext, "DSL[%02d]: ERROR - Alloc HlogData failed!"DSL_DRV_CRLF, ++ DSL_DEV_NUM(pContext))); ++ return DSL_ERR_MEMORY; ++ } ++ ++ memset(HlogData, 0x0, sizeof(DSL_G997_DeltHlogData_t)); + + /* Get SHOWTIME Hlog values*/ + nErrCode = DSL_DRV_DANUBE_G997_DeltHlogGet( +- pContext, nDirection, &HlogData); ++ pContext, nDirection, HlogData); + if (nErrCode != DSL_SUCCESS) + { + DSL_DEBUG(DSL_DBG_ERR, + (pContext, "DSL[%02d]: ERROR - Showtime Hlog get failed!"DSL_DRV_CRLF, + DSL_DEV_NUM(pContext))); ++ kfree(HlogData); + return nErrCode; + } + + /* if actual group size != 1, values should be spread */ +- if (HlogData.nGroupSize != 1) ++ if (HlogData->nGroupSize != 1) + { + nErrCode = DSL_DRV_DANUBE_G997_DeltValuesSpread( +- 0x1, HlogData.nGroupSize, HlogData.deltHlog.nNumData, +- HlogData.deltHlog.nNSCData, pData->deltHlog.nNSCData); ++ 0x1, HlogData->nGroupSize, HlogData->deltHlog.nNumData, ++ HlogData->deltHlog.nNSCData, pData->deltHlog.nNSCData); + + if (nErrCode == DSL_SUCCESS) + { + pData->deltHlog.nNumData = +- (DSL_uint16_t)(HlogData.deltHlog.nNumData * HlogData.nGroupSize); ++ (DSL_uint16_t)(HlogData->deltHlog.nNumData * HlogData->nGroupSize); + pData->nGroupSize = 1; +- pData->nMeasurementTime = HlogData.nMeasurementTime; ++ pData->nMeasurementTime = HlogData->nMeasurementTime; + } + } + else + { + /* No spread needed, copy data*/ +- memcpy(pData, &HlogData, sizeof(DSL_G997_DeltHlogData_t)); ++ memcpy(pData, HlogData, sizeof(DSL_G997_DeltHlogData_t)); + } ++ ++ kfree(HlogData); + } + else + { diff --git a/package/kernel/lantiq/ltq-adsl/patches/203-g997_danube-fix-compilation-warning.patch b/package/kernel/lantiq/ltq-adsl/patches/203-g997_danube-fix-compilation-warning.patch new file mode 100644 index 00000000000..c6a0e70f1f9 --- /dev/null +++ b/package/kernel/lantiq/ltq-adsl/patches/203-g997_danube-fix-compilation-warning.patch @@ -0,0 +1,26 @@ +--- a/src/g997/drv_dsl_cpe_api_g997_danube.c ++++ b/src/g997/drv_dsl_cpe_api_g997_danube.c +@@ -2512,6 +2524,7 @@ DSL_Error_t DSL_DRV_DEV_G997_PowerManagementStateForcedTrigger( + else + { + /* read L3 request failure reason */ ++ DSL_uint8_t nErrCodeL3; + nErrCode = DSL_DRV_DANUBE_CmvRead(pContext, DSL_CMV_GROUP_STAT, + DSL_CMV_ADDRESS_STAT_L3_FAILURE_REASON, 0, 1, &nVal); + DSL_DEBUG(DSL_DBG_MSG, +@@ -2525,11 +2538,13 @@ DSL_Error_t DSL_DRV_DEV_G997_PowerManagementStateForcedTrigger( + nErrCode = DSL_ERR_MSG_EXCHANGE; + break; + } +- if (((nVal >> 4) & 0x15) == 0x5) ++ ++ nErrCodeL3 = (nVal >> 4) & 0x15; ++ if (nErrCodeL3 == 0x5) + { + nErrCode = DSL_ERR_L3_NOT_IN_L0; + } +- else if (((nVal >> 4) & 0x15) == 0x9) ++ else if (nErrCodeL3 == 0x9) + { + nErrCode = DSL_ERR_L3_TIMED_OUT; + } diff --git a/package/kernel/lantiq/ltq-atm/Makefile b/package/kernel/lantiq/ltq-atm/Makefile index f675269ca33..b81f3bb2938 100644 --- a/package/kernel/lantiq/ltq-atm/Makefile +++ b/package/kernel/lantiq/ltq-atm/Makefile @@ -22,13 +22,18 @@ define KernelPackage/ltq-atm-template URL:=http://www.lantiq.com/ VARIANT:=$(1) DEPENDS:=@$(2) +kmod-atm +br2684ctl +ifeq ($(1),vr9) + DEPENDS+= +PACKAGE_kmod-ltq-atm-$(1):kmod-ltq-vdsl-vr9-mei +else + DEPENDS+= +PACKAGE_kmod-ltq-atm-$(1):kmod-ltq-adsl-$(1)-mei +endif FILES:=$(PKG_BUILD_DIR)/ltq_atm_$(1).ko endef -KernelPackage/ltq-atm-danube=$(call KernelPackage/ltq-atm-template,danube,(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy) +kmod-ltq-adsl-danube-mei) -KernelPackage/ltq-atm-ar9=$(call KernelPackage/ltq-atm-template,ar9,TARGET_lantiq_xway +kmod-ltq-adsl-ar9-mei) -KernelPackage/ltq-atm-ase=$(call KernelPackage/ltq-atm-template,ase,TARGET_lantiq_ase +kmod-ltq-adsl-ase-mei) -KernelPackage/ltq-atm-vr9=$(call KernelPackage/ltq-atm-template,vr9,TARGET_lantiq_xrx200 +kmod-ltq-vdsl-vr9-mei) +KernelPackage/ltq-atm-danube=$(call KernelPackage/ltq-atm-template,danube,(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy)) +KernelPackage/ltq-atm-ar9=$(call KernelPackage/ltq-atm-template,ar9,TARGET_lantiq_xway) +KernelPackage/ltq-atm-ase=$(call KernelPackage/ltq-atm-template,ase,TARGET_lantiq_ase) +KernelPackage/ltq-atm-vr9=$(call KernelPackage/ltq-atm-template,vr9,TARGET_lantiq_xrx200) define Build/Configure endef diff --git a/package/kernel/lantiq/ltq-atm/patches/100-ltq_atm-fix-compillation-warning.patch b/package/kernel/lantiq/ltq-atm/patches/100-ltq_atm-fix-compillation-warning.patch new file mode 100644 index 00000000000..c74cfcb6b4d --- /dev/null +++ b/package/kernel/lantiq/ltq-atm/patches/100-ltq_atm-fix-compillation-warning.patch @@ -0,0 +1,12 @@ +--- a/ltq_atm.c ++++ b/ltq_atm.c +@@ -338,7 +338,8 @@ static int ppe_ioctl(struct atm_dev *dev + break; + + case PPE_ATM_MIB_VCC: /* VCC related MIB */ +- copy_from_user(&mib_vcc, arg, sizeof(mib_vcc)); ++ if (copy_from_user(&mib_vcc, arg, sizeof(mib_vcc))) ++ return -EFAULT; + conn = find_vpivci(mib_vcc.vpi, mib_vcc.vci); + if (conn >= 0) { + mib_vcc.mib_vcc.aal5VccCrcErrors = g_atm_priv_data.conn[conn].aal5_vcc_crc_err; diff --git a/package/kernel/lantiq/ltq-deu/Makefile b/package/kernel/lantiq/ltq-deu/Makefile index e5a7d0d86fc..4e8127afabb 100644 --- a/package/kernel/lantiq/ltq-deu/Makefile +++ b/package/kernel/lantiq/ltq-deu/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-deu -PKG_RELEASE:=1 +PKG_RELEASE:=45 PKG_MAINTAINER:=John Crispin <john@phrozen.org> PKG_LICENSE:=GPL-2.0+ @@ -21,7 +21,7 @@ define KernelPackage/ltq-deu-template TITLE:=deu driver for $(1) URL:=http://www.lantiq.com/ VARIANT:=$(1) - DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager @LINUX_5_4 + DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager +kmod-crypto-des FILES:=$(PKG_BUILD_DIR)/ltq_deu_$(1).ko AUTOLOAD:=$(call AutoProbe,ltq_deu_$(1)) endef diff --git a/package/kernel/lantiq/ltq-deu/src/Makefile b/package/kernel/lantiq/ltq-deu/src/Makefile index 93ae7ca922f..13f3dccaee6 100644 --- a/package/kernel/lantiq/ltq-deu/src/Makefile +++ b/package/kernel/lantiq/ltq-deu/src/Makefile @@ -7,18 +7,18 @@ endif ifeq ($(BUILD_VARIANT),ar9) CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \ - -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \ + -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 \ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC obj-m = ltq_deu_ar9.o - ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \ + ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o \ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o endif ifeq ($(BUILD_VARIANT),vr9) CFLAGS_MODULE = -DCONFIG_VR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \ - -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \ + -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 \ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC obj-m = ltq_deu_vr9.o - ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \ + ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o \ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o endif diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 76abfafb4e6..2aa4b095935 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -57,6 +57,14 @@ #include <linux/delay.h> #include <asm/byteorder.h> #include <crypto/algapi.h> +#include <crypto/b128ops.h> +#include <crypto/gcm.h> +#include <crypto/gf128mul.h> +#include <crypto/scatterwalk.h> +#include <crypto/xts.h> +#include <crypto/internal/aead.h> +#include <crypto/internal/hash.h> +#include <crypto/internal/skcipher.h> #include "ifxmips_deu.h" @@ -83,9 +91,12 @@ spinlock_t aes_lock; #define AES_MIN_KEY_SIZE 16 #define AES_MAX_KEY_SIZE 32 #define AES_BLOCK_SIZE 16 +#define AES_BLOCK_WORDS 4 #define CTR_RFC3686_NONCE_SIZE 4 #define CTR_RFC3686_IV_SIZE 8 +#define CTR_RFC3686_MIN_KEY_SIZE (AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) #define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) +#define AES_CBCMAC_DBN_TEMP_SIZE 128 #ifdef CRYPTO_DEBUG extern char debug_level; @@ -112,8 +123,18 @@ extern void ifx_deu_aes (void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg, struct aes_ctx { int key_length; - u32 buf[AES_MAX_KEY_SIZE]; + u8 buf[AES_MAX_KEY_SIZE]; + u8 tweakkey[AES_MAX_KEY_SIZE]; u8 nonce[CTR_RFC3686_NONCE_SIZE]; + u8 lastbuffer[4 * XTS_BLOCK_SIZE]; + int use_tweak; + u32 byte_count; + u32 dbn; + int started; + u32 (*temp)[AES_BLOCK_WORDS]; + u8 block[AES_BLOCK_SIZE]; + u8 hash[AES_BLOCK_SIZE]; + struct gf128mul_4k *gf128; }; extern int disable_deudma; @@ -130,18 +151,17 @@ extern int disable_multiblock; int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); - unsigned long *flags = (unsigned long *) &tfm->crt_flags; //printk("set_key in %s\n", __FILE__); //aes_chip_init(); if (key_len != 16 && key_len != 24 && key_len != 32) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; return -EINVAL; } ctx->key_length = key_len; + ctx->use_tweak = 0; DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length); memcpy ((u8 *) (ctx->buf), in_key, key_len); @@ -149,35 +169,37 @@ int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) } -/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode) +/*! \fn int aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) * \ingroup IFX_AES_FUNCTIONS - * \brief main interface to AES hardware - * \param ctx_arg crypto algo context - * \param out_arg output bytestream - * \param in_arg input bytestream - * \param iv_arg initialization vector - * \param nbytes length of bytestream - * \param encdec 1 for encrypt; 0 for decrypt - * \param mode operation mode such as ebc, cbc, ctr - * -*/ -void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, - u8 *iv_arg, size_t nbytes, int encdec, int mode) + * \brief sets the AES keys for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int aes_set_key_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + return aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len); +} + +/*! \fn void aes_set_key_skcipher (void *ctx_arg) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES key to the hardware, requires spinlock to be set by caller + * \param ctx_arg crypto algo context + * \return +*/ +void aes_set_key_hw (void *ctx_arg) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; - u32 *in_key = ctx->buf; - unsigned long flag; - /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + u8 *in_key = ctx->buf; int key_len = ctx->key_length; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - int i = 0; - int byte_cnt = nbytes; - + if (ctx->use_tweak) in_key = ctx->tweakkey; - CRTCL_SECT_START; /* 128, 192 or 256 bit key length */ aes->controlr.K = key_len / 8 - 2; if (key_len == 128 / 8) { @@ -206,8 +228,7 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, } else { printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); - CRTCL_SECT_END; - return;// -EINVAL; + return; //-EINVAL; } /* let HW pre-process DEcryption key in any case (even if @@ -215,6 +236,36 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, checked in decryption routine! */ aes->controlr.PNK = 1; +} + + +/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode) + * \ingroup IFX_AES_FUNCTIONS + * \brief main interface to AES hardware + * \param ctx_arg crypto algo context + * \param out_arg output bytestream + * \param in_arg input bytestream + * \param iv_arg initialization vector + * \param nbytes length of bytestream + * \param encdec 1 for encrypt; 0 for decrypt + * \param mode operation mode such as ebc, cbc, ctr + * +*/ +void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, + u8 *iv_arg, size_t nbytes, int encdec, int mode) + +{ + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + //struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; + unsigned long flag; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int i = 0; + int byte_cnt = nbytes; + + CRTCL_SECT_START; + + aes_set_key_hw (ctx_arg); aes->controlr.E_D = !encdec; //encryption aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR @@ -251,23 +302,24 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /* To handle all non-aligned bytes (not aligned to 16B size) */ if (byte_cnt) { - aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0)); - aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1)); - aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2)); - aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */ + u8 temparea[16] = {0,}; + + memcpy(temparea, ((u32 *) in_arg + (i * 4)), byte_cnt); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 3)); /* start crypto */ while (aes->controlr.BUS) { } - *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R; - *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R; - *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R; - *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R; - - /* to ensure that the extended pages are clean */ - memset (out_arg + (i * 16) + (nbytes % AES_BLOCK_SIZE), 0, - (AES_BLOCK_SIZE - (nbytes % AES_BLOCK_SIZE))); + *((volatile u32 *) temparea + 0) = aes->OD3R; + *((volatile u32 *) temparea + 1) = aes->OD2R; + *((volatile u32 *) temparea + 2) = aes->OD1R; + *((volatile u32 *) temparea + 3) = aes->OD0R; + memcpy(((u32 *) out_arg + (i * 4)), temparea, byte_cnt); } //tc.chen : copy iv_arg back @@ -294,7 +346,6 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); - unsigned long *flags = (unsigned long *)&tfm->crt_flags; //printk("ctr_rfc3686_aes_set_key in %s\n", __FILE__); @@ -304,17 +355,32 @@ int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsi key_len -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce if (key_len != 16 && key_len != 24 && key_len != 32) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; return -EINVAL; } ctx->key_length = key_len; + ctx->use_tweak = 0; memcpy ((u8 *) (ctx->buf), in_key, key_len); return 0; } +/*! + * \fn int ctr_rfc3686_aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets RFC3686 key for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 20, 28 and 36 bytes supported; last 4 bytes is nonce + * \return 0 - SUCCESS + * -EINVAL - bad key length +*/ +int ctr_rfc3686_aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) +{ + return ctr_rfc3686_aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len); +} + /*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_AES_FUNCTIONS * \brief main interface with deu hardware in DMA mode @@ -423,11 +489,11 @@ void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src, /*! \fn void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS - * \brief encrypt AES_BLOCK_SIZE of data - * \param tfm linux crypto algo transform - * \param out output bytestream - * \param in input bytestream -*/ + * \brief encrypt AES_BLOCK_SIZE of data + * \param tfm linux crypto algo transform + * \param out output bytestream + * \param in input bytestream +*/ void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); @@ -437,11 +503,11 @@ void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) /*! \fn void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS - * \brief decrypt AES_BLOCK_SIZE of data - * \param tfm linux crypto algo transform - * \param out output bytestream - * \param in input bytestream -*/ + * \brief decrypt AES_BLOCK_SIZE of data + * \param tfm linux crypto algo transform + * \param out output bytestream + * \param in input bytestream +*/ void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); @@ -449,14 +515,14 @@ void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) CRYPTO_DIR_DECRYPT, 0); } -/* - * \brief AES function mappings +/* + * \brief AES function mappings */ struct crypto_alg ifxdeu_aes_alg = { .cra_name = "aes", .cra_driver_name = "ifxdeu-aes", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_module = THIS_MODULE, @@ -472,115 +538,91 @@ struct crypto_alg ifxdeu_aes_alg = { } }; -/*! \fn int ecb_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief ECB AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief ECB AES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { enc_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int ecb_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief ECB AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief ECB AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { dec_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/* +/* * \brief AES function mappings */ -struct crypto_alg ifxdeu_ecb_aes_alg = { - .cra_name = "ecb(aes)", - .cra_driver_name = "ifxdeu-ecb(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = aes_set_key, - .encrypt = ecb_aes_encrypt, - .decrypt = ecb_aes_decrypt, - } - } +struct skcipher_alg ifxdeu_ecb_aes_alg = { + .base.cra_name = "ecb(aes)", + .base.cra_driver_name = "ifxdeu-ecb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = AES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ecb_aes_encrypt, + .decrypt = ecb_aes_decrypt, }; - -/*! \fn int cbc_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief CBC AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief CBC AES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int enc_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -588,32 +630,26 @@ int cbc_aes_encrypt(struct blkcipher_desc *desc, ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int cbc_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int cbc_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief CBC AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief CBC AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -621,7 +657,7 @@ int cbc_aes_decrypt(struct blkcipher_desc *desc, ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -630,142 +666,572 @@ int cbc_aes_decrypt(struct blkcipher_desc *desc, /* * \brief AES function mappings */ -struct crypto_alg ifxdeu_cbc_aes_alg = { - .cra_name = "cbc(aes)", - .cra_driver_name = "ifxdeu-cbc(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = aes_set_key, - .encrypt = cbc_aes_encrypt, - .decrypt = cbc_aes_decrypt, +struct skcipher_alg ifxdeu_cbc_aes_alg = { + .base.cra_name = "cbc(aes)", + .base.cra_driver_name = "ifxdeu-cbc(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = AES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = cbc_aes_encrypt, + .decrypt = cbc_aes_decrypt, +}; + +/*! \fn void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec) + * \ingroup IFX_AES_FUNCTIONS + * \brief main interface to AES hardware for XTS impl + * \param ctx_arg crypto algo context + * \param out_arg output bytestream + * \param in_arg input bytestream + * \param iv_arg initialization vector + * \param nbytes length of bytestream + * \param encdec 1 for encrypt; 0 for decrypt + * +*/ +void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, + u8 *iv_arg, size_t nbytes, int encdec) +{ + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + //struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; + unsigned long flag; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + u8 oldiv[16]; + int i = 0; + int byte_cnt = nbytes; + + CRTCL_SECT_START; + + aes_set_key_hw (ctx_arg); + + aes->controlr.E_D = !encdec; //encryption + aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR - CBC mode for xts + + i = 0; + while (byte_cnt >= 16) { + + if (!encdec) { + if (((byte_cnt % 16) > 0) && (byte_cnt < (2*XTS_BLOCK_SIZE))) { + memcpy(oldiv, iv_arg, 16); + gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); + } + u128_xor((u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)iv_arg); + } + + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3)); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long + } + + *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R; + *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R; + *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R; + *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R; + + if (encdec) { + u128_xor((u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)iv_arg); } + gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); + i++; + byte_cnt -= 16; + } + + if (byte_cnt) { + u8 state[XTS_BLOCK_SIZE] = {0,}; + + if (!encdec) memcpy(iv_arg, oldiv, 16); + + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3)); + + memcpy(state, ((u32 *) in_arg + (i * 4) + 0), byte_cnt); + memcpy((state + byte_cnt), (out_arg + ((i - 1) * 16) + byte_cnt), (XTS_BLOCK_SIZE - byte_cnt)); + if (!encdec) { + u128_xor((u128 *)state, (u128 *)state, (u128 *)iv_arg); + } + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) state + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) state + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) state + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) state + 3)); /* start crypto */ + + memcpy(((u32 *) out_arg + (i * 4) + 0), ((u32 *) out_arg + ((i - 1) * 4) + 0), byte_cnt); + + while (aes->controlr.BUS) { + // this will not take long + } + + *((volatile u32 *) out_arg + ((i-1) * 4) + 0) = aes->OD3R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 1) = aes->OD2R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 2) = aes->OD1R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 3) = aes->OD0R; + + if (encdec) { + u128_xor((u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)iv_arg); + } + } + + CRTCL_SECT_END; +} + +/*! \fn int xts_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief XTS AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int xts_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes, processed; + + err = skcipher_walk_virt(&walk, req, false); + + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + ctx->use_tweak = 1; + aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ctx->use_tweak = 0; + processed = 0; + + while ((nbytes = walk.nbytes) && (walk.nbytes >= (XTS_BLOCK_SIZE * 2)) ) { + u8 *iv = walk.iv; + if (nbytes == walk.total) { + enc_bytes = nbytes; + } else { + enc_bytes = nbytes & ~(XTS_BLOCK_SIZE - 1); + if ((req->cryptlen - processed - enc_bytes) < (XTS_BLOCK_SIZE)) { + if (enc_bytes > (2 * XTS_BLOCK_SIZE)) { + enc_bytes -= XTS_BLOCK_SIZE; + } else { + break; + } + } + } + ifx_deu_aes_xts(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, enc_bytes, CRYPTO_DIR_ENCRYPT); + err = skcipher_walk_done(&walk, nbytes - enc_bytes); + processed += enc_bytes; + } + + if ((walk.nbytes)) { + u8 *iv = walk.iv; + nbytes = req->cryptlen - processed; + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, (req->cryptlen - nbytes), nbytes, 0); + ifx_deu_aes_xts(ctx, ctx->lastbuffer, ctx->lastbuffer, + iv, nbytes, CRYPTO_DIR_ENCRYPT); + scatterwalk_map_and_copy(ctx->lastbuffer, req->dst, (req->cryptlen - nbytes), nbytes, 1); + skcipher_request_complete(req, 0); + } + + return err; +} + +/*! \fn int xts_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief XTS AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int xts_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes, processed; + + err = skcipher_walk_virt(&walk, req, false); + + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + ctx->use_tweak = 1; + aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ctx->use_tweak = 0; + processed = 0; + + while ((nbytes = walk.nbytes) && (walk.nbytes >= (XTS_BLOCK_SIZE * 2))) { + u8 *iv = walk.iv; + if (nbytes == walk.total) { + dec_bytes = nbytes; + } else { + dec_bytes = nbytes & ~(XTS_BLOCK_SIZE - 1); + if ((req->cryptlen - processed - dec_bytes) < (XTS_BLOCK_SIZE)) { + if (dec_bytes > (2 * XTS_BLOCK_SIZE)) { + dec_bytes -= XTS_BLOCK_SIZE; + } else { + break; + } + } + } + ifx_deu_aes_xts(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, dec_bytes, CRYPTO_DIR_DECRYPT); + err = skcipher_walk_done(&walk, nbytes - dec_bytes); + processed += dec_bytes; + } + + if ((walk.nbytes)) { + u8 *iv = walk.iv; + nbytes = req->cryptlen - processed; + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, (req->cryptlen - nbytes), nbytes, 0); + ifx_deu_aes_xts(ctx, ctx->lastbuffer, ctx->lastbuffer, + iv, nbytes, CRYPTO_DIR_DECRYPT); + scatterwalk_map_and_copy(ctx->lastbuffer, req->dst, (req->cryptlen - nbytes), nbytes, 1); + skcipher_request_complete(req, 0); } + + return err; +} + +/*! \fn int xts_aes_set_key_skcipher (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for XTS + * \param tfm linux crypto algo transform + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int xts_aes_set_key_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(crypto_skcipher_tfm(tfm)); + unsigned int keylen = (key_len / 2); + + if (key_len % 2) return -EINVAL; + + if (keylen != 16 && keylen != 24 && keylen != 32) { + return -EINVAL; + } + + ctx->key_length = keylen; + ctx->use_tweak = 0; + DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length); + memcpy ((u8 *) (ctx->buf), in_key, keylen); + memcpy ((u8 *) (ctx->tweakkey), in_key + keylen, keylen); + + return 0; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_xts_aes_alg = { + .base.cra_name = "xts(aes)", + .base.cra_driver_name = "ifxdeu-xts(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = XTS_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_xts_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE * 2, + .max_keysize = AES_MAX_KEY_SIZE * 2, + .ivsize = XTS_BLOCK_SIZE, + .walksize = 2 * XTS_BLOCK_SIZE, + .setkey = xts_aes_set_key_skcipher, + .encrypt = xts_aes_encrypt, + .decrypt = xts_aes_decrypt, }; +/*! \fn int ofb_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief OFB AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ofb_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } -/*! \fn int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) + return err; +} + +/*! \fn int ofb_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief OFB AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ofb_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int dec_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); - while ((nbytes = enc_bytes = walk.nbytes)) { - u8 *iv = walk.iv; + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_ofb_aes_alg = { + .base.cra_name = "ofb(aes)", + .base.cra_driver_name = "ifxdeu-ofb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ofb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ofb_aes_encrypt, + .decrypt = ofb_aes_decrypt, +}; + +/*! \fn int cfb_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CFB AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int cfb_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/*! \fn int cfb_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CFB AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int cfb_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_cfb_aes_alg = { + .base.cra_name = "cfb(aes)", + .base.cra_driver_name = "ifxdeu-cfb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cfb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = cfb_aes_encrypt, + .decrypt = cfb_aes_decrypt, +}; + +/*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief Counter mode AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ctr_basic_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { enc_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/*! \fn int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_basic_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); - while ((nbytes = dec_bytes = walk.nbytes)) { - u8 *iv = walk.iv; + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { dec_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/* +/* * \brief AES function mappings */ -struct crypto_alg ifxdeu_ctr_basic_aes_alg = { - .cra_name = "ctr(aes)", - .cra_driver_name = "ifxdeu-ctr(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = aes_set_key, - .encrypt = ctr_basic_aes_encrypt, - .decrypt = ctr_basic_aes_decrypt, - } - } +struct skcipher_alg ifxdeu_ctr_basic_aes_alg = { + .base.cra_name = "ctr(aes)", + .base.cra_driver_name = "ifxdeu-ctr(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ctr_basic_aes_encrypt, + .decrypt = ctr_basic_aes_decrypt, }; - -/*! \fn int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_rfc3686_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES (rfc3686) encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES (rfc3686) encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_rfc3686_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err, bsize = nbytes; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes, enc_bytes; + int err; u8 rfc3686_iv[16]; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - + err = skcipher_walk_virt(&walk, req, false); + nbytes = walk.nbytes; + /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE); @@ -774,54 +1240,40 @@ int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) = cpu_to_be32(1); - /* scatterlist source is the same size as request size, just process once */ - if (nbytes == walk.nbytes) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); - return err; - } - - while ((nbytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - - nbytes -= walk.nbytes; - bsize -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + rfc3686_iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, rfc3686_iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + err = skcipher_walk_done(&walk, 0); } - + return err; } -/*! \fn int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_rfc3686_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES (rfc3686) decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES (rfc3686) decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_rfc3686_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err, bsize = nbytes; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes, dec_bytes; + int err; u8 rfc3686_iv[16]; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); + nbytes = walk.nbytes; /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); @@ -831,86 +1283,634 @@ int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) = cpu_to_be32(1); - /* scatterlist source is the same size as request size, just process once */ - if (nbytes == walk.nbytes) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); - return err; - } - - while ((nbytes = walk.nbytes) % (walk.nbytes >= AES_BLOCK_SIZE)) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_DECRYPT, 0); - - nbytes -= walk.nbytes; - bsize -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + rfc3686_iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + rfc3686_iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/* +/* * \brief AES function mappings */ -struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = { - .cra_name = "rfc3686(ctr(aes))", - .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, - .ivsize = CTR_RFC3686_IV_SIZE, - .setkey = ctr_rfc3686_aes_set_key, - .encrypt = ctr_rfc3686_aes_encrypt, - .decrypt = ctr_rfc3686_aes_decrypt, +struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { + .base.cra_name = "rfc3686(ctr(aes))", + .base.cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.base.cra_list), + .min_keysize = CTR_RFC3686_MIN_KEY_SIZE, + .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, + .ivsize = CTR_RFC3686_IV_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = ctr_rfc3686_aes_set_key_skcipher, + .encrypt = ctr_rfc3686_aes_encrypt, + .decrypt = ctr_rfc3686_aes_decrypt, +}; + +static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); + +/*! \fn static void aes_cbcmac_transform(struct shash_desc *desc, u8 const *in) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief save input block to context + * \param desc linux crypto shash descriptor + * \param in 16-byte block of input +*/ +static void aes_cbcmac_transform(struct shash_desc *desc, u8 const *in) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + + if ( ((mctx->dbn)+1) > AES_CBCMAC_DBN_TEMP_SIZE ) + { + //printk("aes_cbcmac_DBN_TEMP_SIZE exceeded\n"); + aes_cbcmac_final_impl(desc, (u8 *)mctx->hash, false); + } + + memcpy(&mctx->temp[mctx->dbn], in, 16); //dbn workaround + mctx->dbn += 1; +} + +/*! \fn int aes_cbcmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief sets cbcmac aes key + * \param tfm linux crypto shash transform + * \param key input key + * \param keylen key +*/ +static int aes_cbcmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) +{ + return aes_set_key(crypto_shash_tfm(tfm), key, keylen); + + return 0; +} + +/*! \fn void aes_cbcmac_init(struct shash_desc *desc) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief initialize md5 hmac context + * \param desc linux crypto shash descriptor +*/ +static int aes_cbcmac_init(struct shash_desc *desc) +{ + + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + + mctx->dbn = 0; //dbn workaround + mctx->started = 0; + mctx->byte_count = 0; + memset(mctx->hash, 0, AES_BLOCK_SIZE); + + return 0; +} + +/*! \fn void aes_cbcmac_update(struct shash_desc *desc, const u8 *data, unsigned int len) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief on-the-fly cbcmac aes computation + * \param desc linux crypto shash descriptor + * \param data input data + * \param len size of input data +*/ +static int aes_cbcmac_update(struct shash_desc *desc, const u8 *data, unsigned int len) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x0f); + + mctx->byte_count += len; + + if (avail > len) { + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), + data, len); + return 0; + } + + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), + data, avail); + + aes_cbcmac_transform(desc, mctx->block); + data += avail; + len -= avail; + + while (len >= sizeof(mctx->block)) { + memcpy(mctx->block, data, sizeof(mctx->block)); + aes_cbcmac_transform(desc, mctx->block); + data += sizeof(mctx->block); + len -= sizeof(mctx->block); + } + + memcpy(mctx->block, data, len); + return 0; +} + +/*! \fn static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief compute final or intermediate md5 hmac value + * \param desc linux crypto shash descriptor + * \param out final cbcmac aes output value + * \param in finalize or intermediate processing +*/ +static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + const unsigned int offset = mctx->byte_count & 0x0f; + char *p = (char *)mctx->block + offset; + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + unsigned long flag; + int i = 0; + int dbn; + u32 *in = mctx->temp[0]; + + CRTCL_SECT_START; + + aes_set_key_hw (mctx); + + aes->controlr.E_D = !CRYPTO_DIR_ENCRYPT; //encryption + aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR + + //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps + + //printk("\ndbn = %d\n", mctx->dbn); + + if (mctx->started) { + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) mctx->hash); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 3)); + } else { + mctx->started = 1; + aes->IV3R = 0; + aes->IV2R = 0; + aes->IV1R = 0; + aes->IV0R = 0; + } + + i = 0; + for (dbn = 0; dbn < mctx->dbn; dbn++) + { + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long + } + + in += 4; + } + + *((u32 *) mctx->hash) = DEU_ENDIAN_SWAP(aes->IV3R); + *((u32 *) mctx->hash + 1) = DEU_ENDIAN_SWAP(aes->IV2R); + *((u32 *) mctx->hash + 2) = DEU_ENDIAN_SWAP(aes->IV1R); + *((u32 *) mctx->hash + 3) = DEU_ENDIAN_SWAP(aes->IV0R); + + if (hash_final && offset) { + aes->controlr.O = 0; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR + crypto_xor(mctx->block, mctx->hash, offset); + + memcpy(p, mctx->hash + offset, (AES_BLOCK_SIZE - offset)); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long } + + *((u32 *) mctx->hash) = DEU_ENDIAN_SWAP(aes->OD3R); + *((u32 *) mctx->hash + 1) = DEU_ENDIAN_SWAP(aes->OD2R); + *((u32 *) mctx->hash + 2) = DEU_ENDIAN_SWAP(aes->OD1R); + *((u32 *) mctx->hash + 3) = DEU_ENDIAN_SWAP(aes->OD0R); } + + CRTCL_SECT_END; + + if (hash_final) { + memcpy(out, mctx->hash, AES_BLOCK_SIZE); + /* reset the context after we finish with the hash */ + aes_cbcmac_init(desc); + } else { + mctx->dbn = 0; + } + return 0; +} + +/*! \fn static int aes_cbcmac_final(struct crypto_tfm *tfm, u8 *out) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief call aes_cbcmac_final_impl with hash_final true + * \param tfm linux crypto algo transform + * \param out final md5 hmac output value +*/ +static int aes_cbcmac_final(struct shash_desc *desc, u8 *out) +{ + return aes_cbcmac_final_impl(desc, out, true); +} + +/*! \fn void aes_cbcmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief initialize pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static int aes_cbcmac_init_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->temp = kzalloc(AES_BLOCK_SIZE * AES_CBCMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp); + + return 0; +} + +/*! \fn void aes_cbcmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief free pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static void aes_cbcmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *mctx = crypto_tfm_ctx(tfm); + kfree(mctx->temp); +} + +/* + * \brief aes_cbcmac function mappings +*/ +static struct shash_alg ifxdeu_cbcmac_aes_alg = { + .digestsize = AES_BLOCK_SIZE, + .init = aes_cbcmac_init, + .update = aes_cbcmac_update, + .final = aes_cbcmac_final, + .setkey = aes_cbcmac_setkey, + .descsize = sizeof(struct aes_ctx), + .base = { + .cra_name = "cbcmac(aes)", + .cra_driver_name= "ifxdeu-cbcmac(aes)", + .cra_priority = 400, + .cra_ctxsize = sizeof(struct aes_ctx), + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = 1, + .cra_module = THIS_MODULE, + .cra_init = aes_cbcmac_init_tfm, + .cra_exit = aes_cbcmac_exit_tfm, + } }; +/*! \fn int aes_set_key_aead (struct crypto_aead *aead, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for aead gcm + * \param aead linux crypto aead + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int aes_set_key_aead (struct crypto_aead *aead, const u8 *in_key, unsigned int key_len) +{ + struct aes_ctx *ctx = crypto_aead_ctx(aead); + int err; + + err = aes_set_key(&aead->base, in_key, key_len); + if (err) return err; + + memset(ctx->block, 0, sizeof(ctx->block)); + memset(ctx->lastbuffer, 0, AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + ctx->lastbuffer, AES_BLOCK_SIZE, CRYPTO_DIR_ENCRYPT, 0); + if (ctx->gf128) gf128mul_free_4k(ctx->gf128); + ctx->gf128 = gf128mul_init_4k_lle((be128 *)ctx->block); + + return err; +} + +/*! \fn int gcm_aes_setauthsize (struct crypto_aead *aead, unsigned int authsize) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for aead gcm + * \param aead linux crypto aead + * \param in_key input authsize + * \return -EINVAL - bad authsize length, 0 - SUCCESS +*/ +int gcm_aes_setauthsize (struct crypto_aead *aead, unsigned int authsize) +{ + return crypto_gcm_check_authsize(authsize); +} + +/*! \fn int gcm_aes_encrypt(struct aead_request *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief GCM AES encrypt using linux crypto aead + * \param req aead request + * \return err +*/ +int gcm_aes_encrypt(struct aead_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + struct skcipher_request request; + int err; + unsigned int enc_bytes, nbytes; + be128 lengths; + u8 iv[AES_BLOCK_SIZE]; + + lengths.a = cpu_to_be64(req->assoclen * 8); + lengths.b = cpu_to_be64(req->cryptlen * 8); + + memset(ctx->hash, 0, sizeof(ctx->hash)); + memset(ctx->block, 0, sizeof(ctx->block)); + memcpy(iv, req->iv, GCM_AES_IV_SIZE); + *(__be32 *)((void *)iv + GCM_AES_IV_SIZE) = cpu_to_be32(1); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + iv, 16, CRYPTO_DIR_ENCRYPT, 0); + + request.cryptlen = req->cryptlen + req->assoclen; + request.src = req->src; + request.dst = req->dst; + request.base = req->base; + + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = AES_BLOCK_SIZE; + + if (req->assoclen && (req->assoclen < AES_BLOCK_SIZE)) + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = req->assoclen; + + err = skcipher_walk_virt(&walk, &request, false); + + //process assoc data if available + if (req->assoclen > 0) { + unsigned int assoc_remain, ghashlen; + + assoc_remain = req->assoclen; + ghashlen = min(req->assoclen, walk.nbytes); + while ((nbytes = enc_bytes = ghashlen) && (ghashlen >= AES_BLOCK_SIZE)) { + u8 *temp; + if (nbytes > req->assoclen) nbytes = enc_bytes = req->assoclen; + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, enc_bytes); + assoc_remain -= enc_bytes; + temp = walk.dst.virt.addr; + while (enc_bytes > 0) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + enc_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + if (assoc_remain < AES_BLOCK_SIZE) walk.stride = assoc_remain; + if (assoc_remain == 0) walk.stride = AES_BLOCK_SIZE; + enc_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + err = skcipher_walk_done(&walk, (walk.nbytes - enc_bytes)); + ghashlen = min(assoc_remain, walk.nbytes); + } + + if ((enc_bytes = ghashlen)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, enc_bytes); + memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + walk.stride = AES_BLOCK_SIZE; + err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); + } + } + + //crypt and hash + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + u8 *temp; + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + temp = walk.dst.virt.addr; + while (enc_bytes) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + enc_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + err = skcipher_walk_done(&walk, nbytes); + } + + /* crypt and hash remaining bytes < AES_BLOCK_SIZE */ + if ((enc_bytes = walk.nbytes)) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + memcpy(ctx->lastbuffer, walk.dst.virt.addr, enc_bytes); + memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + err = skcipher_walk_done(&walk, 0); + } + + //finalize and copy hash + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + scatterwalk_map_and_copy(ctx->hash, req->dst, req->cryptlen + req->assoclen, crypto_aead_authsize(crypto_aead_reqtfm(req)), 1); + + aead_request_complete(req, 0); + + return err; +} + +/*! \fn int gcm_aes_decrypt(struct aead_request *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief GCM AES decrypt using linux crypto aead + * \param req aead request + * \return err +*/ +int gcm_aes_decrypt(struct aead_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + struct skcipher_request request; + int err; + unsigned int dec_bytes, nbytes, authsize; + be128 lengths; + u8 iv[AES_BLOCK_SIZE]; + + authsize = crypto_aead_authsize(crypto_aead_reqtfm(req)); + + lengths.a = cpu_to_be64(req->assoclen * 8); + lengths.b = cpu_to_be64((req->cryptlen - authsize) * 8); + + memset(ctx->hash, 0, sizeof(ctx->hash)); + memset(ctx->block, 0, sizeof(ctx->block)); + memcpy(iv, req->iv, GCM_AES_IV_SIZE); + *(__be32 *)((void *)iv + GCM_AES_IV_SIZE) = cpu_to_be32(1); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + iv, 16, CRYPTO_DIR_ENCRYPT, 0); + + request.cryptlen = req->cryptlen + req->assoclen - authsize; + request.src = req->src; + request.dst = req->dst; + request.base = req->base; + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = AES_BLOCK_SIZE; + + if (req->assoclen && (req->assoclen < AES_BLOCK_SIZE)) + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = req->assoclen; + + err = skcipher_walk_virt(&walk, &request, false); + + //process assoc data if available + if (req->assoclen > 0) { + unsigned int assoc_remain, ghashlen; + + assoc_remain = req->assoclen; + ghashlen = min(req->assoclen, walk.nbytes); + while ((nbytes = dec_bytes = ghashlen) && (ghashlen >= AES_BLOCK_SIZE)) { + u8 *temp; + if (nbytes > req->assoclen) nbytes = dec_bytes = req->assoclen; + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, dec_bytes); + assoc_remain -= dec_bytes; + temp = walk.dst.virt.addr; + while (dec_bytes > 0) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + dec_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + if (assoc_remain < AES_BLOCK_SIZE) walk.stride = assoc_remain; + if (assoc_remain == 0) walk.stride = AES_BLOCK_SIZE; + dec_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + err = skcipher_walk_done(&walk, (walk.nbytes - dec_bytes)); + ghashlen = min(assoc_remain, walk.nbytes); + } + + if ((dec_bytes = ghashlen)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); + memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + walk.stride = AES_BLOCK_SIZE; + err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); + } + } + + //crypt and hash + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + u8 *temp; + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + temp = walk.src.virt.addr; + while (dec_bytes) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + dec_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + dec_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* crypt and hash remaining bytes < AES_BLOCK_SIZE */ + if ((dec_bytes = walk.nbytes)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); + memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + //finalize and copy hash + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, req->cryptlen + req->assoclen - authsize, authsize, 0); + err = crypto_memneq(ctx->lastbuffer, ctx->hash, authsize) ? -EBADMSG : 0; + + aead_request_complete(req, 0); + + return err; +} + +/*! \fn void aes_gcm_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief free pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static void aes_gcm_exit_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(tfm); + if (ctx->gf128) gf128mul_free_4k(ctx->gf128); +} + +/* + * \brief AES function mappings +*/ +struct aead_alg ifxdeu_gcm_aes_alg = { + .base.cra_name = "gcm(aes)", + .base.cra_driver_name = "ifxdeu-gcm(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_gcm_aes_alg.base.cra_list), + .base.cra_exit = aes_gcm_exit_tfm, + .ivsize = GCM_AES_IV_SIZE, + .maxauthsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_aead, + .encrypt = gcm_aes_encrypt, + .decrypt = gcm_aes_decrypt, + .setauthsize = gcm_aes_setauthsize, +}; /*! \fn int ifxdeu_init_aes (void) * \ingroup IFX_AES_FUNCTIONS - * \brief function to initialize AES driver - * \return ret -*/ + * \brief function to initialize AES driver + * \return ret +*/ int ifxdeu_init_aes (void) { int ret = -ENOSYS; + aes_chip_init(); if ((ret = crypto_register_alg(&ifxdeu_aes_alg))) goto aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ecb_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ecb_aes_alg))) goto ecb_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_cbc_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_cbc_aes_alg))) goto cbc_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ctr_basic_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_xts_aes_alg))) + goto xts_aes_err; + + if ((ret = crypto_register_skcipher(&ifxdeu_ofb_aes_alg))) + goto ofb_aes_err; + + if ((ret = crypto_register_skcipher(&ifxdeu_cfb_aes_alg))) + goto cfb_aes_err; + + if ((ret = crypto_register_skcipher(&ifxdeu_ctr_basic_aes_alg))) goto ctr_basic_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ctr_rfc3686_aes_alg))) goto ctr_rfc3686_aes_err; - aes_chip_init (); + if ((ret = crypto_register_shash(&ifxdeu_cbcmac_aes_alg))) + goto cbcmac_aes_err; + + if ((ret = crypto_register_aead(&ifxdeu_gcm_aes_alg))) + goto gcm_aes_err; CRTCL_SECT_INIT; @@ -918,20 +1918,40 @@ int ifxdeu_init_aes (void) printk (KERN_NOTICE "IFX DEU AES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)"); return ret; +gcm_aes_err: + crypto_unregister_aead(&ifxdeu_gcm_aes_alg); + printk (KERN_ERR "IFX gcm_aes initialization failed!\n"); + return ret; +cbcmac_aes_err: + crypto_unregister_shash(&ifxdeu_cbcmac_aes_alg); + printk (KERN_ERR "IFX cbcmac_aes initialization failed!\n"); + return ret; ctr_rfc3686_aes_err: - crypto_unregister_alg(&ifxdeu_ctr_rfc3686_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ctr_rfc3686_aes_alg); printk (KERN_ERR "IFX ctr_rfc3686_aes initialization failed!\n"); return ret; ctr_basic_aes_err: - crypto_unregister_alg(&ifxdeu_ctr_basic_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ctr_basic_aes_alg); printk (KERN_ERR "IFX ctr_basic_aes initialization failed!\n"); return ret; +cfb_aes_err: + crypto_unregister_skcipher(&ifxdeu_cfb_aes_alg); + printk (KERN_ERR "IFX cfb_aes initialization failed!\n"); + return ret; +ofb_aes_err: + crypto_unregister_skcipher(&ifxdeu_ofb_aes_alg); + printk (KERN_ERR "IFX ofb_aes initialization failed!\n"); + return ret; +xts_aes_err: + crypto_unregister_skcipher(&ifxdeu_xts_aes_alg); + printk (KERN_ERR "IFX xts_aes initialization failed!\n"); + return ret; cbc_aes_err: - crypto_unregister_alg(&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_aes_alg); printk (KERN_ERR "IFX cbc_aes initialization failed!\n"); return ret; ecb_aes_err: - crypto_unregister_alg(&ifxdeu_ecb_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_aes_alg); printk (KERN_ERR "IFX aes initialization failed!\n"); return ret; aes_err: @@ -942,16 +1962,18 @@ aes_err: /*! \fn void ifxdeu_fini_aes (void) * \ingroup IFX_AES_FUNCTIONS - * \brief unregister aes driver -*/ + * \brief unregister aes driver +*/ void ifxdeu_fini_aes (void) { crypto_unregister_alg (&ifxdeu_aes_alg); - crypto_unregister_alg (&ifxdeu_ecb_aes_alg); - crypto_unregister_alg (&ifxdeu_cbc_aes_alg); - crypto_unregister_alg (&ifxdeu_ctr_basic_aes_alg); - crypto_unregister_alg (&ifxdeu_ctr_rfc3686_aes_alg); - + crypto_unregister_skcipher (&ifxdeu_ecb_aes_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher (&ifxdeu_xts_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ofb_aes_alg); + crypto_unregister_skcipher (&ifxdeu_cfb_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ctr_rfc3686_aes_alg); + crypto_unregister_shash (&ifxdeu_cbcmac_aes_alg); + crypto_unregister_aead (&ifxdeu_gcm_aes_alg); } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c index 9faad94016b..51f988fe43c 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c @@ -47,6 +47,7 @@ #include <linux/errno.h> #include <linux/crypto.h> #include <crypto/algapi.h> +#include <crypto/internal/skcipher.h> #include <linux/interrupt.h> #include <asm/byteorder.h> #include <linux/delay.h> @@ -88,7 +89,6 @@ struct arc4_ctx { extern int disable_deudma; extern int disable_multiblock; - /*! \fn static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) \ingroup IFX_ARC4_FUNCTIONS \brief main interface to ARC4 hardware @@ -203,6 +203,19 @@ static int arc4_set_key(struct crypto_tfm *tfm, const u8 *inkey, return 0; } +/*! \fn static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) + \ingroup IFX_ARC4_FUNCTIONS + \brief sets ARC4 key + \param tfm linux crypto skcipher + \param in_key input key + \param key_len key lengths less than or equal to 16 bytes supported +*/ +static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *inkey, + unsigned int key_len) +{ + return arc4_set_key(crypto_skcipher_ctx(tfm), inkey, key_len); +} + /*! \fn static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) \ingroup IFX_ARC4_FUNCTIONS \brief sets ARC4 hardware to ECB mode @@ -243,7 +256,7 @@ static struct crypto_alg ifxdeu_arc4_alg = { .cra_name = "arc4", .cra_driver_name = "ifxdeu-arc4", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = ARC4_BLOCK_SIZE, .cra_ctxsize = sizeof(struct arc4_ctx), .cra_module = THIS_MODULE, @@ -259,61 +272,51 @@ static struct crypto_alg ifxdeu_arc4_alg = { } }; -/*! \fn static int ecb_arc4_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn static int ecb_arc4_encrypt(struct skcipher_request *req) \ingroup IFX_ARC4_FUNCTIONS - \brief ECB ARC4 encrypt using linux crypto blkcipher - \param desc blkcipher descriptor - \param dst output scatterlist - \param src input scatterlist - \param nbytes data size in bytes -*/ -static int ecb_arc4_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) + \brief ECB ARC4 encrypt using linux crypto skcipher + \param req skcipher_request +*/ +static int ecb_arc4_encrypt(struct skcipher_request *req) { - struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct arc4_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= ARC4_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn static int ecb_arc4_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn static int ecb_arc4_decrypt(struct skcipher_request *req) \ingroup IFX_ARC4_FUNCTIONS - \brief ECB ARC4 decrypt using linux crypto blkcipher - \param desc blkcipher descriptor - \param dst output scatterlist - \param src input scatterlist - \param nbytes data size in bytes -*/ -static int ecb_arc4_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) + \brief ECB ARC4 decrypt using linux crypto skcipher + \param desc skcipher_request +*/ +static int ecb_arc4_decrypt(struct skcipher_request *req) { - struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct arc4_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, nbytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= ARC4_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -322,25 +325,20 @@ static int ecb_arc4_decrypt(struct blkcipher_desc *desc, /* * \brief ARC4 function mappings */ -static struct crypto_alg ifxdeu_ecb_arc4_alg = { - .cra_name = "ecb(arc4)", - .cra_driver_name = "ifxdeu-ecb(arc4)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = ARC4_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct arc4_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = ARC4_MIN_KEY_SIZE, - .max_keysize = ARC4_MAX_KEY_SIZE, - .setkey = arc4_set_key, - .encrypt = ecb_arc4_encrypt, - .decrypt = ecb_arc4_decrypt, - } - } +static struct skcipher_alg ifxdeu_ecb_arc4_alg = { + .base.cra_name = "ecb(arc4)", + .base.cra_driver_name = "ifxdeu-ecb(arc4)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = ARC4_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct arc4_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.base.cra_list), + .min_keysize = ARC4_MIN_KEY_SIZE, + .max_keysize = ARC4_MAX_KEY_SIZE, + .setkey = arc4_set_key_skcipher, + .encrypt = ecb_arc4_encrypt, + .decrypt = ecb_arc4_decrypt, }; /*! \fn int ifxdeu_init_arc4(void) @@ -355,7 +353,7 @@ int ifxdeu_init_arc4(void) if ((ret = crypto_register_alg(&ifxdeu_arc4_alg))) goto arc4_err; - if ((ret = crypto_register_alg(&ifxdeu_ecb_arc4_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ecb_arc4_alg))) goto ecb_arc4_err; arc4_chip_init (); @@ -370,7 +368,7 @@ arc4_err: printk(KERN_ERR "IFX arc4 initialization failed!\n"); return ret; ecb_arc4_err: - crypto_unregister_alg(&ifxdeu_ecb_arc4_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_arc4_alg); printk (KERN_ERR "IFX ecb_arc4 initialization failed!\n"); return ret; @@ -383,9 +381,7 @@ ecb_arc4_err: void ifxdeu_fini_arc4(void) { crypto_unregister_alg (&ifxdeu_arc4_alg); - crypto_unregister_alg (&ifxdeu_ecb_arc4_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_arc4_alg); } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c index dcd059371fa..8184fed71fa 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c @@ -964,7 +964,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "aes", .cra_driver_name = "ifxdeu-aes", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -984,7 +984,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "ecb(aes)", .cra_driver_name = "ifxdeu-ecb(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1004,7 +1004,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "cbc(aes)", .cra_driver_name = "ifxdeu-cbc(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1024,7 +1024,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "ctr(aes)", .cra_driver_name = "ifxdeu-ctr(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1044,7 +1044,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "rfc3686(ctr(aes))", .cra_driver_name = "ifxdeu-rfc3686(ctr(aes))", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c index 1523763ccd7..bd560bf6596 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c @@ -761,7 +761,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "des", .cra_driver_name = "lqdeu-des", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -782,7 +782,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "ecb(des)", .cra_driver_name = "lqdeu-ecb(des)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -802,7 +802,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "cbc(des)", .cra_driver_name = "lqdeu-cbc(des)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -822,7 +822,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "des3_ede", .cra_driver_name = "lqdeu-des3_ede", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -842,7 +842,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "ecb(des3_ede)", .cra_driver_name = "lqdeu-ecb(des3_ede)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -862,7 +862,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "cbc(des3_ede)", .cra_driver_name = "lqdeu-cbc(des3_ede)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index 6d7d82fcb92..953c3feddc7 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -50,6 +50,8 @@ #include <linux/delay.h> #include <asm/byteorder.h> #include <crypto/algapi.h> +#include <crypto/des.h> +#include <crypto/internal/skcipher.h> #include "ifxmips_deu.h" #if defined(CONFIG_DANUBE) @@ -105,17 +107,18 @@ void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes); void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode); -struct des_ctx { +struct ifx_deu_des_ctx { int controlr_M; int key_length; u8 iv[DES_BLOCK_SIZE]; u32 expkey[DES3_EDE_EXPKEY_WORDS]; + struct des_ctx des_context; + struct des3_ede_ctx des3_ede_context; }; extern int disable_multiblock; extern int disable_deudma; - /*! \fn int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) * \ingroup IFX_DES_FUNCTIONS * \brief sets DES key @@ -126,18 +129,42 @@ extern int disable_deudma; int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { - struct des_ctx *dctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *dctx = crypto_tfm_ctx(tfm); + int err; //printk("setkey in %s\n", __FILE__); + err = des_expand_key(&dctx->des_context, key, keylen); + if (err == -ENOKEY) { + if (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) + err = -EINVAL; + else + err = 0; + } + dctx->controlr_M = 0; // des dctx->key_length = keylen; memcpy ((u8 *) (dctx->expkey), key, keylen); - return 0; + if (err) + memset(dctx, 0, sizeof(*dctx)); + + return err; } +/*! \fn int des_setkey_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int des_setkey_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + return des_setkey(crypto_skcipher_tfm(tfm), in_key, key_len); +} /*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_DES_FUNCTIONS @@ -155,7 +182,7 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) { volatile struct des_t *des = (struct des_t *) DES_3DES_START; - struct des_ctx *dctx = ctx_arg; + struct ifx_deu_des_ctx *dctx = ctx_arg; u32 *key = dctx->expkey; unsigned long flag; @@ -178,12 +205,13 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, des->K3HR = DEU_ENDIAN_SWAP(*((u32 *) key + 4)); des->K3LR = DEU_ENDIAN_SWAP(*((u32 *) key + 5)); /* no break; */ - + fallthrough; case 16: des->K2HR = DEU_ENDIAN_SWAP(*((u32 *) key + 2)); des->K2LR = DEU_ENDIAN_SWAP(*((u32 *) key + 3)); /* no break; */ + fallthrough; case 8: des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0)); des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1)); @@ -257,8 +285,6 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, * \param mode operation mode such as ebc, cbc */ - - /*! \fn void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) * \ingroup IFX_DES_FUNCTIONS * \brief sets DES hardware to ECB mode @@ -270,7 +296,6 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, * \param encdec 1 for encrypt; 0 for decrypt * \param inplace not used */ - void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) { @@ -345,31 +370,31 @@ void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src, ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 4); } -/*! \fn void des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_DES_FUNCTIONS * \brief encrypt DES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) +void ifx_deu_des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) { - struct des_ctx *ctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE, CRYPTO_DIR_ENCRYPT, 0); } -/*! \fn void des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_DES_FUNCTIONS * \brief encrypt DES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) +void ifx_deu_des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) { - struct des_ctx *ctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE, CRYPTO_DIR_DECRYPT, 0); } @@ -398,16 +423,41 @@ void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { - struct des_ctx *dctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *dctx = crypto_tfm_ctx(tfm); + int err; //printk("setkey in %s\n", __FILE__); + err = des3_ede_expand_key(&dctx->des3_ede_context, key, keylen); + if (err == -ENOKEY) { + if (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) + err = -EINVAL; + else + err = 0; + } + dctx->controlr_M = keylen / 8 + 1; // 3DES EDE1 / EDE2 / EDE3 Mode dctx->key_length = keylen; memcpy ((u8 *) (dctx->expkey), key, keylen); - return 0; + if (err) + memset(dctx, 0, sizeof(*dctx)); + + return err; +} + +/*! \fn int des3_ede_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) + * \ingroup IFX_DES_FUNCTIONS + * \brief sets 3DES key + * \param tfm linux crypto skcipher transform + * \param key input key + * \param keylen key length +*/ +int des3_ede_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen) +{ + return des3_ede_setkey(crypto_skcipher_tfm(tfm), key, keylen); } /* @@ -417,9 +467,9 @@ struct crypto_alg ifxdeu_des_alg = { .cra_name = "des", .cra_driver_name = "ifxdeu-des", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), + .cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, .cra_list = LIST_HEAD_INIT(ifxdeu_des_alg.cra_list), @@ -427,8 +477,8 @@ struct crypto_alg ifxdeu_des_alg = { .cia_min_keysize = DES_KEY_SIZE, .cia_max_keysize = DES_KEY_SIZE, .cia_setkey = des_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt } } + .cia_encrypt = ifx_deu_des_encrypt, + .cia_decrypt = ifx_deu_des_decrypt } } }; /* @@ -438,79 +488,68 @@ struct crypto_alg ifxdeu_des3_ede_alg = { .cra_name = "des3_ede", .cra_driver_name = "ifxdeu-des3_ede", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, .cra_list = LIST_HEAD_INIT(ifxdeu_des3_ede_alg.cra_list), .cra_u = { .cipher = { - .cia_min_keysize = DES_KEY_SIZE, - .cia_max_keysize = DES_KEY_SIZE, + .cia_min_keysize = DES3_EDE_KEY_SIZE, + .cia_max_keysize = DES3_EDE_KEY_SIZE, .cia_setkey = des3_ede_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt } } + .cia_encrypt = ifx_deu_des_encrypt, + .cia_decrypt = ifx_deu_des_decrypt } } }; -/*! \fn int ecb_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief ECB DES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes -*/ -int ecb_des_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +/*! \fn int ecb_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief ECB DES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ecb_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int enc_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { enc_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int ecb_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief ECB DES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int ecb_des_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief ECB DES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_des_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { dec_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -518,73 +557,57 @@ int ecb_des_decrypt(struct blkcipher_desc *desc, /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_ecb_des_alg = { - .cra_name = "ecb(des)", - .cra_driver_name = "ifxdeu-ecb(des)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES_KEY_SIZE, - .max_keysize = DES_KEY_SIZE, - .setkey = des_setkey, - .encrypt = ecb_des_encrypt, - .decrypt = ecb_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_ecb_des_alg = { + .base.cra_name = "ecb(des)", + .base.cra_driver_name = "ifxdeu-ecb(des)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.base.cra_list), + .min_keysize = DES_KEY_SIZE, + .max_keysize = DES_KEY_SIZE, + .setkey = des_setkey_skcipher, + .encrypt = ecb_des_encrypt, + .decrypt = ecb_des_decrypt, }; /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_ecb_des3_ede_alg = { - .cra_name = "ecb(des3_ede)", - .cra_driver_name = "ifxdeu-ecb(des3_ede)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = DES3_EDE_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES3_EDE_KEY_SIZE, - .max_keysize = DES3_EDE_KEY_SIZE, - .setkey = des3_ede_setkey, - .encrypt = ecb_des_encrypt, - .decrypt = ecb_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_ecb_des3_ede_alg = { + .base.cra_name = "ecb(des3_ede)", + .base.cra_driver_name = "ifxdeu-ecb(des3_ede)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.base.cra_list), + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .setkey = des3_ede_setkey_skcipher, + .encrypt = ecb_des_encrypt, + .decrypt = ecb_des_decrypt, }; -/*! \fn int cbc_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief CBC DES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int cbc_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CBC DES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_des_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int enc_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -592,33 +615,27 @@ int cbc_des_encrypt(struct blkcipher_desc *desc, ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int cbc_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief CBC DES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int cbc_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CBC DES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_des_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -626,7 +643,7 @@ int cbc_des_decrypt(struct blkcipher_desc *desc, ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -634,52 +651,42 @@ int cbc_des_decrypt(struct blkcipher_desc *desc, /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_cbc_des_alg = { - .cra_name = "cbc(des)", - .cra_driver_name = "ifxdeu-cbc(des)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES_KEY_SIZE, - .max_keysize = DES_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, - .setkey = des_setkey, - .encrypt = cbc_des_encrypt, - .decrypt = cbc_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_cbc_des_alg = { + .base.cra_name = "cbc(des)", + .base.cra_driver_name = "ifxdeu-cbc(des)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.base.cra_list), + .min_keysize = DES_KEY_SIZE, + .max_keysize = DES_KEY_SIZE, + .ivsize = DES_BLOCK_SIZE, + .setkey = des_setkey_skcipher, + .encrypt = cbc_des_encrypt, + .decrypt = cbc_des_decrypt, }; /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_cbc_des3_ede_alg = { - .cra_name = "cbc(des3_ede)", - .cra_driver_name = "ifxdeu-cbc(des3_ede)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = DES3_EDE_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES3_EDE_KEY_SIZE, - .max_keysize = DES3_EDE_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, - .setkey = des3_ede_setkey, - .encrypt = cbc_des_encrypt, - .decrypt = cbc_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_cbc_des3_ede_alg = { + .base.cra_name = "cbc(des3_ede)", + .base.cra_driver_name = "ifxdeu-cbc(des3_ede)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.base.cra_list), + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .ivsize = DES_BLOCK_SIZE, + .setkey = des3_ede_setkey_skcipher, + .encrypt = cbc_des_encrypt, + .decrypt = cbc_des_decrypt, }; /*! \fn int ifxdeu_init_des (void) @@ -690,16 +697,17 @@ int ifxdeu_init_des (void) { int ret = -ENOSYS; + des_chip_init(); ret = crypto_register_alg(&ifxdeu_des_alg); if (ret < 0) goto des_err; - ret = crypto_register_alg(&ifxdeu_ecb_des_alg); + ret = crypto_register_skcipher(&ifxdeu_ecb_des_alg); if (ret < 0) goto ecb_des_err; - ret = crypto_register_alg(&ifxdeu_cbc_des_alg); + ret = crypto_register_skcipher(&ifxdeu_cbc_des_alg); if (ret < 0) goto cbc_des_err; @@ -707,15 +715,14 @@ int ifxdeu_init_des (void) if (ret < 0) goto des3_ede_err; - ret = crypto_register_alg(&ifxdeu_ecb_des3_ede_alg); + ret = crypto_register_skcipher(&ifxdeu_ecb_des3_ede_alg); if (ret < 0) goto ecb_des3_ede_err; - ret = crypto_register_alg(&ifxdeu_cbc_des3_ede_alg); + ret = crypto_register_skcipher(&ifxdeu_cbc_des3_ede_alg); if (ret < 0) goto cbc_des3_ede_err; - des_chip_init(); CRTCL_SECT_INIT; @@ -728,11 +735,11 @@ des_err: printk(KERN_ERR "IFX des initialization failed!\n"); return ret; ecb_des_err: - crypto_unregister_alg(&ifxdeu_ecb_des_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_des_alg); printk (KERN_ERR "IFX ecb_des initialization failed!\n"); return ret; cbc_des_err: - crypto_unregister_alg(&ifxdeu_cbc_des_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_des_alg); printk (KERN_ERR "IFX cbc_des initialization failed!\n"); return ret; des3_ede_err: @@ -740,11 +747,11 @@ des3_ede_err: printk(KERN_ERR "IFX des3_ede initialization failed!\n"); return ret; ecb_des3_ede_err: - crypto_unregister_alg(&ifxdeu_ecb_des3_ede_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_des3_ede_alg); printk (KERN_ERR "IFX ecb_des3_ede initialization failed!\n"); return ret; cbc_des3_ede_err: - crypto_unregister_alg(&ifxdeu_cbc_des3_ede_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_des3_ede_alg); printk (KERN_ERR "IFX cbc_des3_ede initialization failed!\n"); return ret; @@ -757,11 +764,10 @@ cbc_des3_ede_err: void ifxdeu_fini_des (void) { crypto_unregister_alg (&ifxdeu_des_alg); - crypto_unregister_alg (&ifxdeu_ecb_des_alg); - crypto_unregister_alg (&ifxdeu_cbc_des_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_des_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_des_alg); crypto_unregister_alg (&ifxdeu_des3_ede_alg); - crypto_unregister_alg (&ifxdeu_ecb_des3_ede_alg); - crypto_unregister_alg (&ifxdeu_cbc_des3_ede_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_des3_ede_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_des3_ede_alg); } - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c index 3947b31a40b..096b8b5bba8 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c @@ -46,6 +46,7 @@ #include <linux/modversions.h> #endif #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/types.h> #include <linux/errno.h> @@ -69,6 +70,8 @@ #endif /* CONFIG_xxxx */ int disable_deudma = 1; +spinlock_t ltq_deu_hash_lock; +EXPORT_SYMBOL_GPL(ltq_deu_hash_lock); void chip_version(void); @@ -84,6 +87,7 @@ static int ltq_deu_probe(struct platform_device *pdev) START_DEU_POWER; + CRTCL_SECT_HASH_INIT; #define IFX_DEU_DRV_VERSION "2.0.0" printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h index 8045c2081a6..3c994cb3465 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h @@ -131,6 +131,10 @@ void __exit lqdeu_fini_async_des(void); void __exit deu_fini (void); int deu_dma_init (void); +extern spinlock_t ltq_deu_hash_lock; +#define CRTCL_SECT_HASH_INIT spin_lock_init(<q_deu_hash_lock) +#define CRTCL_SECT_HASH_START spin_lock_irqsave(<q_deu_hash_lock, flag) +#define CRTCL_SECT_HASH_END spin_unlock_irqrestore(<q_deu_hash_lock, flag) #define DEU_WAKELIST_INIT(queue) \ diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h index 69414553dea..2f373589a5c 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h @@ -117,6 +117,14 @@ hash->controlr.INIT = 1; \ } while(0) +#define MD5_HASH_INIT \ + do { \ + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \ + hash->controlr.SM = 1; \ + hash->controlr.ALGO = 1; \ + hash->controlr.INIT = 1; \ + } while(0) + /* DEU Common Structures for AR9*/ struct clc_controlr_t { diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h index 25efa04a696..25561cf6e08 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h @@ -104,6 +104,14 @@ hash->controlr.INIT = 1; \ } while(0) +#define MD5_HASH_INIT \ + do { \ + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \ + hash->controlr.SM = 1; \ + hash->controlr.ALGO = 1; \ + hash->controlr.INIT = 1; \ + } while(0) + /* DEU STRUCTURES */ struct clc_controlr_t { diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c index aaa7bce237b..8063672613a 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c @@ -107,7 +107,7 @@ void aes_chip_init (void) // start crypto engine with write to ILR aes->controlr.SM = 1; - aes->controlr.NDC = 0; + aes->controlr.NDC = 1; asm("sync"); aes->controlr.ENDI = 1; asm("sync"); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index 11cb64799e9..ee7e486b565 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -64,11 +64,6 @@ #define MD5_HASH_WORDS 4 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -86,18 +81,6 @@ struct md5_ctx { extern int disable_deudma; -/*! \fn static u32 endian_swap(u32 input) - * \ingroup IFX_MD5_FUNCTIONS - * \brief perform dword level endian swap - * \param input value of dword that requires to be swapped -*/ -static u32 endian_swap(u32 input) -{ - u8 *ptr = (u8 *)&input; - - return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]); -} - /*! \fn static void md5_transform(u32 *hash, u32 const *in) * \ingroup IFX_MD5_FUNCTIONS * \brief main interface to md5 hardware @@ -110,18 +93,20 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; + + MD5_HASH_INIT; if (mctx->started) { - hashs->D1R = endian_swap(*((u32 *) hash + 0)); - hashs->D2R = endian_swap(*((u32 *) hash + 1)); - hashs->D3R = endian_swap(*((u32 *) hash + 2)); - hashs->D4R = endian_swap(*((u32 *) hash + 3)); + hashs->D1R = *((u32 *) hash + 0); + hashs->D2R = *((u32 *) hash + 1); + hashs->D3R = *((u32 *) hash + 2); + hashs->D4R = *((u32 *) hash + 3); } for (i = 0; i < 16; i++) { - hashs->MR = endian_swap(in[i]); -// printk("in[%d]: %08x\n", i, endian_swap(in[i])); + hashs->MR = in[i]; +// printk("in[%d]: %08x\n", i, in[i]); }; //wait for processing @@ -129,14 +114,14 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) // this will not take long } - *((u32 *) hash + 0) = endian_swap (hashs->D1R); - *((u32 *) hash + 1) = endian_swap (hashs->D2R); - *((u32 *) hash + 2) = endian_swap (hashs->D3R); - *((u32 *) hash + 3) = endian_swap (hashs->D4R); + *((u32 *) hash + 0) = hashs->D1R; + *((u32 *) hash + 1) = hashs->D2R; + *((u32 *) hash + 2) = hashs->D3R; + *((u32 *) hash + 3) = hashs->D4R; - mctx->started = 1; + CRTCL_SECT_HASH_END; - CRTCL_SECT_END; + mctx->started = 1; } /*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx) @@ -158,12 +143,7 @@ static inline void md5_transform_helper(struct md5_ctx *ctx) static int md5_init(struct shash_desc *desc) { struct md5_ctx *mctx = shash_desc_ctx(desc); - volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; - - hash->controlr.ENDI = 0; - hash->controlr.SM = 1; - hash->controlr.ALGO = 1; // 1 = md5 0 = sha1 - hash->controlr.INIT = 1; // Initialize the hash operation by writing a '1' to the INIT bit. + //volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; mctx->byte_count = 0; mctx->started = 0; @@ -220,8 +200,8 @@ static int md5_final(struct shash_desc *desc, u8 *out) const unsigned int offset = mctx->byte_count & 0x3f; char *p = (char *)mctx->block + offset; int padding = 56 - (offset + 1); - volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; - unsigned long flag; + //volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; + //unsigned long flag; *p++ = 0x80; if (padding < 0) { @@ -232,24 +212,12 @@ static int md5_final(struct shash_desc *desc, u8 *out) } memset(p, 0, padding); - mctx->block[14] = endian_swap(mctx->byte_count << 3); - mctx->block[15] = endian_swap(mctx->byte_count >> 29); - -#if 0 - le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - - sizeof(u64)) / sizeof(u32)); -#endif + mctx->block[14] = le32_to_cpu(mctx->byte_count << 3); + mctx->block[15] = le32_to_cpu(mctx->byte_count >> 29); md5_transform(mctx, mctx->hash, mctx->block); - CRTCL_SECT_START; - - *((u32 *) out + 0) = endian_swap (hashs->D1R); - *((u32 *) out + 1) = endian_swap (hashs->D2R); - *((u32 *) out + 2) = endian_swap (hashs->D3R); - *((u32 *) out + 3) = endian_swap (hashs->D4R); - - CRTCL_SECT_END; + memcpy(out, mctx->hash, MD5_DIGEST_SIZE); // Wipe context memset(mctx, 0, sizeof(*mctx)); @@ -270,7 +238,7 @@ static struct shash_alg ifxdeu_md5_alg = { .cra_name = "md5", .cra_driver_name= "ifxdeu-md5", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = MD5_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } @@ -288,8 +256,6 @@ int ifxdeu_init_md5 (void) if ((ret = crypto_register_shash(&ifxdeu_md5_alg))) goto md5_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; @@ -308,4 +274,3 @@ void ifxdeu_fini_md5 (void) crypto_unregister_shash(&ifxdeu_md5_alg); } - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index 6cb2e5a4174..109d27cbfbe 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -63,11 +63,6 @@ #define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -84,24 +79,15 @@ struct md5_hmac_ctx { u32 block[MD5_BLOCK_WORDS]; u64 byte_count; u32 dbn; + int started; unsigned int keylen; + struct shash_desc *desc; + u32 (*temp)[MD5_BLOCK_WORDS]; }; -static u32 temp[MD5_HMAC_DBN_TEMP_SIZE]; - extern int disable_deudma; -/*! \fn static u32 endian_swap(u32 input) - * \ingroup IFX_MD5_HMAC_FUNCTIONS - * \brief perform dword level endian swap - * \param input value of dword that requires to be swapped -*/ -static u32 endian_swap(u32 input) -{ - u8 *ptr = (u8 *)&input; - - return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]); -} +static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); /*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -113,14 +99,14 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm); - memcpy(&temp[mctx->dbn<<4], in, 64); //dbn workaround - mctx->dbn += 1; - - if ( (mctx->dbn<<4) > MD5_HMAC_DBN_TEMP_SIZE ) + if ( ((mctx->dbn<<4)+1) > MD5_HMAC_DBN_TEMP_SIZE ) { - printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n"); + //printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n"); + md5_hmac_final_impl(desc, (u8 *)mctx->hash, false); } + memcpy(&mctx->temp[mctx->dbn], in, 64); //dbn workaround + mctx->dbn += 1; } /*! \fn int md5_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) @@ -133,23 +119,30 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; + int err; //printk("copying keys to context with length %d\n", keylen); if (keylen > MAX_HASH_KEYLEN) { - printk("Key length more than what DEU hash can handle\n"); - return -EINVAL; - } - + char *hash_alg_name = "md5"; - hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0' - memcpy(&mctx->key, key, keylen); - mctx->keylen = keylen; + mctx->desc->tfm = crypto_alloc_shash(hash_alg_name, 0, 0); + if (IS_ERR(mctx->desc->tfm)) return PTR_ERR(mctx->desc->tfm); - return 0; + memset(mctx->key, 0, MAX_HASH_KEYLEN); + err = crypto_shash_digest(mctx->desc, key, keylen, mctx->key); + if (err) return err; -} + mctx->keylen = MD5_DIGEST_SIZE; + crypto_free_shash(mctx->desc->tfm); + } else { + memcpy(mctx->key, key, keylen); + mctx->keylen = keylen; + } + memset(mctx->key + mctx->keylen, 0, MAX_HASH_KEYLEN - mctx->keylen); + + return 0; +} /*! \fn int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -157,17 +150,15 @@ static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int * \param key input key * \param keylen key length greater than 64 bytes IS NOT SUPPORTED */ - static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) { volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; - unsigned long flag; int i, j; u32 *in_key = (u32 *)key; //printk("\nsetkey keylen: %d\n key: ", keylen); - CRTCL_SECT_START; + hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0' j = 0; for (i = 0; i < keylen; i+=4) { @@ -177,7 +168,6 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) asm("sync"); j++; } - CRTCL_SECT_END; return 0; } @@ -194,11 +184,11 @@ static int md5_hmac_init(struct shash_desc *desc) mctx->dbn = 0; //dbn workaround - md5_hmac_setkey_hw(mctx->key, mctx->keylen); + mctx->started = 0; + mctx->byte_count = 0; return 0; } -EXPORT_SYMBOL(md5_hmac_init); /*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -237,16 +227,27 @@ static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int memcpy(mctx->block, data, len); return 0; } -EXPORT_SYMBOL(md5_hmac_update); -/*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out) +/*! \fn static int md5_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_MD5_HMAC_FUNCTIONS - * \brief compute final md5 hmac value + * \brief call md5_hmac_final_impl with hash_final true * \param tfm linux crypto algo transform * \param out final md5 hmac output value */ static int md5_hmac_final(struct shash_desc *desc, u8 *out) { + return md5_hmac_final_impl(desc, out, true); +} + +/*! \fn static int md5_hmac_final_impl(struct crypto_tfm *tfm, u8 *out, bool hash_final) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief compute final or intermediate md5 hmac value + * \param tfm linux crypto algo transform + * \param out final md5 hmac output value + * \param in finalize or intermediate processing +*/ +static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) +{ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm); const unsigned int offset = mctx->byte_count & 0x3f; char *p = (char *)mctx->block + offset; @@ -255,27 +256,36 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) unsigned long flag; int i = 0; int dbn; - u32 *in = &temp[0]; + u32 *in = mctx->temp[0]; + + if (hash_final) { + *p++ = 0x80; + if (padding < 0) { + memset(p, 0x00, padding + sizeof (u64)); + md5_hmac_transform(desc, mctx->block); + p = (char *)mctx->block; + padding = 56; + } + memset(p, 0, padding); + mctx->block[14] = le32_to_cpu((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation + mctx->block[15] = 0x00000000; - *p++ = 0x80; - if (padding < 0) { - memset(p, 0x00, padding + sizeof (u64)); md5_hmac_transform(desc, mctx->block); - p = (char *)mctx->block; - padding = 56; } - memset(p, 0, padding); - mctx->block[14] = endian_swap((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation - mctx->block[15] = 0x00000000; + CRTCL_SECT_HASH_START; - md5_hmac_transform(desc, mctx->block); + MD5_HASH_INIT; - CRTCL_SECT_START; + md5_hmac_setkey_hw(mctx->key, mctx->keylen); //printk("\ndbn = %d\n", mctx->dbn); - hashs->DBN = mctx->dbn; + if (hash_final) { + hashs->DBN = mctx->dbn; + } else { + hashs->DBN = mctx->dbn + 5; + } asm("sync"); *IFX_HASH_CON = 0x0703002D; //khs, go, init, ndc, endi, kyue, hmen, md5 @@ -285,6 +295,15 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) // this will not take long } + if (mctx->started) { + hashs->D1R = *((u32 *) mctx->hash + 0); + hashs->D2R = *((u32 *) mctx->hash + 1); + hashs->D3R = *((u32 *) mctx->hash + 2); + hashs->D4R = *((u32 *) mctx->hash + 3); + } else { + mctx->started = 1; + } + for (dbn = 0; dbn < mctx->dbn; dbn++) { for (i = 0; i < 16; i++) { @@ -302,11 +321,12 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) in += 16; } - #if 1 - //wait for digest ready - while (! hashs->controlr.DGRY) { - // this will not take long + if (hash_final) { + //wait for digest ready + while (! hashs->controlr.DGRY) { + // this will not take long + } } #endif @@ -314,26 +334,49 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 1) = hashs->D2R; *((u32 *) out + 2) = hashs->D3R; *((u32 *) out + 3) = hashs->D4R; - *((u32 *) out + 4) = hashs->D5R; - /* reset the context after we finish with the hash */ - mctx->byte_count = 0; - memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS)); - memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); - memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); + CRTCL_SECT_HASH_END; - CRTCL_SECT_END; + if (hash_final) { + /* reset the context after we finish with the hash */ + md5_hmac_init(desc); + } else { + mctx->dbn = 0; + } + return 0; +} +/*! \fn void md5_hmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief initialize pointers in md5_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static int md5_hmac_init_tfm(struct crypto_tfm *tfm) +{ + struct md5_hmac_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->temp = kzalloc(4 * MD5_HMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp); + mctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL); + if (IS_ERR(mctx->desc)) return PTR_ERR(mctx->desc); - return 0; + return 0; } -EXPORT_SYMBOL(md5_hmac_final); +/*! \fn void md5_hmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief free pointers in md5_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static void md5_hmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct md5_hmac_ctx *mctx = crypto_tfm_ctx(tfm); + kfree(mctx->temp); + kfree(mctx->desc); +} /* * \brief MD5_HMAC function mappings */ - static struct shash_alg ifxdeu_md5_hmac_alg = { .digestsize = MD5_DIGEST_SIZE, .init = md5_hmac_init, @@ -345,10 +388,12 @@ static struct shash_alg ifxdeu_md5_hmac_alg = { .cra_name = "hmac(md5)", .cra_driver_name= "ifxdeu-md5_hmac", .cra_priority = 400, - .cra_ctxsize = sizeof(struct md5_hmac_ctx), - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_ctxsize = sizeof(struct md5_hmac_ctx), + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = MD5_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, + .cra_init = md5_hmac_init_tfm, + .cra_exit = md5_hmac_exit_tfm, } }; @@ -365,8 +410,6 @@ int ifxdeu_init_md5_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg))) goto md5_hmac_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; @@ -383,5 +426,3 @@ void ifxdeu_fini_md5_hmac (void) { crypto_unregister_shash(&ifxdeu_md5_hmac_alg); } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index d711c4804db..76734917d1e 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -38,14 +38,18 @@ \brief ifx deu sha1 functions */ - /* Project header */ #include <linux/init.h> #include <linux/module.h> #include <linux/mm.h> #include <linux/crypto.h> -#include <linux/cryptohash.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0) #include <crypto/sha.h> +#else +#include <crypto/sha1.h> +#endif +#include <crypto/hash.h> #include <crypto/internal/hash.h> #include <linux/types.h> #include <linux/scatterlist.h> @@ -65,11 +69,6 @@ #define SHA1_HMAC_BLOCK_SIZE 64 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -91,20 +90,21 @@ struct sha1_ctx { extern int disable_deudma; - -/*! \fn static void sha1_transform (u32 *state, const u32 *in) +/*! \fn static void sha1_transform1 (u32 *state, const u32 *in) * \ingroup IFX_SHA1_FUNCTIONS * \brief main interface to sha1 hardware * \param state current state * \param in 64-byte block of input */ -static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in) +static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) { int i = 0; volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; + + SHA_HASH_INIT; /* For context switching purposes, the previous hash output * is loaded back into the output register @@ -137,20 +137,18 @@ static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in) sctx->started = 1; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; } -/*! \fn static void sha1_init(struct crypto_tfm *tfm) +/*! \fn static void sha1_init1(struct crypto_tfm *tfm) * \ingroup IFX_SHA1_FUNCTIONS * \brief initialize sha1 hardware * \param tfm linux crypto algo transform */ -static int sha1_init(struct shash_desc *desc) +static int sha1_init1(struct shash_desc *desc) { struct sha1_ctx *sctx = shash_desc_ctx(desc); - SHA_HASH_INIT; - sctx->started = 0; sctx->count = 0; return 0; @@ -174,9 +172,9 @@ static int sha1_update(struct shash_desc * desc, const u8 *data, if ((j + len) > 63) { memcpy (&sctx->buffer[j], data, (i = 64 - j)); - sha1_transform (sctx, sctx->state, (const u32 *)sctx->buffer); + sha1_transform1 (sctx, sctx->state, (const u32 *)sctx->buffer); for (; i + 63 < len; i += 64) { - sha1_transform (sctx, sctx->state, (const u32 *)&data[i]); + sha1_transform1 (sctx, sctx->state, (const u32 *)&data[i]); } j = 0; @@ -201,8 +199,8 @@ static int sha1_final(struct shash_desc *desc, u8 *out) u64 t; u8 bits[8] = { 0, }; static const u8 padding[64] = { 0x80, }; - volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; - unsigned long flag; + //volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; + //unsigned long flag; t = sctx->count; bits[7] = 0xff & t; @@ -229,15 +227,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_update (desc, bits, sizeof bits); - CRTCL_SECT_START; - - *((u32 *) out + 0) = hashs->D1R; - *((u32 *) out + 1) = hashs->D2R; - *((u32 *) out + 2) = hashs->D3R; - *((u32 *) out + 3) = hashs->D4R; - *((u32 *) out + 4) = hashs->D5R; - - CRTCL_SECT_END; + memcpy(out, sctx->hash, SHA1_DIGEST_SIZE); // Wipe context memset (sctx, 0, sizeof *sctx); @@ -250,7 +240,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) */ static struct shash_alg ifxdeu_sha1_alg = { .digestsize = SHA1_DIGEST_SIZE, - .init = sha1_init, + .init = sha1_init1, .update = sha1_update, .final = sha1_final, .descsize = sizeof(struct sha1_ctx), @@ -259,7 +249,7 @@ static struct shash_alg ifxdeu_sha1_alg = { .cra_name = "sha1", .cra_driver_name= "ifxdeu-sha1", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } @@ -278,8 +268,6 @@ int ifxdeu_init_sha1 (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; @@ -298,5 +286,3 @@ void ifxdeu_fini_sha1 (void) } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 7776c51686a..b58a91a5df7 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -38,14 +38,18 @@ \brief ifx sha1 hmac functions */ - /* Project header */ #include <linux/init.h> #include <linux/module.h> #include <linux/mm.h> #include <linux/crypto.h> -#include <linux/cryptohash.h> #include <crypto/internal/hash.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0) +#include <crypto/sha.h> +#else +#include <crypto/sha1.h> +#endif #include <linux/types.h> #include <linux/scatterlist.h> #include <asm/byteorder.h> @@ -60,17 +64,14 @@ #endif #define SHA1_DIGEST_SIZE 20 +#define SHA1_BLOCK_WORDS 16 +#define SHA1_HASH_WORDS 5 #define SHA1_HMAC_BLOCK_SIZE 64 #define SHA1_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON #define SHA1_HMAC_MAX_KEYLEN 64 -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - #ifdef CRYPTO_DEBUG extern char debug_level; #define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args); @@ -83,16 +84,19 @@ struct sha1_hmac_ctx { u8 buffer[SHA1_HMAC_BLOCK_SIZE]; u8 key[SHA1_HMAC_MAX_KEYLEN]; - u32 state[5]; + u32 hash[SHA1_HASH_WORDS]; u32 dbn; + int started; u64 count; + struct shash_desc *desc; + u32 (*temp)[SHA1_BLOCK_WORDS]; }; -static u32 temp[SHA1_HMAC_DBN_TEMP_SIZE]; - extern int disable_deudma; +static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); + /*! \fn static void sha1_hmac_transform(struct crypto_tfm *tfm, u32 const *in) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief save input block to context @@ -103,14 +107,15 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); - memcpy(&temp[sctx->dbn<<4], in, 64); //dbn workaround - sctx->dbn += 1; - - if ( (sctx->dbn<<4) > SHA1_HMAC_DBN_TEMP_SIZE ) + if ( ((sctx->dbn<<4)+1) > SHA1_HMAC_DBN_TEMP_SIZE ) { - printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n"); + //printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n"); + sha1_hmac_final_impl(desc, (u8 *)sctx->hash, false); } - + + memcpy(&sctx->temp[sctx->dbn], in, 64); //dbn workaround + sctx->dbn += 1; + return 0; } @@ -124,24 +129,32 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; - + int err; + if (keylen > SHA1_HMAC_MAX_KEYLEN) { - printk("Key length exceeds maximum key length\n"); - return -EINVAL; + char *hash_alg_name = "sha1"; + + sctx->desc->tfm = crypto_alloc_shash(hash_alg_name, 0, 0); + if (IS_ERR(sctx->desc->tfm)) return PTR_ERR(sctx->desc->tfm); + + memset(sctx->key, 0, SHA1_HMAC_MAX_KEYLEN); + err = crypto_shash_digest(sctx->desc, key, keylen, sctx->key); + if (err) return err; + + sctx->keylen = SHA1_DIGEST_SIZE; + + crypto_free_shash(sctx->desc->tfm); + } else { + memcpy(sctx->key, key, keylen); + sctx->keylen = keylen; } + memset(sctx->key + sctx->keylen, 0, SHA1_HMAC_MAX_KEYLEN - sctx->keylen); //printk("Setting keys of len: %d\n", keylen); - - hashs->KIDX |= 0x80000000; //reset keys back to 0 - memcpy(&sctx->key, key, keylen); - sctx->keylen = keylen; return 0; - } - /*! \fn int sha1_hmac_setkey_hw(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief sets sha1 hmac key into hw registers @@ -153,12 +166,11 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) { volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; int i, j; - unsigned long flag; u32 *in_key = (u32 *)key; j = 0; - CRTCL_SECT_START; + hash->KIDX |= 0x80000000; //reset keys back to 0 for (i = 0; i < keylen; i+=4) { hash->KIDX = j; @@ -167,7 +179,6 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j++; } - CRTCL_SECT_END; return 0; } @@ -182,7 +193,8 @@ static int sha1_hmac_init(struct shash_desc *desc) //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); sctx->dbn = 0; //dbn workaround - sha1_hmac_setkey_hw(sctx->key, sctx->keylen); + sctx->started = 0; + sctx->count = 0; return 0; } @@ -220,15 +232,26 @@ static int sha1_hmac_update(struct shash_desc *desc, const u8 *data, return 0; } -/*! \fn static void sha1_hmac_final(struct crypto_tfm *tfm, u8 *out) +/*! \fn static int sha1_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_SHA1_HMAC_FUNCTIONS - * \brief ompute final sha1 hmac value + * \brief call sha1_hmac_final_impl with hash_final true * \param tfm linux crypto algo transform * \param out final sha1 hmac output value */ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) { - //struct sha1_hmac_ctx *sctx = shash_desc_ctx(desc); + return sha1_hmac_final_impl(desc, out, true); +} + +/*! \fn static int sha1_hmac_final_impl(struct crypto_tfm *tfm, u8 *out, bool hash_final) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief ompute final or intermediate sha1 hmac value + * \param tfm linux crypto algo transform + * \param out final sha1 hmac output value + * \param in finalize or intermediate processing +*/ +static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) +{ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); u32 index, padlen; u64 t; @@ -238,37 +261,48 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) unsigned long flag; int i = 0; int dbn; - u32 *in = &temp[0]; - - t = sctx->count + 512; // need to add 512 bit of the IPAD operation - bits[7] = 0xff & t; - t >>= 8; - bits[6] = 0xff & t; - t >>= 8; - bits[5] = 0xff & t; - t >>= 8; - bits[4] = 0xff & t; - t >>= 8; - bits[3] = 0xff & t; - t >>= 8; - bits[2] = 0xff & t; - t >>= 8; - bits[1] = 0xff & t; - t >>= 8; - bits[0] = 0xff & t; - - /* Pad out to 56 mod 64 */ - index = (sctx->count >> 3) & 0x3f; - padlen = (index < 56) ? (56 - index) : ((64 + 56) - index); - sha1_hmac_update (desc, padding, padlen); - - /* Append length */ - sha1_hmac_update (desc, bits, sizeof bits); - - CRTCL_SECT_START; - - hashs->DBN = sctx->dbn; - + u32 *in = sctx->temp[0]; + + if (hash_final) { + t = sctx->count + 512; // need to add 512 bit of the IPAD operation + bits[7] = 0xff & t; + t >>= 8; + bits[6] = 0xff & t; + t >>= 8; + bits[5] = 0xff & t; + t >>= 8; + bits[4] = 0xff & t; + t >>= 8; + bits[3] = 0xff & t; + t >>= 8; + bits[2] = 0xff & t; + t >>= 8; + bits[1] = 0xff & t; + t >>= 8; + bits[0] = 0xff & t; + + /* Pad out to 56 mod 64 */ + index = (sctx->count >> 3) & 0x3f; + padlen = (index < 56) ? (56 - index) : ((64 + 56) - index); + sha1_hmac_update (desc, padding, padlen); + + /* Append length */ + sha1_hmac_update (desc, bits, sizeof bits); + } + + CRTCL_SECT_HASH_START; + + SHA_HASH_INIT; + + sha1_hmac_setkey_hw(sctx->key, sctx->keylen); + + if (hash_final) { + hashs->DBN = sctx->dbn; + } else { + hashs->DBN = sctx->dbn + 5; + } + asm("sync"); + //for vr9 change, ENDI = 1 *IFX_HASH_CON = HASH_CON_VALUE; @@ -277,28 +311,40 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) // this will not take long } + if (sctx->started) { + hashs->D1R = *((u32 *) sctx->hash + 0); + hashs->D2R = *((u32 *) sctx->hash + 1); + hashs->D3R = *((u32 *) sctx->hash + 2); + hashs->D4R = *((u32 *) sctx->hash + 3); + hashs->D5R = *((u32 *) sctx->hash + 4); + } else { + sctx->started = 1; + } + for (dbn = 0; dbn < sctx->dbn; dbn++) { - for (i = 0; i < 16; i++) { - hashs->MR = in[i]; - }; + for (i = 0; i < 16; i++) { + hashs->MR = in[i]; + }; - hashs->controlr.GO = 1; - asm("sync"); + hashs->controlr.GO = 1; + asm("sync"); - //wait for processing - while (hashs->controlr.BSY) { + //wait for processing + while (hashs->controlr.BSY) { // this will not take long - } + } - in += 16; -} + in += 16; + } #if 1 - //wait for digest ready - while (! hashs->controlr.DGRY) { - // this will not take long + if (hash_final) { + //wait for digest ready + while (! hashs->controlr.DGRY) { + // this will not take long + } } #endif @@ -308,40 +354,71 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 3) = hashs->D4R; *((u32 *) out + 4) = hashs->D5R; - memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE); - sctx->count = 0; - + CRTCL_SECT_HASH_END; + + if (hash_final) { + sha1_hmac_init(desc); + } else { + sctx->dbn = 0; + } //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); - CRTCL_SECT_END; + return 0; + +} + +/*! \fn void sha1_hmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief initialize pointers in sha1_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static int sha1_hmac_init_tfm(struct crypto_tfm *tfm) +{ + struct sha1_hmac_ctx *sctx = crypto_tfm_ctx(tfm); + sctx->temp = kzalloc(4 * SHA1_HMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(sctx->temp)) return PTR_ERR(sctx->temp); + sctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL); + if (IS_ERR(sctx->desc)) return PTR_ERR(sctx->desc); return 0; +} +/*! \fn void sha1_hmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief free pointers in sha1_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static void sha1_hmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct sha1_hmac_ctx *sctx = crypto_tfm_ctx(tfm); + kfree(sctx->temp); + kfree(sctx->desc); } -/* - * \brief SHA1-HMAC function mappings +/* + * \brief SHA1_HMAC function mappings */ + static struct shash_alg ifxdeu_sha1_hmac_alg = { - .digestsize = SHA1_DIGEST_SIZE, - .init = sha1_hmac_init, - .update = sha1_hmac_update, - .final = sha1_hmac_final, - .setkey = sha1_hmac_setkey, - .descsize = sizeof(struct sha1_hmac_ctx), - .base = { - .cra_name = "hmac(sha1)", - .cra_driver_name= "ifxdeu-sha1_hmac", - .cra_priority = 400, - .cra_ctxsize = sizeof(struct sha1_hmac_ctx), - .cra_flags = CRYPTO_ALG_TYPE_HASH, - .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, - .cra_module = THIS_MODULE, + .digestsize = SHA1_DIGEST_SIZE, + .init = sha1_hmac_init, + .update = sha1_hmac_update, + .final = sha1_hmac_final, + .setkey = sha1_hmac_setkey, + .descsize = sizeof(struct sha1_hmac_ctx), + .base = { + .cra_name = "hmac(sha1)", + .cra_driver_name= "ifxdeu-sha1_hmac", + .cra_priority = 400, + .cra_ctxsize = sizeof(struct sha1_hmac_ctx), + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, + .cra_module = THIS_MODULE, + .cra_init = sha1_hmac_init_tfm, + .cra_exit = sha1_hmac_exit_tfm, } - }; - /*! \fn int ifxdeu_init_sha1_hmac (void) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief initialize sha1 hmac driver @@ -355,8 +432,6 @@ int ifxdeu_init_sha1_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; @@ -376,4 +451,3 @@ void ifxdeu_fini_sha1_hmac (void) } - diff --git a/package/kernel/lantiq/ltq-ifxos/Makefile b/package/kernel/lantiq/ltq-ifxos/Makefile index e98cb21eff5..97f7ca78ceb 100644 --- a/package/kernel/lantiq/ltq-ifxos/Makefile +++ b/package/kernel/lantiq/ltq-ifxos/Makefile @@ -6,19 +6,24 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk -PKG_NAME:=lib_ifxos -PKG_VERSION:=1.5.19 +PKG_NAME:=ifxos +PKG_VERSION:=1.7.1 PKG_RELEASE:=4 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_URL:=https://github.com/xdarklight/$(PKG_NAME)/archive/v$(PKG_VERSION) -PKG_HASH:=ed7fe39311d7a4a13d23ed0ae2445c0d825b472b5a98da9b72bcaabcf5ed2d5f + +UGW_VERSION=8.5.2.10 +UGW_BASENAME=$(PKG_NAME)-ugw_$(UGW_VERSION) + +PKG_SOURCE:=$(UGW_BASENAME).tar.bz2 +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(UGW_BASENAME) +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/$(PKG_NAME)/-/archive/ugw_$(UGW_VERSION)/ +PKG_HASH:=055a1f5eab0abfaac34ac7b1613b93ec341fe9ae8462cb11c36c2b0989ce0ca7 PKG_MAINTAINER:=John Crispin <john@phrozen.org> PKG_LICENSE:=GPL-2.0 BSD-2-Clause PKG_LICENSE_FILES:=LICENSE PKG_EXTMOD_SUBDIRS:=src PKG_FIXUP:=autoreconf +PKG_BUILD_FLAGS:=no-mold include $(INCLUDE_DIR)/package.mk @@ -28,7 +33,7 @@ define KernelPackage/ltq-ifxos SUBMENU:=Libraries TITLE:=Lantiq OS abstraction library URL:=http://www.lantiq.com/ - DEPENDS:=@TARGET_lantiq + DEPENDS:=@(TARGET_lantiq||TARGET_ipq40xx) FILES:=$(PKG_BUILD_DIR)/src/drv_ifxos.ko AUTOLOAD:=$(call AutoLoad,10,drv_ifxos) endef @@ -40,13 +45,11 @@ CONFIGURE_ARGS += \ --enable-kernelincl="$(LINUX_DIR)/include" \ --with-kernel-module -ifdef CONFIG_TARGET_lantiq - define Build/InstallDev +define Build/InstallDev $(INSTALL_DIR) $(1)/usr/{lib,include/ifxos} $(CP) $(PKG_BUILD_DIR)/src/include/* $(1)/usr/include/ifxos mkdir -p $(1)/usr/lib - $(CP) $(PKG_BUILD_DIR)/src/libifxos.a $(1)/usr/lib/libifxos.a - endef -endif + $(CP) $(PKG_BUILD_DIR)/src/.libs/libifxos.a $(1)/usr/lib/libifxos.a +endef $(eval $(call KernelPackage,ltq-ifxos)) diff --git a/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch b/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch index 78940649c5e..2c04f9b0092 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch @@ -1,24 +1,10 @@ ---- a/src/include/linux/ifxos_linux_thread.h -+++ b/src/include/linux/ifxos_linux_thread.h -@@ -206,7 +206,7 @@ typedef struct - /** - LINUX User Thread - map the Thread ID. - */ --typedef int IFXOS_thread_t; -+typedef pthread_t IFXOS_thread_t; +--- a/src/include/linux/ifxos_linux_common.h ++++ b/src/include/linux/ifxos_linux_common.h +@@ -49,6 +49,7 @@ + IFX Linux adaptation - Includes (Linux Kernel) + ========================================================================= */ + #include <linux/kernel.h> ++#include <linux/version.h> + #include <asm/byteorder.h> - /** - LINUX Kernel Process - map the Process ID. ---- a/src/linux/ifxos_linux_socket_appl.c -+++ b/src/linux/ifxos_linux_socket_appl.c -@@ -363,8 +363,8 @@ IFX_int_t IFXOS_SocketSendTo( - IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR); - -- ret = (IFX_int_t)sendto((int)socFd, (const char*)pBuffer, -- (int)bufSize_byte, 0, pSocAddr, sizeof(IFXOS_sockAddr_t)); -+ ret = (IFX_int_t)sendto(socFd, pBuffer, -+ bufSize_byte, 0, (struct sockaddr *)pSocAddr, sizeof(IFXOS_sockAddr_t)); - - return ret; - } + /* ============================================================================ diff --git a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch index 38722290de2..be518698e05 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch @@ -1,18 +1,18 @@ ---- a/src/linux/ifxos_linux_copy_user_space_drv.c -+++ b/src/linux/ifxos_linux_copy_user_space_drv.c -@@ -29,7 +29,7 @@ - #ifdef MODULE - #include <linux/module.h> - #endif +--- a/src/linux/ifxos_linux_socket_drv.c ++++ b/src/linux/ifxos_linux_socket_drv.c +@@ -28,7 +28,7 @@ + #include <linux/net.h> + #include <linux/fs.h> + #include <linux/inet.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include "ifx_types.h" #include "ifxos_rt_if_check.h" ---- a/src/linux/ifxos_linux_socket_drv.c -+++ b/src/linux/ifxos_linux_socket_drv.c +--- a/src/linux/ifxos_linux_socket_ipv6_drv.c ++++ b/src/linux/ifxos_linux_socket_ipv6_drv.c @@ -25,7 +25,7 @@ - #endif + #include <linux/version.h> #include <linux/in.h> #include <linux/net.h> -#include <asm/uaccess.h> @@ -20,3 +20,14 @@ #include "ifx_types.h" #include "ifxos_rt_if_check.h" +--- a/src/include/linux/ifxos_linux_interrupt.h ++++ b/src/include/linux/ifxos_linux_interrupt.h +@@ -31,7 +31,7 @@ + IFX Linux adaptation - Includes + ========================================================================= */ + #include "ifx_types.h" +-#include <asm/irq.h> ++#include <linux/interrupt.h> + + /* ============================================================================ + IFX Linux adaptation - supported features diff --git a/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch b/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch index d2e816f5c0d..e883b5b1fd5 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch @@ -1,6 +1,6 @@ --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -45,8 +45,6 @@ endif !HAVE_GCC +@@ -48,8 +48,6 @@ endif !HAVE_GCC if ENABLE_DEBUG used_gcc_cflags += -O1 -g diff --git a/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch b/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch index d9bbf8d7ccf..a3f210487ea 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch @@ -1,160 +1,106 @@ ---- a/src/linux/ifxos_linux_thread_drv.c -+++ b/src/linux/ifxos_linux_thread_drv.c -@@ -38,6 +38,7 @@ - #include <linux/smp_lock.h> - #endif - #include <linux/signal.h> -+#include <linux/kthread.h> - - - #include "ifx_types.h" -@@ -70,10 +71,6 @@ - #if ( defined(IFXOS_HAVE_THREAD) && (IFXOS_HAVE_THREAD == 1) ) - - --IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup( -- IFXOS_ThreadCtrl_t *pThrCntrl); -- -- - /* ============================================================================ - IFX Linux adaptation - Kernel Thread handling - ========================================================================= */ -@@ -98,9 +95,9 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr - - IFX_SUCCESS on success - - IFX_ERROR on error - */ --IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup( -- IFXOS_ThreadCtrl_t *pThrCntrl) -+int IFXOS_KernelThreadStartup(void *data) - { -+ IFXOS_ThreadCtrl_t *pThrCntrl = (IFXOS_ThreadCtrl_t*) data; - IFX_int32_t retVal = IFX_ERROR; - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) - struct task_struct *kthread = current; -@@ -141,7 +138,7 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr - /* let others run */ - unlock_kernel(); - #else -- daemonize(pThrCntrl->thrParams.pName); -+ //daemonize(pThrCntrl->thrParams.pName); - - /* Enable signals in Kernel >= 2.6 */ - allow_signal(SIGKILL); -@@ -221,9 +218,11 @@ IFX_int32_t IFXOS_ThreadInit( - init_completion(&pThrCntrl->thrCompletion); - - /* start kernel thread via the wrapper function */ -- pThrCntrl->tid = kernel_thread( (IFXOS_KERNEL_THREAD_StartRoutine)IFXOS_KernelThreadStartup, -- (void *)pThrCntrl, -- IFXOS_DRV_THREAD_OPTIONS); -+ pThrCntrl->tid = kthread_run(IFXOS_KernelThreadStartup, (void *)pThrCntrl, pThrCntrl->thrParams.pName); -+ if (IS_ERR(pThrCntrl->tid)) { -+ IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -+ ("IFXOS ERROR - Problem creating thread: %li" IFXOS_CRLF, PTR_ERR(pThrCntrl->tid))); -+ } - - pThrCntrl->bValid = IFX_TRUE; - ---- a/src/include/linux/ifxos_linux_thread.h -+++ b/src/include/linux/ifxos_linux_thread.h -@@ -152,7 +152,7 @@ typedef struct - IFXOS_ThreadFunction_t pThrFct; - - /** Kernel thread process ID */ -- IFX_int32_t tid; -+ struct task_struct *tid; - - /** requested kernel thread priority */ - IFX_int32_t nPriority; ---- a/src/linux/ifxos_linux_socket_drv.c -+++ b/src/linux/ifxos_linux_socket_drv.c -@@ -19,6 +19,7 @@ - /* ============================================================================ +--- a/src/linux/ifxos_linux_memory_map_drv.c ++++ b/src/linux/ifxos_linux_memory_map_drv.c +@@ -25,6 +25,7 @@ IFX Linux adaptation - Global Includes - Kernel ========================================================================= */ + +#include <linux/version.h> #include <linux/kernel.h> #ifdef MODULE #include <linux/module.h> -@@ -166,23 +167,33 @@ IFX_int_t IFXOS_SocketSendTo( - IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR); +@@ -97,8 +98,13 @@ IFX_int32_t IFXOS_Phy2VirtMap( + } -+ iov.iov_base = pBuffer; -+ iov.iov_len = (unsigned int) bufSize_byte; + /* remap memory (not cache able): physical --> virtual */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) + pVirtAddr = (IFX_uint8_t *)ioremap_nocache( physicalAddr, + addrRangeSize_byte ); ++#else ++ pVirtAddr = (IFX_uint8_t *)ioremap(physicalAddr, addrRangeSize_byte); ++#endif + - msg.msg_name = (void *) pSocAddr; - msg.msg_namelen = sizeof(IFXOS_sockAddr_t); -- msg.msg_iov = &iov; -- msg.msg_iovlen = 1; - msg.msg_control = IFX_NULL; - msg.msg_controllen = 0; - msg.msg_flags = MSG_DONTWAIT; - -- msg.msg_iov->iov_base = pBuffer; -- msg.msg_iov->iov_len = (unsigned int) bufSize_byte; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; + if (pVirtAddr == IFX_NULL) + { + IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, +--- a/src/linux/ifxos_linux_socket_drv.c ++++ b/src/linux/ifxos_linux_socket_drv.c +@@ -165,8 +165,12 @@ IFX_int_t IFXOS_SocketRecvFrom( + IFXOS_sockAddr_t *pSocAddr) + { + struct msghdr msg; ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0) + struct iovec iov; + mm_segment_t old_fs; +#else -+ iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, bufSize_byte); ++ struct kvec iov; +#endif + int ret; - /* Modify address limitation which is used if user space is calling - kernel space, otherwise sock_sendmsg() will fail.*/ - old_fs = get_fs(); - set_fs(KERNEL_DS); + IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); +@@ -181,6 +185,8 @@ IFX_int_t IFXOS_SocketRecvFrom( + msg.msg_controllen = 0; + msg.msg_flags = 0; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) - ret = sock_sendmsg((struct socket *) socFd, &msg, bufSize_byte); -+#else -+ ret = sock_sendmsg((struct socket *) socFd, &msg); -+#endif ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0) + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)) + msg.msg_iov = &iov; + msg.msg_iovlen = 1; +@@ -200,6 +206,10 @@ IFX_int_t IFXOS_SocketRecvFrom( + #endif set_fs(old_fs); ++#else ++ ret = kernel_recvmsg (socFd, &msg, &iov, 1, bufSize_byte, 0); ++#endif ++ return ret; ---- a/src/linux/ifxos_linux_memory_map_drv.c -+++ b/src/linux/ifxos_linux_memory_map_drv.c -@@ -25,6 +25,7 @@ - IFX Linux adaptation - Global Includes - Kernel - ========================================================================= */ + } -+#include <linux/version.h> - #include <linux/kernel.h> - #ifdef MODULE - #include <linux/module.h> -@@ -87,6 +88,7 @@ IFX_int32_t IFXOS_Phy2VirtMap( - IFXOS_RETURN_IF_POINTER_NOT_NULL(*ppVirtAddr, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(addrRangeSize_byte, IFX_ERROR); +@@ -229,8 +239,12 @@ IFX_int_t IFXOS_SocketSendTo( + IFXOS_sockAddr_t *pSocAddr) + { + struct msghdr msg; ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0) + struct iovec iov; + mm_segment_t old_fs; ++#else ++ struct kvec iov; ++#endif + int ret; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) - if ( check_mem_region(physicalAddr, addrRangeSize_byte) ) - { - IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -@@ -98,10 +100,25 @@ IFX_int32_t IFXOS_Phy2VirtMap( + IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); +@@ -245,6 +259,8 @@ IFX_int_t IFXOS_SocketSendTo( + msg.msg_controllen = 0; + msg.msg_flags = MSG_DONTWAIT; - /* can't fail */ - request_mem_region(physicalAddr, addrRangeSize_byte, pName); -+#else -+ if ( !request_mem_region(physicalAddr, addrRangeSize_byte, pName) ) -+ { -+ IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -+ ("IFXOS: ERROR Phy2Virt map, region request - addr 0x%08lX (size 0x%lX) not free" IFXOS_CRLF, -+ physicalAddr, addrRangeSize_byte)); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0) + -+ return IFX_ERROR; -+ } -+#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)) + msg.msg_iov = &iov; + msg.msg_iovlen = 1; +@@ -264,6 +280,10 @@ IFX_int_t IFXOS_SocketSendTo( + #endif + set_fs(old_fs); - /* remap memory (not cache able): physical --> virtual */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) - pVirtAddr = (IFX_uint8_t *)ioremap_nocache( physicalAddr, - addrRangeSize_byte ); +#else -+ pVirtAddr = (IFX_uint8_t *)ioremap(physicalAddr, addrRangeSize_byte); ++ ret = kernel_sendmsg(socFd, &msg, &iov, 1, bufSize_byte); +#endif + - if (pVirtAddr == IFX_NULL) - { - IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, + return ret; + } + +--- a/src/linux/ifxos_linux_thread_drv.c ++++ b/src/linux/ifxos_linux_thread_drv.c +@@ -154,7 +154,11 @@ IFXOS_STATIC int IFXOS_KernelThreadStart + retVal = pThrCntrl->pThrFct(&pThrCntrl->thrParams); + pThrCntrl->thrParams.bRunning = IFX_FALSE; + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) ++ kthread_complete_and_exit(&pThrCntrl->thrCompletion, (long)retVal); ++#else + complete_and_exit(&pThrCntrl->thrCompletion, (long)retVal); ++#endif + + IFXOS_PRN_USR_DBG_NL( IFXOS, IFXOS_PRN_LEVEL_NORMAL, + ("EXIT - Kernel Thread Startup <%s>" IFXOS_CRLF, diff --git a/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch b/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch deleted file mode 100644 index 453d85849b7..00000000000 --- a/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 7d52945b0b261c54ec736ecc435936c5fb8b81a4 Mon Sep 17 00:00:00 2001 -From: Yousong Zhou <yszhou4tech@gmail.com> -Date: Thu, 30 Nov 2017 11:07:12 +0800 -Subject: [PATCH] Fix app compilation failure from inclusion of wrong headers - -Compiling against glibc can fail with the following errors - - In file included from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/bits/fcntl-linux.h:321:0, - from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/bits/fcntl.h:104, - from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/fcntl.h:35, - from linux/ifxos_linux_device_access_appl.c:30: - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:12:2: error: unknown type name '__s16' - __s16 l_type; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:13:2: error: unknown type name '__s16' - __s16 l_whence; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:14:2: error: unknown type name '__s64' - __s64 l_start; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:15:2: error: unknown type name '__s64' - __s64 l_len; /* len == 0 means until end of file */ - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:16:2: error: unknown type name '__s32' - __s32 l_sysid; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:17:2: error: unknown type name '__u32' - __u32 l_pid; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:18:2: error: unknown type name '__s32' - __s32 l_pad[4]; /* reserved area */ - ^ - Makefile:1945: recipe for target 'libifxos_a-ifxos_linux_device_access_appl.o' failed - -Ref: https://bugs.openwrt.org/index.php?do=details&task_id=1196 ---- - src/Makefile.am | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -14,11 +14,7 @@ lib_LIBRARIES = libifxos.a - - AM_CPPFLAGS = \ - -I@srcdir@\ -- -I@srcdir@/include \ -- -I@KERNEL_INCL_PATH@ \ -- -I@KERNEL_BUILD_PATH@/include \ -- -I@KERNEL_BUILD_PATH@/include2 \ -- -I$(TARGET_INCL_PATH) -+ -I@srcdir@/include - - if HAVE_GCC - diff --git a/package/kernel/lantiq/ltq-ptm/Makefile b/package/kernel/lantiq/ltq-ptm/Makefile index 33a23d6853f..b726cb1560d 100644 --- a/package/kernel/lantiq/ltq-ptm/Makefile +++ b/package/kernel/lantiq/ltq-ptm/Makefile @@ -24,9 +24,9 @@ define KernelPackage/ltq-ptm-template VARIANT:=$(1) DEPENDS:=@TARGET_lantiq_$(2) ifeq ($(1),vr9) - DEPENDS+= +kmod-ltq-vdsl-vr9-mei + DEPENDS+= +PACKAGE_kmod-ltq-ptm-$(1):kmod-ltq-vdsl-vr9-mei else - DEPENDS+= +kmod-ltq-adsl-$(1)-mei + DEPENDS+= +PACKAGE_kmod-ltq-ptm-$(1):kmod-ltq-adsl-$(1)-mei endif ifeq ($(1),ase) DEPENDS+=@BROKEN diff --git a/package/kernel/lantiq/ltq-ptm/patches/100-fix-compilation-warning-debugfs.patch b/package/kernel/lantiq/ltq-ptm/patches/100-fix-compilation-warning-debugfs.patch new file mode 100644 index 00000000000..283982fdef0 --- /dev/null +++ b/package/kernel/lantiq/ltq-ptm/patches/100-fix-compilation-warning-debugfs.patch @@ -0,0 +1,33 @@ +--- a/ifxmips_ptm_adsl.c ++++ b/ifxmips_ptm_adsl.c +@@ -175,9 +175,11 @@ static INLINE void mailbox_signal(unsign + */ + static INLINE void proc_file_create(void); + static INLINE void proc_file_delete(void); ++#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC + static int proc_read_version(char *, char **, off_t, int, int *, void *); + static int proc_read_wanmib(char *, char **, off_t, int, int *, void *); + static int proc_write_wanmib(struct file *, const char *, unsigned long, void *); ++#endif + #if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC + static int proc_read_genconf(char *, char **, off_t, int, int *, void *); + #endif +@@ -889,6 +891,7 @@ static INLINE void proc_file_delete(void + remove_proc_entry("driver/ifx_ptm", NULL); + } + ++#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC + static int proc_read_version(char *buf, char **start, off_t offset, int count, int *eof, void *data) + { + int len = 0; +@@ -963,8 +966,9 @@ static int proc_write_wanmib(struct file + + return count; + } ++#endif + +-#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC ++#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC && defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC + + static int proc_read_genconf(char *page, char **start, off_t off, int count, int *eof, void *data) + { diff --git a/package/kernel/lantiq/ltq-ptm/patches/101-fix-more-compilation-warning-debugfs.patch b/package/kernel/lantiq/ltq-ptm/patches/101-fix-more-compilation-warning-debugfs.patch new file mode 100644 index 00000000000..f854662a078 --- /dev/null +++ b/package/kernel/lantiq/ltq-ptm/patches/101-fix-more-compilation-warning-debugfs.patch @@ -0,0 +1,38 @@ +--- a/ifxmips_ptm_adsl.c ++++ b/ifxmips_ptm_adsl.c +@@ -180,7 +180,7 @@ static int proc_read_version(char *, char **, off_t, int, int *, void *); + static int proc_read_wanmib(char *, char **, off_t, int, int *, void *); + static int proc_write_wanmib(struct file *, const char *, unsigned long, void *); + #endif +-#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC ++#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC && defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC + static int proc_read_genconf(char *, char **, off_t, int, int *, void *); + #endif + #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC +@@ -191,8 +191,8 @@ static int proc_write_wanmib(struct file *, const char *, unsigned long, void *) + /* + * Proc Help Functions + */ +-static INLINE int stricmp(const char *, const char *); + #if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC ++ static INLINE int stricmp(const char *, const char *); + static INLINE int strincmp(const char *, const char *, int); + #endif + static INLINE int ifx_ptm_version(char *); +@@ -1159,8 +1159,6 @@ static int proc_write_dbg(struct file *file, const char *buf, unsigned long coun + return count; + } + +-#endif // defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC +- + static INLINE int stricmp(const char *p1, const char *p2) + { + int c1, c2; +@@ -1178,7 +1176,6 @@ static INLINE int stricmp(const char *p1, const char *p2) + return *p1 - *p2; + } + +-#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC + static INLINE int strincmp(const char *p1, const char *p2, int n) + { + int c1 = 0, c2; diff --git a/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c b/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c index d751680853a..dfb57787b96 100644 --- a/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c +++ b/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c @@ -146,6 +146,8 @@ unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR; static void ptm_setup(struct net_device *dev, int ndev) { + u8 addr[ETH_ALEN]; + netif_carrier_off(dev); dev->netdev_ops = &g_ptm_netdev_ops; @@ -154,12 +156,13 @@ static void ptm_setup(struct net_device *dev, int ndev) netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 16); dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT; - dev->dev_addr[0] = 0x00; - dev->dev_addr[1] = 0x20; - dev->dev_addr[2] = 0xda; - dev->dev_addr[3] = 0x86; - dev->dev_addr[4] = 0x23; - dev->dev_addr[5] = 0x75 + ndev; + addr[0] = 0x00; + addr[1] = 0x20; + addr[2] = 0xda; + addr[3] = 0x86; + addr[4] = 0x23; + addr[5] = 0x75 + ndev; + eth_hw_addr_set(dev, addr); } static struct net_device_stats *ptm_get_stats(struct net_device *dev) @@ -557,7 +560,6 @@ static inline int get_tx_desc(unsigned int itf, unsigned int *f_full) static irqreturn_t mailbox_irq_handler(int irq, void *dev_id) { unsigned int isr; - int i; isr = IFX_REG_R32(MBOX_IGU1_ISR); IFX_REG_W32(isr, MBOX_IGU1_ISRC); diff --git a/package/kernel/lantiq/ltq-tapi/Makefile b/package/kernel/lantiq/ltq-tapi/Makefile index 77728644f60..d44eeae5658 100644 --- a/package/kernel/lantiq/ltq-tapi/Makefile +++ b/package/kernel/lantiq/ltq-tapi/Makefile @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=drv_tapi PKG_VERSION:=3.13.0 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=drv_tapi-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@OPENWRT diff --git a/package/kernel/lantiq/ltq-tapi/patches/410-custom_pulsedigit_time.patch b/package/kernel/lantiq/ltq-tapi/patches/410-custom_pulsedigit_time.patch new file mode 100644 index 00000000000..965b8be9602 --- /dev/null +++ b/package/kernel/lantiq/ltq-tapi/patches/410-custom_pulsedigit_time.patch @@ -0,0 +1,52 @@ +--- a/src/drv_tapi.h ++++ b/src/drv_tapi.h +@@ -25,6 +25,7 @@ + #include <lib_bufferpool.h> + #include "drv_tapi_io.h" + #include "drv_tapi_event.h" ++#include <linux/module.h> + + + /* ============================= */ +--- a/src/drv_tapi_dial.c ++++ b/src/drv_tapi_dial.c +@@ -20,6 +20,19 @@ + #include "drv_tapi.h" + #include "drv_tapi_errno.h" + ++ ++ ++static unsigned int min_digit_low = TAPI_MIN_DIGIT_LOW; ++static unsigned int max_digit_low = TAPI_MAX_DIGIT_LOW; ++static unsigned int min_digit_high = TAPI_MIN_DIGIT_HIGH; ++static unsigned int max_digit_high = TAPI_MAX_DIGIT_HIGH; ++static unsigned int min_interdigit = TAPI_MIN_INTERDIGIT; ++module_param(min_digit_low, uint, 0); ++module_param(max_digit_low, uint, 0); ++module_param(min_digit_high, uint, 0); ++module_param(max_digit_high, uint, 0); ++module_param(min_interdigit, uint, 0); ++ + /*lint -save -esym(749, TAPI_HOOK_STATE_PULSE_H_FLASH_VAL) */ + /* ============================= */ + /* Local macros and definitions */ +@@ -408,14 +421,14 @@ IFX_int32_t IFX_TAPI_Dial_Initialise(TAP + } + } + /* set default values for the validation timers */ +- pTapiDialData->TapiDigitLowTime.nMinTime = TAPI_MIN_DIGIT_LOW; +- pTapiDialData->TapiDigitLowTime.nMaxTime = TAPI_MAX_DIGIT_LOW; +- pTapiDialData->TapiDigitHighTime.nMinTime = TAPI_MIN_DIGIT_HIGH; +- pTapiDialData->TapiDigitHighTime.nMaxTime = TAPI_MAX_DIGIT_HIGH; ++ pTapiDialData->TapiDigitLowTime.nMinTime = min_digit_low; ++ pTapiDialData->TapiDigitLowTime.nMaxTime = max_digit_low; ++ pTapiDialData->TapiDigitHighTime.nMinTime = min_digit_high; ++ pTapiDialData->TapiDigitHighTime.nMaxTime = max_digit_high; + pTapiDialData->TapiHookFlashTime.nMinTime = TAPI_MIN_FLASH; + pTapiDialData->TapiHookFlashTime.nMaxTime = TAPI_MAX_FLASH; + pTapiDialData->TapiHookFlashMakeTime.nMinTime = TAPI_MIN_FLASH_MAKE; +- pTapiDialData->TapiInterDigitTime.nMinTime = TAPI_MIN_INTERDIGIT; ++ pTapiDialData->TapiInterDigitTime.nMinTime = min_interdigit; + pTapiDialData->TapiHookOffTime.nMinTime = TAPI_MIN_OFF_HOOK; + pTapiDialData->TapiHookOnTime.nMinTime = TAPI_MIN_ON_HOOK; + /* start hook state FSM in onhook state */ diff --git a/package/kernel/lantiq/ltq-tapi/patches/500-linux-509.patch b/package/kernel/lantiq/ltq-tapi/patches/500-linux-509.patch index 586af59d856..07f61aa6326 100644 --- a/package/kernel/lantiq/ltq-tapi/patches/500-linux-509.patch +++ b/package/kernel/lantiq/ltq-tapi/patches/500-linux-509.patch @@ -34,6 +34,16 @@ } +@@ -3800,7 +3808,9 @@ module_exit (ifx_tapi_module_exit); + + MODULE_AUTHOR ("Lantiq Deutschland GmbH"); + MODULE_DESCRIPTION ("TAPI Driver - www.lantiq.com"); ++#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,10,0) + MODULE_SUPPORTED_DEVICE ("TAPI DEVICE"); ++#endif + MODULE_LICENSE ("Dual BSD/GPL"); + + EXPORT_SYMBOL (IFX_TAPI_Register_LL_Drv); --- a/src/drv_tapi_kpi.c +++ b/src/drv_tapi_kpi.c @@ -134,7 +134,11 @@ extern IFX_int32_t block_ingre diff --git a/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch b/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch new file mode 100644 index 00000000000..ee20c6caf7c --- /dev/null +++ b/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch @@ -0,0 +1,14 @@ +--- a/src/drv_tapi_linux.c ++++ b/src/drv_tapi_linux.c +@@ -3779,8 +3779,10 @@ IFX_void_t TAPI_OS_ThreadKill(IFXOS_Thre + mb(); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + kill_proc(pThrCntrl->tid, SIGKILL, 1); +-#else ++#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) + kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1); ++#else ++ kill_pid(get_task_pid(pThrCntrl->tid, PIDTYPE_PID), SIGKILL, 1); + #endif + /* release the big kernel lock */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) diff --git a/package/kernel/lantiq/ltq-tapi/patches/600-fix-compilation-warning-switch-fallthrough.patch b/package/kernel/lantiq/ltq-tapi/patches/600-fix-compilation-warning-switch-fallthrough.patch new file mode 100644 index 00000000000..bb27ff355ad --- /dev/null +++ b/package/kernel/lantiq/ltq-tapi/patches/600-fix-compilation-warning-switch-fallthrough.patch @@ -0,0 +1,114 @@ +--- a/src/drv_tapi_cid.c ++++ b/src/drv_tapi_cid.c +@@ -1424,6 +1424,8 @@ static IFX_int32_t cid_lookup_transparent(TAPI_CIDTX_DATA_t *pTxData, + + cidfsk_set_tx_time (pTxData, &pConfData->TapiCidFskConf); + ++ fallthrough; ++ + case IFX_TAPI_CID_GEN_TYPE_DTMF: + memcpy (pTxData->cidBuf[IFX_TAPI_CID_GEN_TYPE_DTMF].pBuf, + pMessage[0].transparent.data, pMessage[0].transparent.len); +@@ -1497,6 +1499,7 @@ static IFX_int32_t cid_prepare_data(TAPI_CHANNEL *pChannel, + break; + case IFX_TAPI_CID_STD_KPN_DTMF: + /*lint -fallthrough*/ ++ fallthrough; + case IFX_TAPI_CID_STD_KPN_DTMF_FSK: + if (IFX_TAPI_CID_HM_ONHOOK == pTxData->txHookMode) + { +@@ -1506,6 +1509,7 @@ static IFX_int32_t cid_prepare_data(TAPI_CHANNEL *pChannel, + } + /* KPN CID Type 2 (off-hook) always using FSK */ + /*lint -fallthrough*/ ++ fallthrough; + default: + pTxData->cidGenType = IFX_TAPI_CID_GEN_TYPE_FSK; + break; +@@ -1532,6 +1536,7 @@ static IFX_int32_t cid_prepare_data(TAPI_CHANNEL *pChannel, + break; + + /*lint -fallthrough*/ ++ fallthrough; + case IFX_TAPI_CID_GEN_TYPE_FSK: + + if (IFX_TAPI_CID_STD_NTT == pConfData->nStandard) +@@ -2036,6 +2041,7 @@ static FSM_STATUS_t cid_fsm_alert_exec(TAPI_CHANNEL *pChannel) + } + pTxData->nCidSubState++; + /*lint -fallthrough*/ ++ fallthrough; + case 1: + if (pConfData->OSIoffhook && pConfData->nSAStone) + { +@@ -2052,6 +2058,7 @@ static FSM_STATUS_t cid_fsm_alert_exec(TAPI_CHANNEL *pChannel) + } + pTxData->nCidSubState++; + /*lint -fallthrough*/ ++ fallthrough; + case 2: + if (pConfData->nSAStone) + { +@@ -2069,6 +2076,7 @@ static FSM_STATUS_t cid_fsm_alert_exec(TAPI_CHANNEL *pChannel) + } + pTxData->nCidSubState++; + /*lint -fallthrough*/ ++ fallthrough; + default: + /* Play CAS tone on data channel, use unprotected function, protection + is done around cid_fsm_alert_exec */ +@@ -3458,6 +3466,7 @@ IFX_int32_t TAPI_Phone_CID_Stop_Tx(TAPI_CHANNEL *pChannel) + } + /* deliberately fall through */ + /*lint -fallthrough*/ ++ fallthrough; + case TAPI_CID_STATE_ACK: + /* deactivate the DTMF override - last two params are ignored */ + if (ptr_chk(pDrvCtx->SIG.DTMFD_Override, "")) +@@ -3469,6 +3478,7 @@ IFX_int32_t TAPI_Phone_CID_Stop_Tx(TAPI_CHANNEL *pChannel) + } + /* deliberately fall through */ + /*lint -fallthrough*/ ++ fallthrough; + case TAPI_CID_STATE_SENDING: + TAPI_Stop_Timer (pTxData->CidTimerID); + break; +@@ -4066,6 +4076,7 @@ IFX_int32_t TAPI_Phone_Get_CidRxData (TAPI_CHANNEL *pChannel, + /* If the fifo is not empty take the data from the fifo first. */ + /* deliberately fallthrough to default case */ + /*lint -fallthrough*/ ++ fallthrough; + default: + /* Allow readout of data in all other states not handled above. + When there is no data in the fifo TAPI_statusErr is returned. */ +--- a/src/drv_tapi_dial.c ++++ b/src/drv_tapi_dial.c +@@ -319,6 +319,8 @@ static IFX_void_t ifx_tapi_dial_OnTimer(Timer_ID Timer, IFX_ulong_t nArg) + /* NOTE: the "break" statement has been intentionally omitted */ + /*lint -fallthrough */ + ++ fallthrough; ++ + case TAPI_HOOK_STATE_DIAL_L_VAL: + /* digit_l_min expires: onhook has lasted long enough to be a + certain low pulse (not noise). The next state is the overlap with +--- a/src/drv_tapi_event.c ++++ b/src/drv_tapi_event.c +@@ -1545,6 +1545,7 @@ IFX_int32_t IFX_TAPI_Event_Dispatch_ProcessCtx(IFX_TAPI_EXT_EVENT_PARAM_t* + /**\todo put in device fifo */ + pEvent->ch = IFX_TAPI_DEVICE_CH_NUMBER; + /*lint -fallthrough */ ++ fallthrough; + case IFX_TAPI_ERRSRC_LL_CH: + pEvent->data.value |= IFX_TAPI_ERRSRC_LL; + break; +--- a/src/drv_tapi_ioctl.c ++++ b/src/drv_tapi_ioctl.c +@@ -1552,6 +1553,7 @@ static IFX_int32_t TAPI_IoctlCh (IFX_TAPI_DRV_CTX_t* pDrvCtx, + /* Dial Services */ + ret = TAPI_statusNotSupported; + /*lint -fallthrough*/ ++ fallthrough; + default: + bHandled = IFX_FALSE; + break; diff --git a/package/kernel/lantiq/ltq-tapi/patches/601-fix-compilation-warning-ret-not-handled.patch b/package/kernel/lantiq/ltq-tapi/patches/601-fix-compilation-warning-ret-not-handled.patch new file mode 100644 index 00000000000..b97ced30f80 --- /dev/null +++ b/package/kernel/lantiq/ltq-tapi/patches/601-fix-compilation-warning-ret-not-handled.patch @@ -0,0 +1,12 @@ +--- a/src/drv_tapi_ioctl.c ++++ b/src/drv_tapi_ioctl.c +@@ -702,7 +702,8 @@ static IFX_int32_t TAPI_IoctlDev (IFX_TAPI_DRV_CTX_t* pDrvCtx, + + if (ret == TAPI_statusOk || ret == 1) + { +- copy_to_user ((IFX_void_t*)ioarg, p_tmp, sizeof(IFX_TAPI_CAP_t)); ++ if (copy_to_user ((IFX_void_t*)ioarg, p_tmp, sizeof(IFX_TAPI_CAP_t))) ++ ret = TAPI_statusErrKernCpy; + } + } + TAPI_OS_Free (p_tmp); diff --git a/package/kernel/lantiq/ltq-vdsl-fw/Makefile b/package/kernel/lantiq/ltq-vdsl-fw/Makefile index 336fc2e5e35..88883ffdee0 100644 --- a/package/kernel/lantiq/ltq-vdsl-fw/Makefile +++ b/package/kernel/lantiq/ltq-vdsl-fw/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ltq-vdsl-fw PKG_VERSION:=6.8.6 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org> diff --git a/package/kernel/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh b/package/kernel/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh index 3d3e5aebee6..c5574ffca24 100755 --- a/package/kernel/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh +++ b/package/kernel/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh @@ -1,9 +1,9 @@ #!/bin/sh -FW="/tmp/firmware-speedport-w921v-1.46.000.bin" -URL="https://www.telekom.de/hilfe/downloads/firmware-speedport-w921v-1.46.000.bin" +FW="/tmp/firmware-speedport-w921v-1.48.000.bin" +URL="https://www.telekom.de/hilfe/downloads/firmware-speedport-w-921v-1.48.000.bin" FW_TAPI="vr9_tapi_fw.bin" FW_DSL="vr9_dsl_fw_annex_b.bin" -MD5_FW="188734c0773b225f8c130984b279621a" +MD5_FW="afa25146119daced87f67c9b66ef94b3" MD5_TAPI="57f2d07f59e11250ce1219bad99c1eda" MD5_DSL="655442e31deaa42c9c68944869361ec0" diff --git a/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c b/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c index 8dc392914cd..92c4be165d1 100644 --- a/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c +++ b/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c @@ -26,7 +26,7 @@ #include "LzmaWrapper.h" -#define FW_NAME "/tmp/firmware-speedport-w921v-1.46.000.bin" +#define FW_NAME "/tmp/firmware-speedport-w921v-1.48.000.bin" #define MAGIC 0x50 #define MAGIC_SZ 0x3FFC00 @@ -78,7 +78,7 @@ int main(int argc, char **argv) if (stat(FW_NAME, &s) != 0) { printf("Failed to find %s\n", FW_NAME); - printf("Ask Google or try https://www.telekom.de/hilfe/downloads/firmware-speedport-w921v-1.45.000.bin\n"); + printf("Ask Google or try https://www.telekom.de/hilfe/downloads/firmware-speedport-w-921v-1.48.000.bin\n"); return -1; } diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile b/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile new file mode 100644 index 00000000000..7b8a948179b --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile @@ -0,0 +1,114 @@ +# Copyright (C) 2012 OpenWrt.org +# Copyright (C) 2015-2016 Lantiq Beteiligungs GmbH & Co KG. +# +# 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:=ltq-vdsl-vr11-mei +PKG_VERSION:=1.11.1 +PKG_RELEASE:=2 +PKG_BASE_NAME:=dsl_cpe_mei + +UGW_VERSION=8.5.2.10 +UGW_BASENAME=$(PKG_BASE_NAME)-ugw_$(UGW_VERSION) + +PKG_SOURCE:=$(UGW_BASENAME).tar.bz2 +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/$(PKG_BASE_NAME)/-/archive/ugw_$(UGW_VERSION)/ +PKG_HASH:=337614473d50ed64de010adaed99a16103e08eea8fc67fe9d6caf155bea33d1d +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(UGW_BASENAME) +PKG_LICENSE:=GPL-2.0 BSD-2-Clause +PKG_LICENSE_FILES:=LICENSE +PKG_EXTMOD_SUBDIRS:=src + +PKG_FIXUP:=autoreconf +PKG_FLAGS:=nonshared +PKG_BUILD_FLAGS:=no-mold + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ltq-vdsl-vr11-mei + TITLE:=mei driver for vdsl + SECTION:=sys + SUBMENU:=Network Devices + DEPENDS:=@TARGET_ipq40xx +kmod-ltq-ifxos +kmod-vrx518_tc + FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko + AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe) +endef + +define KernelPackage/ltq-vdsl-vr11-mei/description + Lantiq MEI CPE Kernel Module Driver +endef + + +define Package/ltq-vdsl-vr11-mei-test + SECTION:=net + CATEGORY:=Network + TITLE:=Lantiq mei driver test tool + URL:=http://www.lantiq.com/ + DEPENDS:=@TARGET_ipq40xx +kmod-ltq-vdsl-vr11-mei +endef + +define Package/ltq-vdsl-vr11-mei-test/description + Userland tool to directly control the mei driver, this is only needed + for test and development purposes. +endef + +MAKE_FLAGS += \ + $(KERNEL_MAKE_FLAGS) \ + SHELL="$(BASH)" + +# ltq-vdsl-app uses a header provided by the MEI driver which has some +# conditionals. +# Define the conditionals here to have the same view on both sides. If you +# change them, you need to change them for the ltq-vdsl-app as well +MEI_DRV_CFLAGS = \ + -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 \ + -DMEI_SUPPORT_DEBUG_STREAMS=1 \ + -DMEI_SUPPORT_OPTIMIZED_FW_DL=1 + +#MEI_DRV_CFLAGS+= \ +# -DMEI_SUPPORT_OPTIMIZED_FW_DL=0 \ +# -DIRQ_POLLING_FORCE=99 + +CONFIGURE_ARGS += \ + --enable-debug-logger-support=no +# --enable-debug-stream-support=no + +# This looks weird, but it's necessary to address the right device. +# (pdev->dev.parent instead of pdev->dev) +MEI_DRV_CFLAGS+= \ + -DMEI_TARGET_x86=1 + +CONFIGURE_ARGS += \ + --enable-kernelincl="$(LINUX_DIR)/include" \ + --enable-device=vr11 \ + --enable-debug \ + --enable-error_print \ + --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos/" \ + --enable-ifxos-library="-L$(STAGING_DIR)/usr/lib" \ + --enable-add_drv_cflags="$(MEI_DRV_CFLAGS)" \ + --enable-linux-26 \ + --enable-kernelbuild="$(LINUX_DIR)" \ + --enable-drv_test_appl=yes \ + ARCH=$(LINUX_KARCH) + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/vdsl + $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_intern.h $(1)/usr/include/vdsl/ + $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_atm_ptm_intern.h $(1)/usr/include/vdsl/ + $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_interface.h $(1)/usr/include/vdsl + $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_config.h $(1)/usr/include/vdsl/ + $(CP) $(PKG_BUILD_DIR)/src/cmv_message_format.h $(1)/usr/include/vdsl/ +endef + +$(eval $(call KernelPackage,ltq-vdsl-vr11-mei)) + +define Package/ltq-vdsl-vr11-mei-test/install + $(INSTALL_DIR) $(1)/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mei_cpe_drv_test $(1)/bin +endef + +$(eval $(call BuildPackage,ltq-vdsl-vr11-mei-test)) diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/001-fix-compile.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/001-fix-compile.patch new file mode 100644 index 00000000000..ff46b1f0886 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/001-fix-compile.patch @@ -0,0 +1,88 @@ +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -1534,7 +1534,7 @@ struct proc_entry { + char name[32]; + proc_rd_callback_t rd; + proc_wr_callback_t wr; +- struct file_operations ops; ++ struct proc_ops ops; + int entity; + }; + +@@ -2068,16 +2068,15 @@ static int mei_proc_single_open(struct i + static void mei_proc_entry_create(struct proc_dir_entry *parent_node, + struct proc_entry *proc_entry) + { +- memset(&proc_entry->ops, 0, sizeof(struct file_operations)); +- proc_entry->ops.owner = THIS_MODULE; ++ memset(&proc_entry->ops, 0, sizeof(struct proc_ops)); + +- proc_entry->ops.open = mei_proc_single_open; +- proc_entry->ops.release = single_release; ++ proc_entry->ops.proc_open = mei_proc_single_open; ++ proc_entry->ops.proc_release = single_release; + +- proc_entry->ops.read = seq_read; +- proc_entry->ops.llseek = seq_lseek; ++ proc_entry->ops.proc_read = seq_read; ++ proc_entry->ops.proc_lseek = seq_lseek; + if (proc_entry->wr) +- proc_entry->ops.write = proc_entry->wr; ++ proc_entry->ops.proc_write = proc_entry->wr; + + proc_create_data(proc_entry->name, + (S_IFREG | S_IRUGO), +--- a/src/drv_mei_cpe_linux.h ++++ b/src/drv_mei_cpe_linux.h +@@ -31,6 +31,7 @@ + #include <linux/module.h> + + #include <linux/sched.h> ++#include <linux/sched/signal.h> + #include <linux/interrupt.h> + #include <linux/version.h> + #include <linux/crc32.h> +@@ -122,7 +123,7 @@ typedef int (*MEI_RequestIrq_WrapLinux_t + /** + Function typedef for the Linux free_irq() + */ +-typedef void (*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq, ++typedef const void *(*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq, + void *usedDevId ); + + +--- a/src/drv_mei_cpe_linux_proc_config.c ++++ b/src/drv_mei_cpe_linux_proc_config.c +@@ -1277,13 +1277,12 @@ static int mei_proc_single_open(struct i + return single_open(file, mei_seq_single_show, PDE_DATA(inode)); + } + +-static struct file_operations proc_ops = { +- .owner = THIS_MODULE, +- .open = mei_proc_single_open, +- .release = single_release, +- .read = seq_read, +- .llseek = seq_lseek, +- .write = MEI_ProcWriteConfig ++static struct proc_ops proc_ops = { ++ .proc_open = mei_proc_single_open, ++ .proc_release = single_release, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_write = MEI_ProcWriteConfig + }; + + /** +--- a/src/mei_cpe_appl_osmap.h ++++ b/src/mei_cpe_appl_osmap.h +@@ -38,10 +38,6 @@ extern "C" + #include <errno.h> + #include <ctype.h> + #include <sys/ioctl.h> +- +-extern int snprintf (char *__restrict __s, size_t __maxlen, +- __const char *__restrict __format, ...) +- __THROW __attribute__ ((__format__ (__printf__, 3, 4))); + #endif + + /* ========================================================================== diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/010-warnings.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/010-warnings.patch new file mode 100644 index 00000000000..f6ee2f7f8bb --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/010-warnings.patch @@ -0,0 +1,20 @@ +--- a/src/drv_mei_cpe_dbg_driver.c ++++ b/src/drv_mei_cpe_dbg_driver.c +@@ -309,7 +309,7 @@ MEI_STATIC IFX_void_t MEI_DbgMsgDumpLogW + IFX_int32_t i; + unsigned short paylSize; + union {IFX_uint8_t d8[2]; IFX_uint16_t d16;} temp16; +- union {IFX_uint8_t d8[4]; IFX_uint16_t d32;} temp32; ++ union {IFX_uint8_t d8[4]; IFX_uint32_t d32;} temp32; + + MEI_DbgMsgDumpLogLabel(pCmvMsg, fctOpCode); + +@@ -368,7 +368,7 @@ MEI_STATIC IFX_void_t MEI_DbgMsgDumpTrcW + IFX_int32_t i; + unsigned short paylSize; + union {IFX_uint8_t d8[2]; IFX_uint16_t d16;} temp16; +- union {IFX_uint8_t d8[4]; IFX_uint16_t d32;} temp32; ++ union {IFX_uint8_t d8[4]; IFX_uint32_t d32;} temp32; + + MEI_DbgMsgDumpTraceLabel(pCmvMsg, fctOpCode); + diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/020-not-leak-cflags.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/020-not-leak-cflags.patch new file mode 100644 index 00000000000..f6fb48ed6ea --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/020-not-leak-cflags.patch @@ -0,0 +1,12 @@ +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -213,8 +213,7 @@ drv_mei_cpe_common_cflags = $(AM_CFLAGS) + else + + drv_mei_cpe_common_cflags = \ +- $(AM_CFLAGS) -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB \ +- -pipe -Wall -Wimplicit -Wunused -Wuninitialized -Wstrict-aliasing -Wno-date-time ++ -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB + + endif + diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/100-compat.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/100-compat.patch new file mode 100644 index 00000000000..74e88894d8f --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/100-compat.patch @@ -0,0 +1,23 @@ +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -4530,7 +4530,6 @@ module_exit (MEI_module_exit); + #ifdef MODULE + MODULE_AUTHOR("www.lantiq.com"); + MODULE_DESCRIPTION("MEI CPE Driver - www.lantiq.com"); +-MODULE_SUPPORTED_DEVICE("MEI CPE Interface"); + MODULE_LICENSE ("GPL"); + #endif /* #ifdef MODULE*/ + +--- a/src/drv_mei_cpe_linux.h ++++ b/src/drv_mei_cpe_linux.h +@@ -110,6 +110,10 @@ typedef irqreturn_t (*usedIsrHandler_t)( + # endif + #endif + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) ++#define PDE_DATA pde_data ++#endif ++ + /** + Function typedef for the Linux request_threaded_irq() + */ diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/101_no-date-time.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/101_no-date-time.patch index 055797ad4d8..18918b9956c 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/101_no-date-time.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/101_no-date-time.patch @@ -1,8 +1,8 @@ --- a/src/drv_mei_cpe_linux.c +++ b/src/drv_mei_cpe_linux.c -@@ -1503,8 +1503,8 @@ struct proc_entry { - static void MEI_GetVersionProc(struct seq_file *s) - { +@@ -1556,8 +1556,8 @@ static void MEI_GetVersionProc(struct se + } + seq_printf(s, "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]); - seq_printf(s, "Compiled on %s, %s for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF, - __DATE__, __TIME__, UTS_RELEASE, jiffies); diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch new file mode 100644 index 00000000000..f57b8f076fb --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch @@ -0,0 +1,12 @@ +--- a/src/drv_mei_cpe_api_atm_ptm_intern.c ++++ b/src/drv_mei_cpe_api_atm_ptm_intern.c +@@ -152,6 +152,9 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit + /* Get line number*/ + dslLineNum = pMeiDynCntrl->pMeiDev->meiDrvCntrl.dslLineNum; + ++ g_tx_link_rate[dslLineNum][0] = 0; ++ g_tx_link_rate[dslLineNum][1] = 0; ++ + #ifdef PPA_SUPPORTS_CALLBACKS + /* get NULL or function pointer */ + mei_showtime_exit = diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/120-remove-debug-printk.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/120-remove-debug-printk.patch new file mode 100644 index 00000000000..24db470c4ae --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/120-remove-debug-printk.patch @@ -0,0 +1,10 @@ +--- a/src/drv_mei_cpe_mei_access_vrx.c ++++ b/src/drv_mei_cpe_mei_access_vrx.c +@@ -1691,7 +1691,6 @@ IFX_int32_t MEI_InterfaceDetect( + { + MEI_REG_ACCESS_ME_VERSION_SET(pMeiDrvCntrl, 0x00000000); + hwVers = MEI_REG_ACCESS_ME_VERSION_GET(pMeiDrvCntrl); +- printk ("hwVers=0x%08X\n", hwVers); + + if (MEI_DEVICE_CFG_IS_PLATFORM(e_MEI_DEV_PLATFORM_CONFIG_VR9)) + { diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/121-cpe-api-intern-dynamically-allocate-dump-msg.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/121-cpe-api-intern-dynamically-allocate-dump-msg.patch new file mode 100644 index 00000000000..40ba73f66bb --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/121-cpe-api-intern-dynamically-allocate-dump-msg.patch @@ -0,0 +1,99 @@ +--- a/src/drv_mei_cpe_api_intern.c ++++ b/src/drv_mei_cpe_api_intern.c +@@ -421,7 +421,9 @@ IFX_int32_t MEI_InternalMsgSend( + return retVal; + } + +-static IFX_void_t MEI_Internal_DumpMessage( ++#define MEI_Internal_DumpMessage_bufSize 10 ++ ++static IFX_int32_t MEI_Internal_DumpMessage( + MEI_DYN_CNTRL_T *pMeiDynCntrl, + const IFX_uint16_t nMsgId, + const IFX_uint16_t *pData, +@@ -435,15 +437,20 @@ static IFX_void_t MEI_Internal_DumpMessa + IFX_uint8_t i; + const IFX_uint32_t nCommonPayloadSize = 5*nSize/2; + const IFX_uint8_t nInfoSize = 35; +- const IFX_uint8_t nBufSize = 10; + IFX_uint32_t nMsgSize = nCommonPayloadSize + nInfoSize; + IFX_uint32_t nCharsWrittenToBuf = 0; +- char msg[nMsgSize]; +- char buf[nBufSize]; ++ char *msg; ++ char buf[MEI_Internal_DumpMessage_bufSize]; + + if((pData == IFX_NULL) || (nSize < 4)) + { +- return ; ++ return 0; ++ } ++ ++ msg = kcalloc(nMsgSize, sizeof(*msg), GFP_KERNEL); ++ if (!msg) ++ { ++ return -ENOMEM; + } + + pMsg16 = (IFX_uint16_t*)(pData+2); +@@ -464,7 +471,8 @@ static IFX_void_t MEI_Internal_DumpMessa + /* 32-bit payload elements */ + for (i=0; i<((nSize-4)/4); i++) + { +- nCharsWrittenToBuf = snprintf(buf, nBufSize, " %08X", pMsg32[i]); ++ nCharsWrittenToBuf = snprintf(buf, MEI_Internal_DumpMessage_bufSize, ++ " %08X", pMsg32[i]); + strncat(msg, buf, nMsgSize); + nMsgSize -= nCharsWrittenToBuf; + } +@@ -474,7 +482,8 @@ static IFX_void_t MEI_Internal_DumpMessa + /* 16-bit payload elements */ + for (i=0; i<((nSize-4)/2); i++) + { +- nCharsWrittenToBuf = snprintf(buf, nBufSize, " %04X", pMsg16[i]); ++ nCharsWrittenToBuf = snprintf(buf, MEI_Internal_DumpMessage_bufSize, ++ " %04X", pMsg16[i]); + strncat(msg, buf, nMsgSize); + nMsgSize -= nCharsWrittenToBuf; + } +@@ -482,6 +491,10 @@ static IFX_void_t MEI_Internal_DumpMessa + strncat(msg, MEI_DRV_CRLF, nMsgSize); + + PRN_DBG_USR_RAW(MEI_MSG_DUMP_API, dbg_level, (msg)); ++ ++ kfree(msg); ++ ++ return 0; + } + + IFX_int32_t MEI_InternalSendMessage( +@@ -503,18 +516,25 @@ IFX_int32_t MEI_InternalSendMessage( + msg.ack_msg.pPayload = (unsigned char *)pDataAck; + msg.ack_msg.paylSize_byte = nLenAck; + +- MEI_Internal_DumpMessage(pMeiDynCntrl, msg.write_msg.msgId, ++ ret = MEI_Internal_DumpMessage(pMeiDynCntrl, msg.write_msg.msgId, + (IFX_uint16_t *)msg.write_msg.pPayload, msg.write_msg.paylSize_byte, + IFX_FALSE, MEI_DRV_PRN_LEVEL_NORMAL); + ++ if (ret < 0) ++ { ++ return ret; ++ } ++ + ret = MEI_InternalMsgSend(pMeiDynCntrl, &msg); + +- if (ret >= 0) ++ if (ret < 0) + { +- MEI_Internal_DumpMessage(pMeiDynCntrl, msg.ack_msg.msgId, ++ return ret; ++ } ++ ++ ret = MEI_Internal_DumpMessage(pMeiDynCntrl, msg.ack_msg.msgId, + (IFX_uint16_t *)msg.ack_msg.pPayload, msg.ack_msg.paylSize_byte, + IFX_TRUE, MEI_DRV_PRN_LEVEL_NORMAL); +- } + + return ret; + } diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/122-cp_linux-fix-compilation-warning.patch b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/122-cp_linux-fix-compilation-warning.patch new file mode 100644 index 00000000000..6f180a284ec --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/patches/122-cp_linux-fix-compilation-warning.patch @@ -0,0 +1,52 @@ +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -1267,7 +1267,9 @@ static long MEI_Ioctl( struct file *filp + MEI_IOCTL_RETURN: + + local_args.drv_ioctl.retCode = ret; +- copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize); ++ if (copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize)) ++ PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_ERR, ++ ("MEI_DRV[??] Error ioctl - copy_to_user failed!" MEI_DRV_CRLF)); + + return (ret < 0) ? -1 : 0; + } +@@ -3571,9 +3573,11 @@ static int MEI_IoctlMeiDbgAccessWr_Wrap( + ret = MEI_IoctlMeiDbgAccessWr( pMeiDynCntrl, pLocalArgument); + + /* return arguments - count */ +- copy_to_user( (void *)&pUserArgument->count, ++ if (copy_to_user( (void *)&pUserArgument->count, + (void *)&pLocalArgument->count, +- sizeof(pUserArgument->count) ) ; ++ sizeof(pUserArgument->count) )) ++ PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_ERR, ++ ("MEI_DRV[??] Error ioctl - copy_to_user failed!" MEI_DRV_CRLF)); + + return ret; + } +@@ -3600,16 +3604,20 @@ static int MEI_IoctlMeiDbgAccessRd_Wrap( + if ( pLocalArgument->count ) + { + /* return the buffer */ +- copy_to_user( pUserBuf, ++ if (copy_to_user( pUserBuf, + pLocalArgument->pData_32, +- pLocalArgument->count * sizeof(IFX_uint32_t) ) ; ++ pLocalArgument->count * sizeof(IFX_uint32_t) )) ++ PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_ERR, ++ ("MEI_DRV[??] Error ioctl - copy_to_user failed!" MEI_DRV_CRLF)); + + } + + /* return count argument */ +- copy_to_user( (void *)&pUserArgument->count, ++ if (copy_to_user( (void *)&pUserArgument->count, + (void *)&pLocalArgument->count, +- sizeof(pUserArgument->count) ) ; ++ sizeof(pUserArgument->count) )) ++ PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_ERR, ++ ("MEI_DRV[??] Error ioctl - copy_to_user failed!" MEI_DRV_CRLF)); + + return ret; + } diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/Makefile b/package/kernel/lantiq/ltq-vdsl-vr11/Makefile new file mode 100644 index 00000000000..11f96d744a4 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/Makefile @@ -0,0 +1,81 @@ +# Copyright (C) 2012 OpenWrt.org +# Copyright (C) 2015-2016 Lantiq Beteiligungs GmbH & Co KG. +# +# 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:=ltq-vdsl-vr11 +PKG_VERSION:=4.23.1 +PKG_RELEASE:=2 +PKG_BASE_NAME:=dsl_cpe_api + +UGW_VERSION=8.5.2.10 +UGW_BASENAME=$(PKG_BASE_NAME)-ugw_$(UGW_VERSION) + +PKG_SOURCE:=$(UGW_BASENAME).tar.bz2 +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/$(PKG_BASE_NAME)/-/archive/ugw_$(UGW_VERSION)/ +PKG_HASH:=5e8bbab841d67dc16e329d9b3774f6db4189dd1d01f575d0e921ccf2c426dd9f +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(UGW_BASENAME) +PKG_LICENSE:=GPL-2.0 BSD-2-Clause +PKG_LICENSE_FILES:=LICENSE + +PKG_FIXUP:=autoreconf +PKG_BUILD_FLAGS:=no-mold + +include $(INCLUDE_DIR)/package.mk + +# TODO this driver depends on the vrx518 dsl firmware, add this dependency if +# that ever gets a compatible license +define KernelPackage/ltq-vdsl-vr11 + TITLE:=vdsl driver + SECTION:=sys + SUBMENU:=Network Devices + DEPENDS:=@TARGET_ipq40xx +kmod-ltq-vdsl-vr11-mei + FILES:=$(PKG_BUILD_DIR)/src/drv_dsl_cpe_api.ko + AUTOLOAD:=$(call AutoLoad,51,drv_dsl_cpe_api) +endef + +define Package/ltq-vdsl-vr11/description + This package contains the Lantiq DSL CPE API driver. + + Supported Devices: + - VRX500 Family +endef + +MAKE_FLAGS += \ + $(KERNEL_MAKE_FLAGS) \ + SHELL="$(BASH)" + +CONFIGURE_ARGS += \ + --enable-add-drv-cflags="" \ + --enable-add_ext_drv_cflags="-DDSL_DRV_ATM_PTM_INTERFACE_ENABLE=1" \ + --enable-debug-logger-support=no + +CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \ + --enable-vrx \ + --enable-vrx-device=vr11 \ + --enable-ifxos \ + --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \ + --enable-driver-include="-I$(STAGING_DIR)/usr/include/vdsl" \ + --enable-linux-26 \ + --enable-kernelbuild="$(LINUX_DIR)" \ + --enable-debug-prints=no \ + ARCH=$(LINUX_KARCH) + +CONFIGURE_ARGS += \ + --enable-model=full \ + --enable-dsl-ceoc=no +#CONFIGURE_ARGS += --enable-model=lite +#CONFIGURE_ARGS += --enable-model=footprint +#CONFIGURE_ARGS += --enable-model=typical +#CONFIGURE_ARGS += --enable-model=debug + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/drv_vdsl_cpe_api + $(CP) $(PKG_BUILD_DIR)/src/include/drv_dsl_cpe*.h $(1)/usr/include/drv_vdsl_cpe_api/ +endef + +$(eval $(call KernelPackage,ltq-vdsl-vr11)) diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/001-fix-compile.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/001-fix-compile.patch new file mode 100644 index 00000000000..709c3766ded --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/001-fix-compile.patch @@ -0,0 +1,84 @@ +--- a/src/include/drv_dsl_cpe_os_linux.h ++++ b/src/include/drv_dsl_cpe_os_linux.h +@@ -36,6 +36,7 @@ + #endif + + #include <linux/sched.h> ++#include <linux/sched/signal.h> + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)) +--- a/configure.in ++++ b/configure.in +@@ -422,7 +422,7 @@ AC_ARG_ENABLE(debug-prints, + AC_SUBST([DSL_DBG_MAX_LEVEL_SET],[no]) + + AC_SUBST([DSL_DBG_MAX_LEVEL_PRE],[n/a]) +- AC_SUBST([INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT],[no]) ++ AC_SUBST([INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT],[yes]) + ;; + no | none ) + AC_DEFINE(DSL_DEBUG_DISABLE,,[Disabled debug prints]) +@@ -433,7 +433,7 @@ AC_ARG_ENABLE(debug-prints, + AC_SUBST([DSL_DBG_MAX_LEVEL_SET],[no]) + + AC_SUBST([DSL_DBG_MAX_LEVEL_PRE],[n/a]) +- AC_SUBST([INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT],[yes]) ++ AC_SUBST([INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT],[no]) + ;; + prn | 0x1 ) + AC_SUBST([DSL_DEBUG_DISABLE],[no]) +--- a/src/common/drv_dsl_cpe_api.c ++++ b/src/common/drv_dsl_cpe_api.c +@@ -88,8 +88,12 @@ static DSL_uint32_t g_VRxPD_IOctlWhiteli + DSL_FIO_BAND_PLAN_STATUS_GET, + DSL_FIO_DBG_MODULE_LEVEL_GET, + DSL_FIO_DBG_MODULE_LEVEL_SET, ++#ifdef INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT ++#ifndef DSL_DEBUG_DISABLE + DSL_FIO_DBG_MODULE_DESTINATION_GET, + DSL_FIO_DBG_MODULE_DESTINATION_SET, ++#endif /* DSL_DEBUG_DISABLE*/ ++#endif /* INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT */ + DSL_FIO_OPERATOR_CONFIG_GET, + DSL_FIO_OPERATOR_CONFIG_SET, + /* Delimeter only. Keep it! */ +--- a/src/common/drv_dsl_cpe_os_linux.c ++++ b/src/common/drv_dsl_cpe_os_linux.c +@@ -625,7 +625,7 @@ DSL_void_t* DSL_DRV_VMalloc( + DSL_DRV_size_t nSize) + { + /* VRX500-BU: Better to use vmalloc or vzmalloc here?! */ +- return __vmalloc((unsigned long)nSize, GFP_KERNEL, PAGE_KERNEL); ++ return __vmalloc((unsigned long)nSize, GFP_KERNEL); + /* return vmalloc(nSize);*/ + } + +--- a/src/include/drv_dsl_cpe_debug.h ++++ b/src/include/drv_dsl_cpe_debug.h +@@ -99,6 +99,7 @@ DSL_void_t DSL_DRV_ErrorSet(DSL_void_t * + /** Terminate execution if assertion fails */ + #define DSL_ASSERT(exp) ((void)0) + ++ #define DSL_DEBUG_LIMIT(level, body) ((void)0) + #else + + #define DSL_DEBUG_SET_ERROR(code) DSL_DRV_ErrorSet(pContext, code); +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -26,6 +26,7 @@ + #define DSL_DBG_BLOCK DSL_DBG_PM + + #ifdef __LINUX__ ++#ifndef DSL_DEBUG_DISABLE + #define DSL_PM_CORE_RATELIMIT_INTERVAL 20 * HZ /* for each 20 seconds */ + #define DSL_PM_CORE_RATELIMIT_BURST 1 /* 1 occurrence */ + /* struct ratelimit_state to be used in DSL_DEBUG_LIMIT */ +@@ -33,6 +34,7 @@ static DEFINE_RATELIMIT_STATE( + DSL_DBG_RATELIMIT_STRUCT_NAME(DSL_DBG_BLOCK), + DSL_PM_CORE_RATELIMIT_INTERVAL, + DSL_PM_CORE_RATELIMIT_BURST); ++#endif + #endif/* __LINUX__ */ + + DSL_boolean_t DSL_DRV_PM_IsPmReady( diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/020-not-leak-cflags.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/020-not-leak-cflags.patch new file mode 100644 index 00000000000..21fc0be18e2 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/020-not-leak-cflags.patch @@ -0,0 +1,23 @@ +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -283,10 +283,7 @@ else + drv_dsl_cpe_api_common_mod_cflags = + endif + +-drv_dsl_cpe_api_common_cflags = -DLINUX -D__LINUX__ -D__KERNEL__ -DEXPORT_SYMTAB \ +- -pipe -Wall -Wformat -Wimplicit -Wunused -Wswitch -Wcomment -Winline \ +- -Wuninitialized -Wparentheses -Wreturn-type \ +- -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common ++drv_dsl_cpe_api_common_cflags = -DLINUX -D__LINUX__ -D__KERNEL__ -DEXPORT_SYMTAB + + if DSL_DBG_MAX_LEVEL_SET + drv_dsl_cpe_api_common_cflags += -DDSL_DBG_MAX_LEVEL=$(DSL_DBG_MAX_LEVEL_PRE) +@@ -296,7 +293,7 @@ endif + drv_dsl_cpe_api_target_cflags = $(ADD_DRV_CFLAGS) + + # compile cflags +-drv_dsl_cpe_api_compile_cflags = $(EXTRA_DRV_CFLAGS) ++drv_dsl_cpe_api_compile_cflags = + + if !KERNEL_2_6 + # the headerfile of linux kernels 2.6.x contain to much arithmetic diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/100-compat.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/100-compat.patch new file mode 100644 index 00000000000..eeda611d715 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/100-compat.patch @@ -0,0 +1,18 @@ +--- a/src/common/drv_dsl_cpe_os_linux.c ++++ b/src/common/drv_dsl_cpe_os_linux.c +@@ -1051,12 +1051,11 @@ DSL_int32_t DSL_DRV_ThreadShutdown( + + DSL_uint32_t DSL_DRV_SysTimeGet(DSL_uint32_t nOffset) + { +- struct timeval tv; ++ struct timespec64 now; + DSL_uint32_t nTime = 0; + +- memset(&tv, 0, sizeof(tv)); +- do_gettimeofday(&tv); +- nTime = (DSL_uint32_t)tv.tv_sec; ++ ktime_get_real_ts64(&now); ++ nTime = (DSL_uint32_t)now.tv_sec; + + if ( (nOffset == 0) || (nOffset > nTime) ) + { diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/200-fix-elapsed-time.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/200-fix-elapsed-time.patch new file mode 100644 index 00000000000..2734415d15c --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/200-fix-elapsed-time.patch @@ -0,0 +1,122 @@ +--- a/src/include/drv_dsl_cpe_pm_core.h ++++ b/src/include/drv_dsl_cpe_pm_core.h +@@ -1554,9 +1554,9 @@ typedef struct + DSL_boolean_t bShowtimeProcessingStart; + /** Showtime reached flag*/ + DSL_boolean_t bShowtimeInvTrigger; +- /** Current Showtime synchronization time to be used, (msec) */ ++ /** Current Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nCurrShowtimeTime; +- /** Showtime synchronization time to be used, (msec) */ ++ /** Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nElapsedShowtimeTime; + /** Actual Line state*/ + DSL_LineStateValue_t nLineState; +--- a/src/pm/drv_dsl_cpe_api_pm.c ++++ b/src/pm/drv_dsl_cpe_api_pm.c +@@ -1633,7 +1633,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -1693,7 +1693,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersEx + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL_EXT(pCounters->nChannel); + +@@ -2764,7 +2764,7 @@ DSL_Error_t DSL_DRV_PM_DataPathCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -3678,7 +3678,7 @@ DSL_Error_t DSL_DRV_PM_DataPathFailureCo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_FAILURE_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -4536,7 +4536,7 @@ DSL_Error_t DSL_DRV_PM_LineSecCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLineCounters = DSL_DRV_PM_PTR_LINE_SEC_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -5273,7 +5273,7 @@ DSL_Error_t DSL_DRV_PM_LineInitCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLinitCounters = DSL_DRV_PM_PTR_LINE_INIT_COUNTERS_TOTAL(); + +@@ -5774,7 +5774,7 @@ DSL_Error_t DSL_DRV_PM_LineEventShowtime + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLfCounters = DSL_DRV_PM_PTR_LINE_EVENT_SHOWTIME_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -6302,7 +6302,7 @@ DSL_Error_t DSL_DRV_PM_ReTxCountersTotal + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pReTxCounters = DSL_DRV_PM_PTR_RETX_COUNTERS_TOTAL(pCounters->nDirection); + +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -78,6 +78,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + DSL_Error_t nErrCode = DSL_SUCCESS; + DSL_uint32_t msecTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE, ++ secTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE/DSL_PM_MSEC, + nCurrMsTime = 0; + #ifdef INCLUDE_DSL_CPE_PM_HISTORY + DSL_uint32_t nCurrSysTime = 0, nPrevElapsedTime = 0; +@@ -117,10 +118,13 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + /* Get elapsed time [msec] since the last entry*/ + msecTimeFrame = nCurrMsTime - DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck; ++ ++ /* Get elapsed time [sec] since the last entry*/ ++ secTimeFrame = (nCurrMsTime/DSL_PM_MSEC) - (DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck/DSL_PM_MSEC); + } + + /* Get Total Elapsed Time Since the PM module startup*/ +- DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += msecTimeFrame; ++ DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += secTimeFrame; + + /* Set last time check to the current time*/ + DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck = nCurrMsTime; +@@ -158,7 +162,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + else + { + /* Update current showtime elapsed time*/ +- DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += (msecTimeFrame/DSL_PM_MSEC); ++ DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += secTimeFrame; + DSL_DRV_PM_CONTEXT(pContext)->nElapsedShowtimeTime = + DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime; + } diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/210-fix-us-eftrmin.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/210-fix-us-eftrmin.patch new file mode 100644 index 00000000000..ad912605b68 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/210-fix-us-eftrmin.patch @@ -0,0 +1,22 @@ +--- a/src/pm/drv_dsl_cpe_api_pm_vrx.c ++++ b/src/pm/drv_dsl_cpe_api_pm_vrx.c +@@ -1482,9 +1482,16 @@ DSL_Error_t DSL_DRV_PM_DEV_ReTxCountersG + /* ignore zero value*/ + if (nEftrMin) + { +- /* Fw Format: kBit/s */ +- /* API format: bit/s */ +- pCounters->nEftrMin = nEftrMin*1000; ++ if (nDirection == DSL_NEAR_END) ++ { ++ /* Fw Format: kBit/s */ ++ /* API format: bit/s */ ++ pCounters->nEftrMin = nEftrMin*1000; ++ } ++ else ++ { ++ pCounters->nEftrMin = nEftrMin; ++ } + } + } + else diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/patches/211-fix-compilation-warning-missing-fallthrough.patch b/package/kernel/lantiq/ltq-vdsl-vr11/patches/211-fix-compilation-warning-missing-fallthrough.patch new file mode 100644 index 00000000000..96e1ffef972 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr11/patches/211-fix-compilation-warning-missing-fallthrough.patch @@ -0,0 +1,49 @@ +--- a/src/device/drv_dsl_cpe_device_vrx.c ++++ b/src/device/drv_dsl_cpe_device_vrx.c +@@ -8885,6 +8885,9 @@ DSL_Error_t DSL_DRV_DEV_AutobootHandleTr + (pContext, SYS_DBG_MSG"DSL[%02d]: ORDERLY_SHUTDOWN state reached" + DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); + /* do not use break here, continue handling */ ++ ++ fallthrough; ++ + #endif /* INCLUDE_DSL_CPE_API_VRX */ + case DSL_LINESTATE_EXCEPTION: + if (!bPreFail) +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -2355,15 +2355,19 @@ DSL_Error_t DSL_DRV_PM_CountersReset( + } + #endif /* #ifdef INCLUDE_DSL_CPE_PM_HISTORY*/ + +- if (ResetType == DSL_PM_RESET_HISTORY) +- break; ++ if (ResetType == DSL_PM_RESET_HISTORY) ++ break; ++ ++ fallthrough; + + case DSL_PM_RESET_TOTAL: + #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS + memset(EpData.pRecTotal, nFillValue, EpData.nEpRecElementSize); + #endif /* #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS*/ +- if (ResetType == DSL_PM_RESET_TOTAL) +- break; ++ if (ResetType == DSL_PM_RESET_TOTAL) ++ break; ++ ++ fallthrough; + + case DSL_PM_RESET_HISTORY_SHOWTIME: + #ifdef INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS +--- a/src/common/drv_dsl_cpe_api.c ++++ b/src/common/drv_dsl_cpe_api.c +@@ -2652,6 +2652,8 @@ DSL_Error_t DSL_DRV_AutobootControlSet( + /* no break */ + /* ... pass to restart*/ + ++ fallthrough; ++ + #if defined (DSL_VRX_DEVICE_VR11) + case DSL_AUTOBOOT_CTRL_STOP_PD: + #endif diff --git a/package/kernel/lantiq/ltq-vdsl-mei/Makefile b/package/kernel/lantiq/ltq-vdsl-vr9-mei/Makefile index 796918549a0..e9c5a681fd0 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/Makefile +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/Makefile @@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-vdsl-vr9-mei PKG_VERSION:=1.5.17.6 -PKG_RELEASE:=4 +PKG_RELEASE:=6 PKG_BASE_NAME:=drv_mei_cpe PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz @@ -29,7 +29,7 @@ define KernelPackage/ltq-vdsl-vr9-mei TITLE:=mei driver for vdsl SECTION:=sys SUBMENU:=Network Devices - DEPENDS:=@TARGET_lantiq_xrx200 +kmod-ltq-ifxos + DEPENDS:=@TARGET_lantiq_xrx200 +kmod-ltq-ifxos +kmod-ltq-vectoring FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe) endef @@ -39,7 +39,7 @@ define KernelPackage/ltq-vdsl-vr9-mei/description endef -define Package/ltq-vdsl-mei-test +define Package/ltq-vdsl-vr9-mei-test SECTION:=net CATEGORY:=Network TITLE:=Lantiq mei driver test tool @@ -47,7 +47,7 @@ define Package/ltq-vdsl-mei-test DEPENDS:=@TARGET_lantiq_xrx200 endef -define Package/ltq-vdsl-mei-test/description +define Package/ltq-vdsl-vr9-mei-test/description Userland tool to directly control the mei driver, this is only needed for test and development purposes. endef @@ -56,10 +56,10 @@ MAKE_FLAGS += \ $(KERNEL_MAKE_FLAGS) \ SHELL="$(BASH)" -# ltq-vdsl-app uses a header provided by the MEI driver which has some +# ltq-vdsl-vr9-app uses a header provided by the MEI driver which has some # conditionals. # Define the conditionals here to have the same view on both sides. If you -# change them, you need to change them for the ltq-vdsl-app as well +# change them, you need to change them for the ltq-vdsl-vr9-app as well MEI_DRV_CFLAGS = \ -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 \ -DMEI_SUPPORT_DEBUG_STREAMS=1 \ @@ -91,9 +91,9 @@ endef $(eval $(call KernelPackage,ltq-vdsl-vr9-mei)) -define Package/ltq-vdsl-mei-test/install +define Package/ltq-vdsl-vr9-mei-test/install $(INSTALL_DIR) $(1)/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mei_cpe_drv_test $(1)/bin endef -$(eval $(call BuildPackage,ltq-vdsl-mei-test)) +$(eval $(call BuildPackage,ltq-vdsl-vr9-mei-test)) diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/001-fix-compile.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/001-fix-compile.patch index 6d3e182ec48..6d3e182ec48 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/001-fix-compile.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/001-fix-compile.patch diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/010-warnings.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/010-warnings.patch index 9a796c65bcb..9a796c65bcb 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/010-warnings.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/010-warnings.patch diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/020-not-leak-cflags.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/020-not-leak-cflags.patch index 31dbba37b9d..31dbba37b9d 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/020-not-leak-cflags.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/020-not-leak-cflags.patch diff --git a/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/030-no-static-linking.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/030-no-static-linking.patch new file mode 100644 index 00000000000..8d4fca1eb1b --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/030-no-static-linking.patch @@ -0,0 +1,47 @@ +This removes -static compile option. The -static option tells GCC to +link this statically with the libc, which we do not want in OpenWrt. We +want to link everything dynamically to the libc. This fixes a compile +problem with glibc. + +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -198,10 +198,10 @@ AM_CFLAGS = -Wall -Wimplicit -Wunused -W + + if IFXOS_ENABLE + AM_LDFLAGS= \ +- -Bstatic -dn -static @IFXOS_LIBRARY_PATH@ ++ -Bstatic -dn @IFXOS_LIBRARY_PATH@ + else + AM_LDFLAGS= \ +- -Bstatic -dn -static ++ -Bstatic -dn + endif + + # +@@ -304,7 +304,7 @@ mei_cpe_appl_ldflags= $(ADD_APPL_LDFLAGS + else + if TARGET_ADM5120_MIPSEL + mei_cpe_appl_cflags = -O1 -g +-mei_cpe_appl_ldflags = -static ++mei_cpe_appl_ldflags = + else + mei_cpe_appl_cflags = -DPPC + endif +@@ -318,7 +318,7 @@ mei_cpe_drv_test_CPPFLAGS = -I@srcdir@\ + mei_cpe_drv_test_CFLAGS = $(mei_cpe_app_common_cflags) \ + $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS) + +-mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@ ++mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@ + + mei_cpe_drv_test_LDADD = -lifxos + endif +@@ -333,7 +333,7 @@ mei_cpe_drv_dbg_strm_dmp_CPPFLAGS = -I@s + -I@KERNEL_INCL_PATH@ $(IFXOS_INCLUDE_PATH) + mei_cpe_drv_dbg_strm_dmp_CFLAGS = $(mei_cpe_app_common_cflags) \ + $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS) +-mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@ ++mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@ + mei_cpe_drv_dbg_strm_dmp_LDADD = -lifxos + + # linux 2.6 kernel object - dummy to force dependencies diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/100-compat.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/100-compat.patch index 75e1500171a..7e7381a3460 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/100-compat.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/100-compat.patch @@ -43,7 +43,18 @@ #ifdef MODULE #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) MODULE_PARM(major_number, "b"); -@@ -1479,7 +1483,11 @@ struct proc_entry { +@@ -1256,7 +1260,9 @@ static long MEI_Ioctl( struct file *filp + MEI_IOCTL_RETURN: + + local_args.drv_ioctl.retCode = ret; +- copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize); ++ if ( ret == IFX_SUCCESS && ++ copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize) ) ++ ret = -e_MEI_ERR_RETURN_ARG; + + return (ret < 0) ? -1 : 0; + } +@@ -1479,7 +1485,11 @@ struct proc_entry { char name[32]; proc_rd_callback_t rd; proc_wr_callback_t wr; @@ -55,7 +66,7 @@ int entity; }; -@@ -1869,6 +1877,7 @@ static int mei_proc_single_open(struct i +@@ -1869,6 +1879,7 @@ static int mei_proc_single_open(struct i static void mei_proc_entry_create(struct proc_dir_entry *parent_node, struct proc_entry *proc_entry) { @@ -63,7 +74,7 @@ memset(&proc_entry->ops, 0, sizeof(struct file_operations)); proc_entry->ops.owner = THIS_MODULE; -@@ -1879,6 +1888,17 @@ static void mei_proc_entry_create(struct +@@ -1879,6 +1890,17 @@ static void mei_proc_entry_create(struct proc_entry->ops.llseek = seq_lseek; if (proc_entry->wr) proc_entry->ops.write = proc_entry->wr; @@ -81,7 +92,7 @@ proc_create_data(proc_entry->name, (S_IFREG | S_IRUGO), -@@ -2174,9 +2194,11 @@ static int MEI_module_init (void) +@@ -2174,9 +2196,11 @@ static int MEI_module_init (void) return (result); } @@ -93,7 +104,7 @@ return 0; } -@@ -2304,6 +2326,10 @@ static void MEI_module_exit (void) +@@ -2304,6 +2328,10 @@ static void MEI_module_exit (void) #else unregister_chrdev ( major_number , DRV_MEI_NAME ); @@ -104,7 +115,7 @@ #endif #if CONFIG_PROC_FS -@@ -2388,9 +2414,11 @@ static void MEI_module_exit (void) +@@ -2388,9 +2416,11 @@ static void MEI_module_exit (void) ("MEI_DRV: Chipset Basic Exit failed" MEI_DRV_CRLF)); } @@ -116,7 +127,7 @@ #if (MEI_SUPPORT_DEBUG_LOGGER == 1) if (nl_debug_sock) -@@ -2514,6 +2542,10 @@ static int MEI_InitModuleRegCharDev(cons +@@ -2514,6 +2544,10 @@ static int MEI_InitModuleRegCharDev(cons ("Using major number %d" MEI_DRV_CRLF, major_number)); } @@ -127,7 +138,7 @@ return 0; #endif /* CONFIG_DEVFS_FS */ } -@@ -2563,21 +2595,32 @@ static int MEI_InitModuleBasics(void) +@@ -2563,21 +2597,32 @@ static int MEI_InitModuleBasics(void) } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) @@ -160,7 +171,7 @@ return 0; } -@@ -2905,11 +2948,15 @@ IFX_int32_t MEI_IoctlInitDevice( +@@ -2905,11 +2950,15 @@ IFX_int32_t MEI_IoctlInitDevice( pMeiDev->eModePoll = e_MEI_DEV_ACCESS_MODE_IRQ; pMeiDev->intMask = ME_ARC2ME_INTERRUPT_UNMASK_ALL; @@ -176,6 +187,46 @@ pTmpXCntrl = MEI_VrxXDevToIrqListAdd( MEI_DRV_LINENUM_GET(pMeiDev), +@@ -3249,9 +3298,11 @@ static int MEI_IoctlMeiDbgAccessWr_Wrap( + ret = MEI_IoctlMeiDbgAccessWr( pMeiDynCntrl, pLocalArgument); + + /* return arguments - count */ +- copy_to_user( (void *)&pUserArgument->count, +- (void *)&pLocalArgument->count, +- sizeof(pUserArgument->count) ) ; ++ if ( ret == IFX_SUCCESS && ++ copy_to_user( (void *)&pUserArgument->count, ++ (void *)&pLocalArgument->count, ++ sizeof(pUserArgument->count) ) ) ++ ret = -e_MEI_ERR_RETURN_ARG; + + return ret; + } +@@ -3278,16 +3329,18 @@ static int MEI_IoctlMeiDbgAccessRd_Wrap( + if ( pLocalArgument->count ) + { + /* return the buffer */ +- copy_to_user( pUserBuf, +- pLocalArgument->pData_32, +- pLocalArgument->count * sizeof(IFX_uint32_t) ) ; ++ if ( copy_to_user( pUserBuf, ++ pLocalArgument->pData_32, ++ pLocalArgument->count * sizeof(IFX_uint32_t) ) ) ++ ret = -e_MEI_ERR_RETURN_ARG; + + } + + /* return count argument */ +- copy_to_user( (void *)&pUserArgument->count, +- (void *)&pLocalArgument->count, +- sizeof(pUserArgument->count) ) ; ++ if ( copy_to_user( (void *)&pUserArgument->count, ++ (void *)&pLocalArgument->count, ++ sizeof(pUserArgument->count) ) ) ++ ret = -e_MEI_ERR_RETURN_ARG; + + return ret; + } --- a/src/drv_mei_cpe_api_atm_ptm_intern.c +++ b/src/drv_mei_cpe_api_atm_ptm_intern.c @@ -147,6 +147,7 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit @@ -376,17 +427,6 @@ } IFX_int32_t MEI_PLL_ConfigInit(MEI_DEV_T *pMeiDev) ---- a/src/drv_mei_cpe_dsm.c -+++ b/src/drv_mei_cpe_dsm.c -@@ -144,7 +144,7 @@ IFX_void_t MEI_VRX_DSM_DataInit(MEI_DEV_ - memset((IFX_uint8_t *)&pMeiDev->firmwareFeatures, 0x00, sizeof(IOCTL_MEI_firmwareFeatures_t)); - pMeiDev->meiFwDlCount = 0; - -- pMeiDev->meiERBbuf.pCallBackFunc = mei_dsm_cb_func_hook; -+ pMeiDev->meiERBbuf.pCallBackFunc = NULL; - - PRN_DBG_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_NORMAL, - ("MEI_DRV: PP callback function addr = 0x%08X" MEI_DRV_CRLF, --- a/src/drv_mei_cpe_download_vrx.c +++ b/src/drv_mei_cpe_download_vrx.c @@ -3281,12 +3281,14 @@ IFX_int32_t MEI_DEV_IoctlFirmwareDownloa diff --git a/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/101_no-date-time.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/101_no-date-time.patch new file mode 100644 index 00000000000..9785bfc4c18 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/101_no-date-time.patch @@ -0,0 +1,23 @@ +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -1505,8 +1505,8 @@ struct proc_entry { + static void MEI_GetVersionProc(struct seq_file *s) + { + seq_printf(s, "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]); +- seq_printf(s, "Compiled on %s, %s for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF, +- __DATE__, __TIME__, UTS_RELEASE, jiffies); ++ seq_printf(s, "Compiled for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF, ++ UTS_RELEASE, jiffies); + } + + /** +@@ -4233,7 +4233,9 @@ module_exit (MEI_module_exit); + #ifdef MODULE + MODULE_AUTHOR("www.lantiq.com"); + MODULE_DESCRIPTION("MEI CPE Driver - www.lantiq.com"); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)) + MODULE_SUPPORTED_DEVICE("MEI CPE Interface"); ++#endif + MODULE_LICENSE ("GPL"); + #endif /* #ifdef MODULE*/ + diff --git a/package/kernel/lantiq/ltq-vdsl-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch index c4ca234be84..c4ca234be84 100644 --- a/package/kernel/lantiq/ltq-vdsl-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/110-reset-g_tx_link_rate-on-showtime-exit.patch diff --git a/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/200-interrupt-lock.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/200-interrupt-lock.patch new file mode 100644 index 00000000000..a677ccec554 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/200-interrupt-lock.patch @@ -0,0 +1,45 @@ +--- a/src/drv_mei_cpe_common.c ++++ b/src/drv_mei_cpe_common.c +@@ -104,6 +104,8 @@ IFX_uint32_t MEI_FsmStateSetMsgPreAction + MEI_DEVCFG_DATA_T MEI_DevCfgData; + #endif + ++static DEFINE_SPINLOCK(MEI_InterruptLock); ++ + /* ============================================================================ + Proc-FS and debug variable definitions + ========================================================================= */ +@@ -2134,6 +2136,9 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN + #if (MEI_SUPPORT_DEBUG_STREAMS == 1) + IFX_int_t extraDbgStreamLoop = 0; + #endif ++ unsigned long flags; ++ ++ spin_lock_irqsave(&MEI_InterruptLock, flags); + + /* get the actual chip device from the list and step through the VRX devices */ + while(pNextXCntrl) +@@ -2167,6 +2172,8 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN + } + #endif + ++ spin_unlock_irqrestore(&MEI_InterruptLock, flags); ++ + return meiIntCnt; + } + +@@ -2639,9 +2646,14 @@ IFX_int32_t MEI_MsgSendPreAction( + */ + IFX_void_t MEI_DisableDeviceInt(MEI_DEV_T *pMeiDev) + { ++ unsigned long flags; ++ spin_lock_irqsave(&MEI_InterruptLock, flags); ++ + MEI_MaskInterrupts( &pMeiDev->meiDrvCntrl, + ME_ARC2ME_INTERRUPT_MASK_ALL); + ++ spin_unlock_irqrestore(&MEI_InterruptLock, flags); ++ + return; + } + diff --git a/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/300-fix-simple-compilation-warning.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/300-fix-simple-compilation-warning.patch new file mode 100644 index 00000000000..e9f1931227f --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/300-fix-simple-compilation-warning.patch @@ -0,0 +1,37 @@ +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -67,7 +67,7 @@ + #if (MEI_SUPPORT_DEBUG_LOGGER == 1) + #include <linux/skbuff.h> + #include <linux/netlink.h> +-#include <net/sock.h> ++#include <net/netlink.h> + #endif + + /* add MEI CPE debug/printout part */ +@@ -1718,8 +1718,8 @@ static void MEI_MeminfoProcPerDevGet(struct seq_file *s) + ", CRC = 0x%08X" + #endif + MEI_DRV_CRLF, +- chunkIdx, pChunk[chunkIdx].pImageChunk_aligned, +- pChunk[chunkIdx].pImageChunk_allocated, ++ chunkIdx, (unsigned int)pChunk[chunkIdx].pImageChunk_aligned, ++ (unsigned int)pChunk[chunkIdx].pImageChunk_allocated, + pChunk[chunkIdx].imageChunkSize_byte, + pChunk[chunkIdx].eImageChunkType + #if (MEI_SUPPORT_OPTIMIZED_FW_DL == 1) +--- a/src/drv_mei_cpe_download_vrx.c ++++ b/src/drv_mei_cpe_download_vrx.c +@@ -3139,9 +3139,9 @@ IFX_int32_t MEI_DEV_IoctlFirmwareDownload( + { + IFX_int32_t ret = 0; + MEI_DEV_T *pMeiDev = pMeiDynCntrl->pMeiDev; +-#if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) +- MEI_TC_Reset_t tc_reset = {0}; +-#endif ++// #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) ++// MEI_TC_Reset_t tc_reset = {0}; ++// #endif + #if (MEI_SUPPORT_OPTIMIZED_FW_DL == 1) + IFX_boolean_t bChunksReuse = IFX_FALSE; + #endif diff --git a/package/kernel/lantiq/ltq-vdsl/Makefile b/package/kernel/lantiq/ltq-vdsl-vr9/Makefile index 229e2b577c3..ebcb935a739 100644 --- a/package/kernel/lantiq/ltq-vdsl/Makefile +++ b/package/kernel/lantiq/ltq-vdsl-vr9/Makefile @@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-vdsl-vr9 PKG_VERSION:=4.17.18.6 -PKG_RELEASE:=4 +PKG_RELEASE:=8 PKG_BASE_NAME:=drv_dsl_cpe_api PKG_SOURCE:=$(PKG_BASE_NAME)_vrx-$(PKG_VERSION).tar.gz @@ -55,17 +55,14 @@ CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \ --enable-driver-include="-I$(STAGING_DIR)/usr/include/vdsl" \ --enable-add-drv-cflags="-DMODULE -DINCLUDE_DSL_ATM_PTM_INTERFACE_SUPPORT" \ - --enable-adsl-led=no \ - --enable-adsl-mib=no \ - --enable-dsl-ceoc=no \ --enable-linux-26 \ --enable-kernelbuild="$(LINUX_DIR)" \ --enable-debug-prints=no \ - --enable-dsl-pm-retx-counters \ - --enable-dsl-pm-retx-thresholds \ ARCH=mips -CONFIGURE_ARGS += --enable-model=full +CONFIGURE_ARGS += \ + --enable-model=full \ + --enable-dsl-ceoc=no #CONFIGURE_ARGS += --enable-model=lite #CONFIGURE_ARGS += --enable-model=footprint #CONFIGURE_ARGS += --enable-model=typical diff --git a/package/kernel/lantiq/ltq-vdsl/patches/001-fix-compile.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/001-fix-compile.patch index 1355a1a7915..1355a1a7915 100644 --- a/package/kernel/lantiq/ltq-vdsl/patches/001-fix-compile.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/001-fix-compile.patch diff --git a/package/kernel/lantiq/ltq-vdsl/patches/020-not-leak-cflags.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/020-not-leak-cflags.patch index 96e69acca0d..96e69acca0d 100644 --- a/package/kernel/lantiq/ltq-vdsl/patches/020-not-leak-cflags.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/020-not-leak-cflags.patch diff --git a/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/100-compat.patch index edacd5f6b86..7670fe6a00e 100644 --- a/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/100-compat.patch @@ -82,9 +82,9 @@ DSL_DRV_DevNodeInit(); -+ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api0"); ++ dsl_class = class_create(THIS_MODULE, DRV_DSL_CPE_API_DEV_NAME); + dsl_devt = MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0); -+ device_create(dsl_class, NULL, dsl_devt, NULL, "dsl_cpe_api0"); ++ device_create(dsl_class, NULL, dsl_devt, NULL, "dsl_cpe_api/0"); + return 0; } diff --git a/package/kernel/lantiq/ltq-vdsl/patches/110-semaphore-lock.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/110-semaphore-lock.patch index 12c00c33ecc..12c00c33ecc 100644 --- a/package/kernel/lantiq/ltq-vdsl/patches/110-semaphore-lock.patch +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/110-semaphore-lock.patch diff --git a/package/kernel/lantiq/ltq-vdsl-vr9/patches/200-fix-elapsed-time.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/200-fix-elapsed-time.patch new file mode 100644 index 00000000000..3ec85460b24 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/200-fix-elapsed-time.patch @@ -0,0 +1,122 @@ +--- a/src/include/drv_dsl_cpe_pm_core.h ++++ b/src/include/drv_dsl_cpe_pm_core.h +@@ -1552,9 +1552,9 @@ typedef struct + DSL_boolean_t bShowtimeProcessingStart; + /** Showtime reached flag*/ + DSL_boolean_t bShowtimeInvTrigger; +- /** Current Showtime synchronization time to be used, (msec) */ ++ /** Current Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nCurrShowtimeTime; +- /** Showtime synchronization time to be used, (msec) */ ++ /** Showtime synchronization time to be used, (sec) */ + DSL_uint32_t nElapsedShowtimeTime; + /** Actual Line state*/ + DSL_LineStateValue_t nLineState; +--- a/src/pm/drv_dsl_cpe_api_pm.c ++++ b/src/pm/drv_dsl_cpe_api_pm.c +@@ -1475,7 +1475,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -1535,7 +1535,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersEx + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pChCounters = DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL_EXT(pCounters->nChannel); + +@@ -2518,7 +2518,7 @@ DSL_Error_t DSL_DRV_PM_DataPathCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -3352,7 +3352,7 @@ DSL_Error_t DSL_DRV_PM_DataPathFailureCo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pDpCounters = DSL_DRV_PM_PTR_DATAPATH_FAILURE_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection); + +@@ -4130,7 +4130,7 @@ DSL_Error_t DSL_DRV_PM_LineSecCountersTo + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLineCounters = DSL_DRV_PM_PTR_LINE_SEC_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -4787,7 +4787,7 @@ DSL_Error_t DSL_DRV_PM_LineInitCountersT + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLinitCounters = DSL_DRV_PM_PTR_LINE_INIT_COUNTERS_TOTAL(); + +@@ -5240,7 +5240,7 @@ DSL_Error_t DSL_DRV_PM_LineEventShowtime + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pLfCounters = DSL_DRV_PM_PTR_LINE_EVENT_SHOWTIME_COUNTERS_TOTAL(pCounters->nDirection); + +@@ -5720,7 +5720,7 @@ DSL_Error_t DSL_DRV_PM_ReTxCountersTotal + } + + /* Fill Total Counters elapsed time*/ +- pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC; ++ pCounters->total.nElapsedTime = DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime; + + pReTxCounters = DSL_DRV_PM_PTR_RETX_COUNTERS_TOTAL(pCounters->nDirection); + +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -60,6 +60,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + DSL_Error_t nErrCode = DSL_SUCCESS; + DSL_uint32_t msecTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE, ++ secTimeFrame = DSL_PM_COUNTER_POLLING_CYCLE/DSL_PM_MSEC, + nCurrMsTime = 0; + #ifdef INCLUDE_DSL_CPE_PM_HISTORY + DSL_uint32_t nCurrSysTime = 0, nPrevElapsedTime = 0; +@@ -99,10 +100,13 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + { + /* Get elapsed time [msec] since the last entry*/ + msecTimeFrame = nCurrMsTime - DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck; ++ ++ /* Get elapsed time [sec] since the last entry*/ ++ secTimeFrame = (nCurrMsTime/DSL_PM_MSEC) - (DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck/DSL_PM_MSEC); + } + + /* Get Total Elapsed Time Since the PM module startup*/ +- DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += msecTimeFrame; ++ DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime += secTimeFrame; + + /* Set last time check to the current time*/ + DSL_DRV_PM_CONTEXT(pContext)->nLastMsTimeCheck = nCurrMsTime; +@@ -140,7 +144,7 @@ static DSL_Error_t DSL_DRV_PM_SyncTimeUp + else + { + /* Update current showtime elapsed time*/ +- DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += (msecTimeFrame/DSL_PM_MSEC); ++ DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime += secTimeFrame; + DSL_DRV_PM_CONTEXT(pContext)->nElapsedShowtimeTime = + DSL_DRV_PM_CONTEXT(pContext)->nCurrShowtimeTime; + } diff --git a/package/kernel/lantiq/ltq-vdsl-vr9/patches/210-fix-us-eftrmin.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/210-fix-us-eftrmin.patch new file mode 100644 index 00000000000..51651f476a3 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/210-fix-us-eftrmin.patch @@ -0,0 +1,22 @@ +--- a/src/pm/drv_dsl_cpe_api_pm_vrx.c ++++ b/src/pm/drv_dsl_cpe_api_pm_vrx.c +@@ -1435,9 +1435,16 @@ DSL_Error_t DSL_DRV_PM_DEV_ReTxCountersG + /* ignore zero value*/ + if (nEftrMin) + { +- /* Fw Format: kBit/s */ +- /* API format: bit/s */ +- pCounters->nEftrMin = nEftrMin*1000; ++ if (nDirection == DSL_NEAR_END) ++ { ++ /* Fw Format: kBit/s */ ++ /* API format: bit/s */ ++ pCounters->nEftrMin = nEftrMin*1000; ++ } ++ else ++ { ++ pCounters->nEftrMin = nEftrMin; ++ } + } + } + else diff --git a/package/kernel/lantiq/ltq-vdsl-vr9/patches/300-fix-compilation-warning-fallthrough.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/300-fix-compilation-warning-fallthrough.patch new file mode 100644 index 00000000000..b0e106a5f57 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/300-fix-compilation-warning-fallthrough.patch @@ -0,0 +1,36 @@ +--- a/src/common/drv_dsl_cpe_api.c ++++ b/src/common/drv_dsl_cpe_api.c +@@ -1922,7 +1922,7 @@ DSL_Error_t DSL_DRV_AutobootControlSet( + } + /* no break */ + /* ... pass to restart*/ +- ++ fallthrough; + case DSL_AUTOBOOT_CTRL_RESTART: + case DSL_AUTOBOOT_CTRL_RESTART_FULL: + if (bAutobootDisable && pData->data.nCommand == DSL_AUTOBOOT_CTRL_RESTART) +--- a/src/pm/drv_dsl_cpe_pm_core.c ++++ b/src/pm/drv_dsl_cpe_pm_core.c +@@ -2325,16 +2325,18 @@ DSL_Error_t DSL_DRV_PM_CountersReset( + } + #endif /* #ifdef INCLUDE_DSL_CPE_PM_HISTORY*/ + +- if (ResetType == DSL_PM_RESET_HISTORY) +- break; ++ if (ResetType == DSL_PM_RESET_HISTORY) ++ break; + ++ fallthrough; + case DSL_PM_RESET_TOTAL: + #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS + memset(EpData.pRecTotal, nFillValue, EpData.nEpRecElementSize); + #endif /* #ifdef INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS*/ +- if (ResetType == DSL_PM_RESET_TOTAL) +- break; ++ if (ResetType == DSL_PM_RESET_TOTAL) ++ break; + ++ fallthrough; + case DSL_PM_RESET_HISTORY_SHOWTIME: + #ifdef INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS + nErrCode = DSL_DRV_PM_HistoryDelete(pContext, EpData.pHistShowtime );
\ No newline at end of file diff --git a/package/kernel/lantiq/ltq-vdsl-vr9/patches/301-fix-compilation-warning-simple-fix.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/301-fix-compilation-warning-simple-fix.patch new file mode 100644 index 00000000000..99f1908f0fa --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/301-fix-compilation-warning-simple-fix.patch @@ -0,0 +1,132 @@ +--- a/src/common/drv_dsl_cpe_os_linux.c ++++ b/src/common/drv_dsl_cpe_os_linux.c +@@ -54,7 +54,7 @@ static int DSL_DRV_Release(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil); + + static DSL_uint_t DSL_DRV_Poll(DSL_DRV_file_t *pFile, DSL_DRV_Poll_Table_t *wait); + +-#ifdef INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT ++#if defined(INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT) && !defined(DSL_DEBUG_DISABLE) + static void DSL_DRV_NlSendMsg(DSL_char_t* pMsg); + #endif + +@@ -368,10 +368,10 @@ int DSL_DRV_debug_printf(DSL_Context_t const *pContext, DSL_char_t const *fmt, . + { + DSL_int_t nRet = 0; + #ifndef _lint +- DSL_int_t nLength = 0; +- DSL_boolean_t bPrint = DSL_FALSE; + #ifdef INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT + #ifndef DSL_DEBUG_DISABLE ++ DSL_int_t nLength = 0; ++ DSL_boolean_t bPrint = DSL_FALSE; + DSL_char_t debugString[DSL_DBG_MAX_DEBUG_PRINT_CHAR + 1] = {0}; + va_list ap; /* points to each unnamed arg in turn */ + +@@ -406,6 +406,8 @@ int DSL_DRV_debug_printf(DSL_Context_t const *pContext, DSL_char_t const *fmt, . + #endif /* DSL_DEBUG_DISABLE */ + return nRet; + #else ++ DSL_int_t nLength = 0; ++ DSL_boolean_t bPrint = DSL_FALSE; + DSL_char_t msg[DSL_DBG_MAX_DEBUG_PRINT_CHAR + 1] = "\0"; + va_list ap; /* points to each unnamed arg in turn */ + +@@ -1172,7 +1174,7 @@ static void DSL_DRV_DebugInit(void) + return; + } + +-#ifdef INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT ++#if defined(INCLUDE_DSL_CPE_DEBUG_LOGGER_SUPPORT) && !defined(DSL_DEBUG_DISABLE) + static void DSL_DRV_NlSendMsg(DSL_char_t* pMsg) + { + struct nlmsghdr *pNlMsgHdr; +@@ -1261,7 +1263,7 @@ void __exit DSL_ModuleCleanup(void) + printk("Module will be unloaded"DSL_DRV_CRLF); + + device_destroy(dsl_class, dsl_devt); +- dsl_devt = NULL; ++ dsl_devt = 0; + class_destroy(dsl_class); + dsl_class = NULL; + +--- a/src/device/drv_dsl_cpe_msg_vrx.c ++++ b/src/device/drv_dsl_cpe_msg_vrx.c +@@ -2456,32 +2456,32 @@ DSL_Error_t DSL_DRV_VRX_SendMsgSnrPerGroupesGet( + #endif /* defined(INCLUDE_DSL_G997_PER_TONE) || defined(INCLUDE_DSL_DELT)*/ + + #ifdef INCLUDE_DSL_DELT +-static DSL_Error_t DSL_DRV_VRX_SpreadArray( +- DSL_void_t* pArray, +- DSL_uint16_t valueSize, +- DSL_uint16_t valueCount, +- DSL_uint16_t multiplier) +-{ +- DSL_void_t* pSrc = pArray + valueSize * (valueCount - 1); +- DSL_void_t* pDst = pArray + valueSize * (valueCount*multiplier - 1); +- +- if (pArray == DSL_NULL) +- { +- return DSL_ERROR; +- } +- +- for (; valueCount; --valueCount, pSrc -= valueSize) +- { +- DSL_uint16_t i; +- +- for ( i = multiplier; i; --i, pDst -= valueSize) +- { +- memcpy(pDst,pSrc,valueSize); +- } +- } +- +- return DSL_SUCCESS; +-} ++// static DSL_Error_t DSL_DRV_VRX_SpreadArray( ++// DSL_void_t* pArray, ++// DSL_uint16_t valueSize, ++// DSL_uint16_t valueCount, ++// DSL_uint16_t multiplier) ++// { ++// DSL_void_t* pSrc = pArray + valueSize * (valueCount - 1); ++// DSL_void_t* pDst = pArray + valueSize * (valueCount*multiplier - 1); ++ ++// if (pArray == DSL_NULL) ++// { ++// return DSL_ERROR; ++// } ++ ++// for (; valueCount; --valueCount, pSrc -= valueSize) ++// { ++// DSL_uint16_t i; ++ ++// for ( i = multiplier; i; --i, pDst -= valueSize) ++// { ++// memcpy(pDst,pSrc,valueSize); ++// } ++// } ++ ++// return DSL_SUCCESS; ++// } + + /** + This function requests a set of up to 60 entries of the DELT data. +--- a/src/device/drv_dsl_cpe_device_vrx.c ++++ b/src/device/drv_dsl_cpe_device_vrx.c +@@ -3356,7 +3356,9 @@ static DSL_Error_t DSL_DRV_VRX_TestParametersFeUpdate( + DSL_Error_t nErrCode = DSL_SUCCESS; + DSL_uint16_t i = 0; + DSL_uint16_t nDataLen = 0; ++#ifndef DSL_DEBUG_DISABLE + DSL_uint16_t nMsgId = EVT_PMD_TESTPARAMSGET; ++#endif /* DSL_DEBUG_DISABLE */ + + DSL_DEBUG( DSL_DBG_MSG, + (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_VRX_TestParametersFeUpdate" +@@ -8312,6 +8314,7 @@ DSL_Error_t DSL_DRV_DEV_AutobootHandleTraining( + (pContext, SYS_DBG_MSG"DSL[%02d]: ORDERLY_SHUTDOWN state reached" + DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); + /* do not use break here, continue handling */ ++ fallthrough; + #endif /* INCLUDE_DSL_CPE_API_VRX */ + case DSL_LINESTATE_EXCEPTION: + if (!bPreFail) diff --git a/package/kernel/lantiq/ltq-vectoring/Makefile b/package/kernel/lantiq/ltq-vectoring/Makefile new file mode 100644 index 00000000000..7e25422f013 --- /dev/null +++ b/package/kernel/lantiq/ltq-vectoring/Makefile @@ -0,0 +1,60 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ltq-vectoring +PKG_RELEASE:=3 +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/ppa_drv.git +PKG_SOURCE_DATE:=2019-05-20 +PKG_SOURCE_VERSION:=4fa7ac30fcc8ec4eddae9debba5f4230981f469f +PKG_MIRROR_HASH:=444eb823dd9ddd25453976bf7a3230955e4148b8bf92f35f165ecffee32c4555 +PKG_LICENSE:=GPL-2.0 BSD-2-Clause + +MAKE_PATH:=src/vectoring +PKG_EXTMOD_SUBDIRS:=$(MAKE_PATH) + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ltq-vectoring + SECTION:=sys + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=driver for sending vectoring error samples + DEPENDS:=@TARGET_lantiq_xrx200 + FILES:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/ltq_vectoring.ko + AUTOLOAD:=$(call AutoLoad,49,ltq_vectoring) +endef + +define Package/ltq-vectoring/description + This driver is responsible for sending error reports to the vectoring + control entity, which is required for downstream vectoring to work. + + The error reports are generated by the DSL firmware, and passed to this + driver by the MEI driver. +endef + +define KernelPackage/ltq-vectoring-test + SECTION:=sys + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=driver for testing the vectoring driver + DEPENDS:=@TARGET_lantiq_xrx200 +kmod-ltq-vectoring + FILES:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/ltq_vectoring_test.ko +endef + +define Package/ltq-vectoring-test/description + This allows to send dummy data to the vectoring error block callback. + This is only needed for test and development purposes. +endef + +define Build/Configure +endef + +define Build/Compile + +$(KERNEL_MAKE) $(PKG_JOBS) \ + M="$(PKG_BUILD_DIR)/$(MAKE_PATH)" \ + modules +endef + +$(eval $(call KernelPackage,ltq-vectoring)) +$(eval $(call KernelPackage,ltq-vectoring-test)) diff --git a/package/kernel/lantiq/ltq-vectoring/patches/001-fix-compile.patch b/package/kernel/lantiq/ltq-vectoring/patches/001-fix-compile.patch new file mode 100644 index 00000000000..c97ec4d94b3 --- /dev/null +++ b/package/kernel/lantiq/ltq-vectoring/patches/001-fix-compile.patch @@ -0,0 +1,95 @@ +--- a/src/vectoring/Makefile ++++ b/src/vectoring/Makefile +@@ -1,5 +1,5 @@ +-obj-$(CONFIG_PTM_VECTORING) += ifxmips_vectoring.o +-obj-y += ifxmips_vectoring_stub.o +-ifeq ($(CONFIG_DSL_MEI_CPE_DRV),) +-obj-$(CONFIG_PTM_VECTORING) += ifxmips_vectoring_test.o +-endif ++obj-m += ltq_vectoring.o ++ltq_vectoring-objs = ifxmips_vectoring.o ifxmips_vectoring_stub.o ++ ++obj-m += ltq_vectoring_test.o ++ltq_vectoring_test-objs = ifxmips_vectoring_test.o +--- a/src/vectoring/ifxmips_vectoring.c ++++ b/src/vectoring/ifxmips_vectoring.c +@@ -30,9 +30,11 @@ + /* + * Common Head File + */ ++#include <linux/version.h> + #include <linux/kernel.h> + #include <linux/module.h> + #include <linux/etherdevice.h> ++#include <linux/proc_fs.h> + + /* + * Chip Specific Head File +@@ -239,7 +241,7 @@ static int netdev_event_handler(struct n + && event != NETDEV_UNREGISTER ) + return NOTIFY_DONE; + +- netif = (struct net_device *)netdev; ++ netif = netdev_notifier_info_to_dev(netdev); + if ( strcmp(netif->name, "ptm0") != 0 ) + return NOTIFY_DONE; + +@@ -356,6 +358,7 @@ static int proc_write_dbg(struct file *f + return count; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) + static struct file_operations g_proc_file_vectoring_dbg_seq_fops = { + .owner = THIS_MODULE, + .open = proc_read_dbg_seq_open, +@@ -364,6 +367,15 @@ static struct file_operations g_proc_fil + .llseek = seq_lseek, + .release = single_release, + }; ++#else ++static struct proc_ops g_proc_file_vectoring_dbg_seq_fops = { ++ .proc_open = proc_read_dbg_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_dbg, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++}; ++#endif + + static int proc_read_dbg_seq_open(struct inode *inode, struct file *file) + { +--- a/src/vectoring/ifxmips_vectoring_test.c ++++ b/src/vectoring/ifxmips_vectoring_test.c +@@ -1,6 +1,8 @@ ++#include <linux/version.h> + #include <linux/kernel.h> + #include <linux/module.h> + #include <linux/proc_fs.h> ++#include <linux/seq_file.h> + + #include "ifxmips_vectoring_stub.h" + +@@ -82,6 +84,7 @@ static int proc_write_vectoring(struct f + return count; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) + static struct file_operations g_proc_file_vectoring_seq_fops = { + .owner = THIS_MODULE, + .open = proc_read_vectoring_seq_open, +@@ -90,6 +93,15 @@ static struct file_operations g_proc_fil + .llseek = seq_lseek, + .release = single_release, + }; ++#else ++static struct proc_ops g_proc_file_vectoring_seq_fops = { ++ .proc_open = proc_read_vectoring_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_vectoring, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++}; ++#endif + + static int proc_read_vectoring_seq_open(struct inode *inode, struct file *file) + { diff --git a/package/kernel/lantiq/ltq-vectoring/patches/100-cleanup.patch b/package/kernel/lantiq/ltq-vectoring/patches/100-cleanup.patch new file mode 100644 index 00000000000..2b0067379df --- /dev/null +++ b/package/kernel/lantiq/ltq-vectoring/patches/100-cleanup.patch @@ -0,0 +1,73 @@ +--- a/src/vectoring/ifxmips_vectoring.c ++++ b/src/vectoring/ifxmips_vectoring.c +@@ -325,7 +325,7 @@ static int proc_write_dbg(struct file *f + else + printk(dbg_enable_mask_str[i] + 1); + } +- printk("] > /proc/vectoring\n"); ++ printk("] > /proc/driver/vectoring\n"); + } + + if ( f_enable ) +@@ -433,11 +433,10 @@ static int __init vectoring_init(void) + { + struct proc_dir_entry *res; + +- res = proc_create("vectoring", ++ res = proc_create("driver/vectoring", + S_IRUGO|S_IWUSR, + 0, + &g_proc_file_vectoring_dbg_seq_fops); +- printk("res = %p\n", res); + + register_netdev_event_handler(); + g_ptm_net_dev = dev_get_by_name(&init_net, "ptm0"); +@@ -460,7 +459,7 @@ static void __exit vectoring_exit(void) + + unregister_netdev_event_handler(); + +- remove_proc_entry("vectoring", NULL); ++ remove_proc_entry("driver/vectoring", NULL); + } + + module_init(vectoring_init); +--- a/src/vectoring/ifxmips_vectoring_test.c ++++ b/src/vectoring/ifxmips_vectoring_test.c +@@ -79,7 +79,7 @@ static int proc_write_vectoring(struct f + } + } + else +- printk("echo send <size> > /proc/eth/vectoring\n"); ++ printk("echo send <size> > /proc/driver/vectoring_test\n"); + + return count; + } +@@ -112,9 +112,7 @@ static __init void proc_file_create(void + { + struct proc_dir_entry *res; + +-// g_proc_dir = proc_mkdir("eth", NULL); +- +- res = proc_create("eth/vectoring", ++ res = proc_create("driver/vectoring_test", + S_IRUGO|S_IWUSR, + g_proc_dir, + &g_proc_file_vectoring_seq_fops); +@@ -122,10 +120,7 @@ static __init void proc_file_create(void + + static __exit void proc_file_delete(void) + { +- remove_proc_entry("vectoring", +- g_proc_dir); +- +- remove_proc_entry("eth", NULL); ++ remove_proc_entry("driver/vectoring_test", NULL); + } + + +@@ -151,3 +146,5 @@ static void __exit vectoring_test_exit(v + + module_init(vectoring_test_init); + module_exit(vectoring_test_exit); ++ ++MODULE_LICENSE("GPL"); diff --git a/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch b/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch new file mode 100644 index 00000000000..04c6880ddea --- /dev/null +++ b/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch @@ -0,0 +1,120 @@ +--- a/src/vectoring/ifxmips_vectoring.c ++++ b/src/vectoring/ifxmips_vectoring.c +@@ -35,6 +35,8 @@ + #include <linux/module.h> + #include <linux/etherdevice.h> + #include <linux/proc_fs.h> ++#include <linux/pkt_sched.h> ++#include <linux/workqueue.h> + + /* + * Chip Specific Head File +@@ -88,6 +90,7 @@ static void dump_skb(struct sk_buff *skb + + static void ltq_vectoring_priority(uint32_t priority); + ++static void xmit_work_handler(struct work_struct *); + + /* + * #################################### +@@ -118,9 +121,11 @@ struct erb_head { + + static struct notifier_block g_netdev_event_handler_nb = {0}; + static struct net_device *g_ptm_net_dev = NULL; +-static uint32_t vector_prio = 0; ++static uint32_t vector_prio = TC_PRIO_CONTROL; + static int g_dbg_enable = 0; + ++DECLARE_WORK(xmit_work, xmit_work_handler); ++struct sk_buff_head xmit_queue; + + + /* +@@ -129,9 +134,16 @@ static int g_dbg_enable = 0; + * #################################### + */ + ++static void xmit_work_handler(__attribute__((unused)) struct work_struct *work) { ++ struct sk_buff *skb; ++ ++ while ((skb = skb_dequeue(&xmit_queue)) != NULL) { ++ dev_queue_xmit(skb); ++ } ++} ++ + static int mei_dsm_cb_func(unsigned int *p_error_vector) + { +- int rc, ret; + struct sk_buff *skb_list = NULL; + struct sk_buff *skb; + struct erb_head *erb; +@@ -179,7 +191,6 @@ static int mei_dsm_cb_func(unsigned int + } + } + +- rc = 0; + sent_size = 0; + segment_code = 0; + while ( (skb = skb_list) != NULL ) { +@@ -197,24 +208,23 @@ static int mei_dsm_cb_func(unsigned int + segment_code |= 0xC0; + ((struct erb_head *)skb->data)->segment_code = segment_code; + +- skb->cb[13] = 0x5A; /* magic number indicating forcing QId */ +- skb->cb[15] = 0x00; /* highest priority queue */ +- skb->priority = vector_prio; ++ skb_reset_mac_header(skb); ++ skb_set_network_header(skb, offsetof(struct erb_head, llc_header)); ++ skb->protocol = htons(ETH_P_802_2); ++ skb->priority = vector_prio; + skb->dev = g_ptm_net_dev; + + dump_skb(skb, ~0, "vectoring TX", 0, 0, 1, 0); + +- ret = g_ptm_net_dev->netdev_ops->ndo_start_xmit(skb, g_ptm_net_dev); +- if ( rc == 0 ) +- rc = ret; ++ skb_queue_tail(&xmit_queue, skb); ++ schedule_work(&xmit_work); + + segment_code++; + } + + *p_error_vector = 0; /* notify DSL firmware that ERB is sent */ + +- ASSERT(rc == 0, "dev_queue_xmit fail - %d", rc); +- return rc; ++ return 0; + } + static void ltq_vectoring_priority(uint32_t priority) + { +@@ -242,7 +252,7 @@ static int netdev_event_handler(struct n + return NOTIFY_DONE; + + netif = netdev_notifier_info_to_dev(netdev); +- if ( strcmp(netif->name, "ptm0") != 0 ) ++ if ( strcmp(netif->name, "dsl0") != 0 ) + return NOTIFY_DONE; + + g_ptm_net_dev = event == NETDEV_REGISTER ? netif : NULL; +@@ -438,8 +448,10 @@ static int __init vectoring_init(void) + 0, + &g_proc_file_vectoring_dbg_seq_fops); + ++ skb_queue_head_init(&xmit_queue); ++ + register_netdev_event_handler(); +- g_ptm_net_dev = dev_get_by_name(&init_net, "ptm0"); ++ g_ptm_net_dev = dev_get_by_name(&init_net, "dsl0"); + if ( g_ptm_net_dev != NULL ) + dev_put(g_ptm_net_dev); + +@@ -459,6 +471,8 @@ static void __exit vectoring_exit(void) + + unregister_netdev_event_handler(); + ++ flush_scheduled_work(); ++ + remove_proc_entry("driver/vectoring", NULL); + } + diff --git a/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch b/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch new file mode 100644 index 00000000000..4d18f8e3b7a --- /dev/null +++ b/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch @@ -0,0 +1,69 @@ +--- a/src/vectoring/ifxmips_vectoring.c ++++ b/src/vectoring/ifxmips_vectoring.c +@@ -298,7 +298,7 @@ static int proc_write_dbg(struct file *file, const char __user *buf, size_t coun + DBG_ENABLE_MASK_ALL + }; + +- char str[2048]; ++ char *str; + char *p; + + int len, rlen; +@@ -306,6 +306,10 @@ static int proc_write_dbg(struct file *file, const char __user *buf, size_t coun + int f_enable = 0; + int i; + ++ str = kcalloc(2048, sizeof(*str), GFP_KERNEL); ++ if (!str) ++ return -ENOMEM; ++ + len = count < sizeof(str) ? count : sizeof(str) - 1; + rlen = len - copy_from_user(str, buf, len); + while ( rlen && str[rlen - 1] <= ' ' ) +@@ -365,6 +369,8 @@ static int proc_write_dbg(struct file *file, const char __user *buf, size_t coun + } + } + ++ kfree(str); ++ + return count; + } + +--- a/src/vectoring/ifxmips_vectoring_test.c ++++ b/src/vectoring/ifxmips_vectoring_test.c +@@ -3,6 +3,7 @@ + #include <linux/module.h> + #include <linux/proc_fs.h> + #include <linux/seq_file.h> ++#include <linux/slab.h> + + #include "ifxmips_vectoring_stub.h" + +@@ -46,13 +47,17 @@ static int proc_write_vectoring(struct file *file, const char __user *buf, size_ + { + char *p; + int len; +- char local_buf[1024]; ++ char *local_buf; + + unsigned long pkt_len; + int ret; + unsigned long sys_flag; + unsigned long start, end; + ++ local_buf = kcalloc(1024, sizeof(*local_buf), GFP_KERNEL); ++ if (!local_buf) ++ return -ENOMEM; ++ + len = sizeof(local_buf) < count ? sizeof(local_buf) - 1 : count; + len = len - copy_from_user(local_buf, buf, len); + local_buf[len] = 0; +@@ -81,6 +86,8 @@ static int proc_write_vectoring(struct file *file, const char __user *buf, size_ + else + printk("echo send <size> > /proc/driver/vectoring_test\n"); + ++ kfree(local_buf); ++ + return count; + } + diff --git a/package/kernel/lantiq/ltq-vmmc/patches/200-compat.patch b/package/kernel/lantiq/ltq-vmmc/patches/200-compat.patch index bf9f17ed057..dd6451b52d7 100644 --- a/package/kernel/lantiq/ltq-vmmc/patches/200-compat.patch +++ b/package/kernel/lantiq/ltq-vmmc/patches/200-compat.patch @@ -9,6 +9,16 @@ /* ============================= */ /* Local Macros & Definitions */ /* ============================= */ +@@ -862,7 +864,9 @@ void vmmc_module_exit(void) + #ifdef MODULE + MODULE_DESCRIPTION("VMMC(VoiceMacroMipsCore) device driver - www.lantiq.com"); + MODULE_AUTHOR("Lantiq Deutschland GmbH"); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)) + MODULE_SUPPORTED_DEVICE("DANUBE, TWINPASS, INCA-IP2, AR9, VR9"); ++#endif + MODULE_LICENSE("Dual BSD/GPL"); + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) --- a/src/mps/drv_mps_vmmc_linux.c +++ b/src/mps/drv_mps_vmmc_linux.c @@ -80,11 +80,15 @@ diff --git a/package/kernel/lantiq/ltq-vmmc/patches/600-fix-compilation-warning-fallthrough.patch b/package/kernel/lantiq/ltq-vmmc/patches/600-fix-compilation-warning-fallthrough.patch new file mode 100644 index 00000000000..7282bc446dd --- /dev/null +++ b/package/kernel/lantiq/ltq-vmmc/patches/600-fix-compilation-warning-fallthrough.patch @@ -0,0 +1,10 @@ +--- a/src/drv_vmmc_bbd.c ++++ b/src/drv_vmmc_bbd.c +@@ -1025,6 +1025,7 @@ static IFX_int32_t vmmc_BBD_WhiteListedCmdWr(VMMC_CHANNEL *pCh, + } + } + } ++ fallthrough; + case VMMC_WL_SDD_RING_CFG: + case VMMC_WL_SDD_DCDC_CFG: + case VMMC_WL_SDD_MWI_CFG: diff --git a/package/kernel/lantiq/ltq-vmmc/patches/601-fix-compilation-warning-ret-not-handled.patch b/package/kernel/lantiq/ltq-vmmc/patches/601-fix-compilation-warning-ret-not-handled.patch new file mode 100644 index 00000000000..da7c1c8a268 --- /dev/null +++ b/package/kernel/lantiq/ltq-vmmc/patches/601-fix-compilation-warning-ret-not-handled.patch @@ -0,0 +1,16 @@ +--- a/src/drv_vmmc_ioctl.c ++++ b/src/drv_vmmc_ioctl.c +@@ -108,9 +108,11 @@ extern IFX_int32_t VMMC_ChipAccessInit ( + {\ + arg* p_arg = VMMC_OS_Malloc (sizeof(arg));\ + VMMC_ASSERT (p_arg != IFX_NULL);\ +- copy_from_user (p_arg, (IFX_uint8_t*)ioarg, sizeof(arg));\ ++ if (copy_from_user (p_arg, (IFX_uint8_t*)ioarg, sizeof(arg)))\ ++ ret = -EFAULT;\ + ret = func((pContext), p_arg);\ +- copy_to_user ((IFX_uint8_t*)ioarg, p_arg, sizeof(arg));\ ++ if (copy_to_user ((IFX_uint8_t*)ioarg, p_arg, sizeof(arg)))\ ++ ret = -EFAULT;\ + VMMC_OS_Free (p_arg);\ + }\ + break diff --git a/package/kernel/lantiq/vrx518_ep/Makefile b/package/kernel/lantiq/vrx518_ep/Makefile new file mode 100644 index 00000000000..b6477b19d6d --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/Makefile @@ -0,0 +1,57 @@ +# +# Copyright (C) 2019 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:=vrx518_ep +PKG_VERSION:=2.1.0 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +# TODO this driver depends on the vrx518 aca firmware, add this dependency if +# that ever gets a compatible license +define KernelPackage/vrx518_ep + SECTION:=sys + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=VRX518 EP Support + DEPENDS:=@TARGET_ipq40xx + AUTOLOAD:=$(call AutoLoad,26,vrx518) + FILES:=$(PKG_BUILD_DIR)/vrx518.ko +endef + +define KernelPackage/vrx518_ep/description + VRX518 endpoint driver +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/net/ + $(CP) $(PKG_BUILD_DIR)/include/net/dc_ep.h $(1)/usr/include/net/ +endef + +EXTRA_KCONFIG:= \ + CONFIG_VRX518=m +# CONFIG_TEST=m +# CONFIG_VRX518_PCIE_SWITCH_BONDING=y + +EXTRA_CFLAGS:= \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \ + -I$(PKG_BUILD_DIR)/include + +define Build/Compile + $(KERNEL_MAKE) \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + $(EXTRA_KCONFIG) \ + modules +endef + +$(eval $(call KernelPackage,vrx518_ep)) diff --git a/package/kernel/lantiq/vrx518_ep/patches/100-compat.patch b/package/kernel/lantiq/vrx518_ep/patches/100-compat.patch new file mode 100644 index 00000000000..a139c7a8624 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/patches/100-compat.patch @@ -0,0 +1,92 @@ +--- a/ep.c ++++ b/ep.c +@@ -373,23 +373,23 @@ int dc_ep_dev_info_req(int dev_idx, enum + + switch (module) { + case DC_EP_INT_PPE: +- dev->irq = priv->irq_base; ++ dev->irq = pci_irq_vector(priv->pdev, 0); + if (priv->msi_mode == DC_EP_8_MSI_MODE) { +- dev->aca_tx_irq = priv->irq_base + 7; +- dev->aca_rx_irq = priv->irq_base + 6; ++ dev->aca_tx_irq = pci_irq_vector(priv->pdev, 7); ++ dev->aca_rx_irq = pci_irq_vector(priv->pdev, 6); + } else if (priv->msi_mode == DC_EP_4_MSI_MODE) { +- dev->aca_tx_irq = priv->irq_base + 2; +- dev->aca_rx_irq = priv->irq_base + 3; ++ dev->aca_tx_irq = pci_irq_vector(priv->pdev, 2); ++ dev->aca_rx_irq = pci_irq_vector(priv->pdev, 3); + } else { + dev_err(dev->dev, "%s ACA should never occur\n", + __func__); + } + break; + case DC_EP_INT_MEI: +- dev->irq = priv->irq_base + 1; ++ dev->irq = pci_irq_vector(priv->pdev, 1); + break; + default: +- dev->irq = priv->irq_base; ++ dev->irq = pci_irq_vector(priv->pdev, 0); + break; + } + +@@ -466,8 +466,8 @@ static int dc_ep_msi_enable(struct pci_d + return -EIO; + } + +- err = pci_enable_msi_exact(pdev, nvec); +- if (err) { ++ err = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSI | PCI_IRQ_LEGACY); ++ if (err < 0) { + dev_err(&pdev->dev, + "%s: Failed to enable MSI interrupts error code: %d\n", + __func__, err); +@@ -589,15 +589,15 @@ static int dc_ep_probe(struct pci_dev *p + /* Target structures have a limit of 32 bit DMA pointers. + * DMA pointers can be wider than 32 bits by default on some systems. + */ +- ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); ++ ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(&pdev->dev, "32-bit DMA not available: %d\n", ret); + goto err_region; + } + +- ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); ++ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); + if (ret) { +- dev_err(&pdev->dev, "cannot enable 32-bit consistent DMA\n"); ++ dev_err(&pdev->dev, "cannot enable 32-bit coherent DMA\n"); + goto err_region; + } + +@@ -654,7 +654,7 @@ static int dc_ep_probe(struct pci_dev *p + goto err_iomap; + + spin_lock(&dc_ep_lock); +- priv->irq_base = pdev->irq; ++ priv->irq_base = pci_irq_vector(pdev, 0); + spin_unlock(&dc_ep_lock); + + #ifndef CONFIG_OF +@@ -715,7 +715,7 @@ static void dc_ep_remove(struct pci_dev + dc_ep_icu_disable(priv); + pci_iounmap(pdev, priv->mem); + pci_release_region(pdev, DC_EP_BAR_NUM); +- pci_disable_msi(pdev); ++ pci_free_irq_vectors(pdev); + wmb(); + pci_clear_master(pdev); + pci_disable_device(pdev); +--- a/aca.c ++++ b/aca.c +@@ -756,7 +756,7 @@ static void aca_hif_param_init_done(stru + addr = fw_param->init_addr; + dev_dbg(priv->dev, "init_addr: %x\n", addr); + memcpy_toio(priv->mem + addr, hif_params, sizeof(*hif_params)); +- kzfree(hif_params); ++ kfree(hif_params); + dev_dbg(priv->dev, "%s\n", __func__); + } + diff --git a/package/kernel/lantiq/vrx518_ep/patches/200-fix-irq-masking.patch b/package/kernel/lantiq/vrx518_ep/patches/200-fix-irq-masking.patch new file mode 100644 index 00000000000..b833c72bec3 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/patches/200-fix-irq-masking.patch @@ -0,0 +1,49 @@ +Fix double negation of bitmask in dc_ep_icu_disable andwr32_mask. +Also add locking to ensure the masking is applied atomically. + +--- a/misc.c ++++ b/misc.c +@@ -68,12 +68,22 @@ void dc_ep_icu_disable(struct dc_ep_priv + + void dc_ep_icu_dis_intr(struct dc_ep_priv *priv, u32 bits) + { +- wr32_mask(~bits, 0, ICU_IMER); ++ struct dc_aca *aca = to_aca(priv); ++ unsigned long flags; ++ ++ spin_lock_irqsave(&aca->icu_lock, flags); ++ wr32_mask(bits, 0, ICU_IMER); ++ spin_unlock_irqrestore(&aca->icu_lock, flags); + } + + void dc_ep_icu_en_intr(struct dc_ep_priv *priv, u32 bits) + { ++ struct dc_aca *aca = to_aca(priv); ++ unsigned long flags; ++ ++ spin_lock_irqsave(&aca->icu_lock, flags); + wr32_mask(0, bits, ICU_IMER); ++ spin_unlock_irqrestore(&aca->icu_lock, flags); + } + + void dc_ep_assert_device(struct dc_ep_priv *priv, u32 bits) +--- a/aca.c ++++ b/aca.c +@@ -1158,6 +1158,7 @@ void dc_aca_info_init(struct dc_ep_priv + struct dc_aca *aca = to_aca(priv); + + aca->initialized = false; ++ spin_lock_init(&aca->icu_lock); + spin_lock_init(&aca->clk_lock); + spin_lock_init(&aca->rcu_lock); + mutex_init(&aca->pin_lock); +--- a/aca.h ++++ b/aca.h +@@ -470,6 +470,7 @@ struct aca_hif_params { + + struct dc_aca { + bool initialized; ++ spinlock_t icu_lock; + spinlock_t clk_lock; + spinlock_t rcu_lock; + struct mutex pin_lock; diff --git a/package/kernel/lantiq/vrx518_ep/src/Kconfig b/package/kernel/lantiq/vrx518_ep/src/Kconfig new file mode 100644 index 00000000000..296bc4c7aae --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/Kconfig @@ -0,0 +1,9 @@ +config TEST + tristate "Intel(R) VRX518 SmartPHY DSL Test Driver" + depends on VRX518 + ---help--- + This driver supports Intel(R) VRX518 DSL interrupt and ACA test. + + To compile this driver as a module, choose M here. The module + will be called vrx518. MSI interrupt support is required for + this driver to work correctly. diff --git a/package/kernel/lantiq/vrx518_ep/src/Makefile b/package/kernel/lantiq/vrx518_ep/src/Makefile new file mode 100644 index 00000000000..b79e74b3170 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/Makefile @@ -0,0 +1,33 @@ +################################################################################ +# +# Intel SmartPHY DSL PCIe EP/ACA Linux driver +# Copyright(c) 2016 Intel Corporation. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms and conditions of the GNU General Public License, +# version 2, as published by the Free Software Foundation. +# +# This program is distributed in the hope 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., +# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +# +# The full GNU General Public License is included in this distribution in +# the file called "COPYING". +# +################################################################################ + +# +# Makefile for the Intel(R) SmartPHY PCIe/ACA driver +# + +obj-$(CONFIG_VRX518) += vrx518.o + +vrx518-objs := ep.o aca.o misc.o + +obj-$(CONFIG_TEST) += test/ + diff --git a/package/kernel/lantiq/vrx518_ep/src/aca.c b/package/kernel/lantiq/vrx518_ep/src/aca.c new file mode 100644 index 00000000000..3fcf454884a --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/aca.c @@ -0,0 +1,1209 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ +#define DEBUG +#include <linux/init.h> +#include <linux/types.h> +#include <linux/delay.h> +#include <linux/firmware.h> + +#include <net/dc_ep.h> + +#include "regs.h" +#include "ep.h" +#include "misc.h" +#include "aca.h" + +#define ACA_FW_FILE "aca_fw.bin" + +#define set_mask_bit(val, set, mask, bits) \ + (val = (((val) & (~((mask) << (bits)))) \ + | (((set) & (mask)) << (bits)))) + +static char soc_str[128]; + +static const char *const aca_img_type_str[ACA_IMG_MAX] = { + "vrx518", + "vrx618", + "falcon-mx", + "pmua", +}; + +static void soc_type_to_str(u32 soc) +{ + memset(soc_str, 0, sizeof(soc_str)); + + if ((soc & ACA_SOC_XRX300)) + strcat(soc_str, "xrx300 "); + + if ((soc & ACA_SOC_XRX500)) + strcat(soc_str, "xrx500 "); + + if ((soc & ACA_SOC_PUMA)) + strcat(soc_str, "puma "); + + if ((soc & ACA_SOC_3RD_PARTY)) + strcat(soc_str, "third party SoC "); +} + +static const char *fw_id_to_str(u32 fw_id) +{ + switch (fw_id) { + case ACA_FW_TXIN: + return "txin"; + + case ACA_FW_TXOUT: + return "txout"; + + case ACA_FW_RXIN: + return "rxin"; + + case ACA_FW_RXOUT: + return "rxout"; + + case ACA_FW_GNRC: + return "Genrisc"; + + default: + return "unknow"; + } +} + +static const char * const sec_id_str[] = { + "Unknown", "HIF", "GenRisc", "MAC_HT", "TXIN", "TXIN_PDRING", "TXOUT", + "TXOUT_PDRING", "RXIN", "RXIN_PDRING", "RXOUT", "RXOUT_PDRING", "DMA", + "FW_INIT", +}; +static const char *sec_id_to_str(u32 sec_id) +{ + switch (sec_id) { + case ACA_SEC_HIF: + case ACA_SEC_GNR: + case ACA_SEC_MAC_HT: + case ACA_SEC_MEM_TXIN: + case ACA_SEC_MEM_TXIN_PDRING: + case ACA_SEC_MEM_TXOUT: + case ACA_SEC_MEM_TXOUT_PDRING: + case ACA_SEC_MEM_RXIN: + case ACA_SEC_MEM_RXIN_PDRING: + case ACA_SEC_MEM_RXOUT: + case ACA_SEC_MEM_RXOUT_PDRING: + case ACA_SEC_DMA: + case ACA_SEC_FW_INIT: + return sec_id_str[sec_id]; + case ACA_SEC_FW: + return "ACA FW"; + + default: + return "unknown"; + } +} + +static inline struct aca_fw_info *to_fw_info(struct dc_ep_priv *priv) +{ + return &priv->aca.fw_info; +} + +static inline struct aca_fw_dl_addr *to_fw_addr(struct dc_ep_priv *priv) +{ + return &priv->aca.fw_info.fw_dl; +} + +static inline struct aca_mem_layout *to_mem_layout(struct dc_ep_priv *priv) +{ + return &priv->aca.fw_info.mem_layout; +} + +static inline struct aca_pdmem_layout *to_pdmem_layout(struct dc_ep_priv *priv) +{ + return &priv->aca.fw_info.pdmem_layout; +} + +static inline struct aca_fw_param *to_aca_fw_param(struct dc_ep_priv *priv) +{ + return &priv->aca.fw_info.fw_param; +} + +static inline struct aca_hif_params *to_hif_params(struct dc_ep_priv *priv) +{ + return priv->aca.hif_params; +} + +static const struct firmware *aca_fetch_fw_file(struct dc_ep_priv *priv, + char *dir, const char *file) +{ + int ret; + char filename[100] = {0}; + const struct firmware *fw; + + if (file == NULL) + return ERR_PTR(-ENOENT); + + if (dir == NULL) + dir = "."; + + snprintf(filename, sizeof(filename), "%s/%s", dir, file); + ret = request_firmware(&fw, filename, priv->dev); + if (ret) + return ERR_PTR(ret); + + return fw; +} + +void dc_aca_free_fw_file(struct dc_ep_priv *priv) +{ + struct aca_fw_info *fw_info = to_fw_info(priv); + + if (fw_info->fw && !IS_ERR(fw_info->fw)) + release_firmware(fw_info->fw); + + fw_info->fw = NULL; + fw_info->fw_data = NULL; + fw_info->fw_len = 0; +} + +static void aca_dma_parse(struct dc_ep_priv *priv, const char *data, int chn) +{ + int i; + u32 cid, dbase; + struct aca_fw_dma *fw_dma; + struct aca_fw_info *fw_info = to_fw_info(priv); + + fw_info->chan_num = chn; + + for (i = 0; i < fw_info->chan_num; i++) { + fw_dma = (struct aca_fw_dma *)(data + i * sizeof(*fw_dma)); + cid = be32_to_cpu(fw_dma->cid); + dbase = be32_to_cpu(fw_dma->base); + fw_info->adma_desc_base[cid] = dbase; + dev_dbg(priv->dev, "dma channel %d desc base 0x%08x\n", + cid, dbase); + } +} + +static void aca_sram_desc_parse(struct dc_ep_priv *priv, const char *data, + u32 sid) +{ + u32 dbase, dnum; + struct aca_sram_desc *desc_base; + struct aca_mem_layout *mem_layout = to_mem_layout(priv); + struct aca_pdmem_layout *pdmem = to_pdmem_layout(priv); + + desc_base = (struct aca_sram_desc *)data; + dbase = be32_to_cpu(desc_base->dbase); + dnum = be32_to_cpu(desc_base->dnum); + + dev_dbg(priv->dev, "Sec %s desc base 0x%08x, des_num: %d\n", + sec_id_to_str(sid), dbase, dnum); + + switch (sid) { + case ACA_SEC_MEM_TXIN: + mem_layout->txin_host_desc_base = dbase; + mem_layout->txin_host_dnum = dnum; + break; + + case ACA_SEC_MEM_TXOUT: + mem_layout->txout_host_desc_base = dbase; + mem_layout->txout_host_dnum = dnum; + break; + + case ACA_SEC_MEM_RXIN: + mem_layout->rxin_host_desc_base = dbase; + mem_layout->rxin_host_dnum = dnum; + break; + + case ACA_SEC_MEM_RXOUT: + mem_layout->rxout_host_desc_base = dbase; + mem_layout->rxout_host_dnum = dnum; + break; + case ACA_SEC_MEM_TXIN_PDRING: + pdmem->txin_pd_desc_base = dbase; + pdmem->txin_pd_dnum = dnum; + break; + case ACA_SEC_MEM_TXOUT_PDRING: + pdmem->txout_pd_desc_base = dbase; + pdmem->txout_pd_dnum = dnum; + break; + case ACA_SEC_MEM_RXIN_PDRING: + pdmem->rxin_pd_desc_base = dbase; + pdmem->rxin_pd_dnum = dnum; + break; + case ACA_SEC_MEM_RXOUT_PDRING: + pdmem->rxin_pd_desc_base = dbase; + pdmem->rxin_pd_dnum = dnum; + break; + default: + dev_err(priv->dev, "Unknow aca sram section %d\n", sid); + break; + } +} + +static void aca_init_parse(struct dc_ep_priv *priv, const char *data, + u32 sid) +{ + struct aca_fw_param *fw_param = to_aca_fw_param(priv); + struct aca_fw_param *param; + u32 hdr_sz, hdr_addr; + + param = (struct aca_fw_param *)data; + hdr_sz = be32_to_cpu(param->st_sz); + hdr_addr = be32_to_cpu(param->init_addr); + + fw_param->init_addr = hdr_addr; + fw_param->st_sz = hdr_sz; + dev_dbg(priv->dev, "init st size: %d, addr: 0x%x\n", + hdr_sz, hdr_addr); +} + +static void aca_fw_parse(struct dc_ep_priv *priv, const char *data, + const char *fw_base, int fw_num) +{ + int i; + size_t size; + u32 id, offset, addr; + struct aca_int_hdr *hdr; + struct aca_fw_dl_addr *fw_dl = to_fw_addr(priv); + + fw_dl->fw_num = fw_num; + + for (i = 0; i < fw_dl->fw_num; i++) { + hdr = (struct aca_int_hdr *)(data + i * sizeof(*hdr)); + id = be32_to_cpu(hdr->id); + offset = be32_to_cpu(hdr->offset); + size = be32_to_cpu(hdr->size); + addr = be32_to_cpu(hdr->load_addr); + + fw_dl->fw_addr[i].fw_id = id; + fw_dl->fw_addr[i].fw_load_addr = addr; + fw_dl->fw_addr[i].fw_size = size; + fw_dl->fw_addr[i].fw_base = fw_base + offset; + dev_dbg(priv->dev, + "aca %s fw offset 0x%x size %zd loc 0x%x fw base %p\n", + fw_id_to_str(id), offset, size, addr, fw_base + offset); + } +} + +/* -------------------------------------------------------- + | Fixed header (20Bytes) | + --------------------------------------------------------- + | Variable header | + | ie / payload | + |-------------------------------------------------------| + | Actual ACA FW | + --------------------------------------------------------- +*/ +static int aca_section_parse(struct dc_ep_priv *priv, const char *fw_data) +{ + int ret = 0; + u32 fixed_hlen; + u32 var_hlen; + u32 ie_id; + size_t ie_len, ie_hlen, ie_dlen; + u32 fw_hlen; + struct aca_fw_f_hdr *fw_f_hdr; + struct aca_fw_ie *ie_hdr; + struct aca_int_hdr *aca_hdr; + const char *data = fw_data; + const char *aca_fw_data; + struct device *dev = priv->dev; + + fw_f_hdr = (struct aca_fw_f_hdr *)data; + + fw_hlen = be32_to_cpu(fw_f_hdr->hdr_size); + fixed_hlen = sizeof(*fw_f_hdr); + var_hlen = fw_hlen - fixed_hlen; + ie_hlen = sizeof(*ie_hdr); + + /* Record actual ACA fw data pointer */ + aca_fw_data = data + fw_hlen; + + /* Point to variable header and parse them */ + data += fixed_hlen; + + while (var_hlen > ie_hlen) { + /* Variable header information element */ + ie_hdr = (struct aca_fw_ie *)data; + ie_id = be32_to_cpu(ie_hdr->id); + ie_len = be32_to_cpu(ie_hdr->len); + dev_dbg(dev, "Section %s ie_len %zd\n", sec_id_to_str(ie_id), + ie_len); + + /* Variable header data conents */ + data += ie_hlen; + var_hlen -= ie_hlen; + + switch (ie_id) { + case ACA_SEC_HIF: + case ACA_SEC_GNR: + case ACA_SEC_MAC_HT: + ie_dlen = ie_len * sizeof(struct aca_fw_reg); + data += ie_dlen; + var_hlen -= ie_dlen; + + break; + + case ACA_SEC_MEM_TXIN: + case ACA_SEC_MEM_TXOUT: + case ACA_SEC_MEM_RXIN: + case ACA_SEC_MEM_RXOUT: + case ACA_SEC_MEM_TXIN_PDRING: + case ACA_SEC_MEM_TXOUT_PDRING: + case ACA_SEC_MEM_RXIN_PDRING: + case ACA_SEC_MEM_RXOUT_PDRING: + aca_sram_desc_parse(priv, data, ie_id); + ie_dlen = ie_len * sizeof(struct aca_sram_desc); + data += ie_dlen; + var_hlen -= ie_dlen; + break; + + case ACA_SEC_DMA: + if (ie_len > ACA_DMA_CHAN_MAX) { + dev_err(dev, "invalid dma channel %d\n", + ie_len); + ret = -EINVAL; + goto done; + } + aca_dma_parse(priv, data, ie_len); + ie_dlen = ie_len * sizeof(struct aca_fw_dma); + data += ie_dlen; + var_hlen -= ie_dlen; + break; + + case ACA_SEC_FW_INIT: + aca_init_parse(priv, data, ie_id); + ie_dlen = ie_len * sizeof(struct aca_fw_param); + data += ie_dlen; + var_hlen -= ie_dlen; + break; + + case ACA_SEC_FW: + if (ie_len > ACA_FW_MAX) { + dev_err(dev, "Too many aca fws %d\n", ie_len); + ret = -EINVAL; + goto done; + } + aca_fw_parse(priv, data, aca_fw_data, ie_len); + ie_dlen = ie_len * sizeof(*aca_hdr); + data += ie_dlen; + var_hlen -= ie_dlen; + break; + + default: + dev_warn(dev, "Unknown Sec id: %u\n", ie_id); + break; + } + } +done: + return ret; +} + +static int aca_fetch_fw_api(struct dc_ep_priv *priv, const char *name) +{ + int ret; + size_t hdr_len; + const u8 *fw_data; + size_t fw_len; + char dir[8] = {0}; + union fw_ver ver; + union img_soc_type type; + struct device *dev = priv->dev; + struct aca_fw_f_hdr *fw_f_hdr; + struct aca_fw_info *fw_info = to_fw_info(priv); + + sprintf(dir, "%04x", priv->pdev->device); + fw_info->fw = aca_fetch_fw_file(priv, dir, name); + if (IS_ERR(fw_info->fw)) { + dev_err(dev, "Could not fetch firmware file '%s': %ld\n", + name, PTR_ERR(fw_info->fw)); + return PTR_ERR(fw_info->fw); + } + + fw_data = fw_info->fw->data; + fw_len = fw_info->fw->size; + + /* Parse the fixed header part */ + fw_f_hdr = (struct aca_fw_f_hdr *)fw_data; + ver.all = be32_to_cpu(fw_f_hdr->ver); + + dev_info(dev, "ACA fw build %d branch %d major 0x%2x minor 0x%04x\n", + ver.field.build, ver.field.branch, + ver.field.major, ver.field.minor); + + type.all = be32_to_cpu(fw_f_hdr->type); + + if (type.field.img_type > (ACA_IMG_MAX - 1) + || ((type.field.soc_type & ACA_SOC_MASK) == 0)) { + dev_err(dev, "Invalid aca fw img %d soc %d\n", + type.field.img_type, type.field.soc_type); + ret = -EINVAL; + goto err; + } + + soc_type_to_str(type.field.soc_type); + + dev_info(priv->dev, "ACA fw for %s supported SoC type %s\n", + aca_img_type_str[type.field.img_type], soc_str); + + hdr_len = be32_to_cpu(fw_f_hdr->hdr_size); + /* Sanity Check */ + if (fw_len < hdr_len) { + dev_err(dev, "Invalid aca fw hdr len %zd fw len %zd\n", + hdr_len, fw_len); + ret = -EINVAL; + goto err; + } + dev_dbg(dev, "Header size 0x%08x fw size 0x%08x\n", + hdr_len, be32_to_cpu(fw_f_hdr->fw_size)); + dev_dbg(dev, "section number %d\n", + be32_to_cpu(fw_f_hdr->num_section)); + + aca_section_parse(priv, fw_data); + return 0; +err: + dc_aca_free_fw_file(priv); + return ret; +} + +static int aca_fetch_fw(struct dc_ep_priv *priv) +{ + return aca_fetch_fw_api(priv, ACA_FW_FILE); +} + +static int aca_fw_download(struct dc_ep_priv *priv) +{ + int i, j; + u32 val; + size_t size; + u32 id, load_addr; + const char *fw_base; + struct aca_fw_dl_addr *fw_dl = to_fw_addr(priv); + + for (i = 0; i < fw_dl->fw_num; i++) { + id = fw_dl->fw_addr[i].fw_id; + load_addr = fw_dl->fw_addr[i].fw_load_addr; + size = fw_dl->fw_addr[i].fw_size; + fw_base = fw_dl->fw_addr[i].fw_base; + + if (size % 4) { + dev_err(priv->dev, + "aca %s fw size is not a multiple of 4\n", + fw_id_to_str(id)); + return -EINVAL; + } + + for (j = 0; j < size; j += 4) { + val = *((u32 *)(fw_base + j)); + wr32(cpu_to_be32(val), load_addr + j); + } + /* Write flush */ + rd32(load_addr); + #ifdef DEBUG + { + u32 src, dst; + + for (j = 0; j < size; j += 4) { + dst = rd32(load_addr + j); + src = *((u32 *)(fw_base + j)); + if (dst != cpu_to_be32(src)) { + dev_info(priv->dev, + "dst 0x%08x != src 0x%08x\n", dst, src); + return -EIO; + } + } + } + #endif /* DEBUG */ + } + return 0; +} + +static void aca_dma_ctrl_init(struct dc_ep_priv *priv) +{ + u32 val; + struct dc_aca *aca = to_aca(priv); + + /* Global software reset CDMA */ + wr32_mask(0, BIT(CTRL_RST), ADMA_CTRL); + while ((rd32(ADMA_CTRL) & BIT(CTRL_RST))) + ; + + val = rd32(ADMA_ID); + /* Record max dma channels for later usage */ + aca->adma_chans = MS(val, ADMA_ID_CHNR); + val = rd32(ADMA_CTRL); + /* + * Enable Packet Arbitration + * Enable Meta data copy + * Enable Dedicated Descriptor port + */ + val |= BIT(CTRL_PKTARB) | BIT(CTRL_MDC) | BIT(CTRL_DSRAM); + set_mask_bit(val, 1, 1, CTRL_ENBE); /* Enable byte enable */ + set_mask_bit(val, 1, 1, CTRL_DCNF); /* 2DW descriptor format */ + set_mask_bit(val, 1, 1, CTRL_DDBR); /* Descriptor read back */ + set_mask_bit(val, 1, 1, CTRL_DRB); /* Dynamic burst read */ + wr32(val, ADMA_CTRL); + + /* Polling cnt cfg */ + wr32(ADMA_CPOLL_EN | SM(ADMA_DEFAULT_POLL, ADMA_CPOLL_CNT), + ADMA_CPOLL); +} + +static void aca_dma_port_init(struct dc_ep_priv *priv) +{ + u32 val; + + /* Only one port /port 0 */ + wr32(0, ADMA_PS); + val = rd32(ADMA_PCTRL); + set_mask_bit(val, 1, 1, PCTRL_RXBL16); + set_mask_bit(val, 1, 1, PCTRL_TXBL16); + set_mask_bit(val, 0, 3, PCTRL_RXBL); + set_mask_bit(val, 0, 3, PCTRL_TXBL); + + set_mask_bit(val, 0, 3, PCTRL_TXENDI); + set_mask_bit(val, 0, 3, PCTRL_RXENDI); + wr32(val, ADMA_PCTRL); +} + +static void aca_dma_ch_init(struct dc_ep_priv *priv, u32 cid, + u32 dbase, u32 dlen) +{ + /* Select channel */ + wr32(cid, ADMA_CS); + + /* Reset Channel */ + wr32_mask(0, BIT(CCTRL_RST), ADMA_CCTRL); + while ((rd32(ADMA_CCTRL) & BIT(CCTRL_RST))) + ; + + /* Set descriptor list base and length */ + wr32(dbase, ADMA_CDBA); + wr32(dlen, ADMA_CDLEN); + + /*Clear Intr */ + wr32(ADMA_CI_ALL, ADMA_CIS); + /* Enable Intr */ + wr32(ADMA_CI_ALL, ADMA_CIE); + + /* Enable Channel */ + wr32_mask(0, BIT(CCTRL_ONOFF), ADMA_CCTRL); + mb(); +} + +static void aca_dma_ch_off(struct dc_ep_priv *priv) +{ + int i; + struct dc_aca *aca = to_aca(priv); + + /* Shared between OS and ACA FW. Stop ACA first */ + for (i = 0; i < aca->adma_chans; i++) { + wr32(i, ADMA_CS); + wr32_mask(BIT(CCTRL_ONOFF), 0, ADMA_CCTRL); + while (rd32(ADMA_CCTRL) & BIT(CCTRL_ONOFF)) + ; + } + dev_dbg(priv->dev, "aca dma channel done\n"); +} + +static void aca_xbar_ia_reject_set(struct dc_ep_priv *priv, int ia_id) +{ + u32 val; + int timeout = 1000; + struct device *dev = priv->dev; + + /* Set reject bit */ + wr32(XBAR_CTRL_REJECT, ACA_AGENT_CTRL(ia_id)); + + /* Poll burst, readex, resp_waiting, req_active */ + val = XBAR_STAT_REQ_ACTIVE | XBAR_STAT_RESP_WAITING + | XBAR_STAT_BURST | XBAR_STAT_READEX; + while (--timeout && !!(rd32(ACA_AGENT_STATUS(ia_id)) & val)) + udelay(1); + + if (timeout <= 0) { + dev_dbg(dev, + "ACA XBAR IA: %d reset timeout, pending on 0x%x\n", + ia_id, rd32(ACA_AGENT_STATUS(ia_id))); + return; + } +} + +static void aca_xbar_ia_reject_clr(struct dc_ep_priv *priv, int ia_id) +{ + u32 val; + + /* Check reject bit */ + val = rd32(ACA_AGENT_CTRL(ia_id)); + if ((val & XBAR_CTRL_REJECT) == 0) + return; + + /* Clear reject bit */ + val &= ~XBAR_CTRL_REJECT; + wr32(val, ACA_AGENT_CTRL(ia_id)); + rd32(ACA_AGENT_CTRL(ia_id)); +} + +static void aca_xbar_ia_reset(struct dc_ep_priv *priv, int ia_id) +{ + /* ACA IA reset */ + wr32(XBAR_CTRL_CORE_RESET, ACA_AGENT_CTRL(ia_id)); + + /* Read till status become 1 */ + while ((rd32(ACA_AGENT_STATUS(ia_id)) & XBAR_STAT_CORE_RESET) == 0) + ; + + /* Clear the IA Reset signal */ + wr32(0, ACA_AGENT_CTRL(ia_id)); + + /* Read till status become 0 */ + while ((rd32(ACA_AGENT_STATUS(ia_id)) & XBAR_STAT_CORE_RESET) == 1) + ; + + dev_dbg(priv->dev, "ACA XBAR IA(%d) reset done\n", ia_id); +} + +void dc_aca_shutdown(struct dc_ep_priv *priv) +{ + struct dc_aca *aca = to_aca(priv); + + if (aca->initialized) { + aca_xbar_ia_reset(priv, ACA_ACC_IA04); + aca_xbar_ia_reset(priv, ACA_M_IA06); + } +} + +static void aca_dma_init(struct dc_ep_priv *priv) +{ + int i; + struct aca_fw_info *fw_info = to_fw_info(priv); + + aca_dma_ctrl_init(priv); + aca_dma_port_init(priv); + + for (i = 0; i < fw_info->chan_num; i++) { + aca_dma_ch_init(priv, i, + fw_info->adma_desc_base[i] | priv->phymem, + DESC_NUM_PER_CH); + } + + dev_dbg(priv->dev, "aca dma init done\n"); +} + +static void aca_basic_init(struct dc_ep_priv *priv) +{ + u32 addr, mask; + + /* Low 32 is RX, High 32 is TX */ + wr32(0x1, UMT_ORDER_CFG); + /* TXIN/TXOUT/RXIN/RXOUT All Controlled by Genrisc */ + wr32(0xF, HOST_TYPE); + /* Enable Host Gate CLK */ + wr32(0x4000, HT_GCLK_ENABLE); + /* Host Page/MASK */ + mask = ~priv->memsize + 1; + addr = mask | ((priv->phymem & mask) >> 16); + wr32(addr, AHB_ARB_HP_REG); + wr32(addr, OCP_ARB_ACC_PAGE_REG); + /* Stop all functions first */ + wr32(0, GNRC_EN_TASK_BITMAP); + + /* Enable XBAR */ + aca_xbar_ia_reject_clr(priv, ACA_ACC_IA04); + aca_xbar_ia_reject_clr(priv, ACA_M_IA06); + + dev_dbg(priv->dev, "aca basic config done\n"); +} + +static int aca_hif_param_init(struct dc_ep_priv *priv) +{ + struct dc_aca *aca = to_aca(priv); + + aca->hif_params = kzalloc(sizeof(struct aca_hif_params), GFP_KERNEL); + if (!aca->hif_params) + return -ENOMEM; + aca->hif_params->task_mask = 0x0000000F; + dev_dbg(priv->dev, "%s\n", __func__); + return 0; +} + +static void aca_hif_param_init_done(struct dc_ep_priv *priv) +{ + u32 addr; + struct aca_hif_params *hif_params = to_hif_params(priv); + struct aca_fw_param *fw_param = to_aca_fw_param(priv); + + /* wr32(ACA_HIF_PARAM_ADDR, ACA_HIF_LOC_POS);*/ + /* addr = rd32(ACA_HIF_LOC_POS);*/ + + addr = fw_param->init_addr; + dev_dbg(priv->dev, "init_addr: %x\n", addr); + memcpy_toio(priv->mem + addr, hif_params, sizeof(*hif_params)); + kzfree(hif_params); + dev_dbg(priv->dev, "%s\n", __func__); +} + +static bool aca_hif_param_init_check(struct dc_ep_priv *priv) +{ + u32 addr; + int timeout = ACA_LOOP_CNT; + u32 offset = offsetof(struct aca_hif_params, magic); + struct aca_fw_param *fw_param = to_aca_fw_param(priv); + + /* addr = rd32(ACA_HIF_LOC_POS);*/ + addr = fw_param->init_addr; + while (--timeout && (rd32(addr + offset) != ACA_MAGIC)) + udelay(1); + + if (timeout <= 0) { + dev_err(priv->dev, "aca hif params init failed\n"); + return false; + } + + return true; +} + +static void aca_txin_init(struct dc_ep_priv *priv, + struct aca_cfg_param *aca_txin) +{ + u32 val = 0; + struct aca_mem_layout *mem_layout = to_mem_layout(priv); + struct aca_hif_params *hif_params = to_hif_params(priv); + struct aca_hif_param *txin_param = &hif_params->txin; + + if (aca_txin->byteswap) + val = BYTE_SWAP_EN; + + val |= (aca_txin->hd_size_in_dw - 1) + | SM((aca_txin->pd_size_in_dw - 1), PD_DESC_IN_DW); + wr32(val, TXIN_CONV_CFG); + + /* SoC cumulative counter address */ + wr32(aca_txin->soc_cmlt_cnt_addr, GNRC_TXIN_CMLT_CNT_ADDR); + + + /* SoC descriptors */ + txin_param->soc_desc_base = aca_txin->soc_desc_base; + txin_param->soc_desc_num = aca_txin->soc_desc_num; + + /* Ping/pong buffer */ + txin_param->pp_buf_base = priv->phymem + + mem_layout->txin_host_desc_base; + + txin_param->pp_buf_num = mem_layout->txin_host_dnum; + + /* PD ring */ + txin_param->pd_desc_base = priv->phymem + + aca_txin->pd_desc_base; + txin_param->pd_desc_num = aca_txin->pd_desc_num; + + dev_dbg(priv->dev, "aca txin init done\n"); +} + +static void aca_txout_init(struct dc_ep_priv *priv, + struct aca_cfg_param *aca_txout) +{ + u32 val = 0; + struct aca_mem_layout *mem_layout = to_mem_layout(priv); + struct aca_hif_params *hif_params = to_hif_params(priv); + struct aca_hif_param *txout_param = &hif_params->txout; + + if (aca_txout->byteswap) + val = BYTE_SWAP_EN; + + val |= (aca_txout->hd_size_in_dw - 1) + | SM((aca_txout->pd_size_in_dw - 1), PD_DESC_IN_DW); + wr32(val, TXOUT_CONV_CFG); + + /* SoC Ring size */ + val = aca_txout->soc_desc_num; + wr32(val, TXOUT_RING_CFG); + + /* SoC cumulative counter address */ + wr32(aca_txout->soc_cmlt_cnt_addr, GNRC_TXOUT_CMLT_CNT_ADDR); + /* SoC descriptors */ + txout_param->soc_desc_base = aca_txout->soc_desc_base; + txout_param->soc_desc_num = aca_txout->soc_desc_num; + + /* Ping/pong buffer */ + txout_param->pp_buf_base = priv->phymem + +mem_layout->txout_host_desc_base; + + txout_param->pp_buf_num = mem_layout->txout_host_dnum; + + /* PD ring */ + txout_param->pd_desc_base = priv->phymem + + aca_txout->pd_desc_base; + txout_param->pd_desc_num = aca_txout->pd_desc_num; + + txout_param->pd_desc_threshold = aca_txout->pp_buf_desc_num; + + dev_dbg(priv->dev, "aca txout init done\n"); +} + +static void aca_rxin_init(struct dc_ep_priv *priv, + struct aca_cfg_param *aca_rxin) +{ + u32 val = 0; + struct aca_mem_layout *mem_layout = to_mem_layout(priv); + struct aca_hif_params *hif_params = to_hif_params(priv); + struct aca_hif_param *rxin_param = &hif_params->rxin; + + if (aca_rxin->byteswap) + val = BYTE_SWAP_EN; + + val |= (aca_rxin->hd_size_in_dw - 1) + | SM((aca_rxin->pd_size_in_dw - 1), PD_DESC_IN_DW); + wr32(val, RXIN_CONV_CFG); + + /* SoC cumulative counter address */ + wr32(aca_rxin->soc_cmlt_cnt_addr, GNRC_RXIN_CMLT_CNT_ADDR); + + /* RXIN may not be used */ + if (!(aca_rxin->soc_desc_base)) + goto __RXIN_DONE; + /* SoC descriptors */ + rxin_param->soc_desc_base = aca_rxin->soc_desc_base; + rxin_param->soc_desc_num = aca_rxin->soc_desc_num; + + /* Ping/pong buffer */ + rxin_param->pp_buf_base = (u32)priv->phymem + + mem_layout->rxin_host_desc_base; + + rxin_param->pp_buf_num = mem_layout->rxin_host_dnum; + + /* PD ring */ + rxin_param->pd_desc_base = (u32)priv->phymem + + aca_rxin->pd_desc_base; + rxin_param->pd_desc_num = aca_rxin->pd_desc_num; + + rxin_param->pd_desc_threshold = aca_rxin->pp_buf_desc_num; + +__RXIN_DONE: + dev_dbg(priv->dev, "aca rxin init done\n"); +} + +static void aca_rxout_init(struct dc_ep_priv *priv, + struct aca_cfg_param *aca_rxout) +{ + u32 val = 0; + struct aca_mem_layout *mem_layout = to_mem_layout(priv); + struct aca_hif_params *hif_params = to_hif_params(priv); + struct aca_hif_param *rxout_param = &hif_params->rxout; + + if (aca_rxout->byteswap) + val = BYTE_SWAP_EN; + + val |= (aca_rxout->hd_size_in_dw - 1) + | SM((aca_rxout->pd_size_in_dw - 1), PD_DESC_IN_DW); + wr32(val, RXOUT_CONV_CFG); + + /* SoC Ring size */ + val = aca_rxout->soc_desc_num; + wr32(val, RXOUT_RING_CFG); + + /* SoC cumulative counter address */ + wr32(aca_rxout->soc_cmlt_cnt_addr, GNRC_RXOUT_CMLT_CNT_ADDR); + /* SoC descriptors */ + rxout_param->soc_desc_base = aca_rxout->soc_desc_base; + rxout_param->soc_desc_num = aca_rxout->soc_desc_num; + + /* Ping/pong buffer */ + rxout_param->pp_buf_base = (u32)priv->phymem + + mem_layout->rxout_host_desc_base; + + rxout_param->pp_buf_num = mem_layout->rxout_host_dnum; + + /* PD ring */ + rxout_param->pd_desc_base = (u32)priv->phymem + + aca_rxout->pd_desc_base; + rxout_param->pd_desc_num = aca_rxout->pd_desc_num; + + rxout_param->pd_desc_threshold = aca_rxout->pp_buf_desc_num; + dev_dbg(priv->dev, "aca rxout init done\n"); +} + +static void aca_mdm_init(struct dc_ep_priv *priv, struct aca_modem_param *mdm) +{ + struct aca_proj_param *param; + + if (!mdm) + return; + + param = &mdm->mdm_txout; + wr32(param->stat | priv->phymem, GNRC_TXOUT_TGT_STAT); + wr32(param->pd | priv->phymem, GNRC_TXOUT_TGT_PD_OFF); + wr32(param->acc_cnt | priv->phymem, GNRC_TXOUT_TGT_ACCM_CNT); + + param = &mdm->mdm_rxin; + wr32(param->stat | priv->phymem, GNRC_RXIN_TGT_STAT); + wr32(param->pd | priv->phymem, GNRC_RXIN_TGT_PD_OFF); + wr32(param->acc_cnt | priv->phymem, GNRC_RXIN_TGT_ACCM_CNT); + + param = &mdm->mdm_rxout; + wr32(param->stat | priv->phymem, GNRC_RXOUT_TGT_STAT); + wr32(param->pd | priv->phymem, GNRC_RXOUT_TGT_PD_OFF); + wr32(param->acc_cnt | priv->phymem, GNRC_RXOUT_TGT_ACCM_CNT); + dev_dbg(priv->dev, "aca mdm init done\n"); +} + +static void dc_aca_clk_on(struct dc_ep_priv *priv) +{ + dc_ep_clk_on(priv, PMU_ADMA); +} + +static void dc_aca_clk_off(struct dc_ep_priv *priv) +{ + dc_ep_clk_off(priv, PMU_ADMA); +} + +static void dc_aca_reset(struct dc_ep_priv *priv) +{ + dc_ep_reset_device(priv, RST_ACA_DMA | RST_ACA_HOSTIF); +} + +static void aca_mem_clear(struct dc_ep_priv *priv) +{ + struct aca_fw_dl_addr *fw_dl = to_fw_addr(priv); + + memset_io(priv->mem + fw_dl->fw_addr[0].fw_load_addr, + 0, ACA_ACC_FW_SIZE); + memset_io(priv->mem + ACA_SRAM_BASE, 0, ACA_SRAM_SIZE); +} + +int dc_aca_start(struct dc_ep_priv *priv, u32 func, int start) +{ + if (!func) + return -EINVAL; + + wr32_mask(0, func, GNRC_EN_TASK_BITMAP); + + /* Only do if requested by caller */ + if (start) { + wr32(0x1, GNRC_START_OP); /* Any write will trigger */ + rd32(GNRC_START_OP); + if (!aca_hif_param_init_check(priv)) + return -EIO; + } + return 0; +} + +static void aca_sw_reset(struct dc_ep_priv *priv) +{ + u32 val = SW_RST_GENRISC | SW_RST_HOSTIF_REG | SW_RST_RXIN + | SW_RST_RXOUT | SW_RST_TXIN | SW_RST_TXOUT; + + wr32(val, HT_SW_RST_ASSRT); + udelay(1); + wr32(val, HT_SW_RST_RELEASE); + wmb(); +} + +int dc_aca_stop(struct dc_ep_priv *priv, u32 *func, int reset) +{ + u32 val = *func; + u32 reg; + + if (!val) + return 0; + + *func = 0; + + /* Only do it if reset is required. Otherwise, pending is fine */ + if (reset) { + if (val & ACA_TXIN_EN) { + reg = rd32(TXIN_COUNTERS); + if (MS(reg, ACA_PENDING_JOB) + || (MS(reg, ACA_AVAIL_BUF) != ACA_PP_BUFS)) { + *func = ACA_TXIN_EN; + return -EBUSY; + } + } + + if (val & ACA_TXOUT_EN) { + reg = rd32(TXOUT_COUNTERS); + if (MS(reg, ACA_PENDING_JOB) + || (MS(reg, ACA_AVAIL_BUF) != ACA_PP_BUFS)) { + *func = ACA_TXOUT_EN; + return -EBUSY; + } + } + + + if (val & ACA_RXIN_EN) { + reg = rd32(RXIN_COUNTERS); + if (MS(reg, ACA_PENDING_JOB) + || (MS(reg, ACA_AVAIL_BUF) != ACA_PP_BUFS)) { + *func = ACA_RXIN_EN; + return -EBUSY; + } + } + + if (val & ACA_RXOUT_EN) { + reg = rd32(RXOUT_COUNTERS); + if (MS(reg, ACA_PENDING_JOB) + || (MS(reg, ACA_AVAIL_BUF) != ACA_PP_BUFS)) { + *func = ACA_RXOUT_EN; + return -EBUSY; + } + } + } + + wr32_mask(val, 0, GNRC_EN_TASK_BITMAP); + + if (reset) { + aca_dma_ch_off(priv); + aca_xbar_ia_reject_set(priv, ACA_ACC_IA04); + aca_xbar_ia_reject_set(priv, ACA_M_IA06); + aca_sw_reset(priv); + } + return 0; +} + +#ifdef CONFIG_SOC_TYPE_XWAY +static void aca_grx330_init(struct dc_ep_priv *priv) +{ + wr32(0x0044001E, TXIN_CFG1); + wr32(0x0040041F, TXIN_CFG2); + wr32(0x007FE020, TXIN_CFG3); + + wr32(0x0044001F, TXOUT_CFG1); + wr32(0x0040041F, TXOUT_CFG2); + wr32(0x007BE020, TXOUT_CFG3); + + wr32(0x0044001F, RXOUT_CFG1); + wr32(0x0040041F, RXOUT_CFG2); + wr32(0x007BE020, RXOUT_CFG3); + + wr32(0x0044001E, RXIN_CFG1); + wr32(0x0040041F, RXIN_CFG2); + wr32(0x007FE020, RXIN_CFG3); + + wr32(0x1, TXIN_DST_OWWBIT_CFG4); + wr32(0x1, TXOUT_DST_OWWBIT_CFG4); + wr32(0x1, RXOUT_SRC_OWNBIT_CFG3); + wr32(0x1, RXIN_SRC_OWNBIT_CFG3); + + wr32(0x0, GNRC_TXIN_BUF_PREFILL); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x4); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x8); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0xc); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x10); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x14); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x18); + wr32(0x0, GNRC_TXIN_BUF_PREFILL + 0x1c); +} +#endif + +int dc_aca_init(struct dc_ep_priv *priv, struct aca_param *param, + struct aca_modem_param *mdm) +{ + int ret; + struct dc_aca *aca = to_aca(priv); + + dc_aca_clk_on(priv); + dc_aca_reset(priv); + + ret = aca_fetch_fw(priv); + if (ret) { + dev_err(priv->dev, + "could not fetch firmware files %d\n", ret); + dc_aca_clk_off(priv); + return ret; + } + + aca_mem_clear(priv); + aca_dma_init(priv); + aca_basic_init(priv); + aca_fw_download(priv); + aca_hif_param_init(priv); + aca_txin_init(priv, ¶m->aca_txin); + aca_txout_init(priv, ¶m->aca_txout); + aca_rxout_init(priv, ¶m->aca_rxout); + aca_rxin_init(priv, ¶m->aca_rxin); + aca_hif_param_init_done(priv); + aca_mdm_init(priv, mdm); +#ifdef CONFIG_SOC_TYPE_XWAY + aca_grx330_init(priv); +#endif + aca->initialized = true; + dev_info(priv->dev, "aca init done\n"); + return 0; +} + +static int aca_max_gpio(struct dc_ep_priv *priv) +{ + return fls(rd32(PADC_AVAIL)); +} + +void dc_aca_info_init(struct dc_ep_priv *priv) +{ + struct dc_aca *aca = to_aca(priv); + + aca->initialized = false; + spin_lock_init(&aca->clk_lock); + spin_lock_init(&aca->rcu_lock); + mutex_init(&aca->pin_lock); + aca->max_gpio = aca_max_gpio(priv); +} + +#define ACA_ENDIAN_ADDR(addr, endian) \ +{ \ + if (endian == ACA_BIG_ENDIAN) \ + return addr##_BE; \ + else \ + return addr; \ +} + +u32 aca_umt_msg_addr(struct dc_ep_priv *priv, u32 endian, u32 type) +{ + switch (type) { + case ACA_TXIN: + ACA_ENDIAN_ADDR(TXIN_HD_ACCUM_ADD, endian); + case ACA_RXIN: + ACA_ENDIAN_ADDR(RXIN_HD_ACCUM_ADD, endian); + case ACA_TXOUT: + ACA_ENDIAN_ADDR(TXOUT_HD_ACCUM_SUB, endian); + case ACA_RXOUT: + ACA_ENDIAN_ADDR(RXOUT_HD_ACCUM_SUB, endian); + default: + ACA_ENDIAN_ADDR(RXIN_HD_ACCUM_ADD, endian); + }; +} + +void dc_aca_event_addr_get(struct dc_ep_priv *priv, + struct aca_event_reg_addr *regs) +{ + regs->txin_acc_sub = TXIN_ACA_ACCUM_SUB; + regs->txout_acc_add = TXOUT_ACA_ACCUM_ADD; + regs->rxin_acc_sub = RXIN_ACA_ACCUM_SUB; + regs->rxout_acc_add = RXOUT_ACA_ACCUM_ADD; +} + +void dc_aca_txin_sub_ack(struct dc_ep_priv *priv, u32 val) +{ + wr32(val, TXIN_ACA_ACCUM_SUB); +} + +u32 dc_aca_txin_hd_cnt(struct dc_ep_priv *priv) +{ + return rd32(TXIN_ACA_HD_ACC_CNT); +} + diff --git a/package/kernel/lantiq/vrx518_ep/src/aca.h b/package/kernel/lantiq/vrx518_ep/src/aca.h new file mode 100644 index 00000000000..10f2ecb4c16 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/aca.h @@ -0,0 +1,481 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef ACA_H +#define ACA_H + +#define HOST_IF_BASE 0x50000 +#define ACA_CORE_BASE 0x50800 +#define GENRISC_IRAM_BASE 0x58000 +#define GENRISC_SPRAM_BASE 0x5C000 +#define GENRISC_BASE 0x5D000 +#define MAC_HT_EXT_BASE 0x5D400 +#define ACA_SRAM_BASE 0x100000 +#define ACA_SRAM_SIZE 0x2000 /* Project specific */ +#define ACA_HOSTIF_ADDR_SHIFT 2 + +#define ACA_HOSTIF_ADDR(addr) ((addr) >> ACA_HOSTIF_ADDR_SHIFT) + +#define ACA_HIF_LOC_POS 0x100060 +#define ACA_HIF_PARAM_ADDR 0x100064 +#define ACA_ACC_FW_SIZE 0x400 +#define ACA_LOOP_CNT 1000 + +/* TODO: change name after karthik explained */ +#define TXIN_DST_OWNBIT 0xC4 +#define TXOUT_DST_OWNBIT 0x1C4 +#define RXOUT_SRC_OWNBIT 0x3C4 +#define RXIN_DST_OWNBIT 0x2C4 + +/* Genrisc Internal Host Descriptor(Ping/Pong) decided by ACA fw header */ +/* ACA Core */ +#define ACA_CORE_REG(X) (ACA_CORE_BASE + (X)) +#define TXIN_CFG1 ACA_CORE_REG(0x0) +#define TXIN_CFG2 ACA_CORE_REG(0x4) +#define TXIN_CFG3 ACA_CORE_REG(0x8) +#define TXIN_DST_OWWBIT_CFG4 ACA_CORE_REG(TXIN_DST_OWNBIT) + +#define TXOUT_CFG1 ACA_CORE_REG(0x100) +#define TXOUT_CFG2 ACA_CORE_REG(0x104) +#define TXOUT_CFG3 ACA_CORE_REG(0x108) +#define TXOUT_DST_OWWBIT_CFG4 ACA_CORE_REG(TXOUT_DST_OWNBIT) + +#define RXOUT_CFG1 ACA_CORE_REG(0x300) +#define RXOUT_CFG2 ACA_CORE_REG(0x304) +#define RXOUT_CFG3 ACA_CORE_REG(0x308) +#define RXOUT_SRC_OWNBIT_CFG3 ACA_CORE_REG(RXOUT_SRC_OWNBIT) + +#define RXIN_CFG1 ACA_CORE_REG(0x200) +#define RXIN_CFG2 ACA_CORE_REG(0x204) +#define RXIN_CFG3 ACA_CORE_REG(0x208) +#define RXIN_SRC_OWNBIT_CFG3 ACA_CORE_REG(RXIN_DST_OWNBIT) + +/* Genrisc */ +#define GNRC_REG(X) (GENRISC_BASE + (X)) +#define GNRC_STOP_OP GNRC_REG(0x60) +#define GNRC_CONTINUE_OP GNRC_REG(0x64) +#define GNRC_START_OP GNRC_REG(0x90) + +/* HOST Interface Register */ +#define HOST_IF_REG(X) (HOST_IF_BASE + (X)) +#define HD_DESC_IN_DW 0x7u +#define HD_DESC_IN_DW_S 0 +#define PD_DESC_IN_DW 0x70u +#define PD_DESC_IN_DW_S 4 +#define BYTE_SWAP_EN BIT(28) + +#define TXIN_CONV_CFG HOST_IF_REG(0x14) +#define TXOUT_CONV_CFG HOST_IF_REG(0x18) +#define RXIN_CONV_CFG HOST_IF_REG(0x1C) +#define RXOUT_CONV_CFG HOST_IF_REG(0x20) + +#define TXIN_COUNTERS HOST_IF_REG(0x44) +#define TXOUT_COUNTERS HOST_IF_REG(0x48) +#define RXIN_COUNTERS HOST_IF_REG(0x4c) +#define RXOUT_COUNTERS HOST_IF_REG(0x50) + +#define TXOUT_RING_CFG HOST_IF_REG(0x98) +#define RXOUT_RING_CFG HOST_IF_REG(0x9C) + +#define ACA_PENDING_JOB 0x00000300 +#define ACA_PENDING_JOB_S 8 +#define ACA_AVAIL_BUF 0x00030000 +#define ACA_AVAIL_BUF_S 16 +#define ACA_PP_BUFS 2 + +#define HOST_TYPE HOST_IF_REG(0xA0) +#define TXOUT_COUNTERS_UPDATE HOST_IF_REG(0xAC) +#define RXOUT_COUNTERS_UPDATE HOST_IF_REG(0xB4) +#define RXIN_HD_ACCUM_ADD HOST_IF_REG(0xC8) /* UMT Message trigger */ +#define TXIN_HD_ACCUM_ADD HOST_IF_REG(0xCC) /* UMT Message trigger */ +#define RXOUT_HD_ACCUM_ADD HOST_IF_REG(0xD0) +#define TXOUT_HD_ACCUM_ADD HOST_IF_REG(0xD4) +#define RXOUT_ACA_ACCUM_ADD HOST_IF_REG(0xE0) /* PPE FW tigger */ +#define TXOUT_ACA_ACCUM_ADD HOST_IF_REG(0xE4) /* PPE FW tigger */ +#define RXOUT_HD_ACCUM_SUB HOST_IF_REG(0xF8) +#define TXOUT_HD_ACCUM_SUB HOST_IF_REG(0xFC) +#define RXIN_ACA_ACCUM_SUB HOST_IF_REG(0x100) +#define TXIN_ACA_ACCUM_SUB HOST_IF_REG(0x104) +#define TXIN_ACA_HD_ACC_CNT HOST_IF_REG(0x11C) +#define UMT_ORDER_CFG HOST_IF_REG(0x234) +#define RXIN_HD_ACCUM_ADD_BE HOST_IF_REG(0x250) +#define TXIN_HD_ACCUM_ADD_BE HOST_IF_REG(0x254) +#define RXOUT_HD_ACCUM_SUB_BE HOST_IF_REG(0x268) +#define TXOUT_HD_ACCUM_SUB_BE HOST_IF_REG(0x26c) + +/* MAC_HT_EXTENSION Register */ +#define MAC_HT_EXT_REG(X) (MAC_HT_EXT_BASE + (X)) + +#define HT_GCLK_ENABLE MAC_HT_EXT_REG(0) +#define HT_SW_RST_RELEASE MAC_HT_EXT_REG(0x4) +#define HT_SW_RST_ASSRT MAC_HT_EXT_REG(0x1C) +#define SW_RST_GENRISC BIT(14) +#define SW_RST_RXOUT BIT(26) +#define SW_RST_RXIN BIT(27) +#define SW_RST_TXOUT BIT(28) +#define SW_RST_TXIN BIT(29) +#define SW_RST_HOSTIF_REG BIT(30) +#define OCP_ARB_ACC_PAGE_REG MAC_HT_EXT_REG(0x1C4) +#define AHB_ARB_HP_REG MAC_HT_EXT_REG(0x1C8) + +/* Genrisc FW Configuration */ +#define GNRC_SPRAM_REG(X) (GENRISC_SPRAM_BASE + (X)) + +/* TX IN */ +#define GNRC_TXIN_TGT_STAT GNRC_SPRAM_REG(0x04) +#define GNRC_TXIN_TGT_PD_OFF GNRC_SPRAM_REG(0x08) +#define GNRC_TXIN_TGT_ACCM_CNT GNRC_SPRAM_REG(0x0C) + +/* TX OUT */ +#define GNRC_TXOUT_TGT_STAT GNRC_SPRAM_REG(0x10) +#define GNRC_TXOUT_TGT_PD_OFF GNRC_SPRAM_REG(0x14) +#define GNRC_TXOUT_TGT_ACCM_CNT GNRC_SPRAM_REG(0x18) + +/* RX IN */ +#define GNRC_RXIN_TGT_STAT GNRC_SPRAM_REG(0x1C) +#define GNRC_RXIN_TGT_PD_OFF GNRC_SPRAM_REG(0x20) +#define GNRC_RXIN_TGT_ACCM_CNT GNRC_SPRAM_REG(0x24) + +/* RX OUT XXX not consistent */ +#define GNRC_RXOUT_TGT_STAT GNRC_SPRAM_REG(0x28) +#define GNRC_RXOUT_TGT_PD_OFF GNRC_SPRAM_REG(0x2C) +#define GNRC_RXOUT_TGT_ACCM_CNT GNRC_SPRAM_REG(0x30) + +/* 4 Ring 8 UMT case SoC cumulative counter address configuration */ +#define GNRC_TXIN_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x34) +#define GNRC_TXOUT_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x38) +#define GNRC_RXOUT_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x3C) +#define GNRC_RXIN_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x40) + + +#define GNRC_SOURCE_TXIN_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x54) +#define GNRC_SOURCE_TXOUT_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x58) +#define GNRC_SOURCE_RXOUT_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x5c) +#define GNRC_SOURCE_RXIN_CMLT_CNT_ADDR GNRC_SPRAM_REG(0x60) + +/* Txin index prefill */ +#define GNRC_TXIN_BUF_PREFILL GNRC_SPRAM_REG(0x44) +/* Task enable bitmap */ +#define GNRC_EN_TASK_BITMAP GNRC_SPRAM_REG(0x64) + +#define ACA_SRAM_REG(X) (ACA_SRAM_BASE + (X)) +#define ACA_TXOUT_PING_BUFFER_START ACA_SRAM_REG(0x1528) + + +/* XBAR SSX0 */ +#define ACA_SSX0_BASE 0x180000 +#define ACA_SSX0_IA_BASE(id) (ACA_SSX0_BASE + (((id) - 1) << 10)) +#define ACA_AGENT_CTRL(id) (ACA_SSX0_IA_BASE(id) + 0x20) +#define ACA_AGENT_STATUS(id) (ACA_SSX0_IA_BASE(id) + 0x28) + +#define XBAR_CTRL_CORE_RESET BIT(0) +#define XBAR_CTRL_REJECT BIT(4) + +#define XBAR_STAT_CORE_RESET BIT(0) +#define XBAR_STAT_REQ_ACTIVE BIT(4) +#define XBAR_STAT_RESP_WAITING BIT(5) +#define XBAR_STAT_BURST BIT(6) +#define XBAR_STAT_READEX BIT(7) + +enum { + ACA_ACC_IA04 = 4, + ACA_M_IA06 = 6, +}; + +/* Should be passed from ACA FW header */ +#define DESC_NUM_PER_CH 1 + +/* ACA DMA REG */ +#define ACA_DMA_BASE 0x60000 + +#define ACA_DMA_REG(X) (ACA_DMA_BASE + (X)) +#define ADMA_CLC ACA_DMA_REG(0x0) +#define ADMA_ID ACA_DMA_REG(0x8) +#define ADMA_CTRL ACA_DMA_REG(0x10) +#define ADMA_CPOLL ACA_DMA_REG(0x14) + +#define ADMA_ID_REV 0x1Fu +#define ADMA_ID_REV_S 0 +#define ADMA_ID_ID 0xFF00u +#define ADMA_ID_ID_S 8 +#define ADMA_ID_PRTNR 0xF0000u +#define ADMA_ID_PRTNR_S 16 +#define ADMA_ID_CHNR 0x7F00000u +#define ADMA_ID_CHNR_S 20 + +#define ADMA_CPOLL_EN BIT(31) + +#define ADMA_CPOLL_CNT 0xFFF0u +#define ADMA_CPOLL_CNT_S 4 +#define ADMA_DEFAULT_POLL 24 +#define ADMA_CS ACA_DMA_REG(0x18) +#define ADMA_CCTRL ACA_DMA_REG(0x1C) +#define ADMA_CDBA ACA_DMA_REG(0x20) +#define ADMA_CDLEN ACA_DMA_REG(0x24) +#define ADMA_CIS ACA_DMA_REG(0x28) +#define ADMA_CIE ACA_DMA_REG(0x2C) + +#define ADMA_CI_EOP BIT(1) +#define ADMA_CI_DUR BIT(2) +#define ADMA_CI_DESCPT BIT(3) +#define ADMA_CI_CHOFF BIT(4) +#define ADMA_CI_RDERR BIT(5) +#define ADMA_CI_ALL (ADMA_CI_EOP | ADMA_CI_DUR | ADMA_CI_DESCPT\ + | ADMA_CI_CHOFF | ADMA_CI_RDERR) + +#define ADMA_CDPTNRD ACA_DMA_REG(0x34) +#define ADMA_PS ACA_DMA_REG(0x40) +#define ADMA_PCTRL ACA_DMA_REG(0x44) + +/* DMA CCTRL BIT */ +#define CCTRL_RST 1 /* Channel Reset */ +#define CCTRL_ONOFF 0 /* Channel On/Off */ + +/* DMA CTRL BIT */ +#define CTRL_PKTARB 31 /* Packet Arbitration */ +#define CTRL_MDC 15 /* Meta data copy */ +#define CTRL_DDBR 14 /* Dynamic Burst */ +#define CTRL_DCNF 13 /* Descriptor Length CFG*/ +#define CTRL_ENBE 9 /* Byte Enable */ +#define CTRL_DRB 8 /* Descriptor read back */ +#define CTRL_DSRAM 1 /* Dedicated Descriptor Access port Enable */ +#define CTRL_RST 0 /* Global Reset */ + +/* DMA PORT BIT */ +#define PCTRL_FLUSH 16 +#define PCTRL_TXENDI 10 /* TX DIR Endianess */ +#define PCTRL_RXENDI 8 /* RX DIR Endianess */ +#define PCTRL_TXBL 4 /* TX burst 2/4/8 */ +#define PCTRL_RXBL 2 /* RX burst 2/4/8 */ +#define PCTRL_TXBL16 1 /* TX burst of 16 */ +#define PCTRL_RXBL16 0 /* RX burst of 16 */ + +/*DMA ID BIT */ +#define ID_CHNR 20 /* Channel Number */ + +/*DMA POLLING BIT */ +#define POLL_EN 31 /* Polling Enable */ +#define POLL_CNT 4 /* Polling Counter */ + +#define ACA_DMA_CHAN_MAX 12 + +enum aca_sec_id { + ACA_SEC_HIF = 0x1, + ACA_SEC_GNR = 0x2, + ACA_SEC_MAC_HT = 0x3, + ACA_SEC_MEM_TXIN = 0x4, + ACA_SEC_MEM_TXIN_PDRING = 0x5, + ACA_SEC_MEM_TXOUT = 0x6, + ACA_SEC_MEM_TXOUT_PDRING = 0x7, + ACA_SEC_MEM_RXOUT = 0x8, + ACA_SEC_MEM_RXOUT_PDRING = 0x9, + ACA_SEC_MEM_RXIN = 0xa, + ACA_SEC_MEM_RXIN_PDRING = 0xb, + ACA_SEC_DMA = 0xc, + ACA_SEC_FW_INIT = 0xd, + ACA_SEC_FW = 0x88, +}; + +enum aca_fw_id { + ACA_FW_TXIN = 1, + ACA_FW_TXOUT = 2, + ACA_FW_RXIN = 3, + ACA_FW_RXOUT = 4, + ACA_FW_GNRC = 5, + ACA_FW_MAX = 5, +}; + +enum aca_img_type { + ACA_VRX518_IMG, + ACA_VRX618_IMG, + ACA_FALCON_IMG, + ACA_PUMA_IMG, + ACA_IMG_MAX, +}; + +enum aca_soc_type { + ACA_SOC_XRX300 = 1, + ACA_SOC_XRX500 = 2, + ACA_SOC_PUMA = 4, + ACA_SOC_3RD_PARTY = 8, +}; + +#define ACA_SOC_MASK 0xf + +/* Common information element, len has different variants */ +struct aca_fw_ie { + __be32 id; + __be32 len; +} __packed; + +struct aca_fw_reg { + __be32 offset; + __be32 value; +} __packed; + +struct aca_sram_desc { + __be32 dnum; + __be32 dbase; +} __packed; + +struct aca_fw_dma { + __be32 cid; + __be32 base; +} __packed; + +/* ACA internal header part */ +struct aca_int_hdr { + __be32 id; + __be32 offset; + __be32 size; + __be32 load_addr; +} __packed; + +struct aca_fw_param { + __be32 st_sz; + __be32 init_addr; +} __packed; + +struct aca_mem_layout { + u32 txin_host_desc_base; + u32 txin_host_dnum; + u32 txout_host_desc_base; + u32 txout_host_dnum; + u32 rxin_host_desc_base; + u32 rxin_host_dnum; + u32 rxout_host_desc_base; + u32 rxout_host_dnum; +}; + +struct aca_pdmem_layout { + u32 txin_pd_desc_base; + u32 txin_pd_dnum; + u32 txout_pd_desc_base; + u32 txout_pd_dnum; + u32 rxin_pd_desc_base; + u32 rxin_pd_dnum; + u32 rxout_pd_desc_base; + u32 rxout_pd_dnum; +}; + +struct aca_fw_addr_tuple { + u32 fw_id; + u32 fw_load_addr; + size_t fw_size; + const char *fw_base; +}; + +struct aca_fw_dl_addr { + u32 fw_num; + struct aca_fw_addr_tuple fw_addr[ACA_FW_MAX]; +}; + +struct aca_fw_info { + const struct firmware *fw; + const void *fw_data; + size_t fw_len; + struct aca_mem_layout mem_layout; + struct aca_pdmem_layout pdmem_layout; + struct aca_fw_param fw_param; + struct aca_fw_dl_addr fw_dl; + u32 chan_num; + u32 adma_desc_base[ACA_DMA_CHAN_MAX]; +}; + +union fw_ver { +#ifdef CONFIG_CPU_BIG_ENDIAN + struct { + u32 build:4; + u32 branch:4; + u32 major:8; + u32 minor:16; + } __packed field; +#else + struct { + u32 minor:16; + u32 major:8; + u32 branch:4; + u32 build:4; + } __packed field; +#endif /* CONFIG_CPU_BIG_ENDIAN */ + u32 all; +} __packed; + +union img_soc_type { +#ifdef CONFIG_CPU_BIG_ENDIAN + struct { + u32 img_type:16; + u32 soc_type:16; + } __packed field; +#else + struct { + u32 soc_type:16; + u32 img_type:16; + } __packed field; +#endif /* CONFIG_CPU_BIG_ENDIAN */ + u32 all; +} __packed; + +/* Fixed header part */ +struct aca_fw_f_hdr { + __be32 ver; + __be32 type; + __be32 hdr_size; + __be32 fw_size; + __be32 num_section; +} __packed; + +struct aca_hif_param { + u32 soc_desc_base; + u32 soc_desc_num; + u32 pp_buf_base; + u32 pp_buf_num; + u32 pd_desc_base; + u32 pd_desc_num; + u32 pd_desc_threshold; +} __packed; + +struct aca_hif_params { + u32 task_mask; + struct aca_hif_param txin; + struct aca_hif_param txout; + struct aca_hif_param rxin; + struct aca_hif_param rxout; + u32 dbg_base; + u32 dbg_size; + u32 magic; +} __packed; + +#define ACA_MAGIC 0x25062016 + +struct dc_aca { + bool initialized; + spinlock_t clk_lock; + spinlock_t rcu_lock; + struct mutex pin_lock; + struct aca_fw_info fw_info; + struct aca_hif_params *hif_params; + u32 max_gpio; + u32 adma_chans; +}; +#endif /* ACA_H */ diff --git a/package/kernel/lantiq/vrx518_ep/src/ep.c b/package/kernel/lantiq/vrx518_ep/src/ep.c new file mode 100644 index 00000000000..40fc9d36299 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/ep.c @@ -0,0 +1,770 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include <linux/module.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/atomic.h> +#include <linux/log2.h> +#include <linux/uaccess.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/pci.h> +#include <linux/pci_regs.h> +#include <linux/platform_device.h> + +#include "ep.h" +#include "aca.h" +#include "misc.h" + +#define DC_EP_DBG + +#define MAJ 2 +#define MIN 1 +#define BUILD 0 +#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \ + __stringify(BUILD) "-k" + +static bool pcie_switch_exist; +module_param(pcie_switch_exist, bool, 0644); +MODULE_PARM_DESC(pcie_switch_exist, "pcie switch existed or not"); + +static const char dc_ep_driver_name[] = "vrx518"; +static const char dc_ep_driver_version[] = DRV_VERSION; +static const char dc_ep_driver_string[] = + "Intel(R) SmartPHY DSL(VRX518) PCIe EP/ACA Driver"; +static const char dc_ep_copyright[] = + "Copyright (c) 2016 Intel Corporation."; + +static struct dc_ep_info g_dc_ep_info; +static DEFINE_SPINLOCK(dc_ep_lock); + +static inline void reset_assert_device(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_ep_assert_device(dev->priv, bits); +} + +static inline void reset_deassert_device(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_ep_deassert_device(dev->priv, bits); +} + +static inline void icu_disable_intr(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_ep_icu_dis_intr(dev->priv, bits); +} + +static inline void icu_enable_intr(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_ep_icu_en_intr(dev->priv, bits); +} + +static inline int reset_device(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_reset_device(dev->priv, bits); +} + +static inline int clk_on(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_clk_on(dev->priv, bits); +} + +static inline int clk_off(struct dc_ep_dev *dev, u32 bits) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_clk_off(dev->priv, bits); +} + +static inline int clk_set(struct dc_ep_dev *dev, u32 sysclk, u32 ppeclk) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_clk_set(dev->priv, sysclk, ppeclk); +} + +static inline int clk_get(struct dc_ep_dev *dev, u32 *sysclk, u32 *ppeclk) +{ + if (WARN_ON(!dev || !sysclk || !ppeclk)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_clk_get(dev->priv, sysclk, ppeclk); +} + +static inline int gpio_dir(struct dc_ep_dev *dev, u32 gpio, int dir) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_dir(dev->priv, gpio, dir); +} + +static inline int gpio_set(struct dc_ep_dev *dev, u32 gpio, int val) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_set(dev->priv, gpio, val); +} + +static inline int gpio_get(struct dc_ep_dev *dev, u32 gpio, int *val) +{ + if (WARN_ON(!dev || !val)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_get(dev->priv, gpio, val); +} + +static inline int pinmux_set(struct dc_ep_dev *dev, u32 gpio, int func) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_pinmux_set(dev->priv, gpio, func); +} + +static inline int pinmux_get(struct dc_ep_dev *dev, u32 gpio, int *func) +{ + if (WARN_ON(!dev || !func)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_pinmux_get(dev->priv, gpio, func); +} + +static inline int gpio_pupd_set(struct dc_ep_dev *dev, u32 gpio, u32 val) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_pupd_set(dev->priv, gpio, val); +} + +static inline int gpio_od_set(struct dc_ep_dev *dev, u32 gpio, int val) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_od_set(dev->priv, gpio, val); +} + +static inline int gpio_src_set(struct dc_ep_dev *dev, u32 gpio, int val) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_src_set(dev->priv, gpio, val); +} + +static inline int gpio_dcc_set(struct dc_ep_dev *dev, u32 gpio, u32 val) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_ep_gpio_dcc_set(dev->priv, gpio, val); +} + +static inline int aca_start(struct dc_ep_dev *dev, u32 func, int start) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_aca_start(dev->priv, func, start); +} + +static inline int aca_stop(struct dc_ep_dev *dev, u32 *func, int reset) +{ + if (WARN_ON(!dev || !func)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_aca_stop(dev->priv, func, reset); +} + +static inline int aca_init(struct dc_ep_dev *dev, struct aca_param *aca, + struct aca_modem_param *mdm) +{ + if (WARN_ON(!dev || !aca)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_aca_init(dev->priv, aca, mdm); +} + +static inline void aca_event_addr_get(struct dc_ep_dev *dev, + struct aca_event_reg_addr *regs) +{ + if (WARN_ON(!dev || !regs)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_aca_event_addr_get(dev->priv, regs); +} + +static inline u32 umt_msg_addr(struct dc_ep_dev *dev, u32 endian, u32 type) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return aca_umt_msg_addr(dev->priv, endian, type); +} + +static inline void aca_txin_sub_ack(struct dc_ep_dev *dev, u32 val) +{ + if (WARN_ON(!dev)) + return; + if (WARN_ON(!dev->priv)) + return; + + dc_aca_txin_sub_ack(dev->priv, val); +} + +static inline u32 aca_txin_hd_cnt(struct dc_ep_dev *dev) +{ + if (WARN_ON(!dev)) + return -EINVAL; + if (WARN_ON(!dev->priv)) + return -EINVAL; + + return dc_aca_txin_hd_cnt(dev->priv); +} + +static const struct aca_hw_ops dc_ep_hw_ops = { + .reset_assert = reset_assert_device, + .reset_deassert = reset_deassert_device, + .reset_device = reset_device, + .icu_en = icu_enable_intr, + .icu_mask = icu_disable_intr, + .clk_on = clk_on, + .clk_off = clk_off, + .clk_set = clk_set, + .clk_get = clk_get, + .gpio_dir = gpio_dir, + .gpio_set = gpio_set, + .gpio_get = gpio_get, + .pinmux_set = pinmux_set, + .pinmux_get = pinmux_get, + .gpio_pupd_set = gpio_pupd_set, + .gpio_od_set = gpio_od_set, + .gpio_src_set = gpio_src_set, + .gpio_dcc_set = gpio_dcc_set, + .aca_start = aca_start, + .aca_stop = aca_stop, + .aca_init = aca_init, + .aca_event_addr_get = aca_event_addr_get, + .umt_msg_addr = umt_msg_addr, + .aca_txin_ack_sub = aca_txin_sub_ack, + .aca_txin_hd_cnt = aca_txin_hd_cnt, +}; + +int dc_ep_dev_num_get(int *dev_num) +{ + if ((g_dc_ep_info.dev_num <= 0) + || (g_dc_ep_info.dev_num > DC_EP_MAX_NUM)) + return -EIO; + + *dev_num = g_dc_ep_info.dev_num; + return 0; +} +EXPORT_SYMBOL_GPL(dc_ep_dev_num_get); + +int dc_ep_dev_info_req(int dev_idx, enum dc_ep_int module, + struct dc_ep_dev *dev) +{ + int i; + struct dc_ep_priv *priv; + + if ((dev_idx < 0) || (dev_idx >= DC_EP_MAX_NUM)) { + dev_err(dev->dev, "%s invalid device index %d\n", + __func__, dev_idx); + return -EIO; + } + + priv = &g_dc_ep_info.pcie_ep[dev_idx]; + if (atomic_read(&priv->refcnt) >= DC_EP_MAX_REFCNT) { + dev_err(dev->dev, + "%s mismatch request/release module usage\n", __func__); + return -EIO; + } + + switch (module) { + case DC_EP_INT_PPE: + dev->irq = priv->irq_base; + if (priv->msi_mode == DC_EP_8_MSI_MODE) { + dev->aca_tx_irq = priv->irq_base + 7; + dev->aca_rx_irq = priv->irq_base + 6; + } else if (priv->msi_mode == DC_EP_4_MSI_MODE) { + dev->aca_tx_irq = priv->irq_base + 2; + dev->aca_rx_irq = priv->irq_base + 3; + } else { + dev_err(dev->dev, "%s ACA should never occur\n", + __func__); + } + break; + case DC_EP_INT_MEI: + dev->irq = priv->irq_base + 1; + break; + default: + dev->irq = priv->irq_base; + break; + } + + dev->dev = priv->dev; + dev->membase = priv->mem; + dev->phy_membase = priv->phymem; + dev->peer_num = priv->peer_num; + for (i = 0; i < dev->peer_num; i++) { + dev->peer_membase[i] = priv->peer_mem[i]; + dev->peer_phy_membase[i] = priv->peer_phymem[i]; + } + dev->switch_attached = priv->switch_attached; + dev->priv = priv; + dev->hw_ops = &dc_ep_hw_ops; + atomic_inc(&priv->refcnt); + return 0; +} +EXPORT_SYMBOL_GPL(dc_ep_dev_info_req); + +int dc_ep_dev_info_release(int dev_idx) +{ + struct dc_ep_priv *priv; + + if ((dev_idx < 0) || (dev_idx >= DC_EP_MAX_NUM)) { + pr_err("%s invalid device index %d\n", + __func__, dev_idx); + return -EIO; + } + + priv = &g_dc_ep_info.pcie_ep[dev_idx]; + if (atomic_read(&priv->refcnt) <= 0) { + pr_err("%s mismatch request/release module usage\n", + __func__); + return -EIO; + } + + atomic_dec(&priv->refcnt); + return 0; +} +EXPORT_SYMBOL_GPL(dc_ep_dev_info_release); + +static int pci_msi_vec_set(struct pci_dev *dev, int nvec) +{ + int pos; + u16 msgctl; + + if (!is_power_of_2(nvec)) + return -EINVAL; + + pos = pci_find_capability(dev, PCI_CAP_ID_MSI); + if (!pos) + return -EINVAL; + + pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &msgctl); + msgctl &= ~PCI_MSI_FLAGS_QSIZE; + msgctl |= ((ffs(nvec) - 1) << 4); + pci_write_config_word(dev, pos + PCI_MSI_FLAGS, msgctl); + pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &msgctl); + return 0; +} + +static int dc_ep_msi_enable(struct pci_dev *pdev, int nvec) +{ + int err; + struct dc_ep_priv *priv = pci_get_drvdata(pdev); + + /* NB, ICU initailize first */ + dc_ep_icu_init(priv); + + err = pci_msi_vec_set(pdev, nvec); + if (err) { + dev_err(&pdev->dev, "%s: Failed to set maximum MSI vector\n", + __func__); + return -EIO; + } + + err = pci_enable_msi_exact(pdev, nvec); + if (err) { + dev_err(&pdev->dev, + "%s: Failed to enable MSI interrupts error code: %d\n", + __func__, err); + return -EIO; + } + return 0; +} + +static void dc_ep_info_xchange(struct pci_dev *pdev, int card_num) +{ + /* More cards supported, exchange address information + * For example, suppose three cards dected. + * 0, <1, 2> + * 1, <0, 2> + * 2, <0, 1> + * For four cards detected + * 0, <1, 2, 3> + * 1, <0, 2, 3> + * 2, <0, 1, 3> + * 3, <0, 1, 2> + * and etc + */ + int i, j, k; + int peer_num; +#ifdef DC_EP_DBG + struct dc_ep_priv *priv; +#endif /* DC_EP_DBG */ + spin_lock(&dc_ep_lock); + if (card_num > 1) { + peer_num = card_num - 1; + for (i = 0; i < card_num; i++) { + struct dc_ep_priv *ep = &g_dc_ep_info.pcie_ep[i]; + j = 0; + k = 0; + ep->peer_num = peer_num; + do { + struct dc_ep_priv *partner; + + if (j == i) { + j++; + continue; + } + partner = &g_dc_ep_info.pcie_ep[j]; + ep->peer_mem[k] = partner->mem; + ep->peer_phymem[k] = partner->phymem; + ep->peer_memsize[k] = partner->memsize; + k++; + j++; + } while ((k < peer_num) && (j < card_num)); + } + } + spin_unlock(&dc_ep_lock); + +#ifdef DC_EP_DBG + dev_dbg(&pdev->dev, "Total cards found %d\n", card_num); + /* Dump detailed debug information */ + for (i = 0; i < card_num; i++) { + priv = &g_dc_ep_info.pcie_ep[i]; + dev_dbg(&pdev->dev, "card %d attached\n", priv->ep_idx); + dev_dbg(&pdev->dev, "irq base %d irq numbers %d\n", + priv->irq_base, priv->irq_num); + dev_dbg(&pdev->dev, + "its own phymem 0x%08x mem 0x%p size 0x%08x\n", + priv->phymem, priv->mem, priv->memsize); + if (card_num > 1) { + for (j = 0; j < priv->peer_num; j++) + dev_dbg(&pdev->dev, + "its peer phymem 0x%08x mem 0x%p size 0x%08x\n", + priv->peer_phymem[j], + priv->peer_mem[j], priv->peer_memsize[j]); + } + } +#endif /* DC_EP_DBG */ +} + +static int pci_msi_vec_num(struct pci_dev *dev) +{ + int ret; + u16 msgctl; + + if (!dev->msi_cap) + return -EINVAL; + + pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &msgctl); + ret = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1); + + return ret; +} + +static int dc_ep_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + int ret; + int nvec; + bool switch_exist; + int current_ep; + unsigned long phymem; + void __iomem *mem; + size_t memsize; + int msi_mode; + static int cards_found; +#ifndef CONFIG_OF + struct pcie_ep_adapter *adapter; +#endif + struct dc_ep_priv *priv; + + ret = pci_enable_device(pdev); + if (ret) { + dev_err(&pdev->dev, "can't enable PCI device %d\n", ret); + goto err_pci; + } + + /* Physical address */ + ret = pci_request_region(pdev, DC_EP_BAR_NUM, dc_ep_driver_name); + if (ret) { + dev_err(&pdev->dev, "PCI MMIO reservation error: %d\n", ret); + goto err_device; + } + + /* Target structures have a limit of 32 bit DMA pointers. + * DMA pointers can be wider than 32 bits by default on some systems. + */ + ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(&pdev->dev, "32-bit DMA not available: %d\n", ret); + goto err_region; + } + + ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(&pdev->dev, "cannot enable 32-bit consistent DMA\n"); + goto err_region; + } + + /* Set bus master bit in PCI_COMMAND to enable DMA */ + pci_set_master(pdev); + /* NB, some delay may need due to BME reset */ + udelay(1); + + /* Arrange for access to Target SoC registers. */ + mem = pci_iomap(pdev, DC_EP_BAR_NUM, 0); + if (!mem) { + dev_err(&pdev->dev, "PCI iomap error\n"); + ret = -EIO; + goto err_master; + } + phymem = pci_resource_start(pdev, DC_EP_BAR_NUM); + memsize = pci_resource_len(pdev, DC_EP_BAR_NUM); + + nvec = pci_msi_vec_num(pdev); + /* Overwrite maximum vector number according to + * the specific requirement + */ + if ((DC_PCIE_SWITCH_ATTACH > 0) || pcie_switch_exist) + switch_exist = true; + else + switch_exist = false; + /* Always use 4 vector mode */ + nvec = DC_EP_DEFAULT_MSI_VECTOR; + msi_mode = DC_EP_4_MSI_MODE; + + current_ep = cards_found++; + priv = &g_dc_ep_info.pcie_ep[current_ep]; + memset(priv, 0, sizeof(*priv)); + pci_set_drvdata(pdev, priv); + + /* Collect basic info for further operations */ + spin_lock(&dc_ep_lock); + g_dc_ep_info.dev_num = cards_found; + atomic_set(&priv->refcnt, 0); + priv->pdev = pdev; + priv->device_id = pdev->device; + priv->dev = &pdev->dev; + priv->ep_idx = current_ep; + priv->mem = mem; + priv->phymem = phymem; + priv->memsize = memsize; + priv->irq_num = nvec; + priv->switch_attached = switch_exist; + priv->msi_mode = msi_mode; + spin_unlock(&dc_ep_lock); + + ret = dc_ep_msi_enable(pdev, nvec); + if (ret) + goto err_iomap; + + spin_lock(&dc_ep_lock); + priv->irq_base = pdev->irq; + spin_unlock(&dc_ep_lock); + +#ifndef CONFIG_OF + adapter = kmalloc(sizeof(struct pcie_ep_adapter), GFP_KERNEL); + if (adapter == NULL) + goto err_iomap; + pci_set_drvdata(pdev, adapter); + adapter->mei_dev = platform_device_register_data(&pdev->dev, "mei_cpe", + PLATFORM_DEVID_AUTO, + NULL, 0); + if (IS_ERR(adapter->mei_dev)) { + dev_err(&pdev->dev, "can not register mei device, err: %li, ignore this\n", + PTR_ERR(adapter->mei_dev)); + goto err_msi; + } +#endif + dc_ep_info_xchange(pdev, cards_found); + /* Disable output clock to save power */ + dc_ep_clkod_disable(priv); + dc_aca_info_init(priv); + return 0; +#ifndef CONFIG_OF +err_msi: + kfree(adapter); +#endif +err_iomap: + pci_iounmap(pdev, mem); +err_master: + pci_clear_master(pdev); +err_region: + pci_release_region(pdev, DC_EP_BAR_NUM); +err_device: + pci_disable_device(pdev); +err_pci: + return ret; +} + +static void dc_ep_remove(struct pci_dev *pdev) +{ + struct dc_ep_priv *priv = pci_get_drvdata(pdev); + +#ifndef CONFIG_OF + struct pcie_ep_adapter *adapter = + (struct pcie_ep_adapter *) pci_get_drvdata(pdev); + + platform_device_unregister(adapter->mei_dev); +#endif + if (priv == NULL) + return; + + if (atomic_read(&priv->refcnt) != 0) { + dev_err(&pdev->dev, "%s still being used, can't remove\n", + __func__); + return; + } + dc_aca_free_fw_file(priv); + dc_aca_shutdown(priv); + dc_ep_icu_disable(priv); + pci_iounmap(pdev, priv->mem); + pci_release_region(pdev, DC_EP_BAR_NUM); + pci_disable_msi(pdev); + wmb(); + pci_clear_master(pdev); + pci_disable_device(pdev); +} + +static const struct pci_device_id dc_ep_id_table[] = { + {0x8086, 0x09a9, PCI_ANY_ID, PCI_ANY_ID}, /* VRX518 */ + {0}, +}; + +MODULE_DEVICE_TABLE(pci, dc_ep_id_table); + +static struct pci_driver dc_ep_driver = { + .name = (char *)dc_ep_driver_name, + .id_table = dc_ep_id_table, + .probe = dc_ep_probe, + .remove = dc_ep_remove, + .shutdown = dc_ep_remove, + /* PM not supported */ + /* AER is controlled by RC */ +}; + +static int __init dc_ep_init(void) +{ + pr_info("%s - version %s\n", + dc_ep_driver_string, dc_ep_driver_version); + + pr_info("%s\n", dc_ep_copyright); + memset(&g_dc_ep_info, 0, sizeof(struct dc_ep_info)); + + if (pci_register_driver(&dc_ep_driver) < 0) { + pr_err("%s: No devices found, driver not installed.\n", + __func__); + return -ENODEV; + } + return 0; +} +module_init(dc_ep_init); + +static void __exit dc_ep_exit(void) +{ + pci_unregister_driver(&dc_ep_driver); + + pr_info("%s: %s driver unloaded\n", __func__, + dc_ep_driver_name); +} +module_exit(dc_ep_exit); + +MODULE_AUTHOR("Intel Corporation, <Chuanhua.lei@intel.com>"); +MODULE_DESCRIPTION("Intel(R) SmartPHY PCIe EP/ACA Driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); diff --git a/package/kernel/lantiq/vrx518_ep/src/ep.h b/package/kernel/lantiq/vrx518_ep/src/ep.h new file mode 100644 index 00000000000..2e31008ec83 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/ep.h @@ -0,0 +1,127 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef EP_H +#define EP_H + +#include <net/dc_ep.h> + +#include "aca.h" + +#define DC_EP_MAX_NUM (DC_EP_MAX_PEER + 1) +#define DC_EP_BAR_NUM 0 + +/* Maximum 8, if PCIe switch attached, 4 is used. 8 is also default one */ +#ifdef CONFIG_VRX518_PCIE_SWITCH_BONDING +#define DC_PCIE_SWITCH_ATTACH 1 +#else +#define DC_PCIE_SWITCH_ATTACH 0 +#endif /* CONFIG_VRX518_PCIE_SWITCH_BONDING */ + +#define DC_EP_DEFAULT_MSI_VECTOR 4 + +#define DC_EP_MAX_REFCNT DC_EP_INT_MAX + +#define MS(_v, _f) (((_v) & (_f)) >> _f##_S) +#define SM(_v, _f) (((_v) << _f##_S) & (_f)) + +enum dc_ep_msi_mode { + DC_EP_8_MSI_MODE = 0, + DC_EP_4_MSI_MODE, + DC_EP_1_MSI_MODE, +}; + +/* Structure used to extract attached EP detailed information for + * PPE/DSL_MEI driver/Bonding + */ +struct dc_ep_priv { + struct pci_dev *pdev; + struct device *dev; + u32 ep_idx; /*!< EP logical index, the first found one will be 0 + regardless of RC physical index + */ + u32 irq_base; /*!< The first MSI interrupt number */ + u32 irq_num; /*!< How many MSI interrupt supported */ + enum dc_ep_msi_mode msi_mode; + u8 __iomem *mem; /*!< The EP inbound memory base address + derived from BAR0, SoC virtual address + for PPE/DSL_MEI driver + */ + u32 phymem; /*!< The EP inbound memory base address + derived from BAR0, physical address for + PPE FW + */ + size_t memsize; /*!< The EP inbound memory window size */ + u32 peer_num; /*!< Bonding peer number available */ + /*!< The bonding peer EP inbound memory base address derived from + * its BAR0, SoC virtual address for PPE/DSL_MEI driver + */ + + u8 __iomem *peer_mem[DC_EP_MAX_PEER]; + + /*!< The bonding peer EP inbound memory base address derived from + * its BAR0, physical address for PPE FW + */ + u32 peer_phymem[DC_EP_MAX_PEER]; + + /*!< The bonding peer inbound memory window size */ + size_t peer_memsize[DC_EP_MAX_PEER]; + atomic_t refcnt; /*!< The EP mapping driver referenced times + by other modules + */ + u16 device_id; /* Potential usage for different EP */ + bool switch_attached; + struct dc_aca aca; +}; + +struct dc_ep_info { + int dev_num; + int msi_mode; + struct dc_ep_priv pcie_ep[DC_EP_MAX_NUM]; +}; + +static inline struct dc_aca *to_aca(struct dc_ep_priv *priv) +{ + return &priv->aca; +} + +void dc_aca_shutdown(struct dc_ep_priv *priv); +void dc_aca_info_init(struct dc_ep_priv *priv); +int dc_aca_start(struct dc_ep_priv *priv, u32 func, int start); +int dc_aca_stop(struct dc_ep_priv *priv, u32 *func, int reset); +int dc_aca_init(struct dc_ep_priv *priv, struct aca_param *aca, + struct aca_modem_param *mdm); +void dc_aca_event_addr_get(struct dc_ep_priv *priv, + struct aca_event_reg_addr *regs); +void dc_aca_txin_sub_ack(struct dc_ep_priv *priv, u32 val); +u32 aca_umt_msg_addr(struct dc_ep_priv *priv, u32 endian, u32 type); +u32 dc_aca_txin_hd_cnt(struct dc_ep_priv *priv); +void dc_aca_free_fw_file(struct dc_ep_priv *priv); + +/* Card specific private data structure */ +struct pcie_ep_adapter { + struct platform_device *mei_dev; /* the mei driver */ +}; + +#endif /* EP_H */ + diff --git a/package/kernel/lantiq/vrx518_ep/src/include/net/dc_ep.h b/package/kernel/lantiq/vrx518_ep/src/include/net/dc_ep.h new file mode 100644 index 00000000000..f1142332e19 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/include/net/dc_ep.h @@ -0,0 +1,349 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef DC_EP_H +#define DC_EP_H + +#include <linux/types.h> +#include <linux/pci.h> +#include <linux/device.h> + +/* @{ */ +/*! \def DC_EP_MAX_PEER + * \brief how many EP partners existed. In most cases, this number should be + * one for bonding application. For the future extension, it could be bigger + * value. For example, multiple bonding + */ +#define DC_EP_MAX_PEER 1 + +/* Reset related module bit definition */ +#define RST_GPIO BIT(2) +#define RST_DSL_IF BIT(3) +#define RST_DFE BIT(7) +#define RST_PPE BIT(8) +#define RST_CDMA BIT(9) +#define RST_SPI BIT(10) +#define RST_IMCU BIT(11) +#define RST_ACA_DMA BIT(14) +#define RST_AFE BIT(16) +#define RST_ACA_HOSTIF BIT(17) +#define RST_PCIE BIT(22) +#define RST_PPE_ATM_TC BIT(23) +#define RST_FPI_SLAVE BIT(25) +#define RST_GLOBAL BIT(30) + +/* PMU related module definition */ +#define PMU_ADMA BIT(0) +#define PMU_CDMA BIT(2) +#define PMU_SPI BIT(8) +#define PMU_DSL BIT(9) +#define PMU_PPE_QSB BIT(18) +#define PMU_PPE_SLL01 BIT(19) +#define PMU_PPE_TC BIT(21) +#define PMU_EMA BIT(22) +#define PMU_PPM2 BIT(23) +#define PMU_PPE_TOP BIT(29) + +/* IMER bit definition */ +#define PPE2HOST_INT0 BIT(0) +#define PPE2HOST_INT1 BIT(1) +#define DYING_GASP_INT BIT(3) +#define MEI_IRQ BIT(8) +#define ACA_XBAR_INT BIT(9) +#define MODEM_XBAR_INT BIT(12) +#define LED0_INT BIT(13) +#define LED1_INT BIT(14) +#define NMI_PLL BIT(15) +#define DMA_TX BIT(16) +#define DMA_RX BIT(17) +#define ACA_HOSTIF_TX BIT(20) +#define ACA_HOSTIF_RX BIT(21) +#define ACA_RXOUT_PD_RING_FULL BIT(22) +#define ACA_TXOUT_PD_RING_FULL BIT(23) + +/* + * Structure used to specify available pin mux functions for gpio pinx + * It will be used in pinmux_set() function + */ +enum gpio_padc_func { + MUX_FUNC_GPIO = 0, + MUX_FUNC_ALT1, + MUX_FUNC_ALT2, + MUX_FUNC_RES, +}; + +/* + * Structure used to specify interrupt source so that EP can assign unique + * interruot to it +*/ +enum dc_ep_int { + DC_EP_INT_PPE, /*!< PPE2HOST_INT 0/1 */ + DC_EP_INT_MEI, /*!< DSL MEI_IRQ */ + DC_EP_INT_MAX, +}; + +/* Clock setting for system clock */ +enum { + SYS_CLK_36MHZ = 0, + SYS_CLK_288MHZ, + SYS_CLK_MAX, +}; + +/* Clock setting for PPE clock */ +enum { + PPE_CLK_36MHZ = 0, + PPE_CLK_576MHZ, + PPE_CLK_494MHZ, + PPE_CLK_432MHZ, + PPE_CLK_288MHZ, + PPE_CLK_MAX, +}; + +/* GPIO direction IN/OUT */ +enum { + GPIO_DIR_IN = 0, + GPIO_DIR_OUT, + GPIO_DIR_MAX, +}; + +/* GPIO Pullup/Pulldown setting */ +enum { + GPIO_PUPD_DISABLE = 0, + GPIO_PULL_UP, + GPIO_PULL_DOWN, + GPIO_PUPD_BOTH, +}; + +/* GPIO slew rate setting */ +enum { + GPIO_SLEW_RATE_SLOW = 0, + GPIO_SLEW_RATE_FAST, +}; + +/* GPIO driver current setting */ +enum { + GPIO_DRV_CUR_2MA = 0, + GPIO_DRV_CUR_4MA, + GPIO_DRV_CUR_8MA, + GPIO_DRV_CUR_12MA, + GPIO_DRV_CUR_MAX, +}; + +enum { + ACA_LITTLE_ENDIAN = 0, + ACA_BIG_ENDIAN, + ACA_ENDIAN_MAX, +}; + +enum { + ACA_TXIN = 0, + ACA_TXOUT, + ACA_RXIN, + ACA_RXOUT, + ACA_MAX, +}; + +/* ACA four major direction functions for start/stop */ +#define ACA_TXIN_EN BIT(0) +#define ACA_TXOUT_EN BIT(1) +#define ACA_RXIN_EN BIT(2) +#define ACA_RXOUT_EN BIT(3) +#define ACA_ALL_EN 0xF + +struct dc_ep_dev; + +/* + * ACA SoC specific parameters. The caller needs to fill up all necessary info + * according to specific SoC and specific project + * For each function, different parameters are needed. + */ +struct aca_cfg_param { + u32 soc_desc_base; /*!< SoC CBM or DDR descriptor base address */ + u32 soc_desc_num; /*!< SoC and HostIF (same) descriptor number */ + u32 soc_cmlt_cnt_addr; /*! SoC cumulative counter address */ + u32 pp_buf_desc_num; /*!< ACA ping pong buffer descriptor number */ + u32 pd_desc_base; /*!< Packet Descriptor base address in modem */ + u32 pd_desc_num; /*!< Packet Descriptor number in modem */ + u32 hd_size_in_dw; /*!< Host(SoC) descriptor size in dwords */ + u32 pd_size_in_dw; /*!< Packet descriptor size in dwords */ + u32 byteswap; /*!< Byte swap enabled or not in ACA FW */ + u32 prefill_cnt; /*!< Prefill counter special required for some platform */ +}; + +struct aca_param { + struct aca_cfg_param aca_txin; + struct aca_cfg_param aca_txout; + struct aca_cfg_param aca_rxin; + struct aca_cfg_param aca_rxout; +}; + +/* ACA project/modem specific parameters. It is only valid for VRX518 */ +struct aca_proj_param { + u32 stat; /*!< Target state */ + u32 pd; /*!< Target packet descripor */ + u32 acc_cnt; /*!< Target accumulate counter */ +}; + +/* Project specific configuration */ +struct aca_modem_param { + struct aca_proj_param mdm_txout; + struct aca_proj_param mdm_rxin; + struct aca_proj_param mdm_rxout; +}; + +/* Event trigger register address <offset> */ +struct aca_event_reg_addr { + u32 txin_acc_sub; + u32 txout_acc_add; + u32 rxin_acc_sub; + u32 rxout_acc_add; +}; + +/* + * ACA common hardware low level APIs, presented as callbacks instead of + * separate APIs to support mulitple instances + */ +struct aca_hw_ops { + /* RCU Callbacks */ + void (*reset_assert)(struct dc_ep_dev *pdev, u32 rd); + void (*reset_deassert)(struct dc_ep_dev *pdev, u32 rd); + /* For hardware self-clear reset, most apply except PCIe */ + int (*reset_device)(struct dc_ep_dev *pdev, u32 hd); + + /* PMU Callbacks */ + int (*clk_on)(struct dc_ep_dev *pdev, u32 cd); + int (*clk_off)(struct dc_ep_dev *pdev, u32 cd); + + /* CGU Callbacks */ + int (*clk_set)(struct dc_ep_dev *pdev, u32 sysclk, u32 ppeclk); + int (*clk_get)(struct dc_ep_dev *pdev, u32 *sysclk, u32 *ppeclk); + + /* GPIO Callbacks */ + int (*gpio_dir)(struct dc_ep_dev *pdev, u32 gpio, int dir); + int (*gpio_set)(struct dc_ep_dev *pdev, u32 gpio, int val); + int (*gpio_get)(struct dc_ep_dev *pdev, u32 gpio, int *val); + + /* PinMux Callbacks */ + int (*pinmux_set)(struct dc_ep_dev *pdev, u32 gpio, int func); + int (*pinmux_get)(struct dc_ep_dev *pdev, u32 gpio, int *func); + int (*gpio_pupd_set)(struct dc_ep_dev *pdev, u32 gpio, u32 val); + int (*gpio_od_set)(struct dc_ep_dev *pdev, u32 gpio, int val); + int (*gpio_src_set)(struct dc_ep_dev *pdev, u32 gpio, int val); + int (*gpio_dcc_set)(struct dc_ep_dev *pdev, u32 gpio, u32 val); + + /* ICU Callbacks */ + void (*icu_en)(struct dc_ep_dev *pdev, u32 bit); + void (*icu_mask)(struct dc_ep_dev *pdev, u32 bit); + + /* ACA related stuff */ + int (*aca_start)(struct dc_ep_dev *pdev, u32 func, int start); + int (*aca_stop)(struct dc_ep_dev *pdev, u32 *func, int reset); + /* If there is no project specific parameters, input NULL */ + int (*aca_init)(struct dc_ep_dev *pdev, struct aca_param *aca, + struct aca_modem_param *mdm); + void (*aca_event_addr_get)(struct dc_ep_dev *pdev, + struct aca_event_reg_addr *regs); + /* UMT address needed for SoC filled in to trigger UMT msg */ + u32 (*umt_msg_addr)(struct dc_ep_dev *pdev, u32 endian, u32 type); + /* TXIN accum sub to ack PPE already processed */ + void (*aca_txin_ack_sub)(struct dc_ep_dev *pdev, u32 val); + u32 (*aca_txin_hd_cnt)(struct dc_ep_dev *pdev); +}; + +/* + * Structure used to extract attached EP detailed information + * for PPE/DSL_MEI driver/Bonding + */ +struct dc_ep_dev { + struct device *dev; + u32 irq; /*!< MSI interrupt number for this device */ + u32 aca_tx_irq; /*!< ACA Non-empty TX irq number for PPE driver */ + u32 aca_rx_irq; /*!< ACA Non-empty RX irq number for PPE driver */ + /*!< The EP inbound memory base address derived from BAR0, SoC + virtual address for PPE/DSL_MEI driver + */ + bool switch_attached; /*!< EP attach switch */ + u8 __iomem *membase; /*!< virtual memory base address to access EP */ + u32 phy_membase; /*!< The EP inbound memory base address derived + from BAR0, physical address for PPE FW + */ + u32 peer_num; /*!< Bonding peer number available */ + /*!< The bonding peer EP inbound memory base address derived from + its BAR0, SoC virtual address for PPE/DSL_MEI driver + */ + u8 __iomem *peer_membase[DC_EP_MAX_PEER]; + /*!< The bonding peer EP inbound memory base address derived from + its BAR0, physical address for PPE FW + */ + u32 peer_phy_membase[DC_EP_MAX_PEER]; + const struct aca_hw_ops *hw_ops; + void *priv; /* Pointer to driver proprietary data for internal use */ +}; + +/* + * This function returns the total number of EPs attached. Normally, + * the number should be one <standard smartPHY EP> or two <smartPHY + * off-chip bonding cases>. Extended case is also considered + + * \param[in/out] dev_num Pointer to detected EP numbers in total. + * \return -EIO Invalid total EP number which means this + * module is not initialized properly + * \return 0 Successfully return the detected EP numbers + */ +int dc_ep_dev_num_get(int *dev_num); + +/* + * This function returns detailed EP device information for PPE/DSL/Bonding + * partner by its logical index obtained + * by \ref dc_ep_dev_num_get and its interrupt module number + * \ref dc_ep_int + + * \param[in] dev_idx Logical device index referred to the related + * device + * \param[in] module EP interrupt module user<PPE/MEI> + * \param[in/out] dev Pointer to returned detail device structure + * \ref dc_ep_dev + * \return -EIO Invalid logical device index or too many modules + * referred to this module + * \return 0 Successfully return required device information + + * \remarks This function normally will be called to trace the detailed device + * information after calling \ref dc_ep_dev_num_get + */ +int dc_ep_dev_info_req(int dev_idx, enum dc_ep_int module, + struct dc_ep_dev *dev); + +/* + * This function releases the usage of this module by PPE/DSL + + * \param[in] dev_idx Logical device index referred to the related device + * \return -EIO Invalid logical device index or release too many + * times to refer to this module + * \return 0 Successfully release the usage of this module + + * \remarks This function should be called once their reference is over. + * The reference usage must matches \ref dc_ep_dev_info_req + */ +int dc_ep_dev_info_release(int dev_idx); + +#endif /* DC_EP_H */ diff --git a/package/kernel/lantiq/vrx518_ep/src/misc.c b/package/kernel/lantiq/vrx518_ep/src/misc.c new file mode 100644 index 00000000000..9140fe79e4d --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/misc.c @@ -0,0 +1,325 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#include <linux/delay.h> +#include <linux/mutex.h> + +#include "regs.h" +#include "ep.h" +#include "misc.h" + +#define padc_getbit(p, r) (!!(rd32(r) & (1 << p))) +#define padc_setbit(p, r) wr32_mask(0, BIT(p), r) +#define padc_clearbit(p, r) wr32_mask(BIT(p), 0, r) + +void dc_ep_clkod_disable(struct dc_ep_priv *priv) +{ + wr32_mask(0, IF_CLKOD_ALL, IF_CLK); +} + +void dc_ep_icu_init(struct dc_ep_priv *priv) +{ + /* Enable all interrupts in ICU level */ + wr32(ICU_DMA_TX_ALL, ICU_DMA_TX_IMER); + wr32(ICU_DMA_RX_ALL, ICU_DMA_RX_IMER); + wr32(ICU_TOP_ALL, ICU_IMER); + + if (priv->msi_mode == DC_EP_4_MSI_MODE) + wr32(PCI_MSI_4_MODE, RCU_MSI); + else + wr32(PCI_MSI_8_MODE, RCU_MSI); + + /* PCIe app has to enable all MSI interrupts regardless of MSI mode */ + wr32(PCIE_MSI_EN_ALL, PCIE_APPL_MSI_EN); +} + +void dc_ep_icu_disable(struct dc_ep_priv *priv) +{ + /* Disable all PCIe related interrupts */ + wr32(0, PCIE_APPL_MSI_EN); + + wr32(PCI_MSI_8_MODE, RCU_MSI); + + /* Disable all interrupts in ICU level */ + wr32(0, ICU_DMA_TX_IMER); + wr32(0, ICU_DMA_RX_IMER); + wr32(0, ICU_IMER); +} + +void dc_ep_icu_dis_intr(struct dc_ep_priv *priv, u32 bits) +{ + wr32_mask(~bits, 0, ICU_IMER); +} + +void dc_ep_icu_en_intr(struct dc_ep_priv *priv, u32 bits) +{ + wr32_mask(0, bits, ICU_IMER); +} + +void dc_ep_assert_device(struct dc_ep_priv *priv, u32 bits) +{ + struct dc_aca *aca = to_aca(priv); + + spin_lock(&aca->rcu_lock); + wr32_mask(0, bits, RCU_REQ); + spin_unlock(&aca->rcu_lock); +} + +void dc_ep_deassert_device(struct dc_ep_priv *priv, u32 bits) +{ + struct dc_aca *aca = to_aca(priv); + + spin_lock(&aca->rcu_lock); + wr32_mask(bits, 0, RCU_REQ); + spin_unlock(&aca->rcu_lock); +} + +int dc_ep_reset_device(struct dc_ep_priv *priv, u32 bits) +{ + int retry = EP_TIMEOUT; + + wr32(bits, RCU_REQ); + do { } while (retry-- && (!(rd32(RCU_STAT) & bits))); + + if (retry == 0) { + dev_err(priv->dev, "%s failed to reset\n", __func__); + return -ETIME; + } + return 0; +} + +int dc_ep_clk_on(struct dc_ep_priv *priv, u32 bits) +{ + int retry = EP_TIMEOUT; + struct dc_aca *aca = to_aca(priv); + + spin_lock(&aca->clk_lock); + wr32_mask(bits, 0, PMU_PWDCR); + spin_unlock(&aca->clk_lock); + + do { } while (--retry && (rd32(PMU_SR) & bits)); + + if (!retry) { + dev_err(priv->dev, "%s failed\n", __func__); + return -ETIME; + } + return 0; +} + +int dc_ep_clk_off(struct dc_ep_priv *priv, u32 bits) +{ + int retry = EP_TIMEOUT; + struct dc_aca *aca = to_aca(priv); + + spin_lock(&aca->clk_lock); + wr32_mask(0, bits, PMU_PWDCR); + spin_unlock(&aca->clk_lock); + + do {} while (--retry + && (!(rd32(PMU_SR) & bits))); + if (!retry) { + dev_err(priv->dev, "%s failed\n", __func__); + return -ETIME; + } + return 0; +} + +int dc_ep_clk_set(struct dc_ep_priv *priv, u32 sysclk, u32 ppeclk) +{ + struct dc_aca *aca = to_aca(priv); + + if (sysclk > SYS_CLK_MAX || ppeclk > PPE_CLK_MAX) + return -EINVAL; + + spin_lock(&aca->clk_lock); + wr32_mask(PPE_CLK | SYS_CLK, + SM(sysclk, SYS_CLK) | SM(ppeclk, PPE_CLK), PLL_OMCFG); + spin_unlock(&aca->clk_lock); + return 0; +} + +int dc_ep_clk_get(struct dc_ep_priv *priv, u32 *sysclk, u32 *ppeclk) +{ + u32 val; + + val = rd32(PLL_OMCFG); + *sysclk = MS(val, SYS_CLK); + *ppeclk = MS(val, PPE_CLK); + return 0; +} + +int dc_ep_gpio_dir(struct dc_ep_priv *priv, u32 gpio, int dir) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + if ((dir != GPIO_DIR_IN) && (dir != GPIO_DIR_OUT)) + return -EINVAL; + + if (dir == GPIO_DIR_IN) + wr32(BIT(gpio), GPIO_DIRCLR); + else + wr32(BIT(gpio), GPIO_DIRSET); + return 0; +} + +int dc_ep_gpio_set(struct dc_ep_priv *priv, u32 gpio, int val) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + dc_ep_gpio_dir(priv, gpio, GPIO_DIR_OUT); + + if (val) + wr32(BIT(gpio), GPIO_OUTSET); + else + wr32(BIT(gpio), GPIO_OUTCLR); + return 0; +} + +int dc_ep_gpio_get(struct dc_ep_priv *priv, u32 gpio, int *val) +{ + u32 dir; + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + dir = rd32(GPIO_DIR); + if ((dir >> gpio) & 0x1) + *val = (rd32(GPIO_OUT) >> gpio) & 0x1; + else + *val = (rd32(GPIO_IN) >> gpio) & 0x1; + return 0; +} + +int dc_ep_pinmux_set(struct dc_ep_priv *priv, u32 gpio, int func) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + if (func >= MUX_FUNC_RES) + return -EINVAL; + + mutex_lock(&aca->pin_lock); + wr32_mask(PADC_MUX_M, func, PADC_MUX(gpio)); + mutex_unlock(&aca->pin_lock); + return 0; +} + +int dc_ep_pinmux_get(struct dc_ep_priv *priv, u32 gpio, int *func) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + *func = rd32(PADC_MUX(gpio)); + return 0; +} + +int dc_ep_gpio_pupd_set(struct dc_ep_priv *priv, u32 gpio, u32 val) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + /* Not support for both enabled */ + if (val >= GPIO_PUPD_BOTH) + return -EINVAL; + + mutex_lock(&aca->pin_lock); + switch (val) { + case GPIO_PUPD_DISABLE: + padc_clearbit(gpio, PADC_PUEN); + padc_clearbit(gpio, PADC_PDEN); + break; + case GPIO_PULL_UP: + padc_setbit(gpio, PADC_PUEN); + padc_clearbit(gpio, PADC_PDEN); + break; + case GPIO_PULL_DOWN: + padc_setbit(gpio, PADC_PDEN); + padc_clearbit(gpio, PADC_PUEN); + break; + default: + break; + } + mutex_unlock(&aca->pin_lock); + return 0; +} + +int dc_ep_gpio_od_set(struct dc_ep_priv *priv, u32 gpio, int val) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + mutex_lock(&aca->pin_lock); + if (!!val) + padc_setbit(gpio, PADC_OD); + else + padc_clearbit(gpio, PADC_OD); + mutex_unlock(&aca->pin_lock); + return 0; +} + +int dc_ep_gpio_src_set(struct dc_ep_priv *priv, u32 gpio, int val) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + mutex_lock(&aca->pin_lock); + if (!!val) + padc_setbit(gpio, PADC_SRC); + else + padc_clearbit(gpio, PADC_SRC); + mutex_unlock(&aca->pin_lock); + return 0; +} + +int dc_ep_gpio_dcc_set(struct dc_ep_priv *priv, u32 gpio, u32 val) +{ + struct dc_aca *aca = to_aca(priv); + + if (gpio > aca->max_gpio) + return -EINVAL; + + if (val >= GPIO_DRV_CUR_MAX) + return -EINVAL; + + mutex_lock(&aca->pin_lock); + wr32_mask((0x3 << (gpio * 2)), (val << (gpio * 2)), PADC_DCC); + mutex_unlock(&aca->pin_lock); + return 0; +} diff --git a/package/kernel/lantiq/vrx518_ep/src/misc.h b/package/kernel/lantiq/vrx518_ep/src/misc.h new file mode 100644 index 00000000000..d92ea83e2fc --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/misc.h @@ -0,0 +1,51 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef MISC_H +#define MISC_H + +#define EP_TIMEOUT 10000 + +void dc_ep_clkod_disable(struct dc_ep_priv *priv); +void dc_ep_icu_init(struct dc_ep_priv *priv); +void dc_ep_icu_disable(struct dc_ep_priv *priv); +void dc_ep_assert_device(struct dc_ep_priv *priv, u32 bits); +void dc_ep_deassert_device(struct dc_ep_priv *priv, u32 bits); +int dc_ep_reset_device(struct dc_ep_priv *priv, u32 bits); +int dc_ep_clk_on(struct dc_ep_priv *priv, u32 bits); +int dc_ep_clk_off(struct dc_ep_priv *priv, u32 bits); +int dc_ep_clk_set(struct dc_ep_priv *priv, u32 sysclk, u32 ppeclk); +int dc_ep_clk_get(struct dc_ep_priv *priv, u32 *sysclk, u32 *ppeclk); +int dc_ep_gpio_dir(struct dc_ep_priv *priv, u32 gpio, int dir); +int dc_ep_gpio_set(struct dc_ep_priv *priv, u32 gpio, int val); +int dc_ep_gpio_get(struct dc_ep_priv *priv, u32 gpio, int *val); +int dc_ep_pinmux_set(struct dc_ep_priv *priv, u32 gpio, int func); +int dc_ep_pinmux_get(struct dc_ep_priv *priv, u32 gpio, int *func); +int dc_ep_gpio_pupd_set(struct dc_ep_priv *priv, u32 gpio, u32 val); +int dc_ep_gpio_od_set(struct dc_ep_priv *priv, u32 gpio, int val); +int dc_ep_gpio_src_set(struct dc_ep_priv *priv, u32 gpio, int val); +int dc_ep_gpio_dcc_set(struct dc_ep_priv *priv, u32 gpio, u32 val); +void dc_ep_icu_dis_intr(struct dc_ep_priv *priv, u32 bits); +void dc_ep_icu_en_intr(struct dc_ep_priv *priv, u32 bits); + +#endif /* MISC_H */ diff --git a/package/kernel/lantiq/vrx518_ep/src/regs.h b/package/kernel/lantiq/vrx518_ep/src/regs.h new file mode 100644 index 00000000000..9236453a4f4 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/regs.h @@ -0,0 +1,138 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef REGS_H +#define REGS_H + +#include <linux/bitops.h> + +/* APPL defined */ +#define PCIE_APPL_BASE 0x00048000 +#define PCIE_APPL_REG(X) (PCIE_APPL_BASE + (X)) + +#define PCIE_APPL_PHY_CFG1 PCIE_APPL_REG(0x3C) +#define PCIE_APPL_PHY_CFG2 PCIE_APPL_REG(0x40) +#define PCIE_APPL_PHY_CFG3 PCIE_APPL_REG(0x58) +#define PCIE_APPL_PHY_CFG4 PCIE_APPL_REG(0x28) +#define PCIE_APPL_INTR_VEC PCIE_APPL_REG(0x48) +#define PCIE_APPL_MSI_EN PCIE_APPL_REG(0x4C) + +#define PCIE_MSI_EN_ALL 0xFF + +/* RCU defined */ +#define RCU_BASE 0x00008000 +#define RCU_REG(X) (RCU_BASE + (X)) +#define RCU_STAT RCU_REG(0x00) +#define RCU_REQ RCU_REG(0x10) + +#define RCU_MSI RCU_REG(0x80) +#define PCI_MSI_4_MODE 1 +#define PCI_MSI_8_MODE 0 + +/* CGU */ +#define CGU_BASE 0x00000000 +#define CGU_REG(X) (CGU_BASE + (X)) +#define PMU_PWDCR CGU_REG(0x011C) +#define PMU_SR CGU_REG(0x0120) +#define PMU_ALL 0x20ec0305 + +#define PLL_OMCFG CGU_REG(0x0064) + +#define SYS_CLK 0x3 +#define SYS_CLK_S 0 +#define PPE_CLK 0x700 +#define PPE_CLK_S 8 + +#define IF_CLK CGU_REG(0x0024) + +#define CLK_PD BIT(10) +#define CLK_OD BIT(11) +#define PCIE_CLKOD (BIT(12) | BIT(13)) +#define AFE_CLKOD BIT(14) + +#define IF_CLKOD_ALL (CLK_PD | CLK_OD | PCIE_CLKOD | AFE_CLKOD) + +/* GPIO */ +#define GPIO_BASE 0x00020000 +#define GPIO_REG(X) (GPIO_BASE + (X)) +#define GPIO_OUT GPIO_REG(0x00) +#define GPIO_IN GPIO_REG(0x04) +#define GPIO_DIR GPIO_REG(0x08) +#define GPIO_OUTSET GPIO_REG(0x40) +#define GPIO_OUTCLR GPIO_REG(0x44) +#define GPIO_DIRSET GPIO_REG(0x48) +#define GPIO_DIRCLR GPIO_REG(0x4c) + +/* PADC */ +#define PADC_BASE 0x00024000 +#define PADC_REG(X) (PADC_BASE + (X)) +#define PADC_MUX(pin) PADC_REG(((pin) << 2)) +#define PADC_PUEN PADC_REG(0x80) +#define PADC_PDEN PADC_REG(0x84) +#define PADC_SRC PADC_REG(0x88) +#define PADC_DCC PADC_REG(0x8c) +#define PADC_OD PADC_REG(0x94) +#define PADC_AVAIL PADC_REG(0x98) +#define PADC_MUX_M 0x7 + +/* ICU defined */ +#define ICU_BASE 0x00010000 +#define ICU_REG(X) (ICU_BASE + (X)) +#define ICU_IMSR ICU_REG(0x40) +#define ICU_IMER ICU_REG(0x44) +#define ICU_IMOSR ICU_REG(0x48) +#define ICU_DMA_TX_STATUS ICU_REG(0x50) +#define ICU_DMA_RX_STATUS ICU_REG(0x54) +#define ICU_DMA_TX_IMER ICU_REG(0x58) +#define ICU_DMA_RX_IMER ICU_REG(0x5C) +#define ICU_DMA_TX_IMOSR ICU_REG(0x60) +#define ICU_DMA_RX_IMOSR ICU_REG(0x64) + +#define PPE2HOST_INT0 BIT(0) +#define PPE2HOST_INT1 BIT(1) +#define DYING_GASP_INT BIT(3) +#define MEI_IRQ BIT(8) +#define ACA_XBAR_INT BIT(9) +#define MODEM_XBAR_INT BIT(12) +#define LED0_INT BIT(13) +#define LED1_INT BIT(14) +#define NMI_PLL BIT(15) +#define DMA_TX BIT(16) +#define DMA_RX BIT(17) +#define ACA_HOSTIF_TX BIT(20) +#define ACA_HOSTIF_RX BIT(21) +#define ACA_RXOUT_PD_RING_FULL BIT(22) +#define ACA_TXOUT_PD_RING_FULL BIT(23) + +#define ICU_TOP_ALL 0x0003f30B /* Except ACA related */ +#define ICU_DMA_TX_ALL 0x003f03FF +#define ICU_DMA_RX_ALL 0x003F03FF + +#define wr32(value, reg) (writel(value, (priv->mem + (reg)))) +#define rd32(reg) (readl(priv->mem + (reg))) +#define wrfl() ((void)rd32(RCU_STAT)) + +#define wr32_mask(clr, set, reg) \ + wr32(((rd32(reg) & ~(clr)) | (set)), (reg)) + +#endif /* REGS_H */ diff --git a/package/kernel/lantiq/vrx518_ep/src/test/Makefile b/package/kernel/lantiq/vrx518_ep/src/test/Makefile new file mode 100644 index 00000000000..d9e5d43e4aa --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/test/Makefile @@ -0,0 +1,2 @@ + +obj-$(CONFIG_TEST) += ep_test.o
\ No newline at end of file diff --git a/package/kernel/lantiq/vrx518_ep/src/test/ep_test.c b/package/kernel/lantiq/vrx518_ep/src/test/ep_test.c new file mode 100644 index 00000000000..ab6139b73ee --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/test/ep_test.c @@ -0,0 +1,924 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux Test driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/version.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/interrupt.h> +#include <linux/delay.h> + +#include <net/dc_ep.h> + +#include "ep_test.h" + +#define DRV_VERSION "1.0.0" +static const char ep_test_driver_version[] = DRV_VERSION; +static struct dc_ep_dev pcie_dev[DC_EP_MAX_PEER + 1]; +static int ppe_irq_num; + +#define ep_wr32(value, reg) (writel(value, dev->membase + reg)) +#define ep_rd32(reg) (readl(dev->membase + reg)) + +#define ep_wr32_mask(clr, set, reg) \ + ep_wr32(((ep_rd32(reg) & ~(clr)) | (set)), (reg)) + +struct aca_hd_desc { + void *base; + dma_addr_t phy_base; + size_t size;/* in bytes */ +}; + +struct aca_hd_desc_cfg { + struct aca_hd_desc txin; + struct aca_hd_desc txout; + struct aca_hd_desc rxout; +}; + +static struct aca_hd_desc_cfg aca_soc_hd_desc[DC_EP_MAX_PEER + 1]; + +static void ep_mem_write(u8 __iomem *dst, const void *src, size_t len) +{ + int i; + const u32 *src_addr = src; + + if (len % 4) + pr_info("Warning!!: Copy len is not multiple of 4\n"); + + len = len >> 2; + + for (i = 0; i < len; i++) + writel(src_addr[i], (dst + (i << 2))); +} + +static irqreturn_t dc_ep_ppe_intr(int irq, void *dev_id) +{ + struct dc_ep_dev *dev = dev_id; + + ppe_irq_num++; + if (ep_rd32(MBOX_IGU0_ISR) == 0) { + pr_err("Fatal error, dummy interrupt\n"); + return IRQ_NONE; + } + + ep_wr32(PPE_MBOX_TEST_BIT, MBOX_IGU0_ISRC); + ep_rd32(MBOX_IGU0_ISR); + return IRQ_HANDLED; +} + +static void dc_ep_ppe_mbox_reg_dump(struct dc_ep_dev *dev) +{ + pr_info("MBOX_IGU0_ISRS addr %p data 0x%08x\n", + dev->membase + MBOX_IGU0_ISRS, + ep_rd32(MBOX_IGU0_ISRS)); + pr_info("MBOX_IGU0_ISRC addr %p data 0x%08x\n", + dev->membase + MBOX_IGU0_ISRC, + ep_rd32(MBOX_IGU0_ISRC)); + pr_info("MBOX_IGU0_ISR addr %p data 0x%08x\n", + dev->membase + MBOX_IGU0_ISR, + ep_rd32(MBOX_IGU0_ISR)); + pr_info("MBOX_IGU0_IER addr %p data 0x%08x\n", + dev->membase + MBOX_IGU0_IER, + ep_rd32(MBOX_IGU0_IER)); +} + +#define PPE_INT_TIMEOUT 10 +static int dc_ep_ppe_mbox_int_stress_test(struct dc_ep_dev *dev) +{ + int i; + int j; + int ret; + + /* Clear it first */ + ep_wr32(PPE_MBOX_TEST_BIT, MBOX_IGU0_ISRC); + + ret = request_irq(dev->irq, dc_ep_ppe_intr, 0, "PPE_MSI", dev); + if (ret) { + pr_err("%s request irq %d failed\n", __func__, dev->irq); + return -1; + } + pr_info("PPE test\n"); + ep_wr32(PPE_MBOX_TEST_BIT, MBOX_IGU0_IER); + ppe_irq_num = 0; + /* Purposely trigger interrupt */ + for (i = 0; i < PPE_MBOX_IRQ_TEST_NUM; i++) { + j = 0; + while ((ep_rd32(MBOX_IGU0_ISR) & PPE_MBOX_TEST_BIT)) { + j++; + if (j > PPE_INT_TIMEOUT) + break; + } + ep_wr32(PPE_MBOX_TEST_BIT, MBOX_IGU0_ISRS); + /* Write flush */ + ep_rd32(MBOX_IGU0_ISR); + } + mdelay(10); + pr_info("irq triggered %d expected %d\n", ppe_irq_num, + PPE_MBOX_IRQ_TEST_NUM); + dc_ep_ppe_mbox_reg_dump(dev); + ppe_irq_num = 0; + return 0; +} + +static void umt_txin_send(struct dc_ep_dev *dev, + u8 __iomem *soc_dbase, int num) +{ + int i; + struct aca_dma_desc desc; + + memset(&desc, 0, sizeof(desc)); + desc.own = 0; + desc.sop = 1; + desc.eop = 1; + desc.dic = 1; + desc.pdu_type = 1; + desc.data_len = 127; + desc.data_pointer = 0x26000000; + desc.dw1 = 0x700; + desc.dw0 = 0x0000007f; + + for (i = 0; i < num; i++) { + desc.data_pointer += roundup(desc.data_len, 4); + ep_mem_write(soc_dbase + i * sizeof(desc), + (void *)&desc, sizeof(desc)); + } + + ep_wr32(num, TXIN_HD_ACCUM_ADD); +} + +static void ppe_txout_send(struct dc_ep_dev *dev, + u8 __iomem *ppe_sb_base, int num) +{ + int i; + struct aca_dma_desc_2dw desc; + + memset(&desc, 0, sizeof(desc)); + desc.status.field.own = 1; + desc.status.field.sop = 1; + desc.status.field.eop = 1; + desc.status.field.data_len = 127; + desc.data_pointer = 0x26100000; + + for (i = 0; i < num; i++) { + desc.data_pointer += roundup(desc.status.field.data_len, 4); + ep_mem_write(ppe_sb_base + i * sizeof(desc), + (void *)&desc, sizeof(desc)); + } + + ep_wr32(num, TXOUT_ACA_ACCUM_ADD); +} + +static void ppe_rxout_send(struct dc_ep_dev *dev, + u8 __iomem *ppe_sb_base, int num) +{ + int i; + struct aca_dma_desc_2dw desc; + + memset(&desc, 0, sizeof(desc)); + desc.status.field.own = 0; + desc.status.field.sop = 1; + desc.status.field.eop = 1; + desc.status.field.meta_data0 = 0x3; + desc.status.field.meta_data1 = 0x7f; + desc.status.field.data_len = 127; + desc.data_pointer = 0x26200000; + + for (i = 0; i < num; i++) { + desc.data_pointer += roundup(desc.status.field.data_len, 4); + ep_mem_write(ppe_sb_base + i * sizeof(desc), + (void *)&desc, sizeof(desc)); + } + + ep_wr32(num, RXOUT_ACA_ACCUM_ADD); +} + +static void dc_aca_test_init(struct dc_ep_dev *dev, void *soc_base) +{ + umt_txin_send(dev, (u8 __iomem *)soc_base, 8); + ppe_txout_send(dev, (TXOUT_PD_DBASE + dev->membase), 8); + ppe_rxout_send(dev, (RXOUT_PD_DBASE + dev->membase), 8); +} + +static const char *sysclk_str[SYS_CLK_MAX] = { + "36MHz", + "288MHz", +}; + +static const char *ppeclk_str[PPE_CLK_MAX] = { + "36MHz", + "576MHz", + "494MHz", + "432MHz", + "288MHz", +}; + +#define ACA_PMU_CTRL 0x11C +#define ACA_PMU_DMA BIT(2) +#define ACA_PMU_EMA BIT(22) + +enum { + DMA_ENDIAN_TYPE0 = 0, + DMA_ENDIAN_TYPE1, /*!< Byte Swap(B0B1B2B3 => B1B0B3B2) */ + DMA_ENDIAN_TYPE2, /*!< Word Swap (B0B1B2B3 => B2B3B0B1) */ + DMA_ENDIAN_TYPE3, /*!< DWord Swap (B0B1B2B3 => B3B2B1B0) */ + DMA_ENDIAN_MAX, +}; + +#ifdef CONFIG_CPU_BIG_ENDIAN +#define DMA_ENDIAN_DEFAULT DMA_ENDIAN_TYPE3 +#else +#define DMA_ENDIAN_DEFAULT DMA_ENDIAN_TYPE0 +#endif + +enum { + DMA_BURSTL_2DW = 1, /*!< 2 DWORD DMA burst length */ + DMA_BURSTL_4DW = 2, /*!< 4 DWORD DMA burst length */ + DMA_BURSTL_8DW = 3, /*!< 8 DWORD DMA burst length */ + DMA_BURSTL_16DW = 16, +}; + +#define DMA_BURSTL_DEFAULT DMA_BURSTL_16DW + +#define DMA_TX_PORT_DEFAULT_WEIGHT 1 +/** Default Port Transmit weight value */ +#define DMA_TX_CHAN_DEFAULT_WEIGHT 1 + +enum { + DMA_RX_CH = 0, /*!< Rx channel */ + DMA_TX_CH = 1, /*!< Tx channel */ +}; + +enum { + DMA_PKT_DROP_DISABLE = 0, + DMA_PKT_DROP_ENABLE, +}; + +#ifdef CONFIG_CPU_BIG_ENDIAN +/* 2 DWs format descriptor */ +struct rx_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 own:1; + u32 c:1; + u32 sop:1; + u32 eop:1; + u32 meta:2; + u32 byte_offset:3; + u32 meta_data:7; + u32 data_len:16; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); + +struct tx_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 own:1; + u32 c:1; + u32 sop:1; + u32 eop:1; + u32 meta:2; + u32 byte_offset:3; + u32 meta_data:7; + u32 data_len:16; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); +#else +/* 2 DWs format descriptor */ +struct rx_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 data_len:16; + u32 meta_data:7; + u32 byte_offset:3; + u32 meta:2; + u32 eop:1; + u32 sop:1; + u32 c:1; + u32 own:1; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); + +struct tx_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 data_len:16; + u32 meta_data:7; + u32 byte_offset:3; + u32 meta:2; + u32 eop:1; + u32 sop:1; + u32 c:1; + u32 own:1; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); +#endif + +enum { + SOC_TO_EP = 0, + EP_TO_SOC, +}; + +static int dma_pkt_size = 1024; +static int dma_mode = SOC_TO_EP; +static int dma_burst = 16; +static int desc_num = 32; + +module_param(dma_pkt_size, int, 0); +MODULE_PARM_DESC(dma_pkt_size, "Single packet length"); + +module_param(dma_mode, int, 0); +MODULE_PARM_DESC(dma_mode, "mode 0 -- Soc->EP, mode 1-- EP->SoC"); + + +static void dma_ctrl_rst(struct dc_ep_dev *dev) +{ + ep_wr32_mask(ACA_PMU_DMA | ACA_PMU_EMA, 0, ACA_PMU_CTRL); + + udelay(10); + ep_wr32_mask(0, 1, DMA_CTRL); + udelay(10); + ep_wr32(0, DMA_CLC); +} + +static void dma_chan_rst(struct dc_ep_dev *dev, int cn) +{ + ep_wr32(cn, DMA_CS); + ep_wr32(0x2, DMA_CCTRL); + while (ep_rd32(DMA_CCTRL) & 0x01) + udelay(10); +} + +static void dma_port_cfg(struct dc_ep_dev *dev) +{ + u32 reg = 0; + + reg |= (DMA_TX_PORT_DEFAULT_WEIGHT << 12); + reg |= (DMA_ENDIAN_TYPE0 << 10); + reg |= (DMA_ENDIAN_TYPE0 << 8); + reg |= (DMA_PKT_DROP_DISABLE << 6); + reg |= 0x3; + ep_wr32(0, DMA_PS); + ep_wr32(reg, DMA_PCTRL); +} + +static void dma_byte_enable(struct dc_ep_dev *dev, int enable) +{ + if (enable) + ep_wr32_mask(0, BIT(9), DMA_CTRL); + else + ep_wr32_mask(BIT(9), 0, DMA_CTRL); +} + +static void dma_tx_ch_cfg(struct dc_ep_dev *dev, int ch, u32 desc_base, + u32 desc_phys, dma_addr_t data_base, int desc_num) +{ + int i; + struct tx_desc_2dw *tx_desc; + + for (i = 0; i < desc_num; i++) { + tx_desc = (struct tx_desc_2dw *) + (desc_base + (i * sizeof(*tx_desc))); + tx_desc->data_pointer = (((u32)(data_base + + (i * dma_pkt_size))) & 0xfffffff8); + tx_desc->status.word = 0; + tx_desc->status.field.byte_offset = 0; + tx_desc->status.field.data_len = dma_pkt_size; + + tx_desc->status.field.sop = 1; + tx_desc->status.field.eop = 1; + tx_desc->status.field.own = 1; + wmb(); + #if 0 + pr_info("Tx desc num %d word 0x%08x data pointer 0x%08x\n", + i, tx_desc->status.word, tx_desc->data_pointer); + #endif + } + ep_wr32(ch, DMA_CS); + ep_wr32(desc_phys, DMA_CDBA); + ep_wr32(desc_num, DMA_CDLEN); + ep_wr32(0, DMA_CIE); +} + +static void dma_rx_ch_cfg(struct dc_ep_dev *dev, int ch, u32 desc_base, + u32 desc_phys, dma_addr_t data_base, int desc_num) +{ + int i; + struct rx_desc_2dw *rx_desc; + + for (i = 0; i < desc_num; i++) { + rx_desc = (struct rx_desc_2dw *)(desc_base + + (i * sizeof(*rx_desc))); + rx_desc->data_pointer = (((u32)(data_base + + (i * dma_pkt_size))) & 0xfffffff8); + + rx_desc->status.word = 0; + rx_desc->status.field.sop = 1; + rx_desc->status.field.eop = 1; + rx_desc->status.field.byte_offset = 0; + rx_desc->status.field.data_len = dma_pkt_size; + rx_desc->status.field.own = 1; /* DMA own the descriptor */ + wmb(); + #if 0 + pr_info("Rx desc num %d word 0x%08x data pointer 0x%08x\n", + i, rx_desc->status.word, rx_desc->data_pointer); + #endif + } + + ep_wr32(ch, DMA_CS); + ep_wr32(desc_phys, DMA_CDBA); + ep_wr32(desc_num, DMA_CDLEN); + ep_wr32(0, DMA_CIE); +} + +static void dma_chan_on(struct dc_ep_dev *dev, u8 cn) +{ + ep_wr32(cn, DMA_CS); + ep_wr32_mask(0, BIT(0), DMA_CCTRL); +} + +static void dma_chan_off(struct dc_ep_dev *dev, u8 cn) +{ + ep_wr32(cn, DMA_CS); + ep_wr32_mask(BIT(0), 0, DMA_CCTRL); + udelay(10); +} + +#define DEFAULT_TEST_PATTEN 0x12345678 + +#define REG32(addr) (*((volatile u32*)(addr))) + +#ifdef CONFIG_CPU_BIG_ENDIAN +#define ___swab32(x) ((u32)( \ + (((u32)(x) & (u32)0x000000ffUL) << 24) | \ + (((u32)(x) & (u32)0x0000ff00UL) << 8) | \ + (((u32)(x) & (u32)0x00ff0000UL) >> 8) | \ + (((u32)(x) & (u32)0xff000000UL) >> 24))) +#else +#define ___swab32(x) (x) +#endif + +static void dma_sdram_preload(void *sdram_data_tx_ptr, void *sdram_data_rx_ptr) +{ + int i; + int j; + + u32 testaddr = (u32)sdram_data_tx_ptr; + + for (i = 0; i < desc_num; i++) { + for (j = 0; j < dma_pkt_size; j = j + 4) { + REG32(testaddr + i * dma_pkt_size + j) + = DEFAULT_TEST_PATTEN; + } + } + pr_info("SDR Preload(0x55aa00ff) with data on TX location done\n"); + + testaddr = (u32)sdram_data_rx_ptr; + pr_info("RX Preload start address:0x%08x\n", (u32)(testaddr)); + + for (i = 0; i < desc_num; i++) { + for (j = 0; j < roundup(dma_pkt_size, + dma_burst << 2); j = j + 4) + REG32(testaddr + i * dma_pkt_size + j) = 0xcccccccc; + } + pr_info("SDR locations for Memcopy RX preset to 0xcccccccc done\n"); +} + +static void memcopy_data_check(u32 rx_data_addr) +{ + int i, j; + u32 read_data; + + for (i = 0; i < desc_num; i++) { + for (j = 0; j < dma_pkt_size; j = j + 4) { + read_data = REG32(rx_data_addr + i * dma_pkt_size + j); + if (read_data != ___swab32(DEFAULT_TEST_PATTEN)) + pr_info("Memcopy ERROR at addr 0x%08x data 0x%08x\n", + (rx_data_addr + j), read_data); + } + } +} + +static u32 plat_throughput_calc(u32 payload, int cycles) +{ + return (u32)((payload * 300) / cycles); +} + +#define DMA_CPOLL_CNT_MASK 0xFFF0u + +static void dma_ctrl_global_polling_enable(struct dc_ep_dev *dev, int interval) +{ + u32 reg = 0; + + reg |= (1 << 31); + reg |= (interval << 4); + + ep_wr32_mask(DMA_CPOLL_CNT_MASK, + reg, DMA_CPOLL); +} + +static void dma_controller_cfg(struct dc_ep_dev *dev) +{ + ep_wr32_mask(0, BIT(31), DMA_CTRL); + ep_wr32_mask(BIT(30), 0, DMA_CTRL); + ep_wr32_mask(0, BIT(1), DMA_CTRL); + ep_wr32_mask(0, BIT(13), DMA_CTRL); +} + +#define PDRAM_OFFSET 0x200200 +#define PDRAM_TX_DESC_OFFSET 0x200000 +#define PDRAM_RX_DESC_OFFSET 0x200100 +#define ACA_SRAM_OFFSET 0x100000 +#define PPE_SB_TX_DESC_OFFSET 0x280000 +#define PPE_SB_RX_DESC_OFFSET 0x281000 + +#define PPE_FPI_TX_DESC_OFFSET 0x320000 +#define PPE_FPI_RX_DESC_OFFSET 0x321000 + +static void dma_test(struct dc_ep_dev *dev, int mode, int rcn, int tcn) +{ + u32 loop = 0; + void *tx_data; + void *rx_data; + dma_addr_t tx_data_phys = 0; + dma_addr_t rx_data_phys = 0; + u32 start, end; + u32 cycles; + struct rx_desc_2dw *rx_desc; + struct tx_desc_2dw *tx_desc; + struct tx_desc_2dw *last_tx_desc; + struct rx_desc_2dw *last_rx_desc; + dma_addr_t tx_desc_phys; + dma_addr_t rx_desc_phys; + u32 membase = (u32)(dev->membase); + + rx_desc = (struct rx_desc_2dw *)(membase + PDRAM_RX_DESC_OFFSET); + rx_desc_phys = (dev->phy_membase + PDRAM_RX_DESC_OFFSET); + tx_desc = (struct tx_desc_2dw *)(membase + PDRAM_TX_DESC_OFFSET); + tx_desc_phys = (dev->phy_membase + PDRAM_TX_DESC_OFFSET); + last_rx_desc = rx_desc + (desc_num - 1); + last_tx_desc = tx_desc + (desc_num - 1); + + if (mode == SOC_TO_EP) { /* Read from SoC DDR to local PDBRAM */ + tx_data = dma_alloc_coherent(NULL, + desc_num * dma_pkt_size, &tx_data_phys, GFP_DMA); + rx_data_phys = (dma_addr_t)(dev->phy_membase + PDRAM_OFFSET); + rx_data = (void *)(membase + PDRAM_OFFSET); + } else { /* Write from local PDBRAM to remote DDR */ + tx_data_phys = (dma_addr_t)(dev->phy_membase + PDRAM_OFFSET); + tx_data = (void *)(membase + PDRAM_OFFSET); + rx_data = dma_alloc_coherent(NULL, desc_num * dma_pkt_size, + &rx_data_phys, GFP_DMA); + } + + pr_info("tx_desc_base %p tx_desc_phys 0x%08x tx_data %p tx_data_phys 0x%08x\n", + tx_desc, (u32)tx_desc_phys, tx_data, (u32)tx_data_phys); + + pr_info("rx_desc_base %p rx_desc_phys 0x%08x rx_data %p rx_data_phys 0x%08x\n", + rx_desc, (u32)rx_desc_phys, rx_data, (u32)rx_data_phys); + + pr_info("dma burst %d desc number %d packet size %d\n", + dma_burst, desc_num, dma_pkt_size); + + dma_ctrl_rst(dev); + dma_chan_rst(dev, rcn); + dma_chan_rst(dev, tcn); + dma_port_cfg(dev); + dma_controller_cfg(dev); + dma_byte_enable(dev, 1); + + dma_ctrl_global_polling_enable(dev, 24); + + dma_sdram_preload(tx_data, rx_data); + + dma_tx_ch_cfg(dev, tcn, (u32)tx_desc, tx_desc_phys, + tx_data_phys, desc_num); + dma_rx_ch_cfg(dev, rcn, (u32)rx_desc, rx_desc_phys, + rx_data_phys, desc_num); + + udelay(5); /* Make sure that RX descriptor prefetched */ + + start = get_cycles(); + dma_chan_on(dev, rcn); + dma_chan_on(dev, tcn); + + /* wait till tx chan desc own is 0 */ + while (last_tx_desc->status.field.own == 1) { + loop++; + udelay(1); + } + end = get_cycles(); + cycles = end - start; + pr_info("cylces %d throughput %dMb\n", cycles, + plat_throughput_calc(desc_num * dma_pkt_size * 8, cycles)); + pr_info("loop times %d\n", loop); + while (last_rx_desc->status.field.own == 1) { + loop++; + udelay(1); + } + + memcopy_data_check((u32)rx_data); + dma_chan_off(dev, rcn); + dma_chan_off(dev, tcn); + if (mode == SOC_TO_EP) { + dma_free_coherent(NULL, desc_num * dma_pkt_size, + tx_data, tx_data_phys); + } else { + dma_free_coherent(NULL, desc_num * dma_pkt_size, + rx_data, rx_data_phys); + } +} + +static int aca_soc_desc_alloc(int dev) +{ + dma_addr_t phy_addr; + void *base; + u32 size; + + if (dev < 0 || dev > (DC_EP_MAX_PEER + 1)) + return -EINVAL; + + /* TXIN */ + size = TXIN_SOC_DES_NUM * TXIN_HD_DES_SIZE * 4; + base = dma_alloc_coherent(NULL, size, &phy_addr, GFP_DMA); + if (!base) + goto txin; + aca_soc_hd_desc[dev].txin.base = base; + aca_soc_hd_desc[dev].txin.phy_base = phy_addr; + aca_soc_hd_desc[dev].txin.size = size; + pr_info("txin soc desc base %p phy 0x%08x size 0x%08x\n", + base, (u32)phy_addr, size); + + /* TXOUT */ + size = TXOUT_SOC_DES_NUM * TXOUT_HD_DES_SIZE * 4; + base = dma_alloc_coherent(NULL, size, &phy_addr, GFP_DMA); + if (!base) + goto txout; + aca_soc_hd_desc[dev].txout.base = base; + aca_soc_hd_desc[dev].txout.phy_base = phy_addr; + aca_soc_hd_desc[dev].txout.size = size; + pr_info("txout soc desc base %p phy 0x%08x size 0x%08x\n", + base, (u32)phy_addr, size); + /* RXOUT */ + size = RXOUT_SOC_DES_NUM * RXOUT_HD_DES_SIZE * 4; + base = dma_alloc_coherent(NULL, size, &phy_addr, GFP_DMA); + if (!base) + goto rxout; + aca_soc_hd_desc[dev].rxout.base = base; + aca_soc_hd_desc[dev].rxout.phy_base = phy_addr; + aca_soc_hd_desc[dev].rxout.size = size; + pr_info("rxout soc desc base %p phy 0x%08x size 0x%08x\n", + base, (u32)phy_addr, size); + return 0; +rxout: + dma_free_coherent(NULL, aca_soc_hd_desc[dev].txout.size, + aca_soc_hd_desc[dev].txout.base, + aca_soc_hd_desc[dev].txout.phy_base); +txout: + dma_free_coherent(NULL, aca_soc_hd_desc[dev].txin.size, + aca_soc_hd_desc[dev].txin.base, + aca_soc_hd_desc[dev].txin.phy_base); +txin: + return -ENOMEM; +} + +static int aca_soc_desc_free(int dev) +{ + dma_addr_t phy_addr; + void *base; + size_t size; + + if (dev < 0 || dev > (DC_EP_MAX_PEER + 1)) + return -EINVAL; + + /* TXIN */ + base = aca_soc_hd_desc[dev].txin.base; + phy_addr = aca_soc_hd_desc[dev].txin.phy_base; + size = aca_soc_hd_desc[dev].txin.size; + dma_free_coherent(NULL, size, base, phy_addr); + + /* TXOUT */ + base = aca_soc_hd_desc[dev].txout.base; + phy_addr = aca_soc_hd_desc[dev].txout.phy_base; + size = aca_soc_hd_desc[dev].txout.size; + dma_free_coherent(NULL, size, base, phy_addr); + + /* RXOUT */ + base = aca_soc_hd_desc[dev].rxout.base; + phy_addr = aca_soc_hd_desc[dev].rxout.phy_base; + size = aca_soc_hd_desc[dev].rxout.size; + dma_free_coherent(NULL, size, base, phy_addr); + return 0; +} + +static int __init dc_ep_test_init(void) +{ + int i, j; + int dev_num; + struct dc_ep_dev dev; + int func = 0; + u32 sysclk = 0; + u32 ppeclk = 0; + + if (dc_ep_dev_num_get(&dev_num)) { + pr_err("%s failed to get total device number\n", __func__); + return -EIO; + } + + pr_info("%s: total %d EPs found\n", __func__, dev_num); + + for (i = 0; i < dev_num; i++) + aca_soc_desc_alloc(i); + + for (i = 0; i < dev_num; i++) { + struct aca_param aca_cfg = { + .aca_txin = { + .soc_desc_base + = aca_soc_hd_desc[i].txin.phy_base, + .soc_desc_num = TXIN_SOC_DES_NUM, + .pp_buf_desc_num = 32, + .pd_desc_base = TXIN_PD_DBASE, + .pd_desc_num = TXIN_PD_DES_NUM, + .hd_size_in_dw = TXIN_HD_DES_SIZE, + .pd_size_in_dw = TXIN_PD_DES_SIZE, + .byteswap = 1, + }, + .aca_txout = { + .soc_desc_base + = aca_soc_hd_desc[i].txout.phy_base, + .soc_desc_num = TXOUT_SOC_DES_NUM, + .pp_buf_desc_num = 32, + .pd_desc_base = TXOUT_PD_DBASE, + .pd_desc_num = TXOUT_PD_DES_NUM, + .hd_size_in_dw = TXOUT_HD_DES_SIZE, + .pd_size_in_dw = TXOUT_PD_DES_SIZE, + .byteswap = 1, + }, + .aca_rxout = { + .soc_desc_base + = aca_soc_hd_desc[i].rxout.phy_base, + .soc_desc_num = RXOUT_SOC_DES_NUM, + .pp_buf_desc_num = 32, + .pd_desc_base = RXOUT_PD_DBASE, + .pd_desc_num = RXOUT_PD_DES_NUM, + .hd_size_in_dw = RXOUT_HD_DES_SIZE, + .pd_size_in_dw = RXOUT_PD_DES_SIZE, + .byteswap = 1, + }, + }; + struct aca_modem_param modem_cfg = { + .mdm_txout = { + .stat = SB_XBAR_ADDR(__TX_OUT_ACA_ACCUM_STATUS), + .pd = SB_XBAR_ADDR(__TX_OUT_QUEUE_PD_BASE_ADDR_OFFSET), + .acc_cnt = SB_XBAR_ADDR(__TX_OUT_ACA_ACCUM_COUNT), + }, + .mdm_rxout = { + .stat = SB_XBAR_ADDR(__RX_OUT_ACA_ACCUM_STATUS), + .pd = SB_XBAR_ADDR(__RX_OUT_QUEUE_PD_BASE_ADDR_OFFSET), + .acc_cnt = SB_XBAR_ADDR(__RX_OUT_ACA_ACCUM_COUNT), + }, + .mdm_rxin = { + .stat = SB_XBAR_ADDR(__RX_IN_ACA_ACCUM_STATUS), + .pd = SB_XBAR_ADDR(__RX_IN_QUEUE_PD_BASE_ADDR_OFFSET), + .acc_cnt = SB_XBAR_ADDR(__RX_IN_ACA_ACCUM_COUNT), + }, + }; + if (dc_ep_dev_info_req(i, DC_EP_INT_PPE, &dev)) + pr_info("%s failed to get pcie ep %d information\n", + __func__, i); + pr_info("irq %d\n", dev.irq); + pr_info("phyiscal membase 0x%08x virtual membase 0x%p\n", + dev.phy_membase, dev.membase); + if (dev_num > 1) { + for (j = 0; j < dev.peer_num; j++) { + pr_info("phyiscal peer membase 0x%08x virtual peer membase 0x%p\n", + dev.peer_phy_membase[j], dev.peer_membase[j]); + } + } + /* For module unload perpose */ + memcpy(&pcie_dev[i], &dev, sizeof(struct dc_ep_dev)); + dc_ep_ppe_mbox_int_stress_test(&pcie_dev[i]); + dev.hw_ops->clk_on(&dev, PMU_CDMA | PMU_EMA | PMU_PPM2); + dev.hw_ops->clk_set(&dev, SYS_CLK_288MHZ, PPE_CLK_576MHZ); + dev.hw_ops->pinmux_set(&dev, 14, MUX_FUNC_ALT1); + dev.hw_ops->pinmux_set(&dev, 15, MUX_FUNC_ALT2); + dev.hw_ops->pinmux_get(&dev, 15, &func); + pr_info("gpio 15 func %d\n", func); + dev.hw_ops->pinmux_set(&dev, 13, MUX_FUNC_GPIO); + dev.hw_ops->gpio_dir(&dev, 13, GPIO_DIR_OUT); + dev.hw_ops->gpio_set(&dev, 13, 1); + dev.hw_ops->gpio_get(&dev, 13, &func); + pr_info("gpio 13 value %d\n", func); + dev.hw_ops->gpio_pupd_set(&dev, 14, GPIO_PULL_DOWN); + dev.hw_ops->gpio_od_set(&dev, 0, 1); + dev.hw_ops->gpio_src_set(&dev, 0, GPIO_SLEW_RATE_FAST); + dev.hw_ops->gpio_dcc_set(&dev, 0, GPIO_DRV_CUR_8MA); + dev.hw_ops->clk_get(&dev, &sysclk, &ppeclk); + pr_info("ppe clk %s sys clk %s\n", ppeclk_str[ppeclk], + sysclk_str[sysclk]); + dev.hw_ops->aca_init(&dev, &aca_cfg, &modem_cfg); + dev.hw_ops->aca_start(&dev, ACA_ALL_EN, 1); + + pr_info("ACA test\n"); + dc_aca_test_init(&dev, aca_soc_hd_desc[i].txin.base); + + pr_info("DMA test\n"); + dma_pkt_size = 64; + dma_test(&dev, dma_mode, 0, 1); +#if 0 + dma_pkt_size = 128; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 256; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 512; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 1024; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 2048; + dma_test(&dev, dma_mode, 0, 1); + + dma_mode = EP_TO_SOC; + dma_pkt_size = 64; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 128; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 256; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 512; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 1024; + dma_test(&dev, dma_mode, 0, 1); + dma_pkt_size = 2048; + dma_test(&dev, dma_mode, 0, 1); +#endif + } + + pr_info("Intel(R) SmartPHY DSL(VRX518) PCIe EP Test Driver - %s\n", + ep_test_driver_version); + return 0; +} + +static void __exit dc_ep_test_exit(void) +{ + int i; + int dev_num; + u32 func = ACA_ALL_EN; + struct dc_ep_dev *dev; + + if (dc_ep_dev_num_get(&dev_num)) { + pr_err("%s failed to get total device number\n", __func__); + return; + } + pr_info("%s: total %d EPs found\n", __func__, dev_num); + for (i = 0; i < dev_num; i++) { + dev = &pcie_dev[i]; + free_irq(dev->irq, dev); + dev->hw_ops->aca_stop(dev, &func, 1); + dev->hw_ops->clk_off(dev, PMU_EMA); + if (dc_ep_dev_info_release(i)) { + pr_info("%s failed to release pcie ep %d information\n", + __func__, i); + } + aca_soc_desc_free(i); + } +} + +module_init(dc_ep_test_init); +module_exit(dc_ep_test_exit); + +MODULE_AUTHOR("Intel Corporation, <Chuanhua.lei@intel.com>"); +MODULE_DESCRIPTION("Intel(R) SmartPHY (VRX518) PCIe EP/ACA test driver"); +MODULE_LICENSE("GPL"); diff --git a/package/kernel/lantiq/vrx518_ep/src/test/ep_test.h b/package/kernel/lantiq/vrx518_ep/src/test/ep_test.h new file mode 100644 index 00000000000..ef2b847bb26 --- /dev/null +++ b/package/kernel/lantiq/vrx518_ep/src/test/ep_test.h @@ -0,0 +1,273 @@ +/******************************************************************************* + + Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver + Copyright(c) 2016 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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., + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + +*******************************************************************************/ + +#ifndef EP_TEST_H +#define EP_TEST_H + +/* SB address on xBar */ +#define SB_XBAR_BASE 0x280000 +#define SB_XBAR_DES_RXBASE SB_XBAR_BASE +#define SB_XBAR_DES_TXBASE (SB_XBAR_BASE + 0x400) +#define SB_XBAR_DATA_BASE (SB_XBAR_BASE + 0x800) +#define SB_XBAR_ADDR(x) (SB_XBAR_BASE + ((((x) - 0xA000)) << 2)) + +/*---------------------------------------------------------- + * ACA Shadow Registers + * 3 * 4 = 12 + * *_STATUS need to be initialized to nonzero by PPE driver + *---------------------------------------------------------- + */ + +#define __ACA_SHADOW_REG_BASE 0xADF0 + +#define __TX_IN_ACA_ACCUM_COUNT 0xADF0 + +#define __TX_IN_ACA_ACCUM_STATUS 0xADF1 + +#define __TX_IN_QUEUE_PD_BASE_ADDR_OFFSET 0xADF2 + +#define __TX_OUT_ACA_ACCUM_COUNT 0xADF3 + +#define __TX_OUT_ACA_ACCUM_STATUS 0xADF4 + +#define __TX_OUT_QUEUE_PD_BASE_ADDR_OFFSET 0xADF5 + +#define __RX_IN_ACA_ACCUM_COUNT 0xADF6 + +#define __RX_IN_ACA_ACCUM_STATUS 0xADF7 + +#define __RX_IN_QUEUE_PD_BASE_ADDR_OFFSET 0xADF8 + +#define __RX_OUT_ACA_ACCUM_COUNT 0xADF9 + +#define __RX_OUT_ACA_ACCUM_STATUS 0xADFA + +#define __RX_OUT_QUEUE_PD_BASE_ADDR_OFFSET 0xADFB + +#define TXIN_PD_DES_NUM 64 +#define TXIN_PD_DBASE 0x105400 +#define TXIN_SOC_DES_NUM 32 +#define TXIN_SOC_DBASE 0x24000000 +#define TXIN_HOST_DES_NUM 32 +#define TXIN_HD_DES_SIZE 4 /* size in DWORD */ +#define TXIN_PD_DES_SIZE 2 /* size in DWORD */ + +#define TXOUT_PD_DES_NUM 32 +#define TXOUT_PD_DBASE 0x105700 +#define TXOUT_SOC_DES_NUM 32 +#define TXOUT_SOC_DBASE 0x24001000 +#define TXOUT_HOST_DES_NUM 32 +#define TXOUT_HD_DES_SIZE 1 /* size in DWORD */ +#define TXOUT_PD_DES_SIZE 2 /* size in DWORD */ + +#define RXOUT_PD_DES_NUM 32 +#define RXOUT_PD_DBASE 0x105C00 +#define RXOUT_SOC_DES_NUM 32 +#define RXOUT_SOC_DBASE 0x24002000 +#define RXOUT_HOST_DES_NUM 32 +#define RXOUT_HD_DES_SIZE 4 /* size in DWORD */ +#define RXOUT_PD_DES_SIZE 2 /* size in DWORD */ + +/* PPE interrupt */ +#define PPE_MBOX_TEST_BIT 0x1 +#define PPE_MBOX_IRQ_TEST_NUM 100 + +#define PPE_MBOX_BASE 0x334800 + +#define MBOX_REG(X) (PPE_MBOX_BASE + (X)) +#define MBOX_IGU0_ISRS MBOX_REG(0x0) +#define MBOX_IGU0_ISRC MBOX_REG(0x4) +#define MBOX_IGU0_ISR MBOX_REG(0x8) +#define MBOX_IGU0_IER MBOX_REG(0xc) + +#define HOST_IF_BASE 0x50000 +#define HOST_IF_REG(X) (HOST_IF_BASE + (X)) +#define TXIN_CONV_CFG HOST_IF_REG(0x14) +#define RXIN_HD_ACCUM_ADD HOST_IF_REG(0xC8) /* UMT Message trigger */ +#define TXIN_HD_ACCUM_ADD HOST_IF_REG(0xCC) /* UMT Message trigger */ +#define RXOUT_ACA_ACCUM_ADD HOST_IF_REG(0xE0) /* PPE FW tigger */ +#define TXOUT_ACA_ACCUM_ADD HOST_IF_REG(0xE4) /* PPE FW tigger */ + +#define CDMA_BASE 0x2D0000 +#define CDMA_REG(X) (CDMA_BASE + (X)) + +#define DMA_CLC CDMA_REG(0x00) +#define DMA_ID CDMA_REG(0x08) +#define DMA_CTRL CDMA_REG(0x10) + +#define DMA_CTRL_RST BIT(0) +#define DMA_CTRL_DSRAM_PATH BIT(1) +#define DMA_CTRL_CH_FL BIT(6) +#define DMA_CTRL_DS_FOD BIT(7) +#define DMA_CTRL_DRB BIT(8) +#define DMA_CTRL_ENBE BIT(9) +#define DMA_CTRL_PRELOAD_INT_S 10 +#define DMA_CTRL_PRELOAD_INT 0x0C00u +#define DMA_CTRL_PRELOAD_EN BIT(12) +#define DMA_CTRL_MBRST_CNT_S 16 +#define DMA_CTRL_MBRST_CNT 0x3FF0000u +#define DMA_CTRL_MBRSTARB BIT(30) +#define DMA_CTRL_PKTARB BIT(31) + +#define DMA_CPOLL CDMA_REG(0x14) +#define DMA_CPOLL_CNT_S 4 +#define DMA_CPOLL_CNT 0xFFF0u +#define DMA_CPOLL_EN BIT(31) + +#define DMA_CS CDMA_REG(0x18) +#define DMA_CCTRL CDMA_REG(0x1C) +#define DMA_CCTRL_ON BIT(0) +#define DMA_CCTRL_RST BIT(1) +#define DMA_CCTRL_DIR_TX BIT(8) +#define DMA_CCTRL_CLASS_S 9 +#define DMA_CCTRL_CLASS 0xE00u +#define DMA_CCTRL_PRTNR_S 12 +#define DMA_CCTRL_PRTNR 0xF000u +#define DMA_CCTRL_TXWGT_S 16 +#define DMA_CCTRL_TXWGT 0x30000u +#define DMA_CCTRL_CLASSH_S 18 +#define DMA_CCTRL_CLASSH 0xC0000u +#define DMA_CCTRL_PDEN BIT(23) +#define DMA_CCTRL_P2PCPY BIT(24) +#define DMA_CCTRL_LBEN BIT(25) +#define DMA_CCTRL_LBCHNR_S 26 +#define DMA_CCTRL_LBCHNR 0xFC000000u + +#define DMA_CDBA CDMA_REG(0x20) +#define DMA_CDLEN CDMA_REG(0x24) +#define DMA_CIS CDMA_REG(0x28) +#define DMA_CIE CDMA_REG(0x2C) + +#define DMA_CI_EOP BIT(1) +#define DMA_CI_DUR BIT(2) +#define DMA_CI_DESCPT BIT(3) +#define DMA_CI_CHOFF BIT(4) +#define DMA_CI_RDERR BIT(5) +#define DMA_CI_ALL (DMA_CI_EOP | DMA_CI_DUR | DMA_CI_DESCPT\ + | DMA_CI_CHOFF | DMA_CI_RDERR) + +#define DMA_CI_DEFAULT (DMA_CI_EOP | DMA_CI_DESCPT) +#define DMA_CDPTNRD CDMA_REG(0x34) + +#define DMA_PS CDMA_REG(0x40) +#define DMA_PCTRL CDMA_REG(0x44) +#define DMA_PCTRL_RXBL16 BIT(0) +#define DMA_PCTRL_TXBL16 BIT(1) +#define DMA_PCTRL_RXBL_S 2 +#define DMA_PCTRL_RXBL 0xCu +#define DMA_PCTRL_TXBL_S 4 +#define DMA_PCTRL_TXBL 0x30u +#define DMA_PCTRL_PDEN BIT(6) +#define DMA_PCTRL_PDEN_S 6 +#define DMA_PCTRL_RXENDI_S 8 +#define DMA_PCTRL_RXENDI 0x300u +#define DMA_PCTRL_TXENDI_S 10 +#define DMA_PCTRL_TXENDI 0xC00u +#define DMA_PCTRL_TXWGT_S 12 +#define DMA_PCTRL_TXWGT 0x7000u +#define DMA_PCTRL_MEM_FLUSH BIT(16) + +#define DMA_IRNEN CDMA_REG(0xF4) +#define DMA_IRNCR CDMA_REG(0xF8) +#define DMA_IRNICR CDMA_REG(0xFC) + +#ifdef CONFIG_CPU_BIG_ENDIAN +struct aca_dma_desc { + /* DW0 */ + u32 dw0; + /* DW1 */ + u32 dw1; + /* DW2 */ + u32 data_pointer; + /* DW3 */ + u32 own:1; + u32 c:1; + u32 sop:1; + u32 eop:1; + u32 dic:1; + u32 pdu_type:1; + u32 byte_off:3; + u32 qid:4; + u32 mpoa_pt:1; + u32 mpoa_mode:2; + u32 data_len:16; +}__packed __aligned(16); + +/* 2 DWs format descriptor */ +struct aca_dma_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 own:1; + u32 c:1; + u32 sop:1; + u32 eop:1; + u32 meta_data0:2; + u32 byte_offset:3; + u32 meta_data1:7; + u32 data_len:16; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); +#else +struct aca_dma_desc { + /* DW0 */ + u32 dw0; + /* DW1 */ + u32 dw1; + /* DW2 */ + u32 data_pointer; + /* DW 3 */ + u32 data_len:16; + u32 mpoa_mode:2; + u32 mpoa_pt:1; + u32 qid:4; + u32 byte_off:3; + u32 pdu_type:1; + u32 dic:1; + u32 eop:1; + u32 sop:1; + u32 c:1; + u32 own:1; +}__packed __aligned(16); + +/* 2 DWs format descriptor */ +struct aca_dma_desc_2dw { + u32 data_pointer; /* Descriptor data pointer */ + union { + struct { + u32 data_len:16; + u32 meta_data1:7; + u32 byte_offset:3; + u32 meta_data0:2; + u32 eop:1; + u32 sop:1; + u32 c:1; + u32 own:1; + } __packed field; + u32 word; + } __packed status; +} __packed __aligned(8); +#endif +#endif /* EP_TEST_H */ diff --git a/package/kernel/lantiq/vrx518_tc/Makefile b/package/kernel/lantiq/vrx518_tc/Makefile new file mode 100644 index 00000000000..b05fb4bb637 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/Makefile @@ -0,0 +1,74 @@ +# +# Copyright (C) 2019 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:=vrx518_tc +PKG_VERSION:=1.5.12.4 +PKG_RELEASE:=3 +PKG_BASE_NAME:=vrx518_tc_drv + +UGW_VERSION=8.5.2.10 +UGW_BASENAME=$(PKG_BASE_NAME)-ugw_$(UGW_VERSION) + +PKG_SOURCE:=$(UGW_BASENAME).tar.bz2 +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/$(PKG_BASE_NAME)/-/archive/ugw_$(UGW_VERSION)/ +PKG_HASH:=0c5bb0f9a06dc4cc4bbb8b930d01a673daba1b66615e8328818356d32c8f1548 +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(UGW_BASENAME) +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +PLAT_DIR:=dcdp +PKG_EXTMOD_SUBDIRS:=$(PLAT_DIR) + +# TODO this driver depends on the vrx518 ppe firmware, add this dependency if +# that ever gets a compatible license +define KernelPackage/$(PKG_NAME) + SECTION:=sys + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=VRX518 TC driver + KCONFIG:= \ + CONFIG_ATM_LANE=m \ + CONFIG_ATM_MPOA=m \ + CONFIG_ATM_MPOA_INTEL_DSL_PHY_SUPPORT=y + DEPENDS:=@TARGET_ipq40xx +kmod-vrx518_ep +kmod-crypto-md5 +kmod-atm +kmod-ipoa +br2684ctl + AUTOLOAD:=$(call AutoLoad,27,vrx518_tc) + FILES:=$(PKG_BUILD_DIR)/$(PLAT_DIR)/$(PKG_NAME).ko +endef + +define KernelPackage/$(PKG_NAME)/description + VRX518 TC Driver +endef + +define Build/Prepare + $(PKG_UNPACK) + # eliminate all carriage returns / convert to unix encoding + (cd $(PKG_BUILD_DIR) && find . -type f -exec sed -i 's/\r//g' {} +) + $(Build/Patch) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/net/ + $(CP) $(PKG_BUILD_DIR)/$(PLAT_DIR)/inc/dsl_tc.h $(1)/usr/include/net/ +endef + +EXTRA_CFLAGS:= \ + -I$(STAGING_DIR)/usr/include + +define Build/Compile + $(KERNEL_MAKE) \ + M="$(PKG_BUILD_DIR)/$(PLAT_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + FEATURE_VRX518_CPU=y \ + modules +endef + +$(eval $(call KernelPackage,$(PKG_NAME))) diff --git a/package/kernel/lantiq/vrx518_tc/patches/100-compat.patch b/package/kernel/lantiq/vrx518_tc/patches/100-compat.patch new file mode 100644 index 00000000000..d04c1ed5df0 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/100-compat.patch @@ -0,0 +1,917 @@ +--- a/dcdp/atm_tc.c ++++ b/dcdp/atm_tc.c +@@ -44,9 +44,9 @@ + #include <linux/atmioc.h> + #include <linux/skbuff.h> + #include "inc/dsl_tc.h" +-#include <net/datapath_proc_api.h> ++// #include <net/datapath_proc_api.h> + #include <linux/atm.h> +-#include <net/datapath_api.h> ++// #include <net/datapath_api.h> + #include <net/dc_ep.h> + #include<linux/sched.h> + #include<linux/kthread.h> +@@ -730,20 +730,16 @@ static void atm_aca_init(struct atm_priv + ACA_TXOUT_EN | ACA_RXIN_EN | ACA_RXOUT_EN, 1); + } + +-static int print_datetime(char *buffer, const struct timespec *datetime) ++static int print_datetime(char *buffer, const struct timespec64 *datetime) + { +- struct timeval tv; + struct tm nowtm; + char tmbuf[64]; +- s64 nsec; + + if (buffer == NULL || datetime == NULL) { + pr_err("%s : Invalid arguments\n", __func__); + return -1; + } +- nsec = timespec_to_ns(datetime); +- tv = ns_to_timeval(nsec); +- time_to_tm(tv.tv_sec, 0, &nowtm); ++ time64_to_tm(datetime->tv_sec, 0, &nowtm); + memset(tmbuf, 0, 64); + + snprintf(tmbuf, sizeof(tmbuf), "%ld-%d-%d %d:%d:%d", +@@ -753,7 +749,7 @@ static int print_datetime(char *buffer, + nowtm.tm_hour, + nowtm.tm_min, + nowtm.tm_sec); +- snprintf(buffer, sizeof(buffer), "%s.%06d", tmbuf, (int)tv.tv_usec); ++ snprintf(buffer, sizeof(buffer), "%s.%06d", tmbuf, (int)datetime->tv_nsec / 1000); + + return 0; + } +@@ -1313,7 +1309,7 @@ static int ppe_send(struct atm_vcc *vcc, + /* assume LLC header + Ethernet ID: 6+2 */ + if ((priv->conn[conn].mpoa_type == MPOA_TYPE_EOA_WO_FCS) || + (priv->conn[conn].mpoa_type == MPOA_TYPE_EOA_W_FCS)) { +- if (__skb_put_padto(skb, ETH_ZLEN + 8)) ++ if (__skb_put_padto(skb, ETH_ZLEN + 8, false)) + goto CHECK_SHOWTIME_FAIL; + } + +@@ -1418,7 +1414,7 @@ int ppe_send_oam(struct atm_vcc *vcc, vo + struct atm_priv *priv = g_atm_tc; + struct sk_buff *skb; + unsigned int conn; +- dp_subif_t dp_id; ++// dp_subif_t dp_id; + #ifdef OAM_FIX_GRX750 + unsigned char *dest_cell; + #endif +@@ -1465,8 +1461,8 @@ int ppe_send_oam(struct atm_vcc *vcc, vo + priv->tc_priv->param.oam_prio = 0; + qid = priv->conn[conn].prio_queue_map[priv->tc_priv->param.oam_prio]; + vid = priv->conn[conn].subif_id; +- dp_id.subif = (vid & (~0x7f)) | +- ATM_DESC_SUBIF_ID(qid, mpoa_pt, mpoa_type); ++// dp_id.subif = (vid & (~0x7f)) | ++// ATM_DESC_SUBIF_ID(qid, mpoa_pt, mpoa_type); + #ifdef OAM_FIX_GRX750 + dest_cell = kmalloc(CELL_SIZE, GFP_KERNEL); + if (dest_cell == NULL) { +@@ -1494,18 +1490,18 @@ int ppe_send_oam(struct atm_vcc *vcc, vo + #else + memcpy(skb->data, cell, CELL_SIZE); + #endif +- /* SET SUBIFID */ +- skb->DW0 = (skb->DW0 & ~0x7FFF) | dp_id.subif; +- skb->dev = priv->conn[conn].dev; +- tc_dbg(priv->tc_priv, MSG_TX, "conn: %d, dev name: %s, qid: 0x%x len:%d\n", +- conn, skb->dev->name, dp_id.subif, skb->len); +- #ifdef OAM_FIX_GRX750 +- if (priv->tc_priv->tc_ops.send(NULL, +- skb, dp_id.subif, ATM_OAM_PKT) == 0) { +- #else ++// /* SET SUBIFID */ ++// skb->DW0 = (skb->DW0 & ~0x7FFF) | dp_id.subif; ++// skb->dev = priv->conn[conn].dev; ++// tc_dbg(priv->tc_priv, MSG_TX, "conn: %d, dev name: %s, qid: 0x%x len:%d\n", ++// conn, skb->dev->name, dp_id.subif, skb->len); ++// #ifdef OAM_FIX_GRX750 ++// if (priv->tc_priv->tc_ops.send(NULL, ++// skb, dp_id.subif, ATM_OAM_PKT) == 0) { ++// #else + if (priv->tc_priv->tc_ops.send(NULL, + skb, qid, ATM_OAM_PKT) == 0) { +- #endif ++// #endif + priv->stats.oam_tx_pkts++; + priv->stats.oam_tx_bytes += skb->len; + priv->conn[conn].stats.oam_tx_pkts++; +@@ -1604,7 +1600,7 @@ static void oam_push(struct atm_priv *pr + conn = -1; /* invalid */ + if (conn_valid(conn) && priv->conn[conn].vcc != NULL) { + vcc = priv->conn[conn].vcc; +- priv->conn[conn].access_time = current_kernel_time(); ++ ktime_get_coarse_ts64(&priv->conn[conn].access_time); + + tc_dbg(priv->tc_priv, MSG_OAM_RX, "conn=%d, vpi: %d, vci:%d\n", + conn, header->vpi, header->vci); +@@ -2547,30 +2543,29 @@ static void ppe_atm_fw_hw_init(struct at + static int atm_dev_init(struct atm_priv *atm_priv, int ep_id) + { + int i, err; +- struct atm_dev *dev; +- dev = atm_dev_register(g_atm_dev_name, +- atm_priv->tc_priv->ep_dev[ep_id].dev, +- &g_ppe_atm_ops, -1, NULL); +- if (!dev) { +- err = -EIO; +- goto ATM_DEV_REGISTER_FAIL; +- } +- dev->ci_range.vpi_bits = 8; +- dev->ci_range.vci_bits = 16; +- /* assume 3200 cell rate +- * before get real information +- */ +- dev->link_rate = +- DEFAULT_CELL_RATE; +- dev->dev_data = atm_priv; +- dev->phy_data = +- (void *)(unsigned long)0; + + for (i = 0; i < ATM_PORT_NUMBER; i++) { + if (atm_priv->port[i].dev) + continue; + atm_priv->port[i].tx_max_cell_rate = DEFAULT_CELL_RATE; +- atm_priv->port[i].dev = dev; ++ atm_priv->port[i].dev = atm_dev_register(g_atm_dev_name, ++ atm_priv->tc_priv->ep_dev[ep_id].dev, ++ &g_ppe_atm_ops, -1, NULL); ++ if (!atm_priv->port[i].dev) { ++ err = -EIO; ++ goto ATM_DEV_REGISTER_FAIL; ++ } else { ++ atm_priv->port[i].dev->ci_range.vpi_bits = 8; ++ atm_priv->port[i].dev->ci_range.vci_bits = 16; ++ /* assume 3200 cell rate ++ * before get real information ++ */ ++ atm_priv->port[i].dev->link_rate = ++ DEFAULT_CELL_RATE; ++ atm_priv->port[i].dev->dev_data = atm_priv; ++ atm_priv->port[i].dev->phy_data = ++ (void *)(unsigned long)i; ++ } + } + //TODO : check for SoC PMAC, current fix + #ifdef CONFIG_SOC_TYPE_XWAY +@@ -2985,7 +2980,8 @@ static unsigned int atm_get_pvc_id(struc + return -EINVAL; + } + +- return (skb->DW0 >> 3) & 0xF; ++// return (skb->DW0 >> 3) & 0xF; ++ return 1; + } + + static int atm_get_qid_by_vcc(struct net_device *dev, struct sk_buff *skb, +@@ -3292,7 +3288,7 @@ static void atm_push(struct net_device * + += skb->len; + } else + priv->stats.aal5_rx_errors++; +- priv->conn[conn].access_time = current_kernel_time(); ++ ktime_get_coarse_ts64(&priv->conn[conn].access_time); + spin_unlock_bh(&priv->atm_lock); + + vcc->push(vcc, skb); +--- a/dcdp/inc/atm_tc.h ++++ b/dcdp/inc/atm_tc.h +@@ -449,7 +449,7 @@ struct atm_port { + struct atm_pvc { + struct atm_vcc *vcc; /* opened VCC */ + struct net_device *dev; /* net device associated with atm VCC */ +- struct timespec access_time; /* time when last user cell arrived */ ++ struct timespec64 access_time; /* time when last user cell arrived */ + int prio_queue_map[ATM_PRIO_Q_NUM]; + unsigned int prio_tx_packets[ATM_PRIO_Q_NUM]; + struct atm_stats stats; +--- a/dcdp/inc/tc_api.h ++++ b/dcdp/inc/tc_api.h +@@ -196,19 +196,6 @@ static inline void aca_ring_addr_init(st + ring->aca_cnt_phyaddr = ep_dev->phy_membase + addr; + } + +-static inline int __skb_put_padto(struct sk_buff *skb, unsigned int len) +-{ +- unsigned int size = skb->len; +- +- if (unlikely(size < len)) { +- len -= size; +- if (skb_pad(skb, len)) +- return -ENOMEM; +- __skb_put(skb, len); +- } +- return 0; +-} +- + extern int showtime_stat(struct tc_priv *); + extern void dump_skb_info(struct tc_priv *, struct sk_buff *, u32); + extern void *tc_buf_alloc(void *, size_t, u32 *, +--- a/dcdp/inc/tc_proc.h ++++ b/dcdp/inc/tc_proc.h +@@ -23,6 +23,8 @@ + #ifndef __TC_PROC_H__ + #define __TC_PROC_H__ + ++#include <linux/version.h> ++ + #define TC_PROC_DIR "driver/vrx518" + #define TC_PROC_ATM_DIR "atm" + #define TC_PROC_PTM_DIR "ptm" +@@ -41,7 +43,7 @@ enum { + struct tc_proc_list { + char proc_name[32]; + umode_t mode; +- const struct file_operations *fops; ++ const struct proc_ops *fops; + int is_folder; + }; + +--- a/dcdp/ptm_tc.c ++++ b/dcdp/ptm_tc.c +@@ -39,7 +39,7 @@ + #include <linux/seq_file.h> + #include <linux/printk.h> + #include <linux/etherdevice.h> +-#include <net/datapath_proc_api.h> ++// #include <net/datapath_proc_api.h> + + #include "inc/tc_main.h" + #include "inc/reg_addr.h" +@@ -62,6 +62,9 @@ + #include "inc/fw/vrx518_addr_def.h" + #include "inc/fw/vrx518_ppe_fw.h" + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) ++#define PDE_DATA pde_data ++#endif + + static struct ptm_priv *g_ptm_priv; + static struct ptm_ep_priv g_ep_priv[BOND_MAX]; +@@ -84,6 +87,7 @@ static int ptm_erb_addr_get(const unsign + unsigned int *data_addr, unsigned int *desc_addr); + + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0)) + static inline void tc_ether_addr_copy(u8 *dst, const u8 *src) + { + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) +@@ -98,6 +102,7 @@ static inline void tc_ether_addr_copy(u8 + a[2] = b[2]; + #endif + } ++#endif + + static inline int is_ptm_sl(struct ptm_ep_priv *priv) + { +@@ -182,8 +187,8 @@ static int ptm_get_qid(struct net_device + return qid; + } + +-static struct rtnl_link_stats64 *ptm_get_stats(struct net_device *dev, +- struct rtnl_link_stats64 *storage) ++static void ptm_get_stats(struct net_device *dev, ++ struct rtnl_link_stats64 *storage) + { + struct ptm_priv *ptm_tc = netdev_priv(dev); + +@@ -191,8 +196,6 @@ static struct rtnl_link_stats64 *ptm_get + memcpy(storage, &ptm_tc->stats64, sizeof(ptm_tc->stats64)); + else + storage->tx_errors += ptm_tc->stats64.tx_errors; +- +- return storage; + } + + static int ptm_set_mac_address(struct net_device *dev, void *p) +@@ -204,12 +207,16 @@ static int ptm_set_mac_address(struct ne + return -EBUSY; + + tc_info(ptm_tc->tc_priv, MSG_EVENT, "ptm mac address update!\n"); ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) ++ eth_hw_addr_set(dev, addr->sa_data); ++#else + tc_ether_addr_copy(dev->dev_addr, addr->sa_data); ++#endif + + return 0; + } + +-static void ptm_tx_timeout(struct net_device *dev) ++static void ptm_tx_timeout(struct net_device *dev, unsigned int txqueue) + { + struct ptm_priv *ptm_tc = netdev_priv(dev); + +@@ -503,7 +510,7 @@ static int ptm_xmit(struct sk_buff *skb, + if (!showtime_stat(ptm_tc->tc_priv)) + goto PTM_XMIT_DROP; + +- if (__skb_put_padto(skb, ETH_ZLEN)) ++ if (__skb_put_padto(skb, ETH_ZLEN, false)) + goto PTM_XMIT_DROP; + + dump_skb_info(ptm_tc->tc_priv, skb, (MSG_TX | MSG_TXDATA)); +@@ -632,11 +639,8 @@ static int ptm_dev_init(struct tc_priv * + struct ptm_priv *ptm_tc; + const char macaddr[ETH_ALEN] + = {0xAC, 0x9A, 0x96, 0x11, 0x22, 0x33}; +-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) +- dev = alloc_netdev_mq(sizeof(*ptm_tc), "ptm%d", ptm_setup, 4); +-#else +- dev = alloc_netdev_mq(sizeof(*ptm_tc), "ptm%d", NET_NAME_ENUM, ptm_setup, 4); +-#endif ++ ++ dev = alloc_netdev_mq(sizeof(*ptm_tc), "dsl%d", NET_NAME_ENUM, ptm_setup, 4); + if (!dev) { + tc_dbg(tc_priv, MSG_INIT, "Cannot alloc net device\n"); + return -ENOMEM; +@@ -644,7 +648,11 @@ static int ptm_dev_init(struct tc_priv * + ptm_tc = netdev_priv(dev); + ptm_tc->dev = dev; + ptm_tc->tc_priv = tc_priv; ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) ++ eth_hw_addr_set(dev, macaddr); ++#else + tc_ether_addr_copy(dev->dev_addr, macaddr); ++#endif + spin_lock_init(&ptm_tc->ptm_lock); + memcpy(ptm_tc->outq_map, def_outq_map, sizeof(def_outq_map)); + SET_NETDEV_DEV(ptm_tc->dev, tc_priv->ep_dev[id].dev); +@@ -2103,7 +2111,6 @@ static int ptm_showtime_exit(const unsig + struct ptm_ep_priv *priv = tc_ep_priv(idx); + u32 stop = ACA_TXIN_EN; + struct dc_ep_dev *ep; +- int i = 0; + + tc_info(priv->tc_priv, MSG_EVENT, "Line[%d]: show time exit!\n", idx); + ep = priv->ep; +--- a/dcdp/tc_api.c ++++ b/dcdp/tc_api.c +@@ -52,18 +52,24 @@ static const char ppe_fw_name[] = "ppe_f + #define VRX518_PPE_FW_ID 0xB + #define MD5_LEN 16 + ++enum tc_multicast_groups { ++ TC_MCGRP, ++}; ++ ++/* TC message multicast group */ ++static const struct genl_multicast_group tc_ml_grps[] = { ++ [TC_MCGRP] = { .name = TC_MCAST_GRP_NAME, }, ++}; ++ + /* TC message genelink family */ + static struct genl_family tc_gnl_family = { +- .id = GENL_ID_GENERATE, /* To generate an id for the family*/ ++// .id = GENL_ID_GENERATE, /* To generate an id for the family*/ + .hdrsize = 0, + .name = TC_FAMILY_NAME, /*family name, used by userspace application*/ + .version = 1, /*version number */ + .maxattr = TC_A_MAX - 1, +-}; +- +-/* TC message multicast group */ +-static struct genl_multicast_group tc_ml_grp = { +- .name = TC_MCAST_GRP_NAME, ++ .mcgrps = tc_ml_grps, ++ .n_mcgrps = ARRAY_SIZE(tc_ml_grps), + }; + + /** +@@ -568,7 +574,8 @@ int tc_ntlk_msg_send(struct tc_priv *pri + nla_put_u32(skb, TC_A_LINENO, ln_no); + + genlmsg_end(skb, msg_head); +- ret = genlmsg_multicast(skb, pid, tc_ml_grp.id, GFP_KERNEL); ++ ret = genlmsg_multicast(&tc_gnl_family, skb, pid, TC_MCGRP, ++ GFP_KERNEL); + if (ret) { + tc_err(priv, MSG_EVENT, "Sent TC multicast message Fail!\n"); + goto err1; +@@ -590,21 +597,11 @@ int tc_gentlk_init(struct tc_priv *priv) + return ret; + } + +- ret = genl_register_mc_group(&tc_gnl_family, &tc_ml_grp); +- if (ret) { +- tc_err(priv, MSG_EVENT, "register mc group fail: %i, grp name: %s\n", +- ret, tc_ml_grp.name); +- genl_unregister_family(&tc_gnl_family); +- return ret; +- } +- + return 0; + } + + void tc_gentlk_exit(void) + { +- /* unregister mc groups */ +- genl_unregister_mc_group(&tc_gnl_family, &tc_ml_grp); + /*unregister the family*/ + genl_unregister_family(&tc_gnl_family); + } +@@ -666,7 +663,7 @@ void dump_skb_info(struct tc_priv *tcpri + (u32)skb->end, skb->len); + tc_dbg(tcpriv, type, + "skb: clone: %d, users: %d\n", +- skb->cloned, atomic_read(&skb->users)); ++ skb->cloned, refcount_read(&skb->users)); + tc_dbg(tcpriv, type, + "skb: nfrag: %d\n", skb_shinfo(skb)->nr_frags); + +@@ -936,7 +933,6 @@ static int fw_md5_check(struct tc_priv * + } + + desc->tfm = md5; +- desc->flags = 0; + + ret = crypto_shash_init(desc); + if (ret) { +--- a/dcdp/tc_proc.c ++++ b/dcdp/tc_proc.c +@@ -22,7 +22,9 @@ + *******************************************************************************/ + #include <linux/fs.h> + #include <linux/seq_file.h> +-#include <net/datapath_api.h> ++// #include <net/datapath_api.h> ++#include <linux/etherdevice.h> ++#include <linux/atmdev.h> + #include <net/genetlink.h> + #include <linux/time.h> + #include "inc/tc_main.h" +@@ -35,6 +37,10 @@ + #include "inc/platform.h" + #include "inc/dsl_tc.h" + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) ++#define PDE_DATA pde_data ++#endif ++ + #define ATM_HEADER_SIZE (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) + static char *dbg_flag_str[] = { + "rx", +@@ -353,7 +359,7 @@ static ssize_t mem_proc_write(struct fil + } + addr = set_val = repeat_cnt = 0; + +- if (!access_ok(VERIFY_READ, buf, count)) ++ if (!access_ok(buf, count)) + return -EFAULT; + + len = count < sizeof(str) ? count : sizeof(str) - 1; +@@ -450,13 +456,12 @@ static int proc_read_mem_seq_open(struct + return single_open(file, proc_read_mem, NULL); + } + +-static const struct file_operations mem_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_mem_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, +- .write = mem_proc_write, ++static const struct proc_ops mem_proc_fops = { ++ .proc_open = proc_read_mem_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = mem_proc_write, + }; + + static ssize_t pp32_proc_write(struct file *file, const char __user *buf, +@@ -748,13 +753,12 @@ static int proc_read_pp32_seq_open(struc + return single_open(file, proc_read_pp32, PDE_DATA(inode)); + } + +-static const struct file_operations pp32_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_pp32_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, +- .write = pp32_proc_write, ++static const struct proc_ops pp32_proc_fops = { ++ .proc_open = proc_read_pp32_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = pp32_proc_write, + }; + + static int proc_read_tc_cfg(struct seq_file *seq, void *v) +@@ -865,13 +869,12 @@ static int proc_read_tc_cfg_seq_open(str + return single_open(file, proc_read_tc_cfg, PDE_DATA(inode)); + } + +-static const struct file_operations tc_cfg_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_tc_cfg_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, +- .write = proc_write_cfg, ++static const struct proc_ops tc_cfg_proc_fops = { ++ .proc_open = proc_read_tc_cfg_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = proc_write_cfg, + }; + + static ssize_t proc_write_dbg(struct file *file, const char __user *buf, +@@ -951,13 +954,12 @@ static int proc_read_dbg_seq_open(struct + return single_open(file, proc_read_dbg, PDE_DATA(inode)); + } + +-static const struct file_operations tc_dbg_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_dbg_seq_open, +- .read = seq_read, +- .write = proc_write_dbg, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops tc_dbg_proc_fops = { ++ .proc_open = proc_read_dbg_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_dbg, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static ssize_t proc_write_tc_switch(struct file *file, const char __user *buf, +@@ -1018,11 +1020,11 @@ proc_tc_switch_help: + return count; + } + +-static const struct file_operations tc_switch_proc_fops = { +- .owner = THIS_MODULE, +- .write = proc_write_tc_switch, +- .llseek = noop_llseek, ++static const struct proc_ops tc_switch_proc_fops = { ++ .proc_write = proc_write_tc_switch, ++ .proc_lseek = noop_llseek, + }; ++ + static ssize_t proc_write_show_time(struct file *file, const char __user *buf, + size_t count, loff_t *data) + { +@@ -1077,10 +1079,9 @@ proc_show_time_help: + return count; + } + +-static const struct file_operations tc_show_time_proc_fops = { +- .owner = THIS_MODULE, +- .write = proc_write_show_time, +- .llseek = noop_llseek, ++static const struct proc_ops tc_show_time_proc_fops = { ++ .proc_write = proc_write_show_time, ++ .proc_lseek = noop_llseek, + }; + + static int proc_read_ver(struct seq_file *seq, void *v) +@@ -1128,12 +1129,11 @@ static int proc_read_ver_seq_open(struct + return single_open(file, proc_read_ver, PDE_DATA(inode)); + } + +-static const struct file_operations tc_ver_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_ver_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops tc_ver_proc_fops = { ++ .proc_open = proc_read_ver_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static int proc_read_soc(struct seq_file *seq, void *v) +@@ -1142,20 +1142,18 @@ static int proc_read_soc(struct seq_file + + tcpriv = (struct tc_priv *)seq->private; + +-#if 0 + seq_printf(seq, "TXIN Base: 0x%08x, TXIN num: %d\n", +- tcpriv->cfg.txin_dbase, +- tcpriv->cfg.txin_dnum); ++ tcpriv->cfg.txin.soc_phydbase, ++ tcpriv->cfg.txin.soc_dnum); + seq_printf(seq, "TXOUT Base: 0x%08x, TXOUT num: %d\n", +- tcpriv->cfg.txout_dbase, +- tcpriv->cfg.txout_dnum); ++ tcpriv->cfg.txout.soc_phydbase, ++ tcpriv->cfg.txout.soc_dnum); + seq_printf(seq, "RXIN Base: 0x%08x, RXIN num: %d\n", +- tcpriv->cfg.rxin_dbase, +- tcpriv->cfg.rxin_dnum); ++ tcpriv->cfg.rxin.soc_phydbase, ++ tcpriv->cfg.rxin.soc_dnum); + seq_printf(seq, "RXOUT Base: 0x%08x, RXOUT num: %d\n", +- tcpriv->cfg.rxout_dbase, +- tcpriv->cfg.rxout_dnum); +-#endif ++ tcpriv->cfg.rxout.soc_phydbase, ++ tcpriv->cfg.rxout.soc_dnum); + + return 0; + } +@@ -1165,15 +1163,13 @@ static int proc_read_soc_seq_open(struct + return single_open(file, proc_read_soc, PDE_DATA(inode)); + } + +-static const struct file_operations tc_soc_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_soc_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops tc_soc_proc_fops = { ++ .proc_open = proc_read_soc_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + +- + static struct tc_proc_list tc_procs[] = { + {TC_PROC_DIR, 0, NULL, 1}, + {"cfg", 0644, &tc_cfg_proc_fops, 0}, +@@ -1241,13 +1237,12 @@ static int proc_read_ptm_wanmib_seq_open + return single_open(file, proc_read_ptm_wanmib, PDE_DATA(inode)); + } + +-static const struct file_operations ptm_wanmib_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_ptm_wanmib_seq_open, +- .read = seq_read, +- .write = proc_write_ptm_wanmib, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops ptm_wanmib_proc_fops = { ++ .proc_open = proc_read_ptm_wanmib_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_ptm_wanmib, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static int proc_ptm_read_cfg(struct seq_file *seq, void *v) +@@ -1300,7 +1295,7 @@ static ssize_t ptm_cfg_proc_write(struct + return -EINVAL; + } + +- if (!access_ok(VERIFY_READ, buf, count)) ++ if (!access_ok(buf, count)) + return -EFAULT; + + len = count < sizeof(str) ? count : sizeof(str) - 1; +@@ -1343,13 +1338,12 @@ proc_ptm_cfg_help: + } + + +-static const struct file_operations ptm_cfg_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_cfg_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .write = ptm_cfg_proc_write, +- .release = single_release, ++static const struct proc_ops ptm_cfg_proc_fops = { ++ .proc_open = proc_read_cfg_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_write = ptm_cfg_proc_write, ++ .proc_release = single_release, + }; + + static ssize_t proc_ptm_write_prio(struct file *file, const char __user *buf, +@@ -1455,13 +1449,12 @@ static int proc_ptm_read_prio_seq_open(s + return single_open(file, proc_ptm_read_prio, PDE_DATA(inode)); + } + +-static const struct file_operations ptm_prio_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_ptm_read_prio_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .write = proc_ptm_write_prio, +- .release = single_release, ++static const struct proc_ops ptm_prio_proc_fops = { ++ .proc_open = proc_ptm_read_prio_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_write = proc_ptm_write_prio, ++ .proc_release = single_release, + }; + + static int proc_ptm_read_bond_seq_open(struct inode *inode, struct file *file) +@@ -1469,12 +1462,11 @@ static int proc_ptm_read_bond_seq_open(s + return single_open(file, proc_ptm_read_bond, PDE_DATA(inode)); + } + +-static const struct file_operations ptm_bond_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_ptm_read_bond_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops ptm_bond_proc_fops = { ++ .proc_open = proc_ptm_read_bond_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static int proc_ptm_read_bondmib_seq_open(struct inode *inode, +@@ -1483,13 +1475,12 @@ static int proc_ptm_read_bondmib_seq_ope + return single_open(file, proc_ptm_read_bondmib, PDE_DATA(inode)); + } + +-static const struct file_operations ptm_bondmib_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_ptm_read_bondmib_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .write = proc_ptm_write_bondmib, +- .release = single_release, ++static const struct proc_ops ptm_bondmib_proc_fops = { ++ .proc_open = proc_ptm_read_bondmib_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_write = proc_ptm_write_bondmib, ++ .proc_release = single_release, + }; + + struct fwdbg_t { +@@ -1910,14 +1901,14 @@ static int proc_read_fwdbg_seq_open(stru + { + return single_open(file, proc_read_fwdbg, NULL); + } +-static const struct file_operations fwdbg_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_fwdbg_seq_open, +- .read = seq_read, +- .write = proc_write_fwdbg_seq, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops fwdbg_proc_fops = { ++ .proc_open = proc_read_fwdbg_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_fwdbg_seq, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; ++ + static struct tc_proc_list ptm_sl_procs[] = { + {TC_PROC_PTM_DIR, 0, NULL, 1}, + {"mem", 0644, &mem_proc_fops, 0}, +@@ -2077,7 +2068,7 @@ static ssize_t atm_cfg_proc_write(struct + + priv = (struct atm_priv *)PDE_DATA(file_inode(file)); + +- if (!access_ok(VERIFY_READ, buf, count)) ++ if (!access_ok(buf, count)) + return -EFAULT; + + len = count < sizeof(str) ? count : sizeof(str) - 1; +@@ -2119,13 +2110,12 @@ proc_atm_cfg_help: + return count; + } + +-static const struct file_operations atm_cfg_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_atm_cfg_seq_open, +- .read = seq_read, +- .write = atm_cfg_proc_write, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops atm_cfg_proc_fops = { ++ .proc_open = proc_read_atm_cfg_seq_open, ++ .proc_read = seq_read, ++ .proc_write = atm_cfg_proc_write, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static ssize_t proc_write_atm_wanmib(struct file *file, const char __user *buf, +@@ -2173,13 +2163,12 @@ static int proc_read_atm_wanmib_seq_open + + + +-static const struct file_operations atm_wanmib_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_atm_wanmib_seq_open, +- .read = seq_read, +- .write = proc_write_atm_wanmib, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops atm_wanmib_proc_fops = { ++ .proc_open = proc_read_atm_wanmib_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_atm_wanmib, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static int proc_read_htu_seq_open(struct inode *inode, struct file *file) +@@ -2187,12 +2176,11 @@ static int proc_read_htu_seq_open(struct + return single_open(file, proc_read_htu, PDE_DATA(inode)); + } + +-static const struct file_operations htu_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_htu_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops htu_proc_fops = { ++ .proc_open = proc_read_htu_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static int proc_read_queue_seq_open(struct inode *inode, struct file *file) +@@ -2200,12 +2188,11 @@ static int proc_read_queue_seq_open(stru + return single_open(file, proc_read_queue, PDE_DATA(inode)); + } + +-static const struct file_operations queue_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_queue_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops queue_proc_fops = { ++ .proc_open = proc_read_queue_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static void set_q_prio(struct atm_priv *priv, +@@ -2428,13 +2415,12 @@ static const struct seq_operations pvc_m + .show = pvc_mib_seq_show, + }; + +-static const struct file_operations atm_prio_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_atm_read_prio_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .write = proc_atm_write_prio, +- .release = single_release, ++static const struct proc_ops atm_prio_proc_fops = { ++ .proc_open = proc_atm_read_prio_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_write = proc_atm_write_prio, ++ .proc_release = single_release, + }; + + static int proc_read_pvc_mib_seq_open(struct inode *inode, struct file *file) +@@ -2447,12 +2433,11 @@ static int proc_read_pvc_mib_seq_open(st + return ret; + } + +-static const struct file_operations atm_pvc_mib_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_pvc_mib_seq_open, +- .read = seq_read, +- .llseek = seq_lseek, +- .release = seq_release, ++static const struct proc_ops atm_pvc_mib_proc_fops = { ++ .proc_open = proc_read_pvc_mib_seq_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = seq_release, + }; + + static ssize_t proc_write_cell(struct file *file, +@@ -2592,13 +2577,12 @@ static int proc_read_cell_seq_open(struc + return single_open(file, proc_read_cell, NULL); + } + +-static const struct file_operations atm_cell_proc_fops = { +- .owner = THIS_MODULE, +- .open = proc_read_cell_seq_open, +- .read = seq_read, +- .write = proc_write_cell, +- .llseek = seq_lseek, +- .release = single_release, ++static const struct proc_ops atm_cell_proc_fops = { ++ .proc_open = proc_read_cell_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_cell, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, + }; + + static struct tc_proc_list atm_procs[] = { diff --git a/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch b/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch new file mode 100644 index 00000000000..edc97998b73 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch @@ -0,0 +1,1356 @@ +The existing software receive and transmit path does not actually work. +This replaces it by a basic working implementation. + +--- a/dcdp/atm_tc.c ++++ b/dcdp/atm_tc.c +@@ -603,7 +603,11 @@ static void atm_aca_init(struct atm_priv + cfg = &priv->tc_priv->cfg; + + txin = ¶m.aca_txin; ++#if defined(__LITTLE_ENDIAN) ++ txin->byteswap = 0; ++#else + txin->byteswap = 1; ++#endif + txin->hd_size_in_dw = cfg->txin.soc_desc_dwsz; + txin->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_IN_PD_LIST_BASE); + txin->pd_desc_num = __ACA_TX_IN_PD_LIST_NUM; +@@ -625,7 +629,11 @@ static void atm_aca_init(struct atm_priv + txin->soc_cmlt_cnt_addr); + + txout = ¶m.aca_txout; ++#if defined(__LITTLE_ENDIAN) ++ txout->byteswap = 0; ++#else + txout->byteswap = 1; ++#endif + txout->hd_size_in_dw = cfg->txout.soc_desc_dwsz; + txout->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_OUT_PD_LIST_BASE); + txout->pd_desc_num = __ACA_TX_OUT_PD_LIST_NUM; +@@ -647,7 +655,11 @@ static void atm_aca_init(struct atm_priv + txout->soc_cmlt_cnt_addr); + + rxout = ¶m.aca_rxout; ++#if defined(__LITTLE_ENDIAN) ++ rxout->byteswap = 0; ++#else + rxout->byteswap = 1; ++#endif + rxout->hd_size_in_dw = cfg->rxout.soc_desc_dwsz; + rxout->pd_desc_base = SB_XBAR_ADDR(__ACA_RX_OUT_PD_LIST_BASE); + rxout->pd_desc_num = __ACA_RX_OUT_PD_LIST_NUM; +@@ -669,7 +681,11 @@ static void atm_aca_init(struct atm_priv + rxout->soc_cmlt_cnt_addr); + + rxin = ¶m.aca_rxin; ++#if defined(__LITTLE_ENDIAN) ++ rxin->byteswap = 0; ++#else + rxin->byteswap = 1; ++#endif + rxin->hd_size_in_dw = cfg->rxin.soc_desc_dwsz; + rxin->pd_desc_base = SB_XBAR_ADDR(__RX_IN_PD_DES_LIST_BASE); + rxin->pd_desc_num = __ACA_RX_IN_PD_LIST_NUM; +@@ -1261,7 +1277,7 @@ static int ppe_ioctl(struct atm_dev *dev + static int ppe_send(struct atm_vcc *vcc, struct sk_buff *skb) + { + int ret, qid, mpoa_pt, mpoa_type, vid; +- unsigned int prio, conn; ++ unsigned int prio, conn, len; + struct atm_priv *priv; + + if (!vcc) { +@@ -1327,12 +1343,14 @@ static int ppe_send(struct atm_vcc *vcc, + tc_dbg(priv->tc_priv, MSG_TX, "vid: 0x%x, qid: 0x%x\n", + vid, qid); + ++ len = skb->len; ++ + if (priv->tc_priv->tc_ops.send(NULL, + skb, qid, ATM_SL_PKT) == 0) { + priv->stats.aal5_tx_pkts++; +- priv->stats.aal5_tx_bytes += skb->len; ++ priv->stats.aal5_tx_bytes += len; + priv->conn[conn].stats.aal5_tx_pkts++; +- priv->conn[conn].stats.aal5_tx_bytes += skb->len; ++ priv->conn[conn].stats.aal5_tx_bytes += len; + priv->conn[conn].prio_tx_packets[prio]++; + } else { + tc_dbg(priv->tc_priv, MSG_TX, "ATM: TX fail\n"); +--- a/dcdp/ptm_tc.c ++++ b/dcdp/ptm_tc.c +@@ -506,6 +506,7 @@ static int ptm_xmit(struct sk_buff *skb, + struct ptm_priv *ptm_tc = netdev_priv(dev); + int qid; + enum tc_pkt_type type; ++ unsigned int len; + + if (!showtime_stat(ptm_tc->tc_priv)) + goto PTM_XMIT_DROP; +@@ -519,11 +520,13 @@ static int ptm_xmit(struct sk_buff *skb, + type = ptm_tc->tc_priv->tc_mode == TC_PTM_BND_MODE + ? PTM_BOND_PKT : PTM_SL_PKT; + ++ len = skb->len; ++ + if (ptm_tc->tc_priv->tc_ops.send(dev, skb, qid, type) < 0) + ptm_tc->stats64.tx_dropped++; + else { + ptm_tc->stats64.tx_packets++; +- ptm_tc->stats64.tx_bytes += skb->len; ++ ptm_tc->stats64.tx_bytes += len; + } + + return 0; +@@ -640,7 +643,7 @@ static int ptm_dev_init(struct tc_priv * + const char macaddr[ETH_ALEN] + = {0xAC, 0x9A, 0x96, 0x11, 0x22, 0x33}; + +- dev = alloc_netdev_mq(sizeof(*ptm_tc), "dsl%d", NET_NAME_ENUM, ptm_setup, 4); ++ dev = alloc_netdev(sizeof(*ptm_tc), "dsl%d", NET_NAME_ENUM, ptm_setup); + if (!dev) { + tc_dbg(tc_priv, MSG_INIT, "Cannot alloc net device\n"); + return -ENOMEM; +@@ -2337,7 +2340,11 @@ static void ptm_aca_init(struct ptm_ep_p + cfg = &priv->tc_priv->cfg; + + txin = ¶m.aca_txin; ++#if defined(__LITTLE_ENDIAN) ++ txin->byteswap = 0; ++#else + txin->byteswap = 1; ++#endif + txin->hd_size_in_dw = cfg->txin.soc_desc_dwsz; + txin->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_IN_PD_LIST_BASE); + txin->pd_desc_num = __ACA_TX_IN_PD_LIST_NUM; +@@ -2360,7 +2367,11 @@ static void ptm_aca_init(struct ptm_ep_p + txin->soc_cmlt_cnt_addr); + + txout = ¶m.aca_txout; ++#if defined(__LITTLE_ENDIAN) ++ txout->byteswap = 0; ++#else + txout->byteswap = 1; ++#endif + txout->hd_size_in_dw = cfg->txout.soc_desc_dwsz; + if (priv->tc_priv->param.cdma_desc_loc == LOC_IN_FPI) + txout->pd_desc_base = sb_r32(__TX_OUT_SHADOW_PTR) - phybase; +@@ -2386,7 +2397,11 @@ static void ptm_aca_init(struct ptm_ep_p + txout->soc_cmlt_cnt_addr); + + rxout = ¶m.aca_rxout; ++#if defined(__LITTLE_ENDIAN) ++ rxout->byteswap = 0; ++#else + rxout->byteswap = 1; ++#endif + rxout->hd_size_in_dw = cfg->rxout.soc_desc_dwsz; + if (priv->tc_priv->param.cdma_desc_loc == LOC_IN_FPI) + rxout->pd_desc_base = sb_r32(__RX_OUT_SHADOW_PTR) - phybase; +@@ -2412,7 +2427,11 @@ static void ptm_aca_init(struct ptm_ep_p + rxout->soc_cmlt_cnt_addr); + + rxin = ¶m.aca_rxin; ++#if defined(__LITTLE_ENDIAN) ++ rxin->byteswap = 0; ++#else + rxin->byteswap = 1; ++#endif + rxin->hd_size_in_dw = cfg->rxin.soc_desc_dwsz; + rxin->pd_desc_base = SB_XBAR_ADDR(__RX_IN_PD_DES_LIST_BASE); + rxin->pd_desc_num = __ACA_RX_IN_PD_LIST_NUM; +--- a/dcdp/platform/sw_plat.c ++++ b/dcdp/platform/sw_plat.c +@@ -36,10 +36,13 @@ + #include <linux/printk.h> + #include <linux/etherdevice.h> + #include <linux/workqueue.h> +-#include "inc/dsl_tc.h" ++#include "../inc/dsl_tc.h" + + #include "../inc/tc_main.h" + #include "../inc/reg_addr.h" ++#include "../inc/tc_common.h" ++ ++#include "../inc/fw/vrx518_addr_def.h" + + + #define PMAC_SIZE 8 +@@ -70,7 +73,7 @@ enum { + #define TXIN_DNUM 128 + #define TXOUT_DNUM 128 + #define RXOUT_DNUM 1024 +-#define RXIN_DNUM 1024 ++#define RXIN_DNUM 0 + + #define TXIN_CHECK_NUM 32 + +@@ -80,22 +83,32 @@ struct aca_ring { + void *umt_dst; + u32 umt_phydst; + u32 dnum; ++ u32 dsize; + int idx; /* SoC RX/TX index */ +- int cnt; +- void *cnt_addr; +- u32 cnt_phyaddr; + int ep_dev_idx; + }; + ++struct tx_list_item { ++ size_t len; ++ void *buf; ++ dma_addr_t phyaddr; ++}; ++ ++struct tx_list { ++ struct tx_list_item *data; ++ u32 dnum; ++}; ++ + struct aca_ring_grp { + struct aca_ring rxin; + struct aca_ring txin; + struct aca_ring rxout; + struct aca_ring txout; ++ struct tx_list txlist; + }; + +-#if 1 +-struct dma_desc { ++#if defined(__LITTLE_ENDIAN) ++struct dma_tx_desc { + /* DW 0 */ + u32 qid; + /* DW 1 */ +@@ -112,8 +125,26 @@ struct dma_desc { + u32 c:1; + u32 own:1; + }__packed; ++ ++struct dma_rx_desc { ++ /* DW 0 */ ++ u32 qid; ++ /* DW 1 */ ++ u32 res2; ++ /* DW 2 */ ++ u32 data_len:16; ++ u32 res0:7; ++ u32 byte_off:3; ++ u32 res1:2; ++ u32 eop:1; ++ u32 sop:1; ++ u32 c:1; ++ u32 own:1; ++ /* DW 3 */ ++ u32 data_ptr; ++}__packed; + #else +-struct dma_desc { ++struct dma_tx_desc { + /* DW 0 */ + u32 qid; + /* DW 1 */ +@@ -131,14 +162,25 @@ struct dma_desc { + u32 data_len:16; + }__packed; + ++struct dma_rx_desc { ++ /* DW 0 */ ++ u32 qid; ++ /* DW 1 */ ++ u32 res; ++ /* DW 2 */ ++ u32 own:1; ++ u32 c:1; ++ u32 sop:1; ++ u32 eop:1; ++ u32 res1:2; ++ u32 byte_off:3; ++ u32 res0:7; ++ u32 data_len:16; ++ /* DW 3 */ ++ u32 data_ptr; ++}__packed; + #endif + +-struct plat_dma { +- u32 chan; /* CHAN IID */ +- u32 dma_chan; /* CONTROLLER/PORT/CHAN ID */ +- u32 ds_dnum; /* DS descriptor number */ +-}; +- + struct plat_umt { + u32 id; + u32 cbm_id; +@@ -152,28 +194,28 @@ struct tc_req { + enum dsl_tc_mode tc_mode; + }; + +-#if 0 +-struct tc_coc { +- enum ltq_cpufreq_state coc_stat; +- struct tasklet_struct coc_task; ++struct mem_map_entry { ++ dma_addr_t phyaddr; ++ void *mem; ++ size_t size; ++ struct hlist_node node; + }; +-#endif + + struct plat_priv { + struct tc_priv *tc_priv; + struct plat_umt umt[EP_MAX_NUM]; +- struct plat_dma dma[EP_MAX_NUM]; + struct ltq_mei_atm_showtime_info dsl_ops; + struct tc_req req_work; + struct aca_ring_grp soc_rings; +- /* struct tc_coc coc;*/ ++ struct net_device *netdev; ++ DECLARE_HASHTABLE(mem_map, 8); + }; + + static struct plat_priv *g_plat_priv; + struct tasklet_struct txout_task; + struct tasklet_struct rxout_task; + +-static void txout_action(struct tc_priv *priv, struct aca_ring *txout); ++static DEFINE_SPINLOCK(tx_spinlock); + + void *ppa_callback_get(e_ltq_mei_cb_type type) + { +@@ -259,122 +301,65 @@ static inline struct tc_priv *plat_to_tc + return g_plat_priv->tc_priv; + } + +-static int32_t plat_rx(struct net_device *rxdev, struct net_device *txdev, +- struct sk_buff *skb, int32_t len) +-{ +- int32_t err; +- struct tc_priv *tc_priv = plat_to_tcpriv(); +- +- if (unlikely(!rxdev)) { +- if (txdev != NULL) +- tc_dbg(tc_priv, MSG_RX, +- "Recv undelivered packet from DP lib\n"); +- else +- tc_dbg(tc_priv, MSG_RX, "Recv unknown packet\n"); +- err = -ENODEV; +- goto err1; +- } +- +- tc_priv->tc_ops.recv(rxdev, skb); +- return 0; +- +-err1: +- dev_kfree_skb_any(skb); +- +- return err; +-} +- +-#if 0 +-static int32_t plat_get_subifid(struct net_device *dev, struct sk_buff *skb, +- void *subif_data, uint8_t dst_mac[MAX_ETH_ALEN], +- dp_subif_t *subif, uint32_t flags) +-{ +- int qid; +- struct tc_priv *priv = plat_to_tcpriv(); +- +- qid = priv->tc_ops.get_qid(dev, skb, subif_data, flags); +- if (qid < 0) +- return qid; +- else +- subif->subif = qid; +- +- return 0; +-} +-#endif +- +-#if 0 +-static void plat_coc_tasklet(unsigned long arg) +-{ +- /* change state to D0 */ +- if (g_plat_priv->coc.coc_stat == LTQ_CPUFREQ_PS_D0) +- return; +- +- g_plat_priv->coc.coc_stat = LTQ_CPUFREQ_PS_D0; +-} +- +-static void plat_coc_req(void) +-{ +- tasklet_schedule(&g_plat_priv->coc.coc_task); +-} ++static void *plat_mem_alloc(size_t size, enum tc_dir dir, u32 *phyaddr); ++static void *plat_mem_virt(u32 phyaddr); ++static void plat_mem_free(u32 phyaddr, enum tc_dir dir); + ++static void txlist_free(struct tx_list *list); + +-static int32_t plat_coc_stat(enum ltq_cpufreq_state new_state, +- enum ltq_cpufreq_state old_state, uint32_t flags) ++static int txlist_init(struct tx_list *list, u32 dnum) + { +- struct tc_priv *priv = plat_to_tcpriv(); +- tc_dbg(priv, MSG_COC, +- "COC current state: %d, new state: %d, old state: %d\n", +- g_plat_priv->coc.coc_stat, new_state, old_state); ++ struct tx_list_item *item; ++ int i; + +- if (g_plat_priv->coc.coc_stat != new_state) { +- g_plat_priv->coc.coc_stat = new_state; ++ list->dnum = dnum; + +- if (new_state == LTQ_CPUFREQ_PS_D3) { +- /* Enable interrupt for DS packet */ +- priv->tc_ops.irq_on(MBOX_PKT_RX); +- } else { +- /* Disable interrupt for DS packet */ +- priv->tc_ops.irq_off(MBOX_PKT_RX); ++ list->data = kcalloc(dnum, sizeof(struct tx_list_item), GFP_KERNEL); ++ if (!list->data) { ++ pr_err("Failed to allocate TX list!\n"); ++ goto err; ++ } ++ ++ for (i = 0; i < list->dnum; i++) { ++ item = &list->data[i]; ++ ++ // use plat_mem_alloc as these buffers will be mixed with buffers allocated in ptm_tc.c / atm_tc.c ++ item->buf = plat_mem_alloc(DMA_PACKET_SZ, US_DIR, &item->phyaddr); ++ if (!item->buf) { ++ pr_err("Failed to allocate TX buffer!\n"); ++ goto err; + } + } + + return 0; +-} +-#endif +- +-static inline int ring_dist(int idx1, int idx2, int size) +-{ +- if (idx1 >= idx2) +- return (idx1 - idx2); +- else +- return (idx1 + size - idx2); +-} + +-static inline int __ring_full(int idx, int cnt, u32 dnum) +-{ +- if (ring_dist(idx, cnt, dnum) < dnum - 1) +- return 0; +- else +- return 1; ++err: ++ txlist_free(list); ++ return -1; + } + +-static inline int ring_full(struct aca_ring *ring) ++static void txlist_free(struct tx_list *list) + { +- if (!__ring_full(ring->idx, ring->cnt, ring->dnum)) +- return 0; ++ struct tx_list_item *item; ++ int i; + +- /* if ring full, update cumulative counter and check again */ +- ring->cnt = readl(ring->cnt_addr) % ring->dnum; ++ if (list->data) { ++ for (i = 0; i < list->dnum; i++) { ++ item = &list->data[i]; ++ ++ if (item->buf) { ++ // use plat_mem_free as these buffers are mixed with buffers allocated in ptm_tc.c / atm_tc.c ++ plat_mem_free(item->phyaddr, US_DIR); ++ } ++ } ++ } + +- return __ring_full(ring->idx, ring->cnt, ring->dnum); ++ kfree(list->data); + } + +-#define ring_idx_inc(ring, idx) \ +- do { ring->idx = (ring->idx + 1) % ring->dnum; } while (0); +- +-static inline void ring_cnt_update(struct aca_ring *ring) ++static inline void ring_idx_inc(struct aca_ring *ring) + { +- ring->cnt = readl(ring->cnt_addr) % ring->dnum; ++ ring->idx = (ring->idx + 1) % ring->dnum; + } + + static struct sk_buff *txin_skb_prepare(struct sk_buff *skb) +@@ -399,252 +384,220 @@ static struct sk_buff *txin_skb_prepare( + return nskb; + } + +-static int ring_mmap(void *mem, int size, +- enum dma_data_direction dir, u32 *addr) +-{ +- struct device *pdev; +- dma_addr_t phy_addr; +- struct tc_priv *priv; +- u32 addr1; +- +- priv = g_plat_priv->tc_priv; +- pdev = priv->ep_dev[0].dev; +- +- phy_addr = dma_map_single(pdev, mem, size, dir); +- if (unlikely(dma_mapping_error(pdev, phy_addr))) { +- tc_err(priv, MSG_INIT, +- "DMA address mapping error: buf: 0x%x, size: %d, dir: %d\n", +- (u32)mem, size, dir); +- return -ENOMEM; +- } +- dma_unmap_single(pdev, phy_addr, size, dir); +- +- pr_info("vaddr: 0x%x, phyaddr: 0x%lx\n", (u32)mem, phy_addr); +- addr1 = (u32)phy_addr; +- +- if (addr) +- *addr = addr1; +- +- return 0; +-} +- +-static void txin_action(struct tc_priv *priv, struct aca_ring *txin, ++static int txin_action(struct tc_priv *priv, struct aca_ring *txin, + struct sk_buff *skb, int qid, enum tc_pkt_type type) + { +- struct dma_desc *desc, desc1; +- u32 phyaddr, *dst, *src; +- int i; ++ struct device *pdev = priv->ep_dev[0].dev; ++ struct aca_ring *txout = &g_plat_priv->soc_rings.txout; ++ struct tx_list *txlist = &g_plat_priv->soc_rings.txlist; ++ struct dma_tx_desc *desc; ++ struct tx_list_item *txlist_item; ++ unsigned long flags; ++ ++ if (!g_plat_priv->netdev) { ++ spin_lock_irqsave(&tx_spinlock, flags); ++ } + +- if (ring_full(txin)) { +- tc_dbg(priv, MSG_TX, +- "TXIN Ring Full!: idx: %d, cnt: %d\n", +- txin->idx, txin->cnt); ++ if ((txin->idx + 2) % txin->dnum == txout->idx) { ++ if (g_plat_priv->netdev) { ++ netif_stop_queue(g_plat_priv->netdev); ++ } ++ } else if ((txin->idx + 1) % txin->dnum == txout->idx) { ++ tc_err(priv, MSG_TX, "TXIN ring full: txin: %d, txout: %d\n", ++ txin->idx, txout->idx); + goto err1; + } + ++ desc = (struct dma_tx_desc *)txin->dbase_mem; ++ desc += txin->idx; ++ ++ txlist_item = &txlist->data[txin->idx]; ++ + skb = txin_skb_prepare(skb); + if (!skb) +- return; ++ goto err2; + +- if (ring_mmap(skb->data, skb->len, DMA_TO_DEVICE, &phyaddr) < 0) { +- tc_err(priv, MSG_TX, "TXIN data mmap failed: 0x%x\n", +- (unsigned int)skb->data); +- goto err1; +- } ++ /* ++ * Copy the data to a buffer in the driver. This is necessary because there doesn't seem to be a timely signal ++ * from the device when it has consumed a buffer, which would allow to safely free it. The data_ptr is only ++ * returned in TXOUT after another fixed number of packets (depending on the size of internal buffers) has been ++ * transmitted, which may not happen in the near future. Making a copy allows to free the SKB here. ++ */ ++ memcpy(txlist_item->buf, skb->data, skb->len); + +- /* init a new descriptor for the new skb */ +- desc = (struct dma_desc *)txin->dbase_mem; +- desc += txin->idx; ++ dma_sync_single_range_for_device(pdev, txlist_item->phyaddr, 0, skb->len, DMA_TO_DEVICE); + +- memset(desc, 0, sizeof(*desc)); +- memset(&desc1, 0, sizeof(desc1)); +- desc1.own = 1; +- desc1.c = 1; +- desc1.sop = 1; +- desc1.eop = 1; +- desc1.byte_off = phyaddr & 0x7; +- desc1.data_len = skb->len; +- +- desc1.data_ptr = phyaddr & (~(0x7)); +- desc1.qid = qid; +- +- dst = (u32 *)desc; +- src = (u32 *)&desc1; +- for (i = 0; i < DW_SZ(desc1); i++) +- dst[i] = cpu_to_be32(src[i]); +- +- pr_info("txin idx: %d\n", txin->idx); +- pr_info("descriptor dst val:(DW0-DW3): 0x%x, 0x%x, 0x%x, 0x%x\n", +- dst[0], dst[1], dst[2], dst[3]); +- pr_info("descriptor src val: (DW0-DW3): 0x%x, 0x%x, 0x%x, 0x%x\n", +- src[0], src[1], src[2], src[3]); +- +- if (ring_mmap(desc, sizeof(*desc), DMA_TO_DEVICE, NULL) < 0) { +- tc_err(priv, MSG_TX, "TXIN descriptor mmap failed: 0x%x\n", +- (unsigned int)desc); ++ // this should never happen, the buffers are already aligned by kmalloc ++ if (WARN_ON((txlist_item->phyaddr & 0x7) != 0)) + goto err1; ++ ++ if (g_plat_priv->netdev) { ++ netdev_sent_queue(g_plat_priv->netdev, skb->len); + } ++ txlist_item->len = skb->len; ++ ++ memset(desc, 0, sizeof(*desc)); + +- ring_idx_inc(txin, idx); ++ desc->data_ptr = txlist_item->phyaddr; ++ desc->byte_off = 0; ++ desc->data_len = skb->len; ++ desc->qid = qid; ++ ++ desc->sop = 1; ++ desc->eop = 1; ++ desc->c = 0; ++ desc->own = 1; ++ ++ dev_consume_skb_any(skb); ++ ++ ring_idx_inc(txin); + + /* update TXIN UMT by 1 */ + writel(1, txin->umt_dst); +- pr_info("TXIN send txin packet 1 packet\n"); + +- /* Free skb */ +- dev_kfree_skb_any(skb); ++ if (!g_plat_priv->netdev) { ++ spin_unlock_irqrestore(&tx_spinlock, flags); ++ } + +- /* check txout for testing*/ +- //txout_action(plat_to_tcpriv(), &g_plat_priv->soc_rings.txout); +- return; ++ return 0; + + err1: +- //skb->delay_free = 0; + dev_kfree_skb_any(skb); ++ ++err2: ++ if (!g_plat_priv->netdev) { ++ spin_unlock_irqrestore(&tx_spinlock, flags); ++ } ++ ++ return -1; + } + + static void txout_action(struct tc_priv *priv, struct aca_ring *txout) + { +- int i, cnt; +- struct dma_desc *desc; +- u32 ptr; +- void *mem; +- +- ring_cnt_update(txout); +- cnt = ring_dist(txout->idx, txout->cnt, txout->dnum); ++ struct aca_ring *txin = &g_plat_priv->soc_rings.txin; ++ struct tx_list *txlist = &g_plat_priv->soc_rings.txlist; ++ struct tx_list_item *txlist_item; ++ int i, cnt, bytes; ++ u32 *desc; ++ unsigned long flags; ++ ++ cnt = 0; ++ bytes = 0; ++ ++ if (g_plat_priv->netdev) { ++ netif_tx_lock(g_plat_priv->netdev); ++ } else { ++ spin_lock_irqsave(&tx_spinlock, flags); ++ } + +- for (i = 0; i < cnt; i++) { ++ for (i = 0; i < txout->dnum; i++) { + desc = txout->dbase_mem; + desc += txout->idx; +- /* read from memory */ +- if (ring_mmap(desc, sizeof(*desc), DMA_FROM_DEVICE, NULL) < 0) { +- tc_err(priv, MSG_TX, +- "map TXOUT DMA descriptor failed\n"); +- continue; ++ ++ // *desc seems to be a pointer to a QoSQ buffer or the data_ptr of some previously sent packet ++ if (*desc == 0) { ++ break; + } +- ptr = desc->data_ptr + desc->byte_off; +- mem = (void * __force)__va(ptr); +- kfree(mem); +- ring_idx_inc(txout, idx); +- } + +- if (cnt) +- writel(cnt, txout->umt_dst); +- pr_info("TXOUT received %d descriptors\n", cnt); +-} ++ if (txout->idx == txin->idx) { ++ tc_err(priv, MSG_TX, "TXOUT unexpected non-zero descriptor: txin: %d, txout: %d\n", ++ txin->idx, txout->idx); ++ break; ++ } + +-static void rxin_action(struct tc_priv *priv, +- struct aca_ring *rxin, int size, int cnt) +-{ +- int i, dist; +- struct dma_desc *desc; +- void *data_ptr; +- u32 phyaddr; +- +- if (ring_full(rxin)) { +- tc_dbg(priv, MSG_RX, +- "RXIN Ring Full!: idx: %d, cnt: %d\n", +- rxin->idx, rxin->cnt); +- return; +- } ++ txlist_item = &txlist->data[txout->idx]; + +- dist = ring_dist(rxin->idx, rxin->cnt, rxin->dnum); +- if (cnt > dist) { +- WARN_ONCE(1, "RXIN NO enough room for free buffers: free: %d, room: %d\n", +- cnt, dist); +- cnt = dist; ++ cnt++; ++ bytes += txlist_item->len; ++ ++ /* ++ * Reuse the returned buffer. The previous buffer should still be referenced by another descriptor. ++ * When the driver is unloaded, all buffers in the txlist as well as those referenced by the ++ * descriptors managed in ptm_tc.c or atm_tc.c will be freed. ++ */ ++ txlist_item->buf = plat_mem_virt(*desc); ++ txlist_item->phyaddr = *desc; ++ ++ *desc = 0; ++ ++ ring_idx_inc(txout); + } + +- for (i = 0; i < cnt; i++) { +- data_ptr = kmalloc(size, GFP_ATOMIC); +- if (!data_ptr) { +- tc_err(priv, MSG_RX, +- "RXIN kmalloc data buffer failed: %d\n", size); +- goto err1; +- } ++ if (cnt) { ++ writel(cnt, txout->umt_dst+0x28); // TXOUT_HD_ACCUM_SUB instead of TXOUT_HD_ACCUM_ADD + +- if (ring_mmap(data_ptr, size, DMA_FROM_DEVICE, &phyaddr) < 0) { +- tc_err(priv, MSG_RX, +- "RXIN kmalloc data buffer failed: %d\n", size); +- goto err2; ++ if (g_plat_priv->netdev) { ++ netdev_completed_queue(g_plat_priv->netdev, cnt, bytes); + } ++ } + +- desc = (struct dma_desc *)rxin->dbase_mem; +- desc += rxin->idx; +- memset(desc, 0, sizeof(*desc)); +- +- desc->data_len = size; +- desc->byte_off = phyaddr & 0x7; +- desc->eop = 1; +- desc->sop = 1; +- desc->own = 1; +- +- desc->data_ptr = phyaddr; +- +- +- if (ring_mmap(desc, sizeof(*desc), DMA_TO_DEVICE, NULL) < 0) { +- tc_err(priv, MSG_RX, "RXIN descriptor mmap failed: 0x%x\n", +- (unsigned int)desc); +- goto err2; +- } +- +- ring_idx_inc(rxin, idx); ++ if (g_plat_priv->netdev) { ++ netif_tx_unlock(g_plat_priv->netdev); ++ } else { ++ spin_unlock_irqrestore(&tx_spinlock, flags); + } + +- /* update RXIN UMT*/ +- writel(i, rxin->umt_dst); +- pr_info("rxin refill %d descriptors\n", i); +- return; ++ if (cnt && g_plat_priv->netdev && netif_queue_stopped(g_plat_priv->netdev)) { ++ netif_wake_queue(g_plat_priv->netdev); ++ } ++} + +-err2: +- kfree(data_ptr); +-err1: +- if (i) +- writel(i, rxin->umt_dst); +- return; ++static void rxin_action(struct tc_priv *priv, ++ struct aca_ring *rxin, int size, int cnt) ++{ ++ /* update RXIN UMT*/ ++ writel(cnt, rxin->umt_dst); + } + + static int rxout_action(struct tc_priv *priv, struct aca_ring *rxout) + { ++ struct device *pdev = priv->ep_dev[0].dev; + int i, cnt; +- struct dma_desc *desc; +- u32 ptr; +- void *mem; ++ struct dma_rx_desc *desc; ++ dma_addr_t phyaddr; ++ void *ptr, *dst; ++ size_t len; + struct sk_buff *skb; + +- ring_cnt_update(rxout); +- cnt = ring_dist(rxout->idx, rxout->cnt, rxout->dnum); +- +- for (i = 0; i < cnt; i++) { ++ cnt = 0; ++ for (i = 0; i < rxout->dnum; i++) { + desc = rxout->dbase_mem; + desc += rxout->idx; + +- /* read from memory */ +- if (ring_mmap(desc, sizeof(*desc), DMA_FROM_DEVICE, NULL) < 0) { +- tc_err(priv, MSG_RX, +- "map RXOUT DMA descriptor failed\n"); +- continue; ++ if (!desc->own) { ++ break; + } +- ptr = desc->data_ptr + desc->byte_off; +- mem = __va(ptr); +- skb = build_skb(mem, 0); +- if (!skb) { +- tc_err(priv, MSG_RX, +- "RXOUT build skb failed\n"); +- kfree(mem); +- continue; ++ ++ // this seems to be a pointer to a DS PKT buffer ++ phyaddr = desc->data_ptr + desc->byte_off; ++ ptr = plat_mem_virt(phyaddr); ++ ++ len = desc->data_len; ++ ++ dma_sync_single_range_for_cpu(pdev, phyaddr, 0, len, DMA_FROM_DEVICE); ++ ++ skb = netdev_alloc_skb(g_plat_priv->netdev, len); ++ if (unlikely(!skb)) { ++ tc_err(priv, MSG_RX, "RXOUT SKB allocation failed\n"); ++ break; + } +- priv->tc_ops.recv(NULL, skb); +- ring_idx_inc(rxout, idx); ++ ++ dst = skb_put(skb, len); ++ memcpy(dst, ptr, len); ++ ++ priv->tc_ops.recv(g_plat_priv->netdev, skb); ++ ++ desc->own = 0; ++ ++ cnt++; ++ ring_idx_inc(rxout); + } + + if (!cnt) +- tc_err(priv, MSG_RX, "RXOUT dummy interrupt: dbase: 0x%x, idx: %d, cnt: %d\n", +- (unsigned int)rxout->dbase_mem, rxout->idx, rxout->cnt); ++ tc_err(priv, MSG_RX, "RXOUT spurious interrupt\n"); + else +- writel(cnt, rxout->umt_dst); ++ writel(cnt, rxout->umt_dst+0x28); // RXOUT_HD_ACCUM_SUB instead of RXOUT_HD_ACCUM_ADD + +- pr_info("txout received %d packets\n", cnt); + return cnt; + } + +@@ -669,7 +622,6 @@ static void plat_rxout_tasklet(unsigned + struct aca_ring *rxin = &priv->soc_rings.rxin; + struct dc_ep_dev *ep_dev = &tcpriv->ep_dev[rxout->ep_dev_idx]; + int cnt; +- + + cnt = rxout_action(tcpriv, rxout); + if (cnt) +@@ -687,68 +639,144 @@ static int plat_send(struct net_device * + { + struct plat_priv *priv = g_plat_priv; + struct aca_ring *txin = &priv->soc_rings.txin; ++ int res; + +- txin_action(priv->tc_priv, txin, skb, qid, type); ++ res = txin_action(priv->tc_priv, txin, skb, qid, type); + +- return 0; ++ return res; ++} ++ ++static void plat_mem_init(void) ++{ ++ struct plat_priv *priv = g_plat_priv; ++ ++ hash_init(priv->mem_map); + } + + /* return virtual address */ +-static void *plat_mem_alloc(size_t size, enum tc_dir dir) ++static void *plat_mem_alloc(size_t size, enum tc_dir dir, u32 *phyaddr) + { +- return kmalloc(size, GFP_KERNEL); ++ struct plat_priv *priv = g_plat_priv; ++ struct tc_priv *tcpriv = priv->tc_priv; ++ struct device *pdev = tcpriv->ep_dev[0].dev; ++ enum dma_data_direction dma_dir; ++ struct mem_map_entry *entry; ++ ++ entry = kzalloc(sizeof(struct mem_map_entry), GFP_KERNEL); ++ if (!entry) ++ goto err; ++ ++ entry->size = size; ++ ++ entry->mem = kmalloc(size, GFP_KERNEL); ++ if (!entry->mem) ++ goto err_alloc; ++ ++ dma_dir = (dir == DS_DIR) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; ++ ++ entry->phyaddr = dma_map_single(pdev, entry->mem, entry->size, dma_dir); ++ if (unlikely(dma_mapping_error(pdev, entry->phyaddr))) { ++ tc_err(priv, MSG_INIT, ++ "plat_mem_alloc: DMA mapping error: buf: 0x%x, size: %d, dir: %d\n", ++ (u32)entry->mem, size, dir); ++ ++ goto err_map; ++ } ++ ++ hash_add(g_plat_priv->mem_map, &entry->node, entry->phyaddr); ++ ++ *phyaddr = entry->phyaddr; ++ return entry->mem; ++ ++err_map: ++ kfree(entry->mem); ++ ++err_alloc: ++ kfree(entry); ++ ++err: ++ return NULL; + } + +-static void plat_mem_free(u32 phy_addr, enum tc_dir dir) ++static void *plat_mem_virt(u32 phyaddr) + { +- void *mem; ++ struct mem_map_entry *entry; ++ ++ hash_for_each_possible(g_plat_priv->mem_map, entry, node, phyaddr) ++ if (entry->phyaddr == phyaddr) ++ return entry->mem; ++ ++ WARN_ON(1); ++ return NULL; ++} ++ ++static struct mem_map_entry *plat_mem_entry(u32 phyaddr) ++{ ++ struct mem_map_entry *entry; ++ ++ hash_for_each_possible(g_plat_priv->mem_map, entry, node, phyaddr) ++ if (entry->phyaddr == phyaddr) ++ return entry; + +- mem = (void * __force)__va(phy_addr); +- kfree(mem); ++ return NULL; + } + +-static void aca_soc_ring_init(struct tc_priv *priv, +- struct aca_ring *ring, u32 dnum, u32 dsize) ++static void plat_mem_free(u32 phyaddr, enum tc_dir dir) + { ++ struct tc_priv *priv = g_plat_priv->tc_priv; ++ struct device *pdev = priv->ep_dev[0].dev; ++ enum dma_data_direction dma_dir; ++ struct mem_map_entry *entry; ++ ++ entry = plat_mem_entry(phyaddr); ++ if (WARN_ON(!entry)) ++ return; ++ ++ hash_del(&entry->node); ++ ++ dma_dir = (dir == DS_DIR) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; ++ dma_unmap_single(pdev, entry->phyaddr, entry->size, dma_dir); ++ ++ kfree(entry->mem); ++ ++ kfree(entry); ++} ++ ++static int ring_init(struct tc_priv *priv, struct aca_ring *ring, u32 dnum, u32 dsize) ++{ ++ struct device *pdev = priv->ep_dev[0].dev; + int size; +- struct device *pdev; + + memset(ring, 0, sizeof(*ring)); + ring->dnum = dnum; ++ ring->dsize = dsize; ++ ++ if (ring->dnum == 0) { ++ return 0; ++ } ++ + size = dsize * dnum; +- pdev = priv->ep_dev[0].dev; + +- ring->dbase_mem = kmalloc(size, GFP_KERNEL); ++ ring->dbase_mem = dma_alloc_coherent(pdev, size, &(ring->dbase_phymem), GFP_KERNEL); + if (!ring->dbase_mem) { +- tc_err(priv, MSG_INIT, "Allocate SoC Ring fail: %d\n", dnum); +- return; ++ tc_err(priv, MSG_INIT, "Ring allocation failed: %d\n", dnum); ++ return -1; + } + +- ring_mmap(ring->dbase_mem, size, DMA_FROM_DEVICE, &(ring->dbase_phymem)); +- tc_dbg(priv, MSG_INIT, "ring: membase: 0x%x, phybase: 0x%x, dnum: %d\n", +- (u32)ring->dbase_mem, ring->dbase_phymem, ring->dnum); +- +- size = sizeof(u32); +- ring->cnt_addr = kzalloc(size, GFP_KERNEL); +- if (!ring->cnt_addr) { +- tc_err(priv, MSG_INIT, "Allocate cumulative counter fail!\n"); +- return; +- } ++ return 0; ++} + +- ring_mmap(ring->cnt_addr, size, DMA_TO_DEVICE, &(ring->cnt_phyaddr)); +- tc_dbg(priv, MSG_INIT, "ring: cumulative cnt addr: 0x%x, phy address: 0x%x\n", +- (u32)ring->cnt_addr, ring->cnt_phyaddr); ++#define ring_dnum(tcpriv, name1, name2) ((!tcpriv->param.name1##_dnum) ? name2##_DNUM : tcpriv->param.name1##_dnum) + +- return; +-} ++static void ring_free(struct tc_priv *priv, struct aca_ring *ring) ++{ ++ struct device *pdev = priv->ep_dev[0].dev; + +-#define ring_init(tcpriv, ring, name1, name2, num, size) \ +-{ \ +- if (!tcpriv->param.name1##_dnum) \ +- num = name2##_DNUM; \ +- else \ +- num = tcpriv->param.name1##_dnum; \ +- aca_soc_ring_init(tcpriv, ring, num, size); \ ++ if (ring->dnum == 0) { ++ return; ++ } ++ ++ dma_free_coherent(pdev, ring->dsize * ring->dnum, ring->dbase_mem, ring->dbase_phymem); + } + + static irqreturn_t aca_rx_irq_handler(int irq, void *dev_id) +@@ -777,39 +805,55 @@ static irqreturn_t aca_tx_irq_handler(in + return IRQ_HANDLED; + } + +-static void irq_init(struct tc_priv *priv, const char *dev_name) ++static void plat_irq_init(struct tc_priv *priv, const char *dev_name) + { + int ret; + int i; +- char name[IFNAMSIZ]; ++ //char name[IFNAMSIZ]; + + for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { +- sprintf(name, "%s%d", dev_name, i); ++ //snprintf(name, sizeof(name), "aca-rxo%d", i); + + ret = devm_request_irq(priv->ep_dev[i].dev, priv->ep_dev[i].aca_rx_irq, +- aca_rx_irq_handler, 0, name, &priv->ep_dev[i]); ++ aca_rx_irq_handler, 0, "aca-rxo", &priv->ep_dev[i]); + + if (ret) { + tc_err(priv, MSG_INIT, + "ACA RX IRQ request Fail!: irq: %d, ep_id: %d\n", + priv->ep_dev[i].aca_rx_irq, i); + //return; +- } ++ } ++ ++ //snprintf(name, sizeof(name), "aca-txo%d", i); + + ret = devm_request_irq(priv->ep_dev[i].dev, priv->ep_dev[i].aca_tx_irq, +- aca_tx_irq_handler, 0, name, &priv->ep_dev[i]); ++ aca_tx_irq_handler, 0, "aca-txo", &priv->ep_dev[i]); + + if (ret) { + tc_err(priv, MSG_INIT, + "ACA TX IRQ request Fail!: irq: %d, ep_id: %d\n", + priv->ep_dev[i].aca_tx_irq, i); + //return; +- } ++ } + } + + return; + } + ++static void plat_irq_free(struct tc_priv *priv) ++{ ++ int i; ++ ++ for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { ++ ++ /* Unregister RX irq handler */ ++ devm_free_irq(priv->ep_dev[i].dev, priv->ep_dev[i].aca_rx_irq, &priv->ep_dev[i]); ++ ++ /* Unregister TX irq handler */ ++ devm_free_irq(priv->ep_dev[i].dev, priv->ep_dev[i].aca_tx_irq, &priv->ep_dev[i]); ++ } ++} ++ + /** + * Decide txin/rxout queue size + * Create a tx/rx queue +@@ -819,29 +863,68 @@ static int plat_dp_init(struct plat_priv + struct tc_priv *tcpriv; + struct aca_ring_grp *soc_rings; + struct aca_ring *ring; +- int size; + u32 dnum; ++ int i; ++ int ret = 0; + + tcpriv = priv->tc_priv; + +- size = sizeof(struct dma_desc); ++ plat_mem_init(); ++ + soc_rings = &priv->soc_rings; + + /* txin ring */ + ring = &soc_rings->txin; +- ring_init(tcpriv, ring, txin, TXIN, dnum, size); ++ dnum = ring_dnum(tcpriv, txin, TXIN); ++ ret = txlist_init(&soc_rings->txlist, dnum); ++ if (ret < 0) ++ goto err5; ++ ret = ring_init(tcpriv, ring, dnum, sizeof(struct dma_tx_desc)); ++ if (ret < 0) ++ goto err4; + + /* txout ring */ + ring = &soc_rings->txout; +- ring_init(tcpriv, ring, txout, TXOUT, dnum, size); ++ dnum = ring_dnum(tcpriv, txout, TXOUT); ++ ret = ring_init(tcpriv, ring, dnum, sizeof(u32)); ++ if (ret < 0) ++ goto err3; ++ + /* rxin ring */ + ring = &soc_rings->rxin; +- ring_init(tcpriv, ring, rxin, RXIN, dnum, size); ++ dnum = ring_dnum(tcpriv, rxin, RXIN); ++ ret |= ring_init(tcpriv, ring, dnum, sizeof(struct dma_rx_desc)); ++ if (ret < 0) ++ goto err2; ++ + /* rxout ring */ + ring = &soc_rings->rxout; +- ring_init(tcpriv, ring, rxout, RXOUT, dnum, size); ++ dnum = ring_dnum(tcpriv, rxout, RXOUT); ++ ret = ring_init(tcpriv, ring, dnum, sizeof(struct dma_rx_desc)); ++ if (ret < 0) ++ goto err1; ++ ++ for (i = 0; i < EP_MAX_NUM && i < tcpriv->ep_num; i++) { ++ ++ /* Enable RX interrupt */ ++ tcpriv->ep_dev[i].hw_ops->icu_en(&tcpriv->ep_dev[i], ACA_HOSTIF_RX); ++ ++ /* Enable TX interrupt */ ++ tcpriv->ep_dev[i].hw_ops->icu_en(&tcpriv->ep_dev[i], ACA_HOSTIF_TX); ++ } + + return 0; ++ ++err1: ++ ring_free(tcpriv, &soc_rings->rxin); ++err2: ++ ring_free(tcpriv, &soc_rings->txout); ++err3: ++ ring_free(tcpriv, &soc_rings->txin); ++err4: ++ txlist_free(&soc_rings->txlist); ++err5: ++ return ret; + } + + /** +@@ -850,6 +933,26 @@ static int plat_dp_init(struct plat_priv + */ + static void plat_dp_exit(struct plat_priv *priv) + { ++ struct tc_priv *tcpriv = priv->tc_priv; ++ struct aca_ring_grp *soc_rings = &priv->soc_rings; ++ int i; ++ ++ for (i = 0; i < EP_MAX_NUM && i < tcpriv->ep_num; i++) { ++ ++ /* Disable RX interrupt */ ++ tcpriv->ep_dev[i].hw_ops->icu_mask(&tcpriv->ep_dev[i], ACA_HOSTIF_RX); ++ ++ /* Disable TX interrupt */ ++ tcpriv->ep_dev[i].hw_ops->icu_mask(&tcpriv->ep_dev[i], ACA_HOSTIF_TX); ++ } ++ ++ ring_free(tcpriv, &soc_rings->txin); ++ ring_free(tcpriv, &soc_rings->txout); ++ ring_free(tcpriv, &soc_rings->rxin); ++ ring_free(tcpriv, &soc_rings->rxout); ++ ++ txlist_free(&soc_rings->txlist); ++ + return; + } + +@@ -858,45 +961,45 @@ static int plat_soc_cfg_get(struct soc_c + struct plat_priv *priv = g_plat_priv; + + /* TXIN */ +- cfg->txin_dbase = priv->soc_rings.txin.dbase_phymem; +- cfg->txin_dnum = priv->soc_rings.txin.dnum; +- cfg->txin_desc_dwsz = DW_SZ(struct dma_desc); +- cfg->txin_cnt_phyaddr = priv->soc_rings.txin.cnt_phyaddr; ++ cfg->txin.soc_phydbase = priv->soc_rings.txin.dbase_phymem; ++ cfg->txin.soc_dnum = priv->soc_rings.txin.dnum; ++ cfg->txin.soc_desc_dwsz = DW_SZ(struct dma_tx_desc); + /* TXOUT */ +- cfg->txout_dbase = priv->soc_rings.txout.dbase_phymem; +- cfg->txout_dnum = priv->soc_rings.txout.dnum; +- cfg->txout_desc_dwsz = DW_SZ(struct dma_desc); +- cfg->txout_cnt_phyaddr = priv->soc_rings.txout.cnt_phyaddr; ++ cfg->txout.soc_phydbase = priv->soc_rings.txout.dbase_phymem; ++ cfg->txout.soc_dnum = priv->soc_rings.txout.dnum; ++ cfg->txout.soc_desc_dwsz = DW_SZ(u32); + /* RXOUT */ +- cfg->rxout_dbase = priv->soc_rings.rxout.dbase_phymem; +- cfg->rxout_dnum = priv->soc_rings.rxout.dnum; +- cfg->rxout_desc_dwsz = DW_SZ(struct dma_desc); +- cfg->rxout_cnt_phyaddr = priv->soc_rings.rxout.cnt_phyaddr; ++ cfg->rxout.soc_phydbase = priv->soc_rings.rxout.dbase_phymem; ++ cfg->rxout.soc_dnum = priv->soc_rings.rxout.dnum; ++ cfg->rxout.soc_desc_dwsz = DW_SZ(struct dma_rx_desc); + /* RXIN */ +- cfg->rxin_dbase = priv->soc_rings.rxin.dbase_phymem; +- cfg->rxin_dnum = priv->soc_rings.rxin.dnum; +- cfg->rxin_desc_dwsz = DW_SZ(struct dma_desc); +- cfg->rxin_cnt_phyaddr = priv->soc_rings.rxin.cnt_phyaddr; ++ cfg->rxin.soc_phydbase = priv->soc_rings.rxin.dbase_phymem; ++ cfg->rxin.soc_dnum = priv->soc_rings.rxin.dnum; ++ cfg->rxin.soc_desc_dwsz = DW_SZ(struct dma_rx_desc); + + tc_info(priv->tc_priv, MSG_INIT, + "id: %d, txin(0x%x: %d, 0x%x), txout(0x%x: %d, 0x%x), rxin(0x%x: %d, 0x%x), rxout(0x%x: %d, 0x%x)\n", +- id, cfg->txin_dbase, cfg->txin_dnum, cfg->txin_cnt_phyaddr, +- cfg->txout_dbase, cfg->txout_dnum, cfg->txout_cnt_phyaddr, +- cfg->rxin_dbase, cfg->rxout_dnum, cfg->rxin_cnt_phyaddr, +- cfg->rxout_dbase, cfg->rxout_dnum, cfg->rxout_cnt_phyaddr); ++ id, cfg->txin.soc_phydbase, cfg->txin.soc_dnum, cfg->txin.soc_cnt_phyaddr, ++ cfg->txout.soc_phydbase, cfg->txout.soc_dnum, cfg->txout.soc_cnt_phyaddr, ++ cfg->rxin.soc_phydbase, cfg->rxin.soc_dnum, cfg->rxin.soc_cnt_phyaddr, ++ cfg->rxout.soc_phydbase, cfg->rxout.soc_dnum, cfg->rxout.soc_cnt_phyaddr); + + return 0; + } + +-static int plat_open(struct net_device *pdev, char *dev_name, +- int *subif, int flag) ++static int plat_open(struct net_device *pdev, const char *dev_name, ++ int id, int flag) + { ++ g_plat_priv->netdev = pdev; ++ + return 0; + } + +-static void plat_close(struct net_device *pdev, char *dev_name, +- int subif, int flag) ++static void plat_close(struct net_device *pdev, const char *dev_name, ++ int flag) + { ++ g_plat_priv->netdev = NULL; ++ + return; + } + +@@ -971,7 +1074,6 @@ static void plat_disable_us(int en) + static int plat_get_mib(struct net_device *pdev, + struct rtnl_link_stats64 *stat) + { +- pr_info("%s is not supported\n", __func__); + return -ENOTSUPP; + } + +@@ -1181,8 +1283,8 @@ int platform_init(struct tc_priv *tc_pri + INIT_WORK(&priv->req_work.work, plat_tc_req_workqueue); + tasklet_init(&txout_task, plat_txout_tasklet, 0); + tasklet_init(&rxout_task, plat_rxout_tasklet, 0); +- irq_init(tc_priv, drv_name); +- //tasklet_init(&priv->coc.coc_task, plat_coc_tasklet, 0); ++ plat_irq_init(tc_priv, drv_name); ++ + plat_tc_ops_setup(tc_priv); + plat_dsl_ops_setup(); + +@@ -1201,8 +1303,15 @@ void platform_dsl_exit(void) + + void platform_exit(void) + { +- //tasklet_kill(&g_plat_priv->coc.coc_task); ++ struct tc_priv *tcpriv = plat_to_tcpriv(); ++ ++ tasklet_kill(&txout_task); ++ tasklet_kill(&rxout_task); ++ ++ plat_irq_free(tcpriv); ++ + plat_dp_exit(g_plat_priv); ++ + g_plat_priv = NULL; + } + diff --git a/package/kernel/lantiq/vrx518_tc/patches/201-desc-length.patch b/package/kernel/lantiq/vrx518_tc/patches/201-desc-length.patch new file mode 100644 index 00000000000..134f119f3c0 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/201-desc-length.patch @@ -0,0 +1,342 @@ +Port FEATURE_CONF_DESC_LENGTH from the grx500 variant of the driver. +This also reduces the default length of some descriptors, resulting in +significantly lower latencies when the line is saturated. + +--- a/dcdp/inc/tc_common.h ++++ b/dcdp/inc/tc_common.h +@@ -27,7 +27,11 @@ + #define UMT_DEF_PERIOD 400 /* microseconds */ + + #define MAX_MTU (DMA_PACKET_SZ - ETH_HLEN - HD_RSRV_SZ) ++#ifdef FEATURE_CONF_DESC_LENGTH ++#define QOSQ_NUM 8 ++#else + #define QOSQ_NUM 2 ++#endif + #define FW_STOP_TIMEOUT 20 /* millisecond */ + #define QOS_DISPATCH_OWN 0 + #define ACA_TXIN_POLL_INTVAL 10 /* millisecond */ +--- a/dcdp/inc/tc_main.h ++++ b/dcdp/inc/tc_main.h +@@ -30,6 +30,7 @@ + #define TCPRIV_ALIGN 32 + #define DMA_PACKET_SZ 2048 + ++#define FEATURE_CONF_DESC_LENGTH 1 + #define FEATURE_POWER_DOWN 1 + + enum { +@@ -157,6 +158,25 @@ struct tc_param { + unsigned int txout_dnum; + unsigned int rxin_dnum; + unsigned int rxout_dnum; ++ ++#ifdef FEATURE_CONF_DESC_LENGTH ++ /* __US_FAST_PATH_DES_LIST_NUM:64 ++ * __ACA_TX_IN_PD_LIST_NUM ++ * __ACA_TX_OUT_PD_LIST_NUM ++ * */ ++ u32 conf_us_fp_desq_len; ++ /* ++ * Number of queue per QoS queue: QOS_DES_NUM / QOSQ_NUM ++ * */ ++ u32 conf_us_qos_queue_len; ++ /* __US_OUTQ0_DES_LIST_NUM: 32 ++ * __US_OUTQ1_DES_LIST_NUM: 32 ++ * OUTQ_DESC_PER_Q ++ * */ ++ u32 conf_us_outq_len; ++ /**/ ++ u32 conf_us_local_q0_desq_len; ++#endif + }; + + struct cdma { +--- a/dcdp/ptm_tc.c ++++ b/dcdp/ptm_tc.c +@@ -78,7 +78,11 @@ static const u32 tx_kvec[] = { + 0x30B1B233, 0xB43536B7, 0xB8393ABB, 0x3CBDBE3F, + 0xC04142C3, 0x44C5C647, 0x48C9CA4B, 0xCC4D4ECF + }; ++#ifndef FEATURE_CONF_DESC_LENGTH + static const u32 def_outq_map[OUTQ_PNUM] = {0x1, 0xFE}; ++#else ++static const u32 def_outq_map[OUTQ_PNUM] = {0x0, 0xFF}; ++#endif + static const char ptm_drv_name[] = "PTM SL"; + static const char ptm_bond_name[][IFNAMSIZ] = {"PTM US BOND", "PTM DS BOND"}; + +@@ -1018,6 +1022,10 @@ static void us_fp_desq_cfg_ctxt_init(str + int i; + u32 desc_addr; + rx_descriptor_t desc; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ struct tc_priv *tc_priv; ++ tc_priv = priv->tc_priv; ++#endif + + memset(&desq_cfg, 0, sizeof(desq_cfg)); + /* Initialize US Fast-Path Descriptor Queue Config/Context */ +@@ -1025,7 +1033,11 @@ static void us_fp_desq_cfg_ctxt_init(str + desq_cfg.fast_path = 1; + desq_cfg.mbox_int_en = 0; + desq_cfg.des_sync_needed = 0; ++#ifndef FEATURE_CONF_DESC_LENGTH + desq_cfg.des_num = __US_FAST_PATH_DES_LIST_NUM; ++#else ++ desq_cfg.des_num = tc_priv->param.conf_us_fp_desq_len; ++#endif + desq_cfg.des_base_addr = __US_FAST_PATH_DES_LIST_BASE; + + tc_mem_write(priv, fpi_addr(__US_FP_INQ_DES_CFG_CTXT), +@@ -1049,12 +1061,20 @@ static void us_qos_desq_cfg_ctxt_init(st + int offset, i; + rx_descriptor_t desc; + u32 phy_addr; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ struct tc_priv *tc_priv; ++ tc_priv = priv->tc_priv; ++#endif + + /* Setup QoSQ_CFG_CTXT */ + memset(&qosq_cfg_ctxt, 0, sizeof(qosq_cfg_ctxt)); + + qosq_cfg_ctxt.threshold = 8; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ qosq_cfg_ctxt.des_num = tc_priv->param.conf_us_qos_queue_len; ++#else + qosq_cfg_ctxt.des_num = QOS_DES_NUM / QOSQ_NUM; ++#endif + + offset = 0; + for (i = 0; i < QOSQ_NUM; i++) { +@@ -1093,6 +1113,10 @@ static void us_outq_desq_cfg_ctxt_init(s + u32 phy_addr; + int i; + u32 offset; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ struct tc_priv *tc_priv; ++ tc_priv = priv->tc_priv; ++#endif + + /* Setup OUTQ_QoS_CFG_CTXT */ + /* NOTE: By default, Shaping & WFQ both are DISABLED!! */ +@@ -1121,7 +1145,11 @@ static void us_outq_desq_cfg_ctxt_init(s + desq_cfg.des_in_own_val = US_OUTQ_DES_OWN; + desq_cfg.mbox_int_en = 0; + desq_cfg.des_sync_needed = 0; +- desq_cfg.des_num = 32; ++#ifndef FEATURE_CONF_DESC_LENGTH ++ desq_cfg.des_num = OUTQ_DESC_PER_Q; ++#else ++ desq_cfg.des_num = tc_priv->param.conf_us_outq_len; ++#endif + /** + * Only BC0 is used in VRX518 + */ +@@ -1187,7 +1215,11 @@ static void us_qos_cfg_init(struct ptm_e + /* Set QoS NO DROP */ + sb_w32(1, __QOSQ_NO_DROP); + /* Enable Preemption function/Disable QoS by default */ ++#ifdef FEATURE_CONF_DESC_LENGTH ++ sb_w32(0, _CHK_PREEMP_MAP); ++#else + sb_w32(1, _CHK_PREEMP_MAP); ++#endif + /* By default, all qid mappint to non-preemption queue */ + sb_w32(0x0, _QID2PREEMP_MAP); + +@@ -1389,6 +1421,11 @@ static void ptm_local_desq_cfg_ctxt_init + u32 dcnt, addr, pdbram_base; + unsigned int us_des_alloc[] = { + __US_TC_LOCAL_Q0_DES_LIST_NUM, __US_TC_LOCAL_Q1_DES_LIST_NUM}; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ struct tc_priv *tc_priv; ++ tc_priv = priv->tc_priv; ++ us_des_alloc[0] = tc_priv->param.conf_us_local_q0_desq_len; ++#endif + + /* Setup the Local DESQ Configuration/Context for UpStream Queues */ + memset(&desq_cfg, 0, sizeof(desq_cfg)); +@@ -2334,6 +2371,10 @@ static void ptm_aca_init(struct ptm_ep_p + u32 phybase = priv->ep->phy_membase; + u32 start; + u32 type; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ struct tc_priv *tc_priv; ++ tc_priv = priv->tc_priv; ++#endif + + priv->tc_priv->tc_ops.soc_cfg_get(&priv->tc_priv->cfg, ptm_id(priv)); + memset(¶m, 0, sizeof(param)); +@@ -2347,7 +2388,11 @@ static void ptm_aca_init(struct ptm_ep_p + #endif + txin->hd_size_in_dw = cfg->txin.soc_desc_dwsz; + txin->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_IN_PD_LIST_BASE); ++#ifndef FEATURE_CONF_DESC_LENGTH + txin->pd_desc_num = __ACA_TX_IN_PD_LIST_NUM; ++#else ++ txin->pd_desc_num = tc_priv->param.conf_us_fp_desq_len; ++#endif + txin->pd_size_in_dw = DESC_DWSZ; + txin->soc_desc_base = cfg->txin.soc_phydbase; + txin->soc_desc_num = cfg->txin.soc_dnum; +--- a/dcdp/tc_main.c ++++ b/dcdp/tc_main.c +@@ -182,6 +182,12 @@ static inline void init_local_param(stru + priv->param.txout_dnum = txout_num; + priv->param.rxin_dnum = rxin_num; + priv->param.rxout_dnum = rxout_num; ++#ifdef FEATURE_CONF_DESC_LENGTH ++ priv->param.conf_us_fp_desq_len = 32; ++ priv->param.conf_us_qos_queue_len = 32; ++ priv->param.conf_us_outq_len = 32; ++ priv->param.conf_us_local_q0_desq_len = 16; ++#endif + priv->tc_mode = TC_NONE_MODE; + priv->tc_stat = NO_TC; + +--- a/dcdp/tc_proc.c ++++ b/dcdp/tc_proc.c +@@ -1118,6 +1118,9 @@ static int proc_read_ver(struct seq_file + (date >> 16) & 0xff, + (date & 0xffff)); + ++#ifdef FEATURE_CONF_DESC_LENGTH ++ seq_puts(seq, " + Support QoS and Configurable descriptor length\n"); ++#endif + #ifdef FEATURE_POWER_DOWN + seq_puts(seq, " + Support Power Down enhancement feature\n"); + #endif +@@ -1170,6 +1173,113 @@ static const struct proc_ops tc_soc_proc + .proc_release = single_release, + }; + ++#ifdef FEATURE_CONF_DESC_LENGTH ++static ssize_t proc_write_desc_conf(struct file *file, const char __user *buf, ++ size_t count, loff_t *data) ++{ ++ struct tc_priv *priv; ++ char str[32]; ++ int len, rlen, temp; ++ int num, temp_num; ++ char *param_list[20]; ++ len = count < sizeof(str) ? count : sizeof(str) - 1; ++ rlen = len - copy_from_user(str, buf, len); ++ str[rlen] = 0; ++ ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EPERM; ++ ++ priv = (struct tc_priv *)PDE_DATA(file_inode(file)); ++ if (priv == NULL) ++ return count; ++ ++ num = vrx_split_buffer(str, param_list, ARRAY_SIZE(param_list)); ++ if (num < 1 || num > 4) ++ goto proc_dbg_desc_conf; ++ ++ temp_num = num; ++ if (num-- != 0) { ++ temp = vrx_atoi(param_list[0]); ++ if (temp < 1 || temp > 128) { ++ pr_info("Fastpath valid range: 1 -> 128\n"); ++ goto proc_dbg_desc_conf; ++ } ++ } ++ if (num-- != 0) { ++ temp = vrx_atoi(param_list[1]); ++ if (temp < 1 || temp > 63) { ++ pr_info("QoS valid range: 1 -> 63\n"); ++ goto proc_dbg_desc_conf; ++ } ++ } ++ if (num-- != 0) { ++ temp = vrx_atoi(param_list[2]); ++ if (temp < 1 || temp > 128) { ++ pr_info("OutQ valid range: 1 -> 128\n"); ++ goto proc_dbg_desc_conf; ++ } ++ } ++ if (num-- != 0) { ++ temp = vrx_atoi(param_list[3]); ++ if (temp < 4 || temp > 16) { ++ pr_info("Local Q0 valid range: 4 -> 16\n"); ++ goto proc_dbg_desc_conf; ++ } ++ } ++ num = temp_num; ++ if (num-- != 0) { ++ priv->param.conf_us_fp_desq_len = vrx_atoi(param_list[0]); ++ } ++ if (num-- != 0) { ++ priv->param.conf_us_qos_queue_len = vrx_atoi(param_list[1]); ++ } ++ if (num-- != 0) { ++ priv->param.conf_us_outq_len = vrx_atoi(param_list[2]); ++ } ++ if (num-- != 0) { ++ priv->param.conf_us_local_q0_desq_len = vrx_atoi(param_list[3]); ++ } ++ ++ return count; ++ ++proc_dbg_desc_conf: ++ pr_info("echo [FP] [QoS] [OutQ] [LocalQ0]> desc_conf\n"); ++ return count; ++} ++ ++static int proc_read_desc_conf(struct seq_file *seq, void *v) ++{ ++ struct tc_priv *priv; ++ priv = (struct tc_priv *)seq->private; ++ if (priv == NULL) ++ return -1; ++ seq_puts(seq, "Upstream descriptor length information:\n"); ++ seq_printf(seq, " - Fastpath: %d\n", ++ priv->param.conf_us_fp_desq_len); ++ seq_printf(seq, " - QoS: %d\n", ++ priv->param.conf_us_qos_queue_len); ++ seq_printf(seq, " - OutQ: %d\n", ++ priv->param.conf_us_outq_len); ++ seq_printf(seq, " - Local Q0: %d\n", ++ priv->param.conf_us_local_q0_desq_len); ++ seq_puts(seq, "\n"); ++ return 0; ++} ++ ++static int proc_read_desc_conf_seq_open(struct inode *inode, struct file *file) ++{ ++ return single_open(file, proc_read_desc_conf, PDE_DATA(inode)); ++} ++#endif ++ ++static const struct proc_ops tc_desc_conf_proc_fops = { ++ .proc_open = proc_read_desc_conf_seq_open, ++ .proc_read = seq_read, ++ .proc_write = proc_write_desc_conf, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++}; ++ + static struct tc_proc_list tc_procs[] = { + {TC_PROC_DIR, 0, NULL, 1}, + {"cfg", 0644, &tc_cfg_proc_fops, 0}, +@@ -1178,6 +1288,9 @@ static struct tc_proc_list tc_procs[] = + {"showtime", 0200, &tc_show_time_proc_fops, 0}, + {"ver", 0644, &tc_ver_proc_fops, 0}, + {"soc", 0644, &tc_soc_proc_fops, 0}, ++#ifdef FEATURE_CONF_DESC_LENGTH ++ {"desc_conf", 0644, &tc_desc_conf_proc_fops, 0}, ++#endif + }; + + int tc_proc_init(struct tc_priv *priv) +@@ -1337,7 +1450,6 @@ proc_ptm_cfg_help: + return count; + } + +- + static const struct proc_ops ptm_cfg_proc_fops = { + .proc_open = proc_read_cfg_seq_open, + .proc_read = seq_read, diff --git a/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch b/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch new file mode 100644 index 00000000000..266beba1a7e --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch @@ -0,0 +1,428 @@ +--- a/dcdp/platform/sw_plat.c ++++ b/dcdp/platform/sw_plat.c +@@ -208,6 +208,8 @@ struct plat_priv { + struct tc_req req_work; + struct aca_ring_grp soc_rings; + struct net_device *netdev; ++ struct napi_struct *napi_tx; ++ struct napi_struct *napi_rx; + DECLARE_HASHTABLE(mem_map, 8); + }; + +@@ -472,7 +474,7 @@ err2: + return -1; + } + +-static void txout_action(struct tc_priv *priv, struct aca_ring *txout) ++static int txout_action(struct tc_priv *priv, struct aca_ring *txout, int budget) + { + struct aca_ring *txin = &g_plat_priv->soc_rings.txin; + struct tx_list *txlist = &g_plat_priv->soc_rings.txlist; +@@ -490,7 +492,10 @@ static void txout_action(struct tc_priv + spin_lock_irqsave(&tx_spinlock, flags); + } + +- for (i = 0; i < txout->dnum; i++) { ++ if (budget == 0 || budget > txout->dnum) ++ budget = txout->dnum; ++ ++ for (i = 0; i < budget; i++) { + desc = txout->dbase_mem; + desc += txout->idx; + +@@ -540,6 +545,8 @@ static void txout_action(struct tc_priv + if (cnt && g_plat_priv->netdev && netif_queue_stopped(g_plat_priv->netdev)) { + netif_wake_queue(g_plat_priv->netdev); + } ++ ++ return cnt; + } + + static void rxin_action(struct tc_priv *priv, +@@ -549,7 +556,7 @@ static void rxin_action(struct tc_priv * + writel(cnt, rxin->umt_dst); + } + +-static int rxout_action(struct tc_priv *priv, struct aca_ring *rxout) ++static int rxout_action(struct tc_priv *priv, struct aca_ring *rxout, int budget) + { + struct device *pdev = priv->ep_dev[0].dev; + int i, cnt; +@@ -559,8 +566,11 @@ static int rxout_action(struct tc_priv * + size_t len; + struct sk_buff *skb; + ++ if (budget == 0 || budget > rxout->dnum) ++ budget = rxout->dnum; ++ + cnt = 0; +- for (i = 0; i < rxout->dnum; i++) { ++ for (i = 0; i < budget; i++) { + desc = rxout->dbase_mem; + desc += rxout->idx; + +@@ -593,14 +603,30 @@ static int rxout_action(struct tc_priv * + ring_idx_inc(rxout); + } + +- if (!cnt) +- tc_err(priv, MSG_RX, "RXOUT spurious interrupt\n"); +- else ++ if (cnt) + writel(cnt, rxout->umt_dst+0x28); // RXOUT_HD_ACCUM_SUB instead of RXOUT_HD_ACCUM_ADD + + return cnt; + } + ++static int plat_txout_napi(struct napi_struct *napi, int budget) ++{ ++ struct plat_priv *priv = g_plat_priv; ++ struct tc_priv *tcpriv = plat_to_tcpriv(); ++ struct aca_ring *txout = &priv->soc_rings.txout; ++ struct dc_ep_dev *ep_dev = &tcpriv->ep_dev[txout->ep_dev_idx]; ++ int cnt; ++ ++ cnt = txout_action(tcpriv, txout, budget); ++ ++ if (cnt < budget) { ++ if (napi_complete_done(napi, cnt)) ++ ep_dev->hw_ops->icu_en(ep_dev, ACA_HOSTIF_TX); ++ } ++ ++ return cnt; ++} ++ + static void plat_txout_tasklet(unsigned long arg) + { + struct plat_priv *priv = g_plat_priv; +@@ -608,12 +634,33 @@ static void plat_txout_tasklet(unsigned + struct aca_ring *txout = &priv->soc_rings.txout; + struct dc_ep_dev *ep_dev = &tcpriv->ep_dev[txout->ep_dev_idx]; + +- txout_action(tcpriv, txout); ++ txout_action(tcpriv, txout, 0); + + /* Enable interrupt */ + ep_dev->hw_ops->icu_en(ep_dev, ACA_HOSTIF_TX); + } + ++static int plat_rxout_napi(struct napi_struct *napi, int budget) ++{ ++ struct plat_priv *priv = g_plat_priv; ++ struct tc_priv *tcpriv = plat_to_tcpriv(); ++ struct aca_ring *rxout = &priv->soc_rings.rxout; ++ struct aca_ring *rxin = &priv->soc_rings.rxin; ++ struct dc_ep_dev *ep_dev = &tcpriv->ep_dev[rxout->ep_dev_idx]; ++ int cnt; ++ ++ cnt = rxout_action(tcpriv, rxout, budget); ++ if (cnt) ++ rxin_action(tcpriv, rxin, DMA_PACKET_SZ, cnt); ++ ++ if (cnt < budget) { ++ if (napi_complete_done(napi, cnt)) ++ ep_dev->hw_ops->icu_en(ep_dev, ACA_HOSTIF_RX); ++ } ++ ++ return cnt; ++} ++ + static void plat_rxout_tasklet(unsigned long arg) + { + struct plat_priv *priv = g_plat_priv; +@@ -623,7 +670,7 @@ static void plat_rxout_tasklet(unsigned + struct dc_ep_dev *ep_dev = &tcpriv->ep_dev[rxout->ep_dev_idx]; + int cnt; + +- cnt = rxout_action(tcpriv, rxout); ++ cnt = rxout_action(tcpriv, rxout, 0); + if (cnt) + rxin_action(tcpriv, rxin, DMA_PACKET_SZ, cnt); + +@@ -783,11 +830,22 @@ static irqreturn_t aca_rx_irq_handler(in + { + struct dc_ep_dev *ep_dev = dev_id; + +- /* Disable IRQ in IMCU */ +- ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_RX); ++ if (g_plat_priv->napi_rx) { ++ ++ if (napi_schedule_prep(g_plat_priv->napi_rx)) { ++ ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_RX); ++ __napi_schedule(g_plat_priv->napi_rx); ++ } ++ ++ } else { ++ ++ /* Disable IRQ in IMCU */ ++ ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_RX); + +- /* Start tasklet */ +- tasklet_schedule(&rxout_task); ++ /* Start tasklet */ ++ tasklet_schedule(&rxout_task); ++ ++ } + + return IRQ_HANDLED; + } +@@ -796,15 +854,62 @@ static irqreturn_t aca_tx_irq_handler(in + { + struct dc_ep_dev *ep_dev = dev_id; + +- /* Disable IRQ in IMCU */ +- ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_TX); ++ if (g_plat_priv->napi_tx) { + +- /* Start tasklet */ +- tasklet_schedule(&txout_task); ++ if (napi_schedule_prep(g_plat_priv->napi_tx)) { ++ ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_TX); ++ __napi_schedule(g_plat_priv->napi_tx); ++ } ++ ++ } else { ++ ++ /* Disable IRQ in IMCU */ ++ ep_dev->hw_ops->icu_mask(ep_dev, ACA_HOSTIF_TX); ++ ++ /* Start tasklet */ ++ tasklet_schedule(&txout_task); ++ ++ } + + return IRQ_HANDLED; + } + ++static void plat_net_open(void) ++{ ++ struct plat_priv *priv = g_plat_priv; ++ struct tc_priv *tcpriv = plat_to_tcpriv(); ++ struct aca_ring *rxout = &priv->soc_rings.rxout; ++ struct aca_ring *txout = &priv->soc_rings.txout; ++ struct dc_ep_dev *ep_dev_rx = &tcpriv->ep_dev[rxout->ep_dev_idx]; ++ struct dc_ep_dev *ep_dev_tx = &tcpriv->ep_dev[txout->ep_dev_idx]; ++ ++ if (priv->napi_rx) ++ napi_enable(priv->napi_rx); ++ ep_dev_rx->hw_ops->icu_en(ep_dev_rx, ACA_HOSTIF_RX); ++ ++ if (priv->napi_tx) ++ napi_enable(priv->napi_tx); ++ ep_dev_tx->hw_ops->icu_en(ep_dev_tx, ACA_HOSTIF_TX); ++} ++ ++static void plat_net_stop(void) ++{ ++ struct plat_priv *priv = g_plat_priv; ++ struct tc_priv *tcpriv = plat_to_tcpriv(); ++ struct aca_ring *rxout = &priv->soc_rings.rxout; ++ struct aca_ring *txout = &priv->soc_rings.txout; ++ struct dc_ep_dev *ep_dev_rx = &tcpriv->ep_dev[rxout->ep_dev_idx]; ++ struct dc_ep_dev *ep_dev_tx = &tcpriv->ep_dev[txout->ep_dev_idx]; ++ ++ if (priv->napi_tx) ++ napi_disable(priv->napi_tx); ++ ep_dev_tx->hw_ops->icu_mask(ep_dev_tx, ACA_HOSTIF_TX); ++ ++ if (priv->napi_rx) ++ napi_disable(priv->napi_rx); ++ ep_dev_rx->hw_ops->icu_mask(ep_dev_rx, ACA_HOSTIF_RX); ++} ++ + static void plat_irq_init(struct tc_priv *priv, const char *dev_name) + { + int ret; +@@ -988,17 +1093,49 @@ static int plat_soc_cfg_get(struct soc_c + } + + static int plat_open(struct net_device *pdev, const char *dev_name, ++ struct napi_struct *napi_tx, struct napi_struct *napi_rx, + int id, int flag) + { ++ struct tc_priv *priv = g_plat_priv->tc_priv; ++ int i; ++ ++ for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { ++ disable_irq(priv->ep_dev[i].aca_rx_irq); ++ disable_irq(priv->ep_dev[i].aca_tx_irq); ++ } ++ + g_plat_priv->netdev = pdev; ++ g_plat_priv->napi_tx = napi_tx; ++ g_plat_priv->napi_rx = napi_rx; ++ ++ for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { ++ enable_irq(priv->ep_dev[i].aca_rx_irq); ++ enable_irq(priv->ep_dev[i].aca_tx_irq); ++ } + + return 0; + } + + static void plat_close(struct net_device *pdev, const char *dev_name, ++ struct napi_struct *napi_tx, struct napi_struct *napi_rx, + int flag) + { ++ struct tc_priv *priv = g_plat_priv->tc_priv; ++ int i; ++ ++ for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { ++ disable_irq(priv->ep_dev[i].aca_rx_irq); ++ disable_irq(priv->ep_dev[i].aca_tx_irq); ++ } ++ + g_plat_priv->netdev = NULL; ++ g_plat_priv->napi_tx = NULL; ++ g_plat_priv->napi_rx = NULL; ++ ++ for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { ++ enable_irq(priv->ep_dev[i].aca_rx_irq); ++ enable_irq(priv->ep_dev[i].aca_tx_irq); ++ } + + return; + } +@@ -1084,6 +1221,10 @@ static void plat_tc_ops_setup(struct tc_ + priv->tc_ops.free = plat_mem_free; + priv->tc_ops.dev_reg = plat_open; + priv->tc_ops.dev_unreg = plat_close; ++ priv->tc_ops.net_open = plat_net_open; ++ priv->tc_ops.net_stop = plat_net_stop; ++ priv->tc_ops.napi_tx = plat_txout_napi; ++ priv->tc_ops.napi_rx = plat_rxout_napi; + priv->tc_ops.umt_init = plat_umt_init; + priv->tc_ops.umt_exit = plat_umt_exit; + priv->tc_ops.umt_start = plat_umt_start; +--- a/dcdp/atm_tc.c ++++ b/dcdp/atm_tc.c +@@ -3650,7 +3650,7 @@ static void atm_aca_ring_config_init(str + static int atm_ring_init(struct atm_priv *priv) + { + atm_aca_ring_config_init(priv); +- return priv->tc_priv->tc_ops.dev_reg(NULL, g_atm_dev_name, 0, 0); ++ return priv->tc_priv->tc_ops.dev_reg(NULL, g_atm_dev_name, NULL, NULL, 0, 0); + } + + static int atm_init(struct tc_priv *tcpriv, u32 ep_id) +@@ -4020,7 +4020,7 @@ void atm_tc_unload(void) + /* unregister device */ + if (priv->tc_priv->tc_ops.dev_unreg != NULL) + priv->tc_priv->tc_ops.dev_unreg(NULL, +- g_atm_dev_name, 0); ++ g_atm_dev_name, NULL, NULL, 0); + + /* atm_dev_deinit(priv); */ + /* modem module power off */ +--- a/dcdp/inc/tc_main.h ++++ b/dcdp/inc/tc_main.h +@@ -209,9 +209,15 @@ struct tc_hw_ops { + void (*subif_unreg)(struct net_device *pdev, const char *dev_name, + int subif_id, int flag); + int (*dev_reg)(struct net_device *pdev, const char *dev_name, ++ struct napi_struct *napi_tx, struct napi_struct *napi_rx, + int id, int flag); + void (*dev_unreg)(struct net_device *pdev, const char *dev_name, ++ struct napi_struct *napi_tx, struct napi_struct *napi_rx, + int flag); ++ void (*net_open)(void); ++ void (*net_stop)(void); ++ int (*napi_tx)(struct napi_struct *napi, int budget); ++ int (*napi_rx)(struct napi_struct *napi, int budget); + + /*umt init/exit including the corresponding DMA init/exit */ + int (*umt_init)(u32 umt_id, u32 umt_period, u32 umt_dst); +--- a/dcdp/ptm_tc.c ++++ b/dcdp/ptm_tc.c +@@ -146,7 +146,11 @@ static int ptm_open(struct net_device *d + struct ptm_priv *ptm_tc = netdev_priv(dev); + + tc_info(ptm_tc->tc_priv, MSG_EVENT, "ptm open\n"); ++ ++ ptm_tc->tc_priv->tc_ops.net_open(); ++ + netif_tx_start_all_queues(dev); ++ + #ifdef CONFIG_SOC_TYPE_XWAY + xet_phy_wan_port(7, NULL, 1, 1); + if (ppa_hook_ppa_phys_port_add_fn) +@@ -163,7 +167,11 @@ static int ptm_stop(struct net_device *d + struct ptm_priv *ptm_tc = netdev_priv(dev); + + tc_info(ptm_tc->tc_priv, MSG_EVENT, "ptm stop\n"); ++ + netif_tx_stop_all_queues(dev); ++ ++ ptm_tc->tc_priv->tc_ops.net_stop(); ++ + #ifdef CONFIG_SOC_TYPE_XWAY + if (ppa_drv_datapath_mac_entry_setting) + ppa_drv_datapath_mac_entry_setting(dev->dev_addr, 0, 6, 10, 1, 2); +@@ -564,7 +572,7 @@ static void ptm_rx(struct net_device *de + ptm_tc->stats64.rx_packets++; + ptm_tc->stats64.rx_bytes += skb->len; + +- if (netif_rx(skb) == NET_RX_DROP) ++ if (netif_receive_skb(skb) == NET_RX_DROP) + ptm_tc->stats64.rx_dropped++; + + return; +@@ -664,6 +672,14 @@ static int ptm_dev_init(struct tc_priv * + memcpy(ptm_tc->outq_map, def_outq_map, sizeof(def_outq_map)); + SET_NETDEV_DEV(ptm_tc->dev, tc_priv->ep_dev[id].dev); + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) ++ netif_napi_add(ptm_tc->dev, &ptm_tc->napi_rx, tc_priv->tc_ops.napi_rx); ++ netif_napi_add_tx(ptm_tc->dev, &ptm_tc->napi_tx, tc_priv->tc_ops.napi_tx); ++#else ++ netif_napi_add(ptm_tc->dev, &ptm_tc->napi_rx, tc_priv->tc_ops.napi_rx, NAPI_POLL_WEIGHT); ++ netif_tx_napi_add(ptm_tc->dev, &ptm_tc->napi_tx, tc_priv->tc_ops.napi_tx, NAPI_POLL_WEIGHT); ++ ++#endif + err = register_netdev(ptm_tc->dev); + if (err) + goto err1; +@@ -2618,7 +2634,9 @@ static int ptm_ring_init(struct ptm_ep_p + { + ptm_aca_ring_config_init(priv, id, bonding); + return priv->tc_priv->tc_ops.dev_reg(priv->ptm_tc->dev, +- priv->ptm_tc->dev->name, id, bonding); ++ priv->ptm_tc->dev->name, ++ &priv->ptm_tc->napi_tx, &priv->ptm_tc->napi_rx, ++ id, bonding); + } + + /** +@@ -2973,7 +2991,9 @@ void ptm_tc_unload(enum dsl_tc_mode tc_m + /* unregister device */ + if (ptm_tc->tc_priv->tc_ops.dev_unreg != NULL) + ptm_tc->tc_priv->tc_ops.dev_unreg(ptm_tc->dev, +- ptm_tc->dev->name, 0); ++ ptm_tc->dev->name, ++ &priv->ptm_tc->napi_tx, &priv->ptm_tc->napi_rx, ++ 0); + + /* remove PTM callback function */ + ptm_cb_setup(ptm_tc, 0); +@@ -2991,6 +3011,10 @@ void ptm_exit(void) + + if (!priv) + return; ++ ++ netif_napi_del(&priv->napi_tx); ++ netif_napi_del(&priv->napi_rx); ++ + unregister_netdev(priv->dev); + free_netdev(priv->dev); + +--- a/dcdp/inc/ptm_tc.h ++++ b/dcdp/inc/ptm_tc.h +@@ -119,6 +119,8 @@ struct ptm_priv { + u32 ep_id; + struct ppe_fw fw; + struct net_device *dev; ++ struct napi_struct napi_tx; ++ struct napi_struct napi_rx; + spinlock_t ptm_lock; + struct rtnl_link_stats64 stats64; + int subif_id; diff --git a/package/kernel/lantiq/vrx518_tc/patches/203-dbg.patch b/package/kernel/lantiq/vrx518_tc/patches/203-dbg.patch new file mode 100644 index 00000000000..687e66f991e --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/203-dbg.patch @@ -0,0 +1,120 @@ +--- a/dcdp/platform/sw_plat.c ++++ b/dcdp/platform/sw_plat.c +@@ -85,6 +85,7 @@ struct aca_ring { + u32 dnum; + u32 dsize; + int idx; /* SoC RX/TX index */ ++ u64 cnt; + int ep_dev_idx; + }; + +@@ -210,6 +211,8 @@ struct plat_priv { + struct net_device *netdev; + struct napi_struct *napi_tx; + struct napi_struct *napi_rx; ++ u64 napi_tx_stats[NAPI_POLL_WEIGHT+1]; ++ u64 napi_rx_stats[NAPI_POLL_WEIGHT+1]; + DECLARE_HASHTABLE(mem_map, 8); + }; + +@@ -362,6 +365,7 @@ static void txlist_free(struct tx_list * + static inline void ring_idx_inc(struct aca_ring *ring) + { + ring->idx = (ring->idx + 1) % ring->dnum; ++ ring->cnt += 1; + } + + static struct sk_buff *txin_skb_prepare(struct sk_buff *skb) +@@ -619,6 +623,8 @@ static int plat_txout_napi(struct napi_s + + cnt = txout_action(tcpriv, txout, budget); + ++ priv->napi_tx_stats[cnt] += 1; ++ + if (cnt < budget) { + if (napi_complete_done(napi, cnt)) + ep_dev->hw_ops->icu_en(ep_dev, ACA_HOSTIF_TX); +@@ -653,6 +659,8 @@ static int plat_rxout_napi(struct napi_s + if (cnt) + rxin_action(tcpriv, rxin, DMA_PACKET_SZ, cnt); + ++ priv->napi_rx_stats[cnt] += 1; ++ + if (cnt < budget) { + if (napi_complete_done(napi, cnt)) + ep_dev->hw_ops->icu_en(ep_dev, ACA_HOSTIF_RX); +@@ -1092,6 +1100,56 @@ static int plat_soc_cfg_get(struct soc_c + return 0; + } + ++static struct proc_dir_entry *g_proc_entry; ++ ++static int proc_show(struct seq_file *m, void *p) ++{ ++ struct aca_ring *txin = &g_plat_priv->soc_rings.txin; ++ struct aca_ring *txout = &g_plat_priv->soc_rings.txout; ++ struct aca_ring *rxin = &g_plat_priv->soc_rings.rxin; ++ struct aca_ring *rxout = &g_plat_priv->soc_rings.rxout; ++ int i; ++ ++ seq_printf(m, "napi_tx_stats: "); ++ for (i = 0; i < sizeof(g_plat_priv->napi_tx_stats) / sizeof(g_plat_priv->napi_tx_stats[0]); i++) { ++ if (i == 0) { ++ seq_printf(m, "%llu", g_plat_priv->napi_tx_stats[i]); ++ } else { ++ seq_printf(m, ", %llu", g_plat_priv->napi_tx_stats[i]); ++ } ++ } ++ seq_printf(m, "\n"); ++ ++ seq_printf(m, "napi_rx_stats: "); ++ for (i = 0; i < sizeof(g_plat_priv->napi_rx_stats) / sizeof(g_plat_priv->napi_rx_stats[0]); i++) { ++ if (i == 0) { ++ seq_printf(m, "%llu", g_plat_priv->napi_rx_stats[i]); ++ } else { ++ seq_printf(m, ", %llu", g_plat_priv->napi_rx_stats[i]); ++ } ++ } ++ seq_printf(m, "\n"); ++ ++ seq_printf(m, "txin: %d/%u, %llu\n", txin->idx, txin->dnum, txin->cnt); ++ seq_printf(m, "txout: %d/%u, %llu\n", txout->idx, txout->dnum, txout->cnt); ++ seq_printf(m, "rxin: %d/%u, %llu\n", rxin->idx, rxin->dnum, rxin->cnt); ++ seq_printf(m, "rxout: %d/%u, %llu\n", rxout->idx, rxout->dnum, rxout->cnt); ++ ++ return 0; ++} ++ ++static int proc_open(struct inode *inode, struct file *file) ++{ ++ return single_open(file, proc_show, NULL); ++} ++ ++static struct proc_ops proc_operations = { ++ .proc_open = proc_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release ++}; ++ + static int plat_open(struct net_device *pdev, const char *dev_name, + struct napi_struct *napi_tx, struct napi_struct *napi_rx, + int id, int flag) +@@ -1099,6 +1157,8 @@ static int plat_open(struct net_device * + struct tc_priv *priv = g_plat_priv->tc_priv; + int i; + ++ g_proc_entry = proc_create("swplat", 0600, priv->proc_dir, &proc_operations); ++ + for (i = 0; i < EP_MAX_NUM && i < priv->ep_num; i++) { + disable_irq(priv->ep_dev[i].aca_rx_irq); + disable_irq(priv->ep_dev[i].aca_tx_irq); +@@ -1137,6 +1197,8 @@ static void plat_close(struct net_device + enable_irq(priv->ep_dev[i].aca_tx_irq); + } + ++ proc_remove(g_proc_entry); ++ + return; + } + diff --git a/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch b/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch new file mode 100644 index 00000000000..bf2d82e2b55 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch @@ -0,0 +1,31 @@ +--- a/dcdp/atm_tc.c ++++ b/dcdp/atm_tc.c +@@ -746,7 +746,8 @@ static void atm_aca_init(struct atm_priv + ACA_TXOUT_EN | ACA_RXIN_EN | ACA_RXOUT_EN, 1); + } + +-static int print_datetime(char *buffer, const struct timespec64 *datetime) ++static int print_datetime(char *buffer, int buffer_size, ++ const struct timespec64 *datetime) + { + struct tm nowtm; + char tmbuf[64]; +@@ -765,7 +766,8 @@ static int print_datetime(char *buffer, + nowtm.tm_hour, + nowtm.tm_min, + nowtm.tm_sec); +- snprintf(buffer, sizeof(buffer), "%s.%06d", tmbuf, (int)datetime->tv_nsec / 1000); ++ snprintf(buffer, sizeof(tmbuf)+buffer_size, "%s.%06d", ++ tmbuf, (int)datetime->tv_nsec / 1000); + + return 0; + } +@@ -967,7 +969,7 @@ void show_atm_pvc(struct seq_file *seq, + char buf[64]; + + seq_printf(seq, "\tNet device: %s\n", pvc->dev->name); +- print_datetime(buf, &(pvc->access_time)); ++ print_datetime(buf, sizeof(buf), &(pvc->access_time)); + seq_printf(seq, "\tLast user cell: %s\n", buf); + seq_printf(seq, "\tPort: %d\n", pvc->port); + seq_printf(seq, "\tSoftware TX Queue: %u\n", pvc->sw_txq_tbl); diff --git a/package/kernel/lantiq/vrx518_tc/patches/205-dcdp-ptm_tc-dynamically-alloc-mib.patch b/package/kernel/lantiq/vrx518_tc/patches/205-dcdp-ptm_tc-dynamically-alloc-mib.patch new file mode 100644 index 00000000000..e239ba33466 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/205-dcdp-ptm_tc-dynamically-alloc-mib.patch @@ -0,0 +1,206 @@ +--- a/dcdp/ptm_tc.c ++++ b/dcdp/ptm_tc.c +@@ -307,15 +307,19 @@ static int ptm_tc_get_stats(struct ptm_e + ) + { + struct rtnl_link_stats64 *stat; +- struct wan_rx_mib_table rx_mib; ++ struct wan_rx_mib_table *rx_mib; + unsigned int cur_cnt, last_cnt; + struct intel_tc_ptm_sl_stats *ptm_sl_stats; + struct ptm_priv *ptm_tc; ++ int ret = 0; + if (!priv || !stats) + return -EFAULT; + ptm_tc = priv->ptm_tc; + if (!ptm_tc) + return -EFAULT; ++ rx_mib = kzalloc(sizeof(*rx_mib), GFP_KERNEL); ++ if (!rx_mib) ++ return -ENOMEM; + if (bonding) + stats->tc_info = TC_PTM_BND_MODE; + else +@@ -349,11 +353,11 @@ static int ptm_tc_get_stats(struct ptm_e + ? cur_cnt - last_cnt + : cur_cnt + ((unsigned int)(-1) - last_cnt); + +- tc_mem_read(priv, &rx_mib, ++ tc_mem_read(priv, rx_mib, + fpi_addr(__RX_GIF_MIB_BASE), +- sizeof(rx_mib) ++ sizeof(*rx_mib) + ); +- ptm_sl_stats->wrx_gif_drop_pdu = rx_mib.wrx_dropdes_pdu; ++ ptm_sl_stats->wrx_gif_drop_pdu = rx_mib->wrx_dropdes_pdu; + + cur_cnt = tc_r32(GIF0_RX_CRC_ERR_CNT); + last_cnt = priv->ptm_mib.rx_crc_err_pdu[0]; +@@ -367,7 +371,7 @@ static int ptm_tc_get_stats(struct ptm_e + ? cur_cnt - last_cnt + : cur_cnt + ((unsigned int)(-1) - last_cnt); + +- ptm_sl_stats->wrx_gif_total_bytes = rx_mib.wrx_total_bytes; ++ ptm_sl_stats->wrx_gif_total_bytes = rx_mib->wrx_total_bytes; + cur_cnt = sb_r32(__US_TC_LOCAL_Q_CFG_CTXT_BASE + + offsetof(desq_cfg_ctxt_t, deq_pkt_cnt) / 4); + last_cnt = priv->ptm_mib.tx_total_pdu[0]; +@@ -385,90 +389,108 @@ static int ptm_tc_get_stats(struct ptm_e + /* For bonding information */ + if (bonding) { + int i; +- struct intel_tc_ptm_bonding_stats ptm_ds; +- struct intel_tc_ptm_bonding_stats ptm_us; ++ struct intel_tc_ptm_bonding_stats *ptm_ds; ++ struct intel_tc_ptm_bonding_stats *ptm_us; + struct intel_tc_ptm_bonding_stats *ptm_bonding_stats; ++ ++ ptm_ds = kzalloc(sizeof(*ptm_ds), GFP_KERNEL); ++ if (!ptm_ds) { ++ ret = -ENOMEM; ++ goto free_rx_mib; ++ } ++ ++ ptm_us = kzalloc(sizeof(*ptm_us), GFP_KERNEL); ++ if (!ptm_us) { ++ ret = -ENOMEM; ++ goto free_ptm_ds; ++ } ++ + priv = tc_ep_priv(0); +- ptm_tc_bond_get_stats(priv, &ptm_ds); ++ ptm_tc_bond_get_stats(priv, ptm_ds); + priv = tc_ep_priv(1); +- ptm_tc_bond_get_stats(priv, &ptm_us); ++ ptm_tc_bond_get_stats(priv, ptm_us); + ptm_bonding_stats = + &(stats->stats.ptm_tc_stats.pmt_bonding_stats); + for (i = 0; i < 8; i++) + ptm_bonding_stats->us_gif_mib[i] = +- ptm_ds.us_gif_mib[i] + ptm_us.us_gif_mib[i]; ++ ptm_ds->us_gif_mib[i] + ptm_us->us_gif_mib[i]; + for (i = 0; i < 8; i++) { + ptm_bonding_stats->ds_gif_mib[i].rx_frag_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_frag_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_frag_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_frag_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_frag_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_of_frag_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_of_frag_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_of_frag_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_of_frag_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_of_frag_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_of_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_of_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_of_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_of_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_of_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_oor_frag_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_oor_frag_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_oor_frag_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_oor_frag_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_oor_frag_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_miss_frag_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_miss_frag_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_miss_frag_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_miss_frag_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_miss_frag_byte_cnt; + ptm_bonding_stats->ds_gif_mib[i].rx_to_frag_byte_cnt = +- ptm_ds.ds_gif_mib[i].rx_to_frag_byte_cnt +- + ptm_us.ds_gif_mib[i].rx_to_frag_byte_cnt; ++ ptm_ds->ds_gif_mib[i].rx_to_frag_byte_cnt ++ + ptm_us->ds_gif_mib[i].rx_to_frag_byte_cnt; + } + for (i = 0; i < 4; i++) { + ptm_bonding_stats->ds_bg_mib[i].conform_pkt_cnt = +- ptm_ds.ds_bg_mib[i].conform_pkt_cnt +- + ptm_us.ds_bg_mib[i].conform_pkt_cnt; ++ ptm_ds->ds_bg_mib[i].conform_pkt_cnt ++ + ptm_us->ds_bg_mib[i].conform_pkt_cnt; + ptm_bonding_stats->ds_bg_mib[i].conform_frag_cnt = +- ptm_ds.ds_bg_mib[i].conform_frag_cnt +- + ptm_us.ds_bg_mib[i].conform_frag_cnt; ++ ptm_ds->ds_bg_mib[i].conform_frag_cnt ++ + ptm_us->ds_bg_mib[i].conform_frag_cnt; + ptm_bonding_stats->ds_bg_mib[i].conform_byte_cnt = +- ptm_ds.ds_bg_mib[i].conform_byte_cnt +- + ptm_us.ds_bg_mib[i].conform_byte_cnt; ++ ptm_ds->ds_bg_mib[i].conform_byte_cnt ++ + ptm_us->ds_bg_mib[i].conform_byte_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_sop_pkt_cnt = +- ptm_ds.ds_bg_mib[i].no_sop_pkt_cnt +- + ptm_us.ds_bg_mib[i].no_sop_pkt_cnt; ++ ptm_ds->ds_bg_mib[i].no_sop_pkt_cnt ++ + ptm_us->ds_bg_mib[i].no_sop_pkt_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_sop_frag_cnt = +- ptm_ds.ds_bg_mib[i].no_sop_frag_cnt +- + ptm_us.ds_bg_mib[i].no_sop_frag_cnt; ++ ptm_ds->ds_bg_mib[i].no_sop_frag_cnt ++ + ptm_us->ds_bg_mib[i].no_sop_frag_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_sop_byte_cnt = +- ptm_ds.ds_bg_mib[i].no_sop_byte_cnt +- + ptm_us.ds_bg_mib[i].no_sop_byte_cnt; ++ ptm_ds->ds_bg_mib[i].no_sop_byte_cnt ++ + ptm_us->ds_bg_mib[i].no_sop_byte_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_eop_pkt_cnt = +- ptm_ds.ds_bg_mib[i].no_eop_pkt_cnt +- + ptm_us.ds_bg_mib[i].no_eop_pkt_cnt; ++ ptm_ds->ds_bg_mib[i].no_eop_pkt_cnt ++ + ptm_us->ds_bg_mib[i].no_eop_pkt_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_eop_frag_cnt = +- ptm_ds.ds_bg_mib[i].no_eop_frag_cnt +- + ptm_us.ds_bg_mib[i].no_eop_frag_cnt; ++ ptm_ds->ds_bg_mib[i].no_eop_frag_cnt ++ + ptm_us->ds_bg_mib[i].no_eop_frag_cnt; + ptm_bonding_stats->ds_bg_mib[i].no_eop_byte_cnt = +- ptm_ds.ds_bg_mib[i].no_eop_byte_cnt +- + ptm_us.ds_bg_mib[i].no_eop_byte_cnt; ++ ptm_ds->ds_bg_mib[i].no_eop_byte_cnt ++ + ptm_us->ds_bg_mib[i].no_eop_byte_cnt; + ptm_bonding_stats->ds_bg_mib[i].oversize_pkt_cnt = +- ptm_ds.ds_bg_mib[i].oversize_pkt_cnt +- + ptm_us.ds_bg_mib[i].oversize_pkt_cnt; ++ ptm_ds->ds_bg_mib[i].oversize_pkt_cnt ++ + ptm_us->ds_bg_mib[i].oversize_pkt_cnt; + ptm_bonding_stats->ds_bg_mib[i].oversize_frag_cnt = +- ptm_ds.ds_bg_mib[i].oversize_frag_cnt +- + ptm_us.ds_bg_mib[i].oversize_frag_cnt; ++ ptm_ds->ds_bg_mib[i].oversize_frag_cnt ++ + ptm_us->ds_bg_mib[i].oversize_frag_cnt; + ptm_bonding_stats->ds_bg_mib[i].oversize_byte_cnt = +- ptm_ds.ds_bg_mib[i].oversize_byte_cnt +- + ptm_us.ds_bg_mib[i].oversize_byte_cnt; ++ ptm_ds->ds_bg_mib[i].oversize_byte_cnt ++ + ptm_us->ds_bg_mib[i].oversize_byte_cnt; + ptm_bonding_stats->ds_bg_mib[i].noncosec_pkt_cnt = +- ptm_ds.ds_bg_mib[i].noncosec_pkt_cnt +- + ptm_us.ds_bg_mib[i].noncosec_pkt_cnt; ++ ptm_ds->ds_bg_mib[i].noncosec_pkt_cnt ++ + ptm_us->ds_bg_mib[i].noncosec_pkt_cnt; + ptm_bonding_stats->ds_bg_mib[i].noncosec_frag_cnt = +- ptm_ds.ds_bg_mib[i].noncosec_frag_cnt +- + ptm_us.ds_bg_mib[i].noncosec_frag_cnt; ++ ptm_ds->ds_bg_mib[i].noncosec_frag_cnt ++ + ptm_us->ds_bg_mib[i].noncosec_frag_cnt; + ptm_bonding_stats->ds_bg_mib[i].noncosec_byte_cnt = +- ptm_ds.ds_bg_mib[i].noncosec_byte_cnt +- + ptm_us.ds_bg_mib[i].noncosec_byte_cnt; ++ ptm_ds->ds_bg_mib[i].noncosec_byte_cnt ++ + ptm_us->ds_bg_mib[i].noncosec_byte_cnt; + } ++ kfree(ptm_us); ++free_ptm_ds: ++ kfree(ptm_ds); + } +- return 0; ++free_rx_mib: ++ kfree(rx_mib); ++ return ret; + } + static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) + { diff --git a/package/kernel/leds-ws2812b/Makefile b/package/kernel/leds-ws2812b/Makefile new file mode 100644 index 00000000000..453d2590f65 --- /dev/null +++ b/package/kernel/leds-ws2812b/Makefile @@ -0,0 +1,34 @@ +# +# Copyright (C) 2008-2010 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:=leds-ws2812b +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/leds-ws2812b + SUBMENU:=LED modules + TITLE:=Worldsemi WS2812B (NeoPixel) LED support + FILES:= \ + $(PKG_BUILD_DIR)/leds-ws2812b.ko + AUTOLOAD:=$(call AutoProbe,leds-ws2812b,1) + DEPENDS:=@TARGET_mediatek_filogic +endef + +define KernelPackage/leds-ws2812b/description + LED support for driving WS2812B (NeoPixel) using SPI MOSI. +endef + +define Build/Compile + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules +endef + +$(eval $(call KernelPackage,leds-ws2812b)) diff --git a/package/kernel/leds-ws2812b/src/Makefile b/package/kernel/leds-ws2812b/src/Makefile new file mode 100644 index 00000000000..718a9f708de --- /dev/null +++ b/package/kernel/leds-ws2812b/src/Makefile @@ -0,0 +1 @@ +obj-m := leds-ws2812b.o diff --git a/package/kernel/leds-ws2812b/src/leds-ws2812b.c b/package/kernel/leds-ws2812b/src/leds-ws2812b.c new file mode 100644 index 00000000000..0dba128c1f0 --- /dev/null +++ b/package/kernel/leds-ws2812b/src/leds-ws2812b.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * WorldSemi WS2812B individually-addressable LED driver using SPI + * + * Copyright 2022 Chuanhong Guo <gch981213@gmail.com> + * + * This driver simulates WS2812B protocol using SPI MOSI pin. A one pulse + * is transferred as 3'b110 and a zero pulse is 3'b100. For this driver to + * work properly, the SPI frequency should be 2.105MHz~2.85MHz and it needs + * to transfer all the bytes continuously. + */ + +#include <linux/led-class-multicolor.h> +#include <linux/leds.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/property.h> +#include <linux/spi/spi.h> +#include <linux/mutex.h> +#include <linux/version.h> + +#define WS2812B_BYTES_PER_COLOR 3 +#define WS2812B_NUM_COLORS 3 +/* A continuous 0 for 50us+ as the 'reset' signal */ +#define WS2812B_RESET_LEN 18 + +struct ws2812b_led { + struct led_classdev_mc mc_cdev; + struct mc_subled subled[WS2812B_NUM_COLORS]; + int cascade; +}; + +struct ws2812b_priv { + struct led_classdev ldev; + struct spi_device *spi; + struct mutex mutex; + int num_leds; + size_t data_len; + u8 *data_buf; + struct ws2812b_led leds[]; +}; + +/** + * ws2812b_set_byte - convert a byte of data to 3-byte SPI data for pulses + * @priv: pointer to the private data structure + * @offset: offset of the target byte in the data stream + * @val: 1-byte data to be set + * + * WS2812B receives a stream of bytes from DI, takes the first 3 byte as LED + * brightness and pases the rest to the next LED through the DO pin. + * This function assembles a single byte of data to the LED: + * A bit is represented with a pulse of specific length. A long pulse is a 1 + * and a short pulse is a 0. + * SPI transfers data continuously, MSB first. We can send 3'b100 to create a + * 0 pulse and 3'b110 for a 1 pulse. In this way, a byte of data takes up 3 + * bytes in a SPI transfer: + * 1x0 1x0 1x0 1x0 1x0 1x0 1x0 1x0 + * Let's rearrange it in 8 bits: + * 1x01x01x 01x01x01 x01x01x0 + * The higher 3 bits, middle 2 bits and lower 3 bits are represented with the + * 1st, 2nd and 3rd byte in the SPI transfer respectively. + * There are only 8 combinations for 3 bits and 4 for 2 bits, so we can create + * a lookup table for the 3 bytes. + * e.g. For 0x6b -> 2'b01101011: + * Bit 7-5: 3'b011 -> 10011011 -> 0x9b + * Bit 4-3: 2'b01 -> 01001101 -> 0x4d + * Bit 2-0: 3'b011 -> 00110110 -> 0x36 + */ +static void ws2812b_set_byte(struct ws2812b_priv *priv, size_t offset, u8 val) +{ + /* The lookup table for Bit 7-5 4-3 2-0 */ + const u8 h3b[] = { 0x92, 0x93, 0x9a, 0x9b, 0xd2, 0xd3, 0xda, 0xdb }; + const u8 m2b[] = { 0x49, 0x4d, 0x69, 0x6d }; + const u8 l3b[] = { 0x24, 0x26, 0x34, 0x36, 0xa4, 0xa6, 0xb4, 0xb6 }; + u8 *p = priv->data_buf + WS2812B_RESET_LEN + (offset * WS2812B_BYTES_PER_COLOR); + + p[0] = h3b[val >> 5]; /* Bit 7-5 */ + p[1] = m2b[(val >> 3) & 0x3]; /* Bit 4-3 */ + p[2] = l3b[val & 0x7]; /* Bit 2-0 */ +} + +static int ws2812b_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct led_classdev_mc *mc_cdev = lcdev_to_mccdev(cdev); + struct ws2812b_led *led = + container_of(mc_cdev, struct ws2812b_led, mc_cdev); + struct ws2812b_priv *priv = dev_get_drvdata(cdev->dev->parent); + int ret; + int i; + + led_mc_calc_color_components(mc_cdev, brightness); + + mutex_lock(&priv->mutex); + for (i = 0; i < WS2812B_NUM_COLORS; i++) + ws2812b_set_byte(priv, led->cascade * WS2812B_NUM_COLORS + i, + led->subled[i].brightness); + ret = spi_write(priv->spi, priv->data_buf, priv->data_len); + mutex_unlock(&priv->mutex); + + return ret; +} + +static int ws2812b_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + int cur_led = 0; + struct ws2812b_priv *priv; + struct fwnode_handle *led_node; + int num_leds, i, cnt, ret; + + num_leds = device_get_child_node_count(dev); + + priv = devm_kzalloc(dev, struct_size(priv, leds, num_leds), GFP_KERNEL); + if (!priv) + return -ENOMEM; + priv->data_len = + num_leds * WS2812B_BYTES_PER_COLOR * WS2812B_NUM_COLORS + + WS2812B_RESET_LEN; + priv->data_buf = kzalloc(priv->data_len, GFP_KERNEL); + if (!priv->data_buf) + return -ENOMEM; + + for (i = 0; i < num_leds * WS2812B_NUM_COLORS; i++) + ws2812b_set_byte(priv, i, 0); + + mutex_init(&priv->mutex); + priv->num_leds = num_leds; + priv->spi = spi; + + device_for_each_child_node(dev, led_node) { + struct led_init_data init_data = { + .fwnode = led_node, + }; + /* WS2812B LEDs usually come with GRB color */ + u32 color_idx[WS2812B_NUM_COLORS] = { + LED_COLOR_ID_GREEN, + LED_COLOR_ID_RED, + LED_COLOR_ID_BLUE, + }; + u32 cascade; + + ret = fwnode_property_read_u32(led_node, "reg", &cascade); + if (ret) { + dev_err(dev, "failed to obtain numerical LED index for %s", + fwnode_get_name(led_node)); + goto ERR_UNREG_LEDS; + } + if (cascade >= num_leds) { + dev_err(dev, "LED index of %s is larger than the number of LEDs.", + fwnode_get_name(led_node)); + ret = -EINVAL; + goto ERR_UNREG_LEDS; + } + + cnt = fwnode_property_count_u32(led_node, "color-index"); + if (cnt > 0 && cnt <= WS2812B_NUM_COLORS) + fwnode_property_read_u32_array(led_node, "color-index", + color_idx, (size_t)cnt); + + priv->leds[cur_led].mc_cdev.subled_info = + priv->leds[cur_led].subled; + priv->leds[cur_led].mc_cdev.num_colors = WS2812B_NUM_COLORS; + priv->leds[cur_led].mc_cdev.led_cdev.max_brightness = 255; + priv->leds[cur_led].mc_cdev.led_cdev.brightness_set_blocking = ws2812b_set; + + for (i = 0; i < WS2812B_NUM_COLORS; i++) { + priv->leds[cur_led].subled[i].color_index = color_idx[i]; + priv->leds[cur_led].subled[i].intensity = 255; + } + + priv->leds[cur_led].cascade = cascade; + + ret = led_classdev_multicolor_register_ext( + dev, &priv->leds[cur_led].mc_cdev, &init_data); + if (ret) { + dev_err(dev, "registration of %s failed.", + fwnode_get_name(led_node)); + goto ERR_UNREG_LEDS; + } + cur_led++; + } + + spi_set_drvdata(spi, priv); + + return 0; +ERR_UNREG_LEDS: + for (; cur_led >= 0; cur_led--) + led_classdev_multicolor_unregister(&priv->leds[cur_led].mc_cdev); + mutex_destroy(&priv->mutex); + kfree(priv->data_buf); + return ret; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0) +static void ws2812b_remove(struct spi_device *spi) +#else +static int ws2812b_remove(struct spi_device *spi) +#endif +{ + struct ws2812b_priv *priv = spi_get_drvdata(spi); + int cur_led; + + for (cur_led = priv->num_leds - 1; cur_led >= 0; cur_led--) + led_classdev_multicolor_unregister(&priv->leds[cur_led].mc_cdev); + kfree(priv->data_buf); + mutex_destroy(&priv->mutex); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) + return 0; +#endif +} + +static const struct spi_device_id ws2812b_spi_ids[] = { + { "ws2812b" }, + {}, +}; +MODULE_DEVICE_TABLE(spi, ws2812b_spi_ids); + +static const struct of_device_id ws2812b_dt_ids[] = { + { .compatible = "worldsemi,ws2812b" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ws2812b_dt_ids); + +static struct spi_driver ws2812b_driver = { + .probe = ws2812b_probe, + .remove = ws2812b_remove, + .id_table = ws2812b_spi_ids, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = ws2812b_dt_ids, + }, +}; + +module_spi_driver(ws2812b_driver); + +MODULE_AUTHOR("Chuanhong Guo <gch981213@gmail.com>"); +MODULE_DESCRIPTION("WS2812B LED driver using SPI"); +MODULE_LICENSE("GPL"); diff --git a/package/kernel/linux/Makefile b/package/kernel/linux/Makefile index 9fa68d78f72..6592b01678f 100644 --- a/package/kernel/linux/Makefile +++ b/package/kernel/linux/Makefile @@ -12,7 +12,9 @@ PKG_NAME:=kernel PKG_FLAGS:=hold PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/packages -SCAN_DEPS=modules/*.mk $(TOPDIR)/target/linux/*/modules.mk $(TOPDIR)/include/netfilter.mk +SUBTARGETS = $(sort $(filter-out feeds,$(notdir $(wildcard $(TOPDIR)/target/linux/* $(TOPDIR)/target/linux/feeds/*)))) +SUBTARGET_MODULES = $(foreach t,$(SUBTARGETS),$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(t)/modules.mk $(TOPDIR)/target/linux/$(t)/modules.mk))) +SCAN_DEPS=modules/*.mk $(SUBTARGET_MODULES) $(TOPDIR)/include/netfilter.mk PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:= @@ -35,6 +37,9 @@ endef define Build/Configure endef +define Build/Quilt +endef + define Build/Compile endef @@ -53,7 +58,12 @@ define Package/kernel endef define Package/kernel/install - # nothing to do + $(INSTALL_DIR) $(1)/$(MODULES_SUBDIR) + $(INSTALL_DATA) $(LINUX_DIR)/modules.builtin $(1)/$(MODULES_SUBDIR) + $(SED) 's,.*/,,' $(1)/$(MODULES_SUBDIR)/modules.builtin + strings $(LINUX_DIR)/modules.builtin.modinfo | \ + grep -E -v "\.(file$(if CONFIG_MODULE_STRIPPED,|parmtype))=" | \ + tr '\n' '\0' > $(1)/$(MODULES_SUBDIR)/modules.builtin.modinfo endef define Package/kernel/extra_provides @@ -63,4 +73,4 @@ endef $(eval $(if $(DUMP),,$(call BuildPackage,kernel))) include $(sort $(wildcard ./modules/*.mk)) --include $(TOPDIR)/target/linux/*/modules.mk +-include $(SUBTARGET_MODULES) diff --git a/package/kernel/linux/files/hotplug-sched-teql.sh b/package/kernel/linux/files/hotplug-sched-teql.sh index a0c0e503aa6..2dc4ed4a842 100644 --- a/package/kernel/linux/files/hotplug-sched-teql.sh +++ b/package/kernel/linux/files/hotplug-sched-teql.sh @@ -12,7 +12,7 @@ config_get teql $INTERFACE teql if [ "$teql" != "" ]; then logger Adding device $DEVICE to TEQL master $teql - insmod sch_teql + modprobe sch_teql tc qdisc add dev $DEVICE root $teql # The kernel doesn't let us bring it up until it has at least one diff --git a/package/kernel/linux/files/sysctl-nf-conntrack.conf b/package/kernel/linux/files/sysctl-nf-conntrack.conf index 37baf5fd6ff..c6a0ef362b6 100644 --- a/package/kernel/linux/files/sysctl-nf-conntrack.conf +++ b/package/kernel/linux/files/sysctl-nf-conntrack.conf @@ -3,7 +3,6 @@ net.netfilter.nf_conntrack_acct=1 net.netfilter.nf_conntrack_checksum=0 -net.netfilter.nf_conntrack_max=16384 net.netfilter.nf_conntrack_tcp_timeout_established=7440 net.netfilter.nf_conntrack_udp_timeout=60 net.netfilter.nf_conntrack_udp_timeout_stream=180 diff --git a/package/kernel/linux/modules/block.mk b/package/kernel/linux/modules/block.mk index e5822d95d78..5e6eefa76a9 100644 --- a/package/kernel/linux/modules/block.mk +++ b/package/kernel/linux/modules/block.mk @@ -90,21 +90,6 @@ endef $(eval $(call KernelPackage,ata-artop)) -define KernelPackage/ata-marvell-sata - TITLE:=Marvell Serial ATA support - KCONFIG:=CONFIG_SATA_MV - FILES:=$(LINUX_DIR)/drivers/ata/sata_mv.ko - AUTOLOAD:=$(call AutoLoad,41,sata_mv,1) - $(call AddDepends/ata) -endef - -define KernelPackage/ata-marvell-sata/description - SATA support for marvell chipsets -endef - -$(eval $(call KernelPackage,ata-marvell-sata)) - - define KernelPackage/ata-nvidia-sata TITLE:=Nvidia Serial ATA support KCONFIG:=CONFIG_SATA_NV @@ -243,7 +228,7 @@ define KernelPackage/dm $(LINUX_DIR)/drivers/md/dm-log.ko \ $(LINUX_DIR)/drivers/md/dm-mirror.ko \ $(LINUX_DIR)/drivers/md/dm-region-hash.ko - AUTOLOAD:=$(call AutoLoad,30,dm-mod dm-log dm-region-hash dm-mirror dm-crypt) + AUTOLOAD:=$(call AutoLoad,30,dm-mod dm-log dm-region-hash dm-mirror dm-crypt,1) endef define KernelPackage/dm/description @@ -465,7 +450,7 @@ define KernelPackage/loop CONFIG_BLK_DEV_LOOP \ CONFIG_BLK_DEV_CRYPTOLOOP=n FILES:=$(LINUX_DIR)/drivers/block/loop.ko - AUTOLOAD:=$(call AutoLoad,30,loop) + AUTOLOAD:=$(call AutoLoad,30,loop,1) endef define KernelPackage/loop/description @@ -508,16 +493,41 @@ endef $(eval $(call KernelPackage,nbd)) +define KernelPackage/nvme + SUBMENU:=$(BLOCK_MENU) + TITLE:=NVM Express block device + DEPENDS:=@PCI_SUPPORT +kmod-hwmon-core + KCONFIG:= \ + CONFIG_NVME_CORE \ + CONFIG_BLK_DEV_NVME \ + CONFIG_NVME_MULTIPATH=n \ + CONFIG_NVME_HWMON=y + FILES:= \ + $(LINUX_DIR)/drivers/nvme/host/nvme-core.ko \ + $(LINUX_DIR)/drivers/nvme/host/nvme.ko + AUTOLOAD:=$(call AutoLoad,30,nvme-core nvme,1) +endef + +define KernelPackage/nvme/description + Kernel module for NVM Express solid state drives directly + connected to the PCI or PCI Express bus. +endef + +$(eval $(call KernelPackage,nvme)) + + define KernelPackage/scsi-core SUBMENU:=$(BLOCK_MENU) TITLE:=SCSI device support KCONFIG:= \ CONFIG_SCSI \ + CONFIG_SCSI_COMMON \ CONFIG_BLK_DEV_SD FILES:= \ $(LINUX_DIR)/drivers/scsi/scsi_mod.ko \ + $(LINUX_DIR)/drivers/scsi/scsi_common.ko \ $(LINUX_DIR)/drivers/scsi/sd_mod.ko - AUTOLOAD:=$(call AutoLoad,40,scsi_mod sd_mod,1) + AUTOLOAD:=$(call AutoLoad,40,scsi_mod scsi_common sd_mod,1) endef $(eval $(call KernelPackage,scsi-core)) diff --git a/package/kernel/linux/modules/can.mk b/package/kernel/linux/modules/can.mk index 3060fc09660..4ff85d1c013 100644 --- a/package/kernel/linux/modules/can.mk +++ b/package/kernel/linux/modules/can.mk @@ -121,7 +121,7 @@ define KernelPackage/can-flexcan KCONFIG:=CONFIG_CAN_FLEXCAN FILES:=$(LINUX_DIR)/drivers/net/can/flexcan.ko AUTOLOAD:=$(call AutoProbe,flexcan) - $(call AddDepends/can,@TARGET_imx6) + $(call AddDepends/can,@TARGET_imx) endef define KernelPackage/can-flexcan/description @@ -152,7 +152,7 @@ define KernelPackage/can-mcp251x CONFIG_SPI=y \ CONFIG_CAN_MCP251X FILES:=$(LINUX_DIR)/drivers/net/can/spi/mcp251x.ko - AUTOLOAD:=$(call AutoProbe,can-mcp251x) + AUTOLOAD:=$(call AutoProbe,mcp251x) $(call AddDepends/can) endef diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk index 6cecb1a0fa6..dd17d868fa1 100644 --- a/package/kernel/linux/modules/crypto.mk +++ b/package/kernel/linux/modules/crypto.mk @@ -42,7 +42,7 @@ define KernelPackage/crypto-aead CONFIG_CRYPTO_AEAD2 FILES:= \ $(LINUX_DIR)/crypto/aead.ko \ - $(LINUX_DIR)/crypto/geniv.ko@ge5.10 + $(LINUX_DIR)/crypto/geniv.ko AUTOLOAD:=$(call AutoLoad,09,aead,1) $(call AddDepends/crypto, +kmod-crypto-null) endef @@ -52,6 +52,7 @@ $(eval $(call KernelPackage,crypto-aead)) define KernelPackage/crypto-arc4 TITLE:=ARC4 cipher CryptoAPI module + DEPENDS:=+kmod-crypto-user KCONFIG:= \ CONFIG_CRYPTO_ARC4 \ CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE=y @@ -69,8 +70,10 @@ define KernelPackage/crypto-authenc TITLE:=Combined mode wrapper for IPsec DEPENDS:=+kmod-crypto-manager +kmod-crypto-null KCONFIG:=CONFIG_CRYPTO_AUTHENC - FILES:=$(LINUX_DIR)/crypto/authenc.ko - AUTOLOAD:=$(call AutoLoad,09,authenc) + FILES:= \ + $(LINUX_DIR)/crypto/authenc.ko \ + $(LINUX_DIR)/crypto/authencesn.ko + AUTOLOAD:=$(call AutoLoad,09,authenc authencesn) $(call AddDepends/crypto) endef @@ -101,6 +104,18 @@ endef $(eval $(call KernelPackage,crypto-ccm)) +define KernelPackage/crypto-chacha20poly1305 + TITLE:=ChaCha20-Poly1305 AEAD support, RFC7539 (used by strongSwan IPsec VPN) + DEPENDS:=+kmod-crypto-aead +kmod-crypto-manager + KCONFIG:=CONFIG_CRYPTO_CHACHA20POLY1305 + FILES:=$(LINUX_DIR)/crypto/chacha20poly1305.ko + AUTOLOAD:=$(call AutoLoad,09,chacha20poly1305) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-chacha20poly1305)) + + define KernelPackage/crypto-cmac TITLE:=Support for Cipher-based Message Authentication Code (CMAC) DEPENDS:=+kmod-crypto-hash @@ -225,6 +240,18 @@ endef $(eval $(call KernelPackage,crypto-echainiv)) +define KernelPackage/crypto-essiv + TITLE:=ESSIV support for block encryption + DEPENDS:=+kmod-crypto-authenc + KCONFIG:=CONFIG_CRYPTO_ESSIV + FILES:= $(LINUX_DIR)/crypto/essiv.ko + AUTOLOAD:=$(call AutoLoad,10,essiv) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-essiv)) + + define KernelPackage/crypto-fcrypt TITLE:=FCRYPT cipher CryptoAPI module KCONFIG:=CONFIG_CRYPTO_FCRYPT @@ -287,7 +314,7 @@ define KernelPackage/crypto-ghash/arm-ce AUTOLOAD+=$(call AutoLoad,09,ghash-arm-ce) endef -KernelPackage/crypto-ghash/imx6=$(KernelPackage/crypto-ghash/arm-ce) +KernelPackage/crypto-ghash/imx=$(KernelPackage/crypto-ghash/arm-ce) KernelPackage/crypto-ghash/ipq40xx=$(KernelPackage/crypto-ghash/arm-ce) KernelPackage/crypto-ghash/mvebu/cortexa9=$(KernelPackage/crypto-ghash/arm-ce) @@ -372,6 +399,19 @@ endef $(eval $(call KernelPackage,crypto-hw-hifn-795x)) +define KernelPackage/crypto-hw-ixp4xx + TITLE:=Intel IXP4xx crypto accelerator + DEPENDS:=@TARGET_ixp4xx +kmod-random-core +kmod-crypto-manager +kmod-crypto-authenc +kmod-crypto-des + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_IXP4XX + FILES:=$(LINUX_DIR)/drivers/crypto/ixp4xx_crypto.ko + AUTOLOAD:=$(call AutoProbe,ixp4xx_crypto) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hw-ixp4xx)) + define KernelPackage/crypto-hw-padlock TITLE:=VIA PadLock ACE with AES/SHA hw crypto module @@ -393,8 +433,9 @@ $(eval $(call KernelPackage,crypto-hw-padlock)) define KernelPackage/crypto-hw-safexcel TITLE:= MVEBU SafeXcel Crypto Engine module - DEPENDS:=@(TARGET_mvebu_cortexa53||TARGET_mvebu_cortexa72) +eip197-mini-firmware \ - +kmod-crypto-authenc +kmod-crypto-md5 +kmod-crypto-hmac +kmod-crypto-sha256 +kmod-crypto-sha512 + DEPENDS:=@(TARGET_mvebu_cortexa53||TARGET_mvebu_cortexa72||TARGET_mediatek_filogic||TARGET_mediatek_mt7623) \ + +eip197-mini-firmware +kmod-crypto-authenc +kmod-crypto-des +kmod-crypto-md5 +kmod-crypto-hmac \ + +kmod-crypto-sha1 +kmod-crypto-sha256 +kmod-crypto-sha512 KCONFIG:= \ CONFIG_CRYPTO_HW=y \ CONFIG_CRYPTO_DEV_SAFEXCEL @@ -435,6 +476,35 @@ endef $(eval $(call KernelPackage,crypto-hw-talitos)) +define KernelPackage/crypto-hw-eip93 + TITLE:=MTK EIP93 crypto module + DEPENDS:=@TARGET_ramips_mt7621 \ + +kmod-crypto-authenc \ + +kmod-crypto-des \ + +kmod-crypto-md5 \ + +kmod-crypto-sha1 \ + +kmod-crypto-sha256 + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_EIP93 \ + CONFIG_CRYPTO_DEV_EIP93_AES=y \ + CONFIG_CRYPTO_DEV_EIP93_DES=y \ + CONFIG_CRYPTO_DEV_EIP93_AEAD=y \ + CONFIG_CRYPTO_DEV_EIP93_GENERIC_SW_MAX_LEN=256 \ + CONFIG_CRYPTO_DEV_EIP93_AES_128_SW_MAX_LEN=512 + FILES:=$(LINUX_DIR)/drivers/crypto/mtk-eip93/crypto-hw-eip93.ko + AUTOLOAD:=$(call AutoLoad,09,crypto-hw-eip93) + $(call AddDepends/crypto) +endef + +define KernelPackage/crypto-hw-eip93/description +Kernel module to enable EIP-93 Crypto engine as found +in the Mediatek MT7621 SoC. +It enables DES/3DES/AES ECB/CBC/CTR and +IPSEC offload with authenc(hmac(sha1/sha256), aes/cbc/rfc3686) +endef + +$(eval $(call KernelPackage,crypto-hw-eip93)) define KernelPackage/crypto-kpp TITLE:=Key-agreement Protocol Primitives @@ -446,29 +516,6 @@ endef $(eval $(call KernelPackage,crypto-kpp)) - -define KernelPackage/crypto-lib-blake2s - TITLE:=BLAKE2s hash function library - KCONFIG:=CONFIG_CRYPTO_LIB_BLAKE2S - HIDDEN:=1 - FILES:= \ - $(LINUX_DIR)/lib/crypto/libblake2s.ko \ - $(LINUX_DIR)/lib/crypto/libblake2s-generic.ko - $(call AddDepends/crypto,+PACKAGE_kmod-crypto-hash:kmod-crypto-hash) -endef - -define KernelPackage/crypto-lib-blake2s/config - imply PACKAGE_kmod-crypto-hash -endef - -define KernelPackage/crypto-lib-blake2s/x86/64 - KCONFIG+=CONFIG_CRYPTO_BLAKE2S_X86 - FILES+=$(LINUX_DIR)/arch/x86/crypto/blake2s-x86_64.ko -endef - -$(eval $(call KernelPackage,crypto-lib-blake2s)) - - define KernelPackage/crypto-lib-chacha20 TITLE:=ChaCha library interface KCONFIG:=CONFIG_CRYPTO_LIB_CHACHA @@ -489,6 +536,8 @@ define KernelPackage/crypto-lib-chacha20/arm FILES:=$(LINUX_DIR)/arch/arm/crypto/chacha-neon.ko endef +KernelPackage/crypto-lib-chacha20/armeb=$(KernelPackage/crypto-lib-chacha20/arm) + define KernelPackage/crypto-lib-chacha20/aarch64 KCONFIG+=CONFIG_CRYPTO_CHACHA20_NEON FILES+=$(LINUX_DIR)/arch/arm64/crypto/chacha-neon.ko @@ -537,7 +586,7 @@ define KernelPackage/crypto-lib-curve25519/config imply PACKAGE_kmod-crypto-kpp endef -define KernelPackage/crypto-lib-curve25519/x86/64 +define KernelPackage/crypto-lib-curve25519/x86_64 KCONFIG+=CONFIG_CRYPTO_CURVE25519_X86 FILES+=$(LINUX_DIR)/arch/x86/crypto/curve25519-x86_64.ko endef @@ -552,6 +601,11 @@ ifeq ($(ARCH)-$(CONFIG_KERNEL_MODE_NEON),arm-y) $(KernelPackage/crypto-lib-curve25519/arm-neon) endif +ifdef KernelPackage/crypto-lib-curve25519/$(ARCH) + KernelPackage/crypto-lib-curve25519/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-lib-curve25519/$(ARCH)) +endif + $(eval $(call KernelPackage,crypto-lib-curve25519)) @@ -577,6 +631,8 @@ define KernelPackage/crypto-lib-poly1305/arm FILES:=$(LINUX_DIR)/arch/arm/crypto/poly1305-arm.ko endef +KernelPackage/crypto-lib-poly1305/armeb=$(KernelPackage/crypto-lib-poly1305/arm) + define KernelPackage/crypto-lib-poly1305/aarch64 KCONFIG+=CONFIG_CRYPTO_POLY1305_NEON FILES:=$(LINUX_DIR)/arch/arm64/crypto/poly1305-neon.ko @@ -630,7 +686,8 @@ define KernelPackage/crypto-md5 DEPENDS:=+kmod-crypto-hash KCONFIG:= \ CONFIG_CRYPTO_MD5 \ - CONFIG_CRYPTO_MD5_OCTEON + CONFIG_CRYPTO_MD5_OCTEON \ + CONFIG_CRYPTO_MD5_PPC FILES:=$(LINUX_DIR)/crypto/md5.ko AUTOLOAD:=$(call AutoLoad,09,md5) $(call AddDepends/crypto) @@ -641,6 +698,16 @@ define KernelPackage/crypto-md5/octeon AUTOLOAD+=$(call AutoLoad,09,octeon-md5) endef +define KernelPackage/crypto-md5/powerpc + FILES+=$(LINUX_DIR)/arch/powerpc/crypto/md5-ppc.ko + AUTOLOAD+=$(call AutoLoad,09,md5-ppc) +endef + +ifdef KernelPackage/crypto-md5/$(ARCH) + KernelPackage/crypto-md5/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-md5/$(ARCH)) +endif + $(eval $(call KernelPackage,crypto-md5)) @@ -658,7 +725,7 @@ $(eval $(call KernelPackage,crypto-michael-mic)) define KernelPackage/crypto-misc TITLE:=Other CryptoAPI modules - DEPENDS:=+kmod-crypto-xts + DEPENDS:=+kmod-crypto-xts +kmod-crypto-user KCONFIG:= \ CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE=y \ CONFIG_CRYPTO_CAMELLIA_X86_64 \ @@ -683,7 +750,6 @@ define KernelPackage/crypto-misc CONFIG_CRYPTO_KHAZAD \ CONFIG_CRYPTO_SERPENT \ CONFIG_CRYPTO_TEA \ - CONFIG_CRYPTO_TGR192 \ CONFIG_CRYPTO_TWOFISH \ CONFIG_CRYPTO_TWOFISH_COMMON \ CONFIG_CRYPTO_TWOFISH_586 \ @@ -696,7 +762,6 @@ define KernelPackage/crypto-misc $(LINUX_DIR)/crypto/cast6_generic.ko \ $(LINUX_DIR)/crypto/khazad.ko \ $(LINUX_DIR)/crypto/tea.ko \ - $(LINUX_DIR)/crypto/tgr192.ko \ $(LINUX_DIR)/crypto/twofish_common.ko \ $(LINUX_DIR)/crypto/wp512.ko \ $(LINUX_DIR)/crypto/twofish_generic.ko \ @@ -704,7 +769,7 @@ define KernelPackage/crypto-misc $(LINUX_DIR)/crypto/blowfish_generic.ko \ $(LINUX_DIR)/crypto/serpent_generic.ko AUTOLOAD:=$(call AutoLoad,10,anubis camellia_generic cast_common \ - cast5_generic cast6_generic khazad tea tgr192 twofish_common \ + cast5_generic cast6_generic khazad tea twofish_common \ wp512 blowfish_common serpent_generic) ifndef CONFIG_TARGET_x86 AUTOLOAD+= $(call AutoLoad,10,twofish_generic blowfish_generic) @@ -717,15 +782,14 @@ ifndef CONFIG_TARGET_x86_64 FILES+= \ $(LINUX_DIR)/arch/x86/crypto/twofish-i586.ko \ $(LINUX_DIR)/arch/x86/crypto/serpent-sse2-i586.ko \ - $(LINUX_DIR)/arch/x86/crypto/glue_helper.ko \ $(LINUX_DIR)/crypto/cryptd.ko \ $(LINUX_DIR)/crypto/crypto_simd.ko - AUTOLOAD+= $(call AutoLoad,10,cryptd glue_helper \ + AUTOLOAD+= $(call AutoLoad,10,cryptd \ serpent-sse2-i586 twofish-i586 blowfish_generic) endef endif -define KernelPackage/crypto-misc/x86/64 +define KernelPackage/crypto-misc/x86_64 FILES+= \ $(LINUX_DIR)/arch/x86/crypto/camellia-x86_64.ko \ $(LINUX_DIR)/arch/x86/crypto/blowfish-x86_64.ko \ @@ -745,6 +809,11 @@ define KernelPackage/crypto-misc/x86/64 twofish-avx-x86_64 blowfish-x86_64 serpent-avx-x86_64 serpent-avx2) endef +ifdef KernelPackage/crypto-misc/$(ARCH) + KernelPackage/crypto-misc/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-misc/$(ARCH)) +endif + $(eval $(call KernelPackage,crypto-misc)) @@ -801,7 +870,7 @@ $(eval $(call KernelPackage,crypto-rmd160)) define KernelPackage/crypto-rng TITLE:=CryptoAPI random number generation - DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha256 + DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha512 KCONFIG:= \ CONFIG_CRYPTO_DRBG \ CONFIG_CRYPTO_DRBG_HMAC=y \ @@ -840,6 +909,7 @@ define KernelPackage/crypto-sha1 CONFIG_CRYPTO_SHA1_ARM \ CONFIG_CRYPTO_SHA1_ARM_NEON \ CONFIG_CRYPTO_SHA1_OCTEON \ + CONFIG_CRYPTO_SHA1_PPC_SPE \ CONFIG_CRYPTO_SHA1_SSSE3 FILES:=$(LINUX_DIR)/crypto/sha1_generic.ko AUTOLOAD:=$(call AutoLoad,09,sha1_generic) @@ -857,7 +927,7 @@ define KernelPackage/crypto-sha1/arm-neon AUTOLOAD+=$(call AutoLoad,09,sha1-arm-neon) endef -KernelPackage/crypto-sha1/imx6=$(KernelPackage/crypto-sha1/arm-neon) +KernelPackage/crypto-sha1/imx=$(KernelPackage/crypto-sha1/arm-neon) KernelPackage/crypto-sha1/ipq40xx=$(KernelPackage/crypto-sha1/arm-neon) KernelPackage/crypto-sha1/mvebu/cortexa9=$(KernelPackage/crypto-sha1/arm-neon) @@ -866,12 +936,24 @@ define KernelPackage/crypto-sha1/octeon AUTOLOAD+=$(call AutoLoad,09,octeon-sha1) endef -KernelPackage/crypto-sha1/tegra=$(KernelPakcage/crypto-sha1/arm) +KernelPackage/crypto-sha1/tegra=$(KernelPackage/crypto-sha1/arm) + +define KernelPackage/crypto-sha1/mpc85xx + FILES+=$(LINUX_DIR)/arch/powerpc/crypto/sha1-ppc-spe.ko + AUTOLOAD+=$(call AutoLoad,09,sha1-ppc-spe) +endef -define KernelPackage/crypto-sha1/x86/64 +ifndef CONFIG_TARGET_uml +define KernelPackage/crypto-sha1/x86_64 FILES+=$(LINUX_DIR)/arch/x86/crypto/sha1-ssse3.ko AUTOLOAD+=$(call AutoLoad,09,sha1-ssse3) endef +endif + +ifdef KernelPackage/crypto-sha1/$(ARCH) + KernelPackage/crypto-sha1/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-sha1/$(ARCH)) +endif $(eval $(call KernelPackage,crypto-sha1)) @@ -882,6 +964,7 @@ define KernelPackage/crypto-sha256 KCONFIG:= \ CONFIG_CRYPTO_SHA256 \ CONFIG_CRYPTO_SHA256_OCTEON \ + CONFIG_CRYPTO_SHA256_PPC_SPE \ CONFIG_CRYPTO_SHA256_SSSE3 FILES:= \ $(LINUX_DIR)/crypto/sha256_generic.ko \ @@ -895,10 +978,22 @@ define KernelPackage/crypto-sha256/octeon AUTOLOAD+=$(call AutoLoad,09,octeon-sha256) endef -define KernelPackage/crypto-sha256/x86/64 +define KernelPackage/crypto-sha256/mpc85xx + FILES+=$(LINUX_DIR)/arch/powerpc/crypto/sha256-ppc-spe.ko + AUTOLOAD+=$(call AutoLoad,09,sha256-ppc-spe) +endef + +ifndef CONFIG_TARGET_uml +define KernelPackage/crypto-sha256/x86_64 FILES+=$(LINUX_DIR)/arch/x86/crypto/sha256-ssse3.ko AUTOLOAD+=$(call AutoLoad,09,sha256-ssse3) endef +endif + +ifdef KernelPackage/crypto-sha256/$(ARCH) + KernelPackage/crypto-sha256/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-sha256/$(ARCH)) +endif $(eval $(call KernelPackage,crypto-sha256)) @@ -921,7 +1016,7 @@ define KernelPackage/crypto-sha512/arm AUTOLOAD+=$(call AutoLoad,09,sha512-arm) endef -KernelPackage/crypto-sha512/imx6=$(KernelPackage/crypto-sha512/arm) +KernelPackage/crypto-sha512/imx=$(KernelPackage/crypto-sha512/arm) KernelPackage/crypto-sha512/ipq40xx=$(KernelPackage/crypto-sha512/arm) KernelPackage/crypto-sha512/mvebu/cortexa9=$(KernelPackage/crypto-sha512/arm) @@ -932,10 +1027,17 @@ endef KernelPackage/crypto-sha512/tegra=$(KernelPackage/crypto-sha512/arm) -define KernelPackage/crypto-sha512/x86/64 +ifndef CONFIG_TARGET_uml +define KernelPackage/crypto-sha512/x86_64 FILES+=$(LINUX_DIR)/arch/x86/crypto/sha512-ssse3.ko AUTOLOAD+=$(call AutoLoad,09,sha512-ssse3) endef +endif + +ifdef KernelPackage/crypto-sha512/$(ARCH) + KernelPackage/crypto-sha512/$(CRYPTO_TARGET)=\ + $(KernelPackage/crypto-sha512/$(ARCH)) +endif $(eval $(call KernelPackage,crypto-sha512)) diff --git a/package/kernel/linux/modules/fs.mk b/package/kernel/linux/modules/fs.mk index 7de1a0673ce..58af180c280 100644 --- a/package/kernel/linux/modules/fs.mk +++ b/package/kernel/linux/modules/fs.mk @@ -10,7 +10,7 @@ FS_MENU:=Filesystems define KernelPackage/fs-9p SUBMENU:=$(FS_MENU) TITLE:=Plan 9 Resource Sharing Support - DEPENDS:=+kmod-9pnet + DEPENDS:=+kmod-9pnet +LINUX_6_1:kmod-fs-netfs KCONFIG:=\ CONFIG_9P_FS \ CONFIG_9P_FS_POSIX_ACL=n \ @@ -70,7 +70,6 @@ define KernelPackage/fs-btrfs DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib-inflate +kmod-lib-zlib-deflate +kmod-lib-raid6 +kmod-lib-xor +kmod-lib-zstd KCONFIG:=\ CONFIG_BTRFS_FS \ - CONFIG_BTRFS_FS_POSIX_ACL=n \ CONFIG_BTRFS_FS_CHECK_INTEGRITY=n FILES:=\ $(LINUX_DIR)/fs/btrfs/btrfs.ko @@ -84,6 +83,27 @@ endef $(eval $(call KernelPackage,fs-btrfs)) +define KernelPackage/fs-smbfs-common + SUBMENU:=$(FS_MENU) + TITLE:=SMBFS common dependencies support + HIDDEN:=1 + KCONFIG:=\ + CONFIG_SMBFS_COMMON@lt6.1 \ + CONFIG_SMBFS@ge6.1 + FILES:= \ + $(LINUX_DIR)/fs/smbfs_common/cifs_arc4.ko@lt6.1 \ + $(LINUX_DIR)/fs/smbfs_common/cifs_md4.ko@lt6.1 \ + $(LINUX_DIR)/fs/smb/common/cifs_arc4.ko@ge6.1 \ + $(LINUX_DIR)/fs/smb/common/cifs_md4.ko@ge6.1 +endef + +define KernelPackage/fs-smbfs-common/description + Kernel module dependency for CIFS or SMB_SERVER support +endef + +$(eval $(call KernelPackage,fs-smbfs-common)) + + define KernelPackage/fs-cifs SUBMENU:=$(FS_MENU) TITLE:=CIFS support @@ -91,21 +111,25 @@ define KernelPackage/fs-cifs CONFIG_CIFS \ CONFIG_CIFS_DFS_UPCALL=n \ CONFIG_CIFS_UPCALL=n - FILES:=$(LINUX_DIR)/fs/cifs/cifs.ko + FILES:= \ + $(LINUX_DIR)/fs/cifs/cifs.ko@lt6.1 \ + $(LINUX_DIR)/fs/smb/client/cifs.ko@ge6.1 AUTOLOAD:=$(call AutoLoad,30,cifs) $(call AddDepends/nls) DEPENDS+= \ - +kmod-crypto-md4 \ + +kmod-fs-smbfs-common \ +kmod-crypto-md5 \ +kmod-crypto-sha256 \ +kmod-crypto-sha512 \ +kmod-crypto-cmac \ +kmod-crypto-hmac \ - +kmod-crypto-arc4 \ +kmod-crypto-aead \ +kmod-crypto-ccm \ +kmod-crypto-ecb \ - +kmod-crypto-des + +kmod-crypto-des \ + +kmod-asn1-decoder \ + +kmod-oid-registry \ + +kmod-dnsresolver endef define KernelPackage/fs-cifs/description @@ -170,9 +194,7 @@ define KernelPackage/fs-exfat KCONFIG:= \ CONFIG_EXFAT_FS \ CONFIG_EXFAT_DEFAULT_IOCHARSET="utf8" - FILES:= \ - $(LINUX_DIR)/drivers/staging/exfat/exfat.ko@lt5.7 \ - $(LINUX_DIR)/fs/exfat/exfat.ko@ge5.7 + FILES:= $(LINUX_DIR)/fs/exfat/exfat.ko AUTOLOAD:=$(call AutoLoad,30,exfat,1) DEPENDS:=+kmod-nls-base endef @@ -243,18 +265,22 @@ $(eval $(call KernelPackage,fs-f2fs)) define KernelPackage/fs-fscache SUBMENU:=$(FS_MENU) TITLE:=General filesystem local cache manager - DEPENDS:= + DEPENDS:=+kmod-fs-netfs KCONFIG:=\ - CONFIG_FSCACHE=m \ + CONFIG_FSCACHE \ CONFIG_FSCACHE_STATS=y \ CONFIG_FSCACHE_HISTOGRAM=n \ CONFIG_FSCACHE_DEBUG=n \ CONFIG_FSCACHE_OBJECT_LIST=n \ - CONFIG_CACHEFILES=y \ + CONFIG_CACHEFILES \ CONFIG_CACHEFILES_DEBUG=n \ - CONFIG_CACHEFILES_HISTOGRAM=n - FILES:=$(LINUX_DIR)/fs/fscache/fscache.ko - AUTOLOAD:=$(call AutoLoad,29,fscache) + CONFIG_CACHEFILES_HISTOGRAM=n \ + CONFIG_CACHEFILES_ERROR_INJECTION=n@ge5.17 \ + CONFIG_CACHEFILES_ONDEMAND=n@ge5.19 + FILES:= \ + $(LINUX_DIR)/fs/fscache/fscache.ko \ + $(LINUX_DIR)/fs/cachefiles/cachefiles.ko + AUTOLOAD:=$(call AutoLoad,29,fscache cachefiles) endef $(eval $(call KernelPackage,fs-fscache)) @@ -326,6 +352,44 @@ endef $(eval $(call KernelPackage,fs-jfs)) + +define KernelPackage/fs-ksmbd + SUBMENU:=$(FS_MENU) + TITLE:=SMB kernel server support + DEPENDS:= \ + +kmod-nls-base \ + +kmod-nls-utf8 \ + +kmod-crypto-md5 \ + +kmod-crypto-hmac \ + +kmod-crypto-ecb \ + +kmod-crypto-des \ + +kmod-crypto-sha256 \ + +kmod-crypto-cmac \ + +kmod-crypto-sha512 \ + +kmod-crypto-aead \ + +kmod-crypto-ccm \ + +kmod-crypto-gcm \ + +kmod-asn1-decoder \ + +kmod-oid-registry \ + +kmod-fs-smbfs-common + KCONFIG:= \ + CONFIG_SMB_SERVER \ + CONFIG_SMB_SERVER_SMBDIRECT=n \ + CONFIG_SMB_SERVER_CHECK_CAP_NET_ADMIN=n \ + CONFIG_SMB_SERVER_KERBEROS5=n + FILES:= \ + $(LINUX_DIR)/fs/ksmbd/ksmbd.ko@lt6.1 \ + $(LINUX_DIR)/fs/smb/server/ksmbd.ko@ge6.1 + AUTOLOAD:=$(call AutoLoad,41,ksmbd) +endef + +define KernelPackage/fs-ksmbd/description + Kernel module for SMB kernel server support +endef + +$(eval $(call KernelPackage,fs-ksmbd)) + + define KernelPackage/fs-minix SUBMENU:=$(FS_MENU) TITLE:=Minix filesystem support @@ -358,6 +422,17 @@ endef $(eval $(call KernelPackage,fs-msdos)) +define KernelPackage/fs-netfs + SUBMENU:=$(FS_MENU) + TITLE:=Network Filesystems support + KCONFIG:= CONFIG_NETFS_SUPPORT + FILES:=$(LINUX_DIR)/fs/netfs/netfs.ko + AUTOLOAD:=$(call AutoLoad,28,netfs) +endef + +$(eval $(call KernelPackage,fs-netfs)) + + define KernelPackage/fs-nfs SUBMENU:=$(FS_MENU) TITLE:=NFS filesystem client support @@ -381,15 +456,22 @@ $(eval $(call KernelPackage,fs-nfs)) define KernelPackage/fs-nfs-common SUBMENU:=$(FS_MENU) TITLE:=Common NFS filesystem modules + DEPENDS:=+kmod-oid-registry KCONFIG:= \ CONFIG_LOCKD \ CONFIG_SUNRPC \ - CONFIG_GRACE_PERIOD + CONFIG_GRACE_PERIOD \ + CONFIG_NFS_V4=y \ + CONFIG_NFS_V4_1=y \ + CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN="kernel.org" \ + CONFIG_NFS_V4_1_MIGRATION=n \ + CONFIG_NFS_V4_2=y \ + CONFIG_NFS_V4_2_READ_PLUS=n FILES:= \ $(LINUX_DIR)/fs/lockd/lockd.ko \ $(LINUX_DIR)/net/sunrpc/sunrpc.ko \ $(LINUX_DIR)/fs/nfs_common/grace.ko \ - $(LINUX_DIR)/fs/nfs_common/nfs_ssc.ko@ge5.10 + $(LINUX_DIR)/fs/nfs_common/nfs_ssc.ko AUTOLOAD:=$(call AutoLoad,30,grace sunrpc lockd) endef @@ -413,10 +495,9 @@ define KernelPackage/fs-nfs-common-rpcsec CONFIG_SUNRPC_GSS \ CONFIG_RPCSEC_GSS_KRB5 FILES:= \ - $(LINUX_DIR)/lib/oid_registry.ko \ $(LINUX_DIR)/net/sunrpc/auth_gss/auth_rpcgss.ko \ $(LINUX_DIR)/net/sunrpc/auth_gss/rpcsec_gss_krb5.ko - AUTOLOAD:=$(call AutoLoad,31,oid_registry auth_rpcgss rpcsec_gss_krb5) + AUTOLOAD:=$(call AutoLoad,31,auth_rpcgss rpcsec_gss_krb5) endef define KernelPackage/fs-nfs-common-rpcsec/description @@ -471,7 +552,8 @@ define KernelPackage/fs-nfsd CONFIG_NFSD_BLOCKLAYOUT=n \ CONFIG_NFSD_SCSILAYOUT=n \ CONFIG_NFSD_FLEXFILELAYOUT=n \ - CONFIG_NFSD_FAULT_INJECTION=n + CONFIG_NFSD_FAULT_INJECTION=n \ + CONFIG_NFSD_V4_2_INTER_SSC=n FILES:=$(LINUX_DIR)/fs/nfsd/nfsd.ko AUTOLOAD:=$(call AutoLoad,40,nfsd) endef @@ -485,7 +567,7 @@ $(eval $(call KernelPackage,fs-nfsd)) define KernelPackage/fs-ntfs SUBMENU:=$(FS_MENU) - TITLE:=NTFS filesystem support + TITLE:=NTFS filesystem read-only (old driver) support KCONFIG:=CONFIG_NTFS_FS FILES:=$(LINUX_DIR)/fs/ntfs/ntfs.ko AUTOLOAD:=$(call AutoLoad,30,ntfs) @@ -493,12 +575,32 @@ define KernelPackage/fs-ntfs endef define KernelPackage/fs-ntfs/description - Kernel module for NTFS filesystem support + Kernel module for limited NTFS filesystem support. Support for writing + is extremely limited and disabled as a result. endef $(eval $(call KernelPackage,fs-ntfs)) +define KernelPackage/fs-ntfs3 + SUBMENU:=$(FS_MENU) + TITLE:=NTFS filesystem read & write (new driver) support + KCONFIG:= CONFIG_NTFS3_FS CONFIG_NTFS3_FS_POSIX_ACL=y + FILES:=$(LINUX_DIR)/fs/ntfs3/ntfs3.ko + $(call AddDepends/nls) + AUTOLOAD:=$(call AutoLoad,80,ntfs3) +endef + +define KernelPackage/fs-ntfs3/description + Kernel module for fully functional NTFS filesystem support. It allows + reading as well as writing. + + It supports NTFS versions up to 3.1. +endef + +$(eval $(call KernelPackage,fs-ntfs3)) + + define KernelPackage/fs-reiserfs SUBMENU:=$(FS_MENU) TITLE:=ReiserFS filesystem support @@ -556,7 +658,7 @@ define KernelPackage/fs-vfat FILES:= \ $(LINUX_DIR)/fs/fat/fat.ko \ $(LINUX_DIR)/fs/fat/vfat.ko - AUTOLOAD:=$(call AutoLoad,30,fat vfat) + AUTOLOAD:=$(call AutoLoad,30,fat vfat,1) $(call AddDepends/nls,cp437 iso8859-1 utf8) endef @@ -596,3 +698,24 @@ define KernelPackage/fuse/description endef $(eval $(call KernelPackage,fuse)) + + +define KernelPackage/pstore + SUBMENU:=$(FS_MENU) + TITLE:=Pstore file system + DEFAULT:=m if ALL_KMODS + KCONFIG:= \ + CONFIG_PSTORE \ + CONFIG_PSTORE_COMPRESS=y \ + CONFIG_PSTORE_COMPRESS_DEFAULT="deflate" \ + CONFIG_PSTORE_DEFLATE_COMPRESS=y \ + CONFIG_PSTORE_DEFLATE_COMPRESS_DEFAULT=y + FILES:= $(LINUX_DIR)/fs/pstore/pstore.ko + AUTOLOAD:=$(call AutoLoad,30,pstore,1) +endef + +define KernelPackage/pstore/description + Kernel module for pstore filesystem support +endef + +$(eval $(call KernelPackage,pstore)) diff --git a/package/kernel/linux/modules/gpio.mk b/package/kernel/linux/modules/gpio.mk new file mode 100644 index 00000000000..511cd3af8ca --- /dev/null +++ b/package/kernel/linux/modules/gpio.mk @@ -0,0 +1,138 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +GPIO_MENU:=GPIO support + +define KernelPackage/gpio-amd-fch + SUBMENU:=$(GPIO_MENU) + DEPENDS:=@GPIO_SUPPORT @TARGET_x86 + TITLE:=GPIO support for AMD Fusion Controller Hub (G-series SOCs) + KCONFIG:=CONFIG_GPIO_AMD_FCH + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-amd-fch.ko + AUTOLOAD:=$(call AutoLoad,25,gpio-amd-fch,1) +endef + +define KernelPackage/gpio-amd-fch/description + This option enables driver for GPIO on AMDs Fusion Controller Hub, + as found on G-series SOCs (eg. GX-412TC) +endef + +$(eval $(call KernelPackage,gpio-amd-fch)) + + +define KernelPackage/gpio-beeper + SUBMENU:=$(GPIO_MENU) + TITLE:=GPIO beeper support + DEPENDS:=+kmod-input-core + KCONFIG:= \ + CONFIG_INPUT_MISC=y \ + CONFIG_INPUT_GPIO_BEEPER + FILES:= \ + $(LINUX_DIR)/drivers/input/misc/gpio-beeper.ko + AUTOLOAD:=$(call AutoLoad,50,gpio-beeper) +endef + +define KernelPackage/gpio-beeper/description + This enables playing beeps through an GPIO-connected buzzer +endef + +$(eval $(call KernelPackage,gpio-beeper)) + + +define KernelPackage/gpio-cascade + SUBMENU:=$(GPIO_MENU) + TITLE:=Generic GPIO cascade + KCONFIG:=CONFIG_GPIO_CASCADE + DEPENDS:=@GPIO_SUPPORT +kmod-mux-core + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-cascade.ko + AUTOLOAD:=$(call AutoLoad,29,gpio-cascade,1) +endef + +define KernelPackage/gpio-cascade/description + Kernel module for Generic GPIO cascade +endef + +$(eval $(call KernelPackage,gpio-cascade)) + + +define KernelPackage/gpio-f7188x + SUBMENU:=$(GPIO_MENU) + TITLE:=Fintek F718xx/F818xx GPIO Support + DEPENDS:=@GPIO_SUPPORT @TARGET_x86 + KCONFIG:=CONFIG_GPIO_F7188X + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-f7188x.ko + AUTOLOAD:=$(call AutoProbe,gpio-f7188x) +endef + +define KernelPackage/gpio-f7188x/description + Kernel module for the GPIOs found on many Fintek Super-IO chips. +endef + +$(eval $(call KernelPackage,gpio-f7188x)) + + +define KernelPackage/gpio-it87 + SUBMENU:=$(GPIO_MENU) + DEPENDS:=@GPIO_SUPPORT @TARGET_x86 + TITLE:=GPIO support for IT87xx Super I/O chips + KCONFIG:=CONFIG_GPIO_IT87 + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-it87.ko + AUTOLOAD:=$(call AutoLoad,25,gpio-it87,1) +endef + +define KernelPackage/gpio-it87/description + This driver is tested with ITE IT8728 and IT8732 Super I/O chips, and + supports the IT8761E, IT8613, IT8620E, and IT8628E Super I/O chips as + well. +endef + +$(eval $(call KernelPackage,gpio-it87)) + + +define KernelPackage/gpio-nxp-74hc164 + SUBMENU:=$(GPIO_MENU) + TITLE:=NXP 74HC164 GPIO expander support + KCONFIG:=CONFIG_GPIO_74X164 + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-74x164.ko + AUTOLOAD:=$(call AutoProbe,gpio-74x164) +endef + +define KernelPackage/gpio-nxp-74hc164/description + Kernel module for NXP 74HC164 GPIO expander +endef + +$(eval $(call KernelPackage,gpio-nxp-74hc164)) + + +define KernelPackage/gpio-pca953x + SUBMENU:=$(GPIO_MENU) + DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-regmap-i2c + TITLE:=PCA95xx, TCA64xx, and MAX7310 I/O ports + KCONFIG:=CONFIG_GPIO_PCA953X + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pca953x.ko + AUTOLOAD:=$(call AutoLoad,55,gpio-pca953x) +endef + +define KernelPackage/gpio-pca953x/description + Kernel module for MAX731{0,2,3,5}, PCA6107, PCA953{4-9}, PCA955{4-7}, + PCA957{4,5} and TCA64{08,16} I2C GPIO expanders +endef + +$(eval $(call KernelPackage,gpio-pca953x)) + + +define KernelPackage/gpio-pcf857x + SUBMENU:=$(GPIO_MENU) + DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core + TITLE:=PCX857x, PCA967x and MAX732X I2C GPIO expanders + KCONFIG:=CONFIG_GPIO_PCF857X + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pcf857x.ko + AUTOLOAD:=$(call AutoLoad,55,gpio-pcf857x) +endef + +define KernelPackage/gpio-pcf857x/description + Kernel module for PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders +endef + +$(eval $(call KernelPackage,gpio-pcf857x)) diff --git a/package/kernel/linux/modules/hwmon.mk b/package/kernel/linux/modules/hwmon.mk index a39a8910f0a..8afe315344f 100644 --- a/package/kernel/linux/modules/hwmon.mk +++ b/package/kernel/linux/modules/hwmon.mk @@ -43,20 +43,6 @@ endef $(eval $(call KernelPackage,hwmon-ad7418)) -define KernelPackage/hwmon-ads1015 - TITLE:=Texas Instruments ADS1015 - KCONFIG:= CONFIG_SENSORS_ADS1015 - FILES:= $(LINUX_DIR)/drivers/hwmon/ads1015.ko - AUTOLOAD:=$(call AutoLoad,60,ads1015) - $(call AddDepends/hwmon,+kmod-i2c-core) -endef - -define KernelPackage/hwmon-ads1015/description - Kernel module for Texas Instruments ADS1015 Analog-to-Digital converter -endef - -$(eval $(call KernelPackage,hwmon-ads1015)) - define KernelPackage/hwmon-adt7410 TITLE:=ADT7410 monitoring support KCONFIG:= \ @@ -66,7 +52,7 @@ define KernelPackage/hwmon-adt7410 $(LINUX_DIR)/drivers/hwmon/adt7x10.ko \ $(LINUX_DIR)/drivers/hwmon/adt7410.ko AUTOLOAD:=$(call AutoLoad,60,adt7x10 adt7410) - $(call AddDepends/hwmon,+kmod-i2c-core) + $(call AddDepends/hwmon,+kmod-i2c-core +LINUX_6_1:kmod-regmap-core) endef define KernelPackage/hwmon-adt7410/description @@ -91,6 +77,23 @@ endef $(eval $(call KernelPackage,hwmon-adt7475)) +define KernelPackage/hwmon-coretemp + TITLE:=Intel Core/Core2/Atom temperature sensor + KCONFIG:=CONFIG_SENSORS_CORETEMP + FILES:=$(LINUX_DIR)/drivers/hwmon/coretemp.ko + AUTOLOAD:=$(call AutoProbe,coretemp) + $(call AddDepends/hwmon,) +endef + +define KernelPackage/hwmon-coretemp/description + Kernel module for Intel Core/Core2/Atom temperature monitoring support. + Most of the family 6 CPUs are supported. + Check Documentation/hwmon/coretemp.rst for details. +endef + +$(eval $(call KernelPackage,hwmon-coretemp)) + + define KernelPackage/hwmon-dme1737 TITLE:=SMSC DME1737 and compatible monitoring support KCONFIG:=CONFIG_SENSORS_DME1737 @@ -122,6 +125,25 @@ endef $(eval $(call KernelPackage,hwmon-drivetemp)) +define KernelPackage/hwmon-gsc + TITLE:=Gateworks System Controller support + KCONFIG:=CONFIG_MFD_GATEWORKS_GSC \ + CONFIG_SENSORS_GSC + FILES:= \ + $(LINUX_DIR)/drivers/mfd/gateworks-gsc.ko \ + $(LINUX_DIR)/drivers/hwmon/gsc-hwmon.ko + AUTOLOAD:=$(call AutoLoad,20,gsc-hwmon,1) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-gsc/description + Kernel module for Gateworks System Controller with temperature sensor, +ADCs, and FAN controller +endef + +$(eval $(call KernelPackage,hwmon-gsc)) + + define KernelPackage/hwmon-gpiofan TITLE:=Generic GPIO FAN support KCONFIG:=CONFIG_SENSORS_GPIO_FAN @@ -152,6 +174,21 @@ endef $(eval $(call KernelPackage,hwmon-f71882fg)) +define KernelPackage/hwmon-g762 + TITLE:=G762/G763 fan speed PWM controller support + KCONFIG:=CONFIG_SENSORS_G762 + FILES:=$(LINUX_DIR)/drivers/hwmon/g762.ko + AUTOLOAD:=$(call AutoProbe,g762) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-g762/description + Kernel module for Global Mixed-mode Technology Inc G762 and G763 fan speed PWM controller chips. +endef + +$(eval $(call KernelPackage,hwmon-g762)) + + define KernelPackage/hwmon-ina209 TITLE:=INA209 monitoring support KCONFIG:=CONFIG_SENSORS_INA209 @@ -197,6 +234,21 @@ endef $(eval $(call KernelPackage,hwmon-it87)) +define KernelPackage/hwmon-jc42 + TITLE:=Jedec JC42.4 compliant temperature sensors support + KCONFIG:=CONFIG_SENSORS_JC42 + FILES:=$(LINUX_DIR)/drivers/hwmon/jc42.ko + AUTOLOAD:=$(call AutoProbe,jc42) + $(call AddDepends/hwmon,+kmod-i2c-core +kmod-regmap-i2c) +endef + +define KernelPackage/hwmon-jc42/description + Kernel module for Jedec JC42.4 compliant temperature sensors +endef + +$(eval $(call KernelPackage,hwmon-jc42)) + + define KernelPackage/hwmon-lm63 TITLE:=LM63/64 monitoring support KCONFIG:=CONFIG_SENSORS_LM63 @@ -212,6 +264,23 @@ endef $(eval $(call KernelPackage,hwmon-lm63)) +define KernelPackage/hwmon-lm70 + TITLE:=LM70 monitoring support + KCONFIG:=CONFIG_SENSORS_LM70 \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + FILES:=$(LINUX_DIR)/drivers/hwmon/lm70.ko + AUTOLOAD:=$(call AutoProbe,lm70) + $(call AddDepends/hwmon) +endef + +define KernelPackage/hwmon-lm70/description + Kernel module for lm70 and compatible thermal monitor chip +endef + +$(eval $(call KernelPackage,hwmon-lm70)) + + define KernelPackage/hwmon-lm75 TITLE:=LM75 monitoring support KCONFIG:=CONFIG_SENSORS_LM75 @@ -317,6 +386,36 @@ endef $(eval $(call KernelPackage,hwmon-ltc4151)) +define KernelPackage/hwmon-max6642 + TITLE:=MAX6642 monitoring support + KCONFIG:=CONFIG_SENSORS_MAX6642 + FILES:=$(LINUX_DIR)/drivers/hwmon/max6642.ko + AUTOLOAD:=$(call AutoLoad,60,max6642 max6642) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-max6642/description + Kernel module for Maxim MAX6642 temperature monitor +endef + +$(eval $(call KernelPackage,hwmon-max6642)) + + +define KernelPackage/hwmon-max6697 + TITLE:=MAX6697 monitoring support + KCONFIG:=CONFIG_SENSORS_MAX6697 + FILES:=$(LINUX_DIR)/drivers/hwmon/max6697.ko + AUTOLOAD:=$(call AutoProbe,max6697) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-max6697/description + Kernel module for Maxim MAX6697 temperature monitor +endef + +$(eval $(call KernelPackage,hwmon-max6697)) + + define KernelPackage/hwmon-mcp3021 TITLE:=MCP3021/3221 monitoring support KCONFIG:=CONFIG_SENSORS_MCP3021 @@ -335,9 +434,11 @@ $(eval $(call KernelPackage,hwmon-mcp3021)) define KernelPackage/hwmon-nct6775 TITLE:=NCT6106D/6775F/6776F/6779D/6791D/6792D/6793D and compatibles monitoring support KCONFIG:=CONFIG_SENSORS_NCT6775 - FILES:=$(LINUX_DIR)/drivers/hwmon/nct6775.ko + FILES:= \ + $(LINUX_DIR)/drivers/hwmon/nct6775.ko \ + $(LINUX_DIR)/drivers/hwmon/nct6775-core.ko AUTOLOAD:=$(call AutoProbe,nct6775) - $(call AddDepends/hwmon,@PCI_SUPPORT @TARGET_x86 +kmod-hwmon-vid) + $(call AddDepends/hwmon,@PCI_SUPPORT @TARGET_x86 +kmod-hwmon-vid +kmod-regmap-core) endef define KernelPackage/hwmon-nct6775/description @@ -347,6 +448,21 @@ endef $(eval $(call KernelPackage,hwmon-nct6775)) +define KernelPackage/hwmon-nct7802 + TITLE:=NCT7802Y and compatibles monitoring support + KCONFIG:=CONFIG_SENSORS_NCT7802 + FILES:=$(LINUX_DIR)/drivers/hwmon/nct7802.ko + AUTOLOAD:=$(call AutoProbe,nct7802) + $(call AddDepends/hwmon,+kmod-regmap-i2c) +endef + +define KernelPackage/hwmon-nct7802/description + Kernel module for NCT7802Y thermal monitor chip +endef + +$(eval $(call KernelPackage,hwmon-nct7802)) + + define KernelPackage/hwmon-pc87360 TITLE:=PC87360 monitoring support KCONFIG:=CONFIG_SENSORS_PC87360 @@ -441,6 +557,21 @@ endef $(eval $(call KernelPackage,hwmon-sht21)) +define KernelPackage/hwmon-sht3x + TITLE:=Sensiron SHT3x and compat. monitoring support + KCONFIG:=CONFIG_SENSORS_SHT3x + FILES:=$(LINUX_DIR)/drivers/hwmon/sht3x.ko + AUTOLOAD:=$(call AutoProbe,sht3x) + $(call AddDepends/hwmon,+kmod-i2c-core +kmod-lib-crc8) +endef + +define KernelPackage/hwmon-sht3x/description + Kernel module for Sensirion SHT3x temperature and humidity sensors chip +endef + +$(eval $(call KernelPackage,hwmon-sht3x)) + + define KernelPackage/hwmon-tmp102 TITLE:=Texas Instruments TMP102 monitoring support KCONFIG:=CONFIG_SENSORS_TMP102 @@ -486,6 +617,20 @@ endef $(eval $(call KernelPackage,hwmon-tmp421)) +define KernelPackage/hwmon-tps23861 + TITLE:=Texas Instruments TPS23861 PoE PSE + KCONFIG:=CONFIG_SENSORS_TPS23861 + FILES:=$(LINUX_DIR)/drivers/hwmon/tps23861.ko + AUTOLOAD:=$(call AutoProbe,tps23861) + $(call AddDepends/hwmon,+kmod-i2c-core +kmod-regmap-i2c) +endef + +define KernelPackage/hwmon-tps23861/description + Kernel module for the Texas Instruments TPS23861 802.3at PoE PSE chips. +endef + +$(eval $(call KernelPackage,hwmon-tps23861)) + define KernelPackage/hwmon-vid TITLE:=VID/VRM/VRD voltage conversion module. KCONFIG:=CONFIG_HWMON_VID diff --git a/package/kernel/linux/modules/i2c.mk b/package/kernel/linux/modules/i2c.mk index f4297632272..7cd69dbb95a 100644 --- a/package/kernel/linux/modules/i2c.mk +++ b/package/kernel/linux/modules/i2c.mk @@ -84,13 +84,27 @@ endef $(eval $(call KernelPackage,i2c-algo-pcf)) +I2C_CCGS_UCSI_MODULES:= \ + CONFIG_I2C_CCGX_UCSI:drivers/i2c/busses/i2c-ccgx-ucsi + +define KernelPackage/i2c-ccgs-ucsi + $(call i2c_defaults,$(I2C_CCGS_UCSI_MODULES),58) + TITLE:=Cypress CCGx Type-C controller + DEPENDS:=+kmod-i2c-core +kmod-regmap-core + HIDDEN:=y +endef + + +$(eval $(call KernelPackage,i2c-ccgs-ucsi)) + + I2C_DWCORE_MODULES:= \ CONFIG_I2C_DESIGNWARE_CORE:drivers/i2c/busses/i2c-designware-core define KernelPackage/i2c-designware-core $(call i2c_defaults,$(I2C_DWCORE_MODULES),58) TITLE:=Synopsys DesignWare I2C core - DEPENDS:=+kmod-i2c-core +!LINUX_5_4:kmod-regmap-core + DEPENDS:=+kmod-i2c-core +kmod-regmap-core HIDDEN:=y endef @@ -103,7 +117,7 @@ I2C_DWPCI_MODULES:= \ define KernelPackage/i2c-designware-pci $(call i2c_defaults,$(I2C_DWPCI_MODULES),59) TITLE:=Synopsys DesignWare PCI - DEPENDS:=+kmod-i2c-designware-core + DEPENDS:=@PCI_SUPPORT +kmod-i2c-designware-core +kmod-i2c-ccgs-ucsi endef define KernelPackage/i2c-designware-pci/description @@ -186,6 +200,22 @@ endef $(eval $(call KernelPackage,i2c-mux-gpio)) +I2C_MUX_REG_MODULES:= \ + CONFIG_I2C_MUX_REG:drivers/i2c/muxes/i2c-mux-reg + +define KernelPackage/i2c-mux-reg + $(call i2c_defaults,$(I2C_MUX_REG_MODULES),51) + TITLE:=Register-based I2C mux/switches + DEPENDS:=+kmod-i2c-mux +endef + +define KernelPackage/i2c-mux-reg/description + Kernel modules for register-based I2C bus mux/switching devices +endef + +$(eval $(call KernelPackage,i2c-mux-reg)) + + I2C_MUX_PCA9541_MODULES:= \ CONFIG_I2C_MUX_PCA9541:drivers/i2c/muxes/i2c-mux-pca9541 diff --git a/package/kernel/linux/modules/iio.mk b/package/kernel/linux/modules/iio.mk index 7bfbd380792..f901f87ddd5 100644 --- a/package/kernel/linux/modules/iio.mk +++ b/package/kernel/linux/modules/iio.mk @@ -25,14 +25,17 @@ endef $(eval $(call KernelPackage,iio-core)) +define AddDepends/iio + SUBMENU:=$(IIO_MENU) + DEPENDS+=+kmod-iio-core $(1) +endef define KernelPackage/iio-kfifo-buf - SUBMENU:=$(IIO_MENU) TITLE:=Industrial I/O buffering based on kfifo - DEPENDS:=+kmod-iio-core KCONFIG:=CONFIG_IIO_KFIFO_BUF FILES:=$(LINUX_DIR)/drivers/iio/buffer/kfifo_buf.ko AUTOLOAD:=$(call AutoLoad,55,kfifo_buf) + $(call AddDepends/iio) endef define KernelPackage/iio-kfifo-buf/description @@ -44,12 +47,12 @@ $(eval $(call KernelPackage,iio-kfifo-buf)) define KernelPackage/industrialio-triggered-buffer - SUBMENU:=$(IIO_MENU) TITLE:=Provides helper functions for setting up triggered buffers. - DEPENDS:=+kmod-iio-core +kmod-iio-kfifo-buf + DEPENDS:=+kmod-iio-kfifo-buf KCONFIG:=CONFIG_IIO_TRIGGERED_BUFFER FILES:=$(LINUX_DIR)/drivers/iio/buffer/industrialio-triggered-buffer.ko AUTOLOAD:=$(call AutoLoad,55,industrialio-triggered-buffer) + $(call AddDepends/iio) endef define KernelPackage/industrialio-triggered-buffer/description @@ -60,14 +63,14 @@ $(eval $(call KernelPackage,industrialio-triggered-buffer)) define KernelPackage/iio-ad799x - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-i2c-core +kmod-industrialio-triggered-buffer TITLE:=Analog Devices AD799x ADC driver KCONFIG:= \ CONFIG_AD799X_RING_BUFFER=y \ CONFIG_AD799X FILES:=$(LINUX_DIR)/drivers/iio/adc/ad799x.ko AUTOLOAD:=$(call AutoLoad,56,ad799x) + $(call AddDepends/iio) endef define KernelPackage/iio-ad799x/description @@ -78,15 +81,30 @@ endef $(eval $(call KernelPackage,iio-ad799x)) +define KernelPackage/iio-ads1015 + DEPENDS:=+kmod-i2c-core +kmod-regmap-i2c +kmod-industrialio-triggered-buffer + TITLE:=Texas Instruments ADS1015 ADC driver + KCONFIG:= CONFIG_TI_ADS1015 + FILES:=$(LINUX_DIR)/drivers/iio/adc/ti-ads1015.ko + AUTOLOAD:=$(call AutoLoad,56,ti-ads1015) + $(call AddDepends/iio) +endef + +define KernelPackage/iio-ads1015/description + This driver adds support for Texas Instruments ADS1015 and ADS1115 ADCs. +endef + +$(eval $(call KernelPackage,iio-ads1015)) + define KernelPackage/iio-hmc5843 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core +kmod-regmap-i2c +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-i2c-core +kmod-regmap-i2c +kmod-industrialio-triggered-buffer TITLE:=Honeywell HMC58x3 Magnetometer KCONFIG:= CONFIG_SENSORS_HMC5843_I2C FILES:= \ $(LINUX_DIR)/drivers/iio/magnetometer/hmc5843_i2c.ko \ $(LINUX_DIR)/drivers/iio/magnetometer/hmc5843_core.ko AUTOLOAD:=$(call AutoLoad,56,hmc5843) + $(call AddDepends/iio) endef define KernelPackage/iio-hmc5843/description @@ -96,12 +114,12 @@ endef $(eval $(call KernelPackage,iio-hmc5843)) define KernelPackage/iio-bh1750 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core + DEPENDS:=+kmod-i2c-core TITLE:=ROHM BH1750 ambient light sensor KCONFIG:= CONFIG_BH1750 FILES:=$(LINUX_DIR)/drivers/iio/light/bh1750.ko AUTOLOAD:=$(call AutoLoad,56,bh1750) + $(call AddDepends/iio) endef define KernelPackage/iio-bh1750/description ROHM BH1750 ambient light sensor (i2c bus) @@ -109,12 +127,12 @@ endef $(eval $(call KernelPackage,iio-bh1750)) define KernelPackage/iio-am2315 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-i2c-core +kmod-industrialio-triggered-buffer TITLE:=Asong AM2315 humidity/temperature sensor KCONFIG:= CONFIG_AM2315 FILES:=$(LINUX_DIR)/drivers/iio/humidity/am2315.ko AUTOLOAD:=$(call AutoLoad,56,am2315) + $(call AddDepends/iio) endef define KernelPackage/iio-am2315/description Aosong AM2315 humidity/temperature sensor (I2C bus) @@ -122,13 +140,13 @@ endef $(eval $(call KernelPackage,iio-am2315)) define KernelPackage/iio-mxs-lradc - SUBMENU:=$(IIO_MENU) - DEPENDS:=@TARGET_mxs +kmod-iio-core +kmod-industrialio-triggered-buffer + DEPENDS:=@TARGET_mxs +kmod-industrialio-triggered-buffer TITLE:=Freescale i.MX23/i.MX28 LRADC ADC driver KCONFIG:= \ CONFIG_MXS_LRADC_ADC FILES:=$(LINUX_DIR)/drivers/iio/adc/mxs-lradc-adc.ko AUTOLOAD:=$(call AutoLoad,56,mxs-lradc-adc) + $(call AddDepends/iio) endef define KernelPackage/iio-mxs-lradc/description @@ -138,13 +156,13 @@ endef $(eval $(call KernelPackage,iio-mxs-lradc)) define KernelPackage/iio-dht11 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-iio-core @GPIO_SUPPORT @USES_DEVICETREE + DEPENDS:=@GPIO_SUPPORT @USES_DEVICETREE TITLE:=DHT11 (and compatible) humidity and temperature sensors KCONFIG:= \ CONFIG_DHT11 FILES:=$(LINUX_DIR)/drivers/iio/humidity/dht11.ko AUTOLOAD:=$(call AutoLoad,56,dht11) + $(call AddDepends/iio) endef define KernelPackage/iio-dht11/description @@ -157,11 +175,11 @@ $(eval $(call KernelPackage,iio-dht11)) define KernelPackage/iio-bme680 - SUBMENU:=$(IIO_MENU) TITLE:=BME680 gas/humidity/pressure/temperature sensor - DEPENDS:=+kmod-iio-core +kmod-regmap-core + DEPENDS:=+kmod-regmap-core KCONFIG:=CONFIG_BME680 FILES:=$(LINUX_DIR)/drivers/iio/chemical/bme680_core.ko + $(call AddDepends/iio) endef define KernelPackage/iio-bme680/description @@ -172,12 +190,12 @@ endef $(eval $(call KernelPackage,iio-bme680)) define KernelPackage/iio-bme680-i2c - SUBMENU:=$(IIO_MENU) TITLE:=BME680 gas/humidity/pressure/temperature sensor (I2C) DEPENDS:=+kmod-iio-bme680 +kmod-regmap-i2c KCONFIG:=CONFIG_BME680_I2C FILES:=$(LINUX_DIR)/drivers/iio/chemical/bme680_i2c.ko AUTOLOAD:=$(call AutoProbe,bme680-i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-bme680-i2c/description This driver adds support for Bosch Sensortec's BME680 connected via I2C. @@ -186,12 +204,12 @@ endef $(eval $(call KernelPackage,iio-bme680-i2c)) define KernelPackage/iio-bme680-spi - SUBMENU:=$(IIO_MENU) TITLE:=BME680 gas/humidity/pressure/temperature sensor (SPI) DEPENDS:=+kmod-iio-bme680 +kmod-regmap-spi KCONFIG:=CONFIG_BME680_SPI FILES:=$(LINUX_DIR)/drivers/iio/chemical/bme680_spi.ko AUTOLOAD:=$(call AutoProbe,bme680-spi) + $(call AddDepends/iio) endef define KernelPackage/iio-bme680-spi/description This driver adds support for Bosch Sensortec's BME680 connected via SPI. @@ -201,11 +219,11 @@ $(eval $(call KernelPackage,iio-bme680-spi)) define KernelPackage/iio-bmp280 - SUBMENU:=$(IIO_MENU) TITLE:=BMP180/BMP280/BME280 pressure/temperatur sensor - DEPENDS:=+kmod-iio-core +kmod-regmap-core + DEPENDS:=+kmod-regmap-core KCONFIG:=CONFIG_BMP280 FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280.ko + $(call AddDepends/iio) endef define KernelPackage/iio-bmp280/description @@ -218,12 +236,12 @@ $(eval $(call KernelPackage,iio-bmp280)) define KernelPackage/iio-bmp280-i2c - SUBMENU:=$(IIO_MENU) TITLE:=BMP180/BMP280/BME280 pressure/temperatur sensor (I2C) DEPENDS:=+kmod-iio-bmp280 +kmod-i2c-core +kmod-regmap-i2c KCONFIG:=CONFIG_BMP280_I2C FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280-i2c.ko AUTOLOAD:=$(call AutoProbe,bmp280-i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-bmp280-i2c/description This driver adds support for Bosch Sensortec's digital pressure and @@ -234,12 +252,12 @@ $(eval $(call KernelPackage,iio-bmp280-i2c)) define KernelPackage/iio-bmp280-spi - SUBMENU:=$(IIO_MENU) TITLE:=BMP180/BMP280/BME280 pressure/temperatur sensor (SPI) DEPENDS:=+kmod-iio-bmp280 +kmod-spi-bitbang KCONFIG:=CONFIG_BMP280_SPI FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280-spi.ko AUTOLOAD:=$(call AutoProbe,bmp280-spi) + $(call AddDepends/iio) endef define KernelPackage/iio-bmp280-spi/description This driver adds support for Bosch Sensortec's digital pressure and @@ -249,8 +267,7 @@ endef $(eval $(call KernelPackage,iio-bmp280-spi)) define KernelPackage/iio-htu21 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core + DEPENDS:=+kmod-i2c-core TITLE:=HTU21 humidity & temperature sensor KCONFIG:= \ CONFIG_HTU21 \ @@ -259,6 +276,7 @@ define KernelPackage/iio-htu21 $(LINUX_DIR)/drivers/iio/humidity/htu21.ko \ $(LINUX_DIR)/drivers/iio/common/ms_sensors/ms_sensors_i2c.ko AUTOLOAD:=$(call AutoLoad,56,htu21) + $(call AddDepends/iio) endef define KernelPackage/iio-htu21/description @@ -272,13 +290,13 @@ $(eval $(call KernelPackage,iio-htu21)) define KernelPackage/iio-ccs811 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-i2c-core +kmod-industrialio-triggered-buffer TITLE:=AMS CCS811 VOC sensor KCONFIG:= \ CONFIG_CCS811 FILES:= $(LINUX_DIR)/drivers/iio/chemical/ccs811.ko AUTOLOAD:=$(call AutoLoad,56,ccs811) + $(call AddDepends/iio) endef define KernelPackage/iio-ccs811/description @@ -289,12 +307,12 @@ $(eval $(call KernelPackage,iio-ccs811)) define KernelPackage/iio-si7020 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core + DEPENDS:=+kmod-i2c-core TITLE:=Silicon Labs Si7020 sensor KCONFIG:= CONFIG_SI7020 FILES:=$(LINUX_DIR)/drivers/iio/humidity/si7020.ko AUTOLOAD:=$(call AutoLoad,56,si7020) + $(call AddDepends/iio) endef define KernelPackage/iio-si7020/description @@ -307,15 +325,15 @@ $(eval $(call KernelPackage,iio-si7020)) define KernelPackage/iio-st_accel - SUBMENU:=$(IIO_MENU) TITLE:=STMicroelectronics accelerometer 3-Axis Driver - DEPENDS:=+kmod-iio-core +kmod-regmap-core +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-regmap-core +kmod-industrialio-triggered-buffer KCONFIG:= \ CONFIG_IIO_ST_ACCEL_3AXIS \ CONFIG_IIO_ST_SENSORS_CORE FILES:= \ $(LINUX_DIR)/drivers/iio/accel/st_accel.ko \ $(LINUX_DIR)/drivers/iio/common/st_sensors/st_sensors.ko + $(call AddDepends/iio) endef define KernelPackage/iio-st_accel/description @@ -329,7 +347,6 @@ $(eval $(call KernelPackage,iio-st_accel)) define KernelPackage/iio-st_accel-i2c - SUBMENU:=$(IIO_MENU) TITLE:=STMicroelectronics accelerometer 3-Axis Driver (I2C) DEPENDS:=+kmod-iio-st_accel +kmod-i2c-core +kmod-regmap-i2c KCONFIG:= CONFIG_IIO_ST_ACCEL_I2C_3AXIS @@ -337,6 +354,7 @@ define KernelPackage/iio-st_accel-i2c $(LINUX_DIR)/drivers/iio/accel/st_accel_i2c.ko \ $(LINUX_DIR)/drivers/iio/common/st_sensors/st_sensors_i2c.ko AUTOLOAD:=$(call AutoLoad,56,st_accel_i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-st_accel-i2c/description @@ -347,7 +365,6 @@ $(eval $(call KernelPackage,iio-st_accel-i2c)) define KernelPackage/iio-st_accel-spi - SUBMENU:=$(IIO_MENU) TITLE:=STMicroelectronics accelerometer 3-Axis Driver (SPI) DEPENDS:=+kmod-iio-st_accel +kmod-regmap-spi KCONFIG:= CONFIG_IIO_ST_ACCEL_SPI_3AXIS @@ -355,6 +372,7 @@ define KernelPackage/iio-st_accel-spi $(LINUX_DIR)/drivers/iio/accel/st_accel_spi.ko \ $(LINUX_DIR)/drivers/iio/common/st_sensors/st_sensors_spi.ko AUTOLOAD:=$(call AutoLoad,56,st_accel_spi) + $(call AddDepends/iio) endef define KernelPackage/iio-st_accel-spi/description @@ -365,12 +383,12 @@ $(eval $(call KernelPackage,iio-st_accel-spi)) define KernelPackage/iio-lsm6dsx - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-iio-core +kmod-iio-kfifo-buf +kmod-regmap-core + DEPENDS:=+kmod-iio-kfifo-buf +kmod-regmap-core TITLE:=ST LSM6DSx driver for IMU MEMS sensors KCONFIG:=CONFIG_IIO_ST_LSM6DSX FILES:=$(LINUX_DIR)/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.ko AUTOLOAD:=$(call AutoProbe,st_lsm6dsx) + $(call AddDepends/iio) endef define KernelPackage/iio-lsm6dsx/description @@ -381,12 +399,12 @@ $(eval $(call KernelPackage,iio-lsm6dsx)) define KernelPackage/iio-lsm6dsx-i2c - SUBMENU:=$(IIO_MENU) DEPENDS:=+kmod-iio-lsm6dsx +kmod-i2c-core +kmod-regmap-i2c TITLE:=ST LSM6DSx driver for IMU MEMS sensors (I2C) KCONFIG:=CONFIG_IIO_ST_LSM6DSX FILES:=$(LINUX_DIR)/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.ko AUTOLOAD:=$(call AutoProbe,st_lsm6dsx-i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-lsm6dsx-i2c/description @@ -397,12 +415,12 @@ $(eval $(call KernelPackage,iio-lsm6dsx-i2c)) define KernelPackage/iio-lsm6dsx-spi - SUBMENU:=$(IIO_MENU) DEPENDS:=+kmod-iio-lsm6dsx +kmod-regmap-spi TITLE:=ST LSM6DSx driver for IMU MEMS sensors (SPI) KCONFIG:=CONFIG_IIO_ST_LSM6DSX FILES:=$(LINUX_DIR)/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.ko AUTOLOAD:=$(call AutoProbe,st_lsm6dsx-spi) + $(call AddDepends/iio) endef define KernelPackage/iio-lsm6dsx-spi/description @@ -413,12 +431,16 @@ $(eval $(call KernelPackage,iio-lsm6dsx-spi)) define KernelPackage/iio-sps30 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core +kmod-industrialio-triggered-buffer +kmod-lib-crc8 + DEPENDS:=+kmod-i2c-core +kmod-industrialio-triggered-buffer +kmod-lib-crc8 TITLE:=Sensirion SPS30 particulate matter sensor - KCONFIG:=CONFIG_SPS30 - FILES:=$(LINUX_DIR)/drivers/iio/chemical/sps30.ko - AUTOLOAD:=$(call AutoProbe,sps30) + KCONFIG:= \ + CONFIG_SPS30 \ + CONFIG_SPS30_I2C + FILES:= \ + $(LINUX_DIR)/drivers/iio/chemical/sps30.ko \ + $(LINUX_DIR)/drivers/iio/chemical/sps30_i2c.ko + AUTOLOAD:=$(call AutoProbe,sps30 sps30_i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-sps30/description @@ -429,12 +451,12 @@ $(eval $(call KernelPackage,iio-sps30)) define KernelPackage/iio-tsl4531 - SUBMENU:=$(IIO_MENU) - DEPENDS:=+kmod-i2c-core +kmod-iio-core + DEPENDS:=+kmod-i2c-core TITLE:=TAOS TSL4531 ambient light sensor KCONFIG:= CONFIG_TSL4531 FILES:=$(LINUX_DIR)/drivers/iio/light/tsl4531.ko AUTOLOAD:=$(call AutoLoad,56,tsl4531) + $(call AddDepends/iio) endef define KernelPackage/iio-tsl4531/description @@ -447,12 +469,12 @@ $(eval $(call KernelPackage,iio-tsl4531)) define KernelPackage/iio-fxas21002c - SUBMENU:=$(IIO_MENU) TITLE:=Freescale FXAS21002C 3-axis gyro driver - DEPENDS:=+kmod-iio-core +kmod-regmap-core +kmod-industrialio-triggered-buffer + DEPENDS:=+kmod-regmap-core +kmod-industrialio-triggered-buffer KCONFIG:= CONFIG_FXAS21002C FILES:=$(LINUX_DIR)/drivers/iio/gyro/fxas21002c_core.ko AUTOLOAD:=$(call AutoLoad,56,fxas21002c) + $(call AddDepends/iio) endef define KernelPackage/iio-fxas21002c/description @@ -463,12 +485,12 @@ $(eval $(call KernelPackage,iio-fxas21002c)) define KernelPackage/iio-fxas21002c-i2c - SUBMENU:=$(IIO_MENU) TITLE:=Freescale FXAS21002C 3-axis gyro driver (I2C) DEPENDS:=+kmod-iio-fxas21002c +kmod-i2c-core +kmod-regmap-i2c KCONFIG:= CONFIG_FXAS21002C_I2C FILES:=$(LINUX_DIR)/drivers/iio/gyro/fxas21002c_i2c.ko AUTOLOAD:=$(call AutoLoad,56,fxas21002c_i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-fxas21002c-i2c/description @@ -480,12 +502,12 @@ endef $(eval $(call KernelPackage,iio-fxas21002c-i2c)) define KernelPackage/iio-fxas21002c-spi - SUBMENU:=$(IIO_MENU) DEPENDS:=+kmod-iio-fxas21002c +kmod-regmap-spi TITLE:=Freescale FXAS21002C 3-axis gyro driver (SPI) KCONFIG:= CONFIG_FXAS21002C_SPI FILES:=$(LINUX_DIR)/drivers/iio/gyro/fxas21002c_spi.ko AUTOLOAD:=$(call AutoLoad,56,fxas21002c_spi) + $(call AddDepends/iio) endef define KernelPackage/iio-fxas21002c-spi/description @@ -497,12 +519,12 @@ $(eval $(call KernelPackage,iio-fxas21002c-spi)) define KernelPackage/iio-fxos8700 - SUBMENU:=$(IIO_MENU) TITLE:=Freescale FXOS8700 3-axis accelerometer driver - DEPENDS:=+kmod-iio-core +kmod-regmap-core + DEPENDS:=+kmod-regmap-core KCONFIG:= CONFIG_FXOS8700 FILES:=$(LINUX_DIR)/drivers/iio/imu/fxos8700_core.ko AUTOLOAD:=$(call AutoLoad,56,fxos8700) + $(call AddDepends/iio) endef define KernelPackage/iio-fxos8700/description @@ -513,12 +535,12 @@ $(eval $(call KernelPackage,iio-fxos8700)) define KernelPackage/iio-fxos8700-i2c - SUBMENU:=$(IIO_MENU) TITLE:=Freescale FXOS8700 3-axis acceleromter driver (I2C) DEPENDS:=+kmod-iio-fxos8700 +kmod-i2c-core +kmod-regmap-i2c KCONFIG:= CONFIG_FXOS8700_I2C FILES:=$(LINUX_DIR)/drivers/iio/imu/fxos8700_i2c.ko AUTOLOAD:=$(call AutoLoad,56,fxos8700_i2c) + $(call AddDepends/iio) endef define KernelPackage/iio-fxos8700-i2c/description @@ -530,12 +552,12 @@ endef $(eval $(call KernelPackage,iio-fxos8700-i2c)) define KernelPackage/iio-fxos8700-spi - SUBMENU:=$(IIO_MENU) DEPENDS:=+kmod-iio-fxos8700 +kmod-regmap-spi TITLE:=Freescale FXOS8700 3-axis accelerometer driver (SPI) KCONFIG:= CONFIG_FXOS8700_SPI FILES:=$(LINUX_DIR)/drivers/iio/imu/fxos8700_spi.ko AUTOLOAD:=$(call AutoLoad,56,fxos8700_spi) + $(call AddDepends/iio) endef define KernelPackage/iio-fxos8700-spi/description @@ -544,3 +566,17 @@ define KernelPackage/iio-fxos8700-spi/description endef $(eval $(call KernelPackage,iio-fxos8700-spi)) + +define KernelPackage/iio-ti-am335x-adc + TITLE:= TI Sitara AM335x ADC driver + DEPENDS:=@TARGET_omap + KCONFIG:=CONFIG_TI_AM335X_ADC + FILES:=$(LINUX_DIR)/drivers/iio/adc/ti_am335x_adc.ko + AUTOLOAD:=$(call AutoProbe,ti_am335x_adc) + $(call AddDepends/iio,+kmod-iio-kfifo-buf) +endef +define KernelPackage/iio-ti-am335x-adc/description + Driver for the TI AM335x ADC. +endef + +$(eval $(call KernelPackage,iio-ti-am335x-adc)) diff --git a/package/kernel/linux/modules/input.mk b/package/kernel/linux/modules/input.mk index c2f39ddd903..92587b1874c 100644 --- a/package/kernel/linux/modules/input.mk +++ b/package/kernel/linux/modules/input.mk @@ -92,7 +92,7 @@ $(eval $(call KernelPackage,input-gpio-keys)) define KernelPackage/input-gpio-keys-polled SUBMENU:=$(INPUT_MODULES_MENU) TITLE:=Polled GPIO key support - DEPENDS:=@GPIO_SUPPORT +kmod-input-polldev + DEPENDS:=@GPIO_SUPPORT +kmod-input-core KCONFIG:= \ CONFIG_KEYBOARD_GPIO_POLLED \ CONFIG_INPUT_KEYBOARD=y @@ -142,21 +142,6 @@ endef $(eval $(call KernelPackage,input-joydev)) -define KernelPackage/input-polldev - SUBMENU:=$(INPUT_MODULES_MENU) - TITLE:=Polled Input device support - DEPENDS:=+kmod-input-core - KCONFIG:=CONFIG_INPUT_POLLDEV - FILES:=$(LINUX_DIR)/drivers/input/input-polldev.ko -endef - -define KernelPackage/input-polldev/description - Kernel module for support of polled input devices -endef - -$(eval $(call KernelPackage,input-polldev)) - - define KernelPackage/input-matrixkmap SUBMENU:=$(INPUT_MODULES_MENU) TITLE:=Input matrix devices support @@ -179,10 +164,8 @@ define KernelPackage/input-touchscreen-ads7846 DEPENDS:=+kmod-hwmon-core +kmod-input-core +kmod-spi-bitbang KCONFIG:= \ CONFIG_INPUT_TOUCHSCREEN=y \ - CONFIG_TOUCHSCREEN_PROPERTIES=y \ CONFIG_TOUCHSCREEN_ADS7846 - FILES:=$(LINUX_DIR)/drivers/input/touchscreen/ads7846.ko \ - $(LINUX_DIR)/drivers/input/touchscreen/of_touchscreen.ko + FILES:=$(LINUX_DIR)/drivers/input/touchscreen/ads7846.ko AUTOLOAD:=$(call AutoProbe,ads7846) endef @@ -193,10 +176,29 @@ endef $(eval $(call KernelPackage,input-touchscreen-ads7846)) +define KernelPackage/input-touchscreen-edt-ft5x06 + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=EDT FT5x06 and Focaltech FT6236 based touchscreens + DEPENDS:=+kmod-i2c-core +kmod-input-core + KCONFIG:= \ + CONFIG_INPUT_TOUCHSCREEN=y \ + CONFIG_TOUCHSCREEN_EDT_FT5X06 + FILES:=$(LINUX_DIR)/drivers/input/touchscreen/edt-ft5x06.ko + AUTOLOAD:=$(call AutoProbe,edt-ft5x06) +endef + +define KernelPackage/input-touchscreen-edt-ft5x06/description + Kernel module for EDT FT5206, FT5306, FT5406, FT5506, Evervision FT5726 \ + and Focaltech FT6236 based touchscreens +endef + +$(eval $(call KernelPackage,input-touchscreen-edt-ft5x06)) + + define KernelPackage/keyboard-imx SUBMENU:=$(INPUT_MODULES_MENU) TITLE:=IMX keypad support - DEPENDS:=@(TARGET_mxs||TARGET_imx6) +kmod-input-matrixkmap + DEPENDS:=@(TARGET_mxs||TARGET_imx) +kmod-input-matrixkmap KCONFIG:= \ CONFIG_KEYBOARD_IMX \ CONFIG_INPUT_KEYBOARD=y diff --git a/package/kernel/linux/modules/leds.mk b/package/kernel/linux/modules/leds.mk index 0ef0aee3fbe..60465a8ad50 100644 --- a/package/kernel/linux/modules/leds.mk +++ b/package/kernel/linux/modules/leds.mk @@ -99,6 +99,38 @@ endef $(eval $(call KernelPackage,ledtrig-oneshot)) +define KernelPackage/ledtrig-pattern + SUBMENU:=$(LEDS_MENU) + TITLE:=LED Pattern Trigger + KCONFIG:=CONFIG_LEDS_TRIGGER_PATTERN + FILES:=$(LED_TRIGGER_DIR)/ledtrig-pattern.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-pattern) +endef + +define KernelPackage/ledtrig-pattern/description + This allows LEDs to be controlled by a software or hardware pattern + which is a series of tuples, of brightness and duration (ms). +endef + +$(eval $(call KernelPackage,ledtrig-pattern)) + + +define KernelPackage/ledtrig-tty + SUBMENU:=$(LEDS_MENU) + TITLE:=LED Trigger for TTY devices + KCONFIG:=CONFIG_LEDS_TRIGGER_TTY + FILES:=$(LED_TRIGGER_DIR)/ledtrig-tty.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-tty) +endef + +define KernelPackage/ledtrig-tty/description + This allows LEDs to be controlled by activity on ttys which includes + serial devices like '/dev/ttyS0'. +endef + +$(eval $(call KernelPackage,ledtrig-tty)) + + define KernelPackage/leds-apu SUBMENU:=$(LEDS_MENU) TITLE:=PC Engines APU1 LED support @@ -115,6 +147,41 @@ endef $(eval $(call KernelPackage,leds-apu)) +define KernelPackage/leds-mlxcpld + SUBMENU:=$(LEDS_MENU) + TITLE:=LED support for the Mellanox boards + FILES:=$(LINUX_DIR)/drivers/leds/leds-mlxcpld.ko + KCONFIG:=CONFIG_LEDS_MLXCPLD + AUTOLOAD:=$(call AutoProbe,leds-mlxcpld) +endef + +define KernelPackage/leds-mlxcpld/description + This option enables support for the LEDs on the Mellanox + boards. +endef + +$(eval $(call KernelPackage,leds-mlxcpld)) + + +define KernelPackage/leds-pca955x + SUBMENU:=$(LEDS_MENU) + TITLE:=LED driver for PCA955x I2C chips + DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_LEDS_PCA955X \ + CONFIG_LEDS_PCA955X_GPIO=y + FILES:=$(LINUX_DIR)/drivers/leds/leds-pca955x.ko + AUTOLOAD:=$(call AutoLoad,60,leds-pca955x,1) +endef + +define KernelPackage/leds-pca955x/description + This option enables support for LEDs connected to PCA955x + LED driver chips accessed via the I2C bus. Supported + devices include PCA9550, PCA9551, PCA9552, and PCA9553. +endef + +$(eval $(call KernelPackage,leds-pca955x)) + + define KernelPackage/leds-pca963x SUBMENU:=$(LEDS_MENU) TITLE:=PCA963x LED support @@ -146,6 +213,24 @@ endef $(eval $(call KernelPackage,leds-pwm)) + +define KernelPackage/leds-tlc591xx + SUBMENU:=$(LEDS_MENU) + TITLE:=LED driver for TLC59108 and TLC59116 controllers + DEPENDS:=+kmod-i2c-core +kmod-regmap-i2c + KCONFIG:=CONFIG_LEDS_TLC591XX + FILES:=$(LINUX_DIR)/drivers/leds/leds-tlc591xx.ko + AUTOLOAD:=$(call AutoLoad,60,leds-tlc591xx,1) +endef + +define KernelPackage/leds-tlc591xx/description + This option enables support for Texas Instruments TLC59108 + and TLC59116 LED controllers. +endef + +$(eval $(call KernelPackage,leds-tlc591xx)) + + define KernelPackage/leds-uleds SUBMENU:=$(LEDS_MENU) TITLE:=Userspace LEDs @@ -176,3 +261,37 @@ define KernelPackage/input-leds/description endef $(eval $(call KernelPackage,input-leds)) + + +define KernelPackage/leds-lp55xx-common + SUBMENU:=$(LEDS_MENU) + TITLE:=LED common driver for LP5521/LP5523/LP55231/LP5562 controllers + DEPENDS:=+kmod-i2c-core + KCONFIG:=CONFIG_LEDS_LP55XX_COMMON + FILES:=$(LINUX_DIR)/drivers/leds/leds-lp55xx-common.ko + AUTOLOAD:=$(call AutoLoad,60,leds-lp55xx-common,1) +endef + +define KernelPackage/leds-lp55xx-common/description + This option enables support for Texas Instruments + LP5521/LP5523/LP55231/LP5562 common driver. +endef + +$(eval $(call KernelPackage,leds-lp55xx-common)) + + +define KernelPackage/leds-lp5562 + SUBMENU:=$(LEDS_MENU) + TITLE:=LED driver for LP5562 controllers + DEPENDS:=+kmod-i2c-core +kmod-leds-lp55xx-common + KCONFIG:=CONFIG_LEDS_LP5562 + FILES:=$(LINUX_DIR)/drivers/leds/leds-lp5562.ko + AUTOLOAD:=$(call AutoLoad,60,leds-lp5562,1) +endef + +define KernelPackage/leds-lp5562/description + This option enables support for Texas Instruments LP5562 + LED controllers. +endef + +$(eval $(call KernelPackage,leds-lp5562))
\ No newline at end of file diff --git a/package/kernel/linux/modules/lib.mk b/package/kernel/linux/modules/lib.mk index 9a341932bde..8d67a3187a6 100644 --- a/package/kernel/linux/modules/lib.mk +++ b/package/kernel/linux/modules/lib.mk @@ -109,9 +109,10 @@ define KernelPackage/lib-lzo HIDDEN:=1 FILES:= \ $(LINUX_DIR)/crypto/lzo.ko \ + $(LINUX_DIR)/crypto/lzo-rle.ko \ $(LINUX_DIR)/lib/lzo/lzo_compress.ko \ $(LINUX_DIR)/lib/lzo/lzo_decompress.ko - AUTOLOAD:=$(call AutoProbe,lzo lzo_compress lzo_decompress) + AUTOLOAD:=$(call AutoProbe,lzo lzo-rle lzo_compress lzo_decompress) endef define KernelPackage/lib-lzo/description @@ -133,6 +134,7 @@ define KernelPackage/lib-zstd FILES:= \ $(LINUX_DIR)/crypto/zstd.ko \ $(LINUX_DIR)/lib/xxhash.ko \ + $(LINUX_DIR)/lib/zstd/zstd_common.ko@ge6.1 \ $(LINUX_DIR)/lib/zstd/zstd_compress.ko \ $(LINUX_DIR)/lib/zstd/zstd_decompress.ko AUTOLOAD:=$(call AutoProbe,xxhash zstd zstd_compress zstd_decompress) @@ -151,13 +153,15 @@ define KernelPackage/lib-lz4 DEPENDS:=+kmod-crypto-acompress KCONFIG:= \ CONFIG_CRYPTO_LZ4 \ + CONFIG_CRYPTO_LZ4HC \ CONFIG_LZ4_COMPRESS \ CONFIG_LZ4_DECOMPRESS FILES:= \ $(LINUX_DIR)/crypto/lz4.ko \ $(LINUX_DIR)/lib/lz4/lz4_compress.ko \ + $(LINUX_DIR)/lib/lz4/lz4hc_compress.ko \ $(LINUX_DIR)/lib/lz4/lz4_decompress.ko - AUTOLOAD:=$(call AutoProbe,lz4 lz4_compress lz4_decompress) + AUTOLOAD:=$(call AutoProbe,lz4 lz4_compress lz4hc_compress lz4_decompress) endef define KernelPackage/lib-lz4/description @@ -167,6 +171,28 @@ endef $(eval $(call KernelPackage,lib-lz4)) +define KernelPackage/lib-842 + SUBMENU:=$(LIB_MENU) + TITLE:=842 support + DEPENDS:=+kmod-crypto-acompress +kmod-crypto-crc32 + KCONFIG:= \ + CONFIG_CRYPTO_842 \ + CONFIG_842_COMPRESS \ + CONFIG_842_DECOMPRESS + FILES:= \ + $(LINUX_DIR)/crypto/842.ko \ + $(LINUX_DIR)/lib/842/842_compress.ko \ + $(LINUX_DIR)/lib/842/842_decompress.ko + AUTOLOAD:=$(call AutoProbe,842 842_compress 842_decompress) +endef + +define KernelPackage/lib-842/description + Kernel module for 842 compression/decompression support +endef + +$(eval $(call KernelPackage,lib-842)) + + define KernelPackage/lib-raid6 SUBMENU:=$(LIB_MENU) TITLE:=RAID6 algorithm support @@ -272,3 +298,49 @@ define KernelPackage/asn1-decoder endef $(eval $(call KernelPackage,asn1-decoder)) + +define KernelPackage/asn1-encoder + SUBMENU:=$(LIB_MENU) + TITLE:=Simple ASN1 encoder + KCONFIG:= CONFIG_ASN1_ENCODER + HIDDEN:=1 + FILES:=$(LINUX_DIR)/lib/asn1_encoder.ko +endef + +$(eval $(call KernelPackage,asn1-encoder)) + +define KernelPackage/oid-registry + SUBMENU:=$(LIB_MENU) + TITLE:=Object identifier registry + KCONFIG:= CONFIG_OID_REGISTRY + FILES:=$(LINUX_DIR)/lib/oid_registry.ko + AUTOLOAD:=$(call AutoLoad,31,oid_registry) +endef + +$(eval $(call KernelPackage,oid-registry)) + + +define KernelPackage/lib-objagg + SUBMENU:=$(LIB_MENU) + TITLE:=objagg support + FILES:=$(LINUX_DIR)/lib/objagg.ko + KCONFIG:= \ + CONFIG_OBJAGG \ + CONFIG_TEST_OBJAGG=n + AUTOLOAD:=$(call AutoProbe,objagg) +endef + +$(eval $(call KernelPackage,lib-objagg)) + + +define KernelPackage/lib-parman + SUBMENU:=$(LIB_MENU) + TITLE:=parman support + FILES:=$(LINUX_DIR)/lib/parman.ko + KCONFIG:= \ + CONFIG_PARMAN \ + CONFIG_TEST_PARMAN=n + AUTOLOAD:=$(call AutoProbe,parman) +endef + +$(eval $(call KernelPackage,lib-parman)) diff --git a/package/kernel/linux/modules/multiplexer.mk b/package/kernel/linux/modules/multiplexer.mk new file mode 100644 index 00000000000..135fc62c6dd --- /dev/null +++ b/package/kernel/linux/modules/multiplexer.mk @@ -0,0 +1,34 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +MENU_TITLE:=Multiplexer Support + +define KernelPackage/mux-core + SUBMENU:=$(MENU_TITLE) + TITLE:=Multiplexer Support + KCONFIG:=CONFIG_MULTIPLEXER + FILES:=$(LINUX_DIR)/drivers/mux/mux-core.ko + AUTOLOAD:=$(call AutoLoad,25,mux-core,1) +endef + +define KernelPackage/mux-core/description + Kernel module for multiplexer support +endef + +$(eval $(call KernelPackage,mux-core)) + +define KernelPackage/mux-gpio + SUBMENU:=$(MENU_TITLE) + TITLE:=GPIO-controlled Multiplexer controller + KCONFIG:=CONFIG_MUX_GPIO + DEPENDS:=@GPIO_SUPPORT kmod-mux-core + FILES:=$(LINUX_DIR)/drivers/mux/mux-gpio.ko + AUTOLOAD:=$(call AutoLoad,25,mux-gpio,1) +endef + +define KernelPackage/mux-gpio/description + Kernel modules for GPIO-controlled Multiplexer controller +endef + +$(eval $(call KernelPackage,mux-gpio)) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index b91442748d4..72504d8de7f 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -111,6 +111,7 @@ $(eval $(call KernelPackage,libphy)) define KernelPackage/phylink SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Model for MAC to optional PHY connection + DEPENDS:=+kmod-libphy KCONFIG:=CONFIG_PHYLINK FILES:=$(LINUX_DIR)/drivers/net/phy/phylink.ko AUTOLOAD:=$(call AutoLoad,15,phylink,1) @@ -141,7 +142,7 @@ $(eval $(call KernelPackage,mii)) define KernelPackage/mdio-devres SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Supports MDIO device registration - DEPENDS:=@LINUX_5_10 +kmod-libphy PACKAGE_kmod-of-mdio:kmod-of-mdio + DEPENDS:=+kmod-libphy +(TARGET_armsr||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio KCONFIG:=CONFIG_MDIO_DEVRES HIDDEN:=1 FILES:=$(LINUX_DIR)/drivers/net/phy/mdio_devres.ko @@ -158,15 +159,13 @@ $(eval $(call KernelPackage,mdio-devres)) define KernelPackage/mdio-gpio SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:= Supports GPIO lib-based MDIO busses - DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_tegra):kmod-of-mdio + DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armsr||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio KCONFIG:= \ CONFIG_MDIO_BITBANG \ CONFIG_MDIO_GPIO FILES:= \ - $(LINUX_DIR)/drivers/net/phy/mdio-gpio.ko@lt5.10 \ - $(LINUX_DIR)/drivers/net/phy/mdio-bitbang.ko@lt5.10 \ - $(LINUX_DIR)/drivers/net/mdio/mdio-gpio.ko@ge5.10 \ - $(LINUX_DIR)/drivers/net/mdio/mdio-bitbang.ko@ge5.10 + $(LINUX_DIR)/drivers/net/mdio/mdio-gpio.ko \ + $(LINUX_DIR)/drivers/net/mdio/mdio-bitbang.ko AUTOLOAD:=$(call AutoProbe,mdio-gpio) endef @@ -196,6 +195,21 @@ endef $(eval $(call KernelPackage,et131x)) +define KernelPackage/phy-microchip + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Microchip Ethernet PHY driver + KCONFIG:=CONFIG_MICROCHIP_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/microchip.ko + AUTOLOAD:=$(call AutoLoad,18,microchip,1) +endef + +define KernelPackage/phy-microchip/description + Supports the LAN88XX PHYs. +endef + +$(eval $(call KernelPackage,phy-microchip)) + define KernelPackage/phylib-broadcom SUBMENU:=$(NETWORK_DEVICES_MENU) @@ -210,6 +224,39 @@ endef $(eval $(call KernelPackage,phylib-broadcom)) +define KernelPackage/phy-amd + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=AMD PHY driver + KCONFIG:=CONFIG_AMD_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/amd.ko + AUTOLOAD:=$(call AutoProbe,amd,1) +endef + +define KernelPackage/phy-amd/description + Currently supports the AMD and Altima PHYs. +endef + +$(eval $(call KernelPackage,phy-amd)) + + +define KernelPackage/phy-ax88796b + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Asix PHY driver + KCONFIG:=CONFIG_AX88796B_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/ax88796b.ko + AUTOLOAD:=$(call AutoProbe,ax88796b) +endef + +define KernelPackage/phy-ax88796b/description + Currently supports the Asix Electronics PHY found in the X-Surf 100 + AX88796B package. +endef + +$(eval $(call KernelPackage,phy-ax88796b)) + + define KernelPackage/phy-broadcom SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Broadcom Ethernet PHY driver @@ -243,6 +290,58 @@ endef $(eval $(call KernelPackage,phy-bcm84881)) +define KernelPackage/phy-marvell + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Marvell Gigabit Ethernet PHY driver + KCONFIG:=CONFIG_MARVELL_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/marvell.ko + AUTOLOAD:=$(call AutoLoad,18,marvell) +endef + +define KernelPackage/phy-marvell/description + Supports Marvell Gigabit Ethernet PHYs: + * 88E1101 + * 88E1112 + * 88E1111 (incl. Finisar variant) + * 88E1118 + * 88E1121R + * 88E1145 + * 88E1149R + * 88E1240 + * 88E1318S + * 88E1116R + * 88E1510 + * 88E1540 + * 88E1545 + * 88E3016 + * 88E6341 family + * 88E6390 family + * 88E6393 family + * 88E1340S + * 88E1548P +endef + +$(eval $(call KernelPackage,phy-marvell)) + +define KernelPackage/phy-marvell-10g + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Marvell 10 Gigabit Ethernet PHY driver + KCONFIG:=CONFIG_MARVELL_10G_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/marvell10g.ko + AUTOLOAD:=$(call AutoLoad,18,marvell10g) +endef + +define KernelPackage/phy-marvell/description + Supports Marvell 10 Gigabit Ethernet PHYs: + * 88E2110 + * 88E2111 + * 88x3310 + * 88x3340 +endef + +$(eval $(call KernelPackage,phy-marvell-10g)) define KernelPackage/phy-realtek SUBMENU:=$(NETWORK_DEVICES_MENU) @@ -260,6 +359,55 @@ endef $(eval $(call KernelPackage,phy-realtek)) +define KernelPackage/phy-smsc + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=SMSC PHY driver + KCONFIG:=CONFIG_SMSC_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/smsc.ko + AUTOLOAD:=$(call AutoProbe,smsc) +endef + +define KernelPackage/phy-smsc/description + Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs +endef + +$(eval $(call KernelPackage,phy-smsc)) + + +define KernelPackage/phy-airoha-en8811h + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Airoha EN8811H 2.5G Ethernet PHY + DEPENDS:=+airoha-en8811h-firmware +kmod-libphy @LINUX_6_1 + KCONFIG:=CONFIG_AIR_EN8811H_PHY + FILES:= \ + $(LINUX_DIR)/drivers/net/phy/air_en8811h.ko + AUTOLOAD:=$(call AutoLoad,18,air_en8811h,1) +endef + +define KernelPackage/phy-airoha-en8811h/description + Kernel modules for Airoha EN8811H 2.5G Ethernet PHY +endef + +$(eval $(call KernelPackage,phy-airoha-en8811h)) + + +define KernelPackage/phy-aquantia + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Aquantia Ethernet PHYs + DEPENDS:=+kmod-libphy +kmod-hwmon-core +kmod-lib-crc-ccitt + KCONFIG:=CONFIG_AQUANTIA_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/aquantia/aquantia.ko + AUTOLOAD:=$(call AutoLoad,18,aquantia,1) +endef + +define KernelPackage/phy-aquantia/description + Kernel modules for Aquantia Ethernet PHYs +endef + +$(eval $(call KernelPackage,phy-aquantia)) + + define KernelPackage/swconfig SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=switch configuration API @@ -341,7 +489,7 @@ $(eval $(call KernelPackage,switch-rtl8306)) define KernelPackage/switch-rtl8366-smi SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Realtek RTL8366 SMI switch interface support - DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_tegra):kmod-of-mdio + DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armsr||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio KCONFIG:=CONFIG_RTL8366_SMI FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi,1) @@ -360,7 +508,7 @@ define KernelPackage/switch-rtl8366rb DEPENDS:=+kmod-switch-rtl8366-smi KCONFIG:=CONFIG_RTL8366RB_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366rb.ko - AUTOLOAD:=$(call AutoLoad,43,rtl8366rb) + AUTOLOAD:=$(call AutoLoad,43,rtl8366rb,1) endef define KernelPackage/switch-rtl8366rb/description @@ -376,7 +524,7 @@ define KernelPackage/switch-rtl8366s DEPENDS:=+kmod-switch-rtl8366-smi KCONFIG:=CONFIG_RTL8366S_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366s.ko - AUTOLOAD:=$(call AutoLoad,43,rtl8366s) + AUTOLOAD:=$(call AutoLoad,43,rtl8366s,1) endef define KernelPackage/switch-rtl8366s/description @@ -386,6 +534,22 @@ endef $(eval $(call KernelPackage,switch-rtl8366s)) +define KernelPackage/switch-rtl8367 + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Realtek RTL8367 switch support + DEPENDS:=+kmod-switch-rtl8366-smi + KCONFIG:=CONFIG_RTL8367_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8367.ko + AUTOLOAD:=$(call AutoLoad,43,rtl8367,1) +endef + +define KernelPackage/switch-rtl8367/description + Realtek RTL8367 switch support +endef + +$(eval $(call KernelPackage,switch-rtl8367)) + + define KernelPackage/switch-rtl8367b SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Realtek RTL8367R/B switch support @@ -402,6 +566,22 @@ endef $(eval $(call KernelPackage,switch-rtl8367b)) +define KernelPackage/switch-ar8xxx + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Atheros AR8216/8327 switch support + DEPENDS:=+kmod-swconfig +kmod-mdio-devres + KCONFIG:=CONFIG_AR8216_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/ar8xxx.ko + AUTOLOAD:=$(call AutoLoad,43,ar8xxx,1) +endef + +define KernelPackage/switch-ar8xxx/description + Atheros AR8216/8327 switch support +endef + +$(eval $(call KernelPackage,switch-ar8xxx)) + + define KernelPackage/natsemi SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=National Semiconductor DP8381x series @@ -562,7 +742,7 @@ $(eval $(call KernelPackage,8139cp)) define KernelPackage/r8169 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support - DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware +kmod-phy-realtek +LINUX_5_10:kmod-mdio-devres + DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware +kmod-phy-realtek +kmod-mdio-devres KCONFIG:= \ CONFIG_R8169 \ CONFIG_R8169_NAPI=y \ @@ -688,7 +868,7 @@ $(eval $(call KernelPackage,igbvf)) define KernelPackage/ixgbe SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) 82598/82599 PCI-Express 10 Gigabit Ethernet support - DEPENDS:=@PCI_SUPPORT +kmod-mdio +kmod-ptp +kmod-hwmon-core +kmod-libphy +LINUX_5_10:kmod-mdio-devres + DEPENDS:=@PCI_SUPPORT +kmod-mdio +kmod-ptp +kmod-hwmon-core +kmod-libphy +kmod-mdio-devres KCONFIG:=CONFIG_IXGBE \ CONFIG_IXGBE_VXLAN=n \ CONFIG_IXGBE_HWMON=y \ @@ -822,7 +1002,7 @@ define KernelPackage/tg3 TITLE:=Broadcom Tigon3 Gigabit Ethernet KCONFIG:=CONFIG_TIGON3 \ CONFIG_TIGON3_HWMON=n - DEPENDS:=+!TARGET_bcm47xx:kmod-libphy +kmod-ptp + DEPENDS:=@PCI_SUPPORT +!TARGET_bcm47xx:kmod-libphy +kmod-ptp SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko AUTOLOAD:=$(call AutoLoad,19,tg3,1) @@ -838,7 +1018,7 @@ $(eval $(call KernelPackage,tg3)) define KernelPackage/hfcpci TITLE:=HFC PCI cards (single port) support for mISDN KCONFIG:=CONFIG_MISDN_HFCPCI - DEPENDS:=+kmod-misdn + DEPENDS:=@PCI_SUPPORT +kmod-misdn SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcpci.ko AUTOLOAD:=$(call AutoLoad,31,hfcpci) @@ -855,7 +1035,7 @@ $(eval $(call KernelPackage,hfcpci)) define KernelPackage/hfcmulti TITLE:=HFC multiport cards (HFC-4S/8S/E1) support for mISDN KCONFIG:=CONFIG_MISDN_HFCMULTI - DEPENDS:=+kmod-misdn + DEPENDS:=@PCI_SUPPORT +kmod-misdn SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcmulti.ko AUTOLOAD:=$(call AutoLoad,31,hfcmulti) @@ -1019,15 +1199,30 @@ endef $(eval $(call KernelPackage,forcedeth)) +define KernelPackage/fixed-phy + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MDIO Bus/PHY emulation with fixed speed/link PHYs + DEPENDS:=+kmod-libphy + KCONFIG:=CONFIG_FIXED_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/fixed_phy.ko + AUTOLOAD:=$(call AutoProbe,fixed_phy) +endef + +define KernelPackage/fixed-phy/description + Kernel driver for "fixed" MDIO Bus to cover the boards + and devices that use PHYs that are not connected to the real MDIO bus. +endef + +$(eval $(call KernelPackage,fixed-phy)) + define KernelPackage/of-mdio SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=OpenFirmware MDIO support - DEPENDS:=+kmod-libphy @!TARGET_x86 + DEPENDS:=+kmod-libphy +kmod-fixed-phy @!TARGET_x86 KCONFIG:=CONFIG_OF_MDIO FILES:= \ - $(LINUX_DIR)/drivers/net/phy/fixed_phy.ko \ - $(LINUX_DIR)/drivers/of/of_mdio.ko@lt5.10 \ - $(LINUX_DIR)/drivers/net/mdio/of_mdio.ko@ge5.10 + $(LINUX_DIR)/drivers/net/mdio/of_mdio.ko \ + $(LINUX_DIR)/drivers/net/mdio/fwnode_mdio.ko AUTOLOAD:=$(call AutoLoad,41,of_mdio) endef @@ -1165,7 +1360,7 @@ $(eval $(call KernelPackage,mlx4-core)) define KernelPackage/mlx5-core SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Mellanox ConnectX(R) mlx5 core Network Driver - DEPENDS:=@PCI_SUPPORT +kmod-ptp + DEPENDS:=@PCI_SUPPORT +kmod-ptp +kmod-mlxfw FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko KCONFIG:= CONFIG_MLX5_CORE \ CONFIG_MLX5_CORE_EN=y \ @@ -1182,7 +1377,8 @@ define KernelPackage/mlx5-core CONFIG_MLX5_MPFS=y \ CONFIG_MLX5_SW_STEERING=n \ CONFIG_MLX5_TC_CT=n \ - CONFIG_MLX5_TLS=n + CONFIG_MLX5_TLS=n \ + CONFIG_MLX5_VFIO_PCI=n AUTOLOAD:=$(call AutoProbe,mlx5_core) endef @@ -1193,13 +1389,143 @@ endef $(eval $(call KernelPackage,mlx5-core)) +define KernelPackage/mlxfw + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Mellanox Technologies firmware flash module + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxfw/mlxfw.ko + KCONFIG:=CONFIG_MLXFW + AUTOLOAD:=$(call AutoProbe,mlxfw) +endef + +define KernelPackage/mlxfw/description + This driver supports Mellanox Technologies Firmware + flashing common logic. +endef + +$(eval $(call KernelPackage,mlxfw)) + + +define KernelPackage/mlxsw-core + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Mellanox Technologies Switch ASICs support + DEPENDS:=+kmod-mlxfw +kmod-hwmon-core + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxsw/mlxsw_core.ko + KCONFIG:= \ + CONFIG_MLXSW_CORE \ + CONFIG_MLXSW_CORE_HWMON=y \ + CONFIG_MLXSW_CORE_THERMAL=y + AUTOLOAD:=$(call AutoProbe,mlxsw_core) +endef + +define KernelPackage/mlxsw-core/description + This driver supports Mellanox Technologies Switch ASICs family. +endef + +$(eval $(call KernelPackage,mlxsw-core)) + + +define KernelPackage/mlxsw-i2c + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=I2C bus implementation for Mellanox Technologies Switch ASICs + DEPENDS:=+kmod-mlxsw-core +kmod-i2c-core + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxsw/mlxsw_i2c.ko + KCONFIG:=CONFIG_MLXSW_I2C + AUTOLOAD:=$(call AutoProbe,mlxsw_i2c) +endef + +define KernelPackage/mlxsw-i2c/description + This is I2C bus implementation for Mellanox Technologies Switch ASICs. +endef + +$(eval $(call KernelPackage,mlxsw-i2c)) + + +define KernelPackage/mlxsw-minimal + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Mellanox Technologies minimal I2C support + DEPENDS:=+kmod-mlxsw-core +kmod-mlxsw-i2c + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxsw/mlxsw_minimal.ko + KCONFIG:=CONFIG_MLXSW_MINIMAL + AUTOLOAD:=$(call AutoProbe,mlxsw_minimal) +endef + +define KernelPackage/mlxsw-minimal/description + This driver supports I2C access for Mellanox Technologies Switch + ASICs. +endef + +$(eval $(call KernelPackage,mlxsw-minimal)) + + +define KernelPackage/mlxsw-pci + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=PCI bus implementation for Mellanox Technologies Switch ASICs + DEPENDS:=@PCI_SUPPORT +kmod-mlxsw-core + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxsw/mlxsw_pci.ko + KCONFIG:=CONFIG_MLXSW_PCI + AUTOLOAD:=$(call AutoProbe,mlxsw_pci) +endef + +define KernelPackage/mlxsw-pci/description + This is PCI bus implementation for Mellanox Technologies Switch ASICs. +endef + +$(eval $(call KernelPackage,mlxsw-pci)) + + +define KernelPackage/mlxsw-spectrum + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Mellanox Technologies Spectrum family support + DEPENDS:= \ + +kmod-mlxsw-core +kmod-mlxsw-pci +kmod-lib-objagg +kmod-lib-parman \ + +kmod-ip6-tunnel +kmod-ptp +kmod-sched-act-sample +kmod-vxlan + FILES:=$(LINUX_DIR)/drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko + KCONFIG:= \ + CONFIG_MLXSW_SPECTRUM \ + CONFIG_NET_SWITCHDEV=y \ + CONFIG_MLXSW_SPECTRUM_DCB=y \ + CONFIG_DCB=y \ + CONFIG_AMD_XGBE_DCB=n \ + CONFIG_IXGBE_DCB=n \ + CONFIG_I40E_DCB=n \ + CONFIG_QLCNIC_DCB=n \ + CONFIG_FSL_DPAA2_ETH_DCB=n \ + CONFIG_FSL_DPAA2_SWITCH=n + AUTOLOAD:=$(call AutoProbe,mlxsw_spectrum) +endef + +define KernelPackage/mlxsw-spectrum/description + This driver supports Mellanox Technologies + Spectrum/Spectrum-2/Spectrum-3/Spectrum-4 Ethernet Switch ASICs. +endef + +$(eval $(call KernelPackage,mlxsw-spectrum)) + + +define KernelPackage/net-selftests + SUBMENU:=$(NETWORK_DEVICES_MENU) + DEPENDS:=+kmod-libphy + TITLE:=Network generic selftest support + KCONFIG:=CONFIG_NET_SELFTESTS + FILES:=$(LINUX_DIR)/net/core/selftests.ko + AUTOLOAD:=$(call AutoLoad,99,selftests) +endef + +define KernelPackage/net-selftests/description + Kernel modules for the generic selftest support +endef + +$(eval $(call KernelPackage,net-selftests)) + + define KernelPackage/qlcnic SUBMENU:=$(NETWORK_DEVICES_MENU) DEPENDS:=@PCI_SUPPORT +kmod-hwmon-core TITLE:=QLogic QLE8240 and QLE8242 device support KCONFIG:= \ CONFIG_QLCNIC \ - CONFIG_QLCNIC_HWMON=y + CONFIG_QLCNIC_HWMON=y \ + CONFIG_QLCNIC_SRIOV=y FILES:=$(LINUX_DIR)/drivers/net/ethernet/qlogic/qlcnic/qlcnic.ko AUTOLOAD:=$(call AutoProbe,qlcnic) endef @@ -1221,8 +1547,7 @@ define KernelPackage/sfp CONFIG_MDIO_I2C FILES:= \ $(LINUX_DIR)/drivers/net/phy/sfp.ko \ - $(LINUX_DIR)/drivers/net/phy/mdio-i2c.ko@lt5.10 \ - $(LINUX_DIR)/drivers/net/mdio/mdio-i2c.ko@ge5.10 + $(LINUX_DIR)/drivers/net/mdio/mdio-i2c.ko AUTOLOAD:=$(call AutoProbe,mdio-i2c sfp) endef @@ -1232,6 +1557,37 @@ endef $(eval $(call KernelPackage,sfp)) + +define KernelPackage/pcs-xpcs + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Synopsis DesignWare PCS driver + DEPENDS:=@(TARGET_x86_64||TARGET_armsr_armv8) +kmod-phylink + KCONFIG:=CONFIG_PCS_XPCS + FILES:=$(LINUX_DIR)/drivers/net/pcs/pcs_xpcs.ko + AUTOLOAD:=$(call AutoLoad,20,pcs_xpcs) +endef + +$(eval $(call KernelPackage,pcs-xpcs)) + + +define KernelPackage/stmmac-core + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Synopsis Ethernet Controller core (NXP,STMMicro,others) + DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 +kmod-pcs-xpcs +kmod-ptp + KCONFIG:=CONFIG_STMMAC_ETH \ + CONFIG_STMMAC_SELFTESTS=n \ + CONFIG_STMMAC_PLATFORM \ + CONFIG_CONFIG_DWMAC_DWC_QOS_ETH=n \ + CONFIG_DWMAC_GENERIC + FILES=$(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/stmmac.ko \ + $(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/stmmac-platform.ko \ + $(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.ko + AUTOLOAD=$(call AutoLoad,40,stmmac stmmac-platform dwmac-generic) +endef + +$(eval $(call KernelPackage,stmmac-core)) + + define KernelPackage/igc SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) Ethernet Controller I225 Series support @@ -1284,3 +1640,115 @@ define KernelPackage/sfc-falcon/description endef $(eval $(call KernelPackage,sfc-falcon)) + + +define KernelPackage/wwan + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=WWAN Driver Core + KCONFIG:= \ + CONFIG_WWAN \ + CONFIG_WWAN_DEBUGFS=y@ge5.17 + FILES:=$(LINUX_DIR)/drivers/net/wwan/wwan.ko + AUTOLOAD:=$(call AutoProbe,wwan) +endef + +define KernelPackage/wwan/description + This driver provides a common framework for WWAN drivers. +endef + +$(eval $(call KernelPackage,wwan)) + + +define KernelPackage/mhi-net + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MHI Network Device + DEPENDS:=@PCI_SUPPORT +kmod-mhi-bus + KCONFIG:=CONFIG_MHI_NET + FILES:=$(LINUX_DIR)/drivers/net/mhi_net.ko + AUTOLOAD:=$(call AutoProbe,mhi_net) +endef + +define KernelPackage/mhi-net/description + Driver for MHI network interface +endef + +$(eval $(call KernelPackage,mhi-net)) + +define KernelPackage/mhi-wwan-ctrl + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MHI WWAN Control + DEPENDS:=@PCI_SUPPORT +kmod-mhi-bus +kmod-wwan + KCONFIG:=CONFIG_MHI_WWAN_CTRL + FILES:=$(LINUX_DIR)/drivers/net/wwan/mhi_wwan_ctrl.ko + AUTOLOAD:=$(call AutoProbe,mhi_wwan_ctrl) +endef + +define KernelPackage/mhi-wwan-ctrl/description + Driver for MHI WWAN Control + This exposes all modem control ports like AT, MBIM, QMI, DIAG, .. +endef + +$(eval $(call KernelPackage,mhi-wwan-ctrl)) + +define KernelPackage/mhi-wwan-mbim + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MHI MBIM + DEPENDS:=@PCI_SUPPORT +kmod-mhi-bus +kmod-wwan + KCONFIG:=CONFIG_MHI_WWAN_MBIM + FILES:=$(LINUX_DIR)/drivers/net/wwan/mhi_wwan_mbim.ko + AUTOLOAD:=$(call AutoProbe,mhi_wwan_mbim) +endef + +define KernelPackage/mhi-wwan-mbim/description + Driver for MHI MBIM + This implements MBIM over MHI +endef + +$(eval $(call KernelPackage,mhi-wwan-mbim)) + +define KernelPackage/atlantic + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Aquantia AQtion 10Gbps Ethernet NIC + DEPENDS:=@PCI_SUPPORT +kmod-ptp +kmod-hwmon-core +kmod-macsec + KCONFIG:=CONFIG_AQTION + FILES:=$(LINUX_DIR)/drivers/net/ethernet/aquantia/atlantic/atlantic.ko + AUTOLOAD:=$(call AutoProbe,atlantic) +endef + +define KernelPackage/atlantic/description + Kernel modules for Aquantia AQtion 10Gbps Ethernet NIC +endef + +$(eval $(call KernelPackage,atlantic)) + + +define KernelPackage/lan743x + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Microchip LAN743x PCI Express Gigabit Ethernet NIC + DEPENDS:=@PCI_SUPPORT +kmod-ptp +kmod-mdio-devres + KCONFIG:=CONFIG_LAN743X + FILES:=$(LINUX_DIR)/drivers/net/ethernet/microchip/lan743x.ko + AUTOLOAD:=$(call AutoProbe,lan743x) +endef + +define KernelPackage/lan743x/description + Kernel module for Microchip LAN743x PCI Express Gigabit Ethernet NIC +endef + +$(eval $(call KernelPackage,lan743x)) + +define KernelPackage/amazon-ena + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Elastic Network Adapter (for Amazon AWS) + DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 + KCONFIG:=CONFIG_ENA_ETHERNET + FILES:=$(LINUX_DIR)/drivers/net/ethernet/amazon/ena/ena.ko + AUTOLOAD:=$(call AutoLoad,12,ena) +endef + +define KernelPackage/amazon-ena/description + This driver supports Elastic Network Adapter (ENA) + used by Amazon AWS T3 (2018) and later instances. +endef + +$(eval $(call KernelPackage,amazon-ena)) diff --git a/package/kernel/linux/modules/netfilter.mk b/package/kernel/linux/modules/netfilter.mk index e2bb1d0681a..da3e69e49ac 100644 --- a/package/kernel/linux/modules/netfilter.mk +++ b/package/kernel/linux/modules/netfilter.mk @@ -1,6 +1,6 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2023 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -39,6 +39,17 @@ endef $(eval $(call KernelPackage,nf-reject6)) +define KernelPackage/nf-conncount + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter conncount support + KCONFIG:=$(KCONFIG_NF_CONNCOUNT) + HIDDEN:=1 + DEPENDS:=+kmod-nf-conntrack + FILES:=$(foreach mod,$(NF_CONNCOUNT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_CONNCOUNT-m))) +endef + +$(eval $(call KernelPackage,nf-conncount)) define KernelPackage/nf-ipt SUBMENU:=$(NF_MENU) @@ -57,7 +68,7 @@ define KernelPackage/nf-ipt6 KCONFIG:=$(KCONFIG_NF_IPT6) FILES:=$(foreach mod,$(NF_IPT6-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_IPT6-m))) - DEPENDS:=+kmod-nf-ipt + DEPENDS:=+kmod-nf-ipt +kmod-nf-log6 endef $(eval $(call KernelPackage,nf-ipt6)) @@ -70,7 +81,7 @@ define KernelPackage/ipt-core KCONFIG:=$(KCONFIG_IPT_CORE) FILES:=$(foreach mod,$(IPT_CORE-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_CORE-m))) - DEPENDS:=+kmod-nf-reject +kmod-nf-ipt + DEPENDS:=+kmod-nf-reject +kmod-nf-ipt +kmod-nf-log endef define KernelPackage/ipt-core/description @@ -121,6 +132,29 @@ endef $(eval $(call KernelPackage,nf-conntrack6)) +define KernelPackage/nf-log + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter Logging + KCONFIG:=$(KCONFIG_NF_LOG) + FILES:=$(foreach mod,$(NF_LOG-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_LOG-m))) +endef + +$(eval $(call KernelPackage,nf-log)) + + +define KernelPackage/nf-log6 + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter IPV6 Logging + KCONFIG:=$(KCONFIG_NF_LOG6) + DEPENDS:=@IPV6 +kmod-nf-log + FILES:=$(foreach mod,$(NF_LOG6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_LOG6-m))) +endef + +$(eval $(call KernelPackage,nf-log6)) + + define KernelPackage/nf-nat SUBMENU:=$(NF_MENU) TITLE:=Netfilter NAT @@ -153,15 +187,35 @@ define KernelPackage/nf-flow CONFIG_NF_FLOW_TABLE \ CONFIG_NF_FLOW_TABLE_HW DEPENDS:=+kmod-nf-conntrack - FILES:= \ - $(LINUX_DIR)/net/netfilter/nf_flow_table.ko \ - $(if $(CONFIG_LINUX_5_4),$(LINUX_DIR)/net/netfilter/nf_flow_table_hw.ko) + FILES:= $(LINUX_DIR)/net/netfilter/nf_flow_table.ko AUTOLOAD:=$(call AutoProbe,nf_flow_table nf_flow_table_hw) endef $(eval $(call KernelPackage,nf-flow)) +define KernelPackage/nf-socket + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter socket lookup support + KCONFIG:= $(KCONFIG_NF_SOCKET) + FILES:=$(foreach mod,$(NF_SOCKET-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_SOCKET-m))) +endef + +$(eval $(call KernelPackage,nf-socket)) + + +define KernelPackage/nf-tproxy + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter tproxy support + KCONFIG:= $(KCONFIG_NF_TPROXY) + FILES:=$(foreach mod,$(NF_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_TPROXY-m))) +endef + +$(eval $(call KernelPackage,nf-tproxy)) + + define AddDepends/ipt SUBMENU:=$(NF_MENU) DEPENDS+= +kmod-ipt-core $(1) @@ -191,6 +245,7 @@ $(eval $(call KernelPackage,ipt-conntrack)) define KernelPackage/ipt-conntrack-extra TITLE:=Extra connection tracking modules + DEPENDS:=+kmod-nf-conncount KCONFIG:=$(KCONFIG_IPT_CONNTRACK_EXTRA) FILES:=$(foreach mod,$(IPT_CONNTRACK_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_CONNTRACK_EXTRA-m))) @@ -305,6 +360,7 @@ IPSET_MODULES:= \ ipset/ip_set_bitmap_ipmac \ ipset/ip_set_bitmap_port \ ipset/ip_set_hash_ip \ + ipset/ip_set_hash_ipmac \ ipset/ip_set_hash_ipmark \ ipset/ip_set_hash_ipport \ ipset/ip_set_hash_ipportip \ @@ -542,7 +598,7 @@ define KernelPackage/nf-nathelper-extra KCONFIG:=$(KCONFIG_NF_NATHELPER_EXTRA) FILES:=$(foreach mod,$(NF_NATHELPER_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_NATHELPER_EXTRA-m))) - DEPENDS:=+kmod-nf-nat +kmod-lib-textsearch +kmod-ipt-raw +kmod-asn1-decoder + DEPENDS:=+kmod-nf-nat +kmod-lib-textsearch +kmod-asn1-decoder endef define KernelPackage/nf-nathelper-extra/description @@ -563,23 +619,6 @@ endef $(eval $(call KernelPackage,nf-nathelper-extra)) -define KernelPackage/ipt-ulog - TITLE:=Module for user-space packet logging - KCONFIG:=$(KCONFIG_IPT_ULOG) - FILES:=$(foreach mod,$(IPT_ULOG-m),$(LINUX_DIR)/net/$(mod).ko) - AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_ULOG-m))) - $(call AddDepends/ipt) -endef - -define KernelPackage/ipt-ulog/description - Netfilter (IPv4) module for user-space packet logging - Includes: - - ULOG -endef - -$(eval $(call KernelPackage,ipt-ulog)) - - define KernelPackage/ipt-nflog TITLE:=Module for user-space packet logging KCONFIG:=$(KCONFIG_IPT_NFLOG) @@ -645,9 +684,24 @@ endef $(eval $(call KernelPackage,ipt-led)) +define KernelPackage/ipt-socket + TITLE:=Iptables socket matching support + DEPENDS+=+kmod-nf-socket +kmod-nf-conntrack + KCONFIG:=$(KCONFIG_IPT_SOCKET) + FILES:=$(foreach mod,$(IPT_SOCKET-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_SOCKET-m))) + $(call AddDepends/ipt) +endef + +define KernelPackage/ipt-socket/description + Kernel modules for socket matching +endef + +$(eval $(call KernelPackage,ipt-socket)) + define KernelPackage/ipt-tproxy TITLE:=Transparent proxying support - DEPENDS+=+kmod-ipt-conntrack +IPV6:kmod-nf-conntrack6 +IPV6:kmod-ip6tables + DEPENDS+=+kmod-nf-tproxy +kmod-nf-conntrack KCONFIG:=$(KCONFIG_IPT_TPROXY) FILES:=$(foreach mod,$(IPT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_TPROXY-m))) @@ -1004,7 +1058,7 @@ define KernelPackage/nf-conntrack-netlink FILES:=$(LINUX_DIR)/net/netfilter/nf_conntrack_netlink.ko KCONFIG:=CONFIG_NF_CT_NETLINK CONFIG_NF_CONNTRACK_EVENTS=y CONFIG_NETFILTER_NETLINK_GLUE_CT=y AUTOLOAD:=$(call AutoProbe,nf_conntrack_netlink) - $(call AddDepends/nfnetlink,+kmod-ipt-conntrack) + $(call AddDepends/nfnetlink,+kmod-nf-conntrack) endef define KernelPackage/nf-conntrack-netlink/description @@ -1052,7 +1106,7 @@ $(eval $(call KernelPackage,ipt-rpfilter)) define KernelPackage/nft-core SUBMENU:=$(NF_MENU) TITLE:=Netfilter nf_tables support - DEPENDS:=+kmod-nfnetlink +kmod-nf-reject +IPV6:kmod-nf-reject6 +IPV6:kmod-nf-conntrack6 +kmod-nf-nat +kmod-lib-crc32c + DEPENDS:=+kmod-nfnetlink +kmod-nf-reject +IPV6:kmod-nf-reject6 +IPV6:kmod-nf-conntrack6 +kmod-nf-nat +kmod-nf-log +IPV6:kmod-nf-log6 +kmod-lib-crc32c FILES:=$(foreach mod,$(NFT_CORE-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_CORE-m))) KCONFIG:= \ @@ -1087,13 +1141,32 @@ define KernelPackage/nft-bridge FILES:=$(foreach mod,$(NFT_BRIDGE-m),$(LINUX_DIR)/net/$(mod).ko) AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_BRIDGE-m))) KCONFIG:= \ - CONFIG_NF_LOG_BRIDGE=n \ $(KCONFIG_NFT_BRIDGE) endef $(eval $(call KernelPackage,nft-bridge)) +define KernelPackage/nft-dup-inet + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables dup in ip/ip6/inet family support + DEPENDS:=+kmod-nft-core +kmod-nf-conntrack +IPV6:kmod-nf-conntrack6 + KCONFIG:= \ + CONFIG_NF_DUP_IPV4 \ + CONFIG_NF_DUP_IPV6 \ + CONFIG_NFT_DUP_IPV4 \ + CONFIG_NFT_DUP_IPV6 + FILES:= \ + $(LINUX_DIR)/net/ipv4/netfilter/nf_dup_ipv4.ko \ + $(LINUX_DIR)/net/ipv6/netfilter/nf_dup_ipv6.ko \ + $(LINUX_DIR)/net/ipv4/netfilter/nft_dup_ipv4.ko \ + $(LINUX_DIR)/net/ipv6/netfilter/nft_dup_ipv6.ko + AUTOLOAD:=$(call AutoProbe,nf_dup_ipv4 nf_dup_ipv6 nft_dup_ipv4 nft_dup_ipv6) +endef + +$(eval $(call KernelPackage,nft-dup-inet)) + + define KernelPackage/nft-nat SUBMENU:=$(NF_MENU) TITLE:=Netfilter nf_tables NAT support @@ -1112,31 +1185,20 @@ define KernelPackage/nft-offload DEPENDS:=@IPV6 +kmod-nf-flow +kmod-nft-nat KCONFIG:= \ CONFIG_NF_FLOW_TABLE_INET \ - CONFIG_NF_FLOW_TABLE_IPV4 \ - CONFIG_NF_FLOW_TABLE_IPV6 \ + CONFIG_NF_FLOW_TABLE_IPV4@lt5.17 \ + CONFIG_NF_FLOW_TABLE_IPV6@lt5.17 \ CONFIG_NFT_FLOW_OFFLOAD FILES:= \ $(LINUX_DIR)/net/netfilter/nf_flow_table_inet.ko \ - $(LINUX_DIR)/net/ipv4/netfilter/nf_flow_table_ipv4.ko \ - $(LINUX_DIR)/net/ipv6/netfilter/nf_flow_table_ipv6.ko \ + $(LINUX_DIR)/net/ipv4/netfilter/nf_flow_table_ipv4.ko@lt5.17 \ + $(LINUX_DIR)/net/ipv6/netfilter/nf_flow_table_ipv6.ko@lt5.17 \ $(LINUX_DIR)/net/netfilter/nft_flow_offload.ko - AUTOLOAD:=$(call AutoProbe,nf_flow_table_inet nf_flow_table_ipv4 nf_flow_table_ipv6 nft_flow_offload) + AUTOLOAD:=$(call AutoProbe,nf_flow_table_inet nf_flow_table_ipv4@lt5.17 nf_flow_table_ipv6@lt5.17 nft_flow_offload) endef $(eval $(call KernelPackage,nft-offload)) -define KernelPackage/nft-nat6 - SUBMENU:=$(NF_MENU) - TITLE:=Netfilter nf_tables IPv6-NAT support - DEPENDS:=+kmod-nft-nat +kmod-nf-nat6 - FILES:=$(foreach mod,$(NFT_NAT6-m),$(LINUX_DIR)/net/$(mod).ko) - AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_NAT6-m))) - KCONFIG:=$(KCONFIG_NFT_NAT6) -endef - -$(eval $(call KernelPackage,nft-nat6)) - define KernelPackage/nft-netdev SUBMENU:=$(NF_MENU) TITLE:=Netfilter nf_tables netdev support @@ -1179,3 +1241,58 @@ define KernelPackage/nft-queue endef $(eval $(call KernelPackage,nft-queue)) + +define KernelPackage/nft-socket + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables socket support + DEPENDS:=+kmod-nft-core +kmod-nf-socket + FILES:=$(foreach mod,$(NFT_SOCKET-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_SOCKET-m))) + KCONFIG:=$(KCONFIG_NFT_SOCKET) +endef + +$(eval $(call KernelPackage,nft-socket)) + +define KernelPackage/nft-tproxy + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables tproxy support + DEPENDS:=+kmod-nft-core +kmod-nf-tproxy +kmod-nf-conntrack + FILES:=$(foreach mod,$(NFT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_TPROXY-m))) + KCONFIG:=$(KCONFIG_NFT_TPROXY) +endef + +$(eval $(call KernelPackage,nft-tproxy)) + +define KernelPackage/nft-compat + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables compat support + DEPENDS:=+kmod-nft-core +kmod-nf-ipt + FILES:=$(foreach mod,$(NFT_COMPAT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_COMPAT-m))) + KCONFIG:=$(KCONFIG_NFT_COMPAT) +endef + +$(eval $(call KernelPackage,nft-compat)) + +define KernelPackage/nft-xfrm + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables xfrm support (ipsec) + DEPENDS:=+kmod-nft-core + FILES:=$(foreach mod,$(NFT_XFRM-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_XFRM-m))) + KCONFIG:=$(KCONFIG_NFT_XFRM) +endef + +$(eval $(call KernelPackage,nft-xfrm)) + +define KernelPackage/nft-connlimit + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables connlimit support + DEPENDS:=+kmod-nft-core +kmod-nf-conncount + FILES:=$(foreach mod,$(NFT_CONNLIMIT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_CONNLIMIT-m))) + KCONFIG:=$(KCONFIG_NFT_CONNLIMIT) +endef + +$(eval $(call KernelPackage,nft-connlimit)) diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk index 1eec9f9b639..fcf327b434e 100644 --- a/package/kernel/linux/modules/netsupport.mk +++ b/package/kernel/linux/modules/netsupport.mk @@ -46,8 +46,10 @@ define KernelPackage/bonding SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Ethernet bonding driver KCONFIG:=CONFIG_BONDING + DEPENDS:=PACKAGE_kmod-tls:kmod-tls FILES:=$(LINUX_DIR)/drivers/net/bonding/bonding.ko AUTOLOAD:=$(call AutoLoad,40,bonding) + MODPARAMS.bonding:=max_bonds=0 endef define KernelPackage/bonding/description @@ -90,7 +92,8 @@ define KernelPackage/vxlan +kmod-udptunnel4 \ +IPV6:kmod-udptunnel6 KCONFIG:=CONFIG_VXLAN - FILES:=$(LINUX_DIR)/drivers/net/vxlan.ko + FILES:= \ + $(LINUX_DIR)/drivers/net/vxlan/vxlan.ko AUTOLOAD:=$(call AutoLoad,13,vxlan) endef @@ -162,38 +165,6 @@ endef $(eval $(call KernelPackage,misdn)) -define KernelPackage/isdn4linux - SUBMENU:=$(NETWORK_SUPPORT_MENU) - TITLE:=Old ISDN4Linux (deprecated) - DEPENDS:=+kmod-ppp - KCONFIG:= \ - CONFIG_ISDN=y \ - CONFIG_ISDN_I4L \ - CONFIG_ISDN_PPP=y \ - CONFIG_ISDN_PPP_VJ=y \ - CONFIG_ISDN_MPP=y \ - CONFIG_IPPP_FILTER=y \ - CONFIG_ISDN_PPP_BSDCOMP \ - CONFIG_ISDN_CAPI_MIDDLEWARE=y \ - CONFIG_ISDN_CAPI_CAPIFS_BOOL=y \ - CONFIG_ISDN_AUDIO=y \ - CONFIG_ISDN_TTY_FAX=y \ - CONFIG_ISDN_X25=y \ - CONFIG_ISDN_DIVERSION - FILES:= \ - $(LINUX_DIR)/drivers/isdn/divert/dss1_divert.ko \ - $(LINUX_DIR)/drivers/isdn/i4l/isdn.ko \ - $(LINUX_DIR)/drivers/isdn/i4l/isdn_bsdcomp.ko - AUTOLOAD:=$(call AutoLoad,40,isdn isdn_bsdcomp dss1_divert) -endef - -define KernelPackage/isdn4linux/description - This driver allows you to use an ISDN adapter for networking -endef - -$(eval $(call KernelPackage,isdn4linux)) - - define KernelPackage/ipip SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=IP-in-IP encapsulation @@ -246,10 +217,8 @@ $(eval $(call KernelPackage,ipsec)) IPSEC4-m = \ ipv4/ah4 \ ipv4/esp4 \ - ipv4/xfrm4_tunnel \ ipv4/ipcomp \ - -IPSEC4-m += $(ifeq ($$(strip $$(call CompareKernelPatchVer,$$(KERNEL_PATCHVER),le,5.2))),ipv4/xfrm4_mode_beet ipv4/xfrm4_mode_transport ipv4/xfrm4_mode_tunnel) + ipv4/xfrm4_tunnel define KernelPackage/ipsec4 SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -259,9 +228,6 @@ define KernelPackage/ipsec4 CONFIG_INET_AH \ CONFIG_INET_ESP \ CONFIG_INET_IPCOMP \ - CONFIG_INET_XFRM_MODE_BEET \ - CONFIG_INET_XFRM_MODE_TRANSPORT \ - CONFIG_INET_XFRM_MODE_TUNNEL \ CONFIG_INET_XFRM_TUNNEL \ CONFIG_INET_ESP_OFFLOAD=n FILES:=$(foreach mod,$(IPSEC4-m),$(LINUX_DIR)/net/$(mod).ko) @@ -274,9 +240,6 @@ define KernelPackage/ipsec4/description - ah4 - esp4 - ipcomp4 - - xfrm4_mode_beet - - xfrm4_mode_transport - - xfrm4_mode_tunnel - xfrm4_tunnel endef @@ -286,10 +249,8 @@ $(eval $(call KernelPackage,ipsec4)) IPSEC6-m = \ ipv6/ah6 \ ipv6/esp6 \ - ipv6/xfrm6_tunnel \ ipv6/ipcomp6 \ - -IPSEC6-m += $(ifeq ($$(strip $$(call CompareKernelPatchVer,$$(KERNEL_PATCHVER),le,5.2))),ipv6/xfrm6_mode_beet ipv6/xfrm6_mode_transport ipv6/xfrm6_mode_tunnel) + ipv6/xfrm6_tunnel define KernelPackage/ipsec6 SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -299,9 +260,6 @@ define KernelPackage/ipsec6 CONFIG_INET6_AH \ CONFIG_INET6_ESP \ CONFIG_INET6_IPCOMP \ - CONFIG_INET6_XFRM_MODE_BEET \ - CONFIG_INET6_XFRM_MODE_TRANSPORT \ - CONFIG_INET6_XFRM_MODE_TUNNEL \ CONFIG_INET6_XFRM_TUNNEL \ CONFIG_INET6_ESP_OFFLOAD=n FILES:=$(foreach mod,$(IPSEC6-m),$(LINUX_DIR)/net/$(mod).ko) @@ -314,9 +272,6 @@ define KernelPackage/ipsec6/description - ah6 - esp6 - ipcomp6 - - xfrm6_mode_beet - - xfrm6_mode_transport - - xfrm6_mode_tunnel - xfrm6_tunnel endef @@ -375,7 +330,7 @@ $(eval $(call KernelPackage,ip6-vti)) define KernelPackage/xfrm-interface SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=IPsec XFRM Interface - DEPENDS:=+kmod-ipsec4 +IPV6:kmod-ipsec6 + DEPENDS:=@IPV6 +kmod-ipsec4 +kmod-ipsec6 KCONFIG:=CONFIG_XFRM_INTERFACE FILES:=$(LINUX_DIR)/net/xfrm/xfrm_interface.ko AUTOLOAD:=$(call AutoProbe,xfrm_interface) @@ -563,6 +518,23 @@ endef $(eval $(call KernelPackage,veth)) +define KernelPackage/vrf + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Virtual Routing and Forwarding (Lite) + DEPENDS:=@KERNEL_NET_L3_MASTER_DEV + KCONFIG:=CONFIG_NET_VRF + FILES:=$(LINUX_DIR)/drivers/net/vrf.ko + AUTOLOAD:=$(call AutoLoad,30,vrf) +endef + +define KernelPackage/vrf/description + This option enables the support for mapping interfaces into VRF's. The + support enables VRF devices. +endef + +$(eval $(call KernelPackage,vrf)) + + define KernelPackage/slhc SUBMENU:=$(NETWORK_SUPPORT_MENU) HIDDEN:=1 @@ -720,12 +692,8 @@ endef $(eval $(call KernelPackage,mppe)) -SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko)) -SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc sch_htb sch_tbf cls_basic cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_gact act_mirred act_skbedit cls_matchall -SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark act_ctinfo sch_cake sch_netem sch_mqprio em_ipset cls_bpf cls_flower act_bpf act_vlan -SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES)) -SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES))) -SCHED_FILES_EXTRA = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(SCHED_MODULES_EXTRA)) +SCHED_MODULES_CORE = sch_ingress sch_hfsc sch_htb sch_tbf cls_basic cls_fw cls_route cls_flow cls_u32 em_u32 act_gact act_mirred act_skbedit cls_matchall +SCHED_FILES_CORE = $(foreach mod,$(SCHED_MODULES_CORE),$(LINUX_DIR)/net/sched/$(mod).ko) define KernelPackage/sched-core SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -736,14 +704,12 @@ define KernelPackage/sched-core CONFIG_NET_SCH_HTB \ CONFIG_NET_SCH_TBF \ CONFIG_NET_SCH_INGRESS \ - CONFIG_NET_SCH_FQ_CODEL \ CONFIG_NET_CLS=y \ CONFIG_NET_CLS_ACT=y \ CONFIG_NET_CLS_BASIC \ CONFIG_NET_CLS_FLOW \ CONFIG_NET_CLS_FW \ CONFIG_NET_CLS_ROUTE4 \ - CONFIG_NET_CLS_TCINDEX \ CONFIG_NET_CLS_U32 \ CONFIG_NET_ACT_GACT \ CONFIG_NET_ACT_MIRRED \ @@ -751,7 +717,7 @@ define KernelPackage/sched-core CONFIG_NET_CLS_MATCHALL \ CONFIG_NET_EMATCH=y \ CONFIG_NET_EMATCH_U32 - FILES:=$(SCHED_FILES) + FILES:=$(SCHED_FILES_CORE) AUTOLOAD:=$(call AutoLoad,70, $(SCHED_MODULES_CORE)) endef @@ -762,35 +728,52 @@ endef $(eval $(call KernelPackage,sched-core)) -define KernelPackage/sched-cake +define KernelPackage/sched-act-police SUBMENU:=$(NETWORK_SUPPORT_MENU) - TITLE:=Cake fq_codel/blue derived shaper + TITLE:=Traffic Policing DEPENDS:=+kmod-sched-core - KCONFIG:=CONFIG_NET_SCH_CAKE - FILES:=$(LINUX_DIR)/net/sched/sch_cake.ko - AUTOLOAD:=$(call AutoProbe,sch_cake) + KCONFIG:=CONFIG_NET_ACT_POLICE + FILES:=$(LINUX_DIR)/net/sched/act_police.ko + AUTOLOAD:=$(call AutoProbe,act_police) endef -define KernelPackage/sched-cake/description - Common Applications Kept Enhanced fq_codel/blue derived shaper -endef +$(eval $(call KernelPackage,sched-act-police)) -$(eval $(call KernelPackage,sched-cake)) -define KernelPackage/sched-flower +define KernelPackage/sched-act-sample SUBMENU:=$(NETWORK_SUPPORT_MENU) - TITLE:=Flower traffic classifier + TITLE:=Traffic Sampling DEPENDS:=+kmod-sched-core - KCONFIG:=CONFIG_NET_CLS_FLOWER - FILES:=$(LINUX_DIR)/net/sched/cls_flower.ko - AUTOLOAD:=$(call AutoProbe, cls_flower) + KCONFIG:= \ + CONFIG_NET_ACT_SAMPLE \ + CONFIG_PSAMPLE + FILES:= \ + $(LINUX_DIR)/net/psample/psample.ko \ + $(LINUX_DIR)/net/sched/act_sample.ko + AUTOLOAD:=$(call AutoProbe,act_sample psample) endef -define KernelPackage/sched-flower/description - Allows to classify packets based on a configurable combination of packet keys and masks. +define KernelPackage/sched-act-sample/description + Packet sampling tc action. endef -$(eval $(call KernelPackage,sched-flower)) +$(eval $(call KernelPackage,sched-act-sample)) + + +define KernelPackage/sched-act-ipt + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPtables targets + DEPENDS:=+kmod-ipt-core +kmod-sched-core + KCONFIG:=CONFIG_NET_ACT_IPT + FILES:=$(LINUX_DIR)/net/sched/act_ipt.ko + AUTOLOAD:=$(call AutoProbe, act_ipt) +endef + +define KernelPackage/sched-act-ipt/description + Allows to invoke iptables targets after successful classification. +endef + +$(eval $(call KernelPackage,sched-act-ipt)) define KernelPackage/sched-act-vlan @@ -809,20 +792,36 @@ endef $(eval $(call KernelPackage,sched-act-vlan)) -define KernelPackage/sched-mqprio +define KernelPackage/sched-bpf SUBMENU:=$(NETWORK_SUPPORT_MENU) - TITLE:=Multi-queue priority scheduler (MQPRIO) + TITLE:=Traffic shaper support for Berkeley Packet Filter + KCONFIG:= \ + CONFIG_NET_CLS_BPF \ + CONFIG_NET_ACT_BPF + FILES:= \ + $(LINUX_DIR)/net/sched/cls_bpf.ko \ + $(LINUX_DIR)/net/sched/act_bpf.ko + AUTOLOAD:=$(call AutoLoad,72,cls_bpf act_bpf) +endef + +$(eval $(call KernelPackage,sched-bpf)) + + +define KernelPackage/sched-cake + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Cake fq_codel/blue derived shaper DEPENDS:=+kmod-sched-core - KCONFIG:=CONFIG_NET_SCH_MQPRIO - FILES:=$(LINUX_DIR)/net/sched/sch_mqprio.ko - AUTOLOAD:=$(call AutoProbe, sch_mqprio) + KCONFIG:=CONFIG_NET_SCH_CAKE + FILES:=$(LINUX_DIR)/net/sched/sch_cake.ko + AUTOLOAD:=$(call AutoProbe,sch_cake) endef -define KernelPackage/sched-mqprio/description - This scheduler allows QOS to be offloaded on NICs that have support for offloading QOS schedulers. +define KernelPackage/sched-cake/description + Common Applications Kept Enhanced fq_codel/blue derived shaper endef -$(eval $(call KernelPackage,sched-mqprio)) +$(eval $(call KernelPackage,sched-cake)) + define KernelPackage/sched-connmark SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -834,6 +833,7 @@ define KernelPackage/sched-connmark endef $(eval $(call KernelPackage,sched-connmark)) + define KernelPackage/sched-ctinfo SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Traffic shaper ctinfo support @@ -844,6 +844,55 @@ define KernelPackage/sched-ctinfo endef $(eval $(call KernelPackage,sched-ctinfo)) + +define KernelPackage/sched-drr + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Deficit Round Robin scheduler (DRR) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_DRR + FILES:=$(LINUX_DIR)/net/sched/sch_drr.ko + AUTOLOAD:=$(call AutoProbe,sch_drr) +endef + +define KernelPackage/sched-drr/description + DRR algorithm Configuration +endef + +$(eval $(call KernelPackage,sched-drr)) + + +define KernelPackage/sched-flower + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Flower traffic classifier + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_CLS_FLOWER + FILES:=$(LINUX_DIR)/net/sched/cls_flower.ko + AUTOLOAD:=$(call AutoProbe, cls_flower) +endef + +define KernelPackage/sched-flower/description + Allows to classify packets based on a configurable combination of packet keys and masks. +endef + +$(eval $(call KernelPackage,sched-flower)) + + +define KernelPackage/sched-fq-pie + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Flow Queue Proportional Integral Enhanced (FQ-PIE) + DEPENDS:=+kmod-sched-core +kmod-sched-pie + KCONFIG:=CONFIG_NET_SCH_FQ_PIE + FILES:=$(LINUX_DIR)/net/sched/sch_fq_pie.ko + AUTOLOAD:=$(call AutoProbe, sch_fq_pie) +endef + +define KernelPackage/sched-fq-pie/description + A queuing discipline that combines Flow Queuing with the PIE AQM. +endef + +$(eval $(call KernelPackage,sched-fq-pie)) + + define KernelPackage/sched-ipset SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Traffic shaper ipset support @@ -858,19 +907,80 @@ endef $(eval $(call KernelPackage,sched-ipset)) -define KernelPackage/sched-bpf +define KernelPackage/sched-mqprio SUBMENU:=$(NETWORK_SUPPORT_MENU) - TITLE:=Traffic shaper support for Berkeley Packet Filter - KCONFIG:= \ - CONFIG_NET_CLS_BPF \ - CONFIG_NET_ACT_BPF - FILES:= \ - $(LINUX_DIR)/net/sched/cls_bpf.ko \ - $(LINUX_DIR)/net/sched/act_bpf.ko - AUTOLOAD:=$(call AutoLoad,72,cls_bpf act_bpf) + TITLE:=Multi-queue priority scheduler (MQPRIO) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_MQPRIO + FILES:=$(LINUX_DIR)/net/sched/sch_mqprio.ko + AUTOLOAD:=$(call AutoProbe, sch_mqprio) endef -$(eval $(call KernelPackage,sched-bpf)) +define KernelPackage/sched-mqprio/description + This scheduler allows QOS to be offloaded on NICs that have support for offloading QOS schedulers. +endef + +$(eval $(call KernelPackage,sched-mqprio)) + + +define KernelPackage/sched-pie + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Proportional Integral controller-Enhanced AQM (PIE) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_PIE + FILES:=$(LINUX_DIR)/net/sched/sch_pie.ko + AUTOLOAD:=$(call AutoProbe, sch_pie) +endef + +define KernelPackage/sched-pie/description + A control theoretic active queue management scheme. +endef + +$(eval $(call KernelPackage,sched-pie)) + + +define KernelPackage/sched-prio + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Multi Band Priority Queueing (PRIO) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_PRIO + FILES:=$(LINUX_DIR)/net/sched/sch_prio.ko + AUTOLOAD:=$(call AutoProbe,sch_prio) +endef + +define KernelPackage/sched-prio/description + PRIO algorithm Configuration +endef + +$(eval $(call KernelPackage,sched-prio)) + + +define KernelPackage/sched-red + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Random Early Detection (RED) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_RED + FILES:=$(LINUX_DIR)/net/sched/sch_red.ko + AUTOLOAD:=$(call AutoProbe,sch_red) +endef + +define KernelPackage/sched-red/description + Random Early Detection (RED) algorithm Configuration +endef + +$(eval $(call KernelPackage,sched-red)) + + +define KernelPackage/sched-skbprio + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=SKB priority queue scheduler (SKBPRIO) + DEPENDS:=+kmod-sched-core + KCONFIG:= CONFIG_NET_SCH_SKBPRIO + FILES:= $(LINUX_DIR)/net/sched/sch_skbprio.ko + AUTOLOAD:=$(call AutoProbe,sch_skbprio) +endef + +$(eval $(call KernelPackage,sched-skbprio)) define KernelPackage/bpf-test @@ -883,26 +993,24 @@ endef $(eval $(call KernelPackage,bpf-test)) +SCHED_MODULES_EXTRA = sch_codel sch_dsmark sch_gred sch_multiq sch_sfq sch_teql sch_fq act_pedit act_simple act_skbmod act_csum em_cmp em_nbyte em_meta em_text +SCHED_FILES_EXTRA = $(foreach mod,$(SCHED_MODULES_EXTRA),$(LINUX_DIR)/net/sched/$(mod).ko) + define KernelPackage/sched SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Extra traffic schedulers - DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-lib-crc32c + DEPENDS:=+kmod-sched-core +kmod-lib-crc32c +kmod-lib-textsearch KCONFIG:= \ CONFIG_NET_SCH_CODEL \ CONFIG_NET_SCH_DSMARK \ - CONFIG_NET_SCH_FIFO \ CONFIG_NET_SCH_GRED \ CONFIG_NET_SCH_MULTIQ \ - CONFIG_NET_SCH_PRIO \ - CONFIG_NET_SCH_RED \ CONFIG_NET_SCH_SFQ \ CONFIG_NET_SCH_TEQL \ CONFIG_NET_SCH_FQ \ - CONFIG_NET_SCH_PIE \ - CONFIG_NET_ACT_POLICE \ - CONFIG_NET_ACT_IPT \ CONFIG_NET_ACT_PEDIT \ CONFIG_NET_ACT_SIMP \ + CONFIG_NET_ACT_SKBMOD \ CONFIG_NET_ACT_CSUM \ CONFIG_NET_EMATCH_CMP \ CONFIG_NET_EMATCH_NBYTE \ @@ -949,6 +1057,24 @@ endef $(eval $(call KernelPackage,tcp-bbr)) +define KernelPackage/tls + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=In-kernel TLS Support with HW Offload + KCONFIG:=CONFIG_TLS \ + CONFIG_TLS_DEVICE=y + FILES:=$(LINUX_DIR)/net/tls/tls.ko + AUTOLOAD:=$(call AutoProbe,tls) +endef + +define KernelPackage/tls/description + Kernel module for in-kernel TLS protocol support and hw offload + (to supported interfaces). + This allows symmetric encryption handling of the TLS protocol to + be done in-kernel and it's HW offload when available. +endef + +$(eval $(call KernelPackage,tls)) + define KernelPackage/tcp-hybla SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -968,6 +1094,24 @@ endef $(eval $(call KernelPackage,tcp-hybla)) +define KernelPackage/tcp-scalable + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=TCP-Scalable congestion control algorithm + KCONFIG:=CONFIG_TCP_CONG_SCALABLE + FILES:=$(LINUX_DIR)/net/ipv4/tcp_scalable.ko + AUTOLOAD:=$(call AutoProbe,tcp-scalable) +endef + +define KernelPackage/tcp-scalable/description + Scalable TCP is a sender-side only change to TCP which uses a + MIMD congestion control algorithm which has some nice scaling + properties, though is known to have fairness issues. + See http://www.deneholme.net/tom/scalable/ +endef + +$(eval $(call KernelPackage,tcp-scalable)) + + define KernelPackage/ax25 SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=AX25 support @@ -1075,7 +1219,8 @@ define KernelPackage/sctp CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5=y FILES:= $(LINUX_DIR)/net/sctp/sctp.ko AUTOLOAD:= $(call AutoLoad,32,sctp) - DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac + DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac \ + +kmod-udptunnel4 +kmod-udptunnel6 endef define KernelPackage/sctp/description @@ -1142,7 +1287,8 @@ define KernelPackage/rxrpc FILES:= \ $(LINUX_DIR)/net/rxrpc/rxrpc.ko AUTOLOAD:=$(call AutoLoad,30,rxrpc.ko) - DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt + DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt \ + +kmod-udptunnel4 +kmod-udptunnel6 endef define KernelPackage/rxrpc/description @@ -1178,16 +1324,13 @@ $(eval $(call KernelPackage,mpls)) define KernelPackage/9pnet SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Plan 9 Resource Sharing Support (9P2000) - DEPENDS:=@VIRTIO_SUPPORT KCONFIG:= \ CONFIG_NET_9P \ CONFIG_NET_9P_DEBUG=n \ - CONFIG_NET_9P_XEN=n \ - CONFIG_NET_9P_VIRTIO + CONFIG_NET_9P_FD=n@ge5.17 FILES:= \ - $(LINUX_DIR)/net/9p/9pnet.ko \ - $(LINUX_DIR)/net/9p/9pnet_virtio.ko - AUTOLOAD:=$(call AutoLoad,29,9pnet 9pnet_virtio) + $(LINUX_DIR)/net/9p/9pnet.ko + AUTOLOAD:=$(call AutoLoad,29,9pnet) endef define KernelPackage/9pnet/description @@ -1197,6 +1340,25 @@ endef $(eval $(call KernelPackage,9pnet)) +define KernelPackage/9pvirtio + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Plan 9 Virtio Support + DEPENDS:=+kmod-9pnet @VIRTIO_SUPPORT + KCONFIG:= \ + CONFIG_NET_9P_XEN=n \ + CONFIG_NET_9P_VIRTIO + FILES:= \ + $(LINUX_DIR)/net/9p/9pnet_virtio.ko + AUTOLOAD:=$(call AutoLoad,29,9pnet_virtio) +endef + +define KernelPackage/9pvirtio/description + Kernel support support for + Plan 9 resource sharing for virtio. +endef + +$(eval $(call KernelPackage,9pvirtio)) + define KernelPackage/nlmon SUBMENU:=$(NETWORK_SUPPORT_MENU) @@ -1228,6 +1390,21 @@ endef $(eval $(call KernelPackage,mdio)) +define KernelPackage/mdio-bus-mux + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=MDIO bus multiplexers + KCONFIG:=CONFIG_MDIO_BUS_MUX + HIDDEN:=1 + FILES:=$(LINUX_DIR)/drivers/net/mdio/mdio-mux.ko + AUTOLOAD:=$(call AutoLoad,32,mdio-mux) +endef + +define KernelPackage/mdio-bus-mux/description + Kernel framework for MDIO bus multiplexers. +endef + +$(eval $(call KernelPackage,mdio-bus-mux)) + define KernelPackage/macsec SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=IEEE 802.1AE MAC-level encryption (MAC) @@ -1259,11 +1436,51 @@ endef $(eval $(call KernelPackage,netlink-diag)) +define KernelPackage/inet-diag + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=INET diag support for ss utility + KCONFIG:= \ + CONFIG_INET_DIAG \ + CONFIG_INET_TCP_DIAG \ + CONFIG_INET_UDP_DIAG \ + CONFIG_INET_RAW_DIAG \ + CONFIG_INET_DIAG_DESTROY=n + FILES:= \ + $(LINUX_DIR)/net/ipv4/inet_diag.ko \ + $(LINUX_DIR)/net/ipv4/tcp_diag.ko \ + $(LINUX_DIR)/net/ipv4/udp_diag.ko \ + $(LINUX_DIR)/net/ipv4/raw_diag.ko + AUTOLOAD:=$(call AutoLoad,31,inet_diag tcp_diag udp_diag raw_diag) +endef + +define KernelPackage/inet-diag/description +Support for INET (TCP, DCCP, etc) socket monitoring interface used by +native Linux tools such as ss. +endef + +$(eval $(call KernelPackage,inet-diag)) + + +define KernelPackage/xdp-sockets-diag + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=PF_XDP sockets monitoring interface support for ss utility + DEPENDS:=@KERNEL_XDP_SOCKETS + KCONFIG:=CONFIG_XDP_SOCKETS_DIAG + FILES:=$(LINUX_DIR)/net/xdp/xsk_diag.ko + AUTOLOAD:=$(call AutoLoad,31,xsk_diag) +endef + +define KernelPackage/xdp-sockets-diag/description + Support for PF_XDP sockets monitoring interface used by the ss tool +endef + +$(eval $(call KernelPackage,xdp-sockets-diag)) + + define KernelPackage/wireguard SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=WireGuard secure network tunnel DEPENDS:= \ - +kmod-crypto-lib-blake2s \ +kmod-crypto-lib-chacha20poly1305 \ +kmod-crypto-lib-curve25519 \ +kmod-udptunnel4 \ @@ -1285,3 +1502,81 @@ define KernelPackage/wireguard/description endef $(eval $(call KernelPackage,wireguard)) + + +define KernelPackage/netconsole + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Network console logging support + KCONFIG:=CONFIG_NETCONSOLE \ + CONFIG_NETCONSOLE_DYNAMIC=n + FILES:=$(LINUX_DIR)/drivers/net/netconsole.ko + AUTOLOAD:=$(call AutoProbe,netconsole) +endef + +define KernelPackage/netconsole/description + Network console logging support. +endef + +$(eval $(call KernelPackage,netconsole)) + + +define KernelPackage/qrtr + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Qualcomm IPC Router support + HIDDEN:=1 + KCONFIG:=CONFIG_QRTR + FILES:= \ + $(LINUX_DIR)/net/qrtr/qrtr.ko + AUTOLOAD:=$(call AutoProbe,qrtr) +endef + +define KernelPackage/qrtr/description + Qualcomm IPC Router support +endef + +$(eval $(call KernelPackage,qrtr)) + +define KernelPackage/qrtr-tun + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=TUN device for Qualcomm IPC Router + DEPENDS:=+kmod-qrtr + KCONFIG:=CONFIG_QRTR_TUN + FILES:= $(LINUX_DIR)/net/qrtr/qrtr-tun.ko + AUTOLOAD:=$(call AutoProbe,qrtr-tun) +endef + +define KernelPackage/qrtr-tun/description + TUN device for Qualcomm IPC Router +endef + +$(eval $(call KernelPackage,qrtr-tun)) + +define KernelPackage/qrtr-smd + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=SMD IPC Router channels + DEPENDS:=+kmod-qrtr @TARGET_qualcommax + KCONFIG:=CONFIG_QRTR_SMD + FILES:= $(LINUX_DIR)/net/qrtr/qrtr-smd.ko + AUTOLOAD:=$(call AutoProbe,qrtr-smd) +endef + +define KernelPackage/qrtr-smd/description + SMD IPC Router channels +endef + +$(eval $(call KernelPackage,qrtr-smd)) + +define KernelPackage/qrtr-mhi + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=MHI IPC Router channels + DEPENDS:=+kmod-mhi-bus +kmod-qrtr + KCONFIG:=CONFIG_QRTR_MHI + FILES:= $(LINUX_DIR)/net/qrtr/qrtr-mhi.ko + AUTOLOAD:=$(call AutoProbe,qrtr-mhi) +endef + +define KernelPackage/qrtr-mhi/description + MHI IPC Router channels +endef + +$(eval $(call KernelPackage,qrtr-mhi)) diff --git a/package/kernel/linux/modules/nls.mk b/package/kernel/linux/modules/nls.mk index 05fce27bbc2..7450ed1ce56 100644 --- a/package/kernel/linux/modules/nls.mk +++ b/package/kernel/linux/modules/nls.mk @@ -135,8 +135,10 @@ define KernelPackage/nls-cp932 SUBMENU:=Native Language Support TITLE:=Codepage 932 (Japanese) KCONFIG:=CONFIG_NLS_CODEPAGE_932 - FILES:=$(LINUX_DIR)/fs/nls/nls_cp932.ko - AUTOLOAD:=$(call AutoLoad,25,nls_cp932) + FILES:= \ + $(LINUX_DIR)/fs/nls/nls_cp932.ko \ + $(LINUX_DIR)/fs/nls/nls_euc-jp.ko + AUTOLOAD:=$(call AutoLoad,25,nls_cp932 nls_euc-jp) $(call AddDepends/nls) endef diff --git a/package/kernel/linux/modules/other.mk b/package/kernel/linux/modules/other.mk index 926fc67386f..4a061974c33 100644 --- a/package/kernel/linux/modules/other.mk +++ b/package/kernel/linux/modules/other.mk @@ -40,6 +40,8 @@ define KernelPackage/bluetooth CONFIG_BT_BNEP \ CONFIG_BT_HCIBTUSB \ CONFIG_BT_HCIBTUSB_BCM=n \ + CONFIG_BT_HCIBTUSB_MTK=y \ + CONFIG_BT_HCIBTUSB_RTL=y \ CONFIG_BT_HCIUART \ CONFIG_BT_HCIUART_BCM=n \ CONFIG_BT_HCIUART_INTEL=n \ @@ -54,7 +56,9 @@ define KernelPackage/bluetooth $(LINUX_DIR)/net/bluetooth/hidp/hidp.ko \ $(LINUX_DIR)/drivers/bluetooth/hci_uart.ko \ $(LINUX_DIR)/drivers/bluetooth/btusb.ko \ - $(LINUX_DIR)/drivers/bluetooth/btintel.ko + $(LINUX_DIR)/drivers/bluetooth/btintel.ko \ + $(LINUX_DIR)/drivers/bluetooth/btrtl.ko \ + $(LINUX_DIR)/drivers/bluetooth/btmtk.ko@ge5.17 AUTOLOAD:=$(call AutoProbe,bluetooth rfcomm bnep hidp hci_uart btusb) endef @@ -71,7 +75,6 @@ define KernelPackage/ath3k KCONFIG:= \ CONFIG_BT_ATH3K \ CONFIG_BT_HCIUART_ATH3K=y - $(call AddDepends/bluetooth) FILES:= \ $(LINUX_DIR)/drivers/bluetooth/ath3k.ko AUTOLOAD:=$(call AutoProbe,ath3k) @@ -107,7 +110,6 @@ define KernelPackage/btmrvl KCONFIG:= \ CONFIG_BT_MRVL \ CONFIG_BT_MRVL_SDIO - $(call AddDepends/bluetooth) FILES:= \ $(LINUX_DIR)/drivers/bluetooth/btmrvl.ko \ $(LINUX_DIR)/drivers/bluetooth/btmrvl_sdio.ko @@ -121,6 +123,24 @@ endef $(eval $(call KernelPackage,btmrvl)) +define KernelPackage/btsdio + SUBMENU:=$(OTHER_MENU) + TITLE:=Bluetooth HCI SDIO driver + DEPENDS:=+kmod-bluetooth +kmod-mmc + KCONFIG:= \ + CONFIG_BT_HCIBTSDIO + FILES:= \ + $(LINUX_DIR)/drivers/bluetooth/btsdio.ko + AUTOLOAD:=$(call AutoProbe,btsdio) +endef + +define KernelPackage/btsdio/description + Kernel support for Bluetooth device with SDIO interface +endef + +$(eval $(call KernelPackage,btsdio)) + + define KernelPackage/dma-buf SUBMENU:=$(OTHER_MENU) TITLE:=DMA shared buffer support @@ -182,136 +202,98 @@ endef $(eval $(call KernelPackage,eeprom-at25)) -define KernelPackage/gpio-dev - SUBMENU:=$(OTHER_MENU) - TITLE:=Generic GPIO char device support - DEPENDS:=@GPIO_SUPPORT - KCONFIG:=CONFIG_GPIO_DEVICE - FILES:=$(LINUX_DIR)/drivers/char/gpio_dev.ko - AUTOLOAD:=$(call AutoLoad,40,gpio_dev) -endef - -define KernelPackage/gpio-dev/description - Kernel module to allows control of GPIO pins using a character device. -endef - -$(eval $(call KernelPackage,gpio-dev)) - - -define KernelPackage/gpio-f7188x - SUBMENU:=$(OTHER_MENU) - TITLE:=Fintek F718xx/F818xx GPIO Support - DEPENDS:=@GPIO_SUPPORT @TARGET_x86 - KCONFIG:=CONFIG_GPIO_F7188X - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-f7188x.ko - AUTOLOAD:=$(call AutoProbe,gpio-f7188x) -endef - -define KernelPackage/gpio-f7188x/description - Kernel module for the GPIOs found on many Fintek Super-IO chips. -endef - -$(eval $(call KernelPackage,gpio-f7188x)) - - -define KernelPackage/gpio-mcp23s08 +define KernelPackage/google-firmware SUBMENU:=$(OTHER_MENU) - TITLE:=Microchip MCP23xxx I/O expander - DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-regmap-i2c + TITLE:=Google firmware drivers (Coreboot, VPD, Memconsole) KCONFIG:= \ - CONFIG_GPIO_MCP23S08 \ - CONFIG_PINCTRL_MCP23S08 + CONFIG_GOOGLE_FIRMWARE=y \ + CONFIG_GOOGLE_COREBOOT_TABLE \ + CONFIG_GOOGLE_MEMCONSOLE \ + CONFIG_GOOGLE_MEMCONSOLE_COREBOOT \ + CONFIG_GOOGLE_VPD FILES:= \ - $(LINUX_DIR)/drivers/pinctrl/pinctrl-mcp23s08.ko - AUTOLOAD:=$(call AutoLoad,40,pinctrl-mcp23s08) + $(LINUX_DIR)/drivers/firmware/google/coreboot_table.ko \ + $(LINUX_DIR)/drivers/firmware/google/memconsole.ko \ + $(LINUX_DIR)/drivers/firmware/google/memconsole-coreboot.ko \ + $(LINUX_DIR)/drivers/firmware/google/vpd-sysfs.ko + AUTOLOAD:=$(call AutoProbe,coreboot_table memconsole-coreboot vpd-sysfs) endef -define KernelPackage/gpio-mcp23s08/description - Kernel module for Microchip MCP23xxx SPI/I2C I/O expander +define KernelPackage/google-firmware/description + Kernel modules for Google firmware drivers. Useful for examining firmware and + boot details on devices using a Google bootloader based on Coreboot. Provides + files like /sys/firmware/log and /sys/firmware/vpd. endef -$(eval $(call KernelPackage,gpio-mcp23s08)) +$(eval $(call KernelPackage,google-firmware)) -define KernelPackage/gpio-nxp-74hc164 +define KernelPackage/lkdtm SUBMENU:=$(OTHER_MENU) - TITLE:=NXP 74HC164 GPIO expander support - KCONFIG:=CONFIG_GPIO_74X164 - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-74x164.ko - AUTOLOAD:=$(call AutoProbe,gpio-74x164) -endef - -define KernelPackage/gpio-nxp-74hc164/description - Kernel module for NXP 74HC164 GPIO expander + TITLE:=Linux Kernel Dump Test Tool Module + KCONFIG:=CONFIG_LKDTM + FILES:=$(LINUX_DIR)/drivers/misc/lkdtm/lkdtm.ko + AUTOLOAD:=$(call AutoProbe,lkdtm) endef -$(eval $(call KernelPackage,gpio-nxp-74hc164)) - -define KernelPackage/gpio-pca953x - SUBMENU:=$(OTHER_MENU) - DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-regmap-i2c - TITLE:=PCA95xx, TCA64xx, and MAX7310 I/O ports - KCONFIG:=CONFIG_GPIO_PCA953X - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pca953x.ko - AUTOLOAD:=$(call AutoLoad,55,gpio-pca953x) +define KernelPackage/lkdtm/description + This module enables testing of the different dumping mechanisms by inducing + system failures at predefined crash points. endef -define KernelPackage/gpio-pca953x/description - Kernel module for MAX731{0,2,3,5}, PCA6107, PCA953{4-9}, PCA955{4-7}, - PCA957{4,5} and TCA64{08,16} I2C GPIO expanders -endef +$(eval $(call KernelPackage,lkdtm)) -$(eval $(call KernelPackage,gpio-pca953x)) -define KernelPackage/gpio-pcf857x +define KernelPackage/pinctrl-mcp23s08 SUBMENU:=$(OTHER_MENU) - DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core - TITLE:=PCX857x, PCA967x and MAX732X I2C GPIO expanders - KCONFIG:=CONFIG_GPIO_PCF857X - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pcf857x.ko - AUTOLOAD:=$(call AutoLoad,55,gpio-pcf857x) + TITLE:=Microchip MCP23xxx I/O expander + HIDDEN:=1 + DEPENDS:=@GPIO_SUPPORT +kmod-regmap-core + KCONFIG:=CONFIG_PINCTRL_MCP23S08 + FILES:=$(LINUX_DIR)/drivers/pinctrl/pinctrl-mcp23s08.ko + AUTOLOAD:=$(call AutoLoad,40,pinctrl-mcp23s08) endef -define KernelPackage/gpio-pcf857x/description - Kernel module for PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders +define KernelPackage/pinctrl-mcp23s08/description + Kernel module for Microchip MCP23xxx I/O expander endef -$(eval $(call KernelPackage,gpio-pcf857x)) +$(eval $(call KernelPackage,pinctrl-mcp23s08)) -define KernelPackage/gpio-it87 +define KernelPackage/pinctrl-mcp23s08-i2c SUBMENU:=$(OTHER_MENU) - DEPENDS:=@GPIO_SUPPORT @TARGET_x86 - TITLE:=GPIO support for IT87xx Super I/O chips - KCONFIG:=CONFIG_GPIO_IT87 - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-it87.ko - AUTOLOAD:=$(call AutoLoad,25,gpio-it87,1) + TITLE:=Microchip MCP23xxx I/O expander (I2C) + DEPENDS:=@GPIO_SUPPORT \ + +kmod-pinctrl-mcp23s08 \ + +kmod-i2c-core \ + +kmod-regmap-i2c + KCONFIG:=CONFIG_PINCTRL_MCP23S08_I2C + FILES:=$(LINUX_DIR)/drivers/pinctrl/pinctrl-mcp23s08_i2c.ko + AUTOLOAD:=$(call AutoLoad,40,pinctrl-mcp23s08-i2c) endef -define KernelPackage/gpio-it87/description - This driver is tested with ITE IT8728 and IT8732 Super I/O chips, and - supports the IT8761E, IT8613, IT8620E, and IT8628E Super I/O chips as - well. +define KernelPackage/pinctrl-mcp23s08-i2c/description + Kernel module for Microchip MCP23xxx I/O expander via I2C endef -$(eval $(call KernelPackage,gpio-it87)) +$(eval $(call KernelPackage,pinctrl-mcp23s08-i2c)) -define KernelPackage/gpio-amd-fch +define KernelPackage/pinctrl-mcp23s08-spi SUBMENU:=$(OTHER_MENU) - DEPENDS:=@GPIO_SUPPORT @TARGET_x86 - TITLE:=GPIO support for AMD Fusion Controller Hub (G-series SOCs) - KCONFIG:=CONFIG_GPIO_AMD_FCH - FILES:=$(LINUX_DIR)/drivers/gpio/gpio-amd-fch.ko - AUTOLOAD:=$(call AutoLoad,25,gpio-amd-fch,1) + TITLE:=Microchip MCP23xxx I/O expander (SPI) + DEPENDS:=@GPIO_SUPPORT +kmod-pinctrl-mcp23s08 + KCONFIG:=CONFIG_PINCTRL_MCP23S08_SPI + FILES:=$(LINUX_DIR)/drivers/pinctrl/pinctrl-mcp23s08_spi.ko + AUTOLOAD:=$(call AutoLoad,40,pinctrl-mcp23s08-spi) endef -define KernelPackage/gpio-amd-fch/description - This option enables driver for GPIO on AMDs Fusion Controller Hub, - as found on G-series SOCs (eg. GX-412TC) +define KernelPackage/pinctrl-mcp23s08-spi/description + Kernel module for Microchip MCP23xxx I/O expander via SPI endef -$(eval $(call KernelPackage,gpio-amd-fch)) +$(eval $(call KernelPackage,pinctrl-mcp23s08-spi)) define KernelPackage/ppdev @@ -375,7 +357,6 @@ define KernelPackage/mmc CONFIG_MMC_BLOCK \ CONFIG_MMC_DEBUG=n \ CONFIG_MMC_UNSAFE_RESUME=n \ - CONFIG_MMC_BLOCK_BOUNCE=y \ CONFIG_MMC_TIFM_SD=n \ CONFIG_MMC_WBSD=n \ CONFIG_SDIO_UART=n @@ -392,23 +373,6 @@ endef $(eval $(call KernelPackage,mmc)) -define KernelPackage/mvsdio - SUBMENU:=$(OTHER_MENU) - TITLE:=Marvell MMC/SD/SDIO host driver - DEPENDS:=+kmod-mmc @TARGET_kirkwood - KCONFIG:= CONFIG_MMC_MVSDIO - FILES:= \ - $(LINUX_DIR)/drivers/mmc/host/mvsdio.ko - AUTOLOAD:=$(call AutoProbe,mvsdio,1) -endef - -define KernelPackage/mvsdio/description - Kernel support for the Marvell SDIO host driver. -endef - -$(eval $(call KernelPackage,mvsdio)) - - define KernelPackage/sdhci SUBMENU:=$(OTHER_MENU) TITLE:=Secure Digital Host Controller Interface support @@ -478,6 +442,7 @@ define KernelPackage/ssb CONFIG_SSB_DRIVER_MIPS=n \ CONFIG_SSB_DRIVER_PCICORE=y \ CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y \ + CONFIG_SSB_FALLBACK_SPROM=y \ CONFIG_SSB_PCIHOST=y \ CONFIG_SSB_PCIHOST_POSSIBLE=y \ CONFIG_SSB_POSSIBLE=y \ @@ -502,6 +467,7 @@ define KernelPackage/bcma CONFIG_BCMA \ CONFIG_BCMA_POSSIBLE=y \ CONFIG_BCMA_BLOCKIO=y \ + CONFIG_BCMA_FALLBACK_SPROM=y \ CONFIG_BCMA_HOST_PCI_POSSIBLE=y \ CONFIG_BCMA_HOST_PCI=y \ CONFIG_BCMA_HOST_SOC=n \ @@ -665,22 +631,22 @@ endef $(eval $(call KernelPackage,rtc-pcf2127)) -define KernelPackage/rtc-pt7c4338 +define KernelPackage/rtc-r7301 SUBMENU:=$(OTHER_MENU) - TITLE:=Pericom PT7C4338 RTC support + TITLE:=Epson RTC7301 support DEFAULT:=m if ALL_KMODS && RTC_SUPPORT - DEPENDS:=+kmod-i2c-core - KCONFIG:=CONFIG_RTC_DRV_PT7C4338 \ + DEPENDS:=+kmod-regmap-mmio + KCONFIG:=CONFIG_RTC_DRV_R7301 \ CONFIG_RTC_CLASS=y - FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pt7c4338.ko - AUTOLOAD:=$(call AutoProbe,rtc-pt7c4338) + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-r7301.ko + AUTOLOAD:=$(call AutoProbe,rtc-r7301) endef -define KernelPackage/rtc-pt7c4338/description - Kernel module for Pericom PT7C4338 i2c RTC chip +define KernelPackage/rtc-r7301/description + Kernel module for Epson RTC7301 RTC chip endef -$(eval $(call KernelPackage,rtc-pt7c4338)) +$(eval $(call KernelPackage,rtc-r7301)) define KernelPackage/rtc-rs5c372a SUBMENU:=$(OTHER_MENU) @@ -733,6 +699,22 @@ endef $(eval $(call KernelPackage,rtc-s35390a)) +define KernelPackage/rtc-x1205 + SUBMENU:=$(OTHER_MENU) + TITLE:=Xicor Intersil X1205 + DEFAULT:=m if ALL_KMODS && RTC_SUPPORT + DEPENDS:=+kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_X1205 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-x1205.ko + AUTOLOAD:=$(call AutoProbe,rtc-x1205) +endef + +define KernelPackage/rtc-x1205/description + Kernel module for Xicor Intersil X1205 I2C RTC chip +endef + +$(eval $(call KernelPackage,rtc-x1205)) define KernelPackage/mtdtests SUBMENU:=$(OTHER_MENU) @@ -786,6 +768,42 @@ endef $(eval $(call KernelPackage,mtdram)) +define KernelPackage/ramoops + SUBMENU:=$(OTHER_MENU) + TITLE:=Ramoops (pstore-ram) + DEFAULT:=m if ALL_KMODS + KCONFIG:=CONFIG_PSTORE_RAM \ + CONFIG_PSTORE_CONSOLE=y + DEPENDS:=+kmod-pstore +kmod-reed-solomon + FILES:= $(LINUX_DIR)/fs/pstore/ramoops.ko + AUTOLOAD:=$(call AutoLoad,30,ramoops,1) +endef + +define KernelPackage/ramoops/description + Kernel module for pstore-ram (ramoops) crash log storage +endef + +$(eval $(call KernelPackage,ramoops)) + + +define KernelPackage/reed-solomon + SUBMENU:=$(OTHER_MENU) + TITLE:=Reed-Solomon error correction + DEFAULT:=m if ALL_KMODS + KCONFIG:=CONFIG_REED_SOLOMON \ + CONFIG_REED_SOLOMON_DEC8=y \ + CONFIG_REED_SOLOMON_ENC8=y + FILES:= $(LINUX_DIR)/lib/reed_solomon/reed_solomon.ko + AUTOLOAD:=$(call AutoLoad,30,reed_solomon,1) +endef + +define KernelPackage/reed-solomon/description + Kernel module for Reed-Solomon error correction +endef + +$(eval $(call KernelPackage,reed-solomon)) + + define KernelPackage/serial-8250 SUBMENU:=$(OTHER_MENU) TITLE:=8250 UARTs @@ -819,7 +837,7 @@ define KernelPackage/serial-8250-exar KCONFIG:= CONFIG_SERIAL_8250_EXAR FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/8250_exar.ko AUTOLOAD:=$(call AutoProbe,8250 8250_base 8250_exar) - DEPENDS:=+kmod-serial-8250 + DEPENDS:=@PCI_SUPPORT +kmod-serial-8250 endef define KernelPackage/serial-8250-exar/description @@ -914,7 +932,6 @@ $(eval $(call KernelPackage,ikconfig)) define KernelPackage/zram SUBMENU:=$(OTHER_MENU) TITLE:=ZRAM - DEPENDS:=+kmod-lib-lzo KCONFIG:= \ CONFIG_ZSMALLOC \ CONFIG_ZRAM \ @@ -931,8 +948,37 @@ define KernelPackage/zram/description Compressed RAM block device support endef -$(eval $(call KernelPackage,zram)) +define KernelPackage/zram/config + if PACKAGE_kmod-zram + choice + prompt "ZRAM Default compressor" + default ZRAM_DEF_COMP_LZORLE + + config ZRAM_DEF_COMP_LZORLE + bool "lzo-rle" + select PACKAGE_kmod-lib-lzo + + config ZRAM_DEF_COMP_LZO + bool "lzo" + select PACKAGE_kmod-lib-lzo + + config ZRAM_DEF_COMP_LZ4 + bool "lz4" + select PACKAGE_kmod-lib-lz4 + + config ZRAM_DEF_COMP_LZ4HC + bool "lz4-hc" + select PACKAGE_kmod-lib-lz4hc + config ZRAM_DEF_COMP_ZSTD + bool "zstd" + select PACKAGE_kmod-lib-zstd + + endchoice + endif +endef + +$(eval $(call KernelPackage,zram)) define KernelPackage/pps SUBMENU:=$(OTHER_MENU) @@ -1008,7 +1054,7 @@ $(eval $(call KernelPackage,ptp)) define KernelPackage/ptp-qoriq SUBMENU:=$(OTHER_MENU) TITLE:=Freescale QorIQ PTP support - DEPENDS:=@TARGET_mpc85xx +kmod-ptp + DEPENDS:=@(TARGET_mpc85xx||TARGET_qoriq) +kmod-ptp KCONFIG:=CONFIG_PTP_1588_CLOCK_QORIQ FILES:=$(LINUX_DIR)/drivers/ptp/ptp-qoriq.ko AUTOLOAD:=$(call AutoProbe,ptp-qoriq) @@ -1064,25 +1110,6 @@ endef $(eval $(call KernelPackage,thermal)) -define KernelPackage/gpio-beeper - SUBMENU:=$(OTHER_MENU) - TITLE:=GPIO beeper support - DEPENDS:=+kmod-input-core - KCONFIG:= \ - CONFIG_INPUT_MISC=y \ - CONFIG_INPUT_GPIO_BEEPER - FILES:= \ - $(LINUX_DIR)/drivers/input/misc/gpio-beeper.ko - AUTOLOAD:=$(call AutoLoad,50,gpio-beeper) -endef - -define KernelPackage/gpio-beeper/description - This enables playing beeps through an GPIO-connected buzzer -endef - -$(eval $(call KernelPackage,gpio-beeper)) - - define KernelPackage/echo SUBMENU:=$(OTHER_MENU) TITLE:=Line Echo Canceller @@ -1125,9 +1152,7 @@ define KernelPackage/keys-trusted TITLE:=TPM trusted keys on kernel keyring DEPENDS:=@KERNEL_KEYS +kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha1 +kmod-tpm KCONFIG:=CONFIG_TRUSTED_KEYS - FILES:= \ - $(LINUX_DIR)/security/keys/trusted.ko@lt5.10 \ - $(LINUX_DIR)/security/keys/trusted-keys/trusted.ko@ge5.10 + FILES:= $(LINUX_DIR)/security/keys/trusted-keys/trusted.ko AUTOLOAD:=$(call AutoLoad,01,trusted-keys,1) endef @@ -1145,7 +1170,8 @@ $(eval $(call KernelPackage,keys-trusted)) define KernelPackage/tpm SUBMENU:=$(OTHER_MENU) TITLE:=TPM Hardware Support - DEPENDS:= +kmod-random-core + DEPENDS:= +kmod-random-core +kmod-asn1-decoder \ + +kmod-asn1-encoder +kmod-oid-registry KCONFIG:= CONFIG_TCG_TPM FILES:= $(LINUX_DIR)/drivers/char/tpm/tpm.ko AUTOLOAD:=$(call AutoLoad,10,tpm,1) @@ -1208,67 +1234,50 @@ endef $(eval $(call KernelPackage,tpm-i2c-infineon)) -define KernelPackage/w83627hf-wdt +define KernelPackage/i6300esb-wdt SUBMENU:=$(OTHER_MENU) - TITLE:=Winbond 83627HF Watchdog Timer - KCONFIG:=CONFIG_W83627HF_WDT - FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/w83627hf_wdt.ko - AUTOLOAD:=$(call AutoLoad,50,w83627hf-wdt,1) + TITLE:=Intel 6300ESB Timer/Watchdog + DEPENDS:=@PCI_SUPPORT @!SMALL_FLASH + KCONFIG:=CONFIG_I6300ESB_WDT \ + CONFIG_WATCHDOG_CORE=y + FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/i6300esb.ko + AUTOLOAD:=$(call AutoLoad,50,i6300esb,1) endef -define KernelPackage/w83627hf-wdt/description - Kernel module for Winbond 83627HF Watchdog Timer +define KernelPackage/i6300esb-wdt/description + Kernel module for the watchdog timer built into the Intel + 6300ESB controller hub. Also used by QEMU/libvirt. endef -$(eval $(call KernelPackage,w83627hf-wdt)) +$(eval $(call KernelPackage,i6300esb-wdt)) -define KernelPackage/itco-wdt +define KernelPackage/mhi-bus SUBMENU:=$(OTHER_MENU) - TITLE:=Intel iTCO Watchdog Timer - KCONFIG:=CONFIG_ITCO_WDT \ - CONFIG_ITCO_VENDOR_SUPPORT=y - FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/iTCO_wdt.ko \ - $(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/iTCO_vendor_support.ko - AUTOLOAD:=$(call AutoLoad,50,iTCO_vendor_support iTCO_wdt,1) + TITLE:=MHI bus + KCONFIG:=CONFIG_MHI_BUS \ + CONFIG_MHI_BUS_DEBUG=y + FILES:=$(LINUX_DIR)/drivers/bus/mhi/host/mhi.ko + AUTOLOAD:=$(call AutoProbe,mhi) endef -define KernelPackage/itco-wdt/description - Kernel module for Intel iTCO Watchdog Timer +define KernelPackage/mhi-bus/description + Kernel module for the Qualcomm MHI bus. endef -$(eval $(call KernelPackage,itco-wdt)) - - -define KernelPackage/it87-wdt - SUBMENU:=$(OTHER_MENU) - TITLE:=ITE IT87 Watchdog Timer - KCONFIG:=CONFIG_IT87_WDT - FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/it87_wdt.ko - AUTOLOAD:=$(call AutoLoad,50,it87-wdt,1) - MODPARAMS.it87-wdt:= \ - nogameport=1 \ - nocir=1 -endef - -define KernelPackage/it87-wdt/description - Kernel module for ITE IT87 Watchdog Timer -endef - -$(eval $(call KernelPackage,it87-wdt)) - +$(eval $(call KernelPackage,mhi-bus)) -define KernelPackage/f71808e-wdt +define KernelPackage/mhi-pci-generic SUBMENU:=$(OTHER_MENU) - TITLE:=Fintek F718xx/F818xx Watchdog Timer - DEPENDS:=@TARGET_x86 - KCONFIG:=CONFIG_F71808E_WDT - FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/f71808e_wdt.ko - AUTOLOAD:=$(call AutoProbe,f71808e-wdt,1) + TITLE:=MHI PCI controller driver + DEPENDS:=@PCI_SUPPORT +kmod-mhi-bus + KCONFIG:=CONFIG_MHI_BUS_PCI_GENERIC + FILES:=$(LINUX_DIR)/drivers/bus/mhi/host/mhi_pci_generic.ko + AUTOLOAD:=$(call AutoProbe,mhi_pci_generic) endef -define KernelPackage/f71808e-wdt/description - Kernel module for the watchdog timer found on many Fintek Super-IO chips. +define KernelPackage/mhi-pci-generic/description + Kernel module for the MHI PCI controller driver. endef -$(eval $(call KernelPackage,f71808e-wdt)) +$(eval $(call KernelPackage,mhi-pci-generic)) diff --git a/package/kernel/linux/modules/sound.mk b/package/kernel/linux/modules/sound.mk index e43be25bc67..623f65ac59a 100644 --- a/package/kernel/linux/modules/sound.mk +++ b/package/kernel/linux/modules/sound.mk @@ -225,17 +225,51 @@ define KernelPackage/sound-soc-imx $(LINUX_DIR)/sound/soc/fsl/snd-soc-fsl-ssi.ko \ $(LINUX_DIR)/sound/soc/fsl/imx-pcm-dma.ko AUTOLOAD:=$(call AutoLoad,56,snd-soc-imx-audmux snd-soc-fsl-ssi snd-soc-imx-pcm) - DEPENDS:=@TARGET_imx6 +kmod-sound-soc-core + DEPENDS:=@TARGET_imx +kmod-sound-soc-core $(call AddDepends/sound) endef define KernelPackage/sound-soc-imx/description - Support for i.MX6 Platform sound (ssi/audmux/pcm) + Support for i.MX Platform sound (ssi/audmux/pcm) endef $(eval $(call KernelPackage,sound-soc-imx)) +define KernelPackage/sound-soc-mt7986 + TITLE:=MediaTek MT7986 Audio support + KCONFIG:=CONFIG_SND_SOC_MT7986 CONFIG_SND_SOC_MT7986_WM8960 + FILES:= \ + $(LINUX_DIR)/sound/soc/mediatek/common/snd-soc-mtk-common.ko \ + $(LINUX_DIR)/sound/soc/mediatek/mt7986/snd-soc-mt7986-afe.ko + AUTOLOAD:=$(call AutoLoad,56,snd-soc-mtk-common snd-soc-mt7986-afe) + DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-core + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-mt7986/description + Support for audio on systems using the MediaTek MT7986 SoC. +endef + +$(eval $(call KernelPackage,sound-soc-mt7986)) + + +define KernelPackage/sound-soc-mt7986-wm8960 + TITLE:=MediaTek MT7986 Audio support + KCONFIG:=CONFIG_SND_SOC_MT7986_WM8960 + FILES:=$(LINUX_DIR)/sound/soc/mediatek/mt7986/mt7986-wm8960.ko + AUTOLOAD:=$(call AutoLoad,57,mt7986-wm8960) + DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-wm8960 +kmod-sound-soc-mt7986 + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-mt7986-wm8960/description + Support for use of the Wolfson Audio WM8960 codec with the MediaTek MT7986 SoC. +endef + +$(eval $(call KernelPackage,sound-soc-mt7986-wm8960)) + + define KernelPackage/sound-soc-imx-sgtl5000 TITLE:=IMX SoC support for SGTL5000 KCONFIG:=CONFIG_SND_SOC_IMX_SGTL5000 @@ -243,17 +277,29 @@ define KernelPackage/sound-soc-imx-sgtl5000 $(LINUX_DIR)/sound/soc/codecs/snd-soc-sgtl5000.ko \ $(LINUX_DIR)/sound/soc/fsl/snd-soc-imx-sgtl5000.ko AUTOLOAD:=$(call AutoLoad,57,snd-soc-sgtl5000 snd-soc-imx-sgtl5000) - DEPENDS:=@TARGET_imx6 +kmod-sound-soc-imx + DEPENDS:=@TARGET_imx +kmod-sound-soc-imx +kmod-regmap-i2c $(call AddDepends/sound) endef define KernelPackage/sound-soc-imx-sgtl5000/description - Support for i.MX6 Platform sound SGTL5000 codec + Support for i.MX Platform sound SGTL5000 codec endef $(eval $(call KernelPackage,sound-soc-imx-sgtl5000)) +define KernelPackage/sound-soc-wm8960 + TITLE:=SoC WM8960 codec support + KCONFIG:=CONFIG_SND_SOC_WM8960 + FILES:=$(LINUX_DIR)/sound/soc/codecs/snd-soc-wm8960.ko + DEPENDS:=+kmod-sound-soc-core +kmod-i2c-core +kmod-regmap-i2c + AUTOLOAD:=$(call AutoProbe,snd-soc-wm8960) + $(call AddDepends/sound) +endef + +$(eval $(call KernelPackage,sound-soc-wm8960)) + + define KernelPackage/sound-soc-spdif TITLE:=SoC S/PDIF codec support KCONFIG:=CONFIG_SND_SOC_SPDIF @@ -523,8 +569,7 @@ define KernelPackage/sound-hda-intel CONFIG_SND_HDA_INTEL FILES:= \ $(LINUX_DIR)/sound/pci/hda/snd-hda-intel.ko \ - $(LINUX_DIR)/sound/hda/snd-intel-nhlt.ko@lt5.5 \ - $(LINUX_DIR)/sound/hda/snd-intel-dspcfg.ko@ge5.5 + $(LINUX_DIR)/sound/hda/snd-intel-dspcfg.ko AUTOLOAD:=$(call AutoProbe,snd-hda-intel) $(call AddDepends/sound,kmod-sound-hda-core) endef diff --git a/package/kernel/linux/modules/spi.mk b/package/kernel/linux/modules/spi.mk index 01dc7dc7e60..78a1c8a0328 100644 --- a/package/kernel/linux/modules/spi.mk +++ b/package/kernel/linux/modules/spi.mk @@ -15,9 +15,9 @@ define KernelPackage/mmc-spi CONFIG_SPI=y \ CONFIG_SPI_MASTER=y FILES:=\ - $(if $(CONFIG_OF),$(LINUX_DIR)/drivers/mmc/host/of_mmc_spi.ko) \ + $(LINUX_DIR)/drivers/mmc/host/of_mmc_spi.ko \ $(LINUX_DIR)/drivers/mmc/host/mmc_spi.ko - AUTOLOAD:=$(call AutoProbe,$(if $(CONFIG_OF),of_mmc_spi) mmc_spi) + AUTOLOAD:=$(call AutoProbe,of_mmc_spi mmc_spi) endef define KernelPackage/mmc-spi/description diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk index 3249b854d66..7f9e627fdb4 100644 --- a/package/kernel/linux/modules/usb.mk +++ b/package/kernel/linux/modules/usb.mk @@ -331,17 +331,6 @@ define KernelPackage/usb-bcma endef $(eval $(call KernelPackage,usb-bcma)) -define KernelPackage/usb-fotg210 - TITLE:=Support for FOTG210 USB host controllers - DEPENDS:=@USB_SUPPORT @TARGET_gemini - KCONFIG:=CONFIG_USB_FOTG210_HCD - FILES:= \ - $(if $(CONFIG_USB_FOTG210_HCD),$(LINUX_DIR)/drivers/usb/host/fotg210-hcd.ko) - AUTOLOAD:=$(call AutoLoad,50,fotg210-hcd,1) - $(call AddDepends/usb) -endef -$(eval $(call KernelPackage,usb-fotg210)) - define KernelPackage/usb-ssb TITLE:=Support for SSB USB controllers DEPENDS:=@USB_SUPPORT @TARGET_bcm47xx @@ -431,10 +420,7 @@ define KernelPackage/usb-dwc2 TITLE:=DWC2 USB controller driver DEPENDS:=+USB_GADGET_SUPPORT:kmod-usb-gadget +kmod-usb-roles KCONFIG:= \ - CONFIG_USB_PCI=y \ CONFIG_USB_DWC2 \ - CONFIG_USB_DWC2_PCI \ - CONFIG_USB_DWC2_PLATFORM \ CONFIG_USB_DWC2_DEBUG=n \ CONFIG_USB_DWC2_VERBOSE=n \ CONFIG_USB_DWC2_TRACK_MISSED_SOFS=n \ @@ -453,6 +439,26 @@ endef $(eval $(call KernelPackage,usb-dwc2)) +define KernelPackage/usb-dwc2-pci + TITLE:=DWC2 USB controller driver (PCI) + DEPENDS:=@PCI_SUPPORT +kmod-usb-dwc2 +kmod-usb-phy-nop + KCONFIG:= \ + CONFIG_USB_PCI=y \ + CONFIG_USB_DWC2_PCI + FILES:= \ + $(LINUX_DIR)/drivers/usb/dwc2/dwc2_pci.ko + AUTOLOAD:=$(call AutoLoad,54,dwc2_pci,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-dwc2-pci/description + The Designware USB2.0 PCI interface module for controllers + connected to a PCI bus. +endef + +$(eval $(call KernelPackage,usb-dwc2-pci)) + + define KernelPackage/usb-dwc3 TITLE:=DWC3 USB controller driver KCONFIG:= \ @@ -477,7 +483,7 @@ $(eval $(call KernelPackage,usb-dwc3)) define KernelPackage/usb-dwc3-qcom TITLE:=DWC3 Qualcomm USB driver - DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x) +kmod-usb-dwc3 + DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x||TARGET_qualcommax) +kmod-usb-dwc3 KCONFIG:= CONFIG_USB_DWC3_QCOM FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3-qcom.ko AUTOLOAD:=$(call AutoLoad,53,dwc3-qcom,1) @@ -528,7 +534,6 @@ $(eval $(call KernelPackage,usb-wdm)) define KernelPackage/usb-audio TITLE:=Support for USB audio devices KCONFIG:= \ - CONFIG_USB_AUDIO \ CONFIG_SND_USB=y \ CONFIG_SND_USB_AUDIO $(call AddDepends/usb) @@ -745,8 +750,9 @@ $(eval $(call KernelPackage,usb-serial-mct)) define KernelPackage/usb-serial-mos7720 TITLE:=Support for Moschip MOS7720 devices - KCONFIG:=CONFIG_USB_SERIAL_MOS7720 + KCONFIG:=CONFIG_USB_SERIAL_MOS7720 CONFIG_USB_SERIAL_MOS7715_PARPORT=y FILES:=$(LINUX_DIR)/drivers/usb/serial/mos7720.ko + DEPENDS:=+kmod-ppdev AUTOLOAD:=$(call AutoProbe,mos7720) $(call AddDepends/usb-serial) endef @@ -1138,7 +1144,9 @@ $(eval $(call KernelPackage,usb-net-aqc111)) define KernelPackage/usb-net-asix TITLE:=Kernel module for USB-to-Ethernet Asix convertors - DEPENDS:=+kmod-libphy + DEPENDS:= \ + +kmod-libphy +kmod-net-selftests +kmod-mdio-devres +kmod-phy-ax88796b \ + +LINUX_6_1:kmod-phylink KCONFIG:=CONFIG_USB_NET_AX8817X FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/asix.ko AUTOLOAD:=$(call AutoProbe,asix) @@ -1201,6 +1209,23 @@ endef $(eval $(call KernelPackage,usb-net-kaweth)) +define KernelPackage/usb-net-lan78xx + TITLE:=USB-To-Ethernet Microchip LAN78XX convertors + DEPENDS:=+kmod-fixed-phy +kmod-phy-microchip +PACKAGE_kmod-of-mdio:kmod-of-mdio + KCONFIG:=CONFIG_USB_LAN78XX + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/lan78xx.ko + AUTOLOAD:=$(call AutoProbe,lan78xx) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-lan78xx/description + Kernel module for Microchip LAN78XX based USB 2 & USB 3 + 10/100/1000 Ethernet adapters. +endef + +$(eval $(call KernelPackage,usb-net-lan78xx)) + + define KernelPackage/usb-net-pegasus TITLE:=Kernel module for USB-to-Ethernet Pegasus convertors KCONFIG:=CONFIG_USB_PEGASUS @@ -1231,9 +1256,25 @@ endef $(eval $(call KernelPackage,usb-net-mcs7830)) +define KernelPackage/usb-net-smsc75xx + TITLE:=SMSC LAN75XX based USB 2.0 Gigabit ethernet devices + DEPENDS:=+kmod-libphy + KCONFIG:=CONFIG_USB_NET_SMSC75XX + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/smsc75xx.ko + AUTOLOAD:=$(call AutoProbe,smsc75xx) + $(call AddDepends/usb-net, +kmod-lib-crc16) +endef + +define KernelPackage/usb-net-smsc75xx/description + Kernel module for SMSC LAN75XX based devices +endef + +$(eval $(call KernelPackage,usb-net-smsc75xx)) + + define KernelPackage/usb-net-smsc95xx TITLE:=SMSC LAN95XX based USB 2.0 10/100 ethernet devices - DEPENDS:=+LINUX_5_10:kmod-libphy + DEPENDS:=+kmod-libphy +kmod-phy-smsc +LINUX_6_1:kmod-net-selftests KCONFIG:=CONFIG_USB_NET_SMSC95XX FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/smsc95xx.ko AUTOLOAD:=$(call AutoProbe,smsc95xx) @@ -1340,10 +1381,11 @@ $(eval $(call KernelPackage,usb-net-rtl8150)) define KernelPackage/usb-net-rtl8152 TITLE:=Kernel module for USB-to-Ethernet Realtek convertors + DEPENDS:=+r8152-firmware +kmod-crypto-sha256 +kmod-usb-net-cdc-ncm KCONFIG:=CONFIG_USB_RTL8152 FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/r8152.ko AUTOLOAD:=$(call AutoProbe,r8152) - $(call AddDepends/usb-net, +LINUX_5_10:kmod-crypto-hash) + $(call AddDepends/usb-net) endef define KernelPackage/usb-net-rtl8152/description @@ -1405,7 +1447,7 @@ define KernelPackage/usb-net-cdc-ncm KCONFIG:=CONFIG_USB_NET_CDC_NCM FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_ncm.ko AUTOLOAD:=$(call AutoProbe,cdc_ncm) - $(call AddDepends/usb-net,+!LINUX_5_4:kmod-usb-net-cdc-ether) + $(call AddDepends/usb-net,+kmod-usb-net-cdc-ether) endef define KernelPackage/usb-net-cdc-ncm/description @@ -1507,8 +1549,8 @@ $(eval $(call KernelPackage,usb-hid)) define KernelPackage/usb-hid-cp2112 SUBMENU:=$(USB_MENU) TITLE:=Silicon Labs CP2112 HID USB to SMBus Master Bridge - KCONFIG:=CONFIG_GPIOLIB=y CONFIG_HID_CP2112 - DEPENDS:=+kmod-usb-hid +kmod-i2c-core + KCONFIG:=CONFIG_HID_CP2112 + DEPENDS:=@GPIO_SUPPORT +kmod-usb-hid +kmod-i2c-core FILES:=$(LINUX_DIR)/drivers/hid/hid-cp2112.ko AUTOLOAD:=$(call AutoProbe,hid-cp2112) endef @@ -1521,6 +1563,23 @@ endef $(eval $(call KernelPackage,usb-hid-cp2112)) +define KernelPackage/usb-hid-mcp2221 + SUBMENU:=$(USB_MENU) + TITLE:=Microchip USB 2.0 to I2C/UART Protocol Converter with GPIO + KCONFIG:=CONFIG_HID_MCP2221 + DEPENDS:=@GPIO_SUPPORT +kmod-usb-hid +kmod-i2c-core + FILES:=$(LINUX_DIR)/drivers/hid/hid-mcp2221.ko + AUTOLOAD:=$(call AutoProbe,hid-mcp2221) +endef + +define KernelPackage/usb-hid-mcp2221/description + HID device driver which registers as an i2c adapter and gpiochip to expose + these functions of the MCP2221. +endef + +$(eval $(call KernelPackage,usb-hid-mcp2221)) + + define KernelPackage/usb-yealink TITLE:=USB Yealink VOIP phone DEPENDS:=+kmod-input-evdev @@ -1678,7 +1737,10 @@ define KernelPackage/usb3 +TARGET_bcm53xx:kmod-usb-bcma \ +TARGET_bcm53xx:kmod-phy-bcm-ns-usb3 \ +TARGET_ramips_mt7621:kmod-usb-xhci-mtk \ - +(TARGET_apm821xx_nand&&LINUX_5_10):kmod-usb-xhci-pci-renesas + +TARGET_mediatek:kmod-usb-xhci-mtk \ + +TARGET_apm821xx_nand:kmod-usb-xhci-pci-renesas \ + +TARGET_lantiq_xrx200:kmod-usb-xhci-pci-renesas \ + +TARGET_mvebu_cortexa9:kmod-usb-xhci-pci-renesas KCONFIG:= \ CONFIG_USB_PCI=y \ CONFIG_USB_XHCI_PCI \ @@ -1752,8 +1814,9 @@ define KernelPackage/usb-xhci-mtk DEPENDS:=+kmod-usb-xhci-hcd KCONFIG:=CONFIG_USB_XHCI_MTK HIDDEN:=1 - FILES:=$(LINUX_DIR)/drivers/usb/host/xhci-mtk.ko - AUTOLOAD:=$(call AutoLoad,54,xhci-mtk,1) + FILES:= \ + $(LINUX_DIR)/drivers/usb/host/xhci-mtk-hcd.ko + AUTOLOAD:=$(call AutoLoad,54,xhci-mtk-hcd,1) $(call AddDepends/usb) endef @@ -1766,7 +1829,6 @@ $(eval $(call KernelPackage,usb-xhci-mtk)) define KernelPackage/usb-xhci-pci-renesas TITLE:=Support for additional Renesas xHCI controller with firmware - DEPENDS:=@LINUX_5_10 KCONFIG:=CONFIG_USB_XHCI_PCI_RENESAS HIDDEN:=1 FILES:=$(LINUX_DIR)/drivers/usb/host/xhci-pci-renesas.ko diff --git a/package/kernel/linux/modules/video.mk b/package/kernel/linux/modules/video.mk index 394dff6239b..982bcb1db00 100644 --- a/package/kernel/linux/modules/video.mk +++ b/package/kernel/linux/modules/video.mk @@ -10,11 +10,30 @@ VIDEO_MENU:=Video Support V4L2_DIR=v4l2-core V4L2_USB_DIR=usb +V4L2_MEM2MEM_DIR=platform # # Video Display # +define KernelPackage/acpi-video + SUBMENU:=$(VIDEO_MENU) + TITLE:=ACPI Extensions For Display Adapters + DEPENDS:=@TARGET_x86 +kmod-backlight + HIDDEN:=1 + KCONFIG:=CONFIG_ACPI_VIDEO \ + CONFIG_ACPI_WMI + FILES:=$(LINUX_DIR)/drivers/acpi/video.ko \ + $(LINUX_DIR)/drivers/platform/x86/wmi.ko + AUTOLOAD:=$(call AutoProbe,wmi video) +endef + +define KernelPackage/acpi-video/description + Kernel support for integrated graphics devices. +endef + +$(eval $(call KernelPackage,acpi-video)) + define KernelPackage/backlight SUBMENU:=$(VIDEO_MENU) TITLE:=Backlight support @@ -225,7 +244,8 @@ define KernelPackage/drm SUBMENU:=$(VIDEO_MENU) TITLE:=Direct Rendering Manager (DRM) support HIDDEN:=1 - DEPENDS:=+kmod-dma-buf +kmod-i2c-core +PACKAGE_kmod-backlight:kmod-backlight + DEPENDS:=+kmod-dma-buf +kmod-i2c-core +PACKAGE_kmod-backlight:kmod-backlight \ + +kmod-fb KCONFIG:=CONFIG_DRM FILES:= \ $(LINUX_DIR)/drivers/gpu/drm/drm.ko \ @@ -239,6 +259,36 @@ endef $(eval $(call KernelPackage,drm)) +define KernelPackage/drm-buddy + SUBMENU:=$(VIDEO_MENU) + TITLE:=A page based buddy allocator + DEPENDS:=@DISPLAY_SUPPORT +kmod-drm @LINUX_6_1 + KCONFIG:=CONFIG_DRM_BUDDY + FILES:= $(LINUX_DIR)/drivers/gpu/drm/drm_buddy.ko + AUTOLOAD:=$(call AutoProbe,drm_buddy) +endef + +define KernelPackage/drm-buddy/description + A page based buddy allocator +endef + +$(eval $(call KernelPackage,drm-buddy)) + +define KernelPackage/drm-display-helper + SUBMENU:=$(VIDEO_MENU) + TITLE:=DRM helpers for display adapters drivers + DEPENDS:=@DISPLAY_SUPPORT +kmod-drm-kms-helper @LINUX_6_1 + KCONFIG:=CONFIG_DRM_DISPLAY_HELPER + FILES:=$(LINUX_DIR)/drivers/gpu/drm/display/drm_display_helper.ko + AUTOLOAD:=$(call AutoProbe,drm_display_helper) +endef + +define KernelPackage/drm-display-helper/description + DRM helpers for display adapters drivers. +endef + +$(eval $(call KernelPackage,drm-display-helper)) + define KernelPackage/drm-ttm SUBMENU:=$(VIDEO_MENU) TITLE:=GPU memory management subsystem @@ -255,6 +305,20 @@ endef $(eval $(call KernelPackage,drm-ttm)) + +define KernelPackage/drm-ttm-helper + SUBMENU:=$(VIDEO_MENU) + TITLE:=Helpers for ttm-based gem objects + HIDDEN:=1 + DEPENDS:=@DISPLAY_SUPPORT +kmod-drm-ttm + KCONFIG:=CONFIG_DRM_TTM_HELPER + FILES:=$(LINUX_DIR)/drivers/gpu/drm/drm_ttm_helper.ko + AUTOLOAD:=$(call AutoProbe,drm_ttm_helper) +endef + +$(eval $(call KernelPackage,drm-ttm-helper)) + + define KernelPackage/drm-kms-helper SUBMENU:=$(VIDEO_MENU) TITLE:=CRTC helpers for KMS drivers @@ -277,7 +341,8 @@ define KernelPackage/drm-amdgpu SUBMENU:=$(VIDEO_MENU) TITLE:=AMDGPU DRM support DEPENDS:=@TARGET_x86 @DISPLAY_SUPPORT +kmod-backlight +kmod-drm-ttm \ - +kmod-drm-kms-helper +kmod-i2c-algo-bit +amdgpu-firmware + +kmod-drm-ttm-helper +kmod-drm-kms-helper +kmod-i2c-algo-bit +amdgpu-firmware \ + +kmod-drm-display-helper +kmod-drm-buddy +kmod-acpi-video KCONFIG:=CONFIG_DRM_AMDGPU \ CONFIG_DRM_AMDGPU_SI=y \ CONFIG_DRM_AMDGPU_CIK=y \ @@ -298,7 +363,7 @@ $(eval $(call KernelPackage,drm-amdgpu)) define KernelPackage/drm-imx SUBMENU:=$(VIDEO_MENU) TITLE:=Freescale i.MX DRM support - DEPENDS:=@TARGET_imx6 +kmod-drm-kms-helper + DEPENDS:=@TARGET_imx +kmod-drm-kms-helper KCONFIG:=CONFIG_DRM_IMX \ CONFIG_DRM_FBDEV_EMULATION=y \ CONFIG_DRM_FBDEV_OVERALLOC=100 \ @@ -315,6 +380,7 @@ define KernelPackage/drm-imx CONFIG_DRM_IMX_HDMI=n FILES:= \ $(LINUX_DIR)/drivers/gpu/drm/imx/imxdrm.ko \ + $(LINUX_DIR)/drivers/gpu/drm/drm_dma_helper.ko@ge6.1 \ $(LINUX_DIR)/drivers/gpu/ipu-v3/imx-ipu-v3.ko AUTOLOAD:=$(call AutoLoad,08,imxdrm imx-ipu-v3 imx-ipuv3-crtc) endef @@ -328,7 +394,7 @@ $(eval $(call KernelPackage,drm-imx)) define KernelPackage/drm-imx-hdmi SUBMENU:=$(VIDEO_MENU) TITLE:=Freescale i.MX HDMI DRM support - DEPENDS:=+kmod-sound-core kmod-drm-imx + DEPENDS:=+kmod-sound-core kmod-drm-imx +LINUX_6_1:kmod-drm-display-helper KCONFIG:=CONFIG_DRM_IMX_HDMI \ CONFIG_DRM_DW_HDMI_AHB_AUDIO \ CONFIG_DRM_DW_HDMI_I2S_AUDIO @@ -360,7 +426,8 @@ define KernelPackage/drm-imx-ldb CONFIG_DRM_PANEL_S6E8AA0=n \ CONFIG_DRM_PANEL_SITRONIX_ST7789V=n FILES:=$(LINUX_DIR)/drivers/gpu/drm/imx/imx-ldb.ko \ - $(LINUX_DIR)/drivers/gpu/drm/panel/panel-simple.ko + $(LINUX_DIR)/drivers/gpu/drm/panel/panel-simple.ko \ + $(LINUX_DIR)/drivers/gpu/drm/drm_dp_aux_bus.ko@lt6.1 AUTOLOAD:=$(call AutoLoad,08,imx-ldb) endef @@ -374,7 +441,8 @@ define KernelPackage/drm-radeon SUBMENU:=$(VIDEO_MENU) TITLE:=Radeon DRM support DEPENDS:=@TARGET_x86 @DISPLAY_SUPPORT +kmod-backlight +kmod-drm-kms-helper \ - +kmod-drm-ttm +kmod-i2c-algo-bit +radeon-firmware + +kmod-drm-ttm +kmod-drm-ttm-helper +kmod-i2c-algo-bit +radeon-firmware \ + +kmod-drm-display-helper +kmod-acpi-video KCONFIG:=CONFIG_DRM_RADEON FILES:=$(LINUX_DIR)/drivers/gpu/drm/radeon/radeon.ko AUTOLOAD:=$(call AutoProbe,radeon) @@ -393,21 +461,16 @@ $(eval $(call KernelPackage,drm-radeon)) define KernelPackage/video-core SUBMENU:=$(VIDEO_MENU) TITLE=Video4Linux support - DEPENDS:=@PCI_SUPPORT||USB_SUPPORT +PACKAGE_kmod-i2c-core:kmod-i2c-core + DEPENDS:=+PACKAGE_kmod-i2c-core:kmod-i2c-core KCONFIG:= \ CONFIG_MEDIA_SUPPORT \ CONFIG_MEDIA_CAMERA_SUPPORT=y \ CONFIG_VIDEO_DEV \ - CONFIG_VIDEO_V4L1=y \ - CONFIG_VIDEO_ALLOW_V4L1=y \ - CONFIG_VIDEO_CAPTURE_DRIVERS=y \ - CONFIG_V4L_USB_DRIVERS=y \ - CONFIG_V4L_PCI_DRIVERS=y \ CONFIG_V4L_PLATFORM_DRIVERS=y \ - CONFIG_V4L_ISA_PARPORT_DRIVERS=y + CONFIG_MEDIA_PLATFORM_DRIVERS=y@ge6.1 FILES:= \ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videodev.ko - AUTOLOAD:=$(call AutoLoad,60, videodev v4l2-common) + AUTOLOAD:=$(call AutoLoad,60,videodev) endef define KernelPackage/video-core/description @@ -428,6 +491,10 @@ $(AddDepends/video) CONFIG_MEDIA_CAMERA_SUPPORT=y endef +define AddDepends/framegrabber +$(AddDepends/video) + KCONFIG+=CONFIG_MEDIA_PCI_SUPPORT=y +endef define KernelPackage/video-videobuf2 TITLE:=videobuf2 lib @@ -435,6 +502,7 @@ define KernelPackage/video-videobuf2 KCONFIG:= \ CONFIG_VIDEOBUF2_CORE \ CONFIG_VIDEOBUF2_MEMOPS \ + CONFIG_VIDEOBUF2_V4L2 \ CONFIG_VIDEOBUF2_VMALLOC FILES:= \ $(LINUX_DIR)/drivers/media/common/videobuf2/videobuf2-common.ko \ @@ -856,6 +924,21 @@ endef $(eval $(call KernelPackage,video-gspca-sq905c)) +define KernelPackage/video-gspca-sq930x + TITLE:=sq930x webcam support + KCONFIG:=CONFIG_USB_GSPCA_SQ930X + FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sq930x.ko + AUTOLOAD:=$(call AutoProbe,gspca_sq930x) + $(call AddDepends/camera-gspca) +endef + +define KernelPackage/video-gspca-sq930x/description + The SQ Technologies SQ930X based USB Camera Driver (sq930x) kernel module +endef + +$(eval $(call KernelPackage,video-gspca-sq930x)) + + define KernelPackage/video-gspca-stk014 TITLE:=stk014 webcam support KCONFIG:=CONFIG_USB_GSPCA_STK014 @@ -1019,3 +1102,101 @@ define KernelPackage/video-gspca-konica/description endef $(eval $(call KernelPackage,video-gspca-konica)) + +# +# Video Processing +# + +define KernelPackage/video-mem2mem + SUBMENU:=$(VIDEO_MENU) + TITLE:=Memory 2 Memory device support + HIDDEN:=1 + DEPENDS:=+kmod-video-videobuf2 + KCONFIG:= \ + CONFIG_V4L_MEM2MEM_DRIVERS=y \ + CONFIG_V4L2_MEM2MEM_DEV + FILES:= $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/v4l2-mem2mem.ko + AUTOLOAD:=$(call AutoLoad,66,v4l2-mem2mem) + $(call AddDepends/video) +endef + +define KernelPackage/video-mem2mem/description + Memory 2 memory device support +endef + +$(eval $(call KernelPackage,video-mem2mem)) + +define KernelPackage/video-dma + SUBMENU:=$(VIDEO_MENU) + TITLE:=Video DMA support + HIDDEN:=1 + DEPENDS:=+kmod-video-videobuf2 + KCONFIG:= \ + CONFIG_VIDEOBUF2_DMA_CONTIG \ + CONFIG_VIDEOBUF2_DMA_SG + FILES:= $(LINUX_DIR)/drivers/media/common/videobuf2/videobuf2-dma-*.ko + AUTOLOAD:=$(call AutoLoad,66,videobuf2-dma-contig videobuf2-dma-sg) + $(call AddDepends/video) +endef + +define KernelPackage/video-dma/description + Video DMA support +endef + +$(eval $(call KernelPackage,video-dma)) + +define KernelPackage/video-coda + TITLE:=i.MX VPU support + DEPENDS:=@(TARGET_imx&&!TARGET_imx_cortexa7) +kmod-video-mem2mem +kmod-video-dma + KCONFIG:= \ + CONFIG_VIDEO_CODA \ + CONFIG_VIDEO_IMX_VDOA + FILES:= \ + $(LINUX_DIR)/drivers/media/$(V4L2_MEM2MEM_DIR)/coda/coda-vpu.ko@lt6.1 \ + $(LINUX_DIR)/drivers/media/$(V4L2_MEM2MEM_DIR)/chips-media/coda-vpu.ko@ge6.1 \ + $(LINUX_DIR)/drivers/media/$(V4L2_MEM2MEM_DIR)/coda/imx-vdoa.ko@lt6.1 \ + $(LINUX_DIR)/drivers/media/$(V4L2_MEM2MEM_DIR)/chips-media/imx-vdoa.ko@ge6.1 \ + $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/v4l2-jpeg.ko + AUTOLOAD:=$(call AutoProbe,coda-vpu imx-vdoa v4l2-jpeg) + $(call AddDepends/video) +endef + +define KernelPackage/video-coda/description + The i.MX Video Processing Unit (VPU) kernel module +endef + +$(eval $(call KernelPackage,video-coda)) + +define KernelPackage/video-pxp + TITLE:=i.MX PXP support + DEPENDS:=@TARGET_imx +kmod-video-mem2mem +kmod-video-dma + KCONFIG:= CONFIG_VIDEO_IMX_PXP + FILES:= $(LINUX_DIR)/drivers/media/$(V4L2_MEM2MEM_DIR)/imx-pxp.ko@lt6.1 \ + $(LINUX_DIR)/drivers/media/platform/nxp/imx-pxp.ko@ge6.1 + AUTOLOAD:=$(call AutoProbe,imx-pxp) + $(call AddDepends/video) +endef + +define KernelPackage/video-pxp/description + The i.MX Pixel Pipeline (PXP) kernel module + This enables hardware accelerated support for image + Colour Conversion, Scaling and Rotation +endef + +$(eval $(call KernelPackage,video-pxp)) + +define KernelPackage/video-tw686x + TITLE:=TW686x support + DEPENDS:=@PCIE_SUPPORT +kmod-video-dma +kmod-sound-core + KCONFIG:= CONFIG_VIDEO_TW686X + FILES:= $(LINUX_DIR)/drivers/media/pci/tw686x/tw686x.ko + AUTOLOAD:=$(call AutoProbe,tw686x) + MODPARAMS.tw686x:=dma_mode=contig + $(call AddDepends/framegrabber) +endef + +define KernelPackage/video-tw686x/description + The Intersil/Techwell TW686x kernel module +endef + +$(eval $(call KernelPackage,video-tw686x)) diff --git a/package/kernel/linux/modules/virt.mk b/package/kernel/linux/modules/virt.mk index a9a0b538ff2..f45cb176147 100644 --- a/package/kernel/linux/modules/virt.mk +++ b/package/kernel/linux/modules/virt.mk @@ -20,8 +20,9 @@ define KernelPackage/kvm-x86 TITLE:=Kernel-based Virtual Machine (KVM) support DEPENDS:=@TARGET_x86_generic||TARGET_x86_64 +kmod-irqbypass KCONFIG:=\ - CONFIG_VIRTUALIZATION=y \ - CONFIG_KVM + CONFIG_KVM \ + CONFIG_KVM_MMU_AUDIT=n \ + CONFIG_VIRTUALIZATION=y FILES:= $(LINUX_DIR)/arch/$(LINUX_KARCH)/kvm/kvm.ko AUTOLOAD:=$(call AutoProbe,kvm.ko) endef @@ -71,3 +72,70 @@ define KernelPackage/kvm-amd/description endef $(eval $(call KernelPackage,kvm-amd)) + + +define KernelPackage/vfio + SUBMENU:=Virtualization + TITLE:=VFIO Non-Privileged userspace driver framework + DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 + KCONFIG:= \ + CONFIG_VFIO \ + CONFIG_VFIO_NOIOMMU=n \ + CONFIG_VFIO_MDEV=n + FILES:= \ + $(LINUX_DIR)/drivers/vfio/vfio.ko \ + $(LINUX_DIR)/drivers/vfio/vfio_virqfd.ko \ + $(LINUX_DIR)/drivers/vfio/vfio_iommu_type1.ko + AUTOLOAD:=$(call AutoProbe,vfio vfio_iommu_type1 vfio_virqfd) +endef + +define KernelPackage/vfio/description + VFIO provides a framework for secure userspace device drivers. +endef + +$(eval $(call KernelPackage,vfio)) + + +define KernelPackage/vfio-pci + SUBMENU:=Virtualization + TITLE:=Generic VFIO support for any PCI device + DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 @PCI_SUPPORT +kmod-vfio +kmod-irqbypass + KCONFIG:= \ + CONFIG_VFIO_PCI \ + CONFIG_VFIO_PCI_IGD=n + FILES:= \ + $(LINUX_DIR)/drivers/vfio/pci/vfio-pci-core.ko \ + $(LINUX_DIR)/drivers/vfio/pci/vfio-pci.ko + AUTOLOAD:=$(call AutoProbe,vfio-pci) +endef + +define KernelPackage/vfio-pci/description + Support for the generic PCI VFIO bus driver which can connect any PCI + device to the VFIO framework. +endef + +$(eval $(call KernelPackage,vfio-pci)) + + +define KernelPackage/vhost + SUBMENU:=Virtualization + TITLE:=Host kernel accelerator for virtio (base) + KCONFIG:=CONFIG_VHOST + FILES:=$(LINUX_DIR)/drivers/vhost/vhost.ko \ + $(LINUX_DIR)/drivers/vhost/vhost_iotlb.ko + AUTOLOAD:=$(call AutoProbe,vhost vhost_iotlb) +endef + +$(eval $(call KernelPackage,vhost)) + + +define KernelPackage/vhost-net + SUBMENU:=Virtualization + TITLE:=Host kernel accelerator for virtio-net + DEPENDS:=+kmod-tun +kmod-vhost + KCONFIG:=CONFIG_VHOST_NET + FILES:=$(LINUX_DIR)/drivers/vhost/vhost_net.ko + AUTOLOAD:=$(call AutoProbe,vhost_net) +endef + +$(eval $(call KernelPackage,vhost-net)) diff --git a/package/kernel/linux/modules/w1.mk b/package/kernel/linux/modules/w1.mk index 6ac7458e429..9cba28da11d 100644 --- a/package/kernel/linux/modules/w1.mk +++ b/package/kernel/linux/modules/w1.mk @@ -83,7 +83,7 @@ $(eval $(call KernelPackage,w1-master-ds2490)) define KernelPackage/w1-master-mxc TITLE:=Freescale MXC 1-wire busmaster - DEPENDS:=@TARGET_imx6 + DEPENDS:=@TARGET_imx KCONFIG:=CONFIG_W1_MASTER_MXC FILES:=$(W1_MASTERS_DIR)/mxc_w1.ko AUTOLOAD:=$(call AutoProbe,mxc_w1) @@ -160,23 +160,6 @@ endef $(eval $(call KernelPackage,w1-slave-ds2433)) -define KernelPackage/w1-slave-ds2760 - TITLE:=Dallas 2760 battery monitor chip (HP iPAQ & others) - KCONFIG:= \ - CONFIG_W1_SLAVE_DS2760 \ - CONFIG_W1_SLAVE_DS2433_CRC=n - FILES:=$(W1_SLAVES_DIR)/w1_ds2760.ko - AUTOLOAD:=$(call AutoProbe,w1_ds2760) - $(call AddDepends/w1) -endef - -define KernelPackage/w1-slave-ds2760/description - Kernel module for 1-wire DS2760 battery monitor chip support -endef - -$(eval $(call KernelPackage,w1-slave-ds2760)) - - define KernelPackage/w1-slave-ds2413 TITLE:=DS2413 2 Ch. Addressable Switch KCONFIG:= \ diff --git a/package/kernel/linux/modules/wireless.mk b/package/kernel/linux/modules/wireless.mk deleted file mode 100644 index f7a40ba10a1..00000000000 --- a/package/kernel/linux/modules/wireless.mk +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (C) 2006-2008 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -WIRELESS_MENU:=Wireless Drivers - -define KernelPackage/net-prism54 - SUBMENU:=$(WIRELESS_MENU) - TITLE:=Intersil Prism54 support - DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT +prism54-firmware - KCONFIG:=CONFIG_PRISM54 - FILES:= \ - $(LINUX_DIR)/drivers/net/wireless/intersil/prism54/prism54.ko - AUTOLOAD:=$(call AutoProbe,prism54) -endef - -define KernelPackage/net-prism54/description - Kernel modules for Intersil Prism54 support -endef - -$(eval $(call KernelPackage,net-prism54)) - - -define KernelPackage/net-rtl8192su - SUBMENU:=$(WIRELESS_MENU) - TITLE:=RTL8192SU support (staging) - DEPENDS:=@USB_SUPPORT +@DRIVER_WEXT_SUPPORT +kmod-usb-core +rtl8192su-firmware - KCONFIG:=\ - CONFIG_STAGING=y \ - CONFIG_R8712U - FILES:=$(LINUX_DIR)/drivers/staging/rtl8712/r8712u.ko - AUTOLOAD:=$(call AutoProbe,r8712u) -endef - -define KernelPackage/net-rtl8192su/description - Kernel modules for RealTek RTL8712 and RTL81XXSU fullmac support. -endef - -$(eval $(call KernelPackage,net-rtl8192su)) diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index dd39c2d0693..6ca5c89cfae 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -10,10 +10,11 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 -PKG_VERSION:=5.10.42-1 -PKG_RELEASE:=1 -PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.10.42/ -PKG_HASH:=6876520105240844fdb32d1dcdf2bfdea291a37a96f16c892fda3776ba714fcb +PKG_VERSION:=6.5 +PKG_RELEASE:=2 +# PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/ +PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/ +PKG_HASH:=908c22dceba185eab83caa5a1e58ce6b3ebdc58f099c3fd3e11c7352ebfab2d7 PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION) @@ -22,16 +23,10 @@ PKG_BUILD_PARALLEL:=1 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> 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 + wlcore wl12xx wl18xx PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_kmod-mac80211 \ @@ -57,7 +52,6 @@ config_package=$(if $(CONFIG_PACKAGE_kmod-$(1)),m) config-y:= \ WLAN \ - CFG80211_WEXT \ CFG80211_CERTIFICATION_ONUS \ MAC80211_RC_MINSTREL \ MAC80211_RC_MINSTREL_HT \ @@ -98,7 +92,7 @@ PKG_CONFIG_DEPENDS += \ define KernelPackage/cfg80211 $(call KernelPackage/mac80211/Default) TITLE:=cfg80211 - wireless configuration API - DEPENDS+= +iw +iwinfo +wireless-regdb + DEPENDS+= +iw +iwinfo +wifi-scripts +wireless-regdb +USE_RFKILL:kmod-rfkill ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) FILES:= \ $(PKG_BUILD_DIR)/compat/compat.ko \ @@ -166,107 +160,11 @@ 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 - FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mac80211_hwsim.ko + DEPENDS+= +kmod-mac80211 +@DRIVER_11AX_SUPPORT +@DRIVER_11AC_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/virtual/mac80211_hwsim.ko AUTOLOAD:=$(call AutoProbe,mac80211_hwsim) endef @@ -274,47 +172,15 @@ endef define KernelPackage/mt7601u $(call KernelPackage/mac80211/Default) TITLE:=MT7601U-based USB dongles Wireless Driver - DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT @USB_SUPPORT +kmod-usb-core +mt7601u-firmware + DEPENDS+= +kmod-mac80211 @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 - 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 + DEPENDS+= +kmod-mac80211 +rs9113-firmware FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rsi/rsi_91x.ko endef @@ -338,7 +204,7 @@ endef define KernelPackage/wlcore $(call KernelPackage/mac80211/Default) TITLE:=TI common driver part - DEPENDS+= +kmod-mmc +kmod-mac80211 +@DRIVER_11N_SUPPORT + DEPENDS+= +kmod-mmc +kmod-mac80211 FILES:= \ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko @@ -376,23 +242,6 @@ define KernelPackage/wl18xx/description 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 - 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 \ @@ -404,39 +253,29 @@ ifdef CONFIG_PACKAGE_MAC80211_TRACING 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)" \ +C_DEFINES= + +ifeq ($(BUILD_VARIANT),smallbuffers) + C_DEFINES+= -DCONFIG_ATH10K_SMALLBUFFERS +endif + +MAKE_OPTS:= \ + $(subst -C $(LINUX_DIR),-C "$(PKG_BUILD_DIR)",$(KERNEL_MAKEOPTS)) \ + EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/include $(IREMAP_CFLAGS) $(C_DEFINES)" \ KLIB_BUILD="$(LINUX_DIR)" \ MODPROBE=true \ KLIB=$(TARGET_MODULES_DIR) \ @@ -458,9 +297,6 @@ define Build/Prepare 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 \ @@ -471,14 +307,14 @@ define Build/Prepare $(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/linux/mhi.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),) +ifneq ($(CONFIG_PACKAGE_kmod-cfg80211),) define Build/Compile/kmod rm -rf $(PKG_BUILD_DIR)/modules +$(MAKE) $(PKG_JOBS) $(MAKE_OPTS) modules @@ -506,6 +342,7 @@ define Build/Patch $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath10k,ath10k/) $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath11k,ath11k/) $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mt7601u,mt7601u/) $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/) $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/) $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rtl,rtl/) @@ -521,6 +358,7 @@ define Quilt/Refresh/Package $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath10k,ath10k/) $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath11k,ath11k/) $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mt7601u,mt7601u/) $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/) $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/) $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rtl,rtl/) @@ -546,19 +384,6 @@ define Build/InstallDev 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_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/package/kernel/mac80211/ath.mk b/package/kernel/mac80211/ath.mk index ba03ae11a6b..881c89db253 100644 --- a/package/kernel/mac80211/ath.mk +++ b/package/kernel/mac80211/ath.mk @@ -1,6 +1,6 @@ PKG_DRIVERS += \ - ath ath5k ath6kl ath6kl-sdio ath6kl-usb ath9k ath9k-common ath9k-htc ath10k \ - carl9170 owl-loader ar5523 wil6210 + ath ath5k ath6kl ath6kl-sdio ath6kl-usb ath9k ath9k-common ath9k-htc ath10k ath10k-smallbuffers \ + ath11k ath11k-ahb ath11k-pci carl9170 owl-loader ar5523 wil6210 PKG_CONFIG_DEPENDS += \ CONFIG_PACKAGE_ATH_DEBUG \ @@ -12,6 +12,7 @@ PKG_CONFIG_DEPENDS += \ CONFIG_ATH9K_TX99 \ CONFIG_ATH10K_LEDS \ CONFIG_ATH10K_THERMAL \ + CONFIG_ATH11K_THERMAL \ CONFIG_ATH_USER_REGD ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS @@ -19,6 +20,7 @@ ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS ATH9K_DEBUGFS \ ATH9K_HTC_DEBUGFS \ ATH10K_DEBUGFS \ + ATH11K_DEBUGFS \ CARL9170_DEBUGFS \ ATH5K_DEBUG \ ATH6KL_DEBUG \ @@ -28,6 +30,7 @@ endif ifdef CONFIG_PACKAGE_MAC80211_TRACING config-y += \ ATH10K_TRACING \ + ATH11K_TRACING \ ATH6KL_TRACING \ ATH_TRACEPOINTS \ ATH5K_TRACER \ @@ -35,9 +38,9 @@ ifdef CONFIG_PACKAGE_MAC80211_TRACING endif config-$(call config_package,ath) += ATH_CARDS ATH_COMMON -config-$(CONFIG_PACKAGE_ATH_DEBUG) += ATH_DEBUG ATH10K_DEBUG ATH9K_STATION_STATISTICS +config-$(CONFIG_PACKAGE_ATH_DEBUG) += ATH_DEBUG ATH10K_DEBUG ATH11K_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_SPECTRAL) += ATH9K_COMMON_SPECTRAL ATH10K_SPECTRAL ATH11K_SPECTRAL config-$(CONFIG_PACKAGE_ATH_DYNACK) += ATH9K_DYNACK config-$(call config_package,ath9k) += ATH9K config-$(call config_package,ath9k-common) += ATH9K_COMMON @@ -52,9 +55,14 @@ 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-$(CONFIG_ATH11K_THERMAL) += ATH11K_THERMAL config-$(call config_package,ath9k-htc) += ATH9K_HTC config-$(call config_package,ath10k) += ATH10K ATH10K_PCI +config-$(call config_package,ath10k-smallbuffers) += ATH10K ATH10K_PCI ATH10K_SMALLBUFFERS +config-$(call config_package,ath11k) += ATH11K +config-$(call config_package,ath11k-ahb) += ATH11K_AHB +config-$(call config_package,ath11k-pci) += ATH11K_PCI config-$(call config_package,ath5k) += ATH5K ifdef CONFIG_TARGET_ath25 @@ -90,7 +98,7 @@ define KernelPackage/ath/config bool "Atheros wireless debugging" help Say Y, if you want to debug atheros wireless drivers. - Only ath9k & ath10k make use of this. + Only ath9k & ath10k & ath11k make use of this. config PACKAGE_ATH_DFS bool "Enable DFS support" @@ -153,7 +161,7 @@ define KernelPackage/ath6kl 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 + DEPENDS+= +kmod-ath FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko endef @@ -190,7 +198,7 @@ define KernelPackage/ath9k-common 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 + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ath79 +kmod-ath +kmod-random-core FILES:= \ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko @@ -217,7 +225,7 @@ define KernelPackage/ath9k/config bool "Add wireless noise as source of randomness to kernel entropy pool" depends on PACKAGE_kmod-ath9k select PACKAGE_kmod-random-core - default n + default y config ATH9K_SUPPORT_PCOEM bool "Support chips used in PC OEM cards" @@ -254,12 +262,14 @@ 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 \ + DEPENDS+= @PCI_SUPPORT +kmod-ath +@DRIVER_11AC_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) + AUTOLOAD:=$(call AutoProbe,ath10k_core ath10k_pci) + MODPARAMS.ath10k_core:=frame_mode=2 + VARIANT:=regular endef define KernelPackage/ath10k/description @@ -273,18 +283,76 @@ define KernelPackage/ath10k/config config ATH10K_LEDS bool "Enable LED support" default y - depends on PACKAGE_kmod-ath10k + depends on PACKAGE_kmod-ath10k || PACKAGE_kmod-ath10k-smallbuffers config ATH10K_THERMAL bool "Enable thermal sensors and throttling support" - depends on PACKAGE_kmod-ath10k + depends on PACKAGE_kmod-ath10k || PACKAGE_kmod-ath10k-smallbuffers + +endef + +define KernelPackage/ath10k-smallbuffers + $(call KernelPackage/ath10k) + TITLE+= (small buffers for low-RAM devices) + VARIANT:=smallbuffers +endef + +define KernelPackage/ath11k + $(call KernelPackage/mac80211/Default) + TITLE:=Qualcomm 802.11ax wireless chipset support (common code) + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath11k + DEPENDS+= +kmod-ath +@DRIVER_11AC_SUPPORT +@DRIVER_11AX_SUPPORT \ + +kmod-crypto-michael-mic +ATH11K_THERMAL:kmod-hwmon-core +ATH11K_THERMAL:kmod-thermal + FILES:=$(PKG_BUILD_DIR)/drivers/soc/qcom/qmi_helpers.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath11k/ath11k.ko +endef + +define KernelPackage/ath11k/description +This module adds support for Qualcomm Technologies 802.11ax family of +chipsets. +endef + +define KernelPackage/ath11k/config + + config ATH11K_THERMAL + bool "Enable thermal sensors and throttling support" + depends on PACKAGE_kmod-ath11k + default y if TARGET_qualcommax + +endef + +define KernelPackage/ath11k-ahb + $(call KernelPackage/mac80211/Default) + TITLE:=Qualcomm 802.11ax AHB wireless chipset support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath11k + DEPENDS+= @TARGET_qualcommax +kmod-ath11k +kmod-qrtr-smd + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath11k/ath11k_ahb.ko + AUTOLOAD:=$(call AutoProbe,ath11k_ahb) +endef + +define KernelPackage/ath11k-ahb/description +This module adds support for Qualcomm Technologies 802.11ax family of +chipsets with AHB bus. +endef + +define KernelPackage/ath11k-pci + $(call KernelPackage/mac80211/Default) + TITLE:=Qualcomm 802.11ax PCI wireless chipset support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath11k + DEPENDS+= @PCI_SUPPORT +kmod-qrtr-mhi +kmod-ath11k + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath11k/ath11k_pci.ko + AUTOLOAD:=$(call AutoProbe,ath11k_pci) +endef +define KernelPackage/ath11k-pci/description +This module adds support for Qualcomm Technologies 802.11ax family of +chipsets with PCI bus. 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 +carl9170-firmware + DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core +carl9170-firmware FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko AUTOLOAD:=$(call AutoProbe,carl9170) endef @@ -309,7 +377,7 @@ 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 + 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/package/kernel/mac80211/broadcom.mk b/package/kernel/mac80211/broadcom.mk index 473bbf597c3..d0b08890881 100644 --- a/package/kernel/mac80211/broadcom.mk +++ b/package/kernel/mac80211/broadcom.mk @@ -1,5 +1,5 @@ PKG_DRIVERS += \ - b43 b43legacy brcmsmac brcmfmac brcmutil + b43 brcmsmac brcmfmac brcmutil PKG_CONFIG_DEPENDS += \ CONFIG_PACKAGE_B43_DEBUG \ @@ -24,9 +24,6 @@ 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 @@ -248,11 +245,11 @@ config PACKAGE_B43_USE_BCMA 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 + depends on !TARGET_bcm47xx_legacy && !TARGET_bcm47xx_mips74k && !TARGET_bcm53xx && !TARGET_bmips bool "BCMA and SSB" config PACKAGE_B43_BUSES_BCMA - depends on !TARGET_bcm47xx_legacy + depends on !TARGET_bcm47xx_legacy && !TARGET_bmips_bcm6358 && !TARGET_bmips_bcm6368 bool "BCMA only" config PACKAGE_B43_BUSES_SSB @@ -341,23 +338,6 @@ 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 - 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 @@ -401,7 +381,7 @@ 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 + DEPENDS+=@!TARGET_bcm47xx_legacy +kmod-mac80211 +!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 @@ -433,10 +413,13 @@ 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 \ + DEPENDS+= @USB_SUPPORT +kmod-cfg80211 +@DRIVER_11AC_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 + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko \ + $(foreach type,bca cyw wcc, \ + $(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmfmac/$(type)/brcmfmac-$(type).ko) AUTOLOAD:=$(call AutoProbe,brcmfmac) endef @@ -450,6 +433,8 @@ define KernelPackage/brcmfmac/config config BRCMFMAC_SDIO bool "Enable SDIO bus interface support" default y if TARGET_bcm27xx + default y if TARGET_imx_cortexa7 + default y if TARGET_rockchip default y if TARGET_sunxi default n help diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh deleted file mode 100644 index 0b7a84d7c95..00000000000 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ /dev/null @@ -1,1202 +0,0 @@ -#!/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_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 \ - 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= - - ieee80211n=1 - ht_capab= - case "$htmode" in - VHT20|HT20|HE20) ;; - HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160) - case "$hwmode" in - a) - case "$(( ($channel / 4) % 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= - chan_ofs=0 - [ "$band" = "6g" ] && chan_ofs=1 - - 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 \ - 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 \ - - # 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" <<EOF -${channel:+channel=$channel} -${channel_list:+chanlist=$channel_list} -${hostapd_noscan:+noscan=1} -${tx_burst:+tx_queue_data2_burst=$tx_burst} -$base_cfg - -EOF - json_select .. - radio_md5sum=$(md5sum $hostapd_conf_file | cut -d" " -f1) - echo "radio_config_id=${radio_md5sum}" >> $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 <<EOF -$hostapd_cfg -bssid=$macaddr -${dtim_period:+dtim_period=$dtim_period} -${max_listen_int:+max_listen_interval=$max_listen_int} -EOF -} - -mac80211_get_addr() { - local phy="$1" - local idx="$(($2 + 1))" - - head -n $idx /sys/class/ieee80211/${phy}/addresses | tail -n1 -} - -mac80211_generate_mac() { - local phy="$1" - local id="${macidx:-0}" - - local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)" - local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)" - - [ "$mask" = "00:00:00:00:00:00" ] && { - mask="ff:ff:ff:ff:ff:ff"; - - [ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt $id ] && { - addr="$(mac80211_get_addr "$phy" "$id")" - [ -n "$addr" ] && { - echo "$addr" - return - } - } - } - - local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS" - - local mask1=$1 - local mask6=$6 - - local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS" - - macidx=$(($id + 1)) - [ "$((0x$mask1))" -gt 0 ] && { - b1="0x$1" - [ "$id" -gt 0 ] && \ - b1=$(($b1 ^ ((($id - !($b1 & 2)) << 2)) | 0x2)) - printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6 - return - } - - [ "$((0x$mask6))" -lt 255 ] && { - printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id )) - return - } - - off2=$(( (0x$6 + $id) / 0x100 )) - printf "%s:%s:%s:%s:%02x:%02x" \ - $1 $2 $3 $4 \ - $(( (0x$5 + $off2) % 0x100 )) \ - $(( (0x$6 + $id) % 0x100 )) -} - -find_phy() { - [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0 - [ -n "$path" ] && { - phy="$(iwinfo nl80211 phyname "path=$path")" - [ -n "$phy" ] && return 0 - } - [ -n "$macaddr" ] && { - for phy in $(ls /sys/class/ieee80211 2>/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 ] && wireless_setup_failed INTERFACE_CREATION_FAILED - return $rc -} - -mac80211_prepare_vif() { - 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)" - 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 - 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 - - [ "$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 - 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/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh deleted file mode 100644 index 6aa46b0c747..00000000000 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/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/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug deleted file mode 100644 index b8655526613..00000000000 --- a/package/kernel/mac80211/files/mac80211.hotplug +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -[ "${ACTION}" = "add" ] && { - /sbin/wifi config -} diff --git a/package/kernel/mac80211/intel.mk b/package/kernel/mac80211/intel.mk index 8bab727a41e..f2aceb96cd5 100644 --- a/package/kernel/mac80211/intel.mk +++ b/package/kernel/mac80211/intel.mk @@ -1,21 +1,12 @@ -PKG_DRIVERS += \ - iwl-legacy iwl3945 iwl4965 iwlwifi \ - libipw ipw2100 ipw2200 \ +PKG_DRIVERS += iwlwifi -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 + DEPENDS:= +kmod-mac80211 +kmod-ptp @PCI_SUPPORT +@DRIVER_11AC_SUPPORT +@DRIVER_11AX_SUPPORT TITLE:=Intel AGN Wireless support FILES:= \ $(PKG_BUILD_DIR)/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko \ @@ -84,117 +75,3 @@ define KernelPackage/iwlwifi/config 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/package/kernel/mac80211/marvell.mk b/package/kernel/mac80211/marvell.mk index a0e67091e5f..dbd07a80da5 100644 --- a/package/kernel/mac80211/marvell.mk +++ b/package/kernel/mac80211/marvell.mk @@ -1,54 +1,15 @@ 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 + DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +mwl8k-firmware FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/marvell/mwl8k.ko AUTOLOAD:=$(call AutoProbe,mwl8k) endef @@ -62,7 +23,7 @@ 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 + DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +@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 @@ -77,7 +38,7 @@ 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 + DEPENDS+= +kmod-mmc +kmod-mac80211 +@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 diff --git a/package/kernel/mac80211/patches/ath/100-wifi-ath-add-struct_group-for-struct-ath_cycle_count.patch b/package/kernel/mac80211/patches/ath/100-wifi-ath-add-struct_group-for-struct-ath_cycle_count.patch new file mode 100644 index 00000000000..6c476e90581 --- /dev/null +++ b/package/kernel/mac80211/patches/ath/100-wifi-ath-add-struct_group-for-struct-ath_cycle_count.patch @@ -0,0 +1,117 @@ +From e8053643b6d70e23a634f14e4408f3a6d1d3a6bf Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@qq.com> +Date: Sat, 27 May 2023 09:04:48 +0000 +Subject: [PATCH] wifi: ath: add struct_group for struct ath_cycle_counters + +Add a struct_group to around all members in struct ath_cycle_counters. +It can help the compiler detect the intended bounds of the memcpy() and +memset(). + +This patch fixes the following build warning: + +In function 'fortify_memset_chk', + inlined from 'ath9k_ps_wakeup' at /home/db/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/backports-6.1.24/drivers/net/wireless/ath/ath9k/main.c:140:3: +./include/linux/fortify-string.h:314:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] + 314 | __write_overflow_field(p_size_field, size); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Shiji Yang <yangshiji66@qq.com> +--- + drivers/net/wireless/ath/ath.h | 10 ++++++---- + drivers/net/wireless/ath/ath5k/ani.c | 2 +- + drivers/net/wireless/ath/ath5k/base.c | 4 ++-- + drivers/net/wireless/ath/ath5k/mac80211-ops.c | 2 +- + drivers/net/wireless/ath/ath9k/link.c | 2 +- + drivers/net/wireless/ath/ath9k/main.c | 4 ++-- + drivers/net/wireless/ath/hw.c | 2 +- + 7 files changed, 14 insertions(+), 12 deletions(-) + +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -43,10 +43,12 @@ struct ath_ani { + }; + + struct ath_cycle_counters { +- u32 cycles; +- u32 rx_busy; +- u32 rx_frame; +- u32 tx_frame; ++ struct_group(cnts, ++ u32 cycles; ++ u32 rx_busy; ++ u32 rx_frame; ++ u32 tx_frame; ++ ); + }; + + enum ath_device_state { +--- a/drivers/net/wireless/ath/ath5k/ani.c ++++ b/drivers/net/wireless/ath/ath5k/ani.c +@@ -379,7 +379,7 @@ ath5k_hw_ani_get_listen_time(struct ath5 + spin_lock_bh(&common->cc_lock); + + ath_hw_cycle_counters_update(common); +- memcpy(&as->last_cc, &common->cc_ani, sizeof(as->last_cc)); ++ memcpy(&as->last_cc.cnts, &common->cc_ani.cnts, sizeof(as->last_cc.cnts)); + + /* clears common->cc_ani */ + listen = ath_hw_get_listen_time(common); +--- a/drivers/net/wireless/ath/ath5k/base.c ++++ b/drivers/net/wireless/ath/ath5k/base.c +@@ -2985,8 +2985,8 @@ ath5k_reset(struct ath5k_hw *ah, struct + memset(&ah->survey, 0, sizeof(ah->survey)); + spin_lock_bh(&common->cc_lock); + ath_hw_cycle_counters_update(common); +- memset(&common->cc_survey, 0, sizeof(common->cc_survey)); +- memset(&common->cc_ani, 0, sizeof(common->cc_ani)); ++ memset(&common->cc_survey.cnts, 0, sizeof(common->cc_survey.cnts)); ++ memset(&common->cc_ani.cnts, 0, sizeof(common->cc_ani.cnts)); + spin_unlock_bh(&common->cc_lock); + + /* +--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c ++++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c +@@ -665,7 +665,7 @@ ath5k_get_survey(struct ieee80211_hw *hw + ah->survey.time_rx += cc->rx_frame / div; + ah->survey.time_tx += cc->tx_frame / div; + } +- memset(cc, 0, sizeof(*cc)); ++ memset(&cc->cnts, 0, sizeof(cc->cnts)); + spin_unlock_bh(&common->cc_lock); + + memcpy(survey, &ah->survey, sizeof(*survey)); +--- a/drivers/net/wireless/ath/ath9k/link.c ++++ b/drivers/net/wireless/ath/ath9k/link.c +@@ -536,7 +536,7 @@ int ath_update_survey_stats(struct ath_s + if (cc->cycles > 0) + ret = cc->rx_busy * 100 / cc->cycles; + +- memset(cc, 0, sizeof(*cc)); ++ memset(&cc->cnts, 0, sizeof(cc->cnts)); + + ath_update_survey_nf(sc, pos); + +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -135,8 +135,8 @@ void ath9k_ps_wakeup(struct ath_softc *s + if (power_mode != ATH9K_PM_AWAKE) { + spin_lock(&common->cc_lock); + ath_hw_cycle_counters_update(common); +- memset(&common->cc_survey, 0, sizeof(common->cc_survey)); +- memset(&common->cc_ani, 0, sizeof(common->cc_ani)); ++ memset(&common->cc_survey.cnts, 0, sizeof(common->cc_survey.cnts)); ++ memset(&common->cc_ani.cnts, 0, sizeof(common->cc_ani.cnts)); + spin_unlock(&common->cc_lock); + } + +--- a/drivers/net/wireless/ath/hw.c ++++ b/drivers/net/wireless/ath/hw.c +@@ -183,7 +183,7 @@ int32_t ath_hw_get_listen_time(struct at + listen_time = (cc->cycles - cc->rx_frame - cc->tx_frame) / + (common->clockrate * 1000); + +- memset(cc, 0, sizeof(*cc)); ++ memset(&cc->cnts, 0, sizeof(cc->cnts)); + + return listen_time; + } diff --git a/package/kernel/mac80211/patches/ath/120-owl-loader-compat.patch b/package/kernel/mac80211/patches/ath/120-owl-loader-compat.patch deleted file mode 100644 index d1d6c9e2e3e..00000000000 --- a/package/kernel/mac80211/patches/ath/120-owl-loader-compat.patch +++ /dev/null @@ -1,53 +0,0 @@ -From: Christian Lamparter <chunkeey@gmail.com> -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 <chunkeey@gmail.com> - ---- 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/package/kernel/mac80211/patches/ath/400-ath_move_debug_code.patch b/package/kernel/mac80211/patches/ath/400-ath_move_debug_code.patch index db10c45104d..23b7340e25c 100644 --- a/package/kernel/mac80211/patches/ath/400-ath_move_debug_code.patch +++ b/package/kernel/mac80211/patches/ath/400-ath_move_debug_code.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/Makefile +++ b/drivers/net/wireless/ath/Makefile -@@ -15,10 +15,10 @@ ath-objs := main.o \ +@@ -16,10 +16,10 @@ ath-objs := main.o \ regd.o \ hw.o \ key.o \ @@ -14,7 +14,7 @@ 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, +@@ -321,14 +321,7 @@ void _ath_dbg(struct ath_common *common, #endif /* CPTCFG_ATH_DEBUG */ /** Returns string describing opmode, or NULL if unknown mode. */ diff --git a/package/kernel/mac80211/patches/ath/402-ath_regd_optional.patch b/package/kernel/mac80211/patches/ath/402-ath_regd_optional.patch index 3c9180b1137..601ebdc7583 100644 --- a/package/kernel/mac80211/patches/ath/402-ath_regd_optional.patch +++ b/package/kernel/mac80211/patches/ath/402-ath_regd_optional.patch @@ -37,7 +37,7 @@ 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 +@@ -379,6 +388,9 @@ ath_reg_apply_ir_flags(struct wiphy *wip { struct ieee80211_supported_band *sband; @@ -47,7 +47,7 @@ sband = wiphy->bands[NL80211_BAND_2GHZ]; if (!sband) return; -@@ -407,6 +419,9 @@ static void ath_reg_apply_radar_flags(st +@@ -408,6 +420,9 @@ static void ath_reg_apply_radar_flags(st struct ieee80211_channel *ch; unsigned int i; @@ -57,7 +57,7 @@ if (!wiphy->bands[NL80211_BAND_5GHZ]) return; -@@ -639,6 +654,10 @@ ath_regd_init_wiphy(struct ath_regulator +@@ -640,6 +655,10 @@ ath_regd_init_wiphy(struct ath_regulator const struct ieee80211_regdomain *regd; wiphy->reg_notifier = reg_notifier; @@ -82,7 +82,7 @@ help --- a/local-symbols +++ b/local-symbols -@@ -86,6 +86,7 @@ ADM8211= +@@ -101,6 +101,7 @@ ADM8211= ATH_COMMON= WLAN_VENDOR_ATH= ATH_DEBUG= diff --git a/package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch b/package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch index c6dc184e28c..d0f4b15772f 100644 --- a/package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch +++ b/package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch @@ -1,6 +1,6 @@ --- a/net/wireless/reg.c +++ b/net/wireless/reg.c -@@ -3252,6 +3252,8 @@ void regulatory_hint_country_ie(struct w +@@ -3340,6 +3340,8 @@ void regulatory_hint_country_ie(struct w enum environment_cap env = ENVIRON_ANY; struct regulatory_request *request = NULL, *lr; @@ -9,7 +9,7 @@ /* IE len must be evenly divisible by 2 */ if (country_ie_len & 0x01) return; -@@ -3503,6 +3505,7 @@ static bool is_wiphy_all_set_reg_flag(en +@@ -3591,6 +3593,7 @@ static bool is_wiphy_all_set_reg_flag(en void regulatory_hint_disconnect(void) { diff --git a/package/kernel/mac80211/patches/ath/405-ath_regd_us.patch b/package/kernel/mac80211/patches/ath/405-ath_regd_us.patch index 088833199d0..6723721a47b 100644 --- a/package/kernel/mac80211/patches/ath/405-ath_regd_us.patch +++ b/package/kernel/mac80211/patches/ath/405-ath_regd_us.patch @@ -8,7 +8,7 @@ FRANCE_RES = 0x31, FCC3_FCCA = 0x3A, FCC3_WORLD = 0x3B, -@@ -172,6 +173,7 @@ static struct reg_dmn_pair_mapping regDo +@@ -173,6 +174,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}, @@ -16,7 +16,7 @@ {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 +@@ -486,6 +488,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"}, diff --git a/package/kernel/mac80211/patches/ath/406-ath_relax_default_regd.patch b/package/kernel/mac80211/patches/ath/406-ath_relax_default_regd.patch index 35b0f2b76ef..ee4e461342a 100644 --- a/package/kernel/mac80211/patches/ath/406-ath_relax_default_regd.patch +++ b/package/kernel/mac80211/patches/ath/406-ath_relax_default_regd.patch @@ -39,7 +39,7 @@ 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 +@@ -659,6 +667,9 @@ ath_regd_init_wiphy(struct ath_regulator if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) return 0; diff --git a/package/kernel/mac80211/patches/ath10k/080-ath10k_thermal_config.patch b/package/kernel/mac80211/patches/ath10k/080-ath10k_thermal_config.patch index 9ce44fd2880..f1b5ce1f1b2 100644 --- a/package/kernel/mac80211/patches/ath10k/080-ath10k_thermal_config.patch +++ b/package/kernel/mac80211/patches/ath10k/080-ath10k_thermal_config.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig -@@ -86,6 +86,12 @@ config ATH10K_TRACING +@@ -87,6 +87,12 @@ config ATH10K_TRACING help Select this to ath10k use tracing infrastructure. @@ -37,7 +37,7 @@ void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature); --- a/local-symbols +++ b/local-symbols -@@ -145,6 +145,7 @@ ATH10K_SNOC= +@@ -160,6 +160,7 @@ ATH10K_SNOC= ATH10K_DEBUG= ATH10K_DEBUGFS= ATH10K_SPECTRAL= diff --git a/package/kernel/mac80211/patches/ath10k/921-ath10k_init_devices_synchronously.patch b/package/kernel/mac80211/patches/ath10k/921-ath10k_init_devices_synchronously.patch index e004acc340f..adfeb3eaaea 100644 --- a/package/kernel/mac80211/patches/ath10k/921-ath10k_init_devices_synchronously.patch +++ b/package/kernel/mac80211/patches/ath10k/921-ath10k_init_devices_synchronously.patch @@ -14,7 +14,7 @@ Signed-off-by: Sven Eckelmann <sven@open-mesh.com> --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c -@@ -3189,6 +3189,16 @@ int ath10k_core_register(struct ath10k * +@@ -3507,6 +3507,16 @@ int ath10k_core_register(struct ath10k * queue_work(ar->workqueue, &ar->register_work); diff --git a/package/kernel/mac80211/patches/ath10k/922-ath10k-increase-rx-buffer-size-to-2048.patch b/package/kernel/mac80211/patches/ath10k/922-ath10k-increase-rx-buffer-size-to-2048.patch deleted file mode 100644 index 8f7a60eec81..00000000000 --- a/package/kernel/mac80211/patches/ath10k/922-ath10k-increase-rx-buffer-size-to-2048.patch +++ /dev/null @@ -1,37 +0,0 @@ -From: Linus Lüssing <ll@simonwunderlich.de> -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 <greearb@candelatech.com> -Signed-off-by: Linus Lüssing <ll@simonwunderlich.de> - -Forwarded: https://patchwork.kernel.org/patch/11367055/ - ---- a/drivers/net/wireless/ath/ath10k/htt.h -+++ b/drivers/net/wireless/ath/ath10k/htt.h -@@ -2243,7 +2243,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/package/kernel/mac80211/patches/ath10k/930-ath10k_add_tpt_led_trigger.patch b/package/kernel/mac80211/patches/ath10k/930-ath10k_add_tpt_led_trigger.patch index 74b3292e0c3..1a043f7b15e 100644 --- a/package/kernel/mac80211/patches/ath10k/930-ath10k_add_tpt_led_trigger.patch +++ b/package/kernel/mac80211/patches/ath10k/930-ath10k_add_tpt_led_trigger.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -9708,6 +9708,21 @@ static int ath10k_mac_init_rd(struct ath +@@ -9917,6 +9917,21 @@ static int ath10k_mac_init_rd(struct ath return 0; } @@ -22,7 +22,7 @@ int ath10k_mac_register(struct ath10k *ar) { static const u32 cipher_suites[] = { -@@ -10057,6 +10072,12 @@ int ath10k_mac_register(struct ath10k *a +@@ -10275,6 +10290,12 @@ int ath10k_mac_register(struct ath10k *a ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; diff --git a/package/kernel/mac80211/patches/ath10k/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch b/package/kernel/mac80211/patches/ath10k/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch index fa007e73a1f..2465470a577 100644 --- a/package/kernel/mac80211/patches/ath10k/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch +++ b/package/kernel/mac80211/patches/ath10k/974-ath10k_add-LED-and-GPIO-controlling-support-for-various-chipsets.patch @@ -85,7 +85,7 @@ v13: 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 +@@ -72,6 +72,16 @@ config ATH10K_DEBUGFS If unsure, say Y to make it easier to debug problems. @@ -114,7 +114,7 @@ v13: ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o --- a/local-symbols +++ b/local-symbols -@@ -146,6 +146,7 @@ ATH10K_DEBUG= +@@ -161,6 +161,7 @@ ATH10K_DEBUG= ATH10K_DEBUGFS= ATH10K_SPECTRAL= ATH10K_THERMAL= @@ -124,7 +124,7 @@ v13: WCN36XX= --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c -@@ -25,6 +25,7 @@ +@@ -26,6 +26,7 @@ #include "testmode.h" #include "wmi-ops.h" #include "coredump.h" @@ -132,7 +132,7 @@ v13: unsigned int ath10k_debug_mask; EXPORT_SYMBOL(ath10k_debug_mask); -@@ -61,6 +62,7 @@ static const struct ath10k_hw_params ath +@@ -65,6 +66,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA988X_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca988x hw2.0", @@ -140,7 +140,7 @@ v13: .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, -@@ -130,6 +132,7 @@ static const struct ath10k_hw_params ath +@@ -146,6 +148,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9887_1_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9887 hw1.0", @@ -148,7 +148,7 @@ v13: .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL, -@@ -335,6 +338,7 @@ static const struct ath10k_hw_params ath +@@ -387,6 +390,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA99X0_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca99x0 hw2.0", @@ -156,7 +156,7 @@ v13: .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .otp_exe_param = 0x00000700, -@@ -375,6 +379,7 @@ static const struct ath10k_hw_params ath +@@ -433,6 +437,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9984_1_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9984/qca9994 hw1.0", @@ -164,7 +164,7 @@ v13: .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, -@@ -422,6 +427,7 @@ static const struct ath10k_hw_params ath +@@ -486,6 +491,7 @@ static const struct ath10k_hw_params ath .dev_id = QCA9888_2_0_DEVICE_ID, .bus = ATH10K_BUS_PCI, .name = "qca9888 hw2.0", @@ -172,7 +172,7 @@ v13: .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH, -@@ -2904,6 +2910,10 @@ int ath10k_core_start(struct ath10k *ar, +@@ -3222,6 +3228,10 @@ int ath10k_core_start(struct ath10k *ar, goto err_hif_stop; } @@ -183,7 +183,7 @@ v13: return 0; err_hif_stop: -@@ -3162,9 +3172,18 @@ static void ath10k_core_register_work(st +@@ -3480,9 +3490,18 @@ static void ath10k_core_register_work(st goto err_spectral_destroy; } @@ -202,7 +202,7 @@ v13: err_spectral_destroy: ath10k_spectral_destroy(ar); err_debug_destroy: -@@ -3210,6 +3229,8 @@ void ath10k_core_unregister(struct ath10 +@@ -3528,6 +3547,8 @@ void ath10k_core_unregister(struct ath10 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags)) return; @@ -221,7 +221,7 @@ v13: #include "htt.h" #include "htc.h" -@@ -1237,6 +1238,13 @@ struct ath10k { +@@ -1256,6 +1257,13 @@ struct ath10k { } testmode; struct { @@ -237,7 +237,7 @@ v13: 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 { +@@ -519,6 +519,7 @@ struct ath10k_hw_params { const char *name; u32 patch_load_addr; int uart_pin; @@ -456,7 +456,7 @@ v13: { --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c -@@ -4594,6 +4594,8 @@ static const struct wmi_ops wmi_tlv_ops +@@ -4601,6 +4601,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, @@ -467,7 +467,7 @@ v13: 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 -@@ -7468,6 +7468,49 @@ ath10k_wmi_op_gen_peer_set_param(struct +@@ -7472,6 +7472,49 @@ ath10k_wmi_op_gen_peer_set_param(struct return skb; } @@ -517,7 +517,7 @@ v13: static struct sk_buff * ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id, enum wmi_sta_ps_mode psmode) -@@ -9156,6 +9199,9 @@ static const struct wmi_ops wmi_ops = { +@@ -9138,6 +9181,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, @@ -527,7 +527,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -9226,6 +9272,8 @@ static const struct wmi_ops wmi_10_1_ops +@@ -9208,6 +9254,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, @@ -536,7 +536,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -9298,6 +9346,8 @@ static const struct wmi_ops wmi_10_2_ops +@@ -9280,6 +9328,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, @@ -545,7 +545,7 @@ v13: /* .gen_pdev_enable_adaptive_cca not implemented */ }; -@@ -9369,6 +9419,8 @@ static const struct wmi_ops wmi_10_2_4_o +@@ -9351,6 +9401,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, @@ -554,7 +554,7 @@ v13: /* .gen_bcn_tmpl not implemented */ /* .gen_prb_tmpl not implemented */ /* .gen_p2p_go_bcn_ie not implemented */ -@@ -9450,6 +9502,8 @@ static const struct wmi_ops wmi_10_4_ops +@@ -9432,6 +9484,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, @@ -565,7 +565,7 @@ v13: int ath10k_wmi_attach(struct ath10k *ar) --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h -@@ -3027,6 +3027,41 @@ enum wmi_10_4_feature_mask { +@@ -3030,6 +3030,41 @@ enum wmi_10_4_feature_mask { }; diff --git a/package/kernel/mac80211/patches/ath10k/975-ath10k-use-tpt-trigger-by-default.patch b/package/kernel/mac80211/patches/ath10k/975-ath10k-use-tpt-trigger-by-default.patch index 6da7bfa725f..95bd48f9235 100644 --- a/package/kernel/mac80211/patches/ath10k/975-ath10k-use-tpt-trigger-by-default.patch +++ b/package/kernel/mac80211/patches/ath10k/975-ath10k-use-tpt-trigger-by-default.patch @@ -16,9 +16,9 @@ Signed-off-by: Mathias Kresin <dev@kresin.me> --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h -@@ -1290,6 +1290,10 @@ struct ath10k { - bool coex_support; - int coex_gpio_pin; +@@ -1312,6 +1312,10 @@ struct ath10k { + s32 tx_power_2g_limit; + s32 tx_power_5g_limit; +#ifdef CPTCFG_MAC80211_LEDS + const char *led_default_trigger; @@ -42,7 +42,7 @@ Signed-off-by: Mathias Kresin <dev@kresin.me> if (ret) --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -10074,7 +10074,7 @@ int ath10k_mac_register(struct ath10k *a +@@ -10292,7 +10292,7 @@ int ath10k_mac_register(struct ath10k *a ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER; #ifdef CPTCFG_MAC80211_LEDS diff --git a/package/kernel/mac80211/patches/ath10k/980-ath10k-fix-max-antenna-gain-unit.patch b/package/kernel/mac80211/patches/ath10k/980-ath10k-fix-max-antenna-gain-unit.patch deleted file mode 100644 index e951e011e6b..00000000000 --- a/package/kernel/mac80211/patches/ath10k/980-ath10k-fix-max-antenna-gain-unit.patch +++ /dev/null @@ -1,49 +0,0 @@ -From: Sven Eckelmann <seckelmann@datto.com> -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 <seckelmann@datto.com> - -Forwarded: https://patchwork.kernel.org/patch/10986723/ - ---- a/drivers/net/wireless/ath/ath10k/mac.c -+++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -1038,7 +1038,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); -@@ -1484,7 +1484,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; -@@ -3255,7 +3255,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/package/kernel/mac80211/patches/ath10k/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch b/package/kernel/mac80211/patches/ath10k/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch index a149ce1216c..3626debf198 100644 --- a/package/kernel/mac80211/patches/ath10k/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch +++ b/package/kernel/mac80211/patches/ath10k/981-ath10k-adjust-tx-power-reduction-for-US-regulatory-d.patch @@ -28,7 +28,7 @@ Forwarded: no --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -1006,6 +1006,40 @@ static inline int ath10k_vdev_setup_sync +@@ -1028,6 +1028,40 @@ static inline int ath10k_vdev_setup_sync return ar->last_wmi_vdev_start_status; } @@ -69,7 +69,7 @@ Forwarded: no static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id) { struct cfg80211_chan_def *chandef = NULL; -@@ -1038,7 +1072,8 @@ static int ath10k_monitor_vdev_start(str +@@ -1060,7 +1094,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; @@ -79,7 +79,7 @@ Forwarded: no reinit_completion(&ar->vdev_setup_done); reinit_completion(&ar->vdev_delete_done); -@@ -1484,7 +1519,8 @@ static int ath10k_vdev_start_restart(str +@@ -1506,7 +1541,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; @@ -89,7 +89,7 @@ Forwarded: no if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { arg.ssid = arvif->u.ap.ssid; -@@ -3255,7 +3291,8 @@ static int ath10k_update_channel_list(st +@@ -3437,7 +3473,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; diff --git a/package/kernel/mac80211/patches/ath/984-ath10k-Try-to-get-mac-address-from-dts.patch b/package/kernel/mac80211/patches/ath10k/984-ath10k-Try-to-get-mac-address-from-dts.patch index d0eb43fdea0..cfa0f9108af 100644 --- a/package/kernel/mac80211/patches/ath/984-ath10k-Try-to-get-mac-address-from-dts.patch +++ b/package/kernel/mac80211/patches/ath10k/984-ath10k-Try-to-get-mac-address-from-dts.patch @@ -16,46 +16,22 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> drivers/net/wireless/ath/ath10k/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c -index 5f4e12196..9ed7b9883 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c -@@ -8,6 +8,9 @@ +@@ -8,6 +8,7 @@ #include <linux/module.h> #include <linux/firmware.h> #include <linux/of.h> +#include <linux/of_net.h> -+#include <linux/of_platform.h> -+#include <linux/property.h> #include <linux/property.h> #include <linux/dmi.h> #include <linux/ctype.h> -@@ -2961,8 +2963,14 @@ EXPORT_SYMBOL(ath10k_core_stop); - static int ath10k_core_probe_fw(struct ath10k *ar) - { - struct bmi_target_info target_info; -+ const char *mac; - int ret = 0; +@@ -3398,6 +3399,8 @@ static int ath10k_core_probe_fw(struct a -+#ifdef CONFIG_OF -+ /* register the platform to be found by the of api */ -+ of_platform_device_create(ar->dev->of_node, NULL, NULL); -+#endif -+ - ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL); - if (ret) { - ath10k_err(ar, "could not power on hif bus (%d)\n", ret); -@@ -3062,6 +3068,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar) + device_get_mac_address(ar->dev, ar->mac_addr); - device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr)); - -+ mac = of_get_mac_address(ar->dev->of_node); -+ if (!IS_ERR(mac)) -+ ether_addr_copy(ar->mac_addr, mac); ++ of_get_mac_address(ar->dev->of_node, ar->mac_addr); + ret = ath10k_core_init_firmware_features(ar); if (ret) { ath10k_err(ar, "fatal problem with firmware features: %d\n", --- -2.27.0 - diff --git a/package/kernel/mac80211/patches/ath10k/988-ath10k-always-use-mac80211-loss-detection.patch b/package/kernel/mac80211/patches/ath10k/988-ath10k-always-use-mac80211-loss-detection.patch new file mode 100644 index 00000000000..5a62ea3fc22 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/988-ath10k-always-use-mac80211-loss-detection.patch @@ -0,0 +1,28 @@ +From f7d6edafe4358e3880a26775cfde4cd5c71ba063 Mon Sep 17 00:00:00 2001 +From: David Bauer <mail@david-bauer.net> +Date: Wed, 5 Jul 2023 01:30:29 +0200 +Subject: [PATCH] ath10k: always use mac80211 loss detection + +ath10k does not report excessive loss in case of broken block-ack +sessions. The loss is communicated to the host-os, but ath10k does not +trigger a low-ack events by itself. + +The mac80211 framework for loss detection however detects this +circumstance well in case of ath10k. So use it regardless of ath10k's +own loss detection mechanism. + +Signed-off-by: David Bauer <mail@david-bauer.net> +--- + drivers/net/wireless/ath/ath10k/mac.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -10088,7 +10088,6 @@ int ath10k_mac_register(struct ath10k *a + ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA); + ieee80211_hw_set(ar->hw, QUEUE_CONTROL); + ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG); +- ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK); + + if (!test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) + ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL); diff --git a/package/kernel/mac80211/patches/ath10k/990-ath10k-small-buffers.patch b/package/kernel/mac80211/patches/ath10k/990-ath10k-small-buffers.patch new file mode 100644 index 00000000000..2f560c70a03 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/990-ath10k-small-buffers.patch @@ -0,0 +1,64 @@ +--- a/drivers/net/wireless/ath/ath10k/htt.h ++++ b/drivers/net/wireless/ath/ath10k/htt.h +@@ -235,7 +235,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) +--- a/drivers/net/wireless/ath/ath10k/pci.c ++++ b/drivers/net/wireless/ath/ath10k/pci.c +@@ -131,7 +131,11 @@ static const struct ce_attr pci_host_ce_ + .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 const struct ce_attr pci_host_ce_ + .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 const struct ce_attr pci_host_ce_ + .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 const struct ce_attr pci_host_ce_ + .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/package/kernel/mac80211/patches/ath11k/0001-wifi-ath11k-fix-band-selection-for-ppdu-received-in-.patch b/package/kernel/mac80211/patches/ath11k/0001-wifi-ath11k-fix-band-selection-for-ppdu-received-in-.patch new file mode 100644 index 00000000000..e6f9ac9e4c0 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0001-wifi-ath11k-fix-band-selection-for-ppdu-received-in-.patch @@ -0,0 +1,37 @@ +From 72c8caf904aed2caed5d6e75233294b6159ddb5d Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Wed, 26 Jul 2023 10:16:24 +0530 +Subject: [PATCH 1/5] wifi: ath11k: fix band selection for ppdu received in + channel 177 of 5 GHz + +5 GHz band channel 177 support was added with the commit e5e94d10c856 ("wifi: +ath11k: add channel 177 into 5 GHz channel list"). However, during processing +for the received ppdu in ath11k_dp_rx_h_ppdu(), channel number is checked only +till 173. This leads to driver code checking for channel and then fetching the +band from it which is extra effort since firmware has already given the channel +number in the metadata. + +Fix this issue by checking the channel number till 177 since we support +it now. + +Found via code review. Compile tested only. + +Fixes: e5e94d10c856 ("wifi: ath11k: add channel 177 into 5 GHz channel list") +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230726044624.20507-1-quic_adisi@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -2408,7 +2408,7 @@ static void ath11k_dp_rx_h_ppdu(struct a + rx_status->freq = center_freq; + } else if (channel_num >= 1 && channel_num <= 14) { + rx_status->band = NL80211_BAND_2GHZ; +- } else if (channel_num >= 36 && channel_num <= 173) { ++ } else if (channel_num >= 36 && channel_num <= 177) { + rx_status->band = NL80211_BAND_5GHZ; + } else { + spin_lock_bh(&ar->data_lock); diff --git a/package/kernel/mac80211/patches/ath11k/0002-wifi-ath11k-simplify-ath11k_mac_validate_vht_he_fixe.patch b/package/kernel/mac80211/patches/ath11k/0002-wifi-ath11k-simplify-ath11k_mac_validate_vht_he_fixe.patch new file mode 100644 index 00000000000..ad761e6a909 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0002-wifi-ath11k-simplify-ath11k_mac_validate_vht_he_fixe.patch @@ -0,0 +1,38 @@ +From 6f092c98dcfa1e4cf37d45f9b8e4d4a3cbeb79d4 Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Wed, 26 Jul 2023 12:21:02 +0300 +Subject: [PATCH 2/5] wifi: ath11k: simplify + ath11k_mac_validate_vht_he_fixed_rate_settings() + +In ath11k_mac_validate_vht_he_fixed_rate_settings() ar->ab->peers +list is not altered so list_for_each_entry() should be safe. + +Compile tested only. + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230726092113.78794-1-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/mac.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -8258,7 +8258,7 @@ ath11k_mac_validate_vht_he_fixed_rate_se + const struct cfg80211_bitrate_mask *mask) + { + bool he_fixed_rate = false, vht_fixed_rate = false; +- struct ath11k_peer *peer, *tmp; ++ struct ath11k_peer *peer; + const u16 *vht_mcs_mask, *he_mcs_mask; + struct ieee80211_link_sta *deflink; + u8 vht_nss, he_nss; +@@ -8281,7 +8281,7 @@ ath11k_mac_validate_vht_he_fixed_rate_se + + rcu_read_lock(); + spin_lock_bh(&ar->ab->base_lock); +- list_for_each_entry_safe(peer, tmp, &ar->ab->peers, list) { ++ list_for_each_entry(peer, &ar->ab->peers, list) { + if (peer->sta) { + deflink = &peer->sta->deflink; + diff --git a/package/kernel/mac80211/patches/ath11k/0003-wifi-ath11k-Split-coldboot-calibration-hw_param.patch b/package/kernel/mac80211/patches/ath11k/0003-wifi-ath11k-Split-coldboot-calibration-hw_param.patch new file mode 100644 index 00000000000..f8c7c937eab --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0003-wifi-ath11k-Split-coldboot-calibration-hw_param.patch @@ -0,0 +1,180 @@ +From 011e5a3052a22d3758d17442bf0c04c68bf79bea Mon Sep 17 00:00:00 2001 +From: Seevalamuthu Mariappan <quic_seevalam@quicinc.com> +Date: Wed, 26 Jul 2023 19:40:30 +0530 +Subject: [PATCH 3/5] wifi: ath11k: Split coldboot calibration hw_param + +QCN9074 enables coldboot calibration only in Factory Test Mode (FTM). +Hence, split cold_boot_calib to two hw_params for mission and FTM +mode. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Seevalamuthu Mariappan <quic_seevalam@quicinc.com> +Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230726141032.3061-2-quic_rajkbhag@quicinc.com +--- + drivers/net/wireless/ath/ath11k/ahb.c | 3 +-- + drivers/net/wireless/ath/ath11k/core.c | 36 ++++++++++++++++++++------ + drivers/net/wireless/ath/ath11k/core.h | 1 + + drivers/net/wireless/ath/ath11k/hw.h | 3 ++- + drivers/net/wireless/ath/ath11k/qmi.c | 6 ++--- + 5 files changed, 35 insertions(+), 14 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/ahb.c ++++ b/drivers/net/wireless/ath/ath11k/ahb.c +@@ -422,8 +422,7 @@ static int ath11k_ahb_fwreset_from_cold_ + { + int timeout; + +- if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done || +- ab->hw_params.cold_boot_calib == 0 || ++ if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done || + ab->hw_params.cbcal_restart_fw == 0) + return 0; + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -86,7 +86,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = false, + .idle_ps = false, + .supports_sta_ps = false, +- .cold_boot_calib = true, ++ .coldboot_cal_mm = true, ++ .coldboot_cal_ftm = true, + .cbcal_restart_fw = true, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -167,7 +168,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = false, + .idle_ps = false, + .supports_sta_ps = false, +- .cold_boot_calib = true, ++ .coldboot_cal_mm = true, ++ .coldboot_cal_ftm = true, + .cbcal_restart_fw = true, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -248,7 +250,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = true, + .idle_ps = true, + .supports_sta_ps = true, +- .cold_boot_calib = false, ++ .coldboot_cal_mm = false, ++ .coldboot_cal_ftm = false, + .cbcal_restart_fw = false, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -332,7 +335,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = false, + .idle_ps = false, + .supports_sta_ps = false, +- .cold_boot_calib = false, ++ .coldboot_cal_mm = false, ++ .coldboot_cal_ftm = false, + .cbcal_restart_fw = false, + .fw_mem_mode = 2, + .num_vdevs = 8, +@@ -413,7 +417,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = true, + .idle_ps = true, + .supports_sta_ps = true, +- .cold_boot_calib = false, ++ .coldboot_cal_mm = false, ++ .coldboot_cal_ftm = false, + .cbcal_restart_fw = false, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -495,7 +500,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = true, + .idle_ps = true, + .supports_sta_ps = true, +- .cold_boot_calib = false, ++ .coldboot_cal_mm = false, ++ .coldboot_cal_ftm = false, + .cbcal_restart_fw = false, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -578,7 +584,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = true, + .idle_ps = true, + .supports_sta_ps = true, +- .cold_boot_calib = true, ++ .coldboot_cal_mm = true, ++ .coldboot_cal_ftm = true, + .cbcal_restart_fw = false, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, +@@ -667,7 +674,8 @@ static const struct ath11k_hw_params ath + .supports_suspend = false, + .hal_params = &ath11k_hw_hal_params_ipq8074, + .single_pdev_only = false, +- .cold_boot_calib = true, ++ .coldboot_cal_mm = true, ++ .coldboot_cal_ftm = true, + .cbcal_restart_fw = true, + .fix_l1ss = true, + .supports_dynamic_smps_6ghz = false, +@@ -749,6 +757,18 @@ void ath11k_fw_stats_free(struct ath11k_ + ath11k_fw_stats_bcn_free(&stats->bcn); + } + ++bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab) ++{ ++ if (!ath11k_cold_boot_cal) ++ return false; ++ ++ if (ath11k_ftm_mode) ++ return ab->hw_params.coldboot_cal_ftm; ++ ++ else ++ return ab->hw_params.coldboot_cal_mm; ++} ++ + int ath11k_core_suspend(struct ath11k_base *ab) + { + int ret; +--- a/drivers/net/wireless/ath/ath11k/core.h ++++ b/drivers/net/wireless/ath/ath11k/core.h +@@ -1186,6 +1186,7 @@ void ath11k_core_halt(struct ath11k *ar) + int ath11k_core_resume(struct ath11k_base *ab); + int ath11k_core_suspend(struct ath11k_base *ab); + void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab); ++bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab); + + const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab, + const char *filename); +--- a/drivers/net/wireless/ath/ath11k/hw.h ++++ b/drivers/net/wireless/ath/ath11k/hw.h +@@ -187,7 +187,8 @@ struct ath11k_hw_params { + bool supports_shadow_regs; + bool idle_ps; + bool supports_sta_ps; +- bool cold_boot_calib; ++ bool coldboot_cal_mm; ++ bool coldboot_cal_ftm; + bool cbcal_restart_fw; + int fw_mem_mode; + u32 num_vdevs; +--- a/drivers/net/wireless/ath/ath11k/qmi.c ++++ b/drivers/net/wireless/ath/ath11k/qmi.c +@@ -2079,7 +2079,7 @@ static int ath11k_qmi_assign_target_mem_ + return -EINVAL; + } + +- if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) { ++ if (ath11k_core_coldboot_cal_support(ab)) { + if (hremote_node) { + ab->qmi.target_mem[idx].paddr = + res.start + host_ddr_sz; +@@ -3209,8 +3209,8 @@ static void ath11k_qmi_driver_event_work + break; + } + +- if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0 && +- ab->hw_params.cold_boot_calib) { ++ if (ab->qmi.cal_done == 0 && ++ ath11k_core_coldboot_cal_support(ab)) { + ath11k_qmi_process_coldboot_calibration(ab); + } else { + clear_bit(ATH11K_FLAG_CRASH_FLUSH, diff --git a/package/kernel/mac80211/patches/ath11k/0004-wifi-ath11k-Add-coldboot-calibration-support-for-QCN.patch b/package/kernel/mac80211/patches/ath11k/0004-wifi-ath11k-Add-coldboot-calibration-support-for-QCN.patch new file mode 100644 index 00000000000..9d51c1c3eaa --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0004-wifi-ath11k-Add-coldboot-calibration-support-for-QCN.patch @@ -0,0 +1,176 @@ +From bdfc967bf5fcd762473a01d39edb81f1165ba290 Mon Sep 17 00:00:00 2001 +From: Anilkumar Kolli <quic_akolli@quicinc.com> +Date: Wed, 26 Jul 2023 19:40:31 +0530 +Subject: [PATCH 4/5] wifi: ath11k: Add coldboot calibration support for + QCN9074 + +QCN9074 supports 6 GHz, which has increased number of channels +compared to 5 GHz/2 GHz. So, to support coldboot calibration in +QCN9074 ATH11K_COLD_BOOT_FW_RESET_DELAY extended to 60 seconds. To +avoid code redundancy, fwreset_from_cold_boot moved to QMI and made +common for both ahb and pci. Coldboot calibration is enabled only in +FTM mode for QCN9074. QCN9074 requires firmware restart after coldboot, +hence enable cbcal_restart_fw in hw_params. + +This support can be enabled/disabled using hw params for different +hardware. Currently it is not enabled for QCA6390. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Anilkumar Kolli <quic_akolli@quicinc.com> +Signed-off-by: Seevalamuthu Mariappan <quic_seevalam@quicinc.com> +Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230726141032.3061-3-quic_rajkbhag@quicinc.com +--- + drivers/net/wireless/ath/ath11k/ahb.c | 28 ++------------------------ + drivers/net/wireless/ath/ath11k/core.c | 4 ++-- + drivers/net/wireless/ath/ath11k/pci.c | 2 ++ + drivers/net/wireless/ath/ath11k/qmi.c | 28 ++++++++++++++++++++++++++ + drivers/net/wireless/ath/ath11k/qmi.h | 3 ++- + 5 files changed, 36 insertions(+), 29 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/ahb.c ++++ b/drivers/net/wireless/ath/ath11k/ahb.c +@@ -14,6 +14,7 @@ + #include "ahb.h" + #include "debug.h" + #include "hif.h" ++#include "qmi.h" + #include <linux/remoteproc.h> + #include "pcic.h" + #include <linux/soc/qcom/smem.h> +@@ -418,31 +419,6 @@ static void ath11k_ahb_power_down(struct + rproc_shutdown(ab_ahb->tgt_rproc); + } + +-static int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab) +-{ +- int timeout; +- +- if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done || +- ab->hw_params.cbcal_restart_fw == 0) +- return 0; +- +- ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n"); +- timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, +- (ab->qmi.cal_done == 1), +- ATH11K_COLD_BOOT_FW_RESET_DELAY); +- if (timeout <= 0) { +- ath11k_cold_boot_cal = 0; +- ath11k_warn(ab, "Coldboot Calibration failed timed out\n"); +- } +- +- /* reset the firmware */ +- ath11k_ahb_power_down(ab); +- ath11k_ahb_power_up(ab); +- +- ath11k_dbg(ab, ATH11K_DBG_AHB, "exited from cold boot mode\n"); +- return 0; +-} +- + static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab) + { + struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg; +@@ -1225,7 +1201,7 @@ static int ath11k_ahb_probe(struct platf + goto err_ce_free; + } + +- ath11k_ahb_fwreset_from_cold_boot(ab); ++ ath11k_qmi_fwreset_from_cold_boot(ab); + + return 0; + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -336,8 +336,8 @@ static const struct ath11k_hw_params ath + .idle_ps = false, + .supports_sta_ps = false, + .coldboot_cal_mm = false, +- .coldboot_cal_ftm = false, +- .cbcal_restart_fw = false, ++ .coldboot_cal_ftm = true, ++ .cbcal_restart_fw = true, + .fw_mem_mode = 2, + .num_vdevs = 8, + .num_peers = 128, +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -15,6 +15,7 @@ + #include "mhi.h" + #include "debug.h" + #include "pcic.h" ++#include "qmi.h" + + #define ATH11K_PCI_BAR_NUM 0 + #define ATH11K_PCI_DMA_MASK 32 +@@ -897,6 +898,7 @@ unsupported_wcn6855_soc: + ath11k_err(ab, "failed to init core: %d\n", ret); + goto err_irq_affinity_cleanup; + } ++ ath11k_qmi_fwreset_from_cold_boot(ab); + return 0; + + err_irq_affinity_cleanup: +--- a/drivers/net/wireless/ath/ath11k/qmi.c ++++ b/drivers/net/wireless/ath/ath11k/qmi.c +@@ -9,6 +9,7 @@ + #include "qmi.h" + #include "core.h" + #include "debug.h" ++#include "hif.h" + #include <linux/of.h> + #include <linux/of_address.h> + #include <linux/ioport.h> +@@ -2839,6 +2840,33 @@ int ath11k_qmi_firmware_start(struct ath + return 0; + } + ++int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) ++{ ++ int timeout; ++ ++ if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done || ++ ab->hw_params.cbcal_restart_fw == 0) ++ return 0; ++ ++ ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); ++ ++ timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, ++ (ab->qmi.cal_done == 1), ++ ATH11K_COLD_BOOT_FW_RESET_DELAY); ++ ++ if (timeout <= 0) { ++ ath11k_warn(ab, "Coldboot Calibration timed out\n"); ++ return -ETIMEDOUT; ++ } ++ ++ /* reset the firmware */ ++ ath11k_hif_power_down(ab); ++ ath11k_hif_power_up(ab); ++ ath11k_dbg(ab, ATH11K_DBG_QMI, "exit wait for cold boot done\n"); ++ return 0; ++} ++EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot); ++ + static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) + { + int timeout; +--- a/drivers/net/wireless/ath/ath11k/qmi.h ++++ b/drivers/net/wireless/ath/ath11k/qmi.h +@@ -37,7 +37,7 @@ + + #define QMI_WLANFW_MAX_DATA_SIZE_V01 6144 + #define ATH11K_FIRMWARE_MODE_OFF 4 +-#define ATH11K_COLD_BOOT_FW_RESET_DELAY (40 * HZ) ++#define ATH11K_COLD_BOOT_FW_RESET_DELAY (60 * HZ) + + #define ATH11K_QMI_DEVICE_BAR_SIZE 0x200000 + +@@ -519,5 +519,6 @@ void ath11k_qmi_msg_recv_work(struct wor + void ath11k_qmi_deinit_service(struct ath11k_base *ab); + int ath11k_qmi_init_service(struct ath11k_base *ab); + void ath11k_qmi_free_resource(struct ath11k_base *ab); ++int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab); + + #endif diff --git a/package/kernel/mac80211/patches/ath11k/0005-wifi-ath11k-Remove-cal_done-check-during-probe.patch b/package/kernel/mac80211/patches/ath11k/0005-wifi-ath11k-Remove-cal_done-check-during-probe.patch new file mode 100644 index 00000000000..884fd58d75b --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0005-wifi-ath11k-Remove-cal_done-check-during-probe.patch @@ -0,0 +1,33 @@ +From 13329d0cb7212b058bd8451a99d215a8f97645ea Mon Sep 17 00:00:00 2001 +From: Seevalamuthu Mariappan <quic_seevalam@quicinc.com> +Date: Wed, 26 Jul 2023 19:40:32 +0530 +Subject: [PATCH 5/5] wifi: ath11k: Remove cal_done check during probe + +In some race conditions, calibration done QMI message is received even +before host wait starts for calibration to be done. +Due to this, resetting firmware was not performed after calibration. + +Hence, remove cal_done check in ath11k_qmi_fwreset_from_cold_boot() +as this is called only from probe. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Seevalamuthu Mariappan <quic_seevalam@quicinc.com> +Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230726141032.3061-4-quic_rajkbhag@quicinc.com +--- + drivers/net/wireless/ath/ath11k/qmi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/qmi.c ++++ b/drivers/net/wireless/ath/ath11k/qmi.c +@@ -2844,7 +2844,7 @@ int ath11k_qmi_fwreset_from_cold_boot(st + { + int timeout; + +- if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done || ++ if (!ath11k_core_coldboot_cal_support(ab) || + ab->hw_params.cbcal_restart_fw == 0) + return 0; + diff --git a/package/kernel/mac80211/patches/ath11k/0006-wifi-ath11k-Don-t-drop-tx_status-when-peer-cannot-be.patch b/package/kernel/mac80211/patches/ath11k/0006-wifi-ath11k-Don-t-drop-tx_status-when-peer-cannot-be.patch new file mode 100644 index 00000000000..e404a7849e6 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0006-wifi-ath11k-Don-t-drop-tx_status-when-peer-cannot-be.patch @@ -0,0 +1,53 @@ +From 400ece6c7f346b0a30867bd00b03b5b2563d4357 Mon Sep 17 00:00:00 2001 +From: Sven Eckelmann <sven@narfation.org> +Date: Tue, 22 Aug 2023 16:42:24 +0300 +Subject: [PATCH] wifi: ath11k: Don't drop tx_status when peer cannot be found + +When a station idles for a long time, hostapd will try to send a QoS Null +frame to the station as "poll". NL80211_CMD_PROBE_CLIENT is used for this +purpose. And the skb will be added to ack_status_frame - waiting for a +completion via ieee80211_report_ack_skb(). + +But when the peer was already removed before the tx_complete arrives, the +peer will be missing. And when using dev_kfree_skb_any (instead of going +through mac80211), the entry will stay inside ack_status_frames. This IDR +will therefore run full after 8K request were generated for such clients. +At this point, the access point will then just stall and not allow any new +clients because idr_alloc() for ack_status_frame will fail. + +ieee80211_free_txskb() on the other hand will (when required) call +ieee80211_report_ack_skb() and make sure that (when required) remove the +entry from the ack_status_frame. + +Tested-on: IPQ6018 hw1.0 WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1 + +Fixes: 6257c702264c ("wifi: ath11k: fix tx status reporting in encap offload mode") +Fixes: 94739d45c388 ("ath11k: switch to using ieee80211_tx_status_ext()") +Cc: stable@vger.kernel.org +Signed-off-by: Sven Eckelmann <sven@narfation.org> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230802-ath11k-ack_status_leak-v2-1-c0af729d6229@narfation.org +--- + drivers/net/wireless/ath/ath11k/dp_tx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -369,7 +369,7 @@ ath11k_dp_tx_htt_tx_complete_buf(struct + "dp_tx: failed to find the peer with peer_id %d\n", + ts->peer_id); + spin_unlock_bh(&ab->base_lock); +- dev_kfree_skb_any(msdu); ++ ieee80211_free_txskb(ar->hw, msdu); + return; + } + spin_unlock_bh(&ab->base_lock); +@@ -624,7 +624,7 @@ static void ath11k_dp_tx_complete_msdu(s + "dp_tx: failed to find the peer with peer_id %d\n", + ts->peer_id); + spin_unlock_bh(&ab->base_lock); +- dev_kfree_skb_any(msdu); ++ ieee80211_free_txskb(ar->hw, msdu); + return; + } + arsta = (struct ath11k_sta *)peer->sta->drv_priv; diff --git a/package/kernel/mac80211/patches/ath11k/0007-wifi-ath11k-Cleanup-mac80211-references-on-failure-d.patch b/package/kernel/mac80211/patches/ath11k/0007-wifi-ath11k-Cleanup-mac80211-references-on-failure-d.patch new file mode 100644 index 00000000000..ae9cd05dd62 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0007-wifi-ath11k-Cleanup-mac80211-references-on-failure-d.patch @@ -0,0 +1,51 @@ +From 29d15589f084d71a4ea8c544039c5839db0236e2 Mon Sep 17 00:00:00 2001 +From: Sven Eckelmann <sven@narfation.org> +Date: Tue, 22 Aug 2023 16:42:24 +0300 +Subject: [PATCH] wifi: ath11k: Cleanup mac80211 references on failure during + tx_complete + +When a function is using functions from mac80211 to free an skb then it +should do it consistently and not switch to the generic dev_kfree_skb_any +(or similar functions). Otherwise (like in the error handlers), mac80211 +will will not be aware of the freed skb and thus not clean up related +information in its internal data structures. + +Not doing so lead in the past to filled up structure which then prevented +new clients to connect. + +Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") +Fixes: 6257c702264c ("wifi: ath11k: fix tx status reporting in encap offload mode") +Cc: stable@vger.kernel.org +Signed-off-by: Sven Eckelmann <sven@narfation.org> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230802-ath11k-ack_status_leak-v2-2-c0af729d6229@narfation.org +--- + drivers/net/wireless/ath/ath11k/dp_tx.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -344,7 +344,7 @@ ath11k_dp_tx_htt_tx_complete_buf(struct + dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + + if (!skb_cb->vif) { +- dev_kfree_skb_any(msdu); ++ ieee80211_free_txskb(ar->hw, msdu); + return; + } + +@@ -566,12 +566,12 @@ static void ath11k_dp_tx_complete_msdu(s + dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + + if (unlikely(!rcu_access_pointer(ab->pdevs_active[ar->pdev_idx]))) { +- dev_kfree_skb_any(msdu); ++ ieee80211_free_txskb(ar->hw, msdu); + return; + } + + if (unlikely(!skb_cb->vif)) { +- dev_kfree_skb_any(msdu); ++ ieee80211_free_txskb(ar->hw, msdu); + return; + } + diff --git a/package/kernel/mac80211/patches/ath11k/0008-wifi-ath11k-Consistently-use-ath11k_vif_to_arvif.patch b/package/kernel/mac80211/patches/ath11k/0008-wifi-ath11k-Consistently-use-ath11k_vif_to_arvif.patch new file mode 100644 index 00000000000..218b3ac35fc --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0008-wifi-ath11k-Consistently-use-ath11k_vif_to_arvif.patch @@ -0,0 +1,316 @@ +From 9476cda44c136089f14f8951ae5197d63e91735c Mon Sep 17 00:00:00 2001 +From: Jeff Johnson <quic_jjohnson@quicinc.com> +Date: Mon, 21 Aug 2023 07:13:36 -0700 +Subject: [PATCH] wifi: ath11k: Consistently use ath11k_vif_to_arvif() + +Helper function ath11k_vif_to_arvif() exists to retrieve a struct +ath11k_vif from a struct ieee80211_vif. However, in multiple places +this logic is open-coded with inline typecasting. Since the +typecasting prevents the compiler from type-checking the source and +destination, update the driver to consistently use the helper +function. + +No functional changes, compile tested only. + +Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230821-ath11k_vif_to_arvif-v1-1-fa2c3b60b5cf@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 64 +++++++++++----------- + drivers/net/wireless/ath/ath11k/testmode.c | 2 +- + 2 files changed, 33 insertions(+), 33 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -566,7 +566,7 @@ static void ath11k_get_arvif_iter(void * + struct ieee80211_vif *vif) + { + struct ath11k_vif_iter *arvif_iter = data; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + + if (arvif->vdev_id == arvif_iter->vdev_id) + arvif_iter->arvif = arvif; +@@ -1464,7 +1464,7 @@ static int ath11k_mac_setup_bcn_tmpl_ema + u32 params = 0; + u8 i = 0; + +- tx_arvif = (void *)arvif->vif->mbssid_tx_vif->drv_priv; ++ tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif); + + beacons = ieee80211_beacon_get_template_ema_list(tx_arvif->ar->hw, + tx_arvif->vif, 0); +@@ -1520,8 +1520,8 @@ static int ath11k_mac_setup_bcn_tmpl_mbs + struct sk_buff *bcn; + int ret; + +- if (arvif->vif->mbssid_tx_vif) { +- tx_arvif = (void *)arvif->vif->mbssid_tx_vif->drv_priv; ++ if (vif->mbssid_tx_vif) { ++ tx_arvif = ath11k_vif_to_arvif(vif->mbssid_tx_vif); + if (tx_arvif != arvif) { + ar = tx_arvif->ar; + ab = ar->ab; +@@ -1562,7 +1562,7 @@ static int ath11k_mac_setup_bcn_tmpl(str + * non-transmitting interfaces, and results in a crash if sent. + */ + if (vif->mbssid_tx_vif && +- arvif != (void *)vif->mbssid_tx_vif->drv_priv && arvif->is_up) ++ arvif != ath11k_vif_to_arvif(vif->mbssid_tx_vif) && arvif->is_up) + return 0; + + if (vif->bss_conf.ema_ap && vif->mbssid_tx_vif) +@@ -1626,7 +1626,7 @@ static void ath11k_control_beaconing(str + ether_addr_copy(arvif->bssid, info->bssid); + + if (arvif->vif->mbssid_tx_vif) +- tx_arvif = (struct ath11k_vif *)arvif->vif->mbssid_tx_vif->drv_priv; ++ tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif); + + ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, + arvif->bssid, +@@ -1649,7 +1649,7 @@ static void ath11k_mac_handle_beacon_ite + { + struct sk_buff *skb = data; + struct ieee80211_mgmt *mgmt = (void *)skb->data; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + + if (vif->type != NL80211_IFTYPE_STATION) + return; +@@ -1672,7 +1672,7 @@ static void ath11k_mac_handle_beacon_mis + struct ieee80211_vif *vif) + { + u32 *vdev_id = data; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct ath11k *ar = arvif->ar; + struct ieee80211_hw *hw = ar->hw; + +@@ -1718,7 +1718,7 @@ static void ath11k_peer_assoc_h_basic(st + struct ieee80211_sta *sta, + struct peer_assoc_params *arg) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + u32 aid; + + lockdep_assert_held(&ar->conf_mutex); +@@ -1746,7 +1746,7 @@ static void ath11k_peer_assoc_h_crypto(s + struct ieee80211_bss_conf *info = &vif->bss_conf; + struct cfg80211_chan_def def; + struct cfg80211_bss *bss; +- struct ath11k_vif *arvif = (struct ath11k_vif *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + const u8 *rsnie = NULL; + const u8 *wpaie = NULL; + +@@ -1804,7 +1804,7 @@ static void ath11k_peer_assoc_h_rates(st + struct ieee80211_sta *sta, + struct peer_assoc_params *arg) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct wmi_rate_set_arg *rateset = &arg->peer_legacy_rates; + struct cfg80211_chan_def def; + const struct ieee80211_supported_band *sband; +@@ -1867,7 +1867,7 @@ static void ath11k_peer_assoc_h_ht(struc + struct peer_assoc_params *arg) + { + const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct cfg80211_chan_def def; + enum nl80211_band band; + const u8 *ht_mcs_mask; +@@ -2064,7 +2064,7 @@ static void ath11k_peer_assoc_h_vht(stru + struct peer_assoc_params *arg) + { + const struct ieee80211_sta_vht_cap *vht_cap = &sta->deflink.vht_cap; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct cfg80211_chan_def def; + enum nl80211_band band; + u16 *vht_mcs_mask; +@@ -2261,7 +2261,7 @@ static void ath11k_peer_assoc_h_he(struc + struct ieee80211_sta *sta, + struct peer_assoc_params *arg) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct cfg80211_chan_def def; + const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; + enum nl80211_band band; +@@ -2584,7 +2584,7 @@ static void ath11k_peer_assoc_h_qos(stru + struct ieee80211_sta *sta, + struct peer_assoc_params *arg) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + + switch (arvif->vdev_type) { + case WMI_VDEV_TYPE_AP: +@@ -2747,7 +2747,7 @@ static void ath11k_peer_assoc_h_phymode( + struct ieee80211_sta *sta, + struct peer_assoc_params *arg) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct cfg80211_chan_def def; + enum nl80211_band band; + const u8 *ht_mcs_mask; +@@ -2933,7 +2933,7 @@ static bool ath11k_mac_vif_recalc_sta_he + struct ieee80211_vif *vif, + struct ieee80211_sta_he_cap *he_cap) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct ieee80211_he_cap_elem he_cap_elem = {0}; + struct ieee80211_sta_he_cap *cap_band = NULL; + struct cfg80211_chan_def def; +@@ -2995,7 +2995,7 @@ static void ath11k_bss_assoc(struct ieee + struct ieee80211_bss_conf *bss_conf) + { + struct ath11k *ar = hw->priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct peer_assoc_params peer_arg; + struct ieee80211_sta *ap_sta; + struct ath11k_peer *peer; +@@ -3111,7 +3111,7 @@ static void ath11k_bss_disassoc(struct i + struct ieee80211_vif *vif) + { + struct ath11k *ar = hw->priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + int ret; + + lockdep_assert_held(&ar->conf_mutex); +@@ -3160,7 +3160,7 @@ static void ath11k_recalculate_mgmt_rate + struct ieee80211_vif *vif, + struct cfg80211_chan_def *def) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + const struct ieee80211_supported_band *sband; + u8 basic_rate_idx; + int hw_rate_code; +@@ -4632,7 +4632,7 @@ static int ath11k_station_disassoc(struc + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + int ret = 0; + + lockdep_assert_held(&ar->conf_mutex); +@@ -5160,7 +5160,7 @@ static int ath11k_mac_op_sta_set_txpwr(s + struct ieee80211_sta *sta) + { + struct ath11k *ar = hw->priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + int ret = 0; + s16 txpwr; + +@@ -5210,7 +5210,7 @@ static void ath11k_mac_op_sta_rc_update( + { + struct ath11k *ar = hw->priv; + struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct ath11k_peer *peer; + u32 bw, smps; + +@@ -5337,7 +5337,7 @@ static int ath11k_mac_op_conf_tx(struct + const struct ieee80211_tx_queue_params *params) + { + struct ath11k *ar = hw->priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct wmi_wmm_params_arg *p = NULL; + int ret; + +@@ -6458,7 +6458,7 @@ static int ath11k_mac_setup_vdev_params_ + return 0; + } + +- tx_arvif = (void *)tx_vif->drv_priv; ++ tx_arvif = ath11k_vif_to_arvif(tx_vif); + + if (arvif->vif->bss_conf.nontransmitted) { + if (ar->hw->wiphy != ieee80211_vif_to_wdev(tx_vif)->wiphy) +@@ -7411,7 +7411,7 @@ ath11k_mac_update_vif_chan(struct ath11k + /* TODO: Update ar->rx_channel */ + + for (i = 0; i < n_vifs; i++) { +- arvif = (void *)vifs[i].vif->drv_priv; ++ arvif = ath11k_vif_to_arvif(vifs[i].vif); + + if (WARN_ON(!arvif->is_started)) + continue; +@@ -7453,7 +7453,7 @@ ath11k_mac_update_vif_chan(struct ath11k + + mbssid_tx_vif = arvif->vif->mbssid_tx_vif; + if (mbssid_tx_vif) +- tx_arvif = (struct ath11k_vif *)mbssid_tx_vif->drv_priv; ++ tx_arvif = ath11k_vif_to_arvif(mbssid_tx_vif); + + ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, + arvif->bssid, +@@ -7549,7 +7549,7 @@ static int ath11k_start_vdev_delay(struc + { + struct ath11k *ar = hw->priv; + struct ath11k_base *ab = ar->ab; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + int ret; + + if (WARN_ON(arvif->is_started)) +@@ -7599,7 +7599,7 @@ ath11k_mac_op_assign_vif_chanctx(struct + { + struct ath11k *ar = hw->priv; + struct ath11k_base *ab = ar->ab; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + int ret; + struct peer_create_params param; + +@@ -7689,7 +7689,7 @@ ath11k_mac_op_unassign_vif_chanctx(struc + { + struct ath11k *ar = hw->priv; + struct ath11k_base *ab = ar->ab; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct ath11k_peer *peer; + int ret; + +@@ -8310,7 +8310,7 @@ ath11k_mac_op_set_bitrate_mask(struct ie + struct ieee80211_vif *vif, + const struct cfg80211_bitrate_mask *mask) + { +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct cfg80211_chan_def def; + struct ath11k_pdev_cap *cap; + struct ath11k *ar = arvif->ar; +@@ -8907,7 +8907,7 @@ static int ath11k_mac_op_remain_on_chann + enum ieee80211_roc_type type) + { + struct ath11k *ar = hw->priv; +- struct ath11k_vif *arvif = (void *)vif->drv_priv; ++ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct scan_req_params arg; + int ret; + u32 scan_time_msec; +--- a/drivers/net/wireless/ath/ath11k/testmode.c ++++ b/drivers/net/wireless/ath/ath11k/testmode.c +@@ -350,7 +350,7 @@ static int ath11k_tm_cmd_wmi(struct ath1 + if (ar->ab->fw_mode != ATH11K_FIRMWARE_MODE_FTM && + (tag == WMI_TAG_VDEV_SET_PARAM_CMD || tag == WMI_TAG_UNIT_TEST_CMD)) { + if (vif) { +- arvif = (struct ath11k_vif *)vif->drv_priv; ++ arvif = ath11k_vif_to_arvif(vif); + *ptr = arvif->vdev_id; + } else { + ret = -EINVAL; diff --git a/package/kernel/mac80211/patches/ath11k/0009-wifi-ath11k-Fix-a-few-spelling-errors.patch b/package/kernel/mac80211/patches/ath11k/0009-wifi-ath11k-Fix-a-few-spelling-errors.patch new file mode 100644 index 00000000000..b093f3e3421 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0009-wifi-ath11k-Fix-a-few-spelling-errors.patch @@ -0,0 +1,50 @@ +From d68a283bfc39aeed2a51c67804e014bf4b35c7e1 Mon Sep 17 00:00:00 2001 +From: Jeff Johnson <quic_jjohnson@quicinc.com> +Date: Tue, 22 Aug 2023 07:50:49 -0700 +Subject: [PATCH] wifi: ath11k: Fix a few spelling errors + +Fix a few issues flagged by 'codespell'. + +Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Acked-by: Randy Dunlap <rdunlap@infradead.org> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230822-ath_spelling-v1-2-8e2698759564@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp.h | 2 +- + drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- + drivers/net/wireless/ath/ath11k/dp_tx.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp.h ++++ b/drivers/net/wireless/ath/ath11k/dp.h +@@ -635,7 +635,7 @@ enum htt_ppdu_stats_tag_type { + * b'24 - status_swap: 1 is to swap status TLV + * b'25 - pkt_swap: 1 is to swap packet TLV + * b'26:31 - rsvd1: reserved for future use +- * dword1 - b'0:16 - ring_buffer_size: size of bufferes referenced by rx ring, ++ * dword1 - b'0:16 - ring_buffer_size: size of buffers referenced by rx ring, + * in byte units. + * Valid only for HW_TO_SW_RING and SW_TO_HW_RING + * - b'16:31 - rsvd2: Reserved for future use +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -3423,7 +3423,7 @@ static int ath11k_dp_rx_h_defrag_reo_rei + ath11k_hal_rx_buf_addr_info_set(msdu0, paddr, cookie, + ab->hw_params.hal_params->rx_buf_rbm); + +- /* Fill mpdu details into reo entrace ring */ ++ /* Fill mpdu details into reo entrance ring */ + srng = &ab->hal.srng_list[ab->dp.reo_reinject_ring.ring_id]; + + spin_lock_bh(&srng->lock); +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -238,7 +238,7 @@ tcl_ring_sel: + spin_unlock_bh(&tcl_ring->lock); + ret = -ENOMEM; + +- /* Checking for available tcl descritors in another ring in ++ /* Checking for available tcl descriptors in another ring in + * case of failure due to full tcl ring now, is better than + * checking this ring earlier for each pkt tx. + * Restart ring selection if some rings are not checked yet. diff --git a/package/kernel/mac80211/patches/ath11k/0010-wifi-ath11k-simplify-the-code-with-module_platform_d.patch b/package/kernel/mac80211/patches/ath11k/0010-wifi-ath11k-simplify-the-code-with-module_platform_d.patch new file mode 100644 index 00000000000..19873339b23 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0010-wifi-ath11k-simplify-the-code-with-module_platform_d.patch @@ -0,0 +1,36 @@ +From 749a660b39030bfbacc366cd8670df2ee0e878b2 Mon Sep 17 00:00:00 2001 +From: Yang Yingliang <yangyingliang@huawei.com> +Date: Fri, 4 Aug 2023 17:12:55 +0800 +Subject: [PATCH] wifi: ath11k: simplify the code with module_platform_driver + +The init/exit() of driver only calls platform_driver_register/unregister, +it can be simpilfied with module_platform_driver. + +Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230804091255.1347178-1-yangyingliang@huawei.com +--- + drivers/net/wireless/ath/ath11k/ahb.c | 12 +----------- + 1 file changed, 1 insertion(+), 11 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/ahb.c ++++ b/drivers/net/wireless/ath/ath11k/ahb.c +@@ -1306,17 +1306,7 @@ static struct platform_driver ath11k_ahb + .shutdown = ath11k_ahb_shutdown, + }; + +-static int ath11k_ahb_init(void) +-{ +- return platform_driver_register(&ath11k_ahb_driver); +-} +-module_init(ath11k_ahb_init); +- +-static void ath11k_ahb_exit(void) +-{ +- platform_driver_unregister(&ath11k_ahb_driver); +-} +-module_exit(ath11k_ahb_exit); ++module_platform_driver(ath11k_ahb_driver); + + MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax WLAN AHB devices"); + MODULE_LICENSE("Dual BSD/GPL"); diff --git a/package/kernel/mac80211/patches/ath11k/0011-wifi-ath11k-fix-Wvoid-pointer-to-enum-cast-warning.patch b/package/kernel/mac80211/patches/ath11k/0011-wifi-ath11k-fix-Wvoid-pointer-to-enum-cast-warning.patch new file mode 100644 index 00000000000..f42b021375b --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0011-wifi-ath11k-fix-Wvoid-pointer-to-enum-cast-warning.patch @@ -0,0 +1,29 @@ +From 6763ef191d672ff3c2db0622652d49b0c0a60c4a Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> +Date: Thu, 10 Aug 2023 11:12:23 +0200 +Subject: [PATCH] wifi: ath11k: fix Wvoid-pointer-to-enum-cast warning + +'hw_rev' is an enum, thus cast of pointer on 64-bit compile test with W=1 +causes: + + h11k/ahb.c:1124:11: error: cast to smaller integer type 'enum ath11k_hw_rev' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] + +Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230810091224.70088-1-krzysztof.kozlowski@linaro.org +--- + drivers/net/wireless/ath/ath11k/ahb.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/ahb.c ++++ b/drivers/net/wireless/ath/ath11k/ahb.c +@@ -1096,7 +1096,7 @@ static int ath11k_ahb_probe(struct platf + return -EINVAL; + } + +- hw_rev = (enum ath11k_hw_rev)of_id->data; ++ hw_rev = (uintptr_t)of_id->data; + + switch (hw_rev) { + case ATH11K_HW_IPQ8074: diff --git a/package/kernel/mac80211/patches/ath11k/0012-wifi-ath11k-Remove-unused-declarations.patch b/package/kernel/mac80211/patches/ath11k/0012-wifi-ath11k-Remove-unused-declarations.patch new file mode 100644 index 00000000000..c318bbc3213 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0012-wifi-ath11k-Remove-unused-declarations.patch @@ -0,0 +1,44 @@ +From adb0b206709f4f2f1256a1ea20619ab98e99f2e7 Mon Sep 17 00:00:00 2001 +From: Yue Haibing <yuehaibing@huawei.com> +Date: Fri, 11 Aug 2023 18:44:13 +0800 +Subject: [PATCH] wifi: ath11k: Remove unused declarations + +Commit 2c3960c2253d ("ath11k: setup ce tasklet for control path") +declared but never implemented ath11k_ce_map_service_to_pipe(). +Commit e3396b8bddd2 ("ath11k: ce: support different CE configurations") +declared but never implemented ath11k_ce_attr_attach(). +Commit d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") +declared but never implemented ath11k_qmi_event_work()/ath11k_qmi_msg_recv_work(). + +Signed-off-by: Yue Haibing <yuehaibing@huawei.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230811104413.33668-1-yuehaibing@huawei.com +--- + drivers/net/wireless/ath/ath11k/ce.h | 3 --- + drivers/net/wireless/ath/ath11k/qmi.h | 2 -- + 2 files changed, 5 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/ce.h ++++ b/drivers/net/wireless/ath/ath11k/ce.h +@@ -203,9 +203,6 @@ int ath11k_ce_alloc_pipes(struct ath11k_ + void ath11k_ce_free_pipes(struct ath11k_base *ab); + int ath11k_ce_get_attr_flags(struct ath11k_base *ab, int ce_id); + void ath11k_ce_poll_send_completed(struct ath11k_base *ab, u8 pipe_id); +-int ath11k_ce_map_service_to_pipe(struct ath11k_base *ab, u16 service_id, +- u8 *ul_pipe, u8 *dl_pipe); +-int ath11k_ce_attr_attach(struct ath11k_base *ab); + void ath11k_ce_get_shadow_config(struct ath11k_base *ab, + u32 **shadow_cfg, u32 *shadow_cfg_len); + void ath11k_ce_stop_shadow_timers(struct ath11k_base *ab); +--- a/drivers/net/wireless/ath/ath11k/qmi.h ++++ b/drivers/net/wireless/ath/ath11k/qmi.h +@@ -514,8 +514,6 @@ struct qmi_wlanfw_wlan_ini_resp_msg_v01 + int ath11k_qmi_firmware_start(struct ath11k_base *ab, + u32 mode); + void ath11k_qmi_firmware_stop(struct ath11k_base *ab); +-void ath11k_qmi_event_work(struct work_struct *work); +-void ath11k_qmi_msg_recv_work(struct work_struct *work); + void ath11k_qmi_deinit_service(struct ath11k_base *ab); + int ath11k_qmi_init_service(struct ath11k_base *ab); + void ath11k_qmi_free_resource(struct ath11k_base *ab); diff --git a/package/kernel/mac80211/patches/ath11k/0013-wifi-ath11k-mhi-add-a-warning-message-for-MHI_CB_EE_.patch b/package/kernel/mac80211/patches/ath11k/0013-wifi-ath11k-mhi-add-a-warning-message-for-MHI_CB_EE_.patch new file mode 100644 index 00000000000..e1286c9537c --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0013-wifi-ath11k-mhi-add-a-warning-message-for-MHI_CB_EE_.patch @@ -0,0 +1,34 @@ +From 4a93b554cf9fa64faa7cf164c0d32fc3ce67108b Mon Sep 17 00:00:00 2001 +From: Arowa Suliman <arowa@chromium.org> +Date: Sat, 26 Aug 2023 08:42:42 +0300 +Subject: [PATCH] wifi: ath11k: mhi: add a warning message for MHI_CB_EE_RDDM + crash + +Currently, the ath11k driver does not print a crash signature when a +MHI_CB_EE_RDDM crash happens. Checked by triggering a simulated crash using the +command and checking dmesg for logs: + +echo assert > /sys/kernel/debug/ath11k/../simulate_fw_crash + +Add a warning when firmware crash MHI_CB_EE_RDDM happens. + +Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 + +Signed-off-by: Arowa Suliman <arowa@chromium.org> +Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230714001126.463127-1-arowa@chromium.org +--- + drivers/net/wireless/ath/ath11k/mhi.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/ath/ath11k/mhi.c ++++ b/drivers/net/wireless/ath/ath11k/mhi.c +@@ -333,6 +333,7 @@ static void ath11k_mhi_op_status_cb(stru + ath11k_warn(ab, "firmware crashed: MHI_CB_SYS_ERROR\n"); + break; + case MHI_CB_EE_RDDM: ++ ath11k_warn(ab, "firmware crashed: MHI_CB_EE_RDDM\n"); + if (!(test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags))) + queue_work(ab->workqueue_aux, &ab->reset_work); + break; diff --git a/package/kernel/mac80211/patches/ath11k/0014-wifi-ath11k-move-references-from-rsvd2-to-info-field.patch b/package/kernel/mac80211/patches/ath11k/0014-wifi-ath11k-move-references-from-rsvd2-to-info-field.patch new file mode 100644 index 00000000000..731a763e17c --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0014-wifi-ath11k-move-references-from-rsvd2-to-info-field.patch @@ -0,0 +1,75 @@ +From 5bd2ced044bb95029d5c44cf7d23ced73e0fc05b Mon Sep 17 00:00:00 2001 +From: Muna Sinada <quic_msinada@quicinc.com> +Date: Sat, 26 Aug 2023 08:42:46 +0300 +Subject: [PATCH] wifi: ath11k: move references from rsvd2 to info fields + +Remove references to reserved fields and add new info fields for +struct hal_rx_ppdu_end_user_stats. Reserved fields should not be +accessed, therefore existing references to it are to be changed to +referencing specific info fields. + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Muna Sinada <quic_msinada@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/1692827868-15667-1-git-send-email-quic_msinada@quicinc.com +--- + drivers/net/wireless/ath/ath11k/hal_rx.c | 10 +++++----- + drivers/net/wireless/ath/ath11k/hal_rx.h | 11 ++++++++--- + 2 files changed, 13 insertions(+), 8 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/hal_rx.c ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.c +@@ -814,7 +814,7 @@ ath11k_hal_rx_handle_ofdma_info(void *rx + + rx_user_status->ul_ofdma_user_v0_word0 = __le32_to_cpu(ppdu_end_user->info6); + +- rx_user_status->ul_ofdma_user_v0_word1 = __le32_to_cpu(ppdu_end_user->rsvd2[10]); ++ rx_user_status->ul_ofdma_user_v0_word1 = __le32_to_cpu(ppdu_end_user->info9); + } + + static inline void +@@ -825,11 +825,11 @@ ath11k_hal_rx_populate_byte_count(void * + (struct hal_rx_ppdu_end_user_stats *)rx_tlv; + + rx_user_status->mpdu_ok_byte_count = +- FIELD_GET(HAL_RX_PPDU_END_USER_STATS_RSVD2_6_MPDU_OK_BYTE_COUNT, +- __le32_to_cpu(ppdu_end_user->rsvd2[6])); ++ FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_OK_BYTE_COUNT, ++ __le32_to_cpu(ppdu_end_user->info7)); + rx_user_status->mpdu_err_byte_count = +- FIELD_GET(HAL_RX_PPDU_END_USER_STATS_RSVD2_8_MPDU_ERR_BYTE_COUNT, +- __le32_to_cpu(ppdu_end_user->rsvd2[8])); ++ FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO9_MPDU_ERR_BYTE_COUNT, ++ __le32_to_cpu(ppdu_end_user->info8)); + } + + static inline void +--- a/drivers/net/wireless/ath/ath11k/hal_rx.h ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.h +@@ -222,8 +222,8 @@ struct hal_rx_ppdu_start { + #define HAL_RX_PPDU_END_USER_STATS_INFO6_TID_BITMAP GENMASK(15, 0) + #define HAL_RX_PPDU_END_USER_STATS_INFO6_TID_EOSP_BITMAP GENMASK(31, 16) + +-#define HAL_RX_PPDU_END_USER_STATS_RSVD2_6_MPDU_OK_BYTE_COUNT GENMASK(24, 0) +-#define HAL_RX_PPDU_END_USER_STATS_RSVD2_8_MPDU_ERR_BYTE_COUNT GENMASK(24, 0) ++#define HAL_RX_PPDU_END_USER_STATS_INFO7_MPDU_OK_BYTE_COUNT GENMASK(24, 0) ++#define HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_ERR_BYTE_COUNT GENMASK(24, 0) + + struct hal_rx_ppdu_end_user_stats { + __le32 rsvd0[2]; +@@ -236,7 +236,12 @@ struct hal_rx_ppdu_end_user_stats { + __le32 info4; + __le32 info5; + __le32 info6; +- __le32 rsvd2[11]; ++ __le32 rsvd2[5]; ++ __le32 info7; ++ __le32 rsvd3; ++ __le32 info8; ++ __le32 rsvd3[2]; ++ __le32 info9; + } __packed; + + struct hal_rx_ppdu_end_user_stats_ext { diff --git a/package/kernel/mac80211/patches/ath11k/0015-wifi-ath11k-fix-tid-bitmap-is-0-in-peer-rx-mu-stats.patch b/package/kernel/mac80211/patches/ath11k/0015-wifi-ath11k-fix-tid-bitmap-is-0-in-peer-rx-mu-stats.patch new file mode 100644 index 00000000000..3edc3fc956c --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0015-wifi-ath11k-fix-tid-bitmap-is-0-in-peer-rx-mu-stats.patch @@ -0,0 +1,100 @@ +From 7791487cd16cafd018cba0bf73789111a9f16843 Mon Sep 17 00:00:00 2001 +From: Muna Sinada <quic_msinada@quicinc.com> +Date: Sat, 26 Aug 2023 08:42:46 +0300 +Subject: [PATCH] wifi: ath11k: fix tid bitmap is 0 in peer rx mu stats + +Correct parsing of reading offset for rx tid 16 bit bitmap. Incorrect +offset caused peer rx mu stats tid bitmap to always be zero. This +correction is in the software context and does not affect the +firmware interface. + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Muna Sinada <quic_msinada@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/1692827868-15667-2-git-send-email-quic_msinada@quicinc.com +--- + drivers/net/wireless/ath/ath11k/hal_rx.c | 10 +++++----- + drivers/net/wireless/ath/ath11k/hal_rx.h | 17 +++++++++-------- + 2 files changed, 14 insertions(+), 13 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/hal_rx.c ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.c +@@ -814,7 +814,7 @@ ath11k_hal_rx_handle_ofdma_info(void *rx + + rx_user_status->ul_ofdma_user_v0_word0 = __le32_to_cpu(ppdu_end_user->info6); + +- rx_user_status->ul_ofdma_user_v0_word1 = __le32_to_cpu(ppdu_end_user->info9); ++ rx_user_status->ul_ofdma_user_v0_word1 = __le32_to_cpu(ppdu_end_user->info10); + } + + static inline void +@@ -826,10 +826,10 @@ ath11k_hal_rx_populate_byte_count(void * + + rx_user_status->mpdu_ok_byte_count = + FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_OK_BYTE_COUNT, +- __le32_to_cpu(ppdu_end_user->info7)); ++ __le32_to_cpu(ppdu_end_user->info8)); + rx_user_status->mpdu_err_byte_count = + FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO9_MPDU_ERR_BYTE_COUNT, +- __le32_to_cpu(ppdu_end_user->info8)); ++ __le32_to_cpu(ppdu_end_user->info9)); + } + + static inline void +@@ -903,8 +903,8 @@ ath11k_hal_rx_parse_mon_status_tlv(struc + FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO2_AST_INDEX, + __le32_to_cpu(eu_stats->info2)); + ppdu_info->tid = +- ffs(FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO6_TID_BITMAP, +- __le32_to_cpu(eu_stats->info6))) - 1; ++ ffs(FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO7_TID_BITMAP, ++ __le32_to_cpu(eu_stats->info7))) - 1; + ppdu_info->tcp_msdu_count = + FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO4_TCP_MSDU_CNT, + __le32_to_cpu(eu_stats->info4)); +--- a/drivers/net/wireless/ath/ath11k/hal_rx.h ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.h +@@ -149,7 +149,7 @@ struct hal_rx_mon_ppdu_info { + u8 beamformed; + u8 rssi_comb; + u8 rssi_chain_pri20[HAL_RX_MAX_NSS]; +- u8 tid; ++ u16 tid; + u16 ht_flags; + u16 vht_flags; + u16 he_flags; +@@ -219,11 +219,11 @@ struct hal_rx_ppdu_start { + #define HAL_RX_PPDU_END_USER_STATS_INFO5_OTHER_MSDU_CNT GENMASK(15, 0) + #define HAL_RX_PPDU_END_USER_STATS_INFO5_TCP_ACK_MSDU_CNT GENMASK(31, 16) + +-#define HAL_RX_PPDU_END_USER_STATS_INFO6_TID_BITMAP GENMASK(15, 0) +-#define HAL_RX_PPDU_END_USER_STATS_INFO6_TID_EOSP_BITMAP GENMASK(31, 16) ++#define HAL_RX_PPDU_END_USER_STATS_INFO7_TID_BITMAP GENMASK(15, 0) ++#define HAL_RX_PPDU_END_USER_STATS_INFO7_TID_EOSP_BITMAP GENMASK(31, 16) + +-#define HAL_RX_PPDU_END_USER_STATS_INFO7_MPDU_OK_BYTE_COUNT GENMASK(24, 0) +-#define HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_ERR_BYTE_COUNT GENMASK(24, 0) ++#define HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_OK_BYTE_COUNT GENMASK(24, 0) ++#define HAL_RX_PPDU_END_USER_STATS_INFO9_MPDU_ERR_BYTE_COUNT GENMASK(24, 0) + + struct hal_rx_ppdu_end_user_stats { + __le32 rsvd0[2]; +@@ -236,12 +236,13 @@ struct hal_rx_ppdu_end_user_stats { + __le32 info4; + __le32 info5; + __le32 info6; +- __le32 rsvd2[5]; + __le32 info7; +- __le32 rsvd3; ++ __le32 rsvd2[4]; + __le32 info8; +- __le32 rsvd3[2]; ++ __le32 rsvd3; + __le32 info9; ++ __le32 rsvd4[2]; ++ __le32 info10; + } __packed; + + struct hal_rx_ppdu_end_user_stats_ext { diff --git a/package/kernel/mac80211/patches/ath11k/0016-wifi-ath11k-add-chip-id-board-name-while-searching-b.patch b/package/kernel/mac80211/patches/ath11k/0016-wifi-ath11k-add-chip-id-board-name-while-searching-b.patch new file mode 100644 index 00000000000..662e28f4ef8 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0016-wifi-ath11k-add-chip-id-board-name-while-searching-b.patch @@ -0,0 +1,214 @@ +From 1133af5aea588a58043244a4ecb5ce511b310356 Mon Sep 17 00:00:00 2001 +From: Wen Gong <quic_wgong@quicinc.com> +Date: Wed, 30 Aug 2023 02:02:26 -0400 +Subject: [PATCH] wifi: ath11k: add chip id board name while searching + board-2.bin for WCN6855 + +Sometimes board-2.bin does not have the board data which matched the +parameters such as bus type, vendor, device, subsystem-vendor, +subsystem-device, qmi-chip-id and qmi-board-id, then wlan will load fail. + +Hence add another type which only matches the bus type and qmi-chip-id, +then the ratio of missing board data reduced. + +Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 + +Signed-off-by: Wen Gong <quic_wgong@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230830060226.18664-1-quic_wgong@quicinc.com +--- + drivers/net/wireless/ath/ath11k/core.c | 108 ++++++++++++++++++++----- + 1 file changed, 87 insertions(+), 21 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -985,9 +985,15 @@ int ath11k_core_check_dt(struct ath11k_b + return 0; + } + ++enum ath11k_bdf_name_type { ++ ATH11K_BDF_NAME_FULL, ++ ATH11K_BDF_NAME_BUS_NAME, ++ ATH11K_BDF_NAME_CHIP_ID, ++}; ++ + static int __ath11k_core_create_board_name(struct ath11k_base *ab, char *name, + size_t name_len, bool with_variant, +- bool bus_type_mode) ++ enum ath11k_bdf_name_type name_type) + { + /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */ + char variant[9 + ATH11K_QMI_BDF_EXT_STR_LENGTH] = { 0 }; +@@ -998,11 +1004,8 @@ static int __ath11k_core_create_board_na + + switch (ab->id.bdf_search) { + case ATH11K_BDF_SEARCH_BUS_AND_BOARD: +- if (bus_type_mode) +- scnprintf(name, name_len, +- "bus=%s", +- ath11k_bus_str(ab->hif.bus)); +- else ++ switch (name_type) { ++ case ATH11K_BDF_NAME_FULL: + scnprintf(name, name_len, + "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x,qmi-chip-id=%d,qmi-board-id=%d%s", + ath11k_bus_str(ab->hif.bus), +@@ -1012,6 +1015,19 @@ static int __ath11k_core_create_board_na + ab->qmi.target.chip_id, + ab->qmi.target.board_id, + variant); ++ break; ++ case ATH11K_BDF_NAME_BUS_NAME: ++ scnprintf(name, name_len, ++ "bus=%s", ++ ath11k_bus_str(ab->hif.bus)); ++ break; ++ case ATH11K_BDF_NAME_CHIP_ID: ++ scnprintf(name, name_len, ++ "bus=%s,qmi-chip-id=%d", ++ ath11k_bus_str(ab->hif.bus), ++ ab->qmi.target.chip_id); ++ break; ++ } + break; + default: + scnprintf(name, name_len, +@@ -1030,19 +1046,29 @@ static int __ath11k_core_create_board_na + static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name, + size_t name_len) + { +- return __ath11k_core_create_board_name(ab, name, name_len, true, false); ++ return __ath11k_core_create_board_name(ab, name, name_len, true, ++ ATH11K_BDF_NAME_FULL); + } + + static int ath11k_core_create_fallback_board_name(struct ath11k_base *ab, char *name, + size_t name_len) + { +- return __ath11k_core_create_board_name(ab, name, name_len, false, false); ++ return __ath11k_core_create_board_name(ab, name, name_len, false, ++ ATH11K_BDF_NAME_FULL); + } + + static int ath11k_core_create_bus_type_board_name(struct ath11k_base *ab, char *name, + size_t name_len) + { +- return __ath11k_core_create_board_name(ab, name, name_len, false, true); ++ return __ath11k_core_create_board_name(ab, name, name_len, false, ++ ATH11K_BDF_NAME_BUS_NAME); ++} ++ ++static int ath11k_core_create_chip_id_board_name(struct ath11k_base *ab, char *name, ++ size_t name_len) ++{ ++ return __ath11k_core_create_board_name(ab, name, name_len, false, ++ ATH11K_BDF_NAME_CHIP_ID); + } + + const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab, +@@ -1289,16 +1315,21 @@ int ath11k_core_fetch_board_data_api_1(s + #define BOARD_NAME_SIZE 200 + int ath11k_core_fetch_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd) + { +- char boardname[BOARD_NAME_SIZE], fallback_boardname[BOARD_NAME_SIZE]; ++ char *boardname = NULL, *fallback_boardname = NULL, *chip_id_boardname = NULL; + char *filename, filepath[100]; +- int ret; ++ int ret = 0; + + filename = ATH11K_BOARD_API2_FILE; ++ boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL); ++ if (!boardname) { ++ ret = -ENOMEM; ++ goto exit; ++ } + +- ret = ath11k_core_create_board_name(ab, boardname, sizeof(boardname)); ++ ret = ath11k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE); + if (ret) { + ath11k_err(ab, "failed to create board name: %d", ret); +- return ret; ++ goto exit; + } + + ab->bd_api = 2; +@@ -1307,13 +1338,19 @@ int ath11k_core_fetch_bdf(struct ath11k_ + ATH11K_BD_IE_BOARD_NAME, + ATH11K_BD_IE_BOARD_DATA); + if (!ret) +- goto success; ++ goto exit; ++ ++ fallback_boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL); ++ if (!fallback_boardname) { ++ ret = -ENOMEM; ++ goto exit; ++ } + + ret = ath11k_core_create_fallback_board_name(ab, fallback_boardname, +- sizeof(fallback_boardname)); ++ BOARD_NAME_SIZE); + if (ret) { + ath11k_err(ab, "failed to create fallback board name: %d", ret); +- return ret; ++ goto exit; + } + + ret = ath11k_core_fetch_board_data_api_n(ab, bd, fallback_boardname, +@@ -1321,7 +1358,28 @@ int ath11k_core_fetch_bdf(struct ath11k_ + ATH11K_BD_IE_BOARD_NAME, + ATH11K_BD_IE_BOARD_DATA); + if (!ret) +- goto success; ++ goto exit; ++ ++ chip_id_boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL); ++ if (!chip_id_boardname) { ++ ret = -ENOMEM; ++ goto exit; ++ } ++ ++ ret = ath11k_core_create_chip_id_board_name(ab, chip_id_boardname, ++ BOARD_NAME_SIZE); ++ if (ret) { ++ ath11k_err(ab, "failed to create chip id board name: %d", ret); ++ goto exit; ++ } ++ ++ ret = ath11k_core_fetch_board_data_api_n(ab, bd, chip_id_boardname, ++ ATH11K_BD_IE_BOARD, ++ ATH11K_BD_IE_BOARD_NAME, ++ ATH11K_BD_IE_BOARD_DATA); ++ ++ if (!ret) ++ goto exit; + + ab->bd_api = 1; + ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_DEFAULT_BOARD_FILE); +@@ -1334,14 +1392,22 @@ int ath11k_core_fetch_bdf(struct ath11k_ + ath11k_err(ab, "failed to fetch board data for %s from %s\n", + fallback_boardname, filepath); + ++ ath11k_err(ab, "failed to fetch board data for %s from %s\n", ++ chip_id_boardname, filepath); ++ + ath11k_err(ab, "failed to fetch board.bin from %s\n", + ab->hw_params.fw.dir); +- return ret; + } + +-success: +- ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board api %d\n", ab->bd_api); +- return 0; ++exit: ++ kfree(boardname); ++ kfree(fallback_boardname); ++ kfree(chip_id_boardname); ++ ++ if (!ret) ++ ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board api %d\n", ab->bd_api); ++ ++ return ret; + } + + int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd) diff --git a/package/kernel/mac80211/patches/ath11k/0017-wifi-ath11k-fix-boot-failure-with-one-MSI-vector.patch b/package/kernel/mac80211/patches/ath11k/0017-wifi-ath11k-fix-boot-failure-with-one-MSI-vector.patch new file mode 100644 index 00000000000..9101a1ea1ce --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0017-wifi-ath11k-fix-boot-failure-with-one-MSI-vector.patch @@ -0,0 +1,103 @@ +From 39564b475ac5a589e6c22c43a08cbd283c295d2c Mon Sep 17 00:00:00 2001 +From: Baochen Qiang <quic_bqiang@quicinc.com> +Date: Thu, 7 Sep 2023 09:56:06 +0800 +Subject: [PATCH] wifi: ath11k: fix boot failure with one MSI vector + +Commit 5b32b6dd96633 ("ath11k: Remove core PCI references from +PCI common code") breaks with one MSI vector because it moves +affinity setting after IRQ request, see below log: + +[ 1417.278835] ath11k_pci 0000:02:00.0: failed to receive control response completion, polling.. +[ 1418.302829] ath11k_pci 0000:02:00.0: Service connect timeout +[ 1418.302833] ath11k_pci 0000:02:00.0: failed to connect to HTT: -110 +[ 1418.303669] ath11k_pci 0000:02:00.0: failed to start core: -110 + +The detail is, if do affinity request after IRQ activated, +which is done in request_irq(), kernel caches that request and +returns success directly. Later when a subsequent MHI interrupt is +fired, kernel will do the real affinity setting work, as a result, +changs the MSI vector. However at that time host has configured +old vector to hardware, so host never receives CE or DP interrupts. + +Fix it by setting affinity before registering MHI controller +where host is, for the first time, doing IRQ request. + +Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3 +Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 +Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-01160-QCAMSLSWPLZ-1 + +Fixes: 5b32b6dd9663 ("ath11k: Remove core PCI references from PCI common code") +Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230907015606.16297-1-quic_bqiang@quicinc.com +--- + drivers/net/wireless/ath/ath11k/pci.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -852,10 +852,16 @@ unsupported_wcn6855_soc: + if (ret) + goto err_pci_disable_msi; + ++ ret = ath11k_pci_set_irq_affinity_hint(ab_pci, cpumask_of(0)); ++ if (ret) { ++ ath11k_err(ab, "failed to set irq affinity %d\n", ret); ++ goto err_pci_disable_msi; ++ } ++ + ret = ath11k_mhi_register(ab_pci); + if (ret) { + ath11k_err(ab, "failed to register mhi: %d\n", ret); +- goto err_pci_disable_msi; ++ goto err_irq_affinity_cleanup; + } + + ret = ath11k_hal_srng_init(ab); +@@ -876,12 +882,6 @@ unsupported_wcn6855_soc: + goto err_ce_free; + } + +- ret = ath11k_pci_set_irq_affinity_hint(ab_pci, cpumask_of(0)); +- if (ret) { +- ath11k_err(ab, "failed to set irq affinity %d\n", ret); +- goto err_free_irq; +- } +- + /* kernel may allocate a dummy vector before request_irq and + * then allocate a real vector when request_irq is called. + * So get msi_data here again to avoid spurious interrupt +@@ -890,20 +890,17 @@ unsupported_wcn6855_soc: + ret = ath11k_pci_config_msi_data(ab_pci); + if (ret) { + ath11k_err(ab, "failed to config msi_data: %d\n", ret); +- goto err_irq_affinity_cleanup; ++ goto err_free_irq; + } + + ret = ath11k_core_init(ab); + if (ret) { + ath11k_err(ab, "failed to init core: %d\n", ret); +- goto err_irq_affinity_cleanup; ++ goto err_free_irq; + } + ath11k_qmi_fwreset_from_cold_boot(ab); + return 0; + +-err_irq_affinity_cleanup: +- ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); +- + err_free_irq: + ath11k_pcic_free_irq(ab); + +@@ -916,6 +913,9 @@ err_hal_srng_deinit: + err_mhi_unregister: + ath11k_mhi_unregister(ab_pci); + ++err_irq_affinity_cleanup: ++ ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); ++ + err_pci_disable_msi: + ath11k_pci_free_msi(ab_pci); + diff --git a/package/kernel/mac80211/patches/ath11k/0018-wifi-ath11k-drop-NULL-pointer-check-in-ath11k_update.patch b/package/kernel/mac80211/patches/ath11k/0018-wifi-ath11k-drop-NULL-pointer-check-in-ath11k_update.patch new file mode 100644 index 00000000000..ccf7461a758 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0018-wifi-ath11k-drop-NULL-pointer-check-in-ath11k_update.patch @@ -0,0 +1,32 @@ +From ac13a7842ab46a87aa315514d6d7e19b03cb2adc Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Wed, 6 Sep 2023 12:36:55 +0300 +Subject: [PATCH] wifi: ath11k: drop NULL pointer check in + ath11k_update_per_peer_tx_stats() + +Since 'user_stats' is a fixed-size array of 'struct htt_ppdu_user_stats' +in 'struct htt_ppdu_stats', any of its member can't be NULL and so +relevant check may be dropped. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230906093704.14001-1-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 3 --- + 1 file changed, 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -1388,9 +1388,6 @@ ath11k_update_per_peer_tx_stats(struct a + u8 tid = HTT_PPDU_STATS_NON_QOS_TID; + bool is_ampdu = false; + +- if (!usr_stats) +- return; +- + if (!(usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_RATE))) + return; + diff --git a/package/kernel/mac80211/patches/ath11k/0019-wifi-ath11k-drop-redundant-check-in-ath11k_dp_rx_mon.patch b/package/kernel/mac80211/patches/ath11k/0019-wifi-ath11k-drop-redundant-check-in-ath11k_dp_rx_mon.patch new file mode 100644 index 00000000000..ace199315b2 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0019-wifi-ath11k-drop-redundant-check-in-ath11k_dp_rx_mon.patch @@ -0,0 +1,38 @@ +From 82ae3f4635382ff23e2ece55b5d5e713223951ec Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Thu, 24 Aug 2023 10:50:44 +0300 +Subject: [PATCH] wifi: ath11k: drop redundant check in + ath11k_dp_rx_mon_dest_process() + +In 'ath11k_dp_rx_mon_dest_process()', 'mon_dst_srng' points to +a member of 'srng_list', which is a fixed-size array inside +'struct ath11k_hal'. This way, if 'ring_id' is valid (i. e. +between 0 and HAL_SRNG_RING_ID_MAX - 1 inclusive), 'mon_dst_srng' +can't be NULL and so relevant check may be dropped. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230824075121.121144-1-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 7 ------- + 1 file changed, 7 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -5094,13 +5094,6 @@ static void ath11k_dp_rx_mon_dest_proces + + mon_dst_srng = &ar->ab->hal.srng_list[ring_id]; + +- if (!mon_dst_srng) { +- ath11k_warn(ar->ab, +- "HAL Monitor Destination Ring Init Failed -- %p", +- mon_dst_srng); +- return; +- } +- + spin_lock_bh(&pmon->mon_lock); + + ath11k_hal_srng_access_begin(ar->ab, mon_dst_srng); diff --git a/package/kernel/mac80211/patches/ath11k/0020-wifi-ath11k-remove-unused-members-of-struct-ath11k_b.patch b/package/kernel/mac80211/patches/ath11k/0020-wifi-ath11k-remove-unused-members-of-struct-ath11k_b.patch new file mode 100644 index 00000000000..ffb210cc106 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0020-wifi-ath11k-remove-unused-members-of-struct-ath11k_b.patch @@ -0,0 +1,46 @@ +From 9066794113c4813b6ce4a66ed6ce14ecdf35625d Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Thu, 24 Aug 2023 10:50:45 +0300 +Subject: [PATCH] wifi: ath11k: remove unused members of 'struct ath11k_base' + +Remove set but otherwise unused 'wlan_init_status' and +'wmi_ready' members of 'struct ath11k_base', adjust +'ath11k_wmi_tlv_rdy_parse()' accordingly. + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230824075121.121144-2-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/core.h | 2 -- + drivers/net/wireless/ath/ath11k/wmi.c | 2 -- + 2 files changed, 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/core.h ++++ b/drivers/net/wireless/ath/ath11k/core.h +@@ -901,8 +901,6 @@ struct ath11k_base { + struct list_head peers; + wait_queue_head_t peer_mapping_wq; + u8 mac_addr[ETH_ALEN]; +- bool wmi_ready; +- u32 wlan_init_status; + int irq_num[ATH11K_IRQ_NUM_MAX]; + struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX]; + struct ath11k_targ_cap target_caps; +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -7222,14 +7222,12 @@ static int ath11k_wmi_tlv_rdy_parse(stru + memset(&fixed_param, 0, sizeof(fixed_param)); + memcpy(&fixed_param, (struct wmi_ready_event *)ptr, + min_t(u16, sizeof(fixed_param), len)); +- ab->wlan_init_status = fixed_param.ready_event_min.status; + rdy_parse->num_extra_mac_addr = + fixed_param.ready_event_min.num_extra_mac_addr; + + ether_addr_copy(ab->mac_addr, + fixed_param.ready_event_min.mac_addr.addr); + ab->pktlog_defs_checksum = fixed_param.pktlog_defs_checksum; +- ab->wmi_ready = true; + break; + case WMI_TAG_ARRAY_FIXED_STRUCT: + addr_list = (struct wmi_mac_addr *)ptr; diff --git a/package/kernel/mac80211/patches/ath11k/0021-wifi-ath11k-use-kstrtoul_from_user-where-appropriate.patch b/package/kernel/mac80211/patches/ath11k/0021-wifi-ath11k-use-kstrtoul_from_user-where-appropriate.patch new file mode 100644 index 00000000000..7a6b11b6d3f --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0021-wifi-ath11k-use-kstrtoul_from_user-where-appropriate.patch @@ -0,0 +1,60 @@ +From 458f66c30df2b8495790cf6fca76ebad44046921 Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Thu, 21 Sep 2023 11:16:57 +0300 +Subject: [PATCH] wifi: ath11k: use kstrtoul_from_user() where appropriate + +Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()' +and 'ath11k_write_file_spectral_bins()' + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230824075121.121144-4-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/spectral.c | 26 +++++++--------------- + 1 file changed, 8 insertions(+), 18 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/spectral.c ++++ b/drivers/net/wireless/ath/ath11k/spectral.c +@@ -386,16 +386,11 @@ static ssize_t ath11k_write_file_spectra + { + struct ath11k *ar = file->private_data; + unsigned long val; +- char buf[32]; +- ssize_t len; +- +- len = min(count, sizeof(buf) - 1); +- if (copy_from_user(buf, user_buf, len)) +- return -EFAULT; ++ ssize_t ret; + +- buf[len] = '\0'; +- if (kstrtoul(buf, 0, &val)) +- return -EINVAL; ++ ret = kstrtoul_from_user(user_buf, count, 0, &val); ++ if (ret) ++ return ret; + + if (val > ATH11K_SPECTRAL_SCAN_COUNT_MAX) + return -EINVAL; +@@ -441,16 +436,11 @@ static ssize_t ath11k_write_file_spectra + { + struct ath11k *ar = file->private_data; + unsigned long val; +- char buf[32]; +- ssize_t len; +- +- len = min(count, sizeof(buf) - 1); +- if (copy_from_user(buf, user_buf, len)) +- return -EFAULT; ++ ssize_t ret; + +- buf[len] = '\0'; +- if (kstrtoul(buf, 0, &val)) +- return -EINVAL; ++ ret = kstrtoul_from_user(user_buf, count, 0, &val); ++ if (ret) ++ return ret; + + if (val < ATH11K_SPECTRAL_MIN_BINS || + val > ar->ab->hw_params.spectral.max_fft_bins) diff --git a/package/kernel/mac80211/patches/ath11k/0022-wifi-ath11k-remove-unnecessary-void-conversions.patch b/package/kernel/mac80211/patches/ath11k/0022-wifi-ath11k-remove-unnecessary-void-conversions.patch new file mode 100644 index 00000000000..cbd664dad58 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0022-wifi-ath11k-remove-unnecessary-void-conversions.patch @@ -0,0 +1,248 @@ +From 87fd0602610d6965c45afc61780ac98842e8f902 Mon Sep 17 00:00:00 2001 +From: Wu Yunchuan <yunchuan@nfschina.com> +Date: Thu, 21 Sep 2023 11:50:05 +0300 +Subject: [PATCH] wifi: ath11k: remove unnecessary (void*) conversions + +No need cast (void *) to (struct ath11k_base *), +struct hal_rx_msdu_link *), (struct ath11k_buffer_addr *) or +other types. + +Signed-off-by: Wu Yunchuan <yunchuan@nfschina.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230919045150.524304-1-yunchuan@nfschina.com +--- + drivers/net/wireless/ath/ath11k/dp.c | 2 +- + drivers/net/wireless/ath/ath11k/dp_rx.c | 13 +++++-------- + drivers/net/wireless/ath/ath11k/hal.c | 8 +++----- + drivers/net/wireless/ath/ath11k/hal_rx.c | 17 +++++++---------- + drivers/net/wireless/ath/ath11k/hal_tx.c | 2 +- + drivers/net/wireless/ath/ath11k/mac.c | 4 ++-- + drivers/net/wireless/ath/ath11k/spectral.c | 2 +- + drivers/net/wireless/ath/ath11k/wmi.c | 6 +++--- + 8 files changed, 23 insertions(+), 31 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp.c ++++ b/drivers/net/wireless/ath/ath11k/dp.c +@@ -1009,7 +1009,7 @@ void ath11k_dp_vdev_tx_attach(struct ath + + static int ath11k_dp_tx_pending_cleanup(int buf_id, void *skb, void *ctx) + { +- struct ath11k_base *ab = (struct ath11k_base *)ctx; ++ struct ath11k_base *ab = ctx; + struct sk_buff *msdu = skb; + + dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len, +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -1256,7 +1256,7 @@ static int ath11k_htt_tlv_ppdu_stats_par + int cur_user; + u16 peer_id; + +- ppdu_info = (struct htt_ppdu_stats_info *)data; ++ ppdu_info = data; + + switch (tag) { + case HTT_PPDU_STATS_TAG_COMMON: +@@ -4486,8 +4486,7 @@ int ath11k_dp_rx_monitor_link_desc_retur + src_srng_desc = ath11k_hal_srng_src_get_next_entry(ar->ab, hal_srng); + + if (src_srng_desc) { +- struct ath11k_buffer_addr *src_desc = +- (struct ath11k_buffer_addr *)src_srng_desc; ++ struct ath11k_buffer_addr *src_desc = src_srng_desc; + + *src_desc = *((struct ath11k_buffer_addr *)p_last_buf_addr_info); + } else { +@@ -4506,8 +4505,7 @@ void ath11k_dp_rx_mon_next_link_desc_get + u8 *rbm, + void **pp_buf_addr_info) + { +- struct hal_rx_msdu_link *msdu_link = +- (struct hal_rx_msdu_link *)rx_msdu_link_desc; ++ struct hal_rx_msdu_link *msdu_link = rx_msdu_link_desc; + struct ath11k_buffer_addr *buf_addr_info; + + buf_addr_info = (struct ath11k_buffer_addr *)&msdu_link->buf_addr_info; +@@ -4548,7 +4546,7 @@ static void ath11k_hal_rx_msdu_list_get( + u32 first = FIELD_PREP(RX_MSDU_DESC_INFO0_FIRST_MSDU_IN_MPDU, 1); + u8 tmp = 0; + +- msdu_link = (struct hal_rx_msdu_link *)msdu_link_desc; ++ msdu_link = msdu_link_desc; + msdu_details = &msdu_link->msdu_link[0]; + + for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) { +@@ -4645,8 +4643,7 @@ ath11k_dp_rx_mon_mpdu_pop(struct ath11k + bool is_frag, is_first_msdu; + bool drop_mpdu = false; + struct ath11k_skb_rxcb *rxcb; +- struct hal_reo_entrance_ring *ent_desc = +- (struct hal_reo_entrance_ring *)ring_entry; ++ struct hal_reo_entrance_ring *ent_desc = ring_entry; + int buf_id; + u32 rx_link_buf_info[2]; + u8 rbm; +--- a/drivers/net/wireless/ath/ath11k/hal.c ++++ b/drivers/net/wireless/ath/ath11k/hal.c +@@ -571,7 +571,7 @@ u32 ath11k_hal_ce_get_desc_size(enum hal + void ath11k_hal_ce_src_set_desc(void *buf, dma_addr_t paddr, u32 len, u32 id, + u8 byte_swap_data) + { +- struct hal_ce_srng_src_desc *desc = (struct hal_ce_srng_src_desc *)buf; ++ struct hal_ce_srng_src_desc *desc = buf; + + desc->buffer_addr_low = paddr & HAL_ADDR_LSB_REG_MASK; + desc->buffer_addr_info = +@@ -586,8 +586,7 @@ void ath11k_hal_ce_src_set_desc(void *bu + + void ath11k_hal_ce_dst_set_desc(void *buf, dma_addr_t paddr) + { +- struct hal_ce_srng_dest_desc *desc = +- (struct hal_ce_srng_dest_desc *)buf; ++ struct hal_ce_srng_dest_desc *desc = buf; + + desc->buffer_addr_low = paddr & HAL_ADDR_LSB_REG_MASK; + desc->buffer_addr_info = +@@ -597,8 +596,7 @@ void ath11k_hal_ce_dst_set_desc(void *bu + + u32 ath11k_hal_ce_dst_status_get_length(void *buf) + { +- struct hal_ce_srng_dst_status_desc *desc = +- (struct hal_ce_srng_dst_status_desc *)buf; ++ struct hal_ce_srng_dst_status_desc *desc = buf; + u32 len; + + len = FIELD_GET(HAL_CE_DST_STATUS_DESC_FLAGS_LEN, desc->flags); +--- a/drivers/net/wireless/ath/ath11k/hal_rx.c ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.c +@@ -265,7 +265,7 @@ out: + void ath11k_hal_rx_buf_addr_info_set(void *desc, dma_addr_t paddr, + u32 cookie, u8 manager) + { +- struct ath11k_buffer_addr *binfo = (struct ath11k_buffer_addr *)desc; ++ struct ath11k_buffer_addr *binfo = desc; + u32 paddr_lo, paddr_hi; + + paddr_lo = lower_32_bits(paddr); +@@ -279,7 +279,7 @@ void ath11k_hal_rx_buf_addr_info_set(voi + void ath11k_hal_rx_buf_addr_info_get(void *desc, dma_addr_t *paddr, + u32 *cookie, u8 *rbm) + { +- struct ath11k_buffer_addr *binfo = (struct ath11k_buffer_addr *)desc; ++ struct ath11k_buffer_addr *binfo = desc; + + *paddr = + (((u64)FIELD_GET(BUFFER_ADDR_INFO1_ADDR, binfo->info1)) << 32) | +@@ -292,7 +292,7 @@ void ath11k_hal_rx_msdu_link_info_get(vo + u32 *msdu_cookies, + enum hal_rx_buf_return_buf_manager *rbm) + { +- struct hal_rx_msdu_link *link = (struct hal_rx_msdu_link *)link_desc; ++ struct hal_rx_msdu_link *link = link_desc; + struct hal_rx_msdu_details *msdu; + int i; + +@@ -699,7 +699,7 @@ u32 ath11k_hal_reo_qdesc_size(u32 ba_win + void ath11k_hal_reo_qdesc_setup(void *vaddr, int tid, u32 ba_window_size, + u32 start_seq, enum hal_pn_type type) + { +- struct hal_rx_reo_queue *qdesc = (struct hal_rx_reo_queue *)vaddr; ++ struct hal_rx_reo_queue *qdesc = vaddr; + struct hal_rx_reo_queue_ext *ext_desc; + + memset(qdesc, 0, sizeof(*qdesc)); +@@ -809,8 +809,7 @@ static inline void + ath11k_hal_rx_handle_ofdma_info(void *rx_tlv, + struct hal_rx_user_status *rx_user_status) + { +- struct hal_rx_ppdu_end_user_stats *ppdu_end_user = +- (struct hal_rx_ppdu_end_user_stats *)rx_tlv; ++ struct hal_rx_ppdu_end_user_stats *ppdu_end_user = rx_tlv; + + rx_user_status->ul_ofdma_user_v0_word0 = __le32_to_cpu(ppdu_end_user->info6); + +@@ -821,8 +820,7 @@ static inline void + ath11k_hal_rx_populate_byte_count(void *rx_tlv, void *ppduinfo, + struct hal_rx_user_status *rx_user_status) + { +- struct hal_rx_ppdu_end_user_stats *ppdu_end_user = +- (struct hal_rx_ppdu_end_user_stats *)rx_tlv; ++ struct hal_rx_ppdu_end_user_stats *ppdu_end_user = rx_tlv; + + rx_user_status->mpdu_ok_byte_count = + FIELD_GET(HAL_RX_PPDU_END_USER_STATS_INFO8_MPDU_OK_BYTE_COUNT, +@@ -1540,8 +1538,7 @@ void ath11k_hal_rx_reo_ent_buf_paddr_get + u32 *sw_cookie, void **pp_buf_addr, + u8 *rbm, u32 *msdu_cnt) + { +- struct hal_reo_entrance_ring *reo_ent_ring = +- (struct hal_reo_entrance_ring *)rx_desc; ++ struct hal_reo_entrance_ring *reo_ent_ring = rx_desc; + struct ath11k_buffer_addr *buf_addr_info; + struct rx_mpdu_desc *rx_mpdu_desc_info_details; + +--- a/drivers/net/wireless/ath/ath11k/hal_tx.c ++++ b/drivers/net/wireless/ath/ath11k/hal_tx.c +@@ -37,7 +37,7 @@ static const u8 dscp_tid_map[DSCP_TID_MA + void ath11k_hal_tx_cmd_desc_setup(struct ath11k_base *ab, void *cmd, + struct hal_tx_info *ti) + { +- struct hal_tcl_data_cmd *tcl_cmd = (struct hal_tcl_data_cmd *)cmd; ++ struct hal_tcl_data_cmd *tcl_cmd = cmd; + + tcl_cmd->buf_addr_info.info0 = + FIELD_PREP(BUFFER_ADDR_INFO0_ADDR, ti->paddr); +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -6970,8 +6970,8 @@ err: + + static int ath11k_mac_vif_unref(int buf_id, void *skb, void *ctx) + { +- struct ieee80211_vif *vif = (struct ieee80211_vif *)ctx; +- struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB((struct sk_buff *)skb); ++ struct ieee80211_vif *vif = ctx; ++ struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb); + + if (skb_cb->vif == vif) + skb_cb->vif = NULL; +--- a/drivers/net/wireless/ath/ath11k/spectral.c ++++ b/drivers/net/wireless/ath/ath11k/spectral.c +@@ -592,7 +592,7 @@ int ath11k_spectral_process_fft(struct a + return -EINVAL; + } + +- tlv = (struct spectral_tlv *)data; ++ tlv = data; + tlv_len = FIELD_GET(SPECTRAL_TLV_HDR_LEN, __le32_to_cpu(tlv->header)); + /* convert Dword into bytes */ + tlv_len *= ATH11K_SPECTRAL_DWORD_SIZE; +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -2281,7 +2281,7 @@ int ath11k_wmi_send_scan_start_cmd(struc + tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_UINT32) | + FIELD_PREP(WMI_TLV_LEN, len); + ptr += TLV_HDR_SIZE; +- tmp_ptr = (u32 *)ptr; ++ tmp_ptr = ptr; + + for (i = 0; i < params->num_chan; ++i) + tmp_ptr[i] = params->chan_list[i]; +@@ -4148,7 +4148,7 @@ static int ath11k_init_cmd_send(struct a + ptr += TLV_HDR_SIZE + len; + + if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) { +- hw_mode = (struct wmi_pdev_set_hw_mode_cmd_param *)ptr; ++ hw_mode = ptr; + hw_mode->tlv_header = FIELD_PREP(WMI_TLV_TAG, + WMI_TAG_PDEV_SET_HW_MODE_CMD) | + FIELD_PREP(WMI_TLV_LEN, +@@ -4168,7 +4168,7 @@ static int ath11k_init_cmd_send(struct a + len = sizeof(*band_to_mac); + + for (idx = 0; idx < param->num_band_to_mac; idx++) { +- band_to_mac = (void *)ptr; ++ band_to_mac = ptr; + + band_to_mac->tlv_header = FIELD_PREP(WMI_TLV_TAG, + WMI_TAG_PDEV_BAND_TO_MAC) | diff --git a/package/kernel/mac80211/patches/ath11k/0023-wifi-ath11k-fix-ath11k_mac_op_remain_on_channel-stac.patch b/package/kernel/mac80211/patches/ath11k/0023-wifi-ath11k-fix-ath11k_mac_op_remain_on_channel-stac.patch new file mode 100644 index 00000000000..2c7f196f8ee --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0023-wifi-ath11k-fix-ath11k_mac_op_remain_on_channel-stac.patch @@ -0,0 +1,96 @@ +From 4fd15bb705d3faa7e6adab2daba2e3af80d9b6bd Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov <dmantipov@yandex.ru> +Date: Tue, 26 Sep 2023 07:29:04 +0300 +Subject: [PATCH] wifi: ath11k: fix ath11k_mac_op_remain_on_channel() stack + usage + +When compiling with clang 16.0.6, I've noticed the following: + +drivers/net/wireless/ath/ath11k/mac.c:8903:12: warning: stack frame +size (1032) exceeds limit (1024) in 'ath11k_mac_op_remain_on_channel' +[-Wframe-larger-than] +static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw, + ^ +68/1032 (6.59%) spills, 964/1032 (93.41%) variables + +So switch to kzalloc()'ed instance of 'struct scan_req_params' like +it's done in 'ath11k_mac_op_hw_scan()'. Compile tested only. + +Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230926042906.13725-1-dmantipov@yandex.ru +--- + drivers/net/wireless/ath/ath11k/mac.c | 44 +++++++++++++++------------ + 1 file changed, 25 insertions(+), 19 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -8908,7 +8908,7 @@ static int ath11k_mac_op_remain_on_chann + { + struct ath11k *ar = hw->priv; + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); +- struct scan_req_params arg; ++ struct scan_req_params *arg; + int ret; + u32 scan_time_msec; + +@@ -8940,27 +8940,31 @@ static int ath11k_mac_op_remain_on_chann + + scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2; + +- memset(&arg, 0, sizeof(arg)); +- ath11k_wmi_start_scan_init(ar, &arg); +- arg.num_chan = 1; +- arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list), +- GFP_KERNEL); +- if (!arg.chan_list) { ++ arg = kzalloc(sizeof(*arg), GFP_KERNEL); ++ if (!arg) { + ret = -ENOMEM; + goto exit; + } ++ ath11k_wmi_start_scan_init(ar, arg); ++ arg->num_chan = 1; ++ arg->chan_list = kcalloc(arg->num_chan, sizeof(*arg->chan_list), ++ GFP_KERNEL); ++ if (!arg->chan_list) { ++ ret = -ENOMEM; ++ goto free_arg; ++ } + +- arg.vdev_id = arvif->vdev_id; +- arg.scan_id = ATH11K_SCAN_ID; +- arg.chan_list[0] = chan->center_freq; +- arg.dwell_time_active = scan_time_msec; +- arg.dwell_time_passive = scan_time_msec; +- arg.max_scan_time = scan_time_msec; +- arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE; +- arg.scan_flags |= WMI_SCAN_FILTER_PROBE_REQ; +- arg.burst_duration = duration; ++ arg->vdev_id = arvif->vdev_id; ++ arg->scan_id = ATH11K_SCAN_ID; ++ arg->chan_list[0] = chan->center_freq; ++ arg->dwell_time_active = scan_time_msec; ++ arg->dwell_time_passive = scan_time_msec; ++ arg->max_scan_time = scan_time_msec; ++ arg->scan_flags |= WMI_SCAN_FLAG_PASSIVE; ++ arg->scan_flags |= WMI_SCAN_FILTER_PROBE_REQ; ++ arg->burst_duration = duration; + +- ret = ath11k_start_scan(ar, &arg); ++ ret = ath11k_start_scan(ar, arg); + if (ret) { + ath11k_warn(ar->ab, "failed to start roc scan: %d\n", ret); + +@@ -8986,7 +8990,9 @@ static int ath11k_mac_op_remain_on_chann + ret = 0; + + free_chan_list: +- kfree(arg.chan_list); ++ kfree(arg->chan_list); ++free_arg: ++ kfree(arg); + exit: + mutex_unlock(&ar->conf_mutex); + return ret; diff --git a/package/kernel/mac80211/patches/ath11k/0024-wifi-ath11k-mac-fix-struct-ieee80211_sband_iftype_da.patch b/package/kernel/mac80211/patches/ath11k/0024-wifi-ath11k-mac-fix-struct-ieee80211_sband_iftype_da.patch new file mode 100644 index 00000000000..90da6a8c44a --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0024-wifi-ath11k-mac-fix-struct-ieee80211_sband_iftype_da.patch @@ -0,0 +1,67 @@ +From 9e61589ac3c2d23c528d3ffd44604d98553ea1cb Mon Sep 17 00:00:00 2001 +From: Kalle Valo <quic_kvalo@quicinc.com> +Date: Wed, 27 Sep 2023 17:27:08 +0300 +Subject: [PATCH] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data + handling + +Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer with +sparse") added sparse checks for struct ieee80211_sband_iftype_data handling +which immediately found an issue in ath11k: + +drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect type in argument 1 (different address spaces) +drivers/net/wireless/ath/ath11k/mac.c:7952:22: expected struct ieee80211_sta_he_cap const *he_cap +drivers/net/wireless/ath/ath11k/mac.c:7952:22: got struct ieee80211_sta_he_cap const [noderef] __iftype_data * + +The problem here is that we are accessing sband->iftype_data directly even +though we should use for_each_sband_iftype_data() or similar. Fortunately +there's ieee80211_get_he_iftype_cap_vif() which is just what we need here so +use it to get HE capabilities. + +Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 + +Reported-by: Johannes Berg <johannes@sipsolutions.net> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230927142708.2897504-2-kvalo@kernel.org +--- + drivers/net/wireless/ath/ath11k/mac.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -7913,12 +7913,14 @@ ath11k_mac_get_tx_mcs_map(const struct i + + static bool + ath11k_mac_bitrate_mask_get_single_nss(struct ath11k *ar, ++ struct ath11k_vif *arvif, + enum nl80211_band band, + const struct cfg80211_bitrate_mask *mask, + int *nss) + { + struct ieee80211_supported_band *sband = &ar->mac.sbands[band]; + u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); ++ const struct ieee80211_sta_he_cap *he_cap; + u16 he_mcs_map = 0; + u8 ht_nss_mask = 0; + u8 vht_nss_mask = 0; +@@ -7949,7 +7951,11 @@ ath11k_mac_bitrate_mask_get_single_nss(s + return false; + } + +- he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap)); ++ he_cap = ieee80211_get_he_iftype_cap_vif(sband, arvif->vif); ++ if (!he_cap) ++ return false; ++ ++ he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(he_cap)); + + for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) { + if (mask->control[band].he_mcs[i] == 0) +@@ -8365,7 +8371,7 @@ ath11k_mac_op_set_bitrate_mask(struct ie + ieee80211_iterate_stations_atomic(ar->hw, + ath11k_mac_disable_peer_fixed_rate, + arvif); +- } else if (ath11k_mac_bitrate_mask_get_single_nss(ar, band, mask, ++ } else if (ath11k_mac_bitrate_mask_get_single_nss(ar, arvif, band, mask, + &single_nss)) { + rate = WMI_FIXED_RATE_NONE; + nss = single_nss; diff --git a/package/kernel/mac80211/patches/ath11k/0025-wifi-ath11k-fix-CAC-running-state-during-virtual-int.patch b/package/kernel/mac80211/patches/ath11k/0025-wifi-ath11k-fix-CAC-running-state-during-virtual-int.patch new file mode 100644 index 00000000000..eee0bf0fb5a --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0025-wifi-ath11k-fix-CAC-running-state-during-virtual-int.patch @@ -0,0 +1,80 @@ +From 69fcb525905600a151997cd16367bb92c34a2b14 Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Tue, 3 Oct 2023 17:26:54 +0300 +Subject: [PATCH] wifi: ath11k: fix CAC running state during virtual interface + start + +Currently channel definition's primary channel's DFS CAC time +as well as primary channel's state i.e usable are used to set +the CAC_RUNNING flag for the ath11k radio structure. However, +this is wrong since certain channel definition are possbile +where primary channel may not be a DFS channel but, secondary +channel is a DFS channel. For example - channel 36 with 160 MHz +bandwidth. +In such cases, the flag will not be set which is wrong. + +Fix this issue by using cfg80211_chandef_dfs_usable() function +from cfg80211 which return trues if at least one channel is in +usable state. + +While at it, modify the CAC running debug log message to print +the CAC time as well in milli-seconds. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230912051857.2284-3-quic_adisi@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -5,6 +5,7 @@ + */ + + #include <net/mac80211.h> ++#include <net/cfg80211.h> + #include <linux/etherdevice.h> + #include <linux/bitfield.h> + #include <linux/inetdevice.h> +@@ -7196,6 +7197,7 @@ ath11k_mac_vdev_start_restart(struct ath + struct wmi_vdev_start_req_arg arg = {}; + const struct cfg80211_chan_def *chandef = &ctx->def; + int ret = 0; ++ unsigned int dfs_cac_time; + + lockdep_assert_held(&ar->conf_mutex); + +@@ -7275,20 +7277,21 @@ ath11k_mac_vdev_start_restart(struct ath + ath11k_dbg(ab, ATH11K_DBG_MAC, "vdev %pM started, vdev_id %d\n", + arvif->vif->addr, arvif->vdev_id); + +- /* Enable CAC Flag in the driver by checking the channel DFS cac time, +- * i.e dfs_cac_ms value which will be valid only for radar channels +- * and state as NL80211_DFS_USABLE which indicates CAC needs to be ++ /* Enable CAC Flag in the driver by checking the all sub-channel's DFS ++ * state as NL80211_DFS_USABLE which indicates CAC needs to be + * done before channel usage. This flags is used to drop rx packets. + * during CAC. + */ + /* TODO Set the flag for other interface types as required */ +- if (arvif->vdev_type == WMI_VDEV_TYPE_AP && +- chandef->chan->dfs_cac_ms && +- chandef->chan->dfs_state == NL80211_DFS_USABLE) { ++ if (arvif->vdev_type == WMI_VDEV_TYPE_AP && ctx->radar_enabled && ++ cfg80211_chandef_dfs_usable(ar->hw->wiphy, chandef)) { + set_bit(ATH11K_CAC_RUNNING, &ar->dev_flags); ++ dfs_cac_time = cfg80211_chandef_dfs_cac_time(ar->hw->wiphy, ++ chandef); + ath11k_dbg(ab, ATH11K_DBG_MAC, +- "CAC Started in chan_freq %d for vdev %d\n", +- arg.channel.freq, arg.vdev_id); ++ "cac started dfs_cac_time %u center_freq %d center_freq1 %d for vdev %d\n", ++ dfs_cac_time, arg.channel.freq, chandef->center_freq1, ++ arg.vdev_id); + } + + ret = ath11k_mac_set_txbf_conf(arvif); diff --git a/package/kernel/mac80211/patches/ath11k/0026-wifi-ath11k-fix-Tx-power-value-during-active-CAC.patch b/package/kernel/mac80211/patches/ath11k/0026-wifi-ath11k-fix-Tx-power-value-during-active-CAC.patch new file mode 100644 index 00000000000..79c1d735b82 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0026-wifi-ath11k-fix-Tx-power-value-during-active-CAC.patch @@ -0,0 +1,43 @@ +From 77f1ee6fd8b6e470f721d05a2e269039d5cafcb7 Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Tue, 3 Oct 2023 17:26:54 +0300 +Subject: [PATCH] wifi: ath11k: fix Tx power value during active CAC + +Tx power is fetched from firmware's pdev stats. However, during active +CAC, firmware does not fill the current Tx power and sends the max +initialised value filled during firmware init. If host sends this power +to user space, this is wrong since in certain situations, the Tx power +could be greater than the max allowed by the regulatory. Hence, host +should not be fetching the Tx power during an active CAC. + +Fix this issue by returning -EAGAIN error so that user space knows that there's +no valid value available. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Fixes: 9a2aa68afe3d ("wifi: ath11k: add get_txpower mac ops") +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20230912051857.2284-4-quic_adisi@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -9060,6 +9060,14 @@ static int ath11k_mac_op_get_txpower(str + if (ar->state != ATH11K_STATE_ON) + goto err_fallback; + ++ /* Firmware doesn't provide Tx power during CAC hence no need to fetch ++ * the stats. ++ */ ++ if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) { ++ mutex_unlock(&ar->conf_mutex); ++ return -EAGAIN; ++ } ++ + req_param.pdev_id = ar->pdev->pdev_id; + req_param.stats_id = WMI_REQUEST_PDEV_STAT; + diff --git a/package/kernel/mac80211/patches/ath11k/0027-wifi-ath11k-call-ath11k_mac_fils_discovery-without-c.patch b/package/kernel/mac80211/patches/ath11k/0027-wifi-ath11k-call-ath11k_mac_fils_discovery-without-c.patch new file mode 100644 index 00000000000..d233492513d --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0027-wifi-ath11k-call-ath11k_mac_fils_discovery-without-c.patch @@ -0,0 +1,37 @@ +From e149353e6562f3e3246f75dfc4cca6a0cc5b4efc Mon Sep 17 00:00:00 2001 +From: Aloka Dixit <quic_alokad@quicinc.com> +Date: Mon, 9 Oct 2023 10:13:54 +0300 +Subject: [PATCH] wifi: ath11k: call ath11k_mac_fils_discovery() without + condition + +Mac80211 does not set flags BSS_CHANGED_FILS_DISCOVERY and +BSS_CHANGED_UNSOL_BCAST_PROBE_RESP if there are no updates to +FILS discovery and unsolicited broadcast probe response transmission +configurations respectively. This results in the transmissions getting +stopped during BSS change operations which do not include these +attributes. Remove the checks for the flags and always send the existing +configuration to firmware. + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20231004044915.6817-1-quic_alokad@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -3732,9 +3732,7 @@ static void ath11k_mac_op_bss_info_chang + arvif->vdev_id, ret); + } + +- if (changed & BSS_CHANGED_FILS_DISCOVERY || +- changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP) +- ath11k_mac_fils_discovery(arvif, info); ++ ath11k_mac_fils_discovery(arvif, info); + + if (changed & BSS_CHANGED_ARP_FILTER) { + ipv4_cnt = min(vif->cfg.arp_addr_cnt, ATH11K_IPV4_MAX_COUNT); diff --git a/package/kernel/mac80211/patches/ath11k/0028-wifi-ath11k-ath11k_debugfs_register-fix-format-trunc.patch b/package/kernel/mac80211/patches/ath11k/0028-wifi-ath11k-ath11k_debugfs_register-fix-format-trunc.patch new file mode 100644 index 00000000000..df8a4283fae --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0028-wifi-ath11k-ath11k_debugfs_register-fix-format-trunc.patch @@ -0,0 +1,39 @@ +From a47111663491ff2829df0626493ce81b48dd880a Mon Sep 17 00:00:00 2001 +From: Kalle Valo <quic_kvalo@quicinc.com> +Date: Tue, 10 Oct 2023 09:22:50 +0300 +Subject: [PATCH] wifi: ath11k: ath11k_debugfs_register(): fix + format-truncation warning + +In v6.6-rc4 with GCC 13.2 I see a new warning: + +drivers/net/wireless/ath/ath11k/debugfs.c: In function 'ath11k_debugfs_register': +drivers/net/wireless/ath/ath11k/debugfs.c:1597:51: error: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Werror=format-truncation=] +drivers/net/wireless/ath/ath11k/debugfs.c:1597:48: note: directive argument in the range [0, 255] +drivers/net/wireless/ath/ath11k/debugfs.c:1597:9: note: 'snprintf' output between 5 and 7 bytes into a destination of size 5 + +Increase the size of pdev_name to 10 bytes to make sure there's enough room for +the string. Also change the format to '%u' as ar->pdev_idx is u8. + +Compile tested only. + +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20231010062250.2580951-1-kvalo@kernel.org +--- + drivers/net/wireless/ath/ath11k/debugfs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/debugfs.c ++++ b/drivers/net/wireless/ath/ath11k/debugfs.c +@@ -1591,10 +1591,10 @@ static const struct file_operations fops + int ath11k_debugfs_register(struct ath11k *ar) + { + struct ath11k_base *ab = ar->ab; +- char pdev_name[5]; ++ char pdev_name[10]; + char buf[100] = {0}; + +- snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx); ++ snprintf(pdev_name, sizeof(pdev_name), "%s%u", "mac", ar->pdev_idx); + + ar->debug.debugfs_pdev = debugfs_create_dir(pdev_name, ab->debugfs_soc); + if (IS_ERR(ar->debug.debugfs_pdev)) diff --git a/package/kernel/mac80211/patches/ath11k/0029-wifi-ath11k-add-parsing-of-phy-bitmap-for-reg-rules.patch b/package/kernel/mac80211/patches/ath11k/0029-wifi-ath11k-add-parsing-of-phy-bitmap-for-reg-rules.patch new file mode 100644 index 00000000000..10d517a27a5 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0029-wifi-ath11k-add-parsing-of-phy-bitmap-for-reg-rules.patch @@ -0,0 +1,84 @@ +From 534c2dd8099a9cc4bad8ea8b3c7fa1f730e10d5d Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Tue, 10 Oct 2023 10:27:19 +0300 +Subject: [PATCH] wifi: ath11k: add parsing of phy bitmap for reg rules + +Certain regulatory domains could put restrictions on phy mode operation. +For example, in a few countries HE Operation is not allowed. For such +countries, firmware indicates this via phy bitmap in each reg rule. + +Currently, there is no logic to parse this info and then pass it on to the +cfg80211/regulatory. + +Add parsing of this phy bitmap from the regulatory channel change event and +then accordingly map it to cfg80211/regulatory flags and pass it on to it. + +While at it, correct typo in debug print s/dsf/dfs. + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20231004092655.25020-1-quic_adisi@quicinc.com +--- + drivers/net/wireless/ath/ath11k/reg.c | 11 +++++++++++ + drivers/net/wireless/ath/ath11k/reg.h | 3 +++ + drivers/net/wireless/ath/ath11k/wmi.c | 5 +++-- + 3 files changed, 17 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/reg.c ++++ b/drivers/net/wireless/ath/ath11k/reg.c +@@ -352,6 +352,16 @@ static u32 ath11k_map_fw_reg_flags(u16 r + return flags; + } + ++static u32 ath11k_map_fw_phy_flags(u32 phy_flags) ++{ ++ u32 flags = 0; ++ ++ if (phy_flags & ATH11K_REG_PHY_BITMAP_NO11AX) ++ flags |= NL80211_RRF_NO_HE; ++ ++ return flags; ++} ++ + static bool + ath11k_reg_can_intersect(struct ieee80211_reg_rule *rule1, + struct ieee80211_reg_rule *rule2) +@@ -685,6 +695,7 @@ ath11k_reg_build_regd(struct ath11k_base + } + + flags |= ath11k_map_fw_reg_flags(reg_rule->flags); ++ flags |= ath11k_map_fw_phy_flags(reg_info->phybitmap); + + ath11k_reg_update_rule(tmp_regd->reg_rules + i, + reg_rule->start_freq, +--- a/drivers/net/wireless/ath/ath11k/reg.h ++++ b/drivers/net/wireless/ath/ath11k/reg.h +@@ -24,6 +24,9 @@ enum ath11k_dfs_region { + ATH11K_DFS_REG_UNDEF, + }; + ++/* Phy bitmaps */ ++#define ATH11K_REG_PHY_BITMAP_NO11AX BIT(5) ++ + /* ATH11K Regulatory API's */ + void ath11k_reg_init(struct ath11k *ar); + void ath11k_reg_free(struct ath11k_base *ab); +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -5440,10 +5440,11 @@ static int ath11k_pull_reg_chan_list_ext + } + + ath11k_dbg(ab, ATH11K_DBG_WMI, +- "cc_ext %s dsf %d BW: min_2ghz %d max_2ghz %d min_5ghz %d max_5ghz %d", ++ "cc_ext %s dfs %d BW: min_2ghz %d max_2ghz %d min_5ghz %d max_5ghz %d phy_bitmap 0x%x", + reg_info->alpha2, reg_info->dfs_region, + reg_info->min_bw_2ghz, reg_info->max_bw_2ghz, +- reg_info->min_bw_5ghz, reg_info->max_bw_5ghz); ++ reg_info->min_bw_5ghz, reg_info->max_bw_5ghz, ++ reg_info->phybitmap); + + ath11k_dbg(ab, ATH11K_DBG_WMI, + "num_2ghz_reg_rules %d num_5ghz_reg_rules %d", diff --git a/package/kernel/mac80211/patches/ath11k/0030-wifi-ath11k-Remove-unused-struct-ath11k_htc_frame.patch b/package/kernel/mac80211/patches/ath11k/0030-wifi-ath11k-Remove-unused-struct-ath11k_htc_frame.patch new file mode 100644 index 00000000000..df4235388a5 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0030-wifi-ath11k-Remove-unused-struct-ath11k_htc_frame.patch @@ -0,0 +1,38 @@ +From 480d230bef0ecd06e72ae3a84117142e38e77503 Mon Sep 17 00:00:00 2001 +From: Jeff Johnson <quic_jjohnson@quicinc.com> +Date: Mon, 9 Oct 2023 09:36:54 -0700 +Subject: [PATCH] wifi: ath11k: Remove unused struct ath11k_htc_frame + +struct ath11k_htc_frame is unused, and since it illogically contains +two consecutive flexible arrays, it could never be used, so remove it. + +No functional changes, compile tested only. + +Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20231009-ath11k_htc_frame-v1-1-81d405b7a195@quicinc.com +--- + drivers/net/wireless/ath/ath11k/htc.h | 12 ------------ + 1 file changed, 12 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/htc.h ++++ b/drivers/net/wireless/ath/ath11k/htc.h +@@ -156,18 +156,6 @@ struct ath11k_htc_record { + }; + } __packed __aligned(4); + +-/* note: the trailer offset is dynamic depending +- * on payload length. this is only a struct layout draft +- */ +-struct ath11k_htc_frame { +- struct ath11k_htc_hdr hdr; +- union { +- struct ath11k_htc_msg msg; +- u8 payload[0]; +- }; +- struct ath11k_htc_record trailer[0]; +-} __packed __aligned(4); +- + enum ath11k_htc_svc_gid { + ATH11K_HTC_SVC_GRP_RSVD = 0, + ATH11K_HTC_SVC_GRP_WMI = 1, diff --git a/package/kernel/mac80211/patches/ath11k/0031-wifi-ath11k-Introduce-and-use-ath11k_sta_to_arsta.patch b/package/kernel/mac80211/patches/ath11k/0031-wifi-ath11k-Introduce-and-use-ath11k_sta_to_arsta.patch new file mode 100644 index 00000000000..59af3b92979 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0031-wifi-ath11k-Introduce-and-use-ath11k_sta_to_arsta.patch @@ -0,0 +1,384 @@ +From 10c65f97b424fcee439463f933140df2a0022f98 Mon Sep 17 00:00:00 2001 +From: Jeff Johnson <quic_jjohnson@quicinc.com> +Date: Mon, 9 Oct 2023 09:39:42 -0700 +Subject: [PATCH] wifi: ath11k: Introduce and use ath11k_sta_to_arsta() + +Currently, the logic to return an ath11k_sta pointer, given a +ieee80211_sta pointer, uses typecasting throughout the driver. In +general, conversion functions are preferable to typecasting since +using a conversion function allows the compiler to validate the types +of both the input and output parameters. + +ath11k already defines a conversion function ath11k_vif_to_arvif() for +a similar conversion. So introduce ath11k_sta_to_arsta() for this use +case, and convert all of the existing typecasting to use this +function. + +No functional changes, compile tested only. + +Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> +Link: https://lore.kernel.org/r/20231009-ath11k_sta_to_arsta-v1-1-1563e3a307e8@quicinc.com +--- + drivers/net/wireless/ath/ath11k/core.h | 5 ++++ + drivers/net/wireless/ath/ath11k/debugfs.c | 4 +-- + drivers/net/wireless/ath/ath11k/debugfs_sta.c | 30 +++++++++---------- + drivers/net/wireless/ath/ath11k/dp_rx.c | 8 ++--- + drivers/net/wireless/ath/ath11k/dp_tx.c | 4 +-- + drivers/net/wireless/ath/ath11k/mac.c | 18 +++++------ + drivers/net/wireless/ath/ath11k/peer.c | 2 +- + drivers/net/wireless/ath/ath11k/wmi.c | 6 ++-- + 8 files changed, 41 insertions(+), 36 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/core.h ++++ b/drivers/net/wireless/ath/ath11k/core.h +@@ -1223,6 +1223,11 @@ static inline struct ath11k_vif *ath11k_ + return (struct ath11k_vif *)vif->drv_priv; + } + ++static inline struct ath11k_sta *ath11k_sta_to_arsta(struct ieee80211_sta *sta) ++{ ++ return (struct ath11k_sta *)sta->drv_priv; ++} ++ + static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab, + int mac_id) + { +--- a/drivers/net/wireless/ath/ath11k/debugfs.c ++++ b/drivers/net/wireless/ath/ath11k/debugfs.c +@@ -1459,7 +1459,7 @@ static void ath11k_reset_peer_ps_duratio + struct ieee80211_sta *sta) + { + struct ath11k *ar = data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + + spin_lock_bh(&ar->data_lock); + arsta->ps_total_duration = 0; +@@ -1510,7 +1510,7 @@ static void ath11k_peer_ps_state_disable + struct ieee80211_sta *sta) + { + struct ath11k *ar = data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + + spin_lock_bh(&ar->data_lock); + arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED; +--- a/drivers/net/wireless/ath/ath11k/debugfs_sta.c ++++ b/drivers/net/wireless/ath/ath11k/debugfs_sta.c +@@ -136,7 +136,7 @@ static ssize_t ath11k_dbg_sta_dump_tx_st + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + struct ath11k_htt_data_stats *stats; + static const char *str_name[ATH11K_STATS_TYPE_MAX] = {"succ", "fail", +@@ -243,7 +243,7 @@ static ssize_t ath11k_dbg_sta_dump_rx_st + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + struct ath11k_rx_peer_stats *rx_stats = arsta->rx_stats; + int len = 0, i, retval = 0; +@@ -340,7 +340,7 @@ static int + ath11k_dbg_sta_open_htt_peer_stats(struct inode *inode, struct file *file) + { + struct ieee80211_sta *sta = inode->i_private; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + struct debug_htt_stats_req *stats_req; + int type = ar->debug.htt_stats.type; +@@ -376,7 +376,7 @@ static int + ath11k_dbg_sta_release_htt_peer_stats(struct inode *inode, struct file *file) + { + struct ieee80211_sta *sta = inode->i_private; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + + mutex_lock(&ar->conf_mutex); +@@ -413,7 +413,7 @@ static ssize_t ath11k_dbg_sta_write_peer + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + int ret, enable; + +@@ -453,7 +453,7 @@ static ssize_t ath11k_dbg_sta_read_peer_ + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + char buf[32] = {0}; + int len; +@@ -480,7 +480,7 @@ static ssize_t ath11k_dbg_sta_write_delb + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + u32 tid, initiator, reason; + int ret; +@@ -531,7 +531,7 @@ static ssize_t ath11k_dbg_sta_write_addb + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + u32 tid, status; + int ret; +@@ -581,7 +581,7 @@ static ssize_t ath11k_dbg_sta_write_addb + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + u32 tid, buf_size; + int ret; +@@ -632,7 +632,7 @@ static ssize_t ath11k_dbg_sta_read_aggr_ + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + char buf[64]; + int len = 0; +@@ -652,7 +652,7 @@ static ssize_t ath11k_dbg_sta_write_aggr + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + u32 aggr_mode; + int ret; +@@ -697,7 +697,7 @@ ath11k_write_htt_peer_stats_reset(struct + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + struct htt_ext_stats_cfg_params cfg_params = { 0 }; + int ret; +@@ -756,7 +756,7 @@ static ssize_t ath11k_dbg_sta_read_peer_ + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + char buf[20]; + int len; +@@ -783,7 +783,7 @@ static ssize_t ath11k_dbg_sta_read_curre + loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + u64 time_since_station_in_power_save; + char buf[20]; +@@ -817,7 +817,7 @@ static ssize_t ath11k_dbg_sta_read_total + size_t count, loff_t *ppos) + { + struct ieee80211_sta *sta = file->private_data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + char buf[20]; + u64 power_save_duration; +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -1099,7 +1099,7 @@ int ath11k_dp_rx_ampdu_start(struct ath1 + struct ieee80211_ampdu_params *params) + { + struct ath11k_base *ab = ar->ab; +- struct ath11k_sta *arsta = (void *)params->sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta); + int vdev_id = arsta->arvif->vdev_id; + int ret; + +@@ -1117,7 +1117,7 @@ int ath11k_dp_rx_ampdu_stop(struct ath11 + { + struct ath11k_base *ab = ar->ab; + struct ath11k_peer *peer; +- struct ath11k_sta *arsta = (void *)params->sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta); + int vdev_id = arsta->arvif->vdev_id; + dma_addr_t paddr; + bool active; +@@ -1456,7 +1456,7 @@ ath11k_update_per_peer_tx_stats(struct a + } + + sta = peer->sta; +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + memset(&arsta->txrate, 0, sizeof(arsta->txrate)); + +@@ -5242,7 +5242,7 @@ int ath11k_dp_rx_process_mon_status(stru + goto next_skb; + } + +- arsta = (struct ath11k_sta *)peer->sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(peer->sta); + ath11k_dp_rx_update_peer_stats(arsta, ppdu_info); + + if (ath11k_debugfs_is_pktlog_peer_valid(ar, peer->addr)) +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -467,7 +467,7 @@ void ath11k_dp_tx_update_txcompl(struct + } + + sta = peer->sta; +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + memset(&arsta->txrate, 0, sizeof(arsta->txrate)); + pkt_type = FIELD_GET(HAL_TX_RATE_STATS_INFO0_PKT_TYPE, +@@ -627,7 +627,7 @@ static void ath11k_dp_tx_complete_msdu(s + ieee80211_free_txskb(ar->hw, msdu); + return; + } +- arsta = (struct ath11k_sta *)peer->sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(peer->sta); + status.sta = peer->sta; + status.skb = msdu; + status.info = info; +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -2832,7 +2832,7 @@ static void ath11k_peer_assoc_prepare(st + + lockdep_assert_held(&ar->conf_mutex); + +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + memset(arg, 0, sizeof(*arg)); + +@@ -4313,7 +4313,7 @@ static int ath11k_mac_op_set_key(struct + ath11k_warn(ab, "peer %pM disappeared!\n", peer_addr); + + if (sta) { +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: +@@ -4904,7 +4904,7 @@ static int ath11k_mac_station_add(struct + { + struct ath11k_base *ab = ar->ab; + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct peer_create_params peer_param; + int ret; + +@@ -5028,7 +5028,7 @@ static int ath11k_mac_op_sta_state(struc + { + struct ath11k *ar = hw->priv; + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k_peer *peer; + int ret = 0; + +@@ -5194,7 +5194,7 @@ static void ath11k_mac_op_sta_set_4addr( + struct ieee80211_sta *sta, bool enabled) + { + struct ath11k *ar = hw->priv; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + + if (enabled && !arsta->use_4addr_set) { + ieee80211_queue_work(ar->hw, &arsta->set_4addr_wk); +@@ -5208,7 +5208,7 @@ static void ath11k_mac_op_sta_rc_update( + u32 changed) + { + struct ath11k *ar = hw->priv; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); + struct ath11k_peer *peer; + u32 bw, smps; +@@ -6201,7 +6201,7 @@ static void ath11k_mac_op_tx(struct ieee + } + + if (control->sta) +- arsta = (struct ath11k_sta *)control->sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(control->sta); + + ret = ath11k_dp_tx(ar, arvif, arsta, skb); + if (unlikely(ret)) { +@@ -8233,7 +8233,7 @@ static void ath11k_mac_set_bitrate_mask_ + struct ieee80211_sta *sta) + { + struct ath11k_vif *arvif = data; +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arvif->ar; + + spin_lock_bh(&ar->data_lock); +@@ -8637,7 +8637,7 @@ static void ath11k_mac_op_sta_statistics + struct ieee80211_sta *sta, + struct station_info *sinfo) + { +- struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; ++ struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta); + struct ath11k *ar = arsta->arvif->ar; + s8 signal; + bool db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT, +--- a/drivers/net/wireless/ath/ath11k/peer.c ++++ b/drivers/net/wireless/ath/ath11k/peer.c +@@ -446,7 +446,7 @@ int ath11k_peer_create(struct ath11k *ar + peer->sec_type_grp = HAL_ENCRYPT_TYPE_OPEN; + + if (sta) { +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + arsta->tcl_metadata |= FIELD_PREP(HTT_TCL_META_DATA_TYPE, 0) | + FIELD_PREP(HTT_TCL_META_DATA_PEER_ID, + peer->peer_id); +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -6453,7 +6453,7 @@ static int ath11k_wmi_tlv_rssi_chain_par + goto exit; + } + +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + BUILD_BUG_ON(ARRAY_SIZE(arsta->chain_signal) > + ARRAY_SIZE(stats_rssi->rssi_avg_beacon)); +@@ -6541,7 +6541,7 @@ static int ath11k_wmi_tlv_fw_stats_data_ + arvif->bssid, + NULL); + if (sta) { +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + arsta->rssi_beacon = src->beacon_snr; + ath11k_dbg(ab, ATH11K_DBG_WMI, + "stats vdev id %d snr %d\n", +@@ -7468,7 +7468,7 @@ static void ath11k_wmi_event_peer_sta_ps + goto exit; + } + +- arsta = (struct ath11k_sta *)sta->drv_priv; ++ arsta = ath11k_sta_to_arsta(sta); + + spin_lock_bh(&ar->data_lock); + diff --git a/package/kernel/mac80211/patches/ath11k/100-wifi-ath11k-use-unique-QRTR-instance-ID.patch b/package/kernel/mac80211/patches/ath11k/100-wifi-ath11k-use-unique-QRTR-instance-ID.patch new file mode 100644 index 00000000000..30472b32298 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/100-wifi-ath11k-use-unique-QRTR-instance-ID.patch @@ -0,0 +1,162 @@ +From 534a5f99d589cfa6b244b4433c192b6a278a67ff Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Sat, 5 Nov 2022 20:15:40 +0100 +Subject: [PATCH] wifi: ath11k: use unique QRTR instance ID + +Currently, trying to use AHB + PCI/MHI cards or multiple PCI/MHI cards +will cause a clash in the QRTR instance node ID and prevent the driver +from talking via QMI to the card and thus initializing it with: +[ 9.836329] ath11k c000000.wifi: host capability request failed: 1 90 +[ 9.842047] ath11k c000000.wifi: failed to send qmi host cap: -22 + +So, in order to allow for this combination of cards, especially AHB + PCI +cards like IPQ8074 + QCN9074 (Used by me and tested on) set the desired +QRTR instance ID offset by calculating a unique one based on PCI domain +and bus ID-s and writing it to bits 7-0 of BHI_ERRDBG2 MHI register by +using the SBL state callback that is added as part of the series. +We also have to make sure that new QRTR offset is added on top of the +default QRTR instance ID-s that are currently used in the driver. + +This finally allows using AHB + PCI or multiple PCI cards on the same +system. + +Since this is not supported on QCA6390 and like, its limited to QCN9074 +which is known to support changing QRTR instance ID. + +Before: +root@OpenWrt:/# qrtr-lookup + Service Version Instance Node Port + 1054 1 0 7 1 <unknown> + 69 1 2 7 3 ATH10k WLAN firmware service + +After: +root@OpenWrt:/# qrtr-lookup + Service Version Instance Node Port + 1054 1 0 7 1 <unknown> + 69 1 2 7 3 ATH10k WLAN firmware service + 15 1 0 8 1 Test service + 69 1 8 8 2 ATH10k WLAN firmware service + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1 +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/wireless/ath/ath11k/mhi.c | 49 ++++++++++++++++++--------- + drivers/net/wireless/ath/ath11k/mhi.h | 3 ++ + drivers/net/wireless/ath/ath11k/pci.c | 9 ++++- + 3 files changed, 44 insertions(+), 17 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mhi.c ++++ b/drivers/net/wireless/ath/ath11k/mhi.c +@@ -294,6 +294,34 @@ static void ath11k_mhi_op_runtime_put(st + { + } + ++static int ath11k_mhi_op_read_reg(struct mhi_controller *mhi_cntrl, ++ void __iomem *addr, ++ u32 *out) ++{ ++ *out = readl(addr); ++ ++ return 0; ++} ++ ++static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl, ++ void __iomem *addr, ++ u32 val) ++{ ++ writel(val, addr); ++} ++ ++static void ath11k_mhi_qrtr_instance_set(struct mhi_controller *mhi_cntrl) ++{ ++ struct ath11k_base *ab = dev_get_drvdata(mhi_cntrl->cntrl_dev); ++ ++ if (ab->hw_rev == ATH11K_HW_QCN9074_HW10) { ++ ath11k_mhi_op_write_reg(mhi_cntrl, ++ mhi_cntrl->bhi + BHI_ERRDBG2, ++ FIELD_PREP(QRTR_INSTANCE_MASK, ++ ab->qmi.service_ins_id - ab->hw_params.qmi_service_ins_id)); ++ } ++} ++ + static char *ath11k_mhi_op_callback_to_str(enum mhi_callback reason) + { + switch (reason) { +@@ -315,6 +343,8 @@ static char *ath11k_mhi_op_callback_to_s + return "MHI_CB_FATAL_ERROR"; + case MHI_CB_BW_REQ: + return "MHI_CB_BW_REQ"; ++ case MHI_CB_EE_SBL_MODE: ++ return "MHI_CB_EE_SBL_MODE"; + default: + return "UNKNOWN"; + } +@@ -337,27 +367,14 @@ static void ath11k_mhi_op_status_cb(stru + if (!(test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags))) + queue_work(ab->workqueue_aux, &ab->reset_work); + break; ++ case MHI_CB_EE_SBL_MODE: ++ ath11k_mhi_qrtr_instance_set(mhi_cntrl); ++ break; + default: + break; + } + } + +-static int ath11k_mhi_op_read_reg(struct mhi_controller *mhi_cntrl, +- void __iomem *addr, +- u32 *out) +-{ +- *out = readl(addr); +- +- return 0; +-} +- +-static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl, +- void __iomem *addr, +- u32 val) +-{ +- writel(val, addr); +-} +- + static int ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl) + { + struct device_node *np; +--- a/drivers/net/wireless/ath/ath11k/mhi.h ++++ b/drivers/net/wireless/ath/ath11k/mhi.h +@@ -16,6 +16,9 @@ + #define MHICTRL 0x38 + #define MHICTRL_RESET_MASK 0x2 + ++#define BHI_ERRDBG2 0x38 ++#define QRTR_INSTANCE_MASK GENMASK(7, 0) ++ + int ath11k_mhi_start(struct ath11k_pci *ar_pci); + void ath11k_mhi_stop(struct ath11k_pci *ar_pci); + int ath11k_mhi_register(struct ath11k_pci *ar_pci); +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -371,13 +371,20 @@ static void ath11k_pci_sw_reset(struct a + static void ath11k_pci_init_qmi_ce_config(struct ath11k_base *ab) + { + struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg; ++ struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); ++ struct pci_bus *bus = ab_pci->pdev->bus; + + cfg->tgt_ce = ab->hw_params.target_ce_config; + cfg->tgt_ce_len = ab->hw_params.target_ce_count; + + cfg->svc_to_ce_map = ab->hw_params.svc_to_ce_map; + cfg->svc_to_ce_map_len = ab->hw_params.svc_to_ce_map_len; +- ab->qmi.service_ins_id = ab->hw_params.qmi_service_ins_id; ++ ++ if (ab->hw_rev == ATH11K_HW_QCN9074_HW10) { ++ ab->qmi.service_ins_id = ab->hw_params.qmi_service_ins_id + ++ (((pci_domain_nr(bus) & 0xF) << 4) | (bus->number & 0xF)); ++ } else ++ ab->qmi.service_ins_id = ab->hw_params.qmi_service_ins_id; + + ath11k_ce_get_shadow_config(ab, &cfg->shadow_reg_v2, + &cfg->shadow_reg_v2_len); diff --git a/package/kernel/mac80211/patches/ath11k/900-ath11k-control-thermal-support-via-symbol.patch b/package/kernel/mac80211/patches/ath11k/900-ath11k-control-thermal-support-via-symbol.patch new file mode 100644 index 00000000000..dcfb4b5ac8b --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/900-ath11k-control-thermal-support-via-symbol.patch @@ -0,0 +1,66 @@ +From 703d6551f71e7290619d6effe2a25a64e10538b7 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Thu, 15 Dec 2022 12:20:52 +0100 +Subject: [PATCH] ath11k: control thermal support via symbol + +Currently, thermal support will get built if CONFIG_THERMAL is reachable, +however this is not suitable for OpenWrt as with ALL_KMODS being set to y +ATH11K_THERMAL wont get selected and so hwmon and thermal kmods wont get +pulled in resulting in a build-failure. + +So, to avoid that, lets do what is already done for ath10k and add a +config symbol into backports for enabling thermal support. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/wireless/ath/ath11k/Kconfig | 7 +++++++ + drivers/net/wireless/ath/ath11k/Makefile | 2 +- + drivers/net/wireless/ath/ath11k/thermal.h | 2 +- + local-symbols | 1 + + 4 files changed, 10 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/Kconfig ++++ b/drivers/net/wireless/ath/ath11k/Kconfig +@@ -61,3 +61,10 @@ config ATH11K_SPECTRAL + Enable ath11k spectral scan support + + Say Y to enable access to the FFT/spectral data via debugfs. ++ ++config ATH11K_THERMAL ++ bool "ath11k thermal sensors and throttling support" ++ depends on ATH11K ++ depends on THERMAL ++ help ++ Enable ath11k thermal sensors and throttling support. +--- a/drivers/net/wireless/ath/ath11k/Makefile ++++ b/drivers/net/wireless/ath/ath11k/Makefile +@@ -22,7 +22,7 @@ ath11k-y += core.o \ + ath11k-$(CPTCFG_ATH11K_DEBUGFS) += debugfs.o debugfs_htt_stats.o debugfs_sta.o + ath11k-$(CPTCFG_NL80211_TESTMODE) += testmode.o + ath11k-$(CPTCFG_ATH11K_TRACING) += trace.o +-ath11k-$(CONFIG_THERMAL) += thermal.o ++ath11k-$(CPTCFG_ATH11K_THERMAL) += thermal.o + ath11k-$(CPTCFG_ATH11K_SPECTRAL) += spectral.o + ath11k-$(CONFIG_PM) += wow.o + +--- a/drivers/net/wireless/ath/ath11k/thermal.h ++++ b/drivers/net/wireless/ath/ath11k/thermal.h +@@ -25,7 +25,7 @@ struct ath11k_thermal { + int temperature; + }; + +-#if IS_REACHABLE(CONFIG_THERMAL) ++#if IS_REACHABLE(CPTCFG_ATH11K_THERMAL) + int ath11k_thermal_register(struct ath11k_base *sc); + void ath11k_thermal_unregister(struct ath11k_base *sc); + int ath11k_thermal_set_throttling(struct ath11k *ar, u32 throttle_state); +--- a/local-symbols ++++ b/local-symbols +@@ -173,6 +173,7 @@ ATH11K_DEBUG= + ATH11K_DEBUGFS= + ATH11K_TRACING= + ATH11K_SPECTRAL= ++ATH11K_THERMAL= + ATH12K= + ATH12K_DEBUG= + ATH12K_TRACING= diff --git a/package/kernel/mac80211/patches/ath11k/901-wifi-ath11k-pci-fix-compilation-in-5.16-and-older.patch b/package/kernel/mac80211/patches/ath11k/901-wifi-ath11k-pci-fix-compilation-in-5.16-and-older.patch new file mode 100644 index 00000000000..9a0ca80090d --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/901-wifi-ath11k-pci-fix-compilation-in-5.16-and-older.patch @@ -0,0 +1,29 @@ +From 04178918e7f6b5f34dde81ec79ee8a1ccace3be3 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Mon, 17 Oct 2022 11:45:03 +0200 +Subject: [PATCH] wifi: ath11k: pci: fix compilation in 5.16 and older + +Commit ("genirq/msi, treewide: Use a named struct for PCI/MSI attributes") +changed the msi_desc structure a bit, however that is only available in +kernels 5.17 and newer, so check for kernel version to allow compilation +in 5.16 and older. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/wireless/ath/ath11k/pci.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -459,7 +459,11 @@ static int ath11k_pci_alloc_msi(struct a + pci_read_config_dword(pci_dev, pci_dev->msi_cap + PCI_MSI_ADDRESS_LO, + &ab->pci.msi.addr_lo); + ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0)) + if (msi_desc->pci.msi_attrib.is_64) { ++#else ++ if (msi_desc->msi_attrib.is_64) { ++#endif + pci_read_config_dword(pci_dev, pci_dev->msi_cap + PCI_MSI_ADDRESS_HI, + &ab->pci.msi.addr_hi); + } else { diff --git a/package/kernel/mac80211/patches/ath11k/902-ath11k-Disable-coldboot-calibration-for-IPQ8074.patch b/package/kernel/mac80211/patches/ath11k/902-ath11k-Disable-coldboot-calibration-for-IPQ8074.patch new file mode 100644 index 00000000000..cff62eea908 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/902-ath11k-Disable-coldboot-calibration-for-IPQ8074.patch @@ -0,0 +1,26 @@ +From dd3b9c59cfa1e9e0b73a575f4646be905691eaef Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Sat, 16 Oct 2021 19:34:10 +0200 +Subject: [PATCH 241/241] ath11k: Disable coldboot calibration for IPQ8074 + +There is a bug with the remoteproc reset after coldboot calibration, +so until that is resolved disabled it to allow using the radio. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/wireless/ath/ath11k/core.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -86,8 +86,8 @@ static const struct ath11k_hw_params ath + .supports_shadow_regs = false, + .idle_ps = false, + .supports_sta_ps = false, +- .coldboot_cal_mm = true, +- .coldboot_cal_ftm = true, ++ .coldboot_cal_mm = false, ++ .coldboot_cal_ftm = false, + .cbcal_restart_fw = true, + .fw_mem_mode = 0, + .num_vdevs = 16 + 1, diff --git a/package/kernel/mac80211/patches/ath11k/903-ath11k-support-setting-FW-memory-mode-via-DT.patch b/package/kernel/mac80211/patches/ath11k/903-ath11k-support-setting-FW-memory-mode-via-DT.patch new file mode 100644 index 00000000000..71373b2136f --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/903-ath11k-support-setting-FW-memory-mode-via-DT.patch @@ -0,0 +1,75 @@ +From fb1c40c225cbc413d82c872dd8c8af3469b2b921 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Fri, 16 Dec 2022 17:17:52 +0100 +Subject: [PATCH] ath11k: support setting FW memory mode via DT + +ath11k is really memory intensive for devices with less that 1GB of RAM, +so lets allow saving a significant amount of memory by setting the FW to +Mode-1 via DTS for devices that need it. + +However the drawback is reduced number of VDEV-s and peers which is a +reasonable tradeoff. + +Mode-2 allows for further reduction, but it has further restrictions. + +While we are here, lets add a print to be able to easily determine what +FW memory mode is being used. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/wireless/ath/ath11k/core.c | 28 ++++++++++++++++++++++++-- + 1 file changed, 26 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -36,7 +36,7 @@ bool ath11k_ftm_mode; + module_param_named(ftm_mode, ath11k_ftm_mode, bool, 0444); + MODULE_PARM_DESC(ftm_mode, "Boots up in factory test mode"); + +-static const struct ath11k_hw_params ath11k_hw_params[] = { ++static struct ath11k_hw_params ath11k_hw_params[] = { + { + .hw_rev = ATH11K_HW_IPQ8074, + .name = "ipq8074 hw2.0", +@@ -2040,7 +2040,8 @@ static void ath11k_core_reset(struct wor + static int ath11k_init_hw_params(struct ath11k_base *ab) + { + const struct ath11k_hw_params *hw_params = NULL; +- int i; ++ u32 fw_mem_mode; ++ int i, ret; + + for (i = 0; i < ARRAY_SIZE(ath11k_hw_params); i++) { + hw_params = &ath11k_hw_params[i]; +@@ -2056,7 +2057,31 @@ static int ath11k_init_hw_params(struct + + ab->hw_params = *hw_params; + ++ ret = of_property_read_u32(ab->dev->of_node, ++ "qcom,ath11k-fw-memory-mode", ++ &fw_mem_mode); ++ if (!ret) { ++ if (fw_mem_mode == 0) { ++ ab->hw_params.fw_mem_mode = 0; ++ ab->hw_params.num_vdevs = 16 + 1; ++ ab->hw_params.num_peers = 512; ++ } ++ else if (fw_mem_mode == 1) { ++ ab->hw_params.fw_mem_mode = 1; ++ ab->hw_params.num_vdevs = 8; ++ ab->hw_params.num_peers = 128; ++ } else if (fw_mem_mode == 2) { ++ ab->hw_params.fw_mem_mode = 2; ++ ab->hw_params.num_vdevs = 8; ++ ab->hw_params.num_peers = 128; ++ ab->hw_params.coldboot_cal_mm = false; ++ ab->hw_params.coldboot_cal_ftm = false; ++ } else ++ ath11k_info(ab, "Unsupported FW memory mode: %u\n", fw_mem_mode); ++ } ++ + ath11k_info(ab, "%s\n", ab->hw_params.name); ++ ath11k_info(ab, "FW memory mode: %d\n", ab->hw_params.fw_mem_mode); + + return 0; + } diff --git a/package/kernel/mac80211/patches/ath11k/905-ath11k-remove-intersection-support-for-regulatory-ru.patch b/package/kernel/mac80211/patches/ath11k/905-ath11k-remove-intersection-support-for-regulatory-ru.patch new file mode 100644 index 00000000000..74317e0262a --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/905-ath11k-remove-intersection-support-for-regulatory-ru.patch @@ -0,0 +1,317 @@ +From abdd0985a36189ef2cc0e393b027276e86137ace Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Tue, 11 Apr 2023 20:08:49 +0200 +Subject: [PATCH] ath11k: remove intersection support for regulatory rules + +Currently, regulatory rules from new country settings is intersected with +rules from default country settings(during initialisation) in order to prevent +users to bypass their default country settings such as power limits, channel +flags, etc. + +However, the country setting in the BDF will take higher higher precendence +and FW will protect it. Therefore, there is no need to handle intersection +on the driver side now. + +Remove regulatory rules intersection logic support. + +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +--- + drivers/net/wireless/ath/ath11k/reg.c | 168 +++----------------------- + drivers/net/wireless/ath/ath11k/reg.h | 2 +- + drivers/net/wireless/ath/ath11k/wmi.c | 24 +--- + 3 files changed, 16 insertions(+), 178 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/reg.c ++++ b/drivers/net/wireless/ath/ath11k/reg.c +@@ -362,129 +362,6 @@ static u32 ath11k_map_fw_phy_flags(u32 p + return flags; + } + +-static bool +-ath11k_reg_can_intersect(struct ieee80211_reg_rule *rule1, +- struct ieee80211_reg_rule *rule2) +-{ +- u32 start_freq1, end_freq1; +- u32 start_freq2, end_freq2; +- +- start_freq1 = rule1->freq_range.start_freq_khz; +- start_freq2 = rule2->freq_range.start_freq_khz; +- +- end_freq1 = rule1->freq_range.end_freq_khz; +- end_freq2 = rule2->freq_range.end_freq_khz; +- +- if ((start_freq1 >= start_freq2 && +- start_freq1 < end_freq2) || +- (start_freq2 > start_freq1 && +- start_freq2 < end_freq1)) +- return true; +- +- /* TODO: Should we restrict intersection feasibility +- * based on min bandwidth of the intersected region also, +- * say the intersected rule should have a min bandwidth +- * of 20MHz? +- */ +- +- return false; +-} +- +-static void ath11k_reg_intersect_rules(struct ieee80211_reg_rule *rule1, +- struct ieee80211_reg_rule *rule2, +- struct ieee80211_reg_rule *new_rule) +-{ +- u32 start_freq1, end_freq1; +- u32 start_freq2, end_freq2; +- u32 freq_diff, max_bw; +- +- start_freq1 = rule1->freq_range.start_freq_khz; +- start_freq2 = rule2->freq_range.start_freq_khz; +- +- end_freq1 = rule1->freq_range.end_freq_khz; +- end_freq2 = rule2->freq_range.end_freq_khz; +- +- new_rule->freq_range.start_freq_khz = max_t(u32, start_freq1, +- start_freq2); +- new_rule->freq_range.end_freq_khz = min_t(u32, end_freq1, end_freq2); +- +- freq_diff = new_rule->freq_range.end_freq_khz - +- new_rule->freq_range.start_freq_khz; +- max_bw = min_t(u32, rule1->freq_range.max_bandwidth_khz, +- rule2->freq_range.max_bandwidth_khz); +- new_rule->freq_range.max_bandwidth_khz = min_t(u32, max_bw, freq_diff); +- +- new_rule->power_rule.max_antenna_gain = +- min_t(u32, rule1->power_rule.max_antenna_gain, +- rule2->power_rule.max_antenna_gain); +- +- new_rule->power_rule.max_eirp = min_t(u32, rule1->power_rule.max_eirp, +- rule2->power_rule.max_eirp); +- +- /* Use the flags of both the rules */ +- new_rule->flags = rule1->flags | rule2->flags; +- +- /* To be safe, lts use the max cac timeout of both rules */ +- new_rule->dfs_cac_ms = max_t(u32, rule1->dfs_cac_ms, +- rule2->dfs_cac_ms); +-} +- +-static struct ieee80211_regdomain * +-ath11k_regd_intersect(struct ieee80211_regdomain *default_regd, +- struct ieee80211_regdomain *curr_regd) +-{ +- u8 num_old_regd_rules, num_curr_regd_rules, num_new_regd_rules; +- struct ieee80211_reg_rule *old_rule, *curr_rule, *new_rule; +- struct ieee80211_regdomain *new_regd = NULL; +- u8 i, j, k; +- +- num_old_regd_rules = default_regd->n_reg_rules; +- num_curr_regd_rules = curr_regd->n_reg_rules; +- num_new_regd_rules = 0; +- +- /* Find the number of intersecting rules to allocate new regd memory */ +- for (i = 0; i < num_old_regd_rules; i++) { +- old_rule = default_regd->reg_rules + i; +- for (j = 0; j < num_curr_regd_rules; j++) { +- curr_rule = curr_regd->reg_rules + j; +- +- if (ath11k_reg_can_intersect(old_rule, curr_rule)) +- num_new_regd_rules++; +- } +- } +- +- if (!num_new_regd_rules) +- return NULL; +- +- new_regd = kzalloc(sizeof(*new_regd) + (num_new_regd_rules * +- sizeof(struct ieee80211_reg_rule)), +- GFP_ATOMIC); +- +- if (!new_regd) +- return NULL; +- +- /* We set the new country and dfs region directly and only trim +- * the freq, power, antenna gain by intersecting with the +- * default regdomain. Also MAX of the dfs cac timeout is selected. +- */ +- new_regd->n_reg_rules = num_new_regd_rules; +- memcpy(new_regd->alpha2, curr_regd->alpha2, sizeof(new_regd->alpha2)); +- new_regd->dfs_region = curr_regd->dfs_region; +- new_rule = new_regd->reg_rules; +- +- for (i = 0, k = 0; i < num_old_regd_rules; i++) { +- old_rule = default_regd->reg_rules + i; +- for (j = 0; j < num_curr_regd_rules; j++) { +- curr_rule = curr_regd->reg_rules + j; +- +- if (ath11k_reg_can_intersect(old_rule, curr_rule)) +- ath11k_reg_intersect_rules(old_rule, curr_rule, +- (new_rule + k++)); +- } +- } +- return new_regd; +-} +- + static const char * + ath11k_reg_get_regdom_str(enum nl80211_dfs_regions dfs_region) + { +@@ -619,9 +496,9 @@ ath11k_reg_update_weather_radar_band(str + + struct ieee80211_regdomain * + ath11k_reg_build_regd(struct ath11k_base *ab, +- struct cur_regulatory_info *reg_info, bool intersect) ++ struct cur_regulatory_info *reg_info) + { +- struct ieee80211_regdomain *tmp_regd, *default_regd, *new_regd = NULL; ++ struct ieee80211_regdomain *new_regd = NULL; + struct cur_reg_rule *reg_rule; + u8 i = 0, j = 0, k = 0; + u8 num_rules; +@@ -638,26 +515,26 @@ ath11k_reg_build_regd(struct ath11k_base + num_rules += reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP]; + + if (!num_rules) +- goto ret; ++ return new_regd; + + /* Add max additional rules to accommodate weather radar band */ + if (reg_info->dfs_region == ATH11K_DFS_REG_ETSI) + num_rules += 2; + +- tmp_regd = kzalloc(sizeof(*tmp_regd) + ++ new_regd = kzalloc(sizeof(*new_regd) + + (num_rules * sizeof(struct ieee80211_reg_rule)), + GFP_ATOMIC); +- if (!tmp_regd) +- goto ret; ++ if (!new_regd) ++ return new_regd; + +- memcpy(tmp_regd->alpha2, reg_info->alpha2, REG_ALPHA2_LEN + 1); ++ memcpy(new_regd->alpha2, reg_info->alpha2, REG_ALPHA2_LEN + 1); + memcpy(alpha2, reg_info->alpha2, REG_ALPHA2_LEN + 1); + alpha2[2] = '\0'; +- tmp_regd->dfs_region = ath11k_map_fw_dfs_region(reg_info->dfs_region); ++ new_regd->dfs_region = ath11k_map_fw_dfs_region(reg_info->dfs_region); + + ath11k_dbg(ab, ATH11K_DBG_REG, + "Country %s, CFG Regdomain %s FW Regdomain %d, num_reg_rules %d\n", +- alpha2, ath11k_reg_get_regdom_str(tmp_regd->dfs_region), ++ alpha2, ath11k_reg_get_regdom_str(new_regd->dfs_region), + reg_info->dfs_region, num_rules); + /* Update reg_rules[] below. Firmware is expected to + * send these rules in order(2 GHz rules first and then 5 GHz) +@@ -697,7 +574,7 @@ ath11k_reg_build_regd(struct ath11k_base + flags |= ath11k_map_fw_reg_flags(reg_rule->flags); + flags |= ath11k_map_fw_phy_flags(reg_info->phybitmap); + +- ath11k_reg_update_rule(tmp_regd->reg_rules + i, ++ ath11k_reg_update_rule(new_regd->reg_rules + i, + reg_rule->start_freq, + reg_rule->end_freq, max_bw, + reg_rule->ant_gain, reg_rule->reg_power, +@@ -712,7 +589,7 @@ ath11k_reg_build_regd(struct ath11k_base + reg_info->dfs_region == ATH11K_DFS_REG_ETSI && + (reg_rule->end_freq > ETSI_WEATHER_RADAR_BAND_LOW && + reg_rule->start_freq < ETSI_WEATHER_RADAR_BAND_HIGH)){ +- ath11k_reg_update_weather_radar_band(ab, tmp_regd, ++ ath11k_reg_update_weather_radar_band(ab, new_regd, + reg_rule, &i, + flags, max_bw); + continue; +@@ -723,37 +600,20 @@ ath11k_reg_build_regd(struct ath11k_base + "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d) (%d, %d)\n", + i + 1, reg_rule->start_freq, reg_rule->end_freq, + max_bw, reg_rule->ant_gain, reg_rule->reg_power, +- tmp_regd->reg_rules[i].dfs_cac_ms, flags, ++ new_regd->reg_rules[i].dfs_cac_ms, flags, + reg_rule->psd_flag, reg_rule->psd_eirp); + } else { + ath11k_dbg(ab, ATH11K_DBG_REG, + "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n", + i + 1, reg_rule->start_freq, reg_rule->end_freq, + max_bw, reg_rule->ant_gain, reg_rule->reg_power, +- tmp_regd->reg_rules[i].dfs_cac_ms, ++ new_regd->reg_rules[i].dfs_cac_ms, + flags); + } + } + +- tmp_regd->n_reg_rules = i; +- +- if (intersect) { +- default_regd = ab->default_regd[reg_info->phy_id]; +- +- /* Get a new regd by intersecting the received regd with +- * our default regd. +- */ +- new_regd = ath11k_regd_intersect(default_regd, tmp_regd); +- kfree(tmp_regd); +- if (!new_regd) { +- ath11k_warn(ab, "Unable to create intersected regdomain\n"); +- goto ret; +- } +- } else { +- new_regd = tmp_regd; +- } ++ new_regd->n_reg_rules = i; + +-ret: + return new_regd; + } + +--- a/drivers/net/wireless/ath/ath11k/reg.h ++++ b/drivers/net/wireless/ath/ath11k/reg.h +@@ -33,7 +33,7 @@ void ath11k_reg_free(struct ath11k_base + void ath11k_regd_update_work(struct work_struct *work); + struct ieee80211_regdomain * + ath11k_reg_build_regd(struct ath11k_base *ab, +- struct cur_regulatory_info *reg_info, bool intersect); ++ struct cur_regulatory_info *reg_info); + int ath11k_regd_update(struct ath11k *ar); + int ath11k_reg_update_chan_list(struct ath11k *ar, bool wait); + #endif +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -7060,24 +7060,12 @@ static void ath11k_wmi_htc_tx_complete(s + wake_up(&wmi->tx_ce_desc_wq); + } + +-static bool ath11k_reg_is_world_alpha(char *alpha) +-{ +- if (alpha[0] == '0' && alpha[1] == '0') +- return true; +- +- if (alpha[0] == 'n' && alpha[1] == 'a') +- return true; +- +- return false; +-} +- + static int ath11k_reg_chan_list_event(struct ath11k_base *ab, + struct sk_buff *skb, + enum wmi_reg_chan_list_cmd_type id) + { + struct cur_regulatory_info *reg_info = NULL; + struct ieee80211_regdomain *regd = NULL; +- bool intersect = false; + int ret = 0, pdev_idx, i, j; + struct ath11k *ar; + +@@ -7141,17 +7129,7 @@ static int ath11k_reg_chan_list_event(st + (char *)reg_info->alpha2, 2)) + goto mem_free; + +- /* Intersect new rules with default regd if a new country setting was +- * requested, i.e a default regd was already set during initialization +- * and the regd coming from this event has a valid country info. +- */ +- if (ab->default_regd[pdev_idx] && +- !ath11k_reg_is_world_alpha((char *) +- ab->default_regd[pdev_idx]->alpha2) && +- !ath11k_reg_is_world_alpha((char *)reg_info->alpha2)) +- intersect = true; +- +- regd = ath11k_reg_build_regd(ab, reg_info, intersect); ++ regd = ath11k_reg_build_regd(ab, reg_info); + if (!regd) { + ath11k_warn(ab, "failed to build regd from reg_info\n"); + goto fallback; diff --git a/package/kernel/mac80211/patches/ath5k/201-ath5k-WAR-for-AR71xx-PCI-bug.patch b/package/kernel/mac80211/patches/ath5k/201-ath5k-WAR-for-AR71xx-PCI-bug.patch index 21516ffde90..4fc97dfaec9 100644 --- a/package/kernel/mac80211/patches/ath5k/201-ath5k-WAR-for-AR71xx-PCI-bug.patch +++ b/package/kernel/mac80211/patches/ath5k/201-ath5k-WAR-for-AR71xx-PCI-bug.patch @@ -17,7 +17,7 @@ { 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) +@@ -854,10 +854,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) { diff --git a/package/kernel/mac80211/patches/ath5k/411-ath5k_allow_adhoc_and_ap.patch b/package/kernel/mac80211/patches/ath5k/411-ath5k_allow_adhoc_and_ap.patch index 9dbe047c9af..1df4aab57ee 100644 --- a/package/kernel/mac80211/patches/ath5k/411-ath5k_allow_adhoc_and_ap.patch +++ b/package/kernel/mac80211/patches/ath5k/411-ath5k_allow_adhoc_and_ap.patch @@ -18,7 +18,7 @@ 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) +@@ -2009,7 +2009,7 @@ ath5k_beacon_send(struct ath5k_hw *ah) } if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + @@ -27,7 +27,7 @@ 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_ +@@ -2095,7 +2095,7 @@ ath5k_beacon_update_timers(struct ath5k_ intval = ah->bintval & AR5K_BEACON_PERIOD; if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs @@ -36,7 +36,7 @@ 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 +@@ -2561,6 +2561,7 @@ static const struct ieee80211_iface_limi BIT(NL80211_IFTYPE_MESH_POINT) | #endif BIT(NL80211_IFTYPE_AP) }, diff --git a/package/kernel/mac80211/patches/ath5k/440-ath5k_channel_bw_debugfs.patch b/package/kernel/mac80211/patches/ath5k/440-ath5k_channel_bw_debugfs.patch index 92fb90c1657..a63f0c881bf 100644 --- a/package/kernel/mac80211/patches/ath5k/440-ath5k_channel_bw_debugfs.patch +++ b/package/kernel/mac80211/patches/ath5k/440-ath5k_channel_bw_debugfs.patch @@ -130,7 +130,7 @@ drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++ /* 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 +@@ -465,6 +465,9 @@ ath5k_chan_set(struct ath5k_hw *ah, stru return -EINVAL; } diff --git a/package/kernel/mac80211/patches/ath9k/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch b/package/kernel/mac80211/patches/ath9k/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch index d648a3a3e56..3a0171d4a2a 100644 --- a/package/kernel/mac80211/patches/ath9k/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch +++ b/package/kernel/mac80211/patches/ath9k/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> --- 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 +@@ -1434,8 +1434,12 @@ static bool ath9k_hw_set_reset(struct at if (!AR_SREV_9100(ah)) REG_WRITE(ah, AR_RC, 0); diff --git a/package/kernel/mac80211/patches/ath9k/351-ath9k_hw-issue-external-reset-for-QCA955x.patch b/package/kernel/mac80211/patches/ath9k/351-ath9k_hw-issue-external-reset-for-QCA955x.patch index 5f265b84c26..aac7e139249 100644 --- a/package/kernel/mac80211/patches/ath9k/351-ath9k_hw-issue-external-reset-for-QCA955x.patch +++ b/package/kernel/mac80211/patches/ath9k/351-ath9k_hw-issue-external-reset-for-QCA955x.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> --- 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 +@@ -1311,39 +1311,56 @@ void ath9k_hw_get_delta_slope_vals(struc *coef_exponent = coef_exp - 16; } @@ -75,7 +75,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> + ath_dbg(ath9k_hw_common(ah), RESET, + "reset MAC via external reset\n"); -- REG_WRITE(ah, AR_RTC_RESET, 1); +- REG_WRITE(ah, AR_RTC_RESET(ah), 1); + err = ah->external_reset(); + if (err) { + ath_err(ath9k_hw_common(ah), @@ -84,17 +84,17 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> } + if (AR_SREV_9550(ah)) { -+ REG_WRITE(ah, AR_RTC_RESET, 0); ++ REG_WRITE(ah, AR_RTC_RESET(ah), 0); + udelay(10); + } + -+ REG_WRITE(ah, AR_RTC_RESET, 1); ++ REG_WRITE(ah, AR_RTC_RESET(ah), 1); + udelay(10); + return true; } -@@ -1397,24 +1414,24 @@ static bool ath9k_hw_set_reset(struct at +@@ -1396,24 +1413,24 @@ static bool ath9k_hw_set_reset(struct at rst_flags |= AR_RTC_RC_MAC_COLD; } @@ -124,6 +124,6 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> + 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); + REG_WRITE(ah, AR_RTC_RC(ah), rst_flags); REGWRITE_BUFFER_FLUSH(ah); diff --git a/package/kernel/mac80211/patches/ath9k/410-ath9k_allow_adhoc_and_ap.patch b/package/kernel/mac80211/patches/ath9k/410-ath9k_allow_adhoc_and_ap.patch index 17dd8f6597b..b2f2763e8e1 100644 --- a/package/kernel/mac80211/patches/ath9k/410-ath9k_allow_adhoc_and_ap.patch +++ b/package/kernel/mac80211/patches/ath9k/410-ath9k_allow_adhoc_and_ap.patch @@ -1,10 +1,10 @@ --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c -@@ -830,6 +830,7 @@ static const struct ieee80211_iface_limi +@@ -882,6 +882,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 + #ifdef CPTCFG_ATH9K_CHANNEL_CONTEXT diff --git a/package/kernel/mac80211/patches/ath9k/450-ath9k-enabled-MFP-capability-unconditionally.patch b/package/kernel/mac80211/patches/ath9k/450-ath9k-enabled-MFP-capability-unconditionally.patch index ea94b523853..f424ca530be 100644 --- a/package/kernel/mac80211/patches/ath9k/450-ath9k-enabled-MFP-capability-unconditionally.patch +++ b/package/kernel/mac80211/patches/ath9k/450-ath9k-enabled-MFP-capability-unconditionally.patch @@ -14,7 +14,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net> --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c -@@ -927,6 +927,7 @@ static void ath9k_set_hw_capab(struct at +@@ -963,6 +963,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); @@ -22,7 +22,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net> if (ath9k_ps_enable) ieee80211_hw_set(hw, SUPPORTS_PS); -@@ -939,9 +940,6 @@ static void ath9k_set_hw_capab(struct at +@@ -975,9 +976,6 @@ static void ath9k_set_hw_capab(struct at IEEE80211_RADIOTAP_MCS_HAVE_STBC; } diff --git a/package/kernel/mac80211/patches/ath9k/500-ath9k_eeprom_debugfs.patch b/package/kernel/mac80211/patches/ath9k/500-ath9k_eeprom_debugfs.patch index 48ccc813080..d23d70b2ce7 100644 --- a/package/kernel/mac80211/patches/ath9k/500-ath9k_eeprom_debugfs.patch +++ b/package/kernel/mac80211/patches/ath9k/500-ath9k_eeprom_debugfs.patch @@ -1,14 +1,24 @@ --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -1364,6 +1364,53 @@ void ath9k_deinit_debug(struct ath_softc - ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); - } +@@ -1471,6 +1471,7 @@ int ath9k_init_debug(struct ath_hw *ah) + + ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah); + ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah); ++ ath9k_cmn_debug_eeprom(sc->debug.debugfs_phy, sc->sc_ah); + debugfs_create_u32("gpio_mask", 0600, + sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); +--- a/drivers/net/wireless/ath/ath9k/common-debug.c ++++ b/drivers/net/wireless/ath/ath9k/common-debug.c +@@ -260,3 +260,58 @@ void ath9k_cmn_debug_phy_err(struct dent + &fops_phy_err); + } + EXPORT_SYMBOL(ath9k_cmn_debug_phy_err); ++ +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_hw *ah = file->private_data; + struct ath_common *common = ath9k_hw_common(ah); + int bytes = 0; + int pos = *ppos; @@ -39,7 +49,8 @@ + } else { + bytes = 2; + } -+ copy_to_user(user_buf, from, bytes); ++ if (copy_to_user(user_buf, from, bytes)) ++ return -EFAULT; + user_buf += bytes; + } + return *ppos - pos; @@ -51,15 +62,31 @@ + .owner = THIS_MODULE +}; + - int ath9k_init_debug(struct ath_hw *ah) - { - struct ath_common *common = ath9k_hw_common(ah); -@@ -1383,6 +1430,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, ++void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy, ++ struct ath_hw *ah) ++{ ++ debugfs_create_file("eeprom", S_IRUSR, debugfs_phy, ah, + &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, ++} ++EXPORT_SYMBOL(ath9k_cmn_debug_eeprom); +--- a/drivers/net/wireless/ath/ath9k/common-debug.h ++++ b/drivers/net/wireless/ath/ath9k/common-debug.h +@@ -69,6 +69,8 @@ void ath9k_cmn_debug_modal_eeprom(struct + struct ath_hw *ah); + void ath9k_cmn_debug_base_eeprom(struct dentry *debugfs_phy, + struct ath_hw *ah); ++void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy, ++ struct ath_hw *ah); + void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats, + struct ath_rx_status *rs); + void ath9k_cmn_debug_recv(struct dentry *debugfs_phy, +--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c ++++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c +@@ -519,6 +519,7 @@ int ath9k_htc_init_debug(struct ath_hw * + + ath9k_cmn_debug_base_eeprom(priv->debug.debugfs_phy, priv->ah); + ath9k_cmn_debug_modal_eeprom(priv->debug.debugfs_phy, priv->ah); ++ ath9k_cmn_debug_eeprom(priv->debug.debugfs_phy, priv->ah); + + return 0; + } diff --git a/package/kernel/mac80211/patches/ath9k/501-ath9k_ahb_init.patch b/package/kernel/mac80211/patches/ath9k/501-ath9k_ahb_init.patch index b9c784eb25e..740ddc39dc3 100644 --- a/package/kernel/mac80211/patches/ath9k/501-ath9k_ahb_init.patch +++ b/package/kernel/mac80211/patches/ath9k/501-ath9k_ahb_init.patch @@ -1,6 +1,6 @@ --- 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) +@@ -1178,25 +1178,25 @@ static int __init ath9k_init(void) { int error; diff --git a/package/kernel/mac80211/patches/ath9k/510-ath9k_intr_mitigation_tweak.patch b/package/kernel/mac80211/patches/ath9k/510-ath9k_intr_mitigation_tweak.patch index 75b48b480e3..fda050a8f20 100644 --- a/package/kernel/mac80211/patches/ath9k/510-ath9k_intr_mitigation_tweak.patch +++ b/package/kernel/mac80211/patches/ath9k/510-ath9k_intr_mitigation_tweak.patch @@ -1,6 +1,6 @@ --- 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 +@@ -402,13 +402,8 @@ static void ath9k_hw_init_config(struct ah->config.rx_intr_mitigation = true; diff --git a/package/kernel/mac80211/patches/ath9k/511-ath9k_reduce_rxbuf.patch b/package/kernel/mac80211/patches/ath9k/511-ath9k_reduce_rxbuf.patch index 15b8d7b86b1..3abf16b03e3 100644 --- a/package/kernel/mac80211/patches/ath9k/511-ath9k_reduce_rxbuf.patch +++ b/package/kernel/mac80211/patches/ath9k/511-ath9k_reduce_rxbuf.patch @@ -1,6 +1,6 @@ --- 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 * +@@ -89,7 +89,7 @@ int ath_descdma_setup(struct ath_softc * (_l) &= ((_sz) - 1); \ } while (0) diff --git a/package/kernel/mac80211/patches/ath9k/512-ath9k_channelbw_debugfs.patch b/package/kernel/mac80211/patches/ath9k/512-ath9k_channelbw_debugfs.patch index 126d1d5c624..474fb3fdbeb 100644 --- a/package/kernel/mac80211/patches/ath9k/512-ath9k_channelbw_debugfs.patch +++ b/package/kernel/mac80211/patches/ath9k/512-ath9k_channelbw_debugfs.patch @@ -1,70 +1,16 @@ --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -1411,6 +1411,52 @@ static const struct file_operations fops - .owner = THIS_MODULE - }; +@@ -1472,6 +1472,7 @@ int ath9k_init_debug(struct ath_hw *ah) + ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah); + ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah); + ath9k_cmn_debug_eeprom(sc->debug.debugfs_phy, sc->sc_ah); ++ ath9k_cmn_debug_chanbw(sc->debug.debugfs_phy, sc->sc_ah); -+ -+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); -@@ -1432,6 +1478,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, + debugfs_create_u32("gpio_mask", 0600, + sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h -@@ -149,6 +149,7 @@ struct ath_common { +@@ -153,6 +153,7 @@ struct ath_common { int debug_mask; enum ath_device_state state; unsigned long op_flags; @@ -72,6 +18,14 @@ struct ath_ani ani; +@@ -181,6 +182,7 @@ struct ath_common { + const struct ath_ops *ops; + const struct ath_bus_ops *bus_ops; + const struct ath_ps_ops *ps_ops; ++ const struct ieee80211_ops *ieee_ops; + + bool btcoex_enabled; + bool disable_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 @@ -123,3 +77,115 @@ return channel; } +--- a/drivers/net/wireless/ath/ath9k/common-debug.c ++++ b/drivers/net/wireless/ath/ath9k/common-debug.c +@@ -315,3 +315,55 @@ void ath9k_cmn_debug_eeprom(struct dentr + &fops_eeprom); + } + EXPORT_SYMBOL(ath9k_cmn_debug_eeprom); ++ ++static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf, ++ size_t count, loff_t *ppos) ++{ ++ struct ath_hw *ah = file->private_data; ++ struct ath_common *common = ath9k_hw_common(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_hw *ah = file->private_data; ++ struct ath_common *common = ath9k_hw_common(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)) ++ common->ieee_ops->config(ah->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, ++}; ++ ++void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy, ++ struct ath_hw *ah) ++{ ++ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, debugfs_phy, ah, ++ &fops_chanbw); ++} ++EXPORT_SYMBOL(ath9k_cmn_debug_chanbw); +--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c ++++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c +@@ -520,6 +520,7 @@ int ath9k_htc_init_debug(struct ath_hw * + ath9k_cmn_debug_base_eeprom(priv->debug.debugfs_phy, priv->ah); + ath9k_cmn_debug_modal_eeprom(priv->debug.debugfs_phy, priv->ah); + ath9k_cmn_debug_eeprom(priv->debug.debugfs_phy, priv->ah); ++ ath9k_cmn_debug_chanbw(priv->debug.debugfs_phy, priv->ah); + + return 0; + } +--- a/drivers/net/wireless/ath/ath9k/common-debug.h ++++ b/drivers/net/wireless/ath/ath9k/common-debug.h +@@ -71,6 +71,8 @@ void ath9k_cmn_debug_base_eeprom(struct + struct ath_hw *ah); + void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy, + struct ath_hw *ah); ++void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy, ++ struct ath_hw *ah); + void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats, + struct ath_rx_status *rs); + void ath9k_cmn_debug_recv(struct dentry *debugfs_phy, +--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c ++++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c +@@ -631,6 +631,7 @@ static int ath9k_init_priv(struct ath9k_ + priv->ah = ah; + + common = ath9k_hw_common(ah); ++ common->ieee_ops = &ath9k_htc_ops; + common->ops = &ah->reg_ops; + common->ps_ops = &ath9k_htc_ps_ops; + common->bus_ops = &ath9k_usb_bus_ops; +@@ -746,9 +747,9 @@ static void ath9k_set_hw_capab(struct at + + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN | + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | +- WIPHY_FLAG_HAS_CHANNEL_SWITCH; +- +- hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; ++ WIPHY_FLAG_HAS_CHANNEL_SWITCH | ++ WIPHY_FLAG_SUPPORTS_5_10_MHZ | ++ WIPHY_FLAG_SUPPORTS_TDLS; + + hw->queues = 4; + hw->max_listen_interval = 1; +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -733,6 +733,7 @@ static int ath9k_init_softc(u16 devid, s + if (!ath9k_is_chanctx_enabled()) + sc->cur_chan->hw_queue_base = 0; + ++ common->ieee_ops = &ath9k_ops; + common->ops = &ah->reg_ops; + common->bus_ops = bus_ops; + common->ps_ops = &ath9k_ps_ops; diff --git a/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch b/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch index 113c35625f7..a085e3a1fbe 100644 --- a/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch +++ b/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch @@ -1,6 +1,6 @@ --- 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) +@@ -662,6 +662,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) { diff --git a/package/kernel/mac80211/patches/ath9k/530-ath9k_extra_leds.patch b/package/kernel/mac80211/patches/ath9k/530-ath9k_extra_leds.patch index 5fd5c73a2f3..9568b091de3 100644 --- a/package/kernel/mac80211/patches/ath9k/530-ath9k_extra_leds.patch +++ b/package/kernel/mac80211/patches/ath9k/530-ath9k_extra_leds.patch @@ -181,7 +181,7 @@ --- 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 +@@ -1089,7 +1089,7 @@ int ath9k_init_device(u16 devid, struct #ifdef CPTCFG_MAC80211_LEDS /* must be initialized before ieee80211_register_hw */ @@ -192,9 +192,9 @@ #endif --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -1456,6 +1456,61 @@ static const struct file_operations fops - .llseek = default_llseek, - }; +@@ -128,6 +128,61 @@ static const struct file_operations fops + + #define DMA_BUF_LEN 1024 +#ifdef CONFIG_MAC80211_LEDS + @@ -252,12 +252,12 @@ +#endif + - int ath9k_init_debug(struct ath_hw *ah) - { -@@ -1480,6 +1535,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); + static ssize_t read_file_ani(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +@@ -1432,6 +1487,10 @@ 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); + +#ifdef CONFIG_MAC80211_LEDS + debugfs_create_file("gpio_led", S_IWUSR, + sc->debug.debugfs_phy, sc, &fops_gpio_led); diff --git a/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch b/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch index f93a6fe5cd7..c54dbbb1884 100644 --- a/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch +++ b/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch @@ -1,8 +1,8 @@ --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -1512,6 +1512,50 @@ static const struct file_operations fops - #endif - +@@ -1468,6 +1468,50 @@ void ath9k_deinit_debug(struct ath_softc + ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); + } +static ssize_t read_file_diag(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) @@ -51,7 +51,7 @@ int ath9k_init_debug(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); -@@ -1539,6 +1583,8 @@ int ath9k_init_debug(struct ath_hw *ah) +@@ -1491,6 +1535,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 @@ -84,7 +84,7 @@ bool reset_power_on; bool htc_reset_init; -@@ -1076,6 +1084,7 @@ void ath9k_hw_check_nav(struct ath_hw *a +@@ -1079,6 +1087,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); @@ -94,7 +94,7 @@ 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 +@@ -1881,6 +1881,20 @@ u32 ath9k_hw_get_tsf_offset(struct times } EXPORT_SYMBOL(ath9k_hw_get_tsf_offset); @@ -115,7 +115,7 @@ 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 +@@ -2089,6 +2103,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st ar9003_hw_disable_phy_restart(ah); ath9k_hw_apply_gpio_override(ah); @@ -125,9 +125,9 @@ 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 -@@ -531,6 +531,11 @@ irqreturn_t ath_isr(int irq, void *dev) - if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) +@@ -538,6 +538,11 @@ irqreturn_t ath_isr(int irq, void *dev) return IRQ_HANDLED; + } + if (test_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag)) { + status |= ATH9K_INT_FATAL; diff --git a/package/kernel/mac80211/patches/ath9k/543-ath9k_entropy_from_adc.patch b/package/kernel/mac80211/patches/ath9k/543-ath9k_entropy_from_adc.patch index 0d938a37303..8b399f4b4ce 100644 --- a/package/kernel/mac80211/patches/ath9k/543-ath9k_entropy_from_adc.patch +++ b/package/kernel/mac80211/patches/ath9k/543-ath9k_entropy_from_adc.patch @@ -18,7 +18,7 @@ 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 +@@ -1918,6 +1918,26 @@ void ar9003_hw_init_rate_txpower(struct } } @@ -26,9 +26,9 @@ +{ + 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); ++ REG_RMW_FIELD(ah, AR_PHY_TEST(ah), AR_PHY_TEST_BBB_OBS_SEL, 1); ++ REG_CLR_BIT(ah, AR_PHY_TEST(ah), AR_PHY_TEST_RX_OBS_SEL_BIT5); ++ REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS(ah), AR_PHY_TEST_CTL_RX_OBS_SEL, 0); + + memset(buf, 0, len); + for (i = 0; i < len; i++) { @@ -45,7 +45,7 @@ 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 +@@ -1954,6 +1974,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; @@ -55,7 +55,7 @@ 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 -@@ -818,7 +818,8 @@ static void ath9k_init_txpower_limits(st +@@ -871,7 +871,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); @@ -65,7 +65,7 @@ } static const struct ieee80211_iface_limit if_limits[] = { -@@ -1015,6 +1016,18 @@ static void ath9k_set_hw_capab(struct at +@@ -1049,6 +1050,18 @@ static void ath9k_set_hw_capab(struct at wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0); } @@ -84,9 +84,9 @@ 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 +@@ -1096,6 +1109,8 @@ int ath9k_init_device(u16 devid, struct + + wiphy_read_of_freq_limits(hw->wiphy); + ath_get_initial_entropy(sc); + @@ -110,7 +110,7 @@ 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 -@@ -1349,9 +1349,30 @@ void ar5008_hw_init_rate_txpower(struct +@@ -1340,9 +1340,30 @@ void ar5008_hw_init_rate_txpower(struct } } @@ -141,7 +141,7 @@ static const u32 ar5416_cca_regs[6] = { AR_PHY_CCA, AR_PHY_CH1_CCA, -@@ -1366,6 +1387,8 @@ int ar5008_hw_attach_phy_ops(struct ath_ +@@ -1357,6 +1378,8 @@ int ar5008_hw_attach_phy_ops(struct ath_ if (ret) return ret; diff --git a/package/kernel/mac80211/patches/ath9k/544-ath9k-ar933x-usb-hang-workaround.patch b/package/kernel/mac80211/patches/ath9k/544-ath9k-ar933x-usb-hang-workaround.patch index 93eee34b648..23a81864faa 100644 --- a/package/kernel/mac80211/patches/ath9k/544-ath9k-ar933x-usb-hang-workaround.patch +++ b/package/kernel/mac80211/patches/ath9k/544-ath9k-ar933x-usb-hang-workaround.patch @@ -1,6 +1,6 @@ --- 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 +@@ -247,6 +247,19 @@ void ath9k_hw_get_channel_centers(struct centers->synth_center + (extoff * HT40_CHANNEL_CENTER_SHIFT); } @@ -20,7 +20,7 @@ /******************/ /* Chip Revisions */ /******************/ -@@ -1455,6 +1468,9 @@ static bool ath9k_hw_set_reset(struct at +@@ -1454,6 +1467,9 @@ static bool ath9k_hw_set_reset(struct at udelay(50); } @@ -30,7 +30,7 @@ return true; } -@@ -1554,6 +1570,9 @@ static bool ath9k_hw_chip_reset(struct a +@@ -1553,6 +1569,9 @@ static bool ath9k_hw_chip_reset(struct a ar9003_hw_internal_regulator_apply(ah); ath9k_hw_init_pll(ah, chan); @@ -40,7 +40,7 @@ return true; } -@@ -1861,8 +1880,14 @@ static int ath9k_hw_do_fastcc(struct ath +@@ -1859,8 +1878,14 @@ static int ath9k_hw_do_fastcc(struct ath if (AR_SREV_9271(ah)) ar9002_hw_load_ani_reg(ah, chan); @@ -55,7 +55,7 @@ return -EINVAL; } -@@ -2116,6 +2141,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st +@@ -2114,6 +2139,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st ath9k_hw_set_radar_params(ah); } diff --git a/package/kernel/mac80211/patches/ath9k/545-ath9k_ani_ws_detect.patch b/package/kernel/mac80211/patches/ath9k/545-ath9k_ani_ws_detect.patch index 466767adb92..d3bf07ff922 100644 --- a/package/kernel/mac80211/patches/ath9k/545-ath9k_ani_ws_detect.patch +++ b/package/kernel/mac80211/patches/ath9k/545-ath9k_ani_ws_detect.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c -@@ -978,55 +978,6 @@ static bool ar5008_hw_ani_control_new(st +@@ -969,55 +969,6 @@ static bool ar5008_hw_ani_control_new(st * on == 0 means more noise imm */ u32 on = param ? 1 : 0; @@ -79,7 +79,7 @@ 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 +@@ -1068,11 +1054,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; @@ -91,7 +91,7 @@ s32 value, value2; switch (cmd & ah->ani_function) { -@@ -1095,61 +1076,6 @@ static bool ar9003_hw_ani_control(struct +@@ -1086,61 +1067,6 @@ static bool ar9003_hw_ani_control(struct */ u32 on = param ? 1 : 0; diff --git a/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch b/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch index 88198a45622..643d51285b0 100644 --- a/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch +++ b/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> --- --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -24,6 +24,7 @@ +@@ -25,6 +25,7 @@ #include <linux/completion.h> #include <linux/time.h> #include <linux/hw_random.h> @@ -91,7 +91,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> + gchip); + struct ath_hw *ah = gc->sc->sc_ah; + -+ return !((REG_READ(ah, AR_GPIO_OE_OUT) >> (offset * 2)) & 3); ++ return !((REG_READ(ah, AR_GPIO_OE_OUT(ah)) >> (offset * 2)) & 3); +} + +/* gpio_chip handler : get GPIO pin value */ diff --git a/package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch b/package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch deleted file mode 100644 index 7d3a334c42d..00000000000 --- a/package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- 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-<bus>-<id>.bin */ - scnprintf(eeprom_name, sizeof(eeprom_name), diff --git a/package/kernel/mac80211/patches/ath9k/551-ath9k_ubnt_uap_plus_hsr.patch b/package/kernel/mac80211/patches/ath9k/551-ath9k_ubnt_uap_plus_hsr.patch index cd2bdbf1a0c..efd2932446d 100644 --- a/package/kernel/mac80211/patches/ath9k/551-ath9k_ubnt_uap_plus_hsr.patch +++ b/package/kernel/mac80211/patches/ath9k/551-ath9k_ubnt_uap_plus_hsr.patch @@ -339,7 +339,7 @@ static void ath9k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop); -@@ -652,6 +653,7 @@ void ath_reset_work(struct work_struct * +@@ -659,6 +660,7 @@ void ath_reset_work(struct work_struct * static int ath9k_start(struct ieee80211_hw *hw) { struct ath_softc *sc = hw->priv; @@ -347,7 +347,7 @@ struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan; -@@ -730,6 +732,11 @@ static int ath9k_start(struct ieee80211_ +@@ -737,6 +739,11 @@ static int ath9k_start(struct ieee80211_ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); } @@ -371,7 +371,7 @@ --- a/local-symbols +++ b/local-symbols -@@ -113,6 +113,7 @@ ATH9K_WOW= +@@ -128,6 +128,7 @@ ATH9K_WOW= ATH9K_RFKILL= ATH9K_CHANNEL_CONTEXT= ATH9K_PCOEM= diff --git a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch index 8fd6e4409b0..637e607e366 100644 --- a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch +++ b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch @@ -16,7 +16,7 @@ static const struct platform_device_id ath9k_platform_id_table[] = { { -@@ -69,6 +77,242 @@ static const struct ath_bus_ops ath_ahb_ +@@ -69,6 +77,236 @@ static const struct ath_bus_ops ath_ahb_ .eeprom_read = ath_ahb_eeprom_read, }; @@ -218,12 +218,6 @@ + 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; + @@ -259,7 +253,7 @@ static int ath_ahb_probe(struct platform_device *pdev) { void __iomem *mem; -@@ -80,6 +324,17 @@ static int ath_ahb_probe(struct platform +@@ -80,6 +318,17 @@ static int ath_ahb_probe(struct platform int ret = 0; struct ath_hw *ah; char hw_name[64]; @@ -277,7 +271,7 @@ 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 +@@ -118,13 +367,16 @@ static int ath_ahb_probe(struct platform sc->mem = mem; sc->irq = irq; @@ -295,7 +289,7 @@ 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 +@@ -155,6 +407,9 @@ static int ath_ahb_remove(struct platfor free_irq(sc->irq, sc); ieee80211_free_hw(sc->hw); } @@ -305,7 +299,7 @@ return 0; } -@@ -168,6 +429,9 @@ static struct platform_driver ath_ahb_dr +@@ -164,6 +419,9 @@ static struct platform_driver ath_ahb_dr .remove = ath_ahb_remove, .driver = { .name = "ath9k", @@ -317,7 +311,7 @@ }; --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -25,6 +25,7 @@ +@@ -26,6 +26,7 @@ #include <linux/time.h> #include <linux/hw_random.h> #include <linux/gpio/driver.h> diff --git a/package/kernel/mac80211/patches/ath9k/553-ath9k_of_gpio_mask.patch b/package/kernel/mac80211/patches/ath9k/553-ath9k_of_gpio_mask.patch index 8e0041e3efc..752a4980a40 100644 --- a/package/kernel/mac80211/patches/ath9k/553-ath9k_of_gpio_mask.patch +++ b/package/kernel/mac80211/patches/ath9k/553-ath9k_of_gpio_mask.patch @@ -1,6 +1,6 @@ --- 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 +@@ -696,6 +696,12 @@ static int ath9k_of_init(struct ath_soft return 0; } @@ -13,7 +13,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) { -@@ -757,6 +763,9 @@ static int ath9k_init_softc(u16 devid, s +@@ -804,6 +810,9 @@ static int ath9k_init_softc(u16 devid, s if (ret) goto err_hw; diff --git a/package/kernel/mac80211/patches/brcm/812-b43-add-antenna-control.patch b/package/kernel/mac80211/patches/brcm/812-b43-add-antenna-control.patch index 52ae7a8ebaa..22b67c49d8e 100644 --- a/package/kernel/mac80211/patches/brcm/812-b43-add-antenna-control.patch +++ b/package/kernel/mac80211/patches/brcm/812-b43-add-antenna-control.patch @@ -20,7 +20,7 @@ if (phy->type == B43_PHYTYPE_B) { value16 = b43_read16(dev, 0x005E); -@@ -3985,7 +3985,6 @@ static int b43_op_config(struct ieee8021 +@@ -3986,7 +3986,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; @@ -28,7 +28,7 @@ int err = 0; mutex_lock(&wl->mutex); -@@ -4028,11 +4027,9 @@ static int b43_op_config(struct ieee8021 +@@ -4029,11 +4028,9 @@ static int b43_op_config(struct ieee8021 } /* Antennas for RX and management frame TX. */ @@ -89,8 +89,8 @@ + static const struct ieee80211_ops b43_hw_ops = { .tx = b43_op_tx, - .conf_tx = b43_op_conf_tx, -@@ -5197,6 +5235,8 @@ static const struct ieee80211_ops b43_hw + .wake_tx_queue = ieee80211_handle_wake_tx_queue, +@@ -5198,6 +5236,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, @@ -99,7 +99,7 @@ }; /* Hard-reset the chip. Do not call this directly. -@@ -5498,6 +5538,8 @@ static int b43_one_core_attach(struct b4 +@@ -5499,6 +5539,8 @@ static int b43_one_core_attach(struct b4 if (!wldev) goto out; @@ -108,7 +108,7 @@ wldev->use_pio = b43_modparam_pio; wldev->dev = dev; wldev->wl = wl; -@@ -5592,6 +5634,9 @@ static struct b43_wl *b43_wireless_init( +@@ -5590,6 +5632,9 @@ static struct b43_wl *b43_wireless_init( wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); diff --git a/package/kernel/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch b/package/kernel/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch index a8eae19413b..3700eaa1a06 100644 --- a/package/kernel/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch +++ b/package/kernel/mac80211/patches/brcm/815-b43-always-take-overlapping-devs.patch @@ -1,6 +1,6 @@ --- 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; +@@ -114,7 +114,7 @@ static int b43_modparam_pio; module_param_named(pio, b43_modparam_pio, int, 0644); MODULE_PARM_DESC(pio, "Use PIO accesses by default: 0=DMA, 1=PIO"); diff --git a/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch b/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch deleted file mode 100644 index c9730e29fdd..00000000000 --- a/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch +++ /dev/null @@ -1,64 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com> -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 <zajec5@gmail.com> ---- - ---- 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/package/kernel/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch b/package/kernel/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch index 7b4cb250f93..b06172ec0ef 100644 --- a/package/kernel/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch +++ b/package/kernel/mac80211/patches/brcm/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch @@ -10,7 +10,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c -@@ -715,8 +715,36 @@ static struct wireless_dev *brcmf_cfg802 +@@ -979,8 +979,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; diff --git a/package/kernel/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch b/package/kernel/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch index e640849e6ad..92e647816b4 100644 --- a/package/kernel/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch +++ b/package/kernel/mac80211/patches/brcm/862-brcmfmac-Disable-power-management.patch @@ -14,7 +14,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c -@@ -2958,6 +2958,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip +@@ -3327,6 +3327,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip * preference in cfg struct to apply this to * FW later while initializing the dongle */ diff --git a/package/kernel/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch b/package/kernel/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch index 9658bda1c17..f873528e263 100644 --- a/package/kernel/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch +++ b/package/kernel/mac80211/patches/brcm/863-brcmfmac-add-in-driver-tables-with-country-codes.patch @@ -12,9 +12,9 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- 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" +@@ -65,6 +65,36 @@ static int brcmf_of_get_country_codes(st + return 0; + } +/* TODO: FIXME: Use DT */ +static void brcmf_of_probe_cc(struct device *dev, @@ -49,12 +49,12 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl> void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, struct brcmf_mp_device *settings) { -@@ -43,6 +73,8 @@ void brcmf_of_probe(struct device *dev, +@@ -113,6 +143,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")) + if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac")) return; + diff --git a/package/kernel/mac80211/patches/brcm/865-brcmfmac-disable-dump_survey-on-bcm2835.patch b/package/kernel/mac80211/patches/brcm/865-brcmfmac-disable-dump_survey-on-bcm2835.patch new file mode 100644 index 00000000000..bb87c69ff38 --- /dev/null +++ b/package/kernel/mac80211/patches/brcm/865-brcmfmac-disable-dump_survey-on-bcm2835.patch @@ -0,0 +1,38 @@ +brcmfmac: disable dump_survey on Raspberry Pi + +Enabling this causes slow iwinfo calls on Raspberry Pi and LuCI slows down +when wireless is enabled. +https://github.com/openwrt/openwrt/issues/14013 + +Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +@@ -7987,6 +7987,7 @@ static s32 brcmf_translate_country_code( + return 0; + } + ++#if !defined(CONFIG_ARCH_BCM2835) + static int + brcmf_parse_dump_obss(char *buf, struct brcmf_dump_survey *survey) + { +@@ -8209,6 +8210,7 @@ exit: + brcmf_set_mpc(ifp, 1); + return err; + } ++#endif /* CONFIG_ARCH_BCM2835 */ + + static void brcmf_cfg80211_reg_notifier(struct wiphy *wiphy, + struct regulatory_request *req) +@@ -8361,8 +8363,10 @@ struct brcmf_cfg80211_info *brcmf_cfg802 + if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_WOWL_GTK)) + ops->set_rekey_data = brcmf_cfg80211_set_rekey_data; + #endif ++#if !defined(CONFIG_ARCH_BCM2835) + if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_DUMP_OBSS)) + ops->dump_survey = brcmf_cfg80211_dump_survey; ++#endif /* CONFIG_ARCH_BCM2835 */ + + err = wiphy_register(wiphy); + if (err < 0) { diff --git a/package/kernel/mac80211/patches/brcm/998-survey.patch b/package/kernel/mac80211/patches/brcm/998-survey.patch deleted file mode 100644 index 9e9f4bbf8fb..00000000000 --- a/package/kernel/mac80211/patches/brcm/998-survey.patch +++ /dev/null @@ -1,148 +0,0 @@ ---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c -+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c -@@ -2910,6 +2910,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) - { -@@ -3005,6 +3062,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; -@@ -3029,6 +3087,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()); -@@ -5515,6 +5584,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 -@@ -1356,6 +1356,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); -@@ -1438,6 +1440,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/package/kernel/mac80211/patches/build/003-remove_bogus_modparams.patch b/package/kernel/mac80211/patches/build/003-remove_bogus_modparams.patch index 8fa465a7e1c..aa26c8cb2ab 100644 --- a/package/kernel/mac80211/patches/build/003-remove_bogus_modparams.patch +++ b/package/kernel/mac80211/patches/build/003-remove_bogus_modparams.patch @@ -1,6 +1,6 @@ --- a/compat/main.c +++ b/compat/main.c -@@ -20,31 +20,6 @@ MODULE_LICENSE("GPL"); +@@ -19,31 +19,6 @@ MODULE_LICENSE("GPL"); #error "You need a CPTCFG_VERSION" #endif diff --git a/package/kernel/mac80211/patches/build/004-fix-kconf-compiling.patch b/package/kernel/mac80211/patches/build/004-fix-kconf-compiling.patch new file mode 100644 index 00000000000..8bae8367f76 --- /dev/null +++ b/package/kernel/mac80211/patches/build/004-fix-kconf-compiling.patch @@ -0,0 +1,47 @@ +--- a/Makefile.real ++++ b/Makefile.real +@@ -6,6 +6,18 @@ else + export BACKPORTS_GIT_TRACKER_DEF= + endif + ++ifneq ($(LLVM),) ++ifneq ($(filter %/,$(LLVM)),) ++LLVM_PREFIX := $(LLVM) ++else ifneq ($(filter -%,$(LLVM)),) ++LLVM_SUFFIX := $(LLVM) ++endif ++ ++HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX) ++else ++HOSTCC = gcc ++endif ++ + # disable built-in rules for this file + .SUFFIXES: + +@@ -24,21 +36,21 @@ listnewconfig oldaskconfig oldconfig \ + silentoldconfig olddefconfig oldnoconfig \ + allnoconfig allyesconfig allmodconfig \ + alldefconfig randconfig: +- @$(MAKE) -C kconf conf ++ @$(MAKE) -C kconf CC=$(HOSTCC) conf + @./kconf/conf --$@ Kconfig + + .PHONY: usedefconfig + usedefconfig: +- @$(MAKE) -C kconf conf ++ @$(MAKE) -C kconf CC=$(HOSTCC) conf + @./kconf/conf --defconfig=defconfig Kconfig + + .PHONY: savedefconfig + savedefconfig: +- @$(MAKE) -C kconf conf ++ @$(MAKE) -C kconf CC=$(HOSTCC) conf + @./kconf/conf --savedefconfig=defconfig Kconfig + + defconfig-%:: +- @$(MAKE) -C kconf conf ++ @$(MAKE) -C kconf CC=$(HOSTCC) conf + @./kconf/conf --defconfig=defconfigs/$(@:defconfig-%=%) Kconfig + + .config: diff --git a/package/kernel/mac80211/patches/build/004-kconfig_backport_fix.patch b/package/kernel/mac80211/patches/build/004-kconfig_backport_fix.patch deleted file mode 100644 index 2c9572ec93e..00000000000 --- a/package/kernel/mac80211/patches/build/004-kconfig_backport_fix.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/backport-include/linux/kconfig.h -+++ b/backport-include/linux/kconfig.h -@@ -5,6 +5,8 @@ - #include_next <linux/kconfig.h> - #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/package/kernel/mac80211/patches/build/010-disable_rfkill.patch b/package/kernel/mac80211/patches/build/010-disable_rfkill.patch deleted file mode 100644 index d5253063ce9..00000000000 --- a/package/kernel/mac80211/patches/build/010-disable_rfkill.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/backport-include/linux/rfkill.h -+++ b/backport-include/linux/rfkill.h -@@ -2,6 +2,12 @@ - #define __COMPAT_RFKILL_H - #include <linux/version.h> - -+#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 <linux/rfkill.h> - #else diff --git a/package/kernel/mac80211/patches/build/015-ipw200-mtu.patch b/package/kernel/mac80211/patches/build/015-ipw200-mtu.patch deleted file mode 100644 index 68db4f72d37..00000000000 --- a/package/kernel/mac80211/patches/build/015-ipw200-mtu.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- 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/package/kernel/mac80211/patches/build/050-lib80211_option.patch b/package/kernel/mac80211/patches/build/050-lib80211_option.patch deleted file mode 100644 index c1b1bc757f2..00000000000 --- a/package/kernel/mac80211/patches/build/050-lib80211_option.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/wireless/Kconfig -+++ b/net/wireless/Kconfig -@@ -188,7 +188,7 @@ config CFG80211_WEXT_EXPORT - endif # CFG80211 - - config LIB80211 -- tristate -+ tristate "lib80211" - depends on m - default n - help -@@ -198,19 +198,19 @@ 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 - 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/package/kernel/mac80211/patches/build/060-no_local_ssb_bcma.patch b/package/kernel/mac80211/patches/build/060-no_local_ssb_bcma.patch index ff2ce2071f5..451d0b79fcc 100644 --- a/package/kernel/mac80211/patches/build/060-no_local_ssb_bcma.patch +++ b/package/kernel/mac80211/patches/build/060-no_local_ssb_bcma.patch @@ -1,9 +1,9 @@ --- a/local-symbols +++ b/local-symbols -@@ -437,43 +437,6 @@ USB_SIERRA_NET= - USB_VL600= +@@ -491,43 +491,6 @@ USB_VL600= USB_NET_CH9200= USB_NET_AQC111= + USB_RTL8153_ECM= -SSB_POSSIBLE= -SSB= -SSB_SPROM= @@ -99,7 +99,7 @@ return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev); #else return bus->chipco.dev; -@@ -4870,7 +4870,7 @@ static int b43_wireless_core_init(struct +@@ -4871,7 +4871,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. */ @@ -158,27 +158,6 @@ 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 -@@ -24,7 +24,7 @@ struct brcms_led { - struct gpio_desc *gpiod; - }; - --#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 @@ -187,15 +166,15 @@ 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 + depends on FW_LOADER + depends on CORDIC --- a/Kconfig.local +++ b/Kconfig.local -@@ -1315,117 +1315,6 @@ config BACKPORTED_USB_NET_CH9200 - config BACKPORTED_USB_NET_AQC111 +@@ -1477,117 +1477,6 @@ config BACKPORTED_USB_NET_AQC111 + config BACKPORTED_USB_RTL8153_ECM tristate - default USB_NET_AQC111 + default USB_RTL8153_ECM -config BACKPORTED_SSB_POSSIBLE - tristate - default SSB_POSSIBLE @@ -312,7 +291,7 @@ default USB_ACM --- a/Kconfig.sources +++ b/Kconfig.sources -@@ -7,9 +7,6 @@ source "$BACKPORT_DIR/net/mac80211/Kconf +@@ -10,9 +10,6 @@ source "$BACKPORT_DIR/drivers/soc/qcom/K source "$BACKPORT_DIR/drivers/net/wireless/Kconfig" source "$BACKPORT_DIR/drivers/net/usb/Kconfig" @@ -324,9 +303,9 @@ 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/ +@@ -43,8 +43,6 @@ obj-$(CPTCFG_QRTR) += net/qrtr/ + obj-$(CPTCFG_QCOM_QMI_HELPERS) += drivers/soc/qcom/ + obj-$(CPTCFG_MHI_BUS) += drivers/bus/mhi/ obj-$(CPTCFG_WLAN) += drivers/net/wireless/ -obj-$(CPTCFG_SSB) += drivers/ssb/ -obj-$(CPTCFG_BCMA) += drivers/bcma/ diff --git a/package/kernel/mac80211/patches/build/070-remove-broken-wext-select.patch b/package/kernel/mac80211/patches/build/070-remove-broken-wext-select.patch new file mode 100644 index 00000000000..121b7faad93 --- /dev/null +++ b/package/kernel/mac80211/patches/build/070-remove-broken-wext-select.patch @@ -0,0 +1,10 @@ +--- a/drivers/staging/rtl8723bs/Kconfig ++++ b/drivers/staging/rtl8723bs/Kconfig +@@ -5,7 +5,6 @@ config RTL8723BS + depends on m + depends on WLAN && MMC && CFG80211 + depends on m +- select CFG80211_WEXT + depends on CRYPTO + select BPAUTO_CRYPTO_LIB_ARC4 + help diff --git a/package/kernel/mac80211/patches/build/080-resv_start_op.patch b/package/kernel/mac80211/patches/build/080-resv_start_op.patch new file mode 100644 index 00000000000..802a0e3fc8a --- /dev/null +++ b/package/kernel/mac80211/patches/build/080-resv_start_op.patch @@ -0,0 +1,24 @@ +--- a/drivers/net/wireless/virtual/mac80211_hwsim.c ++++ b/drivers/net/wireless/virtual/mac80211_hwsim.c +@@ -6179,7 +6179,9 @@ static struct genl_family hwsim_genl_fam + .module = THIS_MODULE, + .small_ops = hwsim_ops, + .n_small_ops = ARRAY_SIZE(hwsim_ops), ++#if LINUX_VERSION_IS_GEQ(6,1,0) + .resv_start_op = HWSIM_CMD_REPORT_PMSR + 1, // match with __HWSIM_CMD_MAX ++#endif + .mcgrps = hwsim_mcgrps, + .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps), + }; +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -17509,7 +17509,9 @@ static struct genl_family nl80211_fam __ + .n_ops = ARRAY_SIZE(nl80211_ops), + .small_ops = nl80211_small_ops, + .n_small_ops = ARRAY_SIZE(nl80211_small_ops), ++#if LINUX_VERSION_IS_GEQ(6,1,0) + .resv_start_op = NL80211_CMD_REMOVE_LINK_STA + 1, ++#endif + .mcgrps = nl80211_mcgrps, + .n_mcgrps = ARRAY_SIZE(nl80211_mcgrps), + .parallel_ops = true, diff --git a/package/kernel/mac80211/patches/build/090-bcma-otp.patch b/package/kernel/mac80211/patches/build/090-bcma-otp.patch new file mode 100644 index 00000000000..39747761246 --- /dev/null +++ b/package/kernel/mac80211/patches/build/090-bcma-otp.patch @@ -0,0 +1,13 @@ +--- /dev/null ++++ b/backport-include/linux/bcma/bcma_driver_chipcommon.h +@@ -0,0 +1,10 @@ ++#ifndef __BACKPORT_BCMA_DRIVER_CHIPCOMMON_H ++#define __BACKPORT_BCMA_DRIVER_CHIPCOMMON_H ++ ++#include_next <linux/bcma/bcma_driver_chipcommon.h> ++ ++#ifndef BCMA_CC_SROM_CONTROL_OTP_PRESENT ++#define BCMA_CC_SROM_CONTROL_OTP_PRESENT 0x00000020 ++#endif ++ ++#endif diff --git a/package/kernel/mac80211/patches/build/100-backports-drop-QRTR-and-MHI.patch b/package/kernel/mac80211/patches/build/100-backports-drop-QRTR-and-MHI.patch new file mode 100644 index 00000000000..b017a0ce146 --- /dev/null +++ b/package/kernel/mac80211/patches/build/100-backports-drop-QRTR-and-MHI.patch @@ -0,0 +1,76 @@ +From 54e0f9aaf340377fb76acdffee9ec7372c4b70ae Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Mon, 17 Oct 2022 11:35:36 +0200 +Subject: [PATCH] backports: drop QRTR and MHI + +Backports currently include QRTR and MHI due to ath11k-pci requiring them, +however this at the same time prevents us from adding ath11k-ahb as it +also requires QRTR however its AHB variant from the kernel will conflict +with the core provided by backports. + +Since MHI also conflicts with existing OpenWrt kmods providing MHI drop +both from backports and use the ones provided by OpenWrt kernel. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + Kconfig.sources | 2 -- + Makefile.kernel | 2 -- + drivers/net/wireless/ath/ath11k/Kconfig | 6 +++--- + local-symbols | 8 -------- + 4 files changed, 3 insertions(+), 15 deletions(-) + +--- a/Kconfig.sources ++++ b/Kconfig.sources +@@ -4,8 +4,6 @@ source "$BACKPORT_DIR/compat/Kconfig" + # these are copied from the kernel + source "$BACKPORT_DIR/net/wireless/Kconfig" + source "$BACKPORT_DIR/net/mac80211/Kconfig" +-source "$BACKPORT_DIR/net/qrtr/Kconfig" +-source "$BACKPORT_DIR/drivers/bus/mhi/Kconfig" + source "$BACKPORT_DIR/drivers/soc/qcom/Kconfig" + source "$BACKPORT_DIR/drivers/net/wireless/Kconfig" + source "$BACKPORT_DIR/drivers/net/usb/Kconfig" +--- a/Makefile.kernel ++++ b/Makefile.kernel +@@ -39,9 +39,7 @@ obj-y += compat/ + + obj-$(CPTCFG_CFG80211) += net/wireless/ + obj-$(CPTCFG_MAC80211) += net/mac80211/ +-obj-$(CPTCFG_QRTR) += net/qrtr/ + obj-$(CPTCFG_QCOM_QMI_HELPERS) += drivers/soc/qcom/ +-obj-$(CPTCFG_MHI_BUS) += drivers/bus/mhi/ + obj-$(CPTCFG_WLAN) += drivers/net/wireless/ + obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/ + +--- a/drivers/net/wireless/ath/ath11k/Kconfig ++++ b/drivers/net/wireless/ath/ath11k/Kconfig +@@ -25,9 +25,9 @@ config ATH11K_PCI + tristate "Atheros ath11k PCI support" + depends on m + depends on ATH11K && PCI +- select MHI_BUS +- select QRTR +- select QRTR_MHI ++ depends on MHI_BUS ++ depends on QRTR ++ depends on QRTR_MHI + help + This module adds support for PCIE bus + +--- a/local-symbols ++++ b/local-symbols +@@ -65,14 +65,6 @@ MAC80211_MESH_PS_DEBUG= + MAC80211_TDLS_DEBUG= + MAC80211_DEBUG_COUNTERS= + MAC80211_STA_HASH_MAX_SIZE= +-QRTR= +-QRTR_SMD= +-QRTR_TUN= +-QRTR_MHI= +-MHI_BUS= +-MHI_BUS_DEBUG= +-MHI_BUS_PCI_GENERIC= +-MHI_BUS_EP= + QCOM_AOSS_QMP= + QCOM_COMMAND_DB= + QCOM_CPR= diff --git a/package/kernel/mac80211/patches/build/110-backport_namepace_const.patch b/package/kernel/mac80211/patches/build/110-backport_namepace_const.patch new file mode 100644 index 00000000000..6dca708edf7 --- /dev/null +++ b/package/kernel/mac80211/patches/build/110-backport_namepace_const.patch @@ -0,0 +1,14 @@ +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -154,7 +154,11 @@ static SIMPLE_DEV_PM_OPS(wiphy_pm_ops, w + #define WIPHY_PM_OPS NULL + #endif + ++#if LINUX_VERSION_IS_GEQ(6,2,0) + static const void *wiphy_namespace(const struct device *d) ++#else ++static const void *wiphy_namespace(struct device *d) ++#endif + { + struct wiphy *wiphy = container_of(d, struct wiphy, dev); + diff --git a/package/kernel/mac80211/patches/build/120-headers_version_fix.patch b/package/kernel/mac80211/patches/build/120-headers_version_fix.patch new file mode 100644 index 00000000000..9a8c4749b2f --- /dev/null +++ b/package/kernel/mac80211/patches/build/120-headers_version_fix.patch @@ -0,0 +1,25 @@ +--- a/backport-include/linux/random.h ++++ b/backport-include/linux/random.h +@@ -23,7 +23,7 @@ static inline u16 get_random_u16(void) + } + #endif + +-#if LINUX_VERSION_IS_LESS(6,2,0) ++#if LINUX_VERSION_IS_LESS(6,1,4) + static inline u32 __get_random_u32_below(u32 ceil) + { + /* +--- a/backport-include/net/dropreason.h ++++ b/backport-include/net/dropreason.h +@@ -3,10 +3,9 @@ + + #include <linux/version.h> + ++#include <net/dropreason-core.h> + #if LINUX_VERSION_IS_GEQ(6,0,0) + #include_next <net/dropreason.h> +-#else +-#include <net/dropreason-core.h> + #endif + + #if LINUX_VERSION_IS_LESS(6,4,0) diff --git a/package/kernel/mac80211/patches/build/130-iommu_backport.patch b/package/kernel/mac80211/patches/build/130-iommu_backport.patch new file mode 100644 index 00000000000..2d3ef88d645 --- /dev/null +++ b/package/kernel/mac80211/patches/build/130-iommu_backport.patch @@ -0,0 +1,26 @@ +--- /dev/null ++++ b/backport-include/linux/iommu.h +@@ -0,0 +1,23 @@ ++#ifndef __BACKPORT_LINUX_IOMMU_H ++#define __BACKPORT_LINUX_IOMMU_H ++ ++#include_next <linux/iommu.h> ++#include <linux/version.h> ++ ++#if LINUX_VERSION_IS_LESS(6,3,0) ++ ++static inline int LINUX_BACKPORT(iommu_map)(struct iommu_domain *domain, ++ unsigned long iova, ++ phys_addr_t paddr, size_t size, ++ int prot, gfp_t gfp) ++{ ++ if (gfp == GFP_ATOMIC) ++ return iommu_map_atomic(domain, iova, paddr, size, prot); ++ ++ return iommu_map(domain, iova, paddr, size, prot); ++} ++#define iommu_map LINUX_BACKPORT(iommu_map) ++ ++#endif /* < 6.3 */ ++ ++#endif diff --git a/package/kernel/mac80211/patches/build/200-Revert-wifi-iwlwifi-Use-generic-thermal_zone_get_tri.patch b/package/kernel/mac80211/patches/build/200-Revert-wifi-iwlwifi-Use-generic-thermal_zone_get_tri.patch new file mode 100644 index 00000000000..3a5285d2f35 --- /dev/null +++ b/package/kernel/mac80211/patches/build/200-Revert-wifi-iwlwifi-Use-generic-thermal_zone_get_tri.patch @@ -0,0 +1,159 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Mon, 17 Apr 2023 19:42:38 +0200 +Subject: [PATCH] Revert "wifi: iwlwifi: Use generic thermal_zone_get_trip() + function" + +This reverts commit 3d2f20ad46f83b333025f5e8e4afc34be8f13c4c. +--- + +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +@@ -531,7 +531,7 @@ struct iwl_mvm_tt_mgmt { + * @tzone: thermal zone device data + */ + struct iwl_mvm_thermal_device { +- struct thermal_trip trips[IWL_MAX_DTS_TRIPS]; ++ s16 temp_trips[IWL_MAX_DTS_TRIPS]; + u8 fw_trips_index[IWL_MAX_DTS_TRIPS]; + struct thermal_zone_device *tzone; + }; +--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +@@ -573,11 +573,11 @@ int iwl_mvm_send_temp_report_ths_cmd(str + * and uncompressed, the FW should get it compressed and sorted + */ + +- /* compress trips to cmd array, remove uninitialized values*/ ++ /* compress temp_trips to cmd array, remove uninitialized values*/ + for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { +- if (mvm->tz_device.trips[i].temperature != INT_MIN) { ++ if (mvm->tz_device.temp_trips[i] != S16_MIN) { + cmd.thresholds[idx++] = +- cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000)); ++ cpu_to_le16(mvm->tz_device.temp_trips[i]); + } + } + cmd.num_temps = cpu_to_le32(idx); +@@ -593,8 +593,8 @@ int iwl_mvm_send_temp_report_ths_cmd(str + */ + for (i = 0; i < idx; i++) { + for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) { +- if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) == +- mvm->tz_device.trips[j].temperature) ++ if (le16_to_cpu(cmd.thresholds[i]) == ++ mvm->tz_device.temp_trips[j]) + mvm->tz_device.fw_trips_index[i] = j; + } + } +@@ -638,12 +638,37 @@ out: + return ret; + } + ++static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device, ++ int trip, int *temp) ++{ ++ struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; ++ ++ if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) ++ return -EINVAL; ++ ++ *temp = mvm->tz_device.temp_trips[trip] * 1000; ++ ++ return 0; ++} ++ ++static int iwl_mvm_tzone_get_trip_type(struct thermal_zone_device *device, ++ int trip, enum thermal_trip_type *type) ++{ ++ if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) ++ return -EINVAL; ++ ++ *type = THERMAL_TRIP_PASSIVE; ++ ++ return 0; ++} ++ + static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, + int trip, int temp) + { + struct iwl_mvm *mvm = thermal_zone_device_priv(device); + struct iwl_mvm_thermal_device *tzone; +- int ret; ++ int i, ret; ++ s16 temperature; + + mutex_lock(&mvm->mutex); + +@@ -653,17 +678,40 @@ static int iwl_mvm_tzone_set_trip_temp(s + goto out; + } + ++ if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) { ++ ret = -EINVAL; ++ goto out; ++ } ++ + if ((temp / 1000) > S16_MAX) { + ret = -EINVAL; + goto out; + } + ++ temperature = (s16)(temp / 1000); + tzone = &mvm->tz_device; ++ + if (!tzone) { + ret = -EIO; + goto out; + } + ++ /* no updates*/ ++ if (tzone->temp_trips[trip] == temperature) { ++ ret = 0; ++ goto out; ++ } ++ ++ /* already existing temperature */ ++ for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { ++ if (tzone->temp_trips[i] == temperature) { ++ ret = -EINVAL; ++ goto out; ++ } ++ } ++ ++ tzone->temp_trips[trip] = temperature; ++ + ret = iwl_mvm_send_temp_report_ths_cmd(mvm); + out: + mutex_unlock(&mvm->mutex); +@@ -672,6 +720,8 @@ out: + + static struct thermal_zone_device_ops tzone_ops = { + .get_temp = iwl_mvm_tzone_get_temp, ++ .get_trip_temp = iwl_mvm_tzone_get_trip_temp, ++ .get_trip_type = iwl_mvm_tzone_get_trip_type, + .set_trip_temp = iwl_mvm_tzone_set_trip_temp, + }; + +@@ -693,8 +743,7 @@ static void iwl_mvm_thermal_zone_registe + BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH); + + sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF); +- mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, +- mvm->tz_device.trips, ++ mvm->tz_device.tzone = thermal_zone_device_register(name, + IWL_MAX_DTS_TRIPS, + IWL_WRITABLE_TRIPS_MSK, + mvm, &tzone_ops, +@@ -717,10 +766,8 @@ static void iwl_mvm_thermal_zone_registe + /* 0 is a valid temperature, + * so initialize the array with S16_MIN which invalid temperature + */ +- for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) { +- mvm->tz_device.trips[i].temperature = INT_MIN; +- mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; +- } ++ for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) ++ mvm->tz_device.temp_trips[i] = S16_MIN; + } + + static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev, diff --git a/package/kernel/mac80211/patches/build/210-revert-split-op.patch b/package/kernel/mac80211/patches/build/210-revert-split-op.patch new file mode 100644 index 00000000000..a1fae5e07da --- /dev/null +++ b/package/kernel/mac80211/patches/build/210-revert-split-op.patch @@ -0,0 +1,22 @@ +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -16400,8 +16400,7 @@ static u32 nl80211_internal_flags[] = { + #undef SELECTOR + }; + +-static int nl80211_pre_doit(const struct genl_split_ops *ops, +- struct sk_buff *skb, ++static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, + struct genl_info *info) + { + struct cfg80211_registered_device *rdev = NULL; +@@ -16502,8 +16501,7 @@ out_unlock: + return err; + } + +-static void nl80211_post_doit(const struct genl_split_ops *ops, +- struct sk_buff *skb, ++static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, + struct genl_info *info) + { + u32 internal_flags = nl80211_internal_flags[ops->internal_flags]; diff --git a/package/kernel/mac80211/patches/build/220-list-don-t-backport-list_count_nodes.patch b/package/kernel/mac80211/patches/build/220-list-don-t-backport-list_count_nodes.patch new file mode 100644 index 00000000000..6d3000278b1 --- /dev/null +++ b/package/kernel/mac80211/patches/build/220-list-don-t-backport-list_count_nodes.patch @@ -0,0 +1,26 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl> +Date: Fri, 15 Dec 2023 10:17:21 +0100 +Subject: [PATCH] list: don't backport list_count_nodes() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It's redundant in OpenWrt as it backports it on its own. This fixes: +backport-include/linux/list.h:11:22: error: redefinition of 'list_count_nodes' + +Signed-off-by: Rafał Miłecki <rafal@milecki.pl> +--- + backport-include/linux/list.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/backport-include/linux/list.h ++++ b/backport-include/linux/list.h +@@ -3,7 +3,7 @@ + #include_next <linux/list.h> + #include <linux/version.h> + +-#if LINUX_VERSION_IS_LESS(6,3,0) ++#if 0 /* OpenWrt backports list_count_nodes() on its own */ + /** + * list_count_nodes - count nodes in the list + * @head: the head for your list. diff --git a/package/kernel/mac80211/patches/mt7601u/001-wifi-mt7601u-update-firmware-path.patch b/package/kernel/mac80211/patches/mt7601u/001-wifi-mt7601u-update-firmware-path.patch new file mode 100644 index 00000000000..5d982906c56 --- /dev/null +++ b/package/kernel/mac80211/patches/mt7601u/001-wifi-mt7601u-update-firmware-path.patch @@ -0,0 +1,55 @@ +From patchwork Mon May 15 22:56:53 2023 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle <daniel@makrotopia.org> +X-Patchwork-Id: 13242309 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: <linux-wireless-owner@vger.kernel.org> +Date: Tue, 16 May 2023 00:56:53 +0200 +From: Daniel Golle <daniel@makrotopia.org> +To: Jakub Kicinski <kuba@kernel.org>, Kalle Valo <kvalo@kernel.org>, + "David S. Miller" <davem@davemloft.net>, + Eric Dumazet <edumazet@google.com>, + Paolo Abeni <pabeni@redhat.com>, + Matthias Brugger <matthias.bgg@gmail.com>, + AngeloGioacchino Del Regno + <angelogioacchino.delregno@collabora.com>, + linux-wireless@vger.kernel.org, netdev@vger.kernel.org, + linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, + linux-mediatek@lists.infradead.org +Subject: [PATCH] wifi: mt7601u: update firmware path +Message-ID: + <fefcbf36f13873ae0d97438a0156b87e7e1ae64e.1684191377.git.daniel@makrotopia.org> +MIME-Version: 1.0 +Content-Disposition: inline +Precedence: bulk +List-ID: <linux-wireless.vger.kernel.org> +X-Mailing-List: linux-wireless@vger.kernel.org + +mt7601u.bin was moved to mediatek/ folder in linux-wireless via commit +8451c2b1 ("mt76xx: Move the old Mediatek WiFi firmware to mediatek") +and linux-firmware release 20230515. + +Update the firmware path requested by the mt7601u driver to follow up +with the move of the file. + +Signed-off-by: Daniel Golle <daniel@makrotopia.org> +--- + drivers/net/wireless/mediatek/mt7601u/usb.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + +base-commit: 0d9b41daa5907756a31772d8af8ac5ff25cf17c1 + +--- a/drivers/net/wireless/mediatek/mt7601u/usb.h ++++ b/drivers/net/wireless/mediatek/mt7601u/usb.h +@@ -8,7 +8,7 @@ + + #include "mt7601u.h" + +-#define MT7601U_FIRMWARE "mt7601u.bin" ++#define MT7601U_FIRMWARE "mediatek/mt7601u.bin" + + #define MT_VEND_REQ_MAX_RETRY 10 + #define MT_VEND_REQ_TOUT_MS 300 diff --git a/package/kernel/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch b/package/kernel/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch index d358cfe3676..11536651b5e 100644 --- a/package/kernel/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch +++ b/package/kernel/mac80211/patches/mwl/700-mwl8k-missing-pci-id-for-WNR854T.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/marvell/mwl8k.c +++ b/drivers/net/wireless/marvell/mwl8k.c -@@ -5695,6 +5695,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw") +@@ -5703,6 +5703,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[] = { diff --git a/package/kernel/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch b/package/kernel/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch index dfa0e502fc5..4d9d3de4655 100644 --- a/package/kernel/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch +++ b/package/kernel/mac80211/patches/mwl/801-libertas-configure-sysfs-links.patch @@ -1,6 +1,6 @@ --- 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 +@@ -2101,6 +2101,8 @@ struct wireless_dev *lbs_cfg_alloc(struc goto err_wiphy_new; } diff --git a/package/kernel/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch b/package/kernel/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch index c2d0a5890d2..9aa559979c3 100644 --- a/package/kernel/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch +++ b/package/kernel/mac80211/patches/mwl/802-libertas-set-wireless-macaddr.patch @@ -1,6 +1,6 @@ --- 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 +@@ -2178,6 +2178,8 @@ int lbs_cfg_register(struct lbs_private wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); wdev->wiphy->reg_notifier = lbs_reg_notifier; diff --git a/package/kernel/mac80211/patches/mwl/900-mwifiex-increase-the-global-limit-up-to-4-SSID.patch b/package/kernel/mac80211/patches/mwl/900-mwifiex-increase-the-global-limit-up-to-4-SSID.patch new file mode 100644 index 00000000000..caa139a2c6e --- /dev/null +++ b/package/kernel/mac80211/patches/mwl/900-mwifiex-increase-the-global-limit-up-to-4-SSID.patch @@ -0,0 +1,41 @@ +From ef8098cd6cb8b5989afef2e8461fe6ba9570a854 Mon Sep 17 00:00:00 2001 +From: Josef Schlehofer <pepe.schlehofer@gmail.com> +Date: Wed, 24 Nov 2021 12:47:40 +0100 +Subject: [PATCH] mwifiex: increase the global limit up to 4 SSID + +Firmware for SDIO (88W8997), which is used in Turris MOX SDIO addon [1], +allows up to 4 SSID. Unfortunately, driver (even in mainline kernel) +has a global limit for all Marvell cards up to 3 SSID. + +Pali Rohár tested this patch and verified that the SDIO Wi-Fi addon works +with the 4 SSID. So, let's increase the global limit from 3 to 4. + +Ideally, this patch should be done differently before sending +it to Linux kernel. It means that limit definition should be moved to +the card-specific structure. + +[1] https://docs.turris.cz/hw/mox/addons/#wi-fi-sdio +--- + drivers/net/wireless/marvell/mwifiex/decl.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/marvell/mwifiex/decl.h ++++ b/drivers/net/wireless/marvell/mwifiex/decl.h +@@ -18,7 +18,7 @@ + #include <net/cfg80211.h> + + #define MWIFIEX_BSS_COEX_COUNT 2 +-#define MWIFIEX_MAX_BSS_NUM (3) ++#define MWIFIEX_MAX_BSS_NUM (4) + + #define MWIFIEX_DMA_ALIGN_SZ 64 + #define MWIFIEX_RX_HEADROOM 64 +@@ -100,7 +100,7 @@ + #define MWIFIEX_RATE_INDEX_OFDM0 4 + + #define MWIFIEX_MAX_STA_NUM 3 +-#define MWIFIEX_MAX_UAP_NUM 3 ++#define MWIFIEX_MAX_UAP_NUM 4 + #define MWIFIEX_MAX_P2P_NUM 3 + + #define MWIFIEX_A_BAND_START_FREQ 5000 diff --git a/package/kernel/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch b/package/kernel/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch index a35cf1875ac..c8d24283aad 100644 --- a/package/kernel/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch +++ b/package/kernel/mac80211/patches/mwl/940-mwl8k_init_devices_synchronously.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/marvell/mwl8k.c +++ b/drivers/net/wireless/marvell/mwl8k.c -@@ -6280,6 +6280,8 @@ static int mwl8k_probe(struct pci_dev *p +@@ -6289,6 +6289,8 @@ static int mwl8k_probe(struct pci_dev *p priv->running_bsses = 0; @@ -9,7 +9,7 @@ return rc; err_stop_firmware: -@@ -6313,8 +6315,6 @@ static void mwl8k_remove(struct pci_dev +@@ -6322,8 +6324,6 @@ static void mwl8k_remove(struct pci_dev return; priv = hw->priv; diff --git a/package/kernel/mac80211/patches/mwl/950-mwifiex-Print-stringified-name-of-command-in-error-l.patch b/package/kernel/mac80211/patches/mwl/950-mwifiex-Print-stringified-name-of-command-in-error-l.patch new file mode 100644 index 00000000000..628b9f8a123 --- /dev/null +++ b/package/kernel/mac80211/patches/mwl/950-mwifiex-Print-stringified-name-of-command-in-error-l.patch @@ -0,0 +1,189 @@ +From f7252b1b5755150535af226e806594bbefd45e0f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org> +Date: Sun, 26 Sep 2021 14:39:44 +0200 +Subject: [PATCH] mwifiex: Print stringified name of command in error log +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Failed hex command number in error log is hard to understand. +So add also more human readable stringified command name into error log. + +Signed-off-by: Pali Rohár <pali@kernel.org> +--- + drivers/net/wireless/marvell/mwifiex/cmdevt.c | 96 +++++++++++++++++-- + drivers/net/wireless/marvell/mwifiex/main.h | 2 + + .../wireless/marvell/mwifiex/sta_cmdresp.c | 5 +- + .../net/wireless/marvell/mwifiex/uap_cmd.c | 3 +- + 4 files changed, 95 insertions(+), 11 deletions(-) + +--- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c ++++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c +@@ -16,6 +16,85 @@ + + static void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter); + ++const char * ++mwifiex_cmd_to_str(u16 command) ++{ ++ switch (command) { ++ case HostCmd_CMD_GET_HW_SPEC: return "GET_HW_SPEC"; ++ case HostCmd_CMD_802_11_SCAN: return "SCAN"; ++ case HostCmd_CMD_802_11_GET_LOG: return "GET_LOG"; ++ case HostCmd_CMD_MAC_MULTICAST_ADR: return "MAC_MULTICAST_ADR"; ++ case HostCmd_CMD_802_11_EEPROM_ACCESS: return "EEPROM_ACCESS"; ++ case HostCmd_CMD_802_11_ASSOCIATE: return "ASSOCIATE"; ++ case HostCmd_CMD_802_11_SNMP_MIB: return "SNMP_MIB"; ++ case HostCmd_CMD_MAC_REG_ACCESS: return "MAC_REG_ACCESS"; ++ case HostCmd_CMD_BBP_REG_ACCESS: return "BBP_REG_ACCESS"; ++ case HostCmd_CMD_RF_REG_ACCESS: return "RF_REG_ACCESS"; ++ case HostCmd_CMD_PMIC_REG_ACCESS: return "PMIC_REG_ACCESS"; ++ case HostCmd_CMD_RF_TX_PWR: return "RF_TX_PWR"; ++ case HostCmd_CMD_RF_ANTENNA: return "RF_ANTENNA"; ++ case HostCmd_CMD_802_11_DEAUTHENTICATE: return "DEAUTHENTICATE"; ++ case HostCmd_CMD_MAC_CONTROL: return "MAC_CONTROL"; ++ case HostCmd_CMD_802_11_AD_HOC_START: return "AD_HOC_START"; ++ case HostCmd_CMD_802_11_AD_HOC_JOIN: return "AD_HOC_JOIN"; ++ case HostCmd_CMD_802_11_AD_HOC_STOP: return "AD_HOC_STOP"; ++ case HostCmd_CMD_802_11_MAC_ADDRESS: return "MAC_ADDRESS"; ++ case HostCmd_CMD_802_11D_DOMAIN_INFO: return "DOMAIN_INFO"; ++ case HostCmd_CMD_802_11_KEY_MATERIAL: return "KEY_MATERIAL"; ++ case HostCmd_CMD_802_11_BG_SCAN_CONFIG: return "BG_SCAN_CONFIG"; ++ case HostCmd_CMD_802_11_BG_SCAN_QUERY: return "BG_SCAN_QUERY"; ++ case HostCmd_CMD_WMM_GET_STATUS: return "WMM_GET_STATUS"; ++ case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: return "SUBSCRIBE_EVENT"; ++ case HostCmd_CMD_802_11_TX_RATE_QUERY: return "TX_RATE_QUERY"; ++ case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: return "IBSS_COALESCING_STATUS"; ++ case HostCmd_CMD_MEM_ACCESS: return "MEM_ACCESS"; ++ case HostCmd_CMD_CFG_DATA: return "CFG_DATA"; ++ case HostCmd_CMD_VERSION_EXT: return "VERSION_EXT"; ++ case HostCmd_CMD_MEF_CFG: return "MEF_CFG"; ++ case HostCmd_CMD_RSSI_INFO: return "RSSI_INFO"; ++ case HostCmd_CMD_FUNC_INIT: return "FUNC_INIT"; ++ case HostCmd_CMD_FUNC_SHUTDOWN: return "FUNC_SHUTDOWN"; ++ case HOST_CMD_APCMD_SYS_RESET: return "SYS_RESET"; ++ case HostCmd_CMD_UAP_SYS_CONFIG: return "UAP_SYS_CONFIG"; ++ case HostCmd_CMD_UAP_BSS_START: return "UAP_BSS_START"; ++ case HostCmd_CMD_UAP_BSS_STOP: return "UAP_BSS_STOP"; ++ case HOST_CMD_APCMD_STA_LIST: return "STA_LIST"; ++ case HostCmd_CMD_UAP_STA_DEAUTH: return "UAP_STA_DEAUTH"; ++ case HostCmd_CMD_11N_CFG: return "11N_CFG"; ++ case HostCmd_CMD_11N_ADDBA_REQ: return "ADDBA_REQ"; ++ case HostCmd_CMD_11N_ADDBA_RSP: return "ADDBA_RSP"; ++ case HostCmd_CMD_11N_DELBA: return "DELBA"; ++ case HostCmd_CMD_RECONFIGURE_TX_BUFF: return "RECONFIGURE_TX_BUFF"; ++ case HostCmd_CMD_CHAN_REPORT_REQUEST: return "CHAN_REPORT_REQUEST"; ++ case HostCmd_CMD_AMSDU_AGGR_CTRL: return "AMSDU_AGGR_CTRL"; ++ case HostCmd_CMD_TXPWR_CFG: return "TXPWR_CFG"; ++ case HostCmd_CMD_TX_RATE_CFG: return "TX_RATE_CFG"; ++ case HostCmd_CMD_ROBUST_COEX: return "ROBUST_COEX"; ++ case HostCmd_CMD_802_11_PS_MODE_ENH: return "PS_MODE_ENH"; ++ case HostCmd_CMD_802_11_HS_CFG_ENH: return "HS_CFG_ENH"; ++ case HostCmd_CMD_P2P_MODE_CFG: return "P2P_MODE_CFG"; ++ case HostCmd_CMD_CAU_REG_ACCESS: return "CAU_REG_ACCESS"; ++ case HostCmd_CMD_SET_BSS_MODE: return "SET_BSS_MODE"; ++ case HostCmd_CMD_PCIE_DESC_DETAILS: return "PCIE_DESC_DETAILS"; ++ case HostCmd_CMD_802_11_SCAN_EXT: return "SCAN_EXT"; ++ case HostCmd_CMD_COALESCE_CFG: return "COALESCE_CFG"; ++ case HostCmd_CMD_MGMT_FRAME_REG: return "MGMT_FRAME_REG"; ++ case HostCmd_CMD_REMAIN_ON_CHAN: return "REMAIN_ON_CHAN"; ++ case HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG: return "GTK_REKEY_OFFLOAD_CFG"; ++ case HostCmd_CMD_11AC_CFG: return "11AC_CFG"; ++ case HostCmd_CMD_HS_WAKEUP_REASON: return "HS_WAKEUP_REASON"; ++ case HostCmd_CMD_TDLS_CONFIG: return "TDLS_CONFIG"; ++ case HostCmd_CMD_MC_POLICY: return "MC_POLICY"; ++ case HostCmd_CMD_TDLS_OPER: return "TDLS_OPER"; ++ case HostCmd_CMD_FW_DUMP_EVENT: return "FW_DUMP_EVENT"; ++ case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG: return "SDIO_SP_RX_AGGR_CFG"; ++ case HostCmd_CMD_STA_CONFIGURE: return "STA_CONFIGURE"; ++ case HostCmd_CMD_CHAN_REGION_CFG: return "CHAN_REGION_CFG"; ++ case HostCmd_CMD_PACKET_AGGR_CTRL: return "PACKET_AGGR_CTRL"; ++ default: return "UNKNOWN"; ++ } ++} ++ + /* + * This function initializes a command node. + * +@@ -193,8 +272,8 @@ static int mwifiex_dnld_cmd_to_fw(struct + cmd_code != HostCmd_CMD_FUNC_SHUTDOWN && + cmd_code != HostCmd_CMD_FUNC_INIT) { + mwifiex_dbg(adapter, ERROR, +- "DNLD_CMD: FW in reset state, ignore cmd %#x\n", +- cmd_code); ++ "DNLD_CMD: FW in reset state, ignore cmd %s (%#x)\n", ++ mwifiex_cmd_to_str(cmd_code), cmd_code); + mwifiex_recycle_cmd_node(adapter, cmd_node); + queue_work(adapter->workqueue, &adapter->main_work); + return -1; +@@ -653,8 +732,8 @@ int mwifiex_send_cmd(struct mwifiex_priv + /* Return error, since the command preparation failed */ + if (ret) { + mwifiex_dbg(adapter, ERROR, +- "PREP_CMD: cmd %#x preparation failed\n", +- cmd_no); ++ "PREP_CMD: cmd %s (%#x) preparation failed\n", ++ mwifiex_cmd_to_str(cmd_no), cmd_no); + mwifiex_insert_cmd_to_free_q(adapter, cmd_node); + return -1; + } +@@ -902,8 +981,9 @@ int mwifiex_process_cmdresp(struct mwifi + if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) { + if (ret) { + mwifiex_dbg(adapter, ERROR, +- "%s: cmd %#x failed during\t" +- "initialization\n", __func__, cmdresp_no); ++ "%s: cmd %s (%#x) failed during\t" ++ "initialization\n", __func__, ++ mwifiex_cmd_to_str(cmdresp_no), cmdresp_no); + mwifiex_init_fw_complete(adapter); + return -1; + } else if (adapter->last_init_cmd == cmdresp_no) +@@ -1273,8 +1353,8 @@ mwifiex_process_sleep_confirm_resp(struc + + if (command != HostCmd_CMD_802_11_PS_MODE_ENH) { + mwifiex_dbg(adapter, ERROR, +- "%s: rcvd unexpected resp for cmd %#x, result = %x\n", +- __func__, command, result); ++ "%s: rcvd unexpected resp for cmd %s (%#x), result = %x\n", ++ __func__, mwifiex_cmd_to_str(command), command, result); + return; + } + +--- a/drivers/net/wireless/marvell/mwifiex/main.h ++++ b/drivers/net/wireless/marvell/mwifiex/main.h +@@ -1100,6 +1100,8 @@ void mwifiex_cancel_all_pending_cmd(stru + void mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter *adapter); + void mwifiex_cancel_scan(struct mwifiex_adapter *adapter); + ++const char *mwifiex_cmd_to_str(u16 command); ++ + void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter, + struct cmd_ctrl_node *cmd_node); + +--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c ++++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c +@@ -36,8 +36,9 @@ mwifiex_process_cmdresp_error(struct mwi + struct host_cmd_ds_802_11_ps_mode_enh *pm; + + mwifiex_dbg(adapter, ERROR, +- "CMD_RESP: cmd %#x error, result=%#x\n", +- resp->command, resp->result); ++ "CMD_RESP: cmd %s (%#x) error, result=%#x\n", ++ mwifiex_cmd_to_str(le16_to_cpu(resp->command)), ++ le16_to_cpu(resp->command), le16_to_cpu(resp->result)); + + if (adapter->curr_cmd->wait_q_enabled) + adapter->cmd_wait_q.status = -1; +--- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c ++++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c +@@ -794,7 +794,8 @@ int mwifiex_uap_prepare_cmd(struct mwifi + break; + default: + mwifiex_dbg(priv->adapter, ERROR, +- "PREP_CMD: unknown cmd %#x\n", cmd_no); ++ "PREP_CMD: unknown cmd (%s) %#x\n", ++ mwifiex_cmd_to_str(cmd_no), cmd_no); + return -1; + } + diff --git a/package/kernel/mac80211/patches/rt2x00/000-v6.6-wifi-rt2x00-correct-MAC_SYS_CTRL-register-RX-mask-i.patch b/package/kernel/mac80211/patches/rt2x00/000-v6.6-wifi-rt2x00-correct-MAC_SYS_CTRL-register-RX-mask-i.patch new file mode 100644 index 00000000000..c84b5a14084 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/000-v6.6-wifi-rt2x00-correct-MAC_SYS_CTRL-register-RX-mask-i.patch @@ -0,0 +1,28 @@ +From 186f2432741f6d28d86ff723ac7830446affddfc Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 5 Aug 2023 17:17:28 +0800 +Subject: wifi: rt2x00: correct MAC_SYS_CTRL register RX mask in R-Calibration + +For MAC_SYS_CTRL register, Bit[2] controls MAC_TX_EN and Bit[3] +controls MAC_RX_EN (Bit index starts from 0). Therefore, 0x08 is +the correct mask for RX. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB03150B571B67B896A504AC34BC0EA@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8561,7 +8561,7 @@ static void rt2800_r_calibration(struct + rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n"); + + maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); +- maccfg &= (~0x04); ++ maccfg &= (~0x08); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); + + if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX))) diff --git a/package/kernel/mac80211/patches/rt2x00/001-v6.6-wifi-rt2x00-limit-MT7620-TX-power-based-on-eeprom.patch b/package/kernel/mac80211/patches/rt2x00/001-v6.6-wifi-rt2x00-limit-MT7620-TX-power-based-on-eeprom.patch new file mode 100644 index 00000000000..aa843d42198 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/001-v6.6-wifi-rt2x00-limit-MT7620-TX-power-based-on-eeprom.patch @@ -0,0 +1,115 @@ +From 821b5192c955144bd2f0aeea6cd153e1aedd16e1 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Fri, 11 Aug 2023 14:34:54 +0800 +Subject: wifi: rt2x00: limit MT7620 TX power based on eeprom calibration + +In the vendor driver, the current channel power is queried from +EEPROM_TXPOWER_BG1 and EEPROM_TXPOWER_BG2. And then the mixed value +will be written into the low half-word of the TX_ALC_CFG_0 register. +The high half-word of the TX_ALC_CFG_0 is a fixed value 0x2f2f. + +We can't get the accurate TX power. Based on my tests and the new +MediaTek mt76 driver source code, the real TX power is approximately +equal to channel_power + (max) rate_power. Usually max rate_power is +the gain of the OFDM 6M rate, which can be readed from the offset +EEPROM_TXPOWER_BYRATE +1. + +Based on these eeprom values, this patch adds basic TX power control +for the MT7620 and limits its maximum TX power. This can avoid the +link speed decrease caused by chip overheating. rt2800_config_alc() +function has also been renamed to rt2800_config_alc_rt6352() because +it's only used by RT6352 (MT7620). + +Notice: +It's still need some work to sync the max channel power to the user +interface. This part is missing from the rt2x00 driver framework. If +we set the power exceed the calibration value, it won't take effect. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB03159090ED14044215E59FD6BC10A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 57 ++++++++++++++++++-------- + 1 file changed, 40 insertions(+), 17 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3865,28 +3865,51 @@ static void rt2800_config_channel_rf7620 + } + } + +-static void rt2800_config_alc(struct rt2x00_dev *rt2x00dev, +- struct ieee80211_channel *chan, +- int power_level) { +- u16 eeprom, target_power, max_power; ++static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev, ++ struct ieee80211_channel *chan, ++ int power_level) ++{ ++ int cur_channel = rt2x00dev->rf_channel; ++ u16 eeprom, chan_power, rate_power, target_power; ++ u16 tx_power[2]; ++ s8 *power_group[2]; + u32 mac_sys_ctrl; +- u32 reg; ++ u32 cnt, reg; + u8 bbp; + +- /* hardware unit is 0.5dBm, limited to 23.5dBm */ +- power_level *= 2; +- if (power_level > 0x2f) +- power_level = 0x2f; +- +- max_power = chan->max_power * 2; +- if (max_power > 0x2f) +- max_power = 0x2f; ++ if (WARN_ON(cur_channel < 1 || cur_channel > 14)) ++ return; ++ ++ /* get per chain power, 2 chains in total, unit is 0.5dBm */ ++ power_level = (power_level - 3) * 2; ++ ++ /* We can't get the accurate TX power. Based on some tests, the real ++ * TX power is approximately equal to channel_power + (max)rate_power. ++ * Usually max rate_power is the gain of the OFDM 6M rate. The antenna ++ * gain and externel PA gain are not included as we are unable to ++ * obtain these values. ++ */ ++ rate_power = rt2800_eeprom_read_from_array(rt2x00dev, ++ EEPROM_TXPOWER_BYRATE, 1); ++ rate_power &= 0x3f; ++ power_level -= rate_power; ++ if (power_level < 1) ++ power_level = 1; ++ ++ power_group[0] = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); ++ power_group[1] = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); ++ for (cnt = 0; cnt < 2; cnt++) { ++ chan_power = power_group[cnt][cur_channel - 1]; ++ if (chan_power >= 0x20 || chan_power == 0) ++ chan_power = 0x10; ++ tx_power[cnt] = power_level < chan_power ? power_level : chan_power; ++ } + + reg = rt2800_register_read(rt2x00dev, TX_ALC_CFG_0); +- rt2x00_set_field32(®, TX_ALC_CFG_0_CH_INIT_0, power_level); +- rt2x00_set_field32(®, TX_ALC_CFG_0_CH_INIT_1, power_level); +- rt2x00_set_field32(®, TX_ALC_CFG_0_LIMIT_0, max_power); +- rt2x00_set_field32(®, TX_ALC_CFG_0_LIMIT_1, max_power); ++ rt2x00_set_field32(®, TX_ALC_CFG_0_CH_INIT_0, tx_power[0]); ++ rt2x00_set_field32(®, TX_ALC_CFG_0_CH_INIT_1, tx_power[1]); ++ rt2x00_set_field32(®, TX_ALC_CFG_0_LIMIT_0, 0x2f); ++ rt2x00_set_field32(®, TX_ALC_CFG_0_LIMIT_1, 0x2f); + + eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1); + if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_INTERNAL_TX_ALC)) { +@@ -5268,7 +5291,7 @@ static void rt2800_config_txpower_rt6352 + rt2x00_set_field32(&pwreg, TX_PWR_CFG_9B_STBC_MCS7, t); + rt2800_register_write(rt2x00dev, TX_PWR_CFG_9, pwreg); + +- rt2800_config_alc(rt2x00dev, chan, power_level); ++ rt2800_config_alc_rt6352(rt2x00dev, chan, power_level); + + /* TODO: temperature compensation code! */ + } diff --git a/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch b/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch deleted file mode 100644 index a50a1952851..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch +++ /dev/null @@ -1,51 +0,0 @@ -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 <pozega.tomislav@gmail.com> -X-Patchwork-Id: 10743707 -X-Patchwork-Delegate: kvalo@adurom.com -From: =?utf-8?q?Tomislav_Po=C5=BEega?= <pozega.tomislav@gmail.com> -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: <linux-wireless.vger.kernel.org> -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 <pozega.tomislav@gmail.com> ---- - 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/package/kernel/mac80211/patches/rt2x00/002-v6.7-wifi-rt2x00-fix-MT7620-low-RSSI-issue.patch b/package/kernel/mac80211/patches/rt2x00/002-v6.7-wifi-rt2x00-fix-MT7620-low-RSSI-issue.patch new file mode 100644 index 00000000000..ffb66559d17 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/002-v6.7-wifi-rt2x00-fix-MT7620-low-RSSI-issue.patch @@ -0,0 +1,43 @@ +From 2ecfe6f07e8e6257cad3d3290c5aec2102120041 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 23 Sep 2023 09:01:01 +0800 +Subject: wifi: rt2x00: fix MT7620 low RSSI issue + +On Mediatek vendor driver[1], MT7620 (RT6352) uses different RSSI +base value '-2' compared to the other RT2x00 chips. This patch +introduces the SoC specific base value to fix the low RSSI value +reports on MT7620. + +[1] Found on MT76x2E_MT7620_LinuxAP_V3.0.4.0_P3 ConvertToRssi(). + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB031571CDB146C414A908A66DBCFEA@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -856,6 +856,7 @@ static int rt2800_agc_to_rssi(struct rt2 + s8 rssi0 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI0); + s8 rssi1 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI1); + s8 rssi2 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI2); ++ s8 base_val = rt2x00_rt(rt2x00dev, RT6352) ? -2 : -12; + u16 eeprom; + u8 offset0; + u8 offset1; +@@ -880,9 +881,9 @@ static int rt2800_agc_to_rssi(struct rt2 + * If the value in the descriptor is 0, it is considered invalid + * and the default (extremely low) rssi value is assumed + */ +- rssi0 = (rssi0) ? (-12 - offset0 - rt2x00dev->lna_gain - rssi0) : -128; +- rssi1 = (rssi1) ? (-12 - offset1 - rt2x00dev->lna_gain - rssi1) : -128; +- rssi2 = (rssi2) ? (-12 - offset2 - rt2x00dev->lna_gain - rssi2) : -128; ++ rssi0 = (rssi0) ? (base_val - offset0 - rt2x00dev->lna_gain - rssi0) : -128; ++ rssi1 = (rssi1) ? (base_val - offset1 - rt2x00dev->lna_gain - rssi1) : -128; ++ rssi2 = (rssi2) ? (base_val - offset2 - rt2x00dev->lna_gain - rssi2) : -128; + + /* + * mac80211 only accepts a single RSSI value. Calculating the diff --git a/package/kernel/mac80211/patches/rt2x00/003-v6.7-wifi-rt2x00-fix-rt2800-watchdog-function.patch b/package/kernel/mac80211/patches/rt2x00/003-v6.7-wifi-rt2x00-fix-rt2800-watchdog-function.patch new file mode 100644 index 00000000000..f253dacf2b2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/003-v6.7-wifi-rt2x00-fix-rt2800-watchdog-function.patch @@ -0,0 +1,78 @@ +From 69708fbb2c698f262e03360d064c7066e0679953 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 14 Oct 2023 14:55:01 +0800 +Subject: wifi: rt2x00: fix rt2800 watchdog function + +The watchdog function is broken on rt2800 series SoCs. This patch +fixes the incorrect watchdog logic to make it work again. + +1. Update current wdt queue index if it's not equal to the previous + index. Watchdog compares the current and previous queue index to + judge if the queue hung. +2. Make sure hung_{rx,tx} 'true' status won't be override by the + normal queue. Any queue hangs should trigger a reset action. +3. Clear the watchdog counter of all queues before resetting the + hardware. This change may help to avoid the reset loop. +4. Change hang check function return type to bool as we only need + to return two status, yes or no. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB0315BC1D83D31154924F0D39BCD1A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1237,13 +1237,14 @@ void rt2800_txdone_nostatus(struct rt2x0 + } + EXPORT_SYMBOL_GPL(rt2800_txdone_nostatus); + +-static int rt2800_check_hung(struct data_queue *queue) ++static bool rt2800_check_hung(struct data_queue *queue) + { + unsigned int cur_idx = rt2800_drv_get_dma_done(queue); + +- if (queue->wd_idx != cur_idx) ++ if (queue->wd_idx != cur_idx) { ++ queue->wd_idx = cur_idx; + queue->wd_count = 0; +- else ++ } else + queue->wd_count++; + + return queue->wd_count > 16; +@@ -1280,7 +1281,7 @@ void rt2800_watchdog(struct rt2x00_dev * + case QID_MGMT: + if (rt2x00queue_empty(queue)) + continue; +- hung_tx = rt2800_check_hung(queue); ++ hung_tx = hung_tx || rt2800_check_hung(queue); + break; + case QID_RX: + /* For station mode we should reactive at least +@@ -1289,7 +1290,7 @@ void rt2800_watchdog(struct rt2x00_dev * + */ + if (rt2x00dev->intf_sta_count == 0) + continue; +- hung_rx = rt2800_check_hung(queue); ++ hung_rx = hung_rx || rt2800_check_hung(queue); + break; + default: + break; +@@ -1302,8 +1303,12 @@ void rt2800_watchdog(struct rt2x00_dev * + if (hung_rx) + rt2x00_warn(rt2x00dev, "Watchdog RX hung detected\n"); + +- if (hung_tx || hung_rx) ++ if (hung_tx || hung_rx) { ++ queue_for_each(rt2x00dev, queue) ++ queue->wd_count = 0; ++ + ieee80211_restart_hw(rt2x00dev->hw); ++ } + } + EXPORT_SYMBOL_GPL(rt2800_watchdog); + diff --git a/package/kernel/mac80211/patches/rt2x00/004-1-v6.7-wifi-rt2x00-improve-MT7620-register-initialization.patch b/package/kernel/mac80211/patches/rt2x00/004-1-v6.7-wifi-rt2x00-improve-MT7620-register-initialization.patch new file mode 100644 index 00000000000..9f4dbb8346e --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/004-1-v6.7-wifi-rt2x00-improve-MT7620-register-initialization.patch @@ -0,0 +1,124 @@ +From 1ffe76d5ae78553948d67a978acd9945c2f0a175 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Thu, 19 Oct 2023 19:58:56 +0800 +Subject: wifi: rt2x00: improve MT7620 register initialization + +1. Do not hard reset the BBP. We can use soft reset instead. This + change has some help to the calibration failure issue. +2. Enable falling back to legacy rate from the HT/RTS rate by + setting the HT_FBK_TO_LEGACY register. +3. Implement MCS rate specific maximum PSDU size. It can improve + the transmission quality under the low RSSI condition. +4. Set BBP_84 register value to 0x19. This is used for extension + channel overlapping IOT. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB031553CCD4B7A3B89C85935DBCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 18 ++++++++++++++++++ + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 24 ++++++++++++++++++++++++ + drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 3 +++ + 3 files changed, 45 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -871,6 +871,18 @@ + #define LED_CFG_LED_POLAR FIELD32(0x40000000) + + /* ++ * AMPDU_MAX_LEN_20M1S: Per MCS max A-MPDU length, 20 MHz, MCS 0-7 ++ * AMPDU_MAX_LEN_20M2S: Per MCS max A-MPDU length, 20 MHz, MCS 8-15 ++ * AMPDU_MAX_LEN_40M1S: Per MCS max A-MPDU length, 40 MHz, MCS 0-7 ++ * AMPDU_MAX_LEN_40M2S: Per MCS max A-MPDU length, 40 MHz, MCS 8-15 ++ * Maximum A-MPDU length = 2^(AMPDU_MAX - 5) kilobytes ++ */ ++#define AMPDU_MAX_LEN_20M1S 0x1030 ++#define AMPDU_MAX_LEN_20M2S 0x1034 ++#define AMPDU_MAX_LEN_40M1S 0x1038 ++#define AMPDU_MAX_LEN_40M2S 0x103C ++ ++/* + * AMPDU_BA_WINSIZE: Force BlockAck window size + * FORCE_WINSIZE_ENABLE: + * 0: Disable forcing of BlockAck window size +@@ -1545,6 +1557,12 @@ + */ + #define EXP_ACK_TIME 0x1380 + ++/* ++ * HT_FBK_TO_LEGACY: Enable/Disable HT/RTS fallback to OFDM/CCK rate ++ * Not available for legacy SoCs ++ */ ++#define HT_FBK_TO_LEGACY 0x1384 ++ + /* TX_PWR_CFG_5 */ + #define TX_PWR_CFG_5 0x1384 + #define TX_PWR_CFG_5_MCS16_CH0 FIELD32(0x0000000f) +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5851,6 +5851,7 @@ static int rt2800_init_registers(struct + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; + u32 reg; + u16 eeprom; ++ u8 bbp; + unsigned int i; + int ret; + +@@ -5860,6 +5861,19 @@ static int rt2800_init_registers(struct + if (ret) + return ret; + ++ if (rt2x00_rt(rt2x00dev, RT6352)) { ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x01); ++ ++ bbp = rt2800_bbp_read(rt2x00dev, 21); ++ bbp |= 0x01; ++ rt2800_bbp_write(rt2x00dev, 21, bbp); ++ bbp = rt2800_bbp_read(rt2x00dev, 21); ++ bbp &= (~0x01); ++ rt2800_bbp_write(rt2x00dev, 21, bbp); ++ ++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00); ++ } ++ + rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f); + rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003); + +@@ -6013,6 +6027,14 @@ static int rt2800_init_registers(struct + reg = rt2800_register_read(rt2x00dev, TX_ALC_CFG_1); + rt2x00_set_field32(®, TX_ALC_CFG_1_ROS_BUSY_EN, 0); + rt2800_register_write(rt2x00dev, TX_ALC_CFG_1, reg); ++ ++ rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_20M1S, 0x77754433); ++ rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_20M2S, 0x77765543); ++ rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_40M1S, 0x77765544); ++ rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_40M2S, 0x77765544); ++ ++ rt2800_register_write(rt2x00dev, HT_FBK_TO_LEGACY, 0x1010); ++ + } else { + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000); + rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); +@@ -7231,6 +7253,8 @@ static void rt2800_init_bbp_6352(struct + rt2800_bbp_dcoc_write(rt2x00dev, 159, 0x64); + + rt2800_bbp4_mac_if_ctrl(rt2x00dev); ++ ++ rt2800_bbp_write(rt2x00dev, 84, 0x19); + } + + static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -760,6 +760,9 @@ int rt2800mmio_init_registers(struct rt2 + + rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); + ++ if (rt2x00_rt(rt2x00dev, RT6352)) ++ return 0; ++ + reg = 0; + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); diff --git a/package/kernel/mac80211/patches/rt2x00/004-2-v6.7-wifi-rt2x00-rework-MT7620-channel-config-function.patch b/package/kernel/mac80211/patches/rt2x00/004-2-v6.7-wifi-rt2x00-rework-MT7620-channel-config-function.patch new file mode 100644 index 00000000000..1aec73d7622 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/004-2-v6.7-wifi-rt2x00-rework-MT7620-channel-config-function.patch @@ -0,0 +1,146 @@ +From a28533c6be1711584bf3ec978309d5c590029821 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Thu, 19 Oct 2023 19:58:57 +0800 +Subject: wifi: rt2x00: rework MT7620 channel config function + +1. Move the channel configuration code from rt2800_vco_calibration() + to the rt2800_config_channel(). +2. Use MT7620 SoC specific AGC initial LNA value instead of the + RT5592's value. +3. BBP{195,196} pairing write has been replaced with + rt2800_bbp_glrt_write() to reduce redundant code. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB0315622A4340BFFA530B1B86BCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 91 ++++++++++---------------- + 1 file changed, 35 insertions(+), 56 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3861,14 +3861,6 @@ static void rt2800_config_channel_rf7620 + rfcsr |= tx_agc_fc; + rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); + } +- +- if (conf_is_ht40(conf)) { +- rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10); +- rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f); +- } else { +- rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a); +- rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40); +- } + } + + static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev, +@@ -4437,32 +4429,46 @@ static void rt2800_config_channel(struct + usleep_range(1000, 1500); + } + +- if (rt2x00_rt(rt2x00dev, RT5592) || rt2x00_rt(rt2x00dev, RT6352)) { +- reg = 0x10; +- if (!conf_is_ht40(conf)) { +- if (rt2x00_rt(rt2x00dev, RT6352) && +- rt2x00_has_cap_external_lna_bg(rt2x00dev)) { +- reg |= 0x5; +- } else { +- reg |= 0xa; +- } +- } +- rt2800_bbp_write(rt2x00dev, 195, 141); +- rt2800_bbp_write(rt2x00dev, 196, reg); ++ if (rt2x00_rt(rt2x00dev, RT5592)) { ++ bbp = conf_is_ht40(conf) ? 0x10 : 0x1a; ++ rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); + +- /* AGC init. +- * Despite the vendor driver using different values here for +- * RT6352 chip, we use 0x1c for now. This may have to be changed +- * once TSSI got implemented. +- */ +- reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; +- rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); ++ bbp = (rf->channel <= 14 ? 0x1c : 0x24) + 2 * rt2x00dev->lna_gain; ++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); + +- if (rt2x00_rt(rt2x00dev, RT5592)) +- rt2800_iq_calibrate(rt2x00dev, rf->channel); ++ rt2800_iq_calibrate(rt2x00dev, rf->channel); + } + + if (rt2x00_rt(rt2x00dev, RT6352)) { ++ /* BBP for GLRT BW */ ++ bbp = conf_is_ht40(conf) ? ++ 0x10 : rt2x00_has_cap_external_lna_bg(rt2x00dev) ? ++ 0x15 : 0x1a; ++ rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); ++ ++ bbp = conf_is_ht40(conf) ? 0x2f : 0x40; ++ rt2800_bbp_glrt_write(rt2x00dev, 157, bbp); ++ ++ if (rt2x00dev->default_ant.rx_chain_num == 1) { ++ rt2800_bbp_write(rt2x00dev, 91, 0x07); ++ rt2800_bbp_write(rt2x00dev, 95, 0x1a); ++ rt2800_bbp_glrt_write(rt2x00dev, 128, 0xa0); ++ rt2800_bbp_glrt_write(rt2x00dev, 170, 0x12); ++ rt2800_bbp_glrt_write(rt2x00dev, 171, 0x10); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 91, 0x06); ++ rt2800_bbp_write(rt2x00dev, 95, 0x9a); ++ rt2800_bbp_glrt_write(rt2x00dev, 128, 0xe0); ++ rt2800_bbp_glrt_write(rt2x00dev, 170, 0x30); ++ rt2800_bbp_glrt_write(rt2x00dev, 171, 0x30); ++ } ++ ++ /* AGC init */ ++ bbp = rf->channel <= 14 ? 0x04 + 2 * rt2x00dev->lna_gain : 0; ++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); ++ ++ usleep_range(1000, 1500); ++ + if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, + &rt2x00dev->cap_flags)) { + reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); +@@ -5608,26 +5614,6 @@ void rt2800_vco_calibration(struct rt2x0 + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); + + if (rt2x00_rt(rt2x00dev, RT6352)) { +- if (rt2x00dev->default_ant.rx_chain_num == 1) { +- rt2800_bbp_write(rt2x00dev, 91, 0x07); +- rt2800_bbp_write(rt2x00dev, 95, 0x1A); +- rt2800_bbp_write(rt2x00dev, 195, 128); +- rt2800_bbp_write(rt2x00dev, 196, 0xA0); +- rt2800_bbp_write(rt2x00dev, 195, 170); +- rt2800_bbp_write(rt2x00dev, 196, 0x12); +- rt2800_bbp_write(rt2x00dev, 195, 171); +- rt2800_bbp_write(rt2x00dev, 196, 0x10); +- } else { +- rt2800_bbp_write(rt2x00dev, 91, 0x06); +- rt2800_bbp_write(rt2x00dev, 95, 0x9A); +- rt2800_bbp_write(rt2x00dev, 195, 128); +- rt2800_bbp_write(rt2x00dev, 196, 0xE0); +- rt2800_bbp_write(rt2x00dev, 195, 170); +- rt2800_bbp_write(rt2x00dev, 196, 0x30); +- rt2800_bbp_write(rt2x00dev, 195, 171); +- rt2800_bbp_write(rt2x00dev, 196, 0x30); +- } +- + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_bbp_write(rt2x00dev, 75, 0x68); + rt2800_bbp_write(rt2x00dev, 76, 0x4C); +@@ -5635,13 +5621,6 @@ void rt2800_vco_calibration(struct rt2x0 + rt2800_bbp_write(rt2x00dev, 80, 0x0C); + rt2800_bbp_write(rt2x00dev, 82, 0xB6); + } +- +- /* On 11A, We should delay and wait RF/BBP to be stable +- * and the appropriate time should be 1000 micro seconds +- * 2005/06/05 - On 11G, we also need this delay time. +- * Otherwise it's difficult to pass the WHQL. +- */ +- usleep_range(1000, 1500); + } + } + EXPORT_SYMBOL_GPL(rt2800_vco_calibration); diff --git a/package/kernel/mac80211/patches/rt2x00/004-3-v6.7-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch b/package/kernel/mac80211/patches/rt2x00/004-3-v6.7-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch new file mode 100644 index 00000000000..64cd599c02b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/004-3-v6.7-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch @@ -0,0 +1,241 @@ +From cca74bed37af1c8217bcd8282d9b384efdbf73bd Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Thu, 19 Oct 2023 19:58:58 +0800 +Subject: wifi: rt2x00: rework MT7620 PA/LNA RF calibration + +1. Move MT7620 PA/LNA calibration code to dedicated functions. +2. For external PA/LNA devices, restore RF and BBP registers before + R-Calibration. +3. Do Rx DCOC calibration again before RXIQ calibration. +4. Add some missing LNA related registers' initialization. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB0315979F92DC563019B8F238BCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 176 +++++++++++++++++-------- + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 + + 2 files changed, 130 insertions(+), 52 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -4468,41 +4468,6 @@ static void rt2800_config_channel(struct + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); + + usleep_range(1000, 1500); +- +- if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, +- &rt2x00dev->cap_flags)) { +- 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); +@@ -5612,16 +5577,6 @@ void rt2800_vco_calibration(struct rt2x0 + } + } + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); +- +- if (rt2x00_rt(rt2x00dev, RT6352)) { +- if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { +- rt2800_bbp_write(rt2x00dev, 75, 0x68); +- rt2800_bbp_write(rt2x00dev, 76, 0x4C); +- rt2800_bbp_write(rt2x00dev, 79, 0x1C); +- rt2800_bbp_write(rt2x00dev, 80, 0x0C); +- rt2800_bbp_write(rt2x00dev, 82, 0xB6); +- } +- } + } + EXPORT_SYMBOL_GPL(rt2800_vco_calibration); + +@@ -10348,6 +10303,128 @@ do_cal: + rt2800_register_write(rt2x00dev, RF_BYPASS0, MAC_RF_BYPASS0); + } + ++static void rt2800_restore_rf_bbp_rt6352(struct rt2x00_dev *rt2x00dev) ++{ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0); ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0); ++ } ++ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02); ++ } ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xd3); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xb3); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xd5); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6c); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xfc); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1f); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xff); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x1c); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x20); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6b); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xf7); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09); ++ } ++ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2800_bbp_write(rt2x00dev, 75, 0x60); ++ rt2800_bbp_write(rt2x00dev, 76, 0x44); ++ rt2800_bbp_write(rt2x00dev, 79, 0x1c); ++ rt2800_bbp_write(rt2x00dev, 80, 0x0c); ++ rt2800_bbp_write(rt2x00dev, 82, 0xB6); ++ } ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x3630363a); ++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6c6c666c); ++ rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6c6c666c); ++ } ++} ++ ++static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev) ++{ ++ u32 reg; ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev) || ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) ++ rt2800_restore_rf_bbp_rt6352(rt2x00dev); ++ ++ 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); ++ rt2800_loft_iq_calibration(rt2x00dev); ++ ++ /* missing DPD calibration for internal PA devices */ ++ ++ rt2800_rxdcoc_calibration(rt2x00dev); ++ rt2800_rxiq_calibration(rt2x00dev); ++ ++ if (!rt2x00_has_cap_external_pa(rt2x00dev) && ++ !rt2x00_has_cap_external_lna_bg(rt2x00dev)) ++ return; ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ 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); ++ } ++ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42); ++ } ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ 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); ++ } ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) ++ rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00); ++ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2800_bbp_write(rt2x00dev, 75, 0x68); ++ rt2800_bbp_write(rt2x00dev, 76, 0x4c); ++ rt2800_bbp_write(rt2x00dev, 79, 0x1c); ++ rt2800_bbp_write(rt2x00dev, 80, 0x0c); ++ rt2800_bbp_write(rt2x00dev, 82, 0xb6); ++ } ++ ++ if (rt2x00_has_cap_external_pa(rt2x00dev)) { ++ 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); ++ } ++} ++ + static void rt2800_init_rfcsr_6352(struct rt2x00_dev *rt2x00dev) + { + /* Initialize RF central register to default value */ +@@ -10612,13 +10689,8 @@ 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_rxdcoc_calibration(rt2x00dev); +- rt2800_bw_filter_calibration(rt2x00dev, true); +- rt2800_bw_filter_calibration(rt2x00dev, false); +- rt2800_loft_iq_calibration(rt2x00dev); +- rt2800_rxiq_calibration(rt2x00dev); ++ /* Do calibration and init PA/LNA */ ++ rt2800_calibration_rt6352(rt2x00dev); + } + + static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -1263,6 +1263,12 @@ rt2x00_has_cap_external_lna_bg(struct rt + } + + static inline bool ++rt2x00_has_cap_external_pa(struct rt2x00_dev *rt2x00dev) ++{ ++ return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_PA_TX0); ++} ++ ++static inline bool + rt2x00_has_cap_double_antenna(struct rt2x00_dev *rt2x00dev) + { + return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_DOUBLE_ANTENNA); diff --git a/package/kernel/mac80211/patches/rt2x00/005-1-v6.8-wifi-rt2x00-introduce-DMA-busy-check-watchdog-for-rt.patch b/package/kernel/mac80211/patches/rt2x00/005-1-v6.8-wifi-rt2x00-introduce-DMA-busy-check-watchdog-for-rt.patch new file mode 100644 index 00000000000..c1c32257330 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/005-1-v6.8-wifi-rt2x00-introduce-DMA-busy-check-watchdog-for-rt.patch @@ -0,0 +1,177 @@ +From b1275cdd7456ef811747dfb4f3c46310ddd300cd Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 4 Nov 2023 16:57:58 +0800 +Subject: wifi: rt2x00: introduce DMA busy check watchdog for rt2800 + +When I tried to fix the watchdog of rt2800, I found that sometimes +the watchdog can not reset the hung device. This is because the +queue is not completely stuck, it just becomes very slow. The MTK +vendor driver for the new chip MT7603/MT7612 has a DMA busy watchdog +to detect device hangs by checking DMA busy status. This watchdog +implementation is something similar to it. To reduce unnecessary +reset, we can check the INT_SOURCE_CSR register together as I found +that when the radio hung, the RX/TX coherent interrupt will always +stuck at triggered state. + +The 'watchdog' module parameter has been extended to control all +watchdogs(0=disabled, 1=hang watchdog, 2=DMA watchdog, 3=both). This +new watchdog function is a slight schedule and it won't affect the +transmission speed. So we can turn on it by default. Due to the +INT_SOURCE_CSR register is invalid on rt2800 USB NICs, the DMA busy +watchdog will be automatically disabled for them. + +Tested on MT7620 and RT5350. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB0315D7462CE08A119A99DE34BCA4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 4 ++ + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 77 ++++++++++++++++++++++---- + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 3 + + 3 files changed, 73 insertions(+), 11 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -3194,4 +3194,8 @@ enum rt2800_eeprom_word { + */ + #define BCN_TBTT_OFFSET 64 + ++/* Watchdog type mask */ ++#define RT2800_WATCHDOG_HANG BIT(0) ++#define RT2800_WATCHDOG_DMA_BUSY BIT(1) ++ + #endif /* RT2800_H */ +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -30,9 +30,10 @@ + #include "rt2800lib.h" + #include "rt2800.h" + +-static bool modparam_watchdog; +-module_param_named(watchdog, modparam_watchdog, bool, S_IRUGO); +-MODULE_PARM_DESC(watchdog, "Enable watchdog to detect tx/rx hangs and reset hardware if detected"); ++static unsigned int modparam_watchdog = RT2800_WATCHDOG_DMA_BUSY; ++module_param_named(watchdog, modparam_watchdog, uint, 0444); ++MODULE_PARM_DESC(watchdog, "Enable watchdog to recover tx/rx hangs.\n" ++ "\t\t(0=disabled, 1=hang watchdog, 2=DMA watchdog(default), 3=both)"); + + /* + * Register access. +@@ -1261,15 +1262,12 @@ static void rt2800_update_survey(struct + chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); + } + +-void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) ++static bool rt2800_watchdog_hung(struct rt2x00_dev *rt2x00dev) + { + struct data_queue *queue; + bool hung_tx = false; + bool hung_rx = false; + +- if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) +- return; +- + rt2800_update_survey(rt2x00dev); + + queue_for_each(rt2x00dev, queue) { +@@ -1297,18 +1295,72 @@ void rt2800_watchdog(struct rt2x00_dev * + } + } + ++ if (!hung_tx && !hung_rx) ++ return false; ++ + if (hung_tx) + rt2x00_warn(rt2x00dev, "Watchdog TX hung detected\n"); + + if (hung_rx) + rt2x00_warn(rt2x00dev, "Watchdog RX hung detected\n"); + +- if (hung_tx || hung_rx) { +- queue_for_each(rt2x00dev, queue) +- queue->wd_count = 0; ++ queue_for_each(rt2x00dev, queue) ++ queue->wd_count = 0; ++ ++ return true; ++} ++ ++static bool rt2800_watchdog_dma_busy(struct rt2x00_dev *rt2x00dev) ++{ ++ bool busy_rx, busy_tx; ++ u32 reg_cfg = rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG); ++ u32 reg_int = rt2800_register_read(rt2x00dev, INT_SOURCE_CSR); ++ ++ if (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_RX_DMA_BUSY) && ++ rt2x00_get_field32(reg_int, INT_SOURCE_CSR_RX_COHERENT)) ++ rt2x00dev->rxdma_busy++; ++ else ++ rt2x00dev->rxdma_busy = 0; + ++ if (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_TX_DMA_BUSY) && ++ rt2x00_get_field32(reg_int, INT_SOURCE_CSR_TX_COHERENT)) ++ rt2x00dev->txdma_busy++; ++ else ++ rt2x00dev->txdma_busy = 0; ++ ++ busy_rx = rt2x00dev->rxdma_busy > 30 ? true : false; ++ busy_tx = rt2x00dev->txdma_busy > 30 ? true : false; ++ ++ if (!busy_rx && !busy_tx) ++ return false; ++ ++ if (busy_rx) ++ rt2x00_warn(rt2x00dev, "Watchdog RX DMA busy detected\n"); ++ ++ if (busy_tx) ++ rt2x00_warn(rt2x00dev, "Watchdog TX DMA busy detected\n"); ++ ++ rt2x00dev->rxdma_busy = 0; ++ rt2x00dev->txdma_busy = 0; ++ ++ return true; ++} ++ ++void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) ++{ ++ bool reset = false; ++ ++ if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) ++ return; ++ ++ if (modparam_watchdog & RT2800_WATCHDOG_DMA_BUSY) ++ reset = rt2800_watchdog_dma_busy(rt2x00dev); ++ ++ if (modparam_watchdog & RT2800_WATCHDOG_HANG) ++ reset = rt2800_watchdog_hung(rt2x00dev) || reset; ++ ++ if (reset) + ieee80211_restart_hw(rt2x00dev->hw); +- } + } + EXPORT_SYMBOL_GPL(rt2800_watchdog); + +@@ -12016,6 +12068,9 @@ int rt2800_probe_hw(struct rt2x00_dev *r + __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); + } + ++ /* USB NICs don't support DMA watchdog as INT_SOURCE_CSR is invalid */ ++ if (rt2x00_is_usb(rt2x00dev)) ++ modparam_watchdog &= ~RT2800_WATCHDOG_DMA_BUSY; + if (modparam_watchdog) { + __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); + rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -926,6 +926,9 @@ struct rt2x00_dev { + */ + u16 beacon_int; + ++ /* Rx/Tx DMA busy watchdog counter */ ++ u16 rxdma_busy, txdma_busy; ++ + /** + * Timestamp of last received beacon + */ diff --git a/package/kernel/mac80211/patches/rt2x00/005-2-v6.8-wifi-rt2x00-disable-RTS-threshold-for-rt2800-by-defa.patch b/package/kernel/mac80211/patches/rt2x00/005-2-v6.8-wifi-rt2x00-disable-RTS-threshold-for-rt2800-by-defa.patch new file mode 100644 index 00000000000..b3e95da5a60 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/005-2-v6.8-wifi-rt2x00-disable-RTS-threshold-for-rt2800-by-defa.patch @@ -0,0 +1,43 @@ +From 570beb6285fd355904b22625da20809f477096c5 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 4 Nov 2023 16:57:59 +0800 +Subject: wifi: rt2x00: disable RTS threshold for rt2800 by default + +rt2800 has a lot of registers to control the RTS enable/disable +status for different rates. And the driver control them via +rt2800_set_rts_threshold(). When RTS was disabled in user +interface, this function won't be called at all. This means that +the RTS is still 'on' for CCK and OFDM rates. So we'd better to +disable them by default because it should be like this. The RTS +for HT20 and HT40 is already default off so we don't need to +touch them. If we toggle the RTS status, these register bits +will be enable/disable again by rt2800_set_rts_threshold(). + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB03155DDB953155B7A2DE849ABCA4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -6100,7 +6100,7 @@ static int rt2800_init_registers(struct + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM40, 0); + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF20, 1); + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF40, 0); +- rt2x00_set_field32(®, CCK_PROT_CFG_RTS_TH_EN, 1); ++ rt2x00_set_field32(®, CCK_PROT_CFG_RTS_TH_EN, 0); + rt2800_register_write(rt2x00dev, CCK_PROT_CFG, reg); + + reg = rt2800_register_read(rt2x00dev, OFDM_PROT_CFG); +@@ -6113,7 +6113,7 @@ static int rt2800_init_registers(struct + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM40, 0); + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF20, 1); + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF40, 0); +- rt2x00_set_field32(®, OFDM_PROT_CFG_RTS_TH_EN, 1); ++ rt2x00_set_field32(®, OFDM_PROT_CFG_RTS_TH_EN, 0); + rt2800_register_write(rt2x00dev, OFDM_PROT_CFG, reg); + + reg = rt2800_register_read(rt2x00dev, MM20_PROT_CFG); diff --git a/package/kernel/mac80211/patches/rt2x00/005-3-v6.8-wifi-rt2x00-restart-beacon-queue-when-hardware-reset.patch b/package/kernel/mac80211/patches/rt2x00/005-3-v6.8-wifi-rt2x00-restart-beacon-queue-when-hardware-reset.patch new file mode 100644 index 00000000000..1fa7b8b0fb9 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/005-3-v6.8-wifi-rt2x00-restart-beacon-queue-when-hardware-reset.patch @@ -0,0 +1,67 @@ +From a11d965a218f0cd95b13fe44d0bcd8a20ce134a8 Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Sat, 4 Nov 2023 16:58:00 +0800 +Subject: wifi: rt2x00: restart beacon queue when hardware reset + +When a hardware reset is triggered, all registers are reset, so all +queues are forced to stop in hardware interface. However, mac80211 +will not automatically stop the queue. If we don't manually stop the +beacon queue, the queue will be deadlocked and unable to start again. +This patch fixes the issue where Apple devices cannot connect to the +AP after calling ieee80211_restart_hw(). + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> +Signed-off-by: Kalle Valo <kvalo@kernel.org> +Link: https://lore.kernel.org/r/TYAP286MB031530EB6D98DCE4DF20766CBCA4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM +--- + drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 3 +++ + drivers/net/wireless/ralink/rt2x00/rt2x00mac.c | 11 +++++++++++ + 2 files changed, 14 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -101,6 +101,7 @@ void rt2x00lib_disable_radio(struct rt2x + rt2x00link_stop_tuner(rt2x00dev); + rt2x00queue_stop_queues(rt2x00dev); + rt2x00queue_flush_queues(rt2x00dev, true); ++ rt2x00queue_stop_queue(rt2x00dev->bcn); + + /* + * Disable radio. +@@ -1286,6 +1287,7 @@ int rt2x00lib_start(struct rt2x00_dev *r + rt2x00dev->intf_ap_count = 0; + rt2x00dev->intf_sta_count = 0; + rt2x00dev->intf_associated = 0; ++ rt2x00dev->intf_beaconing = 0; + + /* Enable the radio */ + retval = rt2x00lib_enable_radio(rt2x00dev); +@@ -1312,6 +1314,7 @@ void rt2x00lib_stop(struct rt2x00_dev *r + rt2x00dev->intf_ap_count = 0; + rt2x00dev->intf_sta_count = 0; + rt2x00dev->intf_associated = 0; ++ rt2x00dev->intf_beaconing = 0; + } + + static inline void rt2x00lib_set_if_combinations(struct rt2x00_dev *rt2x00dev) +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c +@@ -598,6 +598,17 @@ void rt2x00mac_bss_info_changed(struct i + */ + if (changes & BSS_CHANGED_BEACON_ENABLED) { + mutex_lock(&intf->beacon_skb_mutex); ++ ++ /* ++ * Clear the 'enable_beacon' flag and clear beacon because ++ * the beacon queue has been stopped after hardware reset. ++ */ ++ if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags) && ++ intf->enable_beacon) { ++ intf->enable_beacon = false; ++ rt2x00queue_clear_beacon(rt2x00dev, vif); ++ } ++ + if (!bss_conf->enable_beacon && intf->enable_beacon) { + rt2x00dev->intf_beaconing--; + intf->enable_beacon = false; diff --git a/package/kernel/mac80211/patches/rt2x00/101-wifi-rt2x00-correct-wrong-BBP-register-in-RxDCOC-cal.patch b/package/kernel/mac80211/patches/rt2x00/101-wifi-rt2x00-correct-wrong-BBP-register-in-RxDCOC-cal.patch new file mode 100644 index 00000000000..253d1d9c196 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/101-wifi-rt2x00-correct-wrong-BBP-register-in-RxDCOC-cal.patch @@ -0,0 +1,26 @@ +From: Shiji Yang <yangshiji66@outlook.com> +Date: Thu, 9 Nov 2023 12:01:18 +0800 +Subject: [PATCH] wifi: rt2x00: correct wrong BBP register in RxDCOC + calibration + +Refer to Mediatek vendor driver RxDCOC_Calibration() function, when +performing gainfreeze calibration, we should write register 140 +instead of 141. This fix can reduce the total calibration time from +6 seconds to 1 second. + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -8711,7 +8711,7 @@ static void rt2800_rxdcoc_calibration(st + rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4); + rt2800_rfcsr_write_bank(rt2x00dev, 7, 4, saverfb7r4); + +- rt2800_bbp_write(rt2x00dev, 158, 141); ++ rt2800_bbp_write(rt2x00dev, 158, 140); + bbpreg = rt2800_bbp_read(rt2x00dev, 159); + bbpreg = bbpreg & (~0x40); + rt2800_bbp_write(rt2x00dev, 159, bbpreg); diff --git a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch b/package/kernel/mac80211/patches/rt2x00/602-01-wifi-rt2x00-Add-support-for-loading-EEPROM-from-user.patch index 1c52132da65..5040b5af621 100644 --- a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch +++ b/package/kernel/mac80211/patches/rt2x00/602-01-wifi-rt2x00-Add-support-for-loading-EEPROM-from-user.patch @@ -1,6 +1,27 @@ +From 1046fc9e98936991aeb0b0656c84833d96a63c0f Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Sun, 15 Oct 2023 14:22:49 +0200 +Subject: [PATCH 1/5] wifi: rt2x00: Add support for loading EEPROM from + userspace + +Add support for loading EEPROM from userspace. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + drivers/net/wireless/ralink/rt2x00/Kconfig | 5 ++ + drivers/net/wireless/ralink/rt2x00/Makefile | 1 + + .../net/wireless/ralink/rt2x00/rt2800soc.c | 15 +--- + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 + + .../net/wireless/ralink/rt2x00/rt2x00dev.c | 9 +++ + .../net/wireless/ralink/rt2x00/rt2x00eeprom.c | 75 +++++++++++++++++++ + .../net/wireless/ralink/rt2x00/rt2x00soc.c | 1 + + .../net/wireless/ralink/rt2x00/rt2x00soc.h | 9 +++ + 8 files changed, 102 insertions(+), 14 deletions(-) + create mode 100644 drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c + --- a/local-symbols +++ b/local-symbols -@@ -333,6 +333,7 @@ RT2X00_LIB_FIRMWARE= +@@ -350,6 +350,7 @@ RT2X00_LIB_FIRMWARE= RT2X00_LIB_CRYPTO= RT2X00_LIB_LEDS= RT2X00_LIB_DEBUGFS= @@ -46,33 +67,6 @@ 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 @@ -95,17 +89,18 @@ /* Firmware functions */ static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev) { -@@ -167,7 +154,6 @@ static const struct rt2800_ops rt2800soc +@@ -168,7 +155,7 @@ 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, ++ .read_eeprom = rt2x00lib_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 { +@@ -703,6 +703,7 @@ enum rt2x00_capability_flags { REQUIRE_HT_TX_DESC, REQUIRE_PS_AUTOWAKE, REQUIRE_DELAYED_RFKILL, @@ -113,77 +108,24 @@ /* * 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 -@@ -1406,6 +1406,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. - */ -@@ -1549,6 +1553,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 <IvDoorn@gmail.com> -+ Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com> -+ <http://rt2x00.serialmonkey.com> -+ -+ 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. +@@ -0,0 +1,77 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> ++ * Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com> ++ * <http://rt2x00.serialmonkey.com> + */ + -+/* -+ Module: rt2x00lib -+ Abstract: rt2x00 eeprom file loading routines. ++/* Module: rt2x00lib ++ * Abstract: rt2x00 eeprom file loading routines. + */ + +#include <linux/kernel.h> +#include <linux/module.h> + +#include "rt2x00.h" -+#include "rt2x00lib.h" ++#include "rt2x00soc.h" + +static const char * +rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) @@ -193,10 +135,10 @@ + if (pdata && pdata->eeprom_file_name) + return pdata->eeprom_file_name; + -+ return NULL ++ return NULL; +} + -+static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev) ++static int rt2x00lib_read_eeprom_file(struct rt2x00_dev *rt2x00dev) +{ + const struct firmware *ee; + const char *ee_name; @@ -233,8 +175,7 @@ + goto err_release_ee; + } + -+ rt2x00dev->eeprom_file = ee; -+ return 0; ++ memcpy(rt2x00dev->eeprom, ee->data, rt2x00dev->ops->eeprom_size); + +err_release_ee: + release_firmware(ee); @@ -242,48 +183,11 @@ + 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) ++int rt2x00lib_read_eeprom(struct rt2x00_dev *rt2x00dev) +{ -+ return 0; ++ return rt2x00lib_read_eeprom_file(rt2x00dev); +} -+static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev) -+{ -+} -+#endif /* CPTCFG_RT2X00_LIB_EEPROM */ -+ -+/* - * Debugfs handlers. - */ - #ifdef CPTCFG_RT2X00_LIB_DEBUGFS ++EXPORT_SYMBOL_GPL(rt2x00lib_read_eeprom); --- 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 @@ -294,3 +198,19 @@ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); retval = rt2x00soc_alloc_reg(rt2x00dev); +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.h +@@ -26,4 +26,13 @@ int rt2x00soc_resume(struct platform_dev + #define rt2x00soc_resume NULL + #endif /* CONFIG_PM */ + ++/* ++ * EEPROM file handlers. ++ */ ++#ifdef CPTCFG_RT2X00_LIB_EEPROM ++int rt2x00lib_read_eeprom(struct rt2x00_dev *rt2x00dev); ++#else ++#define rt2x00lib_read_eeprom NULL ++#endif /* CPTCFG_RT2X00_LIB_EEPROM */ ++ + #endif /* RT2X00SOC_H */ diff --git a/package/kernel/mac80211/patches/rt2x00/602-02-wifi-rt2x00-Add-option-to-pass-EEPROM-file-name-from.patch b/package/kernel/mac80211/patches/rt2x00/602-02-wifi-rt2x00-Add-option-to-pass-EEPROM-file-name-from.patch new file mode 100644 index 00000000000..90055b911f0 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/602-02-wifi-rt2x00-Add-option-to-pass-EEPROM-file-name-from.patch @@ -0,0 +1,43 @@ +From 15329d8b206d9c04ffad49aecd37f5d0bfb85768 Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Sun, 15 Oct 2023 14:23:19 +0200 +Subject: [PATCH 2/5] wifi: rt2x00: Add option to pass EEPROM file name from DT + +Add option to pass EEPROM file name from DT using ralink,eeprom binding. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -10,6 +10,7 @@ + + #include <linux/kernel.h> + #include <linux/module.h> ++#include <linux/of.h> + + #include "rt2x00.h" + #include "rt2x00soc.h" +@@ -18,10 +19,20 @@ 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; + ++#ifdef CONFIG_OF ++ np = rt2x00dev->dev->of_node; ++ if (np && !of_property_read_string(np, "ralink,eeprom", &eep)) ++ return eep; ++#endif ++ + return NULL; + } + diff --git a/package/kernel/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch b/package/kernel/mac80211/patches/rt2x00/602-03-wifi-rt2x00-Add-support-for-loading-EEPROM-from-MTD.patch index 7338eb15b20..fab4bf39c05 100644 --- a/package/kernel/mac80211/patches/rt2x00/604-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch +++ b/package/kernel/mac80211/patches/rt2x00/602-03-wifi-rt2x00-Add-support-for-loading-EEPROM-from-MTD.patch @@ -1,14 +1,16 @@ -From 339fe73f340161a624cc08e738d2244814852c3e Mon Sep 17 00:00:00 2001 +From 71261ca81b491a4c3b08690347c12e96a75ad0d0 Mon Sep 17 00:00:00 2001 From: John Crispin <blogic@openwrt.org> Date: Sun, 17 Mar 2013 00:55:04 +0100 -Subject: [PATCH] rt2x00: load eeprom on SoC from a mtd device defines inside - OF +Subject: [PATCH 3/5] wifi: rt2x00: Add support for loading EEPROM from MTD + +Add support for loading EEPROM from MTD. Signed-off-by: John Crispin <blogic@openwrt.org> +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> --- - drivers/net/wireless/ralink/rt2x00/Kconfig | 1 + - drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 65 +++++++++++++++++++++++ - 2 files changed, 66 insertions(+) + drivers/net/wireless/ralink/rt2x00/Kconfig | 1 + + .../net/wireless/ralink/rt2x00/rt2x00eeprom.c | 66 +++++++++++++++++++ + 2 files changed, 67 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/Kconfig +++ b/drivers/net/wireless/ralink/rt2x00/Kconfig @@ -22,7 +24,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org> 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 @@ +@@ -10,11 +10,69 @@ #include <linux/kernel.h> #include <linux/module.h> @@ -33,21 +35,20 @@ Signed-off-by: John Crispin <blogic@openwrt.org> #include <linux/of.h> #include "rt2x00.h" - #include "rt2x00lib.h" + #include "rt2x00soc.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; ++ int size, offset = 0; + struct mtd_info *mtd; + const char *part; + const __be32 *list; + phandle phandle; ++ size_t retlen; + + list = of_get_property(np, "ralink,mtd-eeprom", &size); + if (!list) @@ -74,21 +75,15 @@ Signed-off-by: John Crispin <blogic@openwrt.org> + if (size > sizeof(*list)) + offset = be32_to_cpup(list); + -+ ret = mtd_read(mtd, offset, len, &retlen, (u_char *) rt2x00dev->eeprom); ++ ret = mtd_read(mtd, offset, rt2x00dev->ops->eeprom_size, ++ &retlen, (u_char *)rt2x00dev->eeprom); + put_mtd_device(mtd); + -+ if ((retlen != rt2x00dev->ops->eeprom_size) || ret) { ++ 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 + @@ -99,15 +94,18 @@ Signed-off-by: John Crispin <blogic@openwrt.org> 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; +@@ -83,6 +141,14 @@ err_exit: + int rt2x00lib_read_eeprom(struct rt2x00_dev *rt2x00dev) + { ++ int ret; ++ +#if IS_ENABLED(CONFIG_MTD) -+ if (!rt2800lib_read_eeprom_mtd(rt2x00dev)) ++ ret = rt2800lib_read_eeprom_mtd(rt2x00dev); ++ if (!ret) + 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."); + return rt2x00lib_read_eeprom_file(rt2x00dev); + } + EXPORT_SYMBOL_GPL(rt2x00lib_read_eeprom); diff --git a/package/kernel/mac80211/patches/rt2x00/602-04-wifi-rt2x00-Support-EEPROM-swap-binding.patch b/package/kernel/mac80211/patches/rt2x00/602-04-wifi-rt2x00-Support-EEPROM-swap-binding.patch new file mode 100644 index 00000000000..392910d224b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/602-04-wifi-rt2x00-Support-EEPROM-swap-binding.patch @@ -0,0 +1,44 @@ +From 9c9a3c27b96e057f3c3f47151d7a170d84e3bb5f Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Sun, 15 Oct 2023 15:31:47 +0200 +Subject: [PATCH 4/5] wifi: rt2x00: Support EEPROM swap binding + +Add binding "ralink,eeprom-swap" to swap bytes of EEPROM before using +it. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -20,6 +20,19 @@ + #include "rt2x00soc.h" + + #if IS_ENABLED(CONFIG_MTD) ++static void rt2800lib_eeprom_swap(struct rt2x00_dev *rt2x00dev) ++{ ++ struct device_node *np = rt2x00dev->dev->of_node; ++ size_t len = rt2x00dev->ops->eeprom_size; ++ int i; ++ ++ if (!of_find_property(np, "ralink,eeprom-swap", NULL)) ++ return; ++ ++ for (i = 0; i < len / sizeof(u16); i++) ++ rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]); ++} ++ + static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev) + { + int ret = -EINVAL; +@@ -66,6 +79,8 @@ static int rt2800lib_read_eeprom_mtd(str + return ret; + } + ++ rt2800lib_eeprom_swap(rt2x00dev); ++ + dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part); + #endif + diff --git a/package/kernel/mac80211/patches/rt2x00/602-05-wifi-rt2x00-support-loading-eeprom-from-NVMEM-cells.patch b/package/kernel/mac80211/patches/rt2x00/602-05-wifi-rt2x00-support-loading-eeprom-from-NVMEM-cells.patch new file mode 100644 index 00000000000..e6633363bd3 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/602-05-wifi-rt2x00-support-loading-eeprom-from-NVMEM-cells.patch @@ -0,0 +1,97 @@ +From 9008cdacdc41f8233f4444b86cf3a17201686e2d Mon Sep 17 00:00:00 2001 +From: Shiji Yang <yangshiji66@outlook.com> +Date: Tue, 18 Jul 2023 20:18:16 +0800 +Subject: [PATCH 5/5] wifi: rt2x00: support loading eeprom from NVMEM cells + +This patch allows rt2x00 to load eeprom from "eeprom" NVMEM cell. + +Example: + +/* load eeprom from NVMEM provider 'eep' */ +&wmac { + nvmem-cells = <&eep>; + nvmem-cell-names = "eeprom"; +}; + +Signed-off-by: Shiji Yang <yangshiji66@outlook.com> +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + .../net/wireless/ralink/rt2x00/rt2x00eeprom.c | 41 ++++++++++++++++++- + 1 file changed, 40 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c +@@ -14,12 +14,12 @@ + #include <linux/mtd/mtd.h> + #include <linux/mtd/partitions.h> + #endif ++#include <linux/nvmem-consumer.h> + #include <linux/of.h> + + #include "rt2x00.h" + #include "rt2x00soc.h" + +-#if IS_ENABLED(CONFIG_MTD) + static void rt2800lib_eeprom_swap(struct rt2x00_dev *rt2x00dev) + { + struct device_node *np = rt2x00dev->dev->of_node; +@@ -33,6 +33,7 @@ static void rt2800lib_eeprom_swap(struct + rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]); + } + ++#if IS_ENABLED(CONFIG_MTD) + static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev) + { + int ret = -EINVAL; +@@ -88,6 +89,40 @@ static int rt2800lib_read_eeprom_mtd(str + } + #endif + ++static int rt2800lib_read_eeprom_nvmem(struct rt2x00_dev *rt2x00dev) ++{ ++ struct device_node *np = rt2x00dev->dev->of_node; ++ unsigned int len = rt2x00dev->ops->eeprom_size; ++ struct nvmem_cell *cell; ++ const void *data; ++ size_t retlen; ++ int ret = 0; ++ ++ cell = of_nvmem_cell_get(np, "eeprom"); ++ if (IS_ERR(cell)) ++ return PTR_ERR(cell); ++ ++ data = nvmem_cell_read(cell, &retlen); ++ nvmem_cell_put(cell); ++ ++ if (IS_ERR(data)) ++ return PTR_ERR(data); ++ ++ if (retlen != len) { ++ dev_err(rt2x00dev->dev, "invalid eeprom size, required: 0x%04x\n", len); ++ ret = -EINVAL; ++ goto exit; ++ } ++ ++ memcpy(rt2x00dev->eeprom, data, len); ++ ++ rt2800lib_eeprom_swap(rt2x00dev); ++ ++exit: ++ kfree(data); ++ return ret; ++} ++ + static const char * + rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) + { +@@ -164,6 +199,10 @@ int rt2x00lib_read_eeprom(struct rt2x00_ + return 0; + #endif + ++ ret = rt2800lib_read_eeprom_nvmem(rt2x00dev); ++ if (!ret) ++ return 0; ++ + return rt2x00lib_read_eeprom_file(rt2x00dev); + } + EXPORT_SYMBOL_GPL(rt2x00lib_read_eeprom); diff --git a/package/kernel/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch b/package/kernel/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch deleted file mode 100644 index 9dffef1812d..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/603-rt2x00-of_load_eeprom_filename.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c -@@ -26,6 +26,7 @@ - - #include <linux/kernel.h> - #include <linux/module.h> -+#include <linux/of.h> - - #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/package/kernel/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch b/package/kernel/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch index 6a8e594d5e9..ab09a68297f 100644 --- a/package/kernel/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch +++ b/package/kernel/mac80211/patches/rt2x00/606-rt2x00-allow_disabling_bands_through_platform_data.patch @@ -12,7 +12,7 @@ #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 +@@ -1008,6 +1008,22 @@ static int rt2x00lib_probe_hw_modes(stru unsigned int num_rates; unsigned int i; @@ -37,7 +37,7 @@ 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 { +@@ -408,6 +408,7 @@ struct hw_mode_spec { unsigned int supported_bands; #define SUPPORT_BAND_2GHZ 0x00000001 #define SUPPORT_BAND_5GHZ 0x00000002 diff --git a/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch b/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch index b5b2c610379..79f99ffdf4a 100644 --- a/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch +++ b/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch @@ -1,19 +1,18 @@ --- 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 +@@ -990,6 +990,12 @@ 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); + of_get_mac_address(rt2x00dev->dev->of_node, eeprom_mac_addr); + + if (!is_valid_ether_addr(eeprom_mac_addr)) { --- a/include/linux/rt2x00_platform.h +++ b/include/linux/rt2x00_platform.h @@ -14,6 +14,7 @@ diff --git a/package/kernel/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch b/package/kernel/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch index ff8b2c947b0..31f2f0261fd 100644 --- a/package/kernel/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch +++ b/package/kernel/mac80211/patches/rt2x00/608-rt2x00-allow_disabling_bands_through_dts.patch @@ -1,6 +1,6 @@ --- 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 +@@ -1013,6 +1013,16 @@ static int rt2x00lib_probe_hw_modes(stru struct ieee80211_rate *rates; unsigned int num_rates; unsigned int i; diff --git a/package/kernel/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch b/package/kernel/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch index 38f8b771768..c06ed07030e 100644 --- a/package/kernel/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch +++ b/package/kernel/mac80211/patches/rt2x00/609-rt2x00-make-wmac-loadable-via-OF-on-rt288x-305x-SoC.patch @@ -13,7 +13,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org> --- 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 +@@ -226,10 +226,17 @@ static int rt2800soc_probe(struct platfo return rt2x00soc_probe(pdev, &rt2800soc_ops); } diff --git a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch index 039c6f6afc6..8ee4e6cafa6 100644 --- a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch +++ b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch @@ -8,7 +8,7 @@ #include "rt2x00.h" #include "rt2800lib.h" -@@ -9530,6 +9531,17 @@ static int rt2800_init_eeprom(struct rt2 +@@ -11285,6 +11286,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); diff --git a/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch b/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch index 88d6dd559ba..9564f02edde 100644 --- a/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch +++ b/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1344,7 +1344,7 @@ static inline void rt2x00lib_set_if_comb +@@ -1362,7 +1362,7 @@ static inline void rt2x00lib_set_if_comb */ if_limit = &rt2x00dev->if_limits_ap; if_limit->max = rt2x00dev->ops->max_ap_intf; diff --git a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch b/package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch deleted file mode 100644 index fca1fb2cd44..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch +++ /dev/null @@ -1,44 +0,0 @@ -From: David Bauer <mail@david-bauer.net> -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 <mail@david-bauer.net> -Tested-by: Christoph Krapp <achterin@googlemail.com> - ---- 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; -@@ -1210,6 +1223,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/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch deleted file mode 100644 index 20452cd8a7a..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 9782a7f7488443568fa4d6088b73c9aff7eb8510 Mon Sep 17 00:00:00 2001 -From: Daniel Golle <daniel@makrotopia.org> -Date: Wed, 19 Apr 2017 16:14:53 +0200 -Subject: [PATCH] rt2x00: add support for external PA on MT7620 -To: Stanislaw Gruszka <sgruszka@redhat.com> -Cc: Helmut Schaa <helmut.schaa@googlemail.com>, - linux-wireless@vger.kernel.org, - Kalle Valo <kvalo@codeaurora.org> -Content-Type: text/plain; charset="UTF-8" -Content-Transfer-Encoding: quoted-printable - -Signed-off-by: Daniel Golle <daniel@makrotopia.org> -Signed-off-by: Tomislav Po=C5=BEega <pozega.tomislav@gmail.com> -[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/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch deleted file mode 100644 index 6be847478e0..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- 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/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch b/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch deleted file mode 100644 index 3ed0ff7ef53..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch +++ /dev/null @@ -1,166 +0,0 @@ ---- 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/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch deleted file mode 100644 index 77be986d18b..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- 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/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch b/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch deleted file mode 100644 index 7352ad036cd..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch +++ /dev/null @@ -1,395 +0,0 @@ ---- 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/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch deleted file mode 100644 index fe0961baa79..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch +++ /dev/null @@ -1,973 +0,0 @@ ---- 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/package/kernel/mac80211/patches/rt2x00/992-rt2x00-save-survey-for-every-channel-visited.patch b/package/kernel/mac80211/patches/rt2x00/992-rt2x00-save-survey-for-every-channel-visited.patch deleted file mode 100644 index 31a7baeee75..00000000000 --- a/package/kernel/mac80211/patches/rt2x00/992-rt2x00-save-survey-for-every-channel-visited.patch +++ /dev/null @@ -1,183 +0,0 @@ ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -1238,6 +1238,8 @@ void rt2800_watchdog(struct rt2x00_dev * - if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) - return; - -+ rt2800_update_survey(rt2x00dev); -+ - queue_for_each(rt2x00dev, queue) { - switch (queue->qid) { - case QID_AC_VO: -@@ -1274,6 +1276,18 @@ void rt2800_watchdog(struct rt2x00_dev * - } - EXPORT_SYMBOL_GPL(rt2800_watchdog); - -+void rt2800_update_survey(struct rt2x00_dev *rt2x00dev) -+{ -+ struct ieee80211_channel *chan = rt2x00dev->hw->conf.chandef.chan; -+ struct rt2x00_chan_survey *chan_survey = -+ &rt2x00dev->chan_survey[chan->hw_value]; -+ -+ chan_survey->time_idle += rt2800_register_read(rt2x00dev, CH_IDLE_STA); -+ chan_survey->time_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA); -+ chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); -+} -+EXPORT_SYMBOL_GPL(rt2800_update_survey); -+ - static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev, - unsigned int index) - { -@@ -12199,26 +12213,30 @@ int rt2800_get_survey(struct ieee80211_h - { - struct rt2x00_dev *rt2x00dev = hw->priv; - struct ieee80211_conf *conf = &hw->conf; -- u32 idle, busy, busy_ext; -+ struct rt2x00_chan_survey *chan_survey = -+ &rt2x00dev->chan_survey[idx]; -+ enum nl80211_band band = NL80211_BAND_2GHZ; - -- if (idx != 0) -+ if (idx >= rt2x00dev->bands[band].n_channels) { -+ idx -= rt2x00dev->bands[band].n_channels; -+ band = NL80211_BAND_5GHZ; -+ } -+ -+ if (idx >= rt2x00dev->bands[band].n_channels) - return -ENOENT; - -- survey->channel = conf->chandef.chan; -+ if (idx == 0) -+ rt2800_update_survey(rt2x00dev); - -- idle = rt2800_register_read(rt2x00dev, CH_IDLE_STA); -- busy = rt2800_register_read(rt2x00dev, CH_BUSY_STA); -- busy_ext = rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); -- -- if (idle || busy) { -- survey->filled = SURVEY_INFO_TIME | -- SURVEY_INFO_TIME_BUSY | -- SURVEY_INFO_TIME_EXT_BUSY; -- -- survey->time = (idle + busy) / 1000; -- survey->time_busy = busy / 1000; -- survey->time_ext_busy = busy_ext / 1000; -- } -+ survey->channel = &rt2x00dev->bands[band].channels[idx]; -+ -+ survey->filled = SURVEY_INFO_TIME | -+ SURVEY_INFO_TIME_BUSY | -+ SURVEY_INFO_TIME_EXT_BUSY; -+ -+ survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); -+ survey->time_busy = div_u64(chan_survey->time_busy, 1000); -+ survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); - - if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) - survey->filled |= SURVEY_INFO_IN_USE; ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -243,6 +243,7 @@ bool rt2800_txstatus_timeout(struct rt2x - bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev); - - void rt2800_watchdog(struct rt2x00_dev *rt2x00dev); -+void rt2800_update_survey(struct rt2x00_dev *rt2x00dev); - - void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc); - void rt2800_clear_beacon(struct queue_entry *entry); ---- a/drivers/net/wireless/ralink/rt2x00/rt2800pci.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800pci.c -@@ -360,6 +360,7 @@ static const struct rt2x00lib_ops rt2800 - .gain_calibration = rt2800_gain_calibration, - .vco_calibration = rt2800_vco_calibration, - .watchdog = rt2800_watchdog, -+ .update_survey = rt2800_update_survey, - .start_queue = rt2800mmio_start_queue, - .kick_queue = rt2800mmio_kick_queue, - .stop_queue = rt2800mmio_stop_queue, ---- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c -@@ -214,6 +214,7 @@ static const struct rt2x00lib_ops rt2800 - .gain_calibration = rt2800_gain_calibration, - .vco_calibration = rt2800_vco_calibration, - .watchdog = rt2800_watchdog, -+ .update_survey = rt2800_update_survey, - .start_queue = rt2800mmio_start_queue, - .kick_queue = rt2800mmio_kick_queue, - .stop_queue = rt2800mmio_stop_queue, ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h -@@ -183,6 +183,15 @@ struct rf_channel { - }; - - /* -+ * Information structure for channel survey. -+ */ -+struct rt2x00_chan_survey { -+ u64 time_idle; -+ u64 time_busy; -+ u64 time_ext_busy; -+}; -+ -+/* - * Channel information structure - */ - struct channel_info { -@@ -567,6 +576,7 @@ struct rt2x00lib_ops { - * Data queue handlers. - */ - void (*watchdog) (struct rt2x00_dev *rt2x00dev); -+ void (*update_survey) (struct rt2x00_dev *rt2x00dev); - void (*start_queue) (struct data_queue *queue); - void (*kick_queue) (struct data_queue *queue); - void (*stop_queue) (struct data_queue *queue); -@@ -755,6 +765,7 @@ struct rt2x00_dev { - */ - struct ieee80211_hw *hw; - struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; -+ struct rt2x00_chan_survey *chan_survey; - enum nl80211_band curr_band; - int curr_freq; - ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1057,6 +1057,12 @@ static int rt2x00lib_probe_hw_modes(stru - if (!rates) - goto exit_free_channels; - -+ rt2x00dev->chan_survey = -+ kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), -+ GFP_KERNEL); -+ if (!rt2x00dev->chan_survey) -+ goto exit_free_rates; -+ - /* - * Initialize Rate list. - */ -@@ -1108,6 +1114,8 @@ static int rt2x00lib_probe_hw_modes(stru - - return 0; - -+ exit_free_rates: -+ kfree(rates); - exit_free_channels: - kfree(channels); - rt2x00_err(rt2x00dev, "Allocation ieee80211 modes failed\n"); ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c -@@ -317,6 +317,15 @@ int rt2x00mac_config(struct ieee80211_hw - return 0; - - /* -+ * To provide correct survey data for survey-based ACS algorithm -+ * we have to save survey data for current channel before switching. -+ */ -+ if (rt2x00dev->ops->lib->update_survey && -+ (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { -+ rt2x00dev->ops->lib->update_survey(rt2x00dev); -+ } -+ -+ /* - * Some configuration parameters (e.g. channel and antenna values) can - * only be set when the radio is enabled, but do require the RX to - * be off. During this period we should keep link tuning enabled, diff --git a/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch new file mode 100644 index 00000000000..3e48eab5d20 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch @@ -0,0 +1,121 @@ +From 0fce1109f894ec7fcd72cb098843a1eff786716a Mon Sep 17 00:00:00 2001 +From: Daniel Golle <daniel@makrotopia.org> +Date: Fri, 16 Sep 2022 20:49:42 +0100 +Subject: [PATCH 16/16] rt2x00: import support for external LNA on MT7620 +To: linux-wireless@vger.kernel.org, + Stanislaw Gruszka <stf_xl@wp.pl>, + Helmut Schaa <helmut.schaa@googlemail.com> +Cc: Kalle Valo <kvalo@kernel.org>, + David S. Miller <davem@davemloft.net>, + Eric Dumazet <edumazet@google.com>, + Jakub Kicinski <kuba@kernel.org>, + Paolo Abeni <pabeni@redhat.com>, + Johannes Berg <johannes.berg@intel.com> + +In order to carry out calibration on boards with ePA or eLNA the PA pin +needs to be switch to GPIO mode on MT7620. Implement that by selecting +pinctrl state "pa_gpio" which should be defined for MT7620 boards with +eLNA or ePA beside the "default" state. + +Reported-by: Serge Vasilugin <vasilugin@yandex.ru> +Signed-off-by: Daniel Golle <daniel@makrotopia.org> +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 58 +++++++++++++++++++ + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 ++ + .../net/wireless/ralink/rt2x00/rt2x00soc.c | 15 +++++ + 3 files changed, 78 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -305,6 +305,24 @@ static void rt2800_rf_write(struct rt2x0 + mutex_unlock(&rt2x00dev->csr_mutex); + } + ++void rt6352_enable_pa_pin(struct rt2x00_dev *rt2x00dev, int enable) ++{ ++ if (!rt2x00dev->pinctrl) ++ return; ++ ++ if (enable) { ++ if (!rt2x00dev->pins_default) ++ return; ++ ++ pinctrl_select_state(rt2x00dev->pinctrl, rt2x00dev->pins_default); ++ } else { ++ if (!rt2x00dev->pins_pa_gpio) ++ return; ++ ++ pinctrl_select_state(rt2x00dev->pinctrl, rt2x00dev->pins_pa_gpio); ++ } ++} ++ + static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = { + [EEPROM_CHIP_ID] = 0x0000, + [EEPROM_VERSION] = 0x0001, +@@ -10407,8 +10425,10 @@ static void rt2800_calibration_rt6352(st + u32 reg; + + if (rt2x00_has_cap_external_pa(rt2x00dev) || +- rt2x00_has_cap_external_lna_bg(rt2x00dev)) ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt6352_enable_pa_pin(rt2x00dev, 0); + rt2800_restore_rf_bbp_rt6352(rt2x00dev); ++ } + + rt2800_r_calibration(rt2x00dev); + rt2800_rf_self_txdc_cal(rt2x00dev); +@@ -10426,6 +10446,8 @@ static void rt2800_calibration_rt6352(st + !rt2x00_has_cap_external_lna_bg(rt2x00dev)) + return; + ++ rt6352_enable_pa_pin(rt2x00dev, 1); ++ + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); + reg |= 0x00000101; +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -28,6 +28,7 @@ + #include <linux/average.h> + #include <linux/usb.h> + #include <linux/clk.h> ++#include <linux/pinctrl/consumer.h> + #include <linux/rt2x00_platform.h> + + #include <net/mac80211.h> +@@ -1027,6 +1028,11 @@ struct rt2x00_dev { + + /* Clock for System On Chip devices. */ + struct clk *clk; ++ ++ /* pinctrl and states for System On Chip devices with PA/LNA. */ ++ struct pinctrl *pinctrl; ++ struct pinctrl_state *pins_default; ++ struct pinctrl_state *pins_pa_gpio; + }; + + struct rt2x00_bar_list_entry { +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c +@@ -97,6 +97,21 @@ int rt2x00soc_probe(struct platform_devi + if (retval) + goto exit_free_reg; + ++ rt2x00dev->pinctrl = devm_pinctrl_get(&pdev->dev); ++ if (IS_ERR(rt2x00dev->pinctrl)) { ++ rt2x00dev->pinctrl = NULL; ++ rt2x00dev->pins_default = NULL; ++ rt2x00dev->pins_pa_gpio = NULL; ++ } else { ++ rt2x00dev->pins_default = pinctrl_lookup_state(rt2x00dev->pinctrl, "default"); ++ if (IS_ERR(rt2x00dev->pins_default)) ++ rt2x00dev->pins_default = NULL; ++ ++ rt2x00dev->pins_pa_gpio = pinctrl_lookup_state(rt2x00dev->pinctrl, "pa_gpio"); ++ if (IS_ERR(rt2x00dev->pins_pa_gpio)) ++ rt2x00dev->pins_pa_gpio = NULL; ++ } ++ + return 0; + + exit_free_reg: diff --git a/package/kernel/mac80211/patches/rt2x00/990-rt2x00-mt7620-introduce-accessors-for-CHIP_VER-register.patch b/package/kernel/mac80211/patches/rt2x00/995-rt2x00-mt7620-introduce-accessors-for-CHIP_VER-register.patch index 76114fe9ae2..19f1edc928b 100644 --- a/package/kernel/mac80211/patches/rt2x00/990-rt2x00-mt7620-introduce-accessors-for-CHIP_VER-register.patch +++ b/package/kernel/mac80211/patches/rt2x00/995-rt2x00-mt7620-introduce-accessors-for-CHIP_VER-register.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -78,6 +78,9 @@ struct rt2800_ops { +@@ -76,6 +76,9 @@ struct rt2800_ops { int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev); __le32 *(*drv_get_txwi)(struct queue_entry *entry); unsigned int (*drv_get_dma_done)(struct data_queue *queue); @@ -10,7 +10,7 @@ }; static inline u32 rt2800_register_read(struct rt2x00_dev *rt2x00dev, -@@ -195,6 +198,27 @@ static inline unsigned int rt2800_drv_ge +@@ -184,6 +187,27 @@ static inline unsigned int rt2800_drv_ge return rt2800ops->drv_get_dma_done(queue); } @@ -50,8 +50,8 @@ + static const struct ieee80211_ops rt2800pci_mac80211_ops = { .tx = rt2x00mac_tx, - .start = rt2x00mac_start, -@@ -328,6 +332,9 @@ static const struct rt2800_ops rt2800pci + .wake_tx_queue = ieee80211_handle_wake_tx_queue, +@@ -329,6 +333,9 @@ static const struct rt2800_ops rt2800pci .drv_init_registers = rt2800mmio_init_registers, .drv_get_txwi = rt2800mmio_get_txwi, .drv_get_dma_done = rt2800mmio_get_dma_done, @@ -103,8 +103,8 @@ + static const struct ieee80211_ops rt2800soc_mac80211_ops = { .tx = rt2x00mac_tx, - .start = rt2x00mac_start, -@@ -159,6 +186,9 @@ static const struct rt2800_ops rt2800soc + .wake_tx_queue = ieee80211_handle_wake_tx_queue, +@@ -161,6 +188,9 @@ static const struct rt2800_ops rt2800soc .drv_init_registers = rt2800mmio_init_registers, .drv_get_txwi = rt2800mmio_get_txwi, .drv_get_dma_done = rt2800mmio_get_dma_done, @@ -126,8 +126,8 @@ + static const struct ieee80211_ops rt2800usb_mac80211_ops = { .tx = rt2x00mac_tx, - .start = rt2x00mac_start, -@@ -671,6 +675,9 @@ static const struct rt2800_ops rt2800usb + .wake_tx_queue = ieee80211_handle_wake_tx_queue, +@@ -672,6 +676,9 @@ static const struct rt2800_ops rt2800usb .drv_init_registers = rt2800usb_init_registers, .drv_get_txwi = rt2800usb_get_txwi, .drv_get_dma_done = rt2800usb_get_dma_done, diff --git a/package/kernel/mac80211/patches/rt2x00/991-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch b/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch index 3de00b22678..0f699f5e18b 100644 --- a/package/kernel/mac80211/patches/rt2x00/991-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch +++ b/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h -@@ -1042,6 +1042,11 @@ +@@ -1056,6 +1056,11 @@ #define MIMO_PS_CFG_RX_STBY_POL FIELD32(0x00000010) #define MIMO_PS_CFG_RX_RX_STBY0 FIELD32(0x00000020) @@ -14,7 +14,7 @@ */ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -3685,14 +3685,16 @@ static void rt2800_config_channel_rf7620 +@@ -3836,14 +3836,16 @@ static void rt2800_config_channel_rf7620 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); rt2800_rfcsr_write(rt2x00dev, 19, rfcsr); @@ -39,7 +39,7 @@ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); rt2x00_set_field8(&rfcsr, RFCSR1_TX2_EN_MT7620, -@@ -3726,18 +3728,23 @@ static void rt2800_config_channel_rf7620 +@@ -3877,18 +3879,23 @@ static void rt2800_config_channel_rf7620 rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x20); } @@ -73,9 +73,9 @@ if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { if (conf_is_ht40(conf)) { -@@ -3837,25 +3844,29 @@ static void rt2800_config_alc(struct rt2 - if (i == 10000) - rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n"); +@@ -4002,25 +4009,29 @@ static void rt2800_config_alc_rt6352(str + if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY))) + rt2x00_warn(rt2x00dev, "RF busy while configuring ALC\n"); - if (chan->center_freq > 2457) { - bbp = rt2800_bbp_read(rt2x00dev, 30); @@ -121,12 +121,22 @@ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, mac_sys_ctrl); rt2800_vco_calibration(rt2x00dev); -@@ -5887,18 +5898,33 @@ static int rt2800_init_registers(struct +@@ -4513,7 +4524,8 @@ static void rt2800_config_channel(struct + if (rt2x00_rt(rt2x00dev, RT6352)) { + /* BBP for GLRT BW */ + bbp = conf_is_ht40(conf) ? +- 0x10 : rt2x00_has_cap_external_lna_bg(rt2x00dev) ? ++ 0x10 : !rt2x00_has_cap_external_lna_bg(rt2x00dev) ? ++ 0x1a : rt2800_hw_get_chippkg(rt2x00dev) == 1 ? + 0x15 : 0x1a; + rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); + +@@ -6017,18 +6029,33 @@ static int rt2800_init_registers(struct } else if (rt2x00_rt(rt2x00dev, RT5350)) { rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); } else if (rt2x00_rt(rt2x00dev, RT6352)) { - rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401); -- rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000); +- rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0001); - rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); - rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); - rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); @@ -150,7 +160,7 @@ + 0x00550055); + } else { + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401); -+ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000); ++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0001); + rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); + rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); + rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); @@ -167,7 +177,7 @@ reg = rt2800_register_read(rt2x00dev, TX_ALC_CFG_1); rt2x00_set_field32(®, TX_ALC_CFG_1_ROS_BUSY_EN, 0); rt2800_register_write(rt2x00dev, TX_ALC_CFG_1, reg); -@@ -7042,14 +7068,16 @@ static void rt2800_init_bbp_6352(struct +@@ -7141,14 +7168,16 @@ static void rt2800_init_bbp_6352(struct rt2800_bbp_write(rt2x00dev, 188, 0x00); rt2800_bbp_write(rt2x00dev, 189, 0x00); @@ -192,7 +202,27 @@ /* BBP for G band GLRT function (BBP_128 ~ BBP_221) */ rt2800_bbp_glrt_write(rt2x00dev, 0, 0x00); -@@ -10388,31 +10416,36 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10381,6 +10410,9 @@ static void rt2800_restore_rf_bbp_rt6352 + rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0); + } + ++ if (rt2800_hw_get_chippkg(rt2x00dev) != 1) ++ return; ++ + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23); +@@ -10458,6 +10490,9 @@ static void rt2800_calibration_rt6352(st + rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); + } + ++ if (rt2800_hw_get_chippkg(rt2x00dev) != 1) ++ return; ++ + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); +@@ -10548,31 +10583,36 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write(rt2x00dev, 42, 0x5B); rt2800_rfcsr_write(rt2x00dev, 43, 0x00); @@ -254,7 +284,7 @@ /* Initialize RF channel register to default value */ rt2800_rfcsr_write_chanreg(rt2x00dev, 0, 0x03); -@@ -10478,63 +10511,71 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10638,63 +10678,71 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_bank(rt2x00dev, 6, 45, 0xC5); @@ -288,33 +318,6 @@ - rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B); - rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xF7); - rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09); -- -- rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x51); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x2C); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x64); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x51); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x36); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); -- -- rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6C); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFC); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1F); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B); -- -- /* Initialize RF channel register for DRQFN */ -- rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xE3); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xE5); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x28); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x68); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xF7); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x02); -- rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xC7); + if (rt2800_hw_get_chipver(rt2x00dev) > 1) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x47); + rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x71); @@ -347,7 +350,16 @@ + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xF7); + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09); + } -+ + +- rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x51); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x2C); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x64); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x51); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x36); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); + if (rt2800_hw_get_chipver(rt2x00dev) > 1 && + rt2800_hw_get_chipeco(rt2x00dev) >= 2) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x51); @@ -367,7 +379,23 @@ + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66); + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B); + } -+ + +- rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6C); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFC); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1F); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B); +- +- /* Initialize RF channel register for DRQFN */ +- rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xE3); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xE5); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x28); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x68); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xF7); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x02); +- rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xC7); + if (rt2800_hw_get_chippkg(rt2x00dev) == 0 && + rt2800_hw_get_chipver(rt2x00dev) == 1) { + /* Initialize RF channel register for DRQFN */ @@ -383,7 +411,7 @@ /* Initialize RF DC calibration register to default value */ rt2800_rfcsr_write_dccal(rt2x00dev, 0, 0x47); -@@ -10597,12 +10638,17 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10757,12 +10805,17 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 62, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 63, 0x00); @@ -404,5 +432,5 @@ + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); + } - rt2800_r_calibration(rt2x00dev); - rt2800_rf_self_txdc_cal(rt2x00dev); + /* Do calibration and init PA/LNA */ + rt2800_calibration_rt6352(rt2x00dev); diff --git a/package/kernel/mac80211/patches/rtl/002-v5.13-rtlwifi-implement-set_tim-by-update-beacon-content.patch b/package/kernel/mac80211/patches/rtl/002-v5.13-rtlwifi-implement-set_tim-by-update-beacon-content.patch deleted file mode 100644 index 3daf65e9672..00000000000 --- a/package/kernel/mac80211/patches/rtl/002-v5.13-rtlwifi-implement-set_tim-by-update-beacon-content.patch +++ /dev/null @@ -1,118 +0,0 @@ -Date: Mon, 19 Apr 2021 14:59:56 +0800 -From: Ping-Ke Shih <pkshih@realtek.com> -To: <kvalo@codeaurora.org> -CC: <linux-wireless@vger.kernel.org>, <mail@maciej.szmigiero.name>, - <Larry.Finger@lwfinger.net> -Subject: [PATCH] rtlwifi: implement set_tim by update beacon content - -Once beacon content is changed, we update the content to wifi card by -send_beacon_frame(). Then, STA with PS can wake up properly to receive its -packets. - -Since we update beacon content to PCI wifi devices every beacon interval, -the only one usb device, 8192CU, needs to update beacon content when -mac80211 calling set_tim. - -Reported-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> -Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> -Tested-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> ---- - drivers/net/wireless/realtek/rtlwifi/core.c | 32 +++++++++++++++++++++ - drivers/net/wireless/realtek/rtlwifi/core.h | 1 + - drivers/net/wireless/realtek/rtlwifi/usb.c | 3 ++ - drivers/net/wireless/realtek/rtlwifi/wifi.h | 1 + - 4 files changed, 37 insertions(+) - ---- a/drivers/net/wireless/realtek/rtlwifi/core.c -+++ b/drivers/net/wireless/realtek/rtlwifi/core.c -@@ -1018,6 +1018,25 @@ static void send_beacon_frame(struct iee - } - } - -+void rtl_update_beacon_work_callback(struct work_struct *work) -+{ -+ struct rtl_works *rtlworks = -+ container_of(work, struct rtl_works, update_beacon_work); -+ struct ieee80211_hw *hw = rtlworks->hw; -+ struct rtl_priv *rtlpriv = rtl_priv(hw); -+ struct ieee80211_vif *vif = rtlpriv->mac80211.vif; -+ -+ if (!vif) { -+ WARN_ONCE(true, "no vif to update beacon\n"); -+ return; -+ } -+ -+ mutex_lock(&rtlpriv->locks.conf_mutex); -+ send_beacon_frame(hw, vif); -+ mutex_unlock(&rtlpriv->locks.conf_mutex); -+} -+EXPORT_SYMBOL_GPL(rtl_update_beacon_work_callback); -+ - static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, -@@ -1747,6 +1766,18 @@ static void rtl_op_flush(struct ieee8021 - rtlpriv->intf_ops->flush(hw, queues, drop); - } - -+static int rtl_op_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, -+ bool set) -+{ -+ struct rtl_priv *rtlpriv = rtl_priv(hw); -+ struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); -+ -+ if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU) -+ schedule_work(&rtlpriv->works.update_beacon_work); -+ -+ return 0; -+} -+ - /* Description: - * This routine deals with the Power Configuration CMD - * parsing for RTL8723/RTL8188E Series IC. -@@ -1903,6 +1934,7 @@ const struct ieee80211_ops rtl_ops = { - .sta_add = rtl_op_sta_add, - .sta_remove = rtl_op_sta_remove, - .flush = rtl_op_flush, -+ .set_tim = rtl_op_set_tim, - }; - EXPORT_SYMBOL_GPL(rtl_ops); - ---- a/drivers/net/wireless/realtek/rtlwifi/core.h -+++ b/drivers/net/wireless/realtek/rtlwifi/core.h -@@ -60,5 +60,6 @@ void rtl_bb_delay(struct ieee80211_hw *h - bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); - bool rtl_btc_status_false(void); - void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval); -+void rtl_update_beacon_work_callback(struct work_struct *work); - - #endif ---- a/drivers/net/wireless/realtek/rtlwifi/usb.c -+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c -@@ -807,6 +807,7 @@ static void rtl_usb_stop(struct ieee8021 - - tasklet_kill(&rtlusb->rx_work_tasklet); - cancel_work_sync(&rtlpriv->works.lps_change_work); -+ cancel_work_sync(&rtlpriv->works.update_beacon_work); - - flush_workqueue(rtlpriv->works.rtl_wq); - -@@ -1033,6 +1034,8 @@ int rtl_usb_probe(struct usb_interface * - rtl_fill_h2c_cmd_work_callback); - INIT_WORK(&rtlpriv->works.lps_change_work, - rtl_lps_change_work_callback); -+ INIT_WORK(&rtlpriv->works.update_beacon_work, -+ rtl_update_beacon_work_callback); - - rtlpriv->usb_data_index = 0; - init_completion(&rtlpriv->firmware_loading_complete); ---- a/drivers/net/wireless/realtek/rtlwifi/wifi.h -+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h -@@ -2487,6 +2487,7 @@ struct rtl_works { - - struct work_struct lps_change_work; - struct work_struct fill_h2c_cmd; -+ struct work_struct update_beacon_work; - }; - - struct rtl_debug { diff --git a/package/kernel/mac80211/patches/subsys/001-wifi-mac80211-do-not-pass-ap_vlan-vif-pointer-to-dri.patch b/package/kernel/mac80211/patches/subsys/001-wifi-mac80211-do-not-pass-ap_vlan-vif-pointer-to-dri.patch new file mode 100644 index 00000000000..43724aee1ae --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/001-wifi-mac80211-do-not-pass-ap_vlan-vif-pointer-to-dri.patch @@ -0,0 +1,64 @@ +From ee0db868ee4d88493dfdc82f59e3b4e449ddddd5 Mon Sep 17 00:00:00 2001 +From: Oldřich Jedlička <oldium.pro@gmail.com> +Date: Sat, 4 Nov 2023 15:13:33 +0100 +Subject: wifi: mac80211: do not pass AP_VLAN vif pointer to drivers during + flush +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ Upstream commit 3e3a2b645c043f7e3e488d5011478cefb69bbe8b ] + +This fixes WARN_ONs when using AP_VLANs after station removal. The flush +call passed AP_VLAN vif to driver, but because these vifs are virtual and +not registered with drivers, we need to translate to the correct AP vif +first. + +Closes: https://github.com/openwrt/openwrt/issues/12420 +Fixes: 0b75a1b1e42e ("wifi: mac80211: flush queues on STA removal") +Fixes: d00800a289c9 ("wifi: mac80211: add flush_sta method") +Tested-by: Konstantin Demin <rockdrilla@gmail.com> +Tested-by: Koen Vandeputte <koen.vandeputte@citymesh.com> +Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com> +Link: https://lore.kernel.org/r/20231104141333.3710-1-oldium.pro@gmail.com +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +Signed-off-by: Sasha Levin <sashal@kernel.org> +--- + net/mac80211/driver-ops.h | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/net/mac80211/driver-ops.h ++++ b/net/mac80211/driver-ops.h +@@ -23,7 +23,7 @@ + static inline struct ieee80211_sub_if_data * + get_bss_sdata(struct ieee80211_sub_if_data *sdata) + { +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) ++ if (sdata && sdata->vif.type == NL80211_IFTYPE_AP_VLAN) + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, + u.ap); + +@@ -638,10 +638,13 @@ static inline void drv_flush(struct ieee + struct ieee80211_sub_if_data *sdata, + u32 queues, bool drop) + { +- struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; ++ struct ieee80211_vif *vif; + + might_sleep(); + ++ sdata = get_bss_sdata(sdata); ++ vif = sdata ? &sdata->vif : NULL; ++ + if (sdata && !check_sdata_in_driver(sdata)) + return; + +@@ -657,6 +660,8 @@ static inline void drv_flush_sta(struct + { + might_sleep(); + ++ sdata = get_bss_sdata(sdata); ++ + if (sdata && !check_sdata_in_driver(sdata)) + return; + diff --git a/package/kernel/mac80211/patches/subsys/010-sync-nl80211_h.patch b/package/kernel/mac80211/patches/subsys/010-sync-nl80211_h.patch deleted file mode 100644 index e1f66ac1c34..00000000000 --- a/package/kernel/mac80211/patches/subsys/010-sync-nl80211_h.patch +++ /dev/null @@ -1,297 +0,0 @@ ---- a/include/uapi/linux/nl80211.h -+++ b/include/uapi/linux/nl80211.h -@@ -655,6 +655,9 @@ - * When a security association was established on an 802.1X network using - * fast transition, this event should be followed by an - * %NL80211_CMD_PORT_AUTHORIZED event. -+ * Following a %NL80211_CMD_ROAM event userspace can issue -+ * %NL80211_CMD_GET_SCAN in order to obtain the scan information for the -+ * new BSS the card/driver roamed to. - * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify - * userspace that a connection was dropped by the AP or due to other - * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and -@@ -757,7 +760,8 @@ - * of any other interfaces, and other interfaces will again take - * precedence when they are used. - * -- * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface. -+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface -+ * (no longer supported). - * - * @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if this AP should perform - * multicast to unicast conversion. When enabled, all multicast packets -@@ -1177,6 +1181,10 @@ - * includes the contents of the frame. %NL80211_ATTR_ACK flag is included - * if the recipient acknowledged the frame. - * -+ * @NL80211_CMD_SET_SAR_SPECS: SAR power limitation configuration is -+ * passed using %NL80211_ATTR_SAR_SPEC. %NL80211_ATTR_WIPHY is used to -+ * specify the wiphy index to be applied to. -+ * - * @NL80211_CMD_MAX: highest used command number - * @__NL80211_CMD_AFTER_LAST: internal use - */ -@@ -1407,6 +1415,8 @@ enum nl80211_commands { - - NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS, - -+ NL80211_CMD_SET_SAR_SPECS, -+ - /* add new commands above here */ - - /* used to define NL80211_CMD_MAX below */ -@@ -1750,8 +1760,9 @@ enum nl80211_commands { - * specify just a single bitrate, which is to be used for the beacon. - * The driver must also specify support for this with the extended - * features NL80211_EXT_FEATURE_BEACON_RATE_LEGACY, -- * NL80211_EXT_FEATURE_BEACON_RATE_HT and -- * NL80211_EXT_FEATURE_BEACON_RATE_VHT. -+ * NL80211_EXT_FEATURE_BEACON_RATE_HT, -+ * NL80211_EXT_FEATURE_BEACON_RATE_VHT and -+ * NL80211_EXT_FEATURE_BEACON_RATE_HE. - * - * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain - * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME. -@@ -1955,8 +1966,15 @@ enum nl80211_commands { - * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire - * probe-response frame. The DA field in the 802.11 header is zero-ed out, - * to be filled by the FW. -- * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable -- * this feature. Currently, only supported in mac80211 drivers. -+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable -+ * this feature during association. This is a flag attribute. -+ * Currently only supported in mac80211 drivers. -+ * @NL80211_ATTR_DISABLE_VHT: Force VHT capable interfaces to disable -+ * this feature during association. This is a flag attribute. -+ * Currently only supported in mac80211 drivers. -+ * @NL80211_ATTR_DISABLE_HE: Force HE capable interfaces to disable -+ * this feature during association. This is a flag attribute. -+ * Currently only supported in mac80211 drivers. - * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the - * ATTR_HT_CAPABILITY to which attention should be paid. - * Currently, only mac80211 NICs support this feature. -@@ -2077,7 +2095,8 @@ enum nl80211_commands { - * until the channel switch event. - * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission - * must be blocked on the current channel (before the channel switch -- * operation). -+ * operation). Also included in the channel switch started event if quiet -+ * was requested by the AP. - * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information - * for the time while performing a channel switch. - * @NL80211_ATTR_CNTDWN_OFFS_BEACON: An array of offsets (u16) to the channel -@@ -2527,6 +2546,20 @@ enum nl80211_commands { - * override mask. Used with NL80211_ATTR_S1G_CAPABILITY in - * NL80211_CMD_ASSOCIATE or NL80211_CMD_CONNECT. - * -+ * @NL80211_ATTR_SAE_PWE: Indicates the mechanism(s) allowed for SAE PWE -+ * derivation in WPA3-Personal networks which are using SAE authentication. -+ * This is a u8 attribute that encapsulates one of the values from -+ * &enum nl80211_sae_pwe_mechanism. -+ * -+ * @NL80211_ATTR_SAR_SPEC: SAR power limitation specification when -+ * used with %NL80211_CMD_SET_SAR_SPECS. The message contains fields -+ * of %nl80211_sar_attrs which specifies the sar type and related -+ * sar specs. Sar specs contains array of %nl80211_sar_specs_attrs. -+ * -+ * @NL80211_ATTR_RECONNECT_REQUESTED: flag attribute, used with deauth and -+ * disassoc events to indicate that an immediate reconnect to the AP -+ * is desired. -+ * - * @NUM_NL80211_ATTR: total number of nl80211_attrs available - * @NL80211_ATTR_MAX: highest attribute number currently defined - * @__NL80211_ATTR_AFTER_LAST: internal use -@@ -3016,6 +3049,14 @@ enum nl80211_attrs { - NL80211_ATTR_S1G_CAPABILITY, - NL80211_ATTR_S1G_CAPABILITY_MASK, - -+ NL80211_ATTR_SAE_PWE, -+ -+ NL80211_ATTR_RECONNECT_REQUESTED, -+ -+ NL80211_ATTR_SAR_SPEC, -+ -+ NL80211_ATTR_DISABLE_HE, -+ - /* add attributes here, update the policy in nl80211.c */ - - __NL80211_ATTR_AFTER_LAST, -@@ -5896,6 +5937,19 @@ enum nl80211_feature_flags { - * @NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP: Driver/device supports - * unsolicited broadcast probe response transmission - * -+ * @NL80211_EXT_FEATURE_BEACON_RATE_HE: Driver supports beacon rate -+ * configuration (AP/mesh) with HE rates. -+ * -+ * @NL80211_EXT_FEATURE_SECURE_LTF: Device supports secure LTF measurement -+ * exchange protocol. -+ * -+ * @NL80211_EXT_FEATURE_SECURE_RTT: Device supports secure RTT measurement -+ * exchange protocol. -+ * -+ * @NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE: Device supports management -+ * frame protection for all management frames exchanged during the -+ * negotiation and range measurement procedure. -+ * - * @NUM_NL80211_EXT_FEATURES: number of extended features. - * @MAX_NL80211_EXT_FEATURES: highest extended feature index. - */ -@@ -5956,6 +6010,10 @@ enum nl80211_ext_feature_index { - NL80211_EXT_FEATURE_SAE_OFFLOAD_AP, - NL80211_EXT_FEATURE_FILS_DISCOVERY, - NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP, -+ NL80211_EXT_FEATURE_BEACON_RATE_HE, -+ NL80211_EXT_FEATURE_SECURE_LTF, -+ NL80211_EXT_FEATURE_SECURE_RTT, -+ NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE, - - /* add new features before the definition below */ - NUM_NL80211_EXT_FEATURES, -@@ -6253,11 +6311,13 @@ struct nl80211_vendor_cmd_info { - * @NL80211_TDLS_PEER_HT: TDLS peer is HT capable. - * @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable. - * @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable. -+ * @NL80211_TDLS_PEER_HE: TDLS peer is HE capable. - */ - enum nl80211_tdls_peer_capability { - NL80211_TDLS_PEER_HT = 1<<0, - NL80211_TDLS_PEER_VHT = 1<<1, - NL80211_TDLS_PEER_WMM = 1<<2, -+ NL80211_TDLS_PEER_HE = 1<<3, - }; - - /** -@@ -6849,6 +6909,9 @@ enum nl80211_peer_measurement_ftm_capa { - * if neither %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED nor - * %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set, EDCA based - * ranging will be used. -+ * @NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK: negotiate for LMR feedback. Only -+ * valid if either %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED or -+ * %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set. - * - * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal - * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number -@@ -6867,6 +6930,7 @@ enum nl80211_peer_measurement_ftm_req { - NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC, - NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED, - NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED, -+ NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK, - - /* keep last */ - NUM_NL80211_PMSR_FTM_REQ_ATTR, -@@ -7124,4 +7188,115 @@ enum nl80211_unsol_bcast_probe_resp_attr - NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX = - __NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST - 1 - }; -+ -+/** -+ * enum nl80211_sae_pwe_mechanism - The mechanism(s) allowed for SAE PWE -+ * derivation. Applicable only when WPA3-Personal SAE authentication is -+ * used. -+ * -+ * @NL80211_SAE_PWE_UNSPECIFIED: not specified, used internally to indicate that -+ * attribute is not present from userspace. -+ * @NL80211_SAE_PWE_HUNT_AND_PECK: hunting-and-pecking loop only -+ * @NL80211_SAE_PWE_HASH_TO_ELEMENT: hash-to-element only -+ * @NL80211_SAE_PWE_BOTH: both hunting-and-pecking loop and hash-to-element -+ * can be used. -+ */ -+enum nl80211_sae_pwe_mechanism { -+ NL80211_SAE_PWE_UNSPECIFIED, -+ NL80211_SAE_PWE_HUNT_AND_PECK, -+ NL80211_SAE_PWE_HASH_TO_ELEMENT, -+ NL80211_SAE_PWE_BOTH, -+}; -+ -+/** -+ * enum nl80211_sar_type - type of SAR specs -+ * -+ * @NL80211_SAR_TYPE_POWER: power limitation specified in 0.25dBm unit -+ * -+ */ -+enum nl80211_sar_type { -+ NL80211_SAR_TYPE_POWER, -+ -+ /* add new type here */ -+ -+ /* Keep last */ -+ NUM_NL80211_SAR_TYPE, -+}; -+ -+/** -+ * enum nl80211_sar_attrs - Attributes for SAR spec -+ * -+ * @NL80211_SAR_ATTR_TYPE: the SAR type as defined in &enum nl80211_sar_type. -+ * -+ * @NL80211_SAR_ATTR_SPECS: Nested array of SAR power -+ * limit specifications. Each specification contains a set -+ * of %nl80211_sar_specs_attrs. -+ * -+ * For SET operation, it contains array of %NL80211_SAR_ATTR_SPECS_POWER -+ * and %NL80211_SAR_ATTR_SPECS_RANGE_INDEX. -+ * -+ * For sar_capa dump, it contains array of -+ * %NL80211_SAR_ATTR_SPECS_START_FREQ -+ * and %NL80211_SAR_ATTR_SPECS_END_FREQ. -+ * -+ * @__NL80211_SAR_ATTR_LAST: Internal -+ * @NL80211_SAR_ATTR_MAX: highest sar attribute -+ * -+ * These attributes are used with %NL80211_CMD_SET_SAR_SPEC -+ */ -+enum nl80211_sar_attrs { -+ __NL80211_SAR_ATTR_INVALID, -+ -+ NL80211_SAR_ATTR_TYPE, -+ NL80211_SAR_ATTR_SPECS, -+ -+ __NL80211_SAR_ATTR_LAST, -+ NL80211_SAR_ATTR_MAX = __NL80211_SAR_ATTR_LAST - 1, -+}; -+ -+/** -+ * enum nl80211_sar_specs_attrs - Attributes for SAR power limit specs -+ * -+ * @NL80211_SAR_ATTR_SPECS_POWER: Required (s32)value to specify the actual -+ * power limit value in units of 0.25 dBm if type is -+ * NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm). -+ * 0 means userspace doesn't have SAR limitation on this associated range. -+ * -+ * @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the -+ * index of exported freq range table and the associated power limitation -+ * is applied to this range. -+ * -+ * Userspace isn't required to set all the ranges advertised by WLAN driver, -+ * and userspace can skip some certain ranges. These skipped ranges don't -+ * have SAR limitations, and they are same as setting the -+ * %NL80211_SAR_ATTR_SPECS_POWER to any unreasonable high value because any -+ * value higher than regulatory allowed value just means SAR power -+ * limitation is removed, but it's required to set at least one range. -+ * It's not allowed to set duplicated range in one SET operation. -+ * -+ * Every SET operation overwrites previous SET operation. -+ * -+ * @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start -+ * frequency of this range edge when registering SAR capability to wiphy. -+ * It's not a channel center frequency. The unit is kHz. -+ * -+ * @NL80211_SAR_ATTR_SPECS_END_FREQ: Required (u32) value to specify the end -+ * frequency of this range edge when registering SAR capability to wiphy. -+ * It's not a channel center frequency. The unit is kHz. -+ * -+ * @__NL80211_SAR_ATTR_SPECS_LAST: Internal -+ * @NL80211_SAR_ATTR_SPECS_MAX: highest sar specs attribute -+ */ -+enum nl80211_sar_specs_attrs { -+ __NL80211_SAR_ATTR_SPECS_INVALID, -+ -+ NL80211_SAR_ATTR_SPECS_POWER, -+ NL80211_SAR_ATTR_SPECS_RANGE_INDEX, -+ NL80211_SAR_ATTR_SPECS_START_FREQ, -+ NL80211_SAR_ATTR_SPECS_END_FREQ, -+ -+ __NL80211_SAR_ATTR_SPECS_LAST, -+ NL80211_SAR_ATTR_SPECS_MAX = __NL80211_SAR_ATTR_SPECS_LAST - 1, -+}; -+ - #endif /* __LINUX_NL80211_H */ diff --git a/package/kernel/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch b/package/kernel/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch index 665231a040e..e3349dabd0b 100644 --- a/package/kernel/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch +++ b/package/kernel/mac80211/patches/subsys/110-mac80211_keep_keys_on_stop_ap.patch @@ -1,12 +1,19 @@ -Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnects +From: Felix Fietkau <nbd@nbd.name> +Date: Mon, 27 Oct 2014 00:00:00 +0100 +Subject: [PATCH] mac80211: preseve AP mode keys across STA reconnect + +Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnect +--- + net/mac80211/cfg.c | 1 - + 1 file changed, 1 deletion(-) --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c -@@ -1288,7 +1288,6 @@ static int ieee80211_stop_ap(struct wiph - sdata->vif.bss_conf.ftmr_params = NULL; +@@ -1632,7 +1632,6 @@ static int ieee80211_stop_ap(struct wiph + link_conf->bssid_indicator = 0; __sta_info_flush(sdata, true); - ieee80211_free_keys(sdata, true); - sdata->vif.bss_conf.enable_beacon = false; + link_conf->enable_beacon = false; sdata->beacon_rate_set = false; diff --git a/package/kernel/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch b/package/kernel/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch index 172e5b04fdf..f315ae5ca2b 100644 --- a/package/kernel/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch +++ b/package/kernel/mac80211/patches/subsys/120-cfg80211_allow_perm_addr_change.patch @@ -1,6 +1,15 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Thu, 11 Dec 2014 00:00:00 +0100 +Subject: [PATCH] cfg80211: add support for changing the device mac address via + sysfs + +--- + net/wireless/sysfs.c | 27 ++++++++++++++++++++++----- + 1 file changed, 22 insertions(+), 5 deletions(-) + --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c -@@ -23,18 +23,35 @@ static inline struct cfg80211_registered +@@ -24,18 +24,35 @@ static inline struct cfg80211_registered return container_of(dev, struct cfg80211_registered_device, wiphy.dev); } diff --git a/package/kernel/mac80211/patches/subsys/130-disable_auto_vif.patch b/package/kernel/mac80211/patches/subsys/130-disable_auto_vif.patch new file mode 100644 index 00000000000..9d8f781ac41 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/130-disable_auto_vif.patch @@ -0,0 +1,27 @@ +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -1396,24 +1396,6 @@ int ieee80211_register_hw(struct ieee802 + debugfs_hw_add(local); + rate_control_add_debugfs(local); + +- rtnl_lock(); +- wiphy_lock(hw->wiphy); +- +- /* add one default STA interface if supported */ +- if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION) && +- !ieee80211_hw_check(hw, NO_AUTO_VIF)) { +- struct vif_params params = {0}; +- +- result = ieee80211_if_add(local, "wlan%d", NET_NAME_ENUM, NULL, +- NL80211_IFTYPE_STATION, ¶ms); +- if (result) +- wiphy_warn(local->hw.wiphy, +- "Failed to add default virtual iface\n"); +- } +- +- wiphy_unlock(hw->wiphy); +- rtnl_unlock(); +- + #ifdef CONFIG_INET + local->ifa_notifier.notifier_call = ieee80211_ifa_changed; + result = register_inetaddr_notifier(&local->ifa_notifier); diff --git a/package/kernel/mac80211/patches/subsys/150-disable_addr_notifier.patch b/package/kernel/mac80211/patches/subsys/150-disable_addr_notifier.patch deleted file mode 100644 index 8d086625e44..00000000000 --- a/package/kernel/mac80211/patches/subsys/150-disable_addr_notifier.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- 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) - { -@@ -1315,14 +1315,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) -@@ -1331,13 +1331,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); -@@ -1365,10 +1365,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/package/kernel/mac80211/patches/subsys/210-ap_scan.patch b/package/kernel/mac80211/patches/subsys/210-ap_scan.patch index ee49942459d..25b844a21b2 100644 --- a/package/kernel/mac80211/patches/subsys/210-ap_scan.patch +++ b/package/kernel/mac80211/patches/subsys/210-ap_scan.patch @@ -1,11 +1,19 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Wed, 3 Oct 2012 00:00:00 +0200 +Subject: [PATCH] mac80211: allow scans in access point mode (for site survey) + +--- + net/mac80211/cfg.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c -@@ -2444,7 +2444,7 @@ static int ieee80211_scan(struct wiphy * - * the frames sent while scanning on other channel will be - * lost) +@@ -2843,6 +2843,8 @@ static int ieee80211_scan(struct wiphy * */ -- 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; + fallthrough; + case NL80211_IFTYPE_AP: ++ /* skip check */ ++ break; + /* + * If the scan has been forced (and the driver supports + * forcing), don't care about being beaconing already. diff --git a/package/kernel/mac80211/patches/subsys/300-cfg80211-support-immediate-reconnect-request-hint.patch b/package/kernel/mac80211/patches/subsys/300-cfg80211-support-immediate-reconnect-request-hint.patch deleted file mode 100644 index 8fe8723cfe3..00000000000 --- a/package/kernel/mac80211/patches/subsys/300-cfg80211-support-immediate-reconnect-request-hint.patch +++ /dev/null @@ -1,279 +0,0 @@ -From: Johannes Berg <johannes.berg@intel.com> -Date: Sun, 6 Dec 2020 14:54:42 +0200 -Subject: [PATCH] cfg80211: support immediate reconnect request hint - -There are cases where it's necessary to disconnect, but an -immediate reconnection is desired. Support a hint to userspace -that this is the case, by including a new attribute in the -deauth or disassoc event. - -Signed-off-by: Luca Coelho <luciano.coelho@intel.com> -Link: https://lore.kernel.org/r/iwlwifi.20201206145305.58d33941fb9d.I0e7168c205c7949529c8e3b86f3c9b12c01a7017@changeid -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/cfg80211.h -+++ b/include/net/cfg80211.h -@@ -6410,13 +6410,15 @@ void cfg80211_abandon_assoc(struct net_d - * @dev: network device - * @buf: 802.11 frame (header + body) - * @len: length of the frame data -+ * @reconnect: immediate reconnect is desired (include the nl80211 attribute) - * - * This function is called whenever deauthentication has been processed in - * station mode. This includes both received deauthentication frames and - * locally generated ones. This function may sleep. The caller must hold the - * corresponding wdev's mutex. - */ --void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len); -+void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len, -+ bool reconnect); - - /** - * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -2734,7 +2734,7 @@ static void ieee80211_report_disconnect( - }; - - if (tx) -- cfg80211_tx_mlme_mgmt(sdata->dev, buf, len); -+ cfg80211_tx_mlme_mgmt(sdata->dev, buf, len, false); - else - cfg80211_rx_mlme_mgmt(sdata->dev, buf, len); - -@@ -4724,7 +4724,8 @@ void ieee80211_mgd_quiesce(struct ieee80 - if (ifmgd->auth_data) - ieee80211_destroy_auth_data(sdata, false); - cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, -- IEEE80211_DEAUTH_FRAME_LEN); -+ IEEE80211_DEAUTH_FRAME_LEN, -+ false); - } - - /* This is a bit of a hack - we should find a better and more generic ---- a/net/wireless/mlme.c -+++ b/net/wireless/mlme.c -@@ -4,7 +4,7 @@ - * - * Copyright (c) 2009, Jouni Malinen <j@w1.fi> - * Copyright (c) 2015 Intel Deutschland GmbH -- * Copyright (C) 2019 Intel Corporation -+ * Copyright (C) 2019-2020 Intel Corporation - */ - - #include <linux/kernel.h> -@@ -81,7 +81,8 @@ static void cfg80211_process_auth(struct - } - - static void cfg80211_process_deauth(struct wireless_dev *wdev, -- const u8 *buf, size_t len) -+ const u8 *buf, size_t len, -+ bool reconnect) - { - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; -@@ -89,7 +90,7 @@ static void cfg80211_process_deauth(stru - u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); - bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr); - -- nl80211_send_deauth(rdev, wdev->netdev, buf, len, GFP_KERNEL); -+ nl80211_send_deauth(rdev, wdev->netdev, buf, len, reconnect, GFP_KERNEL); - - if (!wdev->current_bss || - !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) -@@ -100,7 +101,8 @@ static void cfg80211_process_deauth(stru - } - - static void cfg80211_process_disassoc(struct wireless_dev *wdev, -- const u8 *buf, size_t len) -+ const u8 *buf, size_t len, -+ bool reconnect) - { - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; -@@ -108,7 +110,8 @@ static void cfg80211_process_disassoc(st - u16 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); - bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr); - -- nl80211_send_disassoc(rdev, wdev->netdev, buf, len, GFP_KERNEL); -+ nl80211_send_disassoc(rdev, wdev->netdev, buf, len, reconnect, -+ GFP_KERNEL); - - if (WARN_ON(!wdev->current_bss || - !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) -@@ -133,9 +136,9 @@ void cfg80211_rx_mlme_mgmt(struct net_de - if (ieee80211_is_auth(mgmt->frame_control)) - cfg80211_process_auth(wdev, buf, len); - else if (ieee80211_is_deauth(mgmt->frame_control)) -- cfg80211_process_deauth(wdev, buf, len); -+ cfg80211_process_deauth(wdev, buf, len, false); - else if (ieee80211_is_disassoc(mgmt->frame_control)) -- cfg80211_process_disassoc(wdev, buf, len); -+ cfg80211_process_disassoc(wdev, buf, len, false); - } - EXPORT_SYMBOL(cfg80211_rx_mlme_mgmt); - -@@ -180,22 +183,23 @@ void cfg80211_abandon_assoc(struct net_d - } - EXPORT_SYMBOL(cfg80211_abandon_assoc); - --void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len) -+void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len, -+ bool reconnect) - { - struct wireless_dev *wdev = dev->ieee80211_ptr; - struct ieee80211_mgmt *mgmt = (void *)buf; - - ASSERT_WDEV_LOCK(wdev); - -- trace_cfg80211_tx_mlme_mgmt(dev, buf, len); -+ trace_cfg80211_tx_mlme_mgmt(dev, buf, len, reconnect); - - if (WARN_ON(len < 2)) - return; - - if (ieee80211_is_deauth(mgmt->frame_control)) -- cfg80211_process_deauth(wdev, buf, len); -+ cfg80211_process_deauth(wdev, buf, len, reconnect); - else -- cfg80211_process_disassoc(wdev, buf, len); -+ cfg80211_process_disassoc(wdev, buf, len, reconnect); - } - EXPORT_SYMBOL(cfg80211_tx_mlme_mgmt); - ---- a/net/wireless/nl80211.c -+++ b/net/wireless/nl80211.c -@@ -736,6 +736,7 @@ static const struct nla_policy nl80211_p - NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN), - [NL80211_ATTR_S1G_CAPABILITY_MASK] = - NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN), -+ [NL80211_ATTR_RECONNECT_REQUESTED] = { .type = NLA_REJECT }, - }; - - /* policy for the key attributes */ -@@ -15903,7 +15904,7 @@ static void nl80211_send_mlme_event(stru - const u8 *buf, size_t len, - enum nl80211_commands cmd, gfp_t gfp, - int uapsd_queues, const u8 *req_ies, -- size_t req_ies_len) -+ size_t req_ies_len, bool reconnect) - { - struct sk_buff *msg; - void *hdr; -@@ -15925,6 +15926,9 @@ static void nl80211_send_mlme_event(stru - nla_put(msg, NL80211_ATTR_REQ_IE, req_ies_len, req_ies))) - goto nla_put_failure; - -+ if (reconnect && nla_put_flag(msg, NL80211_ATTR_RECONNECT_REQUESTED)) -+ goto nla_put_failure; -+ - if (uapsd_queues >= 0) { - struct nlattr *nla_wmm = - nla_nest_start_noflag(msg, NL80211_ATTR_STA_WME); -@@ -15953,7 +15957,8 @@ void nl80211_send_rx_auth(struct cfg8021 - size_t len, gfp_t gfp) - { - nl80211_send_mlme_event(rdev, netdev, buf, len, -- NL80211_CMD_AUTHENTICATE, gfp, -1, NULL, 0); -+ NL80211_CMD_AUTHENTICATE, gfp, -1, NULL, 0, -+ false); - } - - void nl80211_send_rx_assoc(struct cfg80211_registered_device *rdev, -@@ -15963,23 +15968,25 @@ void nl80211_send_rx_assoc(struct cfg802 - { - nl80211_send_mlme_event(rdev, netdev, buf, len, - NL80211_CMD_ASSOCIATE, gfp, uapsd_queues, -- req_ies, req_ies_len); -+ req_ies, req_ies_len, false); - } - - void nl80211_send_deauth(struct cfg80211_registered_device *rdev, - struct net_device *netdev, const u8 *buf, -- size_t len, gfp_t gfp) -+ size_t len, bool reconnect, gfp_t gfp) - { - nl80211_send_mlme_event(rdev, netdev, buf, len, -- NL80211_CMD_DEAUTHENTICATE, gfp, -1, NULL, 0); -+ NL80211_CMD_DEAUTHENTICATE, gfp, -1, NULL, 0, -+ reconnect); - } - - void nl80211_send_disassoc(struct cfg80211_registered_device *rdev, - struct net_device *netdev, const u8 *buf, -- size_t len, gfp_t gfp) -+ size_t len, bool reconnect, gfp_t gfp) - { - nl80211_send_mlme_event(rdev, netdev, buf, len, -- NL80211_CMD_DISASSOCIATE, gfp, -1, NULL, 0); -+ NL80211_CMD_DISASSOCIATE, gfp, -1, NULL, 0, -+ reconnect); - } - - void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev, const u8 *buf, -@@ -16010,7 +16017,7 @@ void cfg80211_rx_unprot_mlme_mgmt(struct - - trace_cfg80211_rx_unprot_mlme_mgmt(dev, buf, len); - nl80211_send_mlme_event(rdev, dev, buf, len, cmd, GFP_ATOMIC, -1, -- NULL, 0); -+ NULL, 0, false); - } - EXPORT_SYMBOL(cfg80211_rx_unprot_mlme_mgmt); - ---- a/net/wireless/nl80211.h -+++ b/net/wireless/nl80211.h -@@ -1,7 +1,7 @@ - /* SPDX-License-Identifier: GPL-2.0 */ - /* - * Portions of this file -- * Copyright (C) 2018 Intel Corporation -+ * Copyright (C) 2018, 2020 Intel Corporation - */ - #ifndef __NET_WIRELESS_NL80211_H - #define __NET_WIRELESS_NL80211_H -@@ -69,10 +69,12 @@ void nl80211_send_rx_assoc(struct cfg802 - const u8 *req_ies, size_t req_ies_len); - void nl80211_send_deauth(struct cfg80211_registered_device *rdev, - struct net_device *netdev, -- const u8 *buf, size_t len, gfp_t gfp); -+ const u8 *buf, size_t len, -+ bool reconnect, gfp_t gfp); - void nl80211_send_disassoc(struct cfg80211_registered_device *rdev, - struct net_device *netdev, -- const u8 *buf, size_t len, gfp_t gfp); -+ const u8 *buf, size_t len, -+ bool reconnect, gfp_t gfp); - void nl80211_send_auth_timeout(struct cfg80211_registered_device *rdev, - struct net_device *netdev, - const u8 *addr, gfp_t gfp); ---- a/net/wireless/trace.h -+++ b/net/wireless/trace.h -@@ -2684,19 +2684,23 @@ DEFINE_EVENT(netdev_frame_event, cfg8021 - ); - - TRACE_EVENT(cfg80211_tx_mlme_mgmt, -- TP_PROTO(struct net_device *netdev, const u8 *buf, int len), -- TP_ARGS(netdev, buf, len), -+ TP_PROTO(struct net_device *netdev, const u8 *buf, int len, -+ bool reconnect), -+ TP_ARGS(netdev, buf, len, reconnect), - TP_STRUCT__entry( - NETDEV_ENTRY - __dynamic_array(u8, frame, len) -+ __field(int, reconnect) - ), - TP_fast_assign( - NETDEV_ASSIGN; - memcpy(__get_dynamic_array(frame), buf, len); -+ __entry->reconnect = reconnect; - ), -- TP_printk(NETDEV_PR_FMT ", ftype:0x%.2x", -+ TP_printk(NETDEV_PR_FMT ", ftype:0x%.2x reconnect:%d", - NETDEV_PR_ARG, -- le16_to_cpup((__le16 *)__get_dynamic_array(frame))) -+ le16_to_cpup((__le16 *)__get_dynamic_array(frame)), -+ __entry->reconnect) - ); - - DECLARE_EVENT_CLASS(netdev_mac_evt, diff --git a/package/kernel/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch b/package/kernel/mac80211/patches/subsys/301-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch index d09d70725e5..ffa5c17e487 100644 --- a/package/kernel/mac80211/patches/subsys/304-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch +++ b/package/kernel/mac80211/patches/subsys/301-mac80211-sta-randomize-BA-session-dialog-token-alloc.patch @@ -28,7 +28,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com> --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c -@@ -357,6 +357,7 @@ struct sta_info *sta_info_alloc(struct i +@@ -558,6 +558,7 @@ __sta_info_alloc(struct ieee80211_sub_if 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); diff --git a/package/kernel/mac80211/patches/subsys/301-mac80211-support-driver-based-disconnect-with-reconn.patch b/package/kernel/mac80211/patches/subsys/301-mac80211-support-driver-based-disconnect-with-reconn.patch deleted file mode 100644 index 31621ebf116..00000000000 --- a/package/kernel/mac80211/patches/subsys/301-mac80211-support-driver-based-disconnect-with-reconn.patch +++ /dev/null @@ -1,271 +0,0 @@ -From: Johannes Berg <johannes.berg@intel.com> -Date: Sun, 6 Dec 2020 14:54:43 +0200 -Subject: [PATCH] mac80211: support driver-based disconnect with reconnect hint - -Support the driver indicating that a disconnection needs -to be performed, and pass through the reconnect hint in -this case. - -Signed-off-by: Johannes Berg <johannes.berg@intel.com> -Signed-off-by: Luca Coelho <luciano.coelho@intel.com> -Link: https://lore.kernel.org/r/iwlwifi.20201206145305.5c8dab7a22a0.I58459fdf6968b16c90cab9c574f0f04ca22b0c79@changeid -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -5885,6 +5885,17 @@ void ieee80211_beacon_loss(struct ieee80 - void ieee80211_connection_loss(struct ieee80211_vif *vif); - - /** -+ * ieee80211_disconnect - request disconnection -+ * -+ * @vif: &struct ieee80211_vif pointer from the add_interface callback. -+ * @reconnect: immediate reconnect is desired -+ * -+ * Request disconnection from the current network and, if enabled, send a -+ * hint to the higher layers that immediate reconnect is desired. -+ */ -+void ieee80211_disconnect(struct ieee80211_vif *vif, bool reconnect); -+ -+/** - * ieee80211_resume_disconnect - disconnect from AP after resume - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -450,7 +450,9 @@ struct ieee80211_if_managed { - unsigned long probe_timeout; - int probe_send_count; - bool nullfunc_failed; -- bool connection_loss; -+ u8 connection_loss:1, -+ driver_disconnect:1, -+ reconnect:1; - - struct cfg80211_bss *associated; - struct ieee80211_mgd_auth_data *auth_data; ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -2725,7 +2725,7 @@ EXPORT_SYMBOL(ieee80211_ap_probereq_get) - - static void ieee80211_report_disconnect(struct ieee80211_sub_if_data *sdata, - const u8 *buf, size_t len, bool tx, -- u16 reason) -+ u16 reason, bool reconnect) - { - struct ieee80211_event event = { - .type = MLME_EVENT, -@@ -2734,7 +2734,7 @@ static void ieee80211_report_disconnect( - }; - - if (tx) -- cfg80211_tx_mlme_mgmt(sdata->dev, buf, len, false); -+ cfg80211_tx_mlme_mgmt(sdata->dev, buf, len, reconnect); - else - cfg80211_rx_mlme_mgmt(sdata->dev, buf, len); - -@@ -2756,13 +2756,18 @@ static void __ieee80211_disconnect(struc - - tx = !sdata->csa_block_tx; - -- /* AP is probably out of range (or not reachable for another reason) so -- * remove the bss struct for that AP. -- */ -- cfg80211_unlink_bss(local->hw.wiphy, ifmgd->associated); -+ if (!ifmgd->driver_disconnect) { -+ /* -+ * AP is probably out of range (or not reachable for another -+ * reason) so remove the bss struct for that AP. -+ */ -+ cfg80211_unlink_bss(local->hw.wiphy, ifmgd->associated); -+ } - - ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, -- WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, -+ ifmgd->driver_disconnect ? -+ WLAN_REASON_DEAUTH_LEAVING : -+ WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, - tx, frame_buf); - mutex_lock(&local->mtx); - sdata->vif.csa_active = false; -@@ -2775,7 +2780,9 @@ static void __ieee80211_disconnect(struc - mutex_unlock(&local->mtx); - - ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), tx, -- WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); -+ WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, -+ ifmgd->reconnect); -+ ifmgd->reconnect = false; - - sdata_unlock(sdata); - } -@@ -2794,6 +2801,13 @@ static void ieee80211_beacon_connection_ - sdata_info(sdata, "Connection to AP %pM lost\n", - ifmgd->bssid); - __ieee80211_disconnect(sdata); -+ ifmgd->connection_loss = false; -+ } else if (ifmgd->driver_disconnect) { -+ sdata_info(sdata, -+ "Driver requested disconnection from AP %pM\n", -+ ifmgd->bssid); -+ __ieee80211_disconnect(sdata); -+ ifmgd->driver_disconnect = false; - } else { - ieee80211_mgd_probe_ap(sdata, true); - } -@@ -2832,6 +2846,21 @@ void ieee80211_connection_loss(struct ie - } - EXPORT_SYMBOL(ieee80211_connection_loss); - -+void ieee80211_disconnect(struct ieee80211_vif *vif, bool reconnect) -+{ -+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); -+ struct ieee80211_hw *hw = &sdata->local->hw; -+ -+ trace_api_disconnect(sdata, reconnect); -+ -+ if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) -+ return; -+ -+ sdata->u.mgd.driver_disconnect = true; -+ sdata->u.mgd.reconnect = reconnect; -+ ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); -+} -+EXPORT_SYMBOL(ieee80211_disconnect); - - static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, - bool assoc) -@@ -3135,7 +3164,7 @@ static void ieee80211_rx_mgmt_deauth(str - ieee80211_set_disassoc(sdata, 0, 0, false, NULL); - - ieee80211_report_disconnect(sdata, (u8 *)mgmt, len, false, -- reason_code); -+ reason_code, false); - return; - } - -@@ -3184,7 +3213,8 @@ static void ieee80211_rx_mgmt_disassoc(s - - ieee80211_set_disassoc(sdata, 0, 0, false, NULL); - -- ieee80211_report_disconnect(sdata, (u8 *)mgmt, len, false, reason_code); -+ ieee80211_report_disconnect(sdata, (u8 *)mgmt, len, false, reason_code, -+ false); - } - - static void ieee80211_get_rates(struct ieee80211_supported_band *sband, -@@ -4204,7 +4234,8 @@ static void ieee80211_rx_mgmt_beacon(str - true, deauth_buf); - ieee80211_report_disconnect(sdata, deauth_buf, - sizeof(deauth_buf), true, -- WLAN_REASON_DEAUTH_LEAVING); -+ WLAN_REASON_DEAUTH_LEAVING, -+ false); - return; - } - -@@ -4349,7 +4380,7 @@ static void ieee80211_sta_connection_los - tx, frame_buf); - - ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), true, -- reason); -+ reason, false); - } - - static int ieee80211_auth(struct ieee80211_sub_if_data *sdata) -@@ -5439,7 +5470,8 @@ int ieee80211_mgd_auth(struct ieee80211_ - - ieee80211_report_disconnect(sdata, frame_buf, - sizeof(frame_buf), true, -- WLAN_REASON_UNSPECIFIED); -+ WLAN_REASON_UNSPECIFIED, -+ false); - } - - sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid); -@@ -5511,7 +5543,8 @@ int ieee80211_mgd_assoc(struct ieee80211 - - ieee80211_report_disconnect(sdata, frame_buf, - sizeof(frame_buf), true, -- WLAN_REASON_UNSPECIFIED); -+ WLAN_REASON_UNSPECIFIED, -+ false); - } - - if (ifmgd->auth_data && !ifmgd->auth_data->done) { -@@ -5810,7 +5843,7 @@ int ieee80211_mgd_deauth(struct ieee8021 - ieee80211_destroy_auth_data(sdata, false); - ieee80211_report_disconnect(sdata, frame_buf, - sizeof(frame_buf), true, -- req->reason_code); -+ req->reason_code, false); - - return 0; - } -@@ -5830,7 +5863,7 @@ int ieee80211_mgd_deauth(struct ieee8021 - ieee80211_destroy_assoc_data(sdata, false, true); - ieee80211_report_disconnect(sdata, frame_buf, - sizeof(frame_buf), true, -- req->reason_code); -+ req->reason_code, false); - return 0; - } - -@@ -5845,7 +5878,7 @@ int ieee80211_mgd_deauth(struct ieee8021 - req->reason_code, tx, frame_buf); - ieee80211_report_disconnect(sdata, frame_buf, - sizeof(frame_buf), true, -- req->reason_code); -+ req->reason_code, false); - return 0; - } - -@@ -5878,7 +5911,7 @@ int ieee80211_mgd_disassoc(struct ieee80 - frame_buf); - - ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), true, -- req->reason_code); -+ req->reason_code, false); - - return 0; - } ---- a/net/mac80211/trace.h -+++ b/net/mac80211/trace.h -@@ -2,7 +2,7 @@ - /* - * Portions of this file - * Copyright(c) 2016-2017 Intel Deutschland GmbH --* Copyright (C) 2018 - 2019 Intel Corporation -+* Copyright (C) 2018 - 2020 Intel Corporation - */ - - #if !defined(__MAC80211_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ) -@@ -2086,6 +2086,27 @@ TRACE_EVENT(api_connection_loss, - ) - ); - -+TRACE_EVENT(api_disconnect, -+ TP_PROTO(struct ieee80211_sub_if_data *sdata, bool reconnect), -+ -+ TP_ARGS(sdata, reconnect), -+ -+ TP_STRUCT__entry( -+ VIF_ENTRY -+ __field(int, reconnect) -+ ), -+ -+ TP_fast_assign( -+ VIF_ASSIGN; -+ __entry->reconnect = reconnect; -+ ), -+ -+ TP_printk( -+ VIF_PR_FMT " reconnect:%d", -+ VIF_PR_ARG, __entry->reconnect -+ ) -+); -+ - TRACE_EVENT(api_cqm_rssi_notify, - TP_PROTO(struct ieee80211_sub_if_data *sdata, - enum nl80211_cqm_rssi_threshold_event rssi_event, diff --git a/package/kernel/mac80211/patches/subsys/302-cfg80211-Add-support-to-configure-SAE-PWE-value-to-d.patch b/package/kernel/mac80211/patches/subsys/302-cfg80211-Add-support-to-configure-SAE-PWE-value-to-d.patch deleted file mode 100644 index acfdae0f5b0..00000000000 --- a/package/kernel/mac80211/patches/subsys/302-cfg80211-Add-support-to-configure-SAE-PWE-value-to-d.patch +++ /dev/null @@ -1,74 +0,0 @@ -From: Rohan Dutta <drohan@codeaurora.org> -Date: Tue, 27 Oct 2020 12:09:10 +0200 -Subject: [PATCH] cfg80211: Add support to configure SAE PWE value to drivers - -Add support to configure SAE PWE preference from userspace to drivers in -both AP and STA modes. This is needed for cases where the driver takes -care of Authentication frame processing (SME in the driver) so that -correct enforcement of the acceptable PWE derivation mechanism can be -performed. - -The userspace applications can pass the sae_pwe value using the -NL80211_ATTR_SAE_PWE attribute in the NL80211_CMD_CONNECT and -NL80211_CMD_START_AP commands to the driver. This allows selection -between the hunting-and-pecking loop and hash-to-element options for PWE -derivation. For backwards compatibility, this new attribute is optional -and if not included, the driver is notified of the value being -unspecified. - -Signed-off-by: Rohan Dutta <drohan@codeaurora.org> -Signed-off-by: Jouni Malinen <jouni@codeaurora.org> -Link: https://lore.kernel.org/r/20201027100910.22283-1-jouni@codeaurora.org -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/cfg80211.h -+++ b/include/net/cfg80211.h -@@ -1009,6 +1009,14 @@ struct survey_info { - * @sae_pwd: password for SAE authentication (for devices supporting SAE - * offload) - * @sae_pwd_len: length of SAE password (for devices supporting SAE offload) -+ * @sae_pwe: The mechanisms allowed for SAE PWE derivation -+ * NL80211_SAE_PWE_UNSPECIFIED: Not-specified, used to indicate userspace -+ * did not specify any preference. The driver should follow its -+ * internal policy in such a scenario. -+ * NL80211_SAE_PWE_HUNT_AND_PECK: Allow hunting-and-pecking loop only -+ * NL80211_SAE_PWE_HASH_TO_ELEMENT: Allow hash-to-element only -+ * NL80211_SAE_PWE_BOTH: Allow either hunting-and-pecking loop -+ * or hash-to-element - */ - struct cfg80211_crypto_settings { - u32 wpa_versions; -@@ -1027,6 +1035,7 @@ struct cfg80211_crypto_settings { - const u8 *psk; - const u8 *sae_pwd; - u8 sae_pwd_len; -+ enum nl80211_sae_pwe_mechanism sae_pwe; - }; - - /** ---- a/net/wireless/nl80211.c -+++ b/net/wireless/nl80211.c -@@ -736,6 +736,9 @@ static const struct nla_policy nl80211_p - NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN), - [NL80211_ATTR_S1G_CAPABILITY_MASK] = - NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN), -+ [NL80211_ATTR_SAE_PWE] = -+ NLA_POLICY_RANGE(NLA_U8, NL80211_SAE_PWE_HUNT_AND_PECK, -+ NL80211_SAE_PWE_BOTH), - [NL80211_ATTR_RECONNECT_REQUESTED] = { .type = NLA_REJECT }, - }; - -@@ -9764,6 +9767,12 @@ static int nl80211_crypto_settings(struc - nla_len(info->attrs[NL80211_ATTR_SAE_PASSWORD]); - } - -+ if (info->attrs[NL80211_ATTR_SAE_PWE]) -+ settings->sae_pwe = -+ nla_get_u8(info->attrs[NL80211_ATTR_SAE_PWE]); -+ else -+ settings->sae_pwe = NL80211_SAE_PWE_UNSPECIFIED; -+ - return 0; - } - diff --git a/package/kernel/mac80211/patches/subsys/353-mac80211-minstrel_ht-fix-MINSTREL_FRAC-macro.patch b/package/kernel/mac80211/patches/subsys/302-mac80211-minstrel_ht-fix-MINSTREL_FRAC-macro.patch index 0d475b73297..0d475b73297 100644 --- a/package/kernel/mac80211/patches/subsys/353-mac80211-minstrel_ht-fix-MINSTREL_FRAC-macro.patch +++ b/package/kernel/mac80211/patches/subsys/302-mac80211-minstrel_ht-fix-MINSTREL_FRAC-macro.patch diff --git a/package/kernel/mac80211/patches/subsys/354-mac80211-minstrel_ht-reduce-fluctuations-in-rate-pro.patch b/package/kernel/mac80211/patches/subsys/303-mac80211-minstrel_ht-reduce-fluctuations-in-rate-pro.patch index 16bcbc2ef91..f26477e8112 100644 --- a/package/kernel/mac80211/patches/subsys/354-mac80211-minstrel_ht-reduce-fluctuations-in-rate-pro.patch +++ b/package/kernel/mac80211/patches/subsys/303-mac80211-minstrel_ht-reduce-fluctuations-in-rate-pro.patch @@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -700,7 +700,8 @@ minstrel_ht_calc_rate_stats(struct minst +@@ -769,7 +769,8 @@ minstrel_ht_calc_rate_stats(struct minst unsigned int cur_prob; if (unlikely(mrs->attempts > 0)) { diff --git a/package/kernel/mac80211/patches/subsys/355-mac80211-minstrel_ht-rework-rate-downgrade-code-and-.patch b/package/kernel/mac80211/patches/subsys/304-mac80211-minstrel_ht-rework-rate-downgrade-code-and-.patch index aec2e077812..9b3cc3a664a 100644 --- a/package/kernel/mac80211/patches/subsys/355-mac80211-minstrel_ht-rework-rate-downgrade-code-and-.patch +++ b/package/kernel/mac80211/patches/subsys/304-mac80211-minstrel_ht-rework-rate-downgrade-code-and-.patch @@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -511,6 +511,14 @@ minstrel_ht_set_best_prob_rate(struct mi +@@ -580,6 +580,14 @@ minstrel_ht_set_best_prob_rate(struct mi int cur_tp_avg, cur_group, cur_idx; int max_gpr_group, max_gpr_idx; int max_gpr_tp_avg, max_gpr_prob; @@ -33,7 +33,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> cur_group = MI_RATE_GROUP(index); cur_idx = MI_RATE_IDX(index); -@@ -532,11 +540,6 @@ minstrel_ht_set_best_prob_rate(struct mi +@@ -601,11 +609,6 @@ minstrel_ht_set_best_prob_rate(struct mi !minstrel_ht_is_legacy_group(max_tp_group)) return; @@ -45,7 +45,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> max_gpr_group = MI_RATE_GROUP(mg->max_group_prob_rate); max_gpr_idx = MI_RATE_IDX(mg->max_group_prob_rate); max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_avg; -@@ -594,40 +597,6 @@ minstrel_ht_assign_best_tp_rates(struct +@@ -663,40 +666,6 @@ minstrel_ht_assign_best_tp_rates(struct } @@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> - int tmp_max_streams, group, tmp_idx, tmp_prob; - int tmp_tp = 0; - -- if (!mi->sta->ht_cap.ht_supported) +- if (!mi->sta->deflink.ht_cap.ht_supported) - return; - - group = MI_RATE_GROUP(mi->max_tp_rate[0]); @@ -86,7 +86,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> static u16 __minstrel_ht_get_sample_rate(struct minstrel_ht_sta *mi, enum minstrel_sample_type type) -@@ -1111,8 +1080,6 @@ minstrel_ht_update_stats(struct minstrel +@@ -1176,8 +1145,6 @@ minstrel_ht_update_stats(struct minstrel mi->max_prob_rate = tmp_max_prob_rate; @@ -95,7 +95,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> minstrel_ht_refill_sample_rates(mi); #ifdef CPTCFG_MAC80211_DEBUGFS -@@ -1157,7 +1124,7 @@ minstrel_ht_txstat_valid(struct minstrel +@@ -1256,7 +1223,7 @@ minstrel_ht_ri_txstat_valid(struct minst } static void @@ -104,7 +104,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> { int group, orig_group; -@@ -1172,11 +1139,7 @@ minstrel_downgrade_rate(struct minstrel_ +@@ -1271,11 +1238,7 @@ minstrel_downgrade_rate(struct minstrel_ minstrel_mcs_groups[orig_group].streams) continue; @@ -117,7 +117,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> } } -@@ -1210,7 +1173,7 @@ minstrel_ht_tx_status(void *priv, struct +@@ -1286,7 +1249,7 @@ minstrel_ht_tx_status(void *priv, struct struct ieee80211_tx_info *info = st->info; struct minstrel_ht_sta *mi = priv_sta; struct ieee80211_tx_rate *ar = info->status.rates; @@ -126,7 +126,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> struct minstrel_priv *mp = priv; u32 update_interval = mp->update_interval; bool last, update = false; -@@ -1256,18 +1219,13 @@ minstrel_ht_tx_status(void *priv, struct +@@ -1354,18 +1317,13 @@ minstrel_ht_tx_status(void *priv, struct /* * check for sudden death of spatial multiplexing, * downgrade to a lower number of streams if necessary. diff --git a/package/kernel/mac80211/patches/subsys/305-mac80211-increase-quantum-for-airtime-scheduler.patch b/package/kernel/mac80211/patches/subsys/305-mac80211-increase-quantum-for-airtime-scheduler.patch new file mode 100644 index 00000000000..a27925e64ee --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/305-mac80211-increase-quantum-for-airtime-scheduler.patch @@ -0,0 +1,53 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sun, 26 Jun 2022 11:43:25 +0200 +Subject: [PATCH] mac80211: increase quantum for airtime scheduler + +Given the typical AQL budget and queue length, a quantum of 256 with the +default station weight often requires iterating over all queues frequently, +until one of them becomes eligible. +Improve performance by using 8 times station weight as scheduler quantum + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -92,6 +92,8 @@ extern const u8 ieee80211_ac_to_qos_mask + */ + #define AIRTIME_ACTIVE_DURATION (HZ / 10) + ++#define AIRTIME_QUANTUM_SHIFT 3 ++ + struct ieee80211_bss { + u32 device_ts_beacon, device_ts_presp; + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -4059,7 +4059,7 @@ struct ieee80211_txq *ieee80211_next_txq + + if (deficit < 0) + sta->airtime[txqi->txq.ac].deficit += +- sta->airtime_weight; ++ sta->airtime_weight << AIRTIME_QUANTUM_SHIFT; + + if (deficit < 0 || !aql_check) { + list_move_tail(&txqi->schedule_order, +@@ -4202,7 +4202,8 @@ bool ieee80211_txq_may_transmit(struct i + } + sta = container_of(iter->txq.sta, struct sta_info, sta); + if (ieee80211_sta_deficit(sta, ac) < 0) +- sta->airtime[ac].deficit += sta->airtime_weight; ++ sta->airtime[ac].deficit += sta->airtime_weight << ++ AIRTIME_QUANTUM_SHIFT; + list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); + } + +@@ -4210,7 +4211,7 @@ bool ieee80211_txq_may_transmit(struct i + if (sta->airtime[ac].deficit >= 0) + goto out; + +- sta->airtime[ac].deficit += sta->airtime_weight; ++ sta->airtime[ac].deficit += sta->airtime_weight << AIRTIME_QUANTUM_SHIFT; + list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); + spin_unlock_bh(&local->active_txq_lock[ac]); + diff --git a/package/kernel/mac80211/patches/subsys/310-mac80211-split-mesh-fast-tx-cache-into-local-proxied.patch b/package/kernel/mac80211/patches/subsys/310-mac80211-split-mesh-fast-tx-cache-into-local-proxied.patch new file mode 100644 index 00000000000..f362751e0a3 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/310-mac80211-split-mesh-fast-tx-cache-into-local-proxied.patch @@ -0,0 +1,219 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Fri, 30 Jun 2023 13:11:51 +0200 +Subject: [PATCH] mac80211: split mesh fast tx cache into + local/proxied/forwarded + +Depending on the origin of the packets (and their SA), 802.11 + mesh headers +could be filled in differently. In order to properly deal with that, add a +new field to the lookup key, indicating the type (local, proxied or +forwarded). This can fix spurious packet drop issues that depend on the order +in which nodes/hosts communicate with each other. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/mesh.c ++++ b/net/mac80211/mesh.c +@@ -765,6 +765,9 @@ bool ieee80211_mesh_xmit_fast(struct iee + struct sk_buff *skb, u32 ctrl_flags) + { + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; ++ struct ieee80211_mesh_fast_tx_key key = { ++ .type = MESH_FAST_TX_TYPE_LOCAL ++ }; + struct ieee80211_mesh_fast_tx *entry; + struct ieee80211s_hdr *meshhdr; + u8 sa[ETH_ALEN] __aligned(2); +@@ -800,7 +803,10 @@ bool ieee80211_mesh_xmit_fast(struct iee + return false; + } + +- entry = mesh_fast_tx_get(sdata, skb->data); ++ ether_addr_copy(key.addr, skb->data); ++ if (!ether_addr_equal(skb->data + ETH_ALEN, sdata->vif.addr)) ++ key.type = MESH_FAST_TX_TYPE_PROXIED; ++ entry = mesh_fast_tx_get(sdata, &key); + if (!entry) + return false; + +--- a/net/mac80211/mesh.h ++++ b/net/mac80211/mesh.h +@@ -134,9 +134,33 @@ struct mesh_path { + #define MESH_FAST_TX_CACHE_TIMEOUT 8000 /* msecs */ + + /** ++ * enum ieee80211_mesh_fast_tx_type - cached mesh fast tx entry type ++ * ++ * @MESH_FAST_TX_TYPE_LOCAL: tx from the local vif address as SA ++ * @MESH_FAST_TX_TYPE_PROXIED: local tx with a different SA (e.g. bridged) ++ * @MESH_FAST_TX_TYPE_FORWARDED: forwarded from a different mesh point ++ */ ++enum ieee80211_mesh_fast_tx_type { ++ MESH_FAST_TX_TYPE_LOCAL, ++ MESH_FAST_TX_TYPE_PROXIED, ++ MESH_FAST_TX_TYPE_FORWARDED, ++}; ++ ++/** ++ * struct ieee80211_mesh_fast_tx_key - cached mesh fast tx entry key ++ * ++ * @addr: The Ethernet DA for this entry ++ * @type: cache entry type ++ */ ++struct ieee80211_mesh_fast_tx_key { ++ u8 addr[ETH_ALEN] __aligned(2); ++ enum ieee80211_mesh_fast_tx_type type; ++}; ++ ++/** + * struct ieee80211_mesh_fast_tx - cached mesh fast tx entry + * @rhash: rhashtable pointer +- * @addr_key: The Ethernet DA which is the key for this entry ++ * @key: the lookup key for this cache entry + * @fast_tx: base fast_tx data + * @hdr: cached mesh and rfc1042 headers + * @hdrlen: length of mesh + rfc1042 +@@ -147,7 +171,7 @@ struct mesh_path { + */ + struct ieee80211_mesh_fast_tx { + struct rhash_head rhash; +- u8 addr_key[ETH_ALEN] __aligned(2); ++ struct ieee80211_mesh_fast_tx_key key; + + struct ieee80211_fast_tx fast_tx; + u8 hdr[sizeof(struct ieee80211s_hdr) + sizeof(rfc1042_header)]; +@@ -334,7 +358,8 @@ void mesh_path_tx_root_frame(struct ieee + + bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt); + struct ieee80211_mesh_fast_tx * +-mesh_fast_tx_get(struct ieee80211_sub_if_data *sdata, const u8 *addr); ++mesh_fast_tx_get(struct ieee80211_sub_if_data *sdata, ++ struct ieee80211_mesh_fast_tx_key *key); + bool ieee80211_mesh_xmit_fast(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u32 ctrl_flags); + void mesh_fast_tx_cache(struct ieee80211_sub_if_data *sdata, +--- a/net/mac80211/mesh_pathtbl.c ++++ b/net/mac80211/mesh_pathtbl.c +@@ -36,8 +36,8 @@ static const struct rhashtable_params me + static const struct rhashtable_params fast_tx_rht_params = { + .nelem_hint = 10, + .automatic_shrinking = true, +- .key_len = ETH_ALEN, +- .key_offset = offsetof(struct ieee80211_mesh_fast_tx, addr_key), ++ .key_len = sizeof(struct ieee80211_mesh_fast_tx_key), ++ .key_offset = offsetof(struct ieee80211_mesh_fast_tx, key), + .head_offset = offsetof(struct ieee80211_mesh_fast_tx, rhash), + .hashfn = mesh_table_hash, + }; +@@ -426,20 +426,21 @@ static void mesh_fast_tx_entry_free(stru + } + + struct ieee80211_mesh_fast_tx * +-mesh_fast_tx_get(struct ieee80211_sub_if_data *sdata, const u8 *addr) ++mesh_fast_tx_get(struct ieee80211_sub_if_data *sdata, ++ struct ieee80211_mesh_fast_tx_key *key) + { + struct ieee80211_mesh_fast_tx *entry; + struct mesh_tx_cache *cache; + + cache = &sdata->u.mesh.tx_cache; +- entry = rhashtable_lookup(&cache->rht, addr, fast_tx_rht_params); ++ entry = rhashtable_lookup(&cache->rht, key, fast_tx_rht_params); + if (!entry) + return NULL; + + if (!(entry->mpath->flags & MESH_PATH_ACTIVE) || + mpath_expired(entry->mpath)) { + spin_lock_bh(&cache->walk_lock); +- entry = rhashtable_lookup(&cache->rht, addr, fast_tx_rht_params); ++ entry = rhashtable_lookup(&cache->rht, key, fast_tx_rht_params); + if (entry) + mesh_fast_tx_entry_free(cache, entry); + spin_unlock_bh(&cache->walk_lock); +@@ -484,18 +485,24 @@ void mesh_fast_tx_cache(struct ieee80211 + if (!sta) + return; + ++ build.key.type = MESH_FAST_TX_TYPE_LOCAL; + if ((meshhdr->flags & MESH_FLAGS_AE) == MESH_FLAGS_AE_A5_A6) { + /* This is required to keep the mppath alive */ + mppath = mpp_path_lookup(sdata, meshhdr->eaddr1); + if (!mppath) + return; + build.mppath = mppath; ++ if (!ether_addr_equal(meshhdr->eaddr2, sdata->vif.addr)) ++ build.key.type = MESH_FAST_TX_TYPE_PROXIED; + } else if (ieee80211_has_a4(hdr->frame_control)) { + mppath = mpath; + } else { + return; + } + ++ if (!ether_addr_equal(hdr->addr4, sdata->vif.addr)) ++ build.key.type = MESH_FAST_TX_TYPE_FORWARDED; ++ + /* rate limit, in case fast xmit can't be enabled */ + if (mppath->fast_tx_check == jiffies) + return; +@@ -542,7 +549,7 @@ void mesh_fast_tx_cache(struct ieee80211 + } + } + +- memcpy(build.addr_key, mppath->dst, ETH_ALEN); ++ memcpy(build.key.addr, mppath->dst, ETH_ALEN); + build.timestamp = jiffies; + build.fast_tx.band = info->band; + build.fast_tx.da_offs = offsetof(struct ieee80211_hdr, addr3); +@@ -644,13 +651,19 @@ void mesh_fast_tx_flush_addr(struct ieee + const u8 *addr) + { + struct mesh_tx_cache *cache = &sdata->u.mesh.tx_cache; ++ struct ieee80211_mesh_fast_tx_key key = {}; + struct ieee80211_mesh_fast_tx *entry; ++ int i; + ++ ether_addr_copy(key.addr, addr); + cache = &sdata->u.mesh.tx_cache; + spin_lock_bh(&cache->walk_lock); +- entry = rhashtable_lookup(&cache->rht, addr, fast_tx_rht_params); +- if (entry) +- mesh_fast_tx_entry_free(cache, entry); ++ for (i = MESH_FAST_TX_TYPE_LOCAL; i < MESH_FAST_TX_TYPE_FORWARDED; i++) { ++ key.type = i; ++ entry = rhashtable_lookup(&cache->rht, &key, fast_tx_rht_params); ++ if (entry) ++ mesh_fast_tx_entry_free(cache, entry); ++ } + spin_unlock_bh(&cache->walk_lock); + } + +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -2727,7 +2727,10 @@ ieee80211_rx_mesh_fast_forward(struct ie + struct sk_buff *skb, int hdrlen) + { + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; +- struct ieee80211_mesh_fast_tx *entry = NULL; ++ struct ieee80211_mesh_fast_tx_key key = { ++ .type = MESH_FAST_TX_TYPE_FORWARDED ++ }; ++ struct ieee80211_mesh_fast_tx *entry; + struct ieee80211s_hdr *mesh_hdr; + struct tid_ampdu_tx *tid_tx; + struct sta_info *sta; +@@ -2736,9 +2739,13 @@ ieee80211_rx_mesh_fast_forward(struct ie + + mesh_hdr = (struct ieee80211s_hdr *)(skb->data + sizeof(eth)); + if ((mesh_hdr->flags & MESH_FLAGS_AE) == MESH_FLAGS_AE_A5_A6) +- entry = mesh_fast_tx_get(sdata, mesh_hdr->eaddr1); ++ ether_addr_copy(key.addr, mesh_hdr->eaddr1); + else if (!(mesh_hdr->flags & MESH_FLAGS_AE)) +- entry = mesh_fast_tx_get(sdata, skb->data); ++ ether_addr_copy(key.addr, skb->data); ++ else ++ return false; ++ ++ entry = mesh_fast_tx_get(sdata, &key); + if (!entry) + return false; + diff --git a/package/kernel/mac80211/patches/subsys/310-net-fq_impl-bulk-free-packets-from-a-flow-on-overmem.patch b/package/kernel/mac80211/patches/subsys/310-net-fq_impl-bulk-free-packets-from-a-flow-on-overmem.patch deleted file mode 100644 index 05a888006e2..00000000000 --- a/package/kernel/mac80211/patches/subsys/310-net-fq_impl-bulk-free-packets-from-a-flow-on-overmem.patch +++ /dev/null @@ -1,95 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Wed, 25 Nov 2020 18:03:46 +0100 -Subject: [PATCH] net/fq_impl: bulk-free packets from a flow on overmemory - -This is similar to what sch_fq_codel does. It also amortizes the worst -case cost of a follow-up patch that changes the selection of the biggest -flow for dropping packets - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/include/net/fq_impl.h -+++ b/include/net/fq_impl.h -@@ -11,17 +11,25 @@ - - /* functions that are embedded into includer */ - -+ -+static void -+__fq_adjust_removal(struct fq *fq, struct fq_flow *flow, unsigned int packets, -+ unsigned int bytes, unsigned int truesize) -+{ -+ struct fq_tin *tin = flow->tin; -+ -+ tin->backlog_bytes -= bytes; -+ tin->backlog_packets -= packets; -+ flow->backlog -= bytes; -+ fq->backlog -= packets; -+ fq->memory_usage -= truesize; -+} -+ - static void fq_adjust_removal(struct fq *fq, - struct fq_flow *flow, - struct sk_buff *skb) - { -- struct fq_tin *tin = flow->tin; -- -- tin->backlog_bytes -= skb->len; -- tin->backlog_packets--; -- flow->backlog -= skb->len; -- fq->backlog--; -- fq->memory_usage -= skb->truesize; -+ __fq_adjust_removal(fq, flow, 1, skb->len, skb->truesize); - } - - static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow) -@@ -59,6 +67,34 @@ static struct sk_buff *fq_flow_dequeue(s - return skb; - } - -+static int fq_flow_drop(struct fq *fq, struct fq_flow *flow, -+ fq_skb_free_t free_func) -+{ -+ unsigned int packets = 0, bytes = 0, truesize = 0; -+ struct fq_tin *tin = flow->tin; -+ struct sk_buff *skb; -+ int pending; -+ -+ lockdep_assert_held(&fq->lock); -+ -+ pending = min_t(int, 32, skb_queue_len(&flow->queue) / 2); -+ do { -+ skb = __skb_dequeue(&flow->queue); -+ if (!skb) -+ break; -+ -+ packets++; -+ bytes += skb->len; -+ truesize += skb->truesize; -+ free_func(fq, tin, flow, skb); -+ } while (packets < pending); -+ -+ __fq_adjust_removal(fq, flow, packets, bytes, truesize); -+ fq_rejigger_backlog(fq, flow); -+ -+ return packets; -+} -+ - static struct sk_buff *fq_tin_dequeue(struct fq *fq, - struct fq_tin *tin, - fq_tin_dequeue_t dequeue_func) -@@ -190,12 +226,9 @@ static void fq_tin_enqueue(struct fq *fq - if (!flow) - return; - -- skb = fq_flow_dequeue(fq, flow); -- if (!skb) -+ if (!fq_flow_drop(fq, flow, free_func)) - return; - -- free_func(fq, flow->tin, flow, skb); -- - flow->tin->overlimit++; - fq->overlimit++; - if (oom) { diff --git a/package/kernel/mac80211/patches/subsys/311-mac80211-fix-mesh-id-corruption-on-32-bit-systems.patch b/package/kernel/mac80211/patches/subsys/311-mac80211-fix-mesh-id-corruption-on-32-bit-systems.patch new file mode 100644 index 00000000000..c0c774a89d5 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/311-mac80211-fix-mesh-id-corruption-on-32-bit-systems.patch @@ -0,0 +1,62 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Tue, 12 Sep 2023 15:09:27 +0200 +Subject: [PATCH] mac80211: fix mesh id corruption on 32 bit systems +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since the changed field size was increased to u64, mesh_bss_info_changed +pulls invalid bits from the first 3 bytes of the mesh id, clears them, and +passes them on to ieee80211_link_info_change_notify, because +ifmsh->mbss_changed was not updated to match its size. +Fix this by turning into ifmsh->mbss_changed into an unsigned long array with +64 bit size. + +Fixes: 15ddba5f4311 ("wifi: mac80211: consistently use u64 for BSS changes") +Reported-by: Thomas Hühn <thomas.huehn@hs-nordhausen.de> +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -678,7 +678,7 @@ struct ieee80211_if_mesh { + struct timer_list mesh_path_root_timer; + + unsigned long wrkq_flags; +- unsigned long mbss_changed; ++ unsigned long mbss_changed[64 / BITS_PER_LONG]; + + bool userspace_handles_dfs; + +--- a/net/mac80211/mesh.c ++++ b/net/mac80211/mesh.c +@@ -1181,7 +1181,7 @@ void ieee80211_mbss_info_change_notify(s + + /* if we race with running work, worst case this work becomes a noop */ + for_each_set_bit(bit, &bits, sizeof(changed) * BITS_PER_BYTE) +- set_bit(bit, &ifmsh->mbss_changed); ++ set_bit(bit, ifmsh->mbss_changed); + set_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags); + wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); + } +@@ -1263,7 +1263,7 @@ void ieee80211_stop_mesh(struct ieee8021 + + /* clear any mesh work (for next join) we may have accrued */ + ifmsh->wrkq_flags = 0; +- ifmsh->mbss_changed = 0; ++ memset(ifmsh->mbss_changed, 0, sizeof(ifmsh->mbss_changed)); + + local->fif_other_bss--; + atomic_dec(&local->iff_allmultis); +@@ -1730,9 +1730,9 @@ static void mesh_bss_info_changed(struct + u32 bit; + u64 changed = 0; + +- for_each_set_bit(bit, &ifmsh->mbss_changed, ++ for_each_set_bit(bit, ifmsh->mbss_changed, + sizeof(changed) * BITS_PER_BYTE) { +- clear_bit(bit, &ifmsh->mbss_changed); ++ clear_bit(bit, ifmsh->mbss_changed); + changed |= BIT(bit); + } + diff --git a/package/kernel/mac80211/patches/subsys/311-net-fq_impl-drop-get_default_func-move-default-flow-.patch b/package/kernel/mac80211/patches/subsys/311-net-fq_impl-drop-get_default_func-move-default-flow-.patch deleted file mode 100644 index 33dbb5eb905..00000000000 --- a/package/kernel/mac80211/patches/subsys/311-net-fq_impl-drop-get_default_func-move-default-flow-.patch +++ /dev/null @@ -1,144 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Wed, 25 Nov 2020 18:09:10 +0100 -Subject: [PATCH] net/fq_impl: drop get_default_func, move default flow to - fq_tin - -Simplifies the code and prepares for a rework of scanning for flows on -overmemory drop. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/include/net/fq.h -+++ b/include/net/fq.h -@@ -47,6 +47,7 @@ struct fq_flow { - struct fq_tin { - struct list_head new_flows; - struct list_head old_flows; -+ struct fq_flow default_flow; - u32 backlog_bytes; - u32 backlog_packets; - u32 overlimit; ---- a/include/net/fq_impl.h -+++ b/include/net/fq_impl.h -@@ -151,8 +151,7 @@ static u32 fq_flow_idx(struct fq *fq, st - - static struct fq_flow *fq_flow_classify(struct fq *fq, - struct fq_tin *tin, u32 idx, -- struct sk_buff *skb, -- fq_flow_get_default_t get_default_func) -+ struct sk_buff *skb) - { - struct fq_flow *flow; - -@@ -160,7 +159,7 @@ static struct fq_flow *fq_flow_classify( - - flow = &fq->flows[idx]; - if (flow->tin && flow->tin != tin) { -- flow = get_default_func(fq, tin, idx, skb); -+ flow = &tin->default_flow; - tin->collisions++; - fq->collisions++; - } -@@ -192,15 +191,14 @@ static void fq_recalc_backlog(struct fq - static void fq_tin_enqueue(struct fq *fq, - struct fq_tin *tin, u32 idx, - struct sk_buff *skb, -- fq_skb_free_t free_func, -- fq_flow_get_default_t get_default_func) -+ fq_skb_free_t free_func) - { - struct fq_flow *flow; - bool oom; - - lockdep_assert_held(&fq->lock); - -- flow = fq_flow_classify(fq, tin, idx, skb, get_default_func); -+ flow = fq_flow_classify(fq, tin, idx, skb); - - flow->tin = tin; - flow->backlog += skb->len; -@@ -331,6 +329,7 @@ static void fq_tin_init(struct fq_tin *t - { - INIT_LIST_HEAD(&tin->new_flows); - INIT_LIST_HEAD(&tin->old_flows); -+ fq_flow_init(&tin->default_flow); - } - - static int fq_init(struct fq *fq, int flows_cnt) ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -846,7 +846,6 @@ enum txq_info_flags { - */ - struct txq_info { - struct fq_tin tin; -- struct fq_flow def_flow; - struct codel_vars def_cvars; - struct codel_stats cstats; - struct sk_buff_head frags; ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -1322,7 +1322,7 @@ static struct sk_buff *codel_dequeue_fun - fq = &local->fq; - - if (cvars == &txqi->def_cvars) -- flow = &txqi->def_flow; -+ flow = &txqi->tin.default_flow; - else - flow = &fq->flows[cvars - local->cvars]; - -@@ -1365,7 +1365,7 @@ static struct sk_buff *fq_tin_dequeue_fu - cparams = &local->cparams; - } - -- if (flow == &txqi->def_flow) -+ if (flow == &tin->default_flow) - cvars = &txqi->def_cvars; - else - cvars = &local->cvars[flow - fq->flows]; -@@ -1392,17 +1392,6 @@ static void fq_skb_free_func(struct fq * - ieee80211_free_txskb(&local->hw, skb); - } - --static struct fq_flow *fq_flow_get_default_func(struct fq *fq, -- struct fq_tin *tin, -- int idx, -- struct sk_buff *skb) --{ -- struct txq_info *txqi; -- -- txqi = container_of(tin, struct txq_info, tin); -- return &txqi->def_flow; --} -- - static void ieee80211_txq_enqueue(struct ieee80211_local *local, - struct txq_info *txqi, - struct sk_buff *skb) -@@ -1415,8 +1404,7 @@ static void ieee80211_txq_enqueue(struct - - spin_lock_bh(&fq->lock); - fq_tin_enqueue(fq, tin, flow_idx, skb, -- fq_skb_free_func, -- fq_flow_get_default_func); -+ fq_skb_free_func); - spin_unlock_bh(&fq->lock); - } - -@@ -1459,7 +1447,6 @@ void ieee80211_txq_init(struct ieee80211 - struct txq_info *txqi, int tid) - { - fq_tin_init(&txqi->tin); -- fq_flow_init(&txqi->def_flow); - codel_vars_init(&txqi->def_cvars); - codel_stats_init(&txqi->cstats); - __skb_queue_head_init(&txqi->frags); -@@ -3310,8 +3297,7 @@ static bool ieee80211_amsdu_aggregate(st - */ - - tin = &txqi->tin; -- flow = fq_flow_classify(fq, tin, flow_idx, skb, -- fq_flow_get_default_func); -+ flow = fq_flow_classify(fq, tin, flow_idx, skb); - head = skb_peek_tail(&flow->queue); - if (!head || skb_is_gso(head)) - goto out; diff --git a/package/kernel/mac80211/patches/subsys/312-net-fq_impl-do-not-maintain-a-backlog-sorted-list-of.patch b/package/kernel/mac80211/patches/subsys/312-net-fq_impl-do-not-maintain-a-backlog-sorted-list-of.patch deleted file mode 100644 index 08e5cbb5b90..00000000000 --- a/package/kernel/mac80211/patches/subsys/312-net-fq_impl-do-not-maintain-a-backlog-sorted-list-of.patch +++ /dev/null @@ -1,317 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Wed, 25 Nov 2020 18:10:34 +0100 -Subject: [PATCH] net/fq_impl: do not maintain a backlog-sorted list of - flows - -A sorted flow list is only needed to drop packets in the biggest flow when -hitting the overmemory condition. -By scanning flows only when needed, we can avoid paying the cost of -maintaining the list under normal conditions -In order to avoid scanning lots of empty flows and touching too many cold -cache lines, a bitmap of flows with backlog is maintained - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/include/net/fq.h -+++ b/include/net/fq.h -@@ -19,8 +19,6 @@ struct fq_tin; - * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++ - * (deficit round robin) based round robin queuing similar to the one - * found in net/sched/sch_fq_codel.c -- * @backlogchain: can be linked to other fq_flow and fq. Used to keep track of -- * fat flows and efficient head-dropping if packet limit is reached - * @queue: sk_buff queue to hold packets - * @backlog: number of bytes pending in the queue. The number of packets can be - * found in @queue.qlen -@@ -29,7 +27,6 @@ struct fq_tin; - struct fq_flow { - struct fq_tin *tin; - struct list_head flowchain; -- struct list_head backlogchain; - struct sk_buff_head queue; - u32 backlog; - int deficit; -@@ -47,6 +44,7 @@ struct fq_flow { - struct fq_tin { - struct list_head new_flows; - struct list_head old_flows; -+ struct list_head tin_list; - struct fq_flow default_flow; - u32 backlog_bytes; - u32 backlog_packets; -@@ -60,14 +58,14 @@ struct fq_tin { - /** - * struct fq - main container for fair queuing purposes - * -- * @backlogs: linked to fq_flows. Used to maintain fat flows for efficient -- * head-dropping when @backlog reaches @limit - * @limit: max number of packets that can be queued across all flows - * @backlog: number of packets queued across all flows - */ - struct fq { - struct fq_flow *flows; -- struct list_head backlogs; -+ unsigned long *flows_bitmap; -+ -+ struct list_head tin_backlog; - spinlock_t lock; - u32 flows_cnt; - u32 limit; ---- a/include/net/fq_impl.h -+++ b/include/net/fq_impl.h -@@ -17,12 +17,24 @@ __fq_adjust_removal(struct fq *fq, struc - unsigned int bytes, unsigned int truesize) - { - struct fq_tin *tin = flow->tin; -+ int idx; - - tin->backlog_bytes -= bytes; - tin->backlog_packets -= packets; - flow->backlog -= bytes; - fq->backlog -= packets; - fq->memory_usage -= truesize; -+ -+ if (flow->backlog) -+ return; -+ -+ if (flow == &tin->default_flow) { -+ list_del_init(&tin->tin_list); -+ return; -+ } -+ -+ idx = flow - fq->flows; -+ __clear_bit(idx, fq->flows_bitmap); - } - - static void fq_adjust_removal(struct fq *fq, -@@ -32,24 +44,6 @@ static void fq_adjust_removal(struct fq - __fq_adjust_removal(fq, flow, 1, skb->len, skb->truesize); - } - --static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow) --{ -- struct fq_flow *i; -- -- if (flow->backlog == 0) { -- list_del_init(&flow->backlogchain); -- } else { -- i = flow; -- -- list_for_each_entry_continue(i, &fq->backlogs, backlogchain) -- if (i->backlog < flow->backlog) -- break; -- -- list_move_tail(&flow->backlogchain, -- &i->backlogchain); -- } --} -- - static struct sk_buff *fq_flow_dequeue(struct fq *fq, - struct fq_flow *flow) - { -@@ -62,7 +56,6 @@ static struct sk_buff *fq_flow_dequeue(s - return NULL; - - fq_adjust_removal(fq, flow, skb); -- fq_rejigger_backlog(fq, flow); - - return skb; - } -@@ -90,7 +83,6 @@ static int fq_flow_drop(struct fq *fq, s - } while (packets < pending); - - __fq_adjust_removal(fq, flow, packets, bytes, truesize); -- fq_rejigger_backlog(fq, flow); - - return packets; - } -@@ -170,22 +162,36 @@ static struct fq_flow *fq_flow_classify( - return flow; - } - --static void fq_recalc_backlog(struct fq *fq, -- struct fq_tin *tin, -- struct fq_flow *flow) --{ -- struct fq_flow *i; -- -- if (list_empty(&flow->backlogchain)) -- list_add_tail(&flow->backlogchain, &fq->backlogs); -- -- i = flow; -- list_for_each_entry_continue_reverse(i, &fq->backlogs, -- backlogchain) -- if (i->backlog > flow->backlog) -- break; -+static struct fq_flow *fq_find_fattest_flow(struct fq *fq) -+{ -+ struct fq_tin *tin; -+ struct fq_flow *flow = NULL; -+ u32 len = 0; -+ int i; -+ -+ for_each_set_bit(i, fq->flows_bitmap, fq->flows_cnt) { -+ struct fq_flow *cur = &fq->flows[i]; -+ unsigned int cur_len; -+ -+ cur_len = cur->backlog; -+ if (cur_len <= len) -+ continue; -+ -+ flow = cur; -+ len = cur_len; -+ } - -- list_move(&flow->backlogchain, &i->backlogchain); -+ list_for_each_entry(tin, &fq->tin_backlog, tin_list) { -+ unsigned int cur_len = tin->default_flow.backlog; -+ -+ if (cur_len <= len) -+ continue; -+ -+ flow = &tin->default_flow; -+ len = cur_len; -+ } -+ -+ return flow; - } - - static void fq_tin_enqueue(struct fq *fq, -@@ -200,6 +206,13 @@ static void fq_tin_enqueue(struct fq *fq - - flow = fq_flow_classify(fq, tin, idx, skb); - -+ if (!flow->backlog) { -+ if (flow != &tin->default_flow) -+ __set_bit(idx, fq->flows_bitmap); -+ else if (list_empty(&tin->tin_list)) -+ list_add(&tin->tin_list, &fq->tin_backlog); -+ } -+ - flow->tin = tin; - flow->backlog += skb->len; - tin->backlog_bytes += skb->len; -@@ -207,8 +220,6 @@ static void fq_tin_enqueue(struct fq *fq - fq->memory_usage += skb->truesize; - fq->backlog++; - -- fq_recalc_backlog(fq, tin, flow); -- - if (list_empty(&flow->flowchain)) { - flow->deficit = fq->quantum; - list_add_tail(&flow->flowchain, -@@ -218,9 +229,7 @@ static void fq_tin_enqueue(struct fq *fq - __skb_queue_tail(&flow->queue, skb); - oom = (fq->memory_usage > fq->memory_limit); - while (fq->backlog > fq->limit || oom) { -- flow = list_first_entry_or_null(&fq->backlogs, -- struct fq_flow, -- backlogchain); -+ flow = fq_find_fattest_flow(fq); - if (!flow) - return; - -@@ -255,8 +264,6 @@ static void fq_flow_filter(struct fq *fq - fq_adjust_removal(fq, flow, skb); - free_func(fq, tin, flow, skb); - } -- -- fq_rejigger_backlog(fq, flow); - } - - static void fq_tin_filter(struct fq *fq, -@@ -279,16 +286,18 @@ static void fq_flow_reset(struct fq *fq, - struct fq_flow *flow, - fq_skb_free_t free_func) - { -+ struct fq_tin *tin = flow->tin; - struct sk_buff *skb; - - while ((skb = fq_flow_dequeue(fq, flow))) -- free_func(fq, flow->tin, flow, skb); -+ free_func(fq, tin, flow, skb); - -- if (!list_empty(&flow->flowchain)) -+ if (!list_empty(&flow->flowchain)) { - list_del_init(&flow->flowchain); -- -- if (!list_empty(&flow->backlogchain)) -- list_del_init(&flow->backlogchain); -+ if (list_empty(&tin->new_flows) && -+ list_empty(&tin->old_flows)) -+ list_del_init(&tin->tin_list); -+ } - - flow->tin = NULL; - -@@ -314,6 +323,7 @@ static void fq_tin_reset(struct fq *fq, - fq_flow_reset(fq, flow, free_func); - } - -+ WARN_ON_ONCE(!list_empty(&tin->tin_list)); - WARN_ON_ONCE(tin->backlog_bytes); - WARN_ON_ONCE(tin->backlog_packets); - } -@@ -321,7 +331,6 @@ static void fq_tin_reset(struct fq *fq, - static void fq_flow_init(struct fq_flow *flow) - { - INIT_LIST_HEAD(&flow->flowchain); -- INIT_LIST_HEAD(&flow->backlogchain); - __skb_queue_head_init(&flow->queue); - } - -@@ -329,6 +338,7 @@ static void fq_tin_init(struct fq_tin *t - { - INIT_LIST_HEAD(&tin->new_flows); - INIT_LIST_HEAD(&tin->old_flows); -+ INIT_LIST_HEAD(&tin->tin_list); - fq_flow_init(&tin->default_flow); - } - -@@ -337,8 +347,8 @@ static int fq_init(struct fq *fq, int fl - int i; - - memset(fq, 0, sizeof(fq[0])); -- INIT_LIST_HEAD(&fq->backlogs); - spin_lock_init(&fq->lock); -+ INIT_LIST_HEAD(&fq->tin_backlog); - fq->flows_cnt = max_t(u32, flows_cnt, 1); - fq->quantum = 300; - fq->limit = 8192; -@@ -348,6 +358,14 @@ static int fq_init(struct fq *fq, int fl - if (!fq->flows) - return -ENOMEM; - -+ fq->flows_bitmap = kcalloc(BITS_TO_LONGS(fq->flows_cnt), sizeof(long), -+ GFP_KERNEL); -+ if (!fq->flows_bitmap) { -+ kvfree(fq->flows); -+ fq->flows = NULL; -+ return -ENOMEM; -+ } -+ - for (i = 0; i < fq->flows_cnt; i++) - fq_flow_init(&fq->flows[i]); - -@@ -364,6 +382,9 @@ static void fq_reset(struct fq *fq, - - kvfree(fq->flows); - fq->flows = NULL; -+ -+ kfree(fq->flows_bitmap); -+ fq->flows_bitmap = NULL; - } - - #endif ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -3364,8 +3364,6 @@ out_recalc: - if (head->len != orig_len) { - flow->backlog += head->len - orig_len; - tin->backlog_bytes += head->len - orig_len; -- -- fq_recalc_backlog(fq, tin, flow); - } - out: - spin_unlock_bh(&fq->lock); diff --git a/package/kernel/mac80211/patches/subsys/312-wifi-cfg80211-annotate-iftype_data-pointer-with-spar.patch b/package/kernel/mac80211/patches/subsys/312-wifi-cfg80211-annotate-iftype_data-pointer-with-spar.patch new file mode 100644 index 00000000000..18420a80cf9 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/312-wifi-cfg80211-annotate-iftype_data-pointer-with-spar.patch @@ -0,0 +1,467 @@ +From: Johannes Berg <johannes.berg@intel.com> +Date: Mon, 28 Aug 2023 09:54:39 +0200 +Subject: [PATCH] wifi: cfg80211: annotate iftype_data pointer with sparse + +There were are a number of cases in mac80211 and iwlwifi (at +least) that used the sband->iftype_data pointer directly, +instead of using the accessors to find the right array entry +to use. + +Make sparse warn when such a thing is done. + +To not have a lot of casts, add two helper functions/macros + + - ieee80211_set_sband_iftype_data() + - for_each_sband_iftype_data() + +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +--- + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -5893,8 +5893,9 @@ static void ath11k_mac_setup_he_cap(stru + ar->mac.iftype[NL80211_BAND_2GHZ], + NL80211_BAND_2GHZ); + band = &ar->mac.sbands[NL80211_BAND_2GHZ]; +- band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ]; +- band->n_iftype_data = count; ++ _ieee80211_set_sband_iftype_data(band, ++ ar->mac.iftype[NL80211_BAND_2GHZ], ++ count); + } + + if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { +@@ -5902,8 +5903,9 @@ static void ath11k_mac_setup_he_cap(stru + ar->mac.iftype[NL80211_BAND_5GHZ], + NL80211_BAND_5GHZ); + band = &ar->mac.sbands[NL80211_BAND_5GHZ]; +- band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ]; +- band->n_iftype_data = count; ++ _ieee80211_set_sband_iftype_data(band, ++ ar->mac.iftype[NL80211_BAND_5GHZ], ++ count); + } + + if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && +@@ -5912,8 +5914,9 @@ static void ath11k_mac_setup_he_cap(stru + ar->mac.iftype[NL80211_BAND_6GHZ], + NL80211_BAND_6GHZ); + band = &ar->mac.sbands[NL80211_BAND_6GHZ]; +- band->iftype_data = ar->mac.iftype[NL80211_BAND_6GHZ]; +- band->n_iftype_data = count; ++ _ieee80211_set_sband_iftype_data(band, ++ ar->mac.iftype[NL80211_BAND_6GHZ], ++ count); + } + } + +--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c ++++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +@@ -1075,8 +1075,8 @@ static void iwl_init_he_hw_capab(struct + + memcpy(iftype_data, iwl_he_eht_capa, sizeof(iwl_he_eht_capa)); + +- sband->iftype_data = iftype_data; +- sband->n_iftype_data = ARRAY_SIZE(iwl_he_eht_capa); ++ _ieee80211_set_sband_iftype_data(sband, iftype_data, ++ ARRAY_SIZE(iwl_he_eht_capa)); + + for (i = 0; i < sband->n_iftype_data; i++) + iwl_nvm_fixup_sband_iftd(trans, data, sband, &iftype_data[i], +--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c ++++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c +@@ -1119,8 +1119,7 @@ void mt7915_set_stream_he_caps(struct mt + n = mt7915_init_he_caps(phy, NL80211_BAND_2GHZ, data); + + band = &phy->mt76->sband_2g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + } + + if (phy->mt76->cap.has_5ghz) { +@@ -1128,8 +1127,7 @@ void mt7915_set_stream_he_caps(struct mt + n = mt7915_init_he_caps(phy, NL80211_BAND_5GHZ, data); + + band = &phy->mt76->sband_5g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + } + + if (phy->mt76->cap.has_6ghz) { +@@ -1137,8 +1135,7 @@ void mt7915_set_stream_he_caps(struct mt + n = mt7915_init_he_caps(phy, NL80211_BAND_6GHZ, data); + + band = &phy->mt76->sband_6g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + } + } + +--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c ++++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c +@@ -196,8 +196,7 @@ void mt7921_set_stream_he_caps(struct mt + n = mt7921_init_he_caps(phy, NL80211_BAND_2GHZ, data); + + band = &phy->mt76->sband_2g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + } + + if (phy->mt76->cap.has_5ghz) { +@@ -205,16 +204,14 @@ void mt7921_set_stream_he_caps(struct mt + n = mt7921_init_he_caps(phy, NL80211_BAND_5GHZ, data); + + band = &phy->mt76->sband_5g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + + if (phy->mt76->cap.has_6ghz) { + data = phy->iftype[NL80211_BAND_6GHZ]; + n = mt7921_init_he_caps(phy, NL80211_BAND_6GHZ, data); + + band = &phy->mt76->sband_6g.sband; +- band->iftype_data = data; +- band->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(band, data, n); + } + } + } +--- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c ++++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c +@@ -823,8 +823,7 @@ __mt7996_set_stream_he_eht_caps(struct m + n++; + } + +- sband->iftype_data = data; +- sband->n_iftype_data = n; ++ _ieee80211_set_sband_iftype_data(sband, data, n); + } + + void mt7996_set_stream_he_eht_caps(struct mt7996_phy *phy) +--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c ++++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c +@@ -1335,7 +1335,7 @@ static int qtnf_cmd_band_fill_iftype(con + return -EINVAL; + } + +- kfree(band->iftype_data); ++ kfree((__force void *)band->iftype_data); + band->iftype_data = NULL; + band->n_iftype_data = tlv->n_iftype_data; + if (band->n_iftype_data == 0) +@@ -1347,7 +1347,8 @@ static int qtnf_cmd_band_fill_iftype(con + band->n_iftype_data = 0; + return -ENOMEM; + } +- band->iftype_data = iftype_data; ++ ++ _ieee80211_set_sband_iftype_data(band, iftype_data, tlv->n_iftype_data); + + for (i = 0; i < band->n_iftype_data; i++) + qtnf_cmd_conv_iftype(iftype_data++, &tlv->iftype_data[i]); +--- a/drivers/net/wireless/quantenna/qtnfmac/core.c ++++ b/drivers/net/wireless/quantenna/qtnfmac/core.c +@@ -549,7 +549,7 @@ static void qtnf_core_mac_detach(struct + if (!wiphy->bands[band]) + continue; + +- kfree(wiphy->bands[band]->iftype_data); ++ kfree((__force void *)wiphy->bands[band]->iftype_data); + wiphy->bands[band]->n_iftype_data = 0; + + kfree(wiphy->bands[band]->channels); +--- a/drivers/net/wireless/realtek/rtw89/core.c ++++ b/drivers/net/wireless/realtek/rtw89/core.c +@@ -3328,8 +3328,7 @@ static void rtw89_init_he_cap(struct rtw + idx++; + } + +- sband->iftype_data = iftype_data; +- sband->n_iftype_data = idx; ++ _ieee80211_set_sband_iftype_data(sband, iftype_data, idx); + } + + static int rtw89_core_set_supported_band(struct rtw89_dev *rtwdev) +@@ -3374,11 +3373,11 @@ err: + hw->wiphy->bands[NL80211_BAND_5GHZ] = NULL; + hw->wiphy->bands[NL80211_BAND_6GHZ] = NULL; + if (sband_2ghz) +- kfree(sband_2ghz->iftype_data); ++ kfree((__force void *)sband_2ghz->iftype_data); + if (sband_5ghz) +- kfree(sband_5ghz->iftype_data); ++ kfree((__force void *)sband_5ghz->iftype_data); + if (sband_6ghz) +- kfree(sband_6ghz->iftype_data); ++ kfree((__force void *)sband_6ghz->iftype_data); + kfree(sband_2ghz); + kfree(sband_5ghz); + kfree(sband_6ghz); +@@ -3390,11 +3389,11 @@ static void rtw89_core_clr_supported_ban + struct ieee80211_hw *hw = rtwdev->hw; + + if (hw->wiphy->bands[NL80211_BAND_2GHZ]) +- kfree(hw->wiphy->bands[NL80211_BAND_2GHZ]->iftype_data); ++ kfree((__force void *)hw->wiphy->bands[NL80211_BAND_2GHZ]->iftype_data); + if (hw->wiphy->bands[NL80211_BAND_5GHZ]) +- kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]->iftype_data); ++ kfree((__force void *)hw->wiphy->bands[NL80211_BAND_5GHZ]->iftype_data); + if (hw->wiphy->bands[NL80211_BAND_6GHZ]) +- kfree(hw->wiphy->bands[NL80211_BAND_6GHZ]->iftype_data); ++ kfree((__force void *)hw->wiphy->bands[NL80211_BAND_6GHZ]->iftype_data); + kfree(hw->wiphy->bands[NL80211_BAND_2GHZ]); + kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]); + kfree(hw->wiphy->bands[NL80211_BAND_6GHZ]); +--- a/drivers/net/wireless/realtek/rtw89/regd.c ++++ b/drivers/net/wireless/realtek/rtw89/regd.c +@@ -376,7 +376,7 @@ bottom: + return; + + wiphy->bands[NL80211_BAND_6GHZ] = NULL; +- kfree(sband->iftype_data); ++ kfree((__force void *)sband->iftype_data); + kfree(sband); + } + +--- a/drivers/net/wireless/virtual/mac80211_hwsim.c ++++ b/drivers/net/wireless/virtual/mac80211_hwsim.c +@@ -4900,25 +4900,19 @@ static const struct ieee80211_sband_ifty + + static void mac80211_hwsim_sband_capab(struct ieee80211_supported_band *sband) + { +- u16 n_iftype_data; +- +- if (sband->band == NL80211_BAND_2GHZ) { +- n_iftype_data = ARRAY_SIZE(sband_capa_2ghz); +- sband->iftype_data = +- (struct ieee80211_sband_iftype_data *)sband_capa_2ghz; +- } else if (sband->band == NL80211_BAND_5GHZ) { +- n_iftype_data = ARRAY_SIZE(sband_capa_5ghz); +- sband->iftype_data = +- (struct ieee80211_sband_iftype_data *)sband_capa_5ghz; +- } else if (sband->band == NL80211_BAND_6GHZ) { +- n_iftype_data = ARRAY_SIZE(sband_capa_6ghz); +- sband->iftype_data = +- (struct ieee80211_sband_iftype_data *)sband_capa_6ghz; +- } else { +- return; ++ switch (sband->band) { ++ case NL80211_BAND_2GHZ: ++ ieee80211_set_sband_iftype_data(sband, sband_capa_2ghz); ++ break; ++ case NL80211_BAND_5GHZ: ++ ieee80211_set_sband_iftype_data(sband, sband_capa_5ghz); ++ break; ++ case NL80211_BAND_6GHZ: ++ ieee80211_set_sband_iftype_data(sband, sband_capa_6ghz); ++ break; ++ default: ++ break; + } +- +- sband->n_iftype_data = n_iftype_data; + } + + #ifdef CPTCFG_MAC80211_MESH +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -415,6 +415,19 @@ struct ieee80211_sta_eht_cap { + u8 eht_ppe_thres[IEEE80211_EHT_PPE_THRES_MAX_LEN]; + }; + ++/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */ ++#ifdef __CHECKER__ ++/* ++ * This is used to mark the sband->iftype_data pointer which is supposed ++ * to be an array with special access semantics (per iftype), but a lot ++ * of code got it wrong in the past, so with this marking sparse will be ++ * noisy when the pointer is used directly. ++ */ ++# define __iftd __attribute__((noderef, address_space(__iftype_data))) ++#else ++# define __iftd ++#endif /* __CHECKER__ */ ++ + /** + * struct ieee80211_sband_iftype_data - sband data per interface type + * +@@ -548,10 +561,48 @@ struct ieee80211_supported_band { + struct ieee80211_sta_s1g_cap s1g_cap; + struct ieee80211_edmg edmg_cap; + u16 n_iftype_data; +- const struct ieee80211_sband_iftype_data *iftype_data; ++ const struct ieee80211_sband_iftype_data __iftd *iftype_data; + }; + + /** ++ * _ieee80211_set_sband_iftype_data - set sband iftype data array ++ * @sband: the sband to initialize ++ * @iftd: the iftype data array pointer ++ * @n_iftd: the length of the iftype data array ++ * ++ * Set the sband iftype data array; use this where the length cannot ++ * be derived from the ARRAY_SIZE() of the argument, but prefer ++ * ieee80211_set_sband_iftype_data() where it can be used. ++ */ ++static inline void ++_ieee80211_set_sband_iftype_data(struct ieee80211_supported_band *sband, ++ const struct ieee80211_sband_iftype_data *iftd, ++ u16 n_iftd) ++{ ++ sband->iftype_data = (const void __iftd __force *)iftd; ++ sband->n_iftype_data = n_iftd; ++} ++ ++/** ++ * ieee80211_set_sband_iftype_data - set sband iftype data array ++ * @sband: the sband to initialize ++ * @iftd: the iftype data array ++ */ ++#define ieee80211_set_sband_iftype_data(sband, iftd) \ ++ _ieee80211_set_sband_iftype_data(sband, iftd, ARRAY_SIZE(iftd)) ++ ++/** ++ * for_each_sband_iftype_data - iterate sband iftype data entries ++ * @sband: the sband whose iftype_data array to iterate ++ * @i: iterator counter ++ * @iftd: iftype data pointer to set ++ */ ++#define for_each_sband_iftype_data(sband, i, iftd) \ ++ for (i = 0, iftd = (const void __force *)&(sband)->iftype_data[i]; \ ++ i < (sband)->n_iftype_data; \ ++ i++, iftd = (const void __force *)&(sband)->iftype_data[i]) ++ ++/** + * ieee80211_get_sband_iftype_data - return sband data for a given iftype + * @sband: the sband to search for the STA on + * @iftype: enum nl80211_iftype +@@ -562,6 +613,7 @@ static inline const struct ieee80211_sba + ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband, + u8 iftype) + { ++ const struct ieee80211_sband_iftype_data *data; + int i; + + if (WARN_ON(iftype >= NL80211_IFTYPE_MAX)) +@@ -570,10 +622,7 @@ ieee80211_get_sband_iftype_data(const st + if (iftype == NL80211_IFTYPE_AP_VLAN) + iftype = NL80211_IFTYPE_AP; + +- for (i = 0; i < sband->n_iftype_data; i++) { +- const struct ieee80211_sband_iftype_data *data = +- &sband->iftype_data[i]; +- ++ for_each_sband_iftype_data(sband, i, data) { + if (data->types_mask & BIT(iftype)) + return data; + } +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -1055,6 +1055,7 @@ int ieee80211_register_hw(struct ieee802 + supp_he = false; + supp_eht = false; + for (band = 0; band < NUM_NL80211_BANDS; band++) { ++ const struct ieee80211_sband_iftype_data *iftd; + struct ieee80211_supported_band *sband; + + sband = local->hw.wiphy->bands[band]; +@@ -1101,11 +1102,7 @@ int ieee80211_register_hw(struct ieee802 + supp_ht = supp_ht || sband->ht_cap.ht_supported; + supp_vht = supp_vht || sband->vht_cap.vht_supported; + +- for (i = 0; i < sband->n_iftype_data; i++) { +- const struct ieee80211_sband_iftype_data *iftd; +- +- iftd = &sband->iftype_data[i]; +- ++ for_each_sband_iftype_data(sband, i, iftd) { + supp_he = supp_he || iftd->he_cap.has_he; + supp_eht = supp_eht || iftd->eht_cap.has_eht; + } +--- a/net/wireless/chan.c ++++ b/net/wireless/chan.c +@@ -6,7 +6,7 @@ + * + * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> + * Copyright 2013-2014 Intel Mobile Communications GmbH +- * Copyright 2018-2022 Intel Corporation ++ * Copyright 2018-2023 Intel Corporation + */ + + #include <linux/export.h> +@@ -1162,8 +1162,7 @@ bool cfg80211_chandef_usable(struct wiph + if (!sband) + return false; + +- for (i = 0; i < sband->n_iftype_data; i++) { +- iftd = &sband->iftype_data[i]; ++ for_each_sband_iftype_data(sband, i, iftd) { + if (!iftd->eht_cap.has_eht) + continue; + +--- a/net/wireless/core.c ++++ b/net/wireless/core.c +@@ -5,7 +5,7 @@ + * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> + * Copyright 2013-2014 Intel Mobile Communications GmbH + * Copyright 2015-2017 Intel Deutschland GmbH +- * Copyright (C) 2018-2022 Intel Corporation ++ * Copyright (C) 2018-2023 Intel Corporation + */ + + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +@@ -817,6 +817,7 @@ int wiphy_register(struct wiphy *wiphy) + + /* sanity check supported bands/channels */ + for (band = 0; band < NUM_NL80211_BANDS; band++) { ++ const struct ieee80211_sband_iftype_data *iftd; + u16 types = 0; + bool have_he = false; + +@@ -873,14 +874,11 @@ int wiphy_register(struct wiphy *wiphy) + return -EINVAL; + } + +- for (i = 0; i < sband->n_iftype_data; i++) { +- const struct ieee80211_sband_iftype_data *iftd; ++ for_each_sband_iftype_data(sband, i, iftd) { + bool has_ap, has_non_ap; + u32 ap_bits = BIT(NL80211_IFTYPE_AP) | + BIT(NL80211_IFTYPE_P2P_GO); + +- iftd = &sband->iftype_data[i]; +- + if (WARN_ON(!iftd->types_mask)) + return -EINVAL; + if (WARN_ON(types & iftd->types_mask)) +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -1906,20 +1906,20 @@ static int nl80211_send_band_rateinfo(st + struct nlattr *nl_iftype_data = + nla_nest_start_noflag(msg, + NL80211_BAND_ATTR_IFTYPE_DATA); ++ const struct ieee80211_sband_iftype_data *iftd; + int err; + + if (!nl_iftype_data) + return -ENOBUFS; + +- for (i = 0; i < sband->n_iftype_data; i++) { ++ for_each_sband_iftype_data(sband, i, iftd) { + struct nlattr *iftdata; + + iftdata = nla_nest_start_noflag(msg, i + 1); + if (!iftdata) + return -ENOBUFS; + +- err = nl80211_send_iftype_data(msg, sband, +- &sband->iftype_data[i]); ++ err = nl80211_send_iftype_data(msg, sband, iftd); + if (err) + return err; + diff --git a/package/kernel/mac80211/patches/subsys/313-wifi-cfg80211-export-DFS-CAC-time-and-usable-state-h.patch b/package/kernel/mac80211/patches/subsys/313-wifi-cfg80211-export-DFS-CAC-time-and-usable-state-h.patch new file mode 100644 index 00000000000..78ec030e18b --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/313-wifi-cfg80211-export-DFS-CAC-time-and-usable-state-h.patch @@ -0,0 +1,111 @@ +From 30ca8b0c4d6c9fb1d76e5894b1e8bf7c6a12224d Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh <quic_adisi@quicinc.com> +Date: Tue, 12 Sep 2023 10:48:55 +0530 +Subject: [PATCH] wifi: cfg80211: export DFS CAC time and usable state helper + functions + +cfg80211 has cfg80211_chandef_dfs_usable() function to know whether +at least one channel in the chandef is in usable state or not. Also, +cfg80211_chandef_dfs_cac_time() function is there which tells the CAC +time required for the given chandef. + +Make these two functions visible to drivers by exporting their symbol +to global list of kernel symbols. + +Lower level drivers can make use of these two functions to be aware +if CAC is required on the given chandef and for how long. For example +drivers which maintains the CAC state internally can make use of these. + +Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> +Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com> +Link: https://lore.kernel.org/r/20230912051857.2284-2-quic_adisi@quicinc.com +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +--- + include/net/cfg80211.h | 24 ++++++++++++++++++++++++ + net/wireless/chan.c | 2 ++ + net/wireless/core.h | 17 ----------------- + 3 files changed, 26 insertions(+), 17 deletions(-) + +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -1008,6 +1008,30 @@ int cfg80211_chandef_dfs_required(struct + enum nl80211_iftype iftype); + + /** ++ * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable and we ++ * can/need start CAC on such channel ++ * @wiphy: the wiphy to validate against ++ * @chandef: the channel definition to check ++ * ++ * Return: true if all channels available and at least ++ * one channel requires CAC (NL80211_DFS_USABLE) ++ */ ++bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy, ++ const struct cfg80211_chan_def *chandef); ++ ++/** ++ * cfg80211_chandef_dfs_cac_time - get the DFS CAC time (in ms) for given ++ * channel definition ++ * @wiphy: the wiphy to validate against ++ * @chandef: the channel definition to check ++ * ++ * Returns: DFS CAC time (in ms) which applies for this channel definition ++ */ ++unsigned int ++cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy, ++ const struct cfg80211_chan_def *chandef); ++ ++/** + * nl80211_send_chandef - sends the channel definition. + * @msg: the msg to send channel definition + * @chandef: the channel definition to check +--- a/net/wireless/chan.c ++++ b/net/wireless/chan.c +@@ -666,6 +666,7 @@ bool cfg80211_chandef_dfs_usable(struct + + return (r1 + r2 > 0); + } ++EXPORT_SYMBOL(cfg80211_chandef_dfs_usable); + + /* + * Checks if center frequency of chan falls with in the bandwidth +@@ -965,6 +966,7 @@ cfg80211_chandef_dfs_cac_time(struct wip + + return max(t1, t2); + } ++EXPORT_SYMBOL(cfg80211_chandef_dfs_cac_time); + + static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, + u32 center_freq, u32 bandwidth, +--- a/net/wireless/core.h ++++ b/net/wireless/core.h +@@ -469,29 +469,12 @@ int cfg80211_scan(struct cfg80211_regist + + extern struct work_struct cfg80211_disconnect_work; + +-/** +- * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable +- * @wiphy: the wiphy to validate against +- * @chandef: the channel definition to check +- * +- * Checks if chandef is usable and we can/need start CAC on such channel. +- * +- * Return: true if all channels available and at least +- * one channel requires CAC (NL80211_DFS_USABLE) +- */ +-bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy, +- const struct cfg80211_chan_def *chandef); +- + void cfg80211_set_dfs_state(struct wiphy *wiphy, + const struct cfg80211_chan_def *chandef, + enum nl80211_dfs_state dfs_state); + + void cfg80211_dfs_channels_update_work(struct work_struct *work); + +-unsigned int +-cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy, +- const struct cfg80211_chan_def *chandef); +- + void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev); + + int diff --git a/package/kernel/mac80211/patches/subsys/314-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch b/package/kernel/mac80211/patches/subsys/314-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch new file mode 100644 index 00000000000..191eb67e8ea --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/314-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch @@ -0,0 +1,34 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Wed, 3 Jan 2024 15:10:18 +0100 +Subject: [PATCH] wifi: mac80211: fix race condition on enabling fast-xmit + +fast-xmit must only be enabled after the sta has been uploaded to the driver, +otherwise it could end up passing the not-yet-uploaded sta via drv_tx calls +to the driver, leading to potential crashes because of uninitialized drv_priv +data. +Add a missing sta->uploaded check and re-check fast xmit after inserting a sta. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -911,6 +911,7 @@ static int sta_info_insert_finish(struct + + if (ieee80211_vif_is_mesh(&sdata->vif)) + mesh_accept_plinks_update(sdata); ++ ieee80211_check_fast_xmit(sta); + + return 0; + out_remove: +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3033,7 +3033,7 @@ void ieee80211_check_fast_xmit(struct st + sdata->vif.type == NL80211_IFTYPE_STATION) + goto out; + +- if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED)) ++ if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) + goto out; + + if (test_sta_flag(sta, WLAN_STA_PS_STA) || diff --git a/package/kernel/mac80211/patches/subsys/315-mac80211-add-rx-decapsulation-offload-support.patch b/package/kernel/mac80211/patches/subsys/315-mac80211-add-rx-decapsulation-offload-support.patch deleted file mode 100644 index b8bb2930f58..00000000000 --- a/package/kernel/mac80211/patches/subsys/315-mac80211-add-rx-decapsulation-offload-support.patch +++ /dev/null @@ -1,570 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Wed, 16 Dec 2020 21:34:03 +0100 -Subject: [PATCH] mac80211: add rx decapsulation offload support - -This allows drivers to pass 802.3 frames to mac80211, with some restrictions: - -- the skb must be passed with a valid sta -- fast-rx needs to be active for the sta -- monitor mode needs to be disabled - -mac80211 will tell the driver when it is safe to enable rx decap offload for -a particular station. - -In order to implement support, a driver must: - -- call ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD) -- implement ops->sta_set_decap_offload -- mark 802.3 frames with RX_FLAG_8023 - -If it doesn't want to enable offload for some vif types, it can mask out -IEEE80211_OFFLOAD_DECAP_ENABLED in vif->offload_flags from within the -.add_interface or .update_vif_offload driver ops - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -1297,6 +1297,8 @@ ieee80211_tx_info_clear_status(struct ie - * the "0-length PSDU" field included there. The value for it is - * in &struct ieee80211_rx_status. Note that if this value isn't - * known the frame shouldn't be reported. -+ * @RX_FLAG_8023: the frame has an 802.3 header (decap offload performed by -+ * hardware or driver) - */ - enum mac80211_rx_flags { - RX_FLAG_MMIC_ERROR = BIT(0), -@@ -1329,6 +1331,7 @@ enum mac80211_rx_flags { - RX_FLAG_RADIOTAP_HE_MU = BIT(27), - RX_FLAG_RADIOTAP_LSIG = BIT(28), - RX_FLAG_NO_PSDU = BIT(29), -+ RX_FLAG_8023 = BIT(30), - }; - - /** -@@ -1650,11 +1653,15 @@ enum ieee80211_vif_flags { - * 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 -+ * @IEEE80211_OFFLOAD_DECAP_ENABLED: rx encapsulation offload is enabled -+ * The driver supports passing received 802.11 frames as 802.3 frames to -+ * mac80211. - */ - - enum ieee80211_offload_flags { - IEEE80211_OFFLOAD_ENCAP_ENABLED = BIT(0), - IEEE80211_OFFLOAD_ENCAP_4ADDR = BIT(1), -+ IEEE80211_OFFLOAD_DECAP_ENABLED = BIT(2), - }; - - /** -@@ -2390,6 +2397,9 @@ struct ieee80211_txq { - * @IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD: Hardware supports tx encapsulation - * offload - * -+ * @IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD: Hardware supports rx decapsulation -+ * offload -+ * - * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays - */ - enum ieee80211_hw_flags { -@@ -2443,6 +2453,7 @@ enum ieee80211_hw_flags { - IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID, - IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT, - IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD, -+ IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD, - - /* keep last, obviously */ - NUM_IEEE80211_HW_FLAGS -@@ -4196,6 +4207,9 @@ struct ieee80211_ops { - struct ieee80211_vif *vif); - void (*sta_set_4addr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, bool enabled); -+ void (*sta_set_decap_offload)(struct ieee80211_hw *hw, -+ struct ieee80211_vif *vif, -+ struct ieee80211_sta *sta, bool enabled); - }; - - /** ---- a/net/mac80211/debugfs.c -+++ b/net/mac80211/debugfs.c -@@ -405,6 +405,7 @@ static const char *hw_flag_names[] = { - FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID), - FLAG(AMPDU_KEYBORDER_SUPPORT), - FLAG(SUPPORTS_TX_ENCAP_OFFLOAD), -+ FLAG(SUPPORTS_RX_DECAP_OFFLOAD), - #undef FLAG - }; - ---- a/net/mac80211/debugfs_sta.c -+++ b/net/mac80211/debugfs_sta.c -@@ -79,6 +79,7 @@ static const char * const sta_flag_names - FLAG(MPSP_RECIPIENT), - FLAG(PS_DELIVER), - FLAG(USES_ENCRYPTION), -+ FLAG(DECAP_OFFLOAD), - #undef FLAG - }; - ---- a/net/mac80211/driver-ops.h -+++ b/net/mac80211/driver-ops.h -@@ -1413,4 +1413,20 @@ static inline void drv_sta_set_4addr(str - trace_drv_return_void(local); - } - -+static inline void drv_sta_set_decap_offload(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_decap_offload(local, sdata, sta, enabled); -+ if (local->ops->sta_set_decap_offload) -+ local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta, -+ enabled); -+ trace_drv_return_void(local); -+} -+ - #endif /* __MAC80211_DRIVER_OPS */ ---- a/net/mac80211/iface.c -+++ b/net/mac80211/iface.c -@@ -835,7 +835,7 @@ static const struct net_device_ops ieee8 - - }; - --static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype) -+static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype) - { - switch (iftype) { - /* P2P GO and client are mapped to AP/STATION types */ -@@ -855,7 +855,7 @@ static bool ieee80211_set_sdata_offload_ - flags = sdata->vif.offload_flags; - - if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) && -- ieee80211_iftype_supports_encap_offload(sdata->vif.type)) { -+ ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) { - flags |= IEEE80211_OFFLOAD_ENCAP_ENABLED; - - if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG) && -@@ -868,10 +868,21 @@ static bool ieee80211_set_sdata_offload_ - flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; - } - -+ if (ieee80211_hw_check(&local->hw, SUPPORTS_RX_DECAP_OFFLOAD) && -+ ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) { -+ flags |= IEEE80211_OFFLOAD_DECAP_ENABLED; -+ -+ if (local->monitors) -+ flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; -+ } else { -+ flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; -+ } -+ - if (sdata->vif.offload_flags == flags) - return false; - - sdata->vif.offload_flags = flags; -+ ieee80211_check_fast_rx_iface(sdata); - return true; - } - -@@ -889,7 +900,7 @@ static void ieee80211_set_vif_encap_ops( - } - - if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) || -- !ieee80211_iftype_supports_encap_offload(bss->vif.type)) -+ !ieee80211_iftype_supports_hdr_offload(bss->vif.type)) - return; - - enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED; ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -4198,7 +4198,9 @@ void ieee80211_check_fast_rx(struct sta_ - .vif_type = sdata->vif.type, - .control_port_protocol = sdata->control_port_protocol, - }, *old, *new = NULL; -+ bool set_offload = false; - bool assign = false; -+ bool offload; - - /* use sparse to check that we don't return without updating */ - __acquire(check_fast_rx); -@@ -4311,6 +4313,17 @@ void ieee80211_check_fast_rx(struct sta_ - if (assign) - new = kmemdup(&fastrx, sizeof(fastrx), GFP_KERNEL); - -+ offload = assign && -+ (sdata->vif.offload_flags & IEEE80211_OFFLOAD_DECAP_ENABLED); -+ -+ if (offload) -+ set_offload = !test_and_set_sta_flag(sta, WLAN_STA_DECAP_OFFLOAD); -+ else -+ set_offload = test_and_clear_sta_flag(sta, WLAN_STA_DECAP_OFFLOAD); -+ -+ if (set_offload) -+ drv_sta_set_decap_offload(local, sdata, &sta->sta, assign); -+ - spin_lock_bh(&sta->lock); - old = rcu_dereference_protected(sta->fast_rx, true); - rcu_assign_pointer(sta->fast_rx, new); -@@ -4357,6 +4370,108 @@ void ieee80211_check_fast_rx_iface(struc - mutex_unlock(&local->sta_mtx); - } - -+static void ieee80211_rx_8023(struct ieee80211_rx_data *rx, -+ struct ieee80211_fast_rx *fast_rx, -+ int orig_len) -+{ -+ struct ieee80211_sta_rx_stats *stats; -+ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); -+ struct sta_info *sta = rx->sta; -+ struct sk_buff *skb = rx->skb; -+ void *sa = skb->data + ETH_ALEN; -+ void *da = skb->data; -+ -+ stats = &sta->rx_stats; -+ if (fast_rx->uses_rss) -+ stats = this_cpu_ptr(sta->pcpu_rx_stats); -+ -+ /* statistics part of ieee80211_rx_h_sta_process() */ -+ if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { -+ stats->last_signal = status->signal; -+ if (!fast_rx->uses_rss) -+ ewma_signal_add(&sta->rx_stats_avg.signal, -+ -status->signal); -+ } -+ -+ if (status->chains) { -+ int i; -+ -+ stats->chains = status->chains; -+ for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { -+ int signal = status->chain_signal[i]; -+ -+ if (!(status->chains & BIT(i))) -+ continue; -+ -+ stats->chain_signal_last[i] = signal; -+ if (!fast_rx->uses_rss) -+ ewma_signal_add(&sta->rx_stats_avg.chain_signal[i], -+ -signal); -+ } -+ } -+ /* end of statistics */ -+ -+ stats->last_rx = jiffies; -+ stats->last_rate = sta_stats_encode_rate(status); -+ -+ stats->fragments++; -+ stats->packets++; -+ -+ skb->dev = fast_rx->dev; -+ -+ ieee80211_rx_stats(fast_rx->dev, skb->len); -+ -+ /* The seqno index has the same property as needed -+ * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS -+ * for non-QoS-data frames. Here we know it's a data -+ * frame, so count MSDUs. -+ */ -+ u64_stats_update_begin(&stats->syncp); -+ stats->msdu[rx->seqno_idx]++; -+ stats->bytes += orig_len; -+ u64_stats_update_end(&stats->syncp); -+ -+ if (fast_rx->internal_forward) { -+ struct sk_buff *xmit_skb = NULL; -+ if (is_multicast_ether_addr(da)) { -+ xmit_skb = skb_copy(skb, GFP_ATOMIC); -+ } else if (!ether_addr_equal(da, sa) && -+ sta_info_get(rx->sdata, da)) { -+ xmit_skb = skb; -+ skb = NULL; -+ } -+ -+ if (xmit_skb) { -+ /* -+ * Send to wireless media and increase priority by 256 -+ * to keep the received priority instead of -+ * reclassifying the frame (see cfg80211_classify8021d). -+ */ -+ xmit_skb->priority += 256; -+ xmit_skb->protocol = htons(ETH_P_802_3); -+ skb_reset_network_header(xmit_skb); -+ skb_reset_mac_header(xmit_skb); -+ dev_queue_xmit(xmit_skb); -+ } -+ -+ if (!skb) -+ return; -+ } -+ -+ /* deliver to local stack */ -+ skb->protocol = eth_type_trans(skb, fast_rx->dev); -+ memset(skb->cb, 0, sizeof(skb->cb)); -+ if (rx->list) -+#if LINUX_VERSION_IS_GEQ(4,19,0) -+ list_add_tail(&skb->list, rx->list); -+#else -+ __skb_queue_tail(rx->list, skb); -+#endif -+ else -+ netif_receive_skb(skb); -+ -+} -+ - static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, - struct ieee80211_fast_rx *fast_rx) - { -@@ -4377,9 +4492,6 @@ static bool ieee80211_invoke_fast_rx(str - } addrs __aligned(2); - struct ieee80211_sta_rx_stats *stats = &sta->rx_stats; - -- if (fast_rx->uses_rss) -- stats = this_cpu_ptr(sta->pcpu_rx_stats); -- - /* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write - * to a common data structure; drivers can implement that per queue - * but we don't have that information in mac80211 -@@ -4453,32 +4565,6 @@ static bool ieee80211_invoke_fast_rx(str - pskb_trim(skb, skb->len - fast_rx->icv_len)) - goto drop; - -- /* statistics part of ieee80211_rx_h_sta_process() */ -- if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { -- stats->last_signal = status->signal; -- if (!fast_rx->uses_rss) -- ewma_signal_add(&sta->rx_stats_avg.signal, -- -status->signal); -- } -- -- if (status->chains) { -- int i; -- -- stats->chains = status->chains; -- for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { -- int signal = status->chain_signal[i]; -- -- if (!(status->chains & BIT(i))) -- continue; -- -- stats->chain_signal_last[i] = signal; -- if (!fast_rx->uses_rss) -- ewma_signal_add(&sta->rx_stats_avg.chain_signal[i], -- -signal); -- } -- } -- /* end of statistics */ -- - if (rx->key && !ieee80211_has_protected(hdr->frame_control)) - goto drop; - -@@ -4490,12 +4576,6 @@ static bool ieee80211_invoke_fast_rx(str - return true; - } - -- stats->last_rx = jiffies; -- stats->last_rate = sta_stats_encode_rate(status); -- -- stats->fragments++; -- stats->packets++; -- - /* do the header conversion - first grab the addresses */ - ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs); - ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs); -@@ -4504,62 +4584,14 @@ static bool ieee80211_invoke_fast_rx(str - /* push the addresses in front */ - memcpy(skb_push(skb, sizeof(addrs)), &addrs, sizeof(addrs)); - -- skb->dev = fast_rx->dev; -- -- ieee80211_rx_stats(fast_rx->dev, skb->len); -- -- /* The seqno index has the same property as needed -- * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS -- * for non-QoS-data frames. Here we know it's a data -- * frame, so count MSDUs. -- */ -- u64_stats_update_begin(&stats->syncp); -- stats->msdu[rx->seqno_idx]++; -- stats->bytes += orig_len; -- u64_stats_update_end(&stats->syncp); -- -- if (fast_rx->internal_forward) { -- struct sk_buff *xmit_skb = NULL; -- if (is_multicast_ether_addr(addrs.da)) { -- xmit_skb = skb_copy(skb, GFP_ATOMIC); -- } else if (!ether_addr_equal(addrs.da, addrs.sa) && -- sta_info_get(rx->sdata, addrs.da)) { -- xmit_skb = skb; -- skb = NULL; -- } -- -- if (xmit_skb) { -- /* -- * Send to wireless media and increase priority by 256 -- * to keep the received priority instead of -- * reclassifying the frame (see cfg80211_classify8021d). -- */ -- xmit_skb->priority += 256; -- xmit_skb->protocol = htons(ETH_P_802_3); -- skb_reset_network_header(xmit_skb); -- skb_reset_mac_header(xmit_skb); -- dev_queue_xmit(xmit_skb); -- } -- -- if (!skb) -- return true; -- } -- -- /* deliver to local stack */ -- skb->protocol = eth_type_trans(skb, fast_rx->dev); -- memset(skb->cb, 0, sizeof(skb->cb)); -- if (rx->list) --#if LINUX_VERSION_IS_GEQ(4,19,0) -- list_add_tail(&skb->list, rx->list); --#else -- __skb_queue_tail(rx->list, skb); --#endif -- else -- netif_receive_skb(skb); -+ ieee80211_rx_8023(rx, fast_rx, orig_len); - - return true; - drop: - dev_kfree_skb(skb); -+ if (fast_rx->uses_rss) -+ stats = this_cpu_ptr(sta->pcpu_rx_stats); -+ - stats->dropped++; - return true; - } -@@ -4613,6 +4645,47 @@ static bool ieee80211_prepare_and_rx_han - return true; - } - -+static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw, -+ struct ieee80211_sta *pubsta, -+ struct sk_buff *skb, -+#if LINUX_VERSION_IS_GEQ(4,19,0) -+ struct list_head *list) -+#else -+ struct sk_buff_head *list) -+#endif -+{ -+ struct ieee80211_local *local = hw_to_local(hw); -+ struct ieee80211_fast_rx *fast_rx; -+ struct ieee80211_rx_data rx; -+ -+ memset(&rx, 0, sizeof(rx)); -+ rx.skb = skb; -+ rx.local = local; -+ rx.list = list; -+ -+ I802_DEBUG_INC(local->dot11ReceivedFragmentCount); -+ -+ /* drop frame if too short for header */ -+ if (skb->len < sizeof(struct ethhdr)) -+ goto drop; -+ -+ if (!pubsta) -+ goto drop; -+ -+ rx.sta = container_of(pubsta, struct sta_info, sta); -+ rx.sdata = rx.sta->sdata; -+ -+ fast_rx = rcu_dereference(rx.sta->fast_rx); -+ if (!fast_rx) -+ goto drop; -+ -+ ieee80211_rx_8023(&rx, fast_rx, skb->len); -+ return; -+ -+drop: -+ dev_kfree_skb(skb); -+} -+ - /* - * This is the actual Rx frames handler. as it belongs to Rx path it must - * be called with rcu_read_lock protection. -@@ -4850,15 +4923,20 @@ void ieee80211_rx_list(struct ieee80211_ - * if it was previously present. - * Also, frames with less than 16 bytes are dropped. - */ -- skb = ieee80211_rx_monitor(local, skb, rate); -- if (!skb) -- return; -+ if (!(status->flag & RX_FLAG_8023)) { -+ skb = ieee80211_rx_monitor(local, skb, rate); -+ 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, list); -+ if (status->flag & RX_FLAG_8023) -+ __ieee80211_rx_handle_8023(hw, pubsta, skb, list); -+ else -+ __ieee80211_rx_handle_packet(hw, pubsta, skb, list); - - return; - drop: ---- a/net/mac80211/sta_info.h -+++ b/net/mac80211/sta_info.h -@@ -71,6 +71,7 @@ - * until pending frames are delivered - * @WLAN_STA_USES_ENCRYPTION: This station was configured for encryption, - * so drop all packets without a key later. -+ * @WLAN_STA_DECAP_OFFLOAD: This station uses rx decap offload - * - * @NUM_WLAN_STA_FLAGS: number of defined flags - */ -@@ -102,6 +103,7 @@ enum ieee80211_sta_info_flags { - WLAN_STA_MPSP_RECIPIENT, - WLAN_STA_PS_DELIVER, - WLAN_STA_USES_ENCRYPTION, -+ WLAN_STA_DECAP_OFFLOAD, - - NUM_WLAN_STA_FLAGS, - }; ---- a/net/mac80211/trace.h -+++ b/net/mac80211/trace.h -@@ -2761,7 +2761,7 @@ DEFINE_EVENT(local_sdata_addr_evt, drv_u - TP_ARGS(local, sdata) - ); - --TRACE_EVENT(drv_sta_set_4addr, -+DECLARE_EVENT_CLASS(sta_flag_evt, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - struct ieee80211_sta *sta, bool enabled), -@@ -2788,6 +2788,22 @@ TRACE_EVENT(drv_sta_set_4addr, - ) - ); - -+DEFINE_EVENT(sta_flag_evt, 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) -+); -+ -+DEFINE_EVENT(sta_flag_evt, drv_sta_set_decap_offload, -+ TP_PROTO(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata, -+ struct ieee80211_sta *sta, bool enabled), -+ -+ TP_ARGS(local, sdata, sta, enabled) -+); -+ - #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ - - #undef TRACE_INCLUDE_PATH diff --git a/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch b/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch deleted file mode 100644 index 4be011ffec0..00000000000 --- a/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch +++ /dev/null @@ -1,116 +0,0 @@ -From: Markus Theil <markus.theil@tu-ilmenau.de> -Date: Sat, 6 Feb 2021 12:51:12 +0100 -Subject: [PATCH] mac80211: enable QoS support for nl80211 ctrl port - -This patch unifies sending control port frames -over nl80211 and AF_PACKET sockets a little more. - -Before this patch, EAPOL frames got QoS prioritization -only when using AF_PACKET sockets. - -__ieee80211_select_queue only selects a QoS-enabled queue -for control port frames, when the control port protocol -is set correctly on the skb. For the AF_PACKET path this -works, but the nl80211 path used ETH_P_802_3. - -Another check for injected frames in wme.c then prevented -the QoS TID to be copied in the frame. - -In order to fix this, get rid of the frame injection marking -for nl80211 ctrl port and set the correct ethernet protocol. - -Please note: -An erlier version of this path tried to prevent -frame aggregation for control port frames in order to speed up -the initial connection setup a little. This seemed to cause -issues on my older Intel dvm-based hardware, and was therefore -removed again. Future commits which try to reintroduce this -have to check carefully how hw behaves with aggregated and -non-aggregated traffic for the same TID. -My NIC: Intel(R) Centrino(R) Ultimate-N 6300 AGN, REV=0x74 - -Reported-by: kernel test robot <lkp@intel.com> -Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de> -Link: https://lore.kernel.org/r/20210206115112.567881-1-markus.theil@tu-ilmenau.de -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/net/mac80211/status.c -+++ b/net/mac80211/status.c -@@ -628,16 +628,12 @@ static void ieee80211_report_ack_skb(str - u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie; - struct ieee80211_sub_if_data *sdata; - struct ieee80211_hdr *hdr = (void *)skb->data; -- __be16 ethertype = 0; -- -- if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3)) -- skb_copy_bits(skb, 2 * ETH_ALEN, ðertype, ETH_TLEN); - - rcu_read_lock(); - sdata = ieee80211_sdata_from_skb(local, skb); - if (sdata) { -- if (ethertype == sdata->control_port_protocol || -- ethertype == cpu_to_be16(ETH_P_PREAUTH)) -+ if (skb->protocol == sdata->control_port_protocol || -+ skb->protocol == cpu_to_be16(ETH_P_PREAUTH)) - cfg80211_control_port_tx_status(&sdata->wdev, - cookie, - skb->data, ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -1195,9 +1195,7 @@ ieee80211_tx_prepare(struct ieee80211_su - tx->sta = rcu_dereference(sdata->u.vlan.sta); - if (!tx->sta && sdata->wdev.use_4addr) - return TX_DROP; -- } else if (info->flags & (IEEE80211_TX_INTFL_NL80211_FRAME_TX | -- IEEE80211_TX_CTL_INJECTED) || -- tx->sdata->control_port_protocol == tx->skb->protocol) { -+ } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { - tx->sta = sta_info_get_bss(sdata, hdr->addr1); - } - if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) -@@ -5421,6 +5419,7 @@ int ieee80211_tx_control_port(struct wip - { - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); - struct ieee80211_local *local = sdata->local; -+ struct sta_info *sta; - struct sk_buff *skb; - struct ethhdr *ehdr; - u32 ctrl_flags = 0; -@@ -5443,8 +5442,7 @@ int ieee80211_tx_control_port(struct wip - if (cookie) - ctrl_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; - -- flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX | -- IEEE80211_TX_CTL_INJECTED; -+ flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX; - - skb = dev_alloc_skb(local->hw.extra_tx_headroom + - sizeof(struct ethhdr) + len); -@@ -5461,10 +5459,25 @@ int ieee80211_tx_control_port(struct wip - ehdr->h_proto = proto; - - skb->dev = dev; -- skb->protocol = htons(ETH_P_802_3); -+ skb->protocol = proto; - skb_reset_network_header(skb); - skb_reset_mac_header(skb); - -+ /* update QoS header to prioritize control port frames if possible, -+ * priorization also happens for control port frames send over -+ * AF_PACKET -+ */ -+ rcu_read_lock(); -+ -+ if (ieee80211_lookup_ra_sta(sdata, skb, &sta) == 0 && !IS_ERR(sta)) { -+ u16 queue = __ieee80211_select_queue(sdata, sta, skb); -+ -+ skb_set_queue_mapping(skb, queue); -+ skb_get_hash(skb); -+ } -+ -+ rcu_read_unlock(); -+ - /* mutex lock is only needed for incrementing the cookie counter */ - mutex_lock(&local->mtx); - diff --git a/package/kernel/mac80211/patches/subsys/320-cfg80211-allow-grace-period-for-DFS-available-after-.patch b/package/kernel/mac80211/patches/subsys/320-cfg80211-allow-grace-period-for-DFS-available-after-.patch new file mode 100644 index 00000000000..28e2144f7f5 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/320-cfg80211-allow-grace-period-for-DFS-available-after-.patch @@ -0,0 +1,149 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Thu, 14 Sep 2023 13:17:16 +0200 +Subject: [PATCH] cfg80211: allow grace period for DFS available after beacon + shutdown + +Fixes reconfiguring an AP on a DFS channel in non-ETSI regdomain + +Fixes: b35a51c7dd25 ("cfg80211: Make pre-CAC results valid only for ETSI domain") +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -175,6 +175,8 @@ enum ieee80211_channel_flags { + * @dfs_state: current state of this channel. Only relevant if radar is required + * on this channel. + * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered. ++ * @dfs_state_last_available: timestamp (jiffies) of the last time when the ++ * channel was available. + * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels. + */ + struct ieee80211_channel { +@@ -191,6 +193,7 @@ struct ieee80211_channel { + int orig_mag, orig_mpwr; + enum nl80211_dfs_state dfs_state; + unsigned long dfs_state_entered; ++ unsigned long dfs_state_last_available; + unsigned int dfs_cac_ms; + }; + +--- a/net/wireless/ap.c ++++ b/net/wireless/ap.c +@@ -30,6 +30,9 @@ static int ___cfg80211_stop_ap(struct cf + if (!wdev->links[link_id].ap.beacon_interval) + return -ENOENT; + ++ cfg80211_update_last_available(wdev->wiphy, ++ &wdev->links[link_id].ap.chandef); ++ + err = rdev_stop_ap(rdev, dev, link_id); + if (!err) { + wdev->conn_owner_nlportid = 0; +@@ -41,9 +44,6 @@ static int ___cfg80211_stop_ap(struct cf + if (notify) + nl80211_send_ap_stopped(wdev, link_id); + +- /* Should we apply the grace period during beaconing interface +- * shutdown also? +- */ + cfg80211_sched_dfs_chan_update(rdev); + } + +--- a/net/wireless/chan.c ++++ b/net/wireless/chan.c +@@ -461,6 +461,8 @@ static void cfg80211_set_chans_dfs_state + + c->dfs_state = dfs_state; + c->dfs_state_entered = jiffies; ++ if (dfs_state == NL80211_DFS_AVAILABLE) ++ c->dfs_state_last_available = jiffies; + } + } + +@@ -874,6 +876,49 @@ static bool cfg80211_get_chans_dfs_avail + return true; + } + ++static void ++__cfg80211_update_last_available(struct wiphy *wiphy, ++ u32 center_freq, ++ u32 bandwidth) ++{ ++ struct ieee80211_channel *c; ++ u32 freq, start_freq, end_freq; ++ ++ start_freq = cfg80211_get_start_freq(center_freq, bandwidth); ++ end_freq = cfg80211_get_end_freq(center_freq, bandwidth); ++ ++ /* ++ * Check entire range of channels for the bandwidth. ++ * If any channel in between is disabled or has not ++ * had gone through CAC return false ++ */ ++ for (freq = start_freq; freq <= end_freq; freq += MHZ_TO_KHZ(20)) { ++ c = ieee80211_get_channel_khz(wiphy, freq); ++ if (!c) ++ return; ++ ++ c->dfs_state_last_available = jiffies; ++ } ++} ++ ++void cfg80211_update_last_available(struct wiphy *wiphy, ++ const struct cfg80211_chan_def *chandef) ++{ ++ int width; ++ ++ width = cfg80211_chandef_get_width(chandef); ++ if (width < 0) ++ return; ++ ++ __cfg80211_update_last_available(wiphy, MHZ_TO_KHZ(chandef->center_freq1), ++ width); ++ if (chandef->width != NL80211_CHAN_WIDTH_80P80) ++ return; ++ ++ __cfg80211_update_last_available(wiphy, MHZ_TO_KHZ(chandef->center_freq2), ++ width); ++} ++ + static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy, + const struct cfg80211_chan_def *chandef) + { +--- a/net/wireless/core.h ++++ b/net/wireless/core.h +@@ -474,6 +474,8 @@ void cfg80211_set_dfs_state(struct wiphy + enum nl80211_dfs_state dfs_state); + + void cfg80211_dfs_channels_update_work(struct work_struct *work); ++void cfg80211_update_last_available(struct wiphy *wiphy, ++ const struct cfg80211_chan_def *chandef); + + void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev); + +--- a/net/wireless/mlme.c ++++ b/net/wireless/mlme.c +@@ -915,6 +915,8 @@ void cfg80211_dfs_channels_update_work(s + if (c->dfs_state == NL80211_DFS_UNAVAILABLE) { + time_dfs_update = IEEE80211_DFS_MIN_NOP_TIME_MS; + radar_event = NL80211_RADAR_NOP_FINISHED; ++ timeout = c->dfs_state_entered + ++ msecs_to_jiffies(time_dfs_update); + } else { + if (regulatory_pre_cac_allowed(wiphy) || + cfg80211_any_wiphy_oper_chan(wiphy, c)) +@@ -922,11 +924,10 @@ void cfg80211_dfs_channels_update_work(s + + time_dfs_update = REG_PRE_CAC_EXPIRY_GRACE_MS; + radar_event = NL80211_RADAR_PRE_CAC_EXPIRED; ++ timeout = c->dfs_state_last_available + ++ msecs_to_jiffies(time_dfs_update); + } + +- timeout = c->dfs_state_entered + +- msecs_to_jiffies(time_dfs_update); +- + if (time_after_eq(jiffies, timeout)) { + c->dfs_state = NL80211_DFS_USABLE; + c->dfs_state_entered = jiffies; diff --git a/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch b/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch deleted file mode 100644 index a7c09f00bc4..00000000000 --- a/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch +++ /dev/null @@ -1,123 +0,0 @@ -From: Ramon Fontes <ramonreisfontes@gmail.com> -Date: Sun, 27 Dec 2020 00:11:55 -0300 -Subject: [PATCH] mac80211_hwsim: add 6GHz channels - -Advertise 6GHz channels to mac80211. - -Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com> -Link: https://lore.kernel.org/r/20201227031155.81161-1-ramonreisfontes@gmail.com -[reword commit message] -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/drivers/net/wireless/mac80211_hwsim.c -+++ b/drivers/net/wireless/mac80211_hwsim.c -@@ -311,6 +311,12 @@ static struct net_device *hwsim_mon; /* - .hw_value = (_freq), \ - } - -+#define CHAN6G(_freq) { \ -+ .band = NL80211_BAND_6GHZ, \ -+ .center_freq = (_freq), \ -+ .hw_value = (_freq), \ -+} -+ - static const struct ieee80211_channel hwsim_channels_2ghz[] = { - CHAN2G(2412), /* Channel 1 */ - CHAN2G(2417), /* Channel 2 */ -@@ -377,6 +383,68 @@ static const struct ieee80211_channel hw - CHAN5G(5925), /* Channel 185 */ - }; - -+static const struct ieee80211_channel hwsim_channels_6ghz[] = { -+ CHAN6G(5955), /* Channel 1 */ -+ CHAN6G(5975), /* Channel 5 */ -+ CHAN6G(5995), /* Channel 9 */ -+ CHAN6G(6015), /* Channel 13 */ -+ CHAN6G(6035), /* Channel 17 */ -+ CHAN6G(6055), /* Channel 21 */ -+ CHAN6G(6075), /* Channel 25 */ -+ CHAN6G(6095), /* Channel 29 */ -+ CHAN6G(6115), /* Channel 33 */ -+ CHAN6G(6135), /* Channel 37 */ -+ CHAN6G(6155), /* Channel 41 */ -+ CHAN6G(6175), /* Channel 45 */ -+ CHAN6G(6195), /* Channel 49 */ -+ CHAN6G(6215), /* Channel 53 */ -+ CHAN6G(6235), /* Channel 57 */ -+ CHAN6G(6255), /* Channel 61 */ -+ CHAN6G(6275), /* Channel 65 */ -+ CHAN6G(6295), /* Channel 69 */ -+ CHAN6G(6315), /* Channel 73 */ -+ CHAN6G(6335), /* Channel 77 */ -+ CHAN6G(6355), /* Channel 81 */ -+ CHAN6G(6375), /* Channel 85 */ -+ CHAN6G(6395), /* Channel 89 */ -+ CHAN6G(6415), /* Channel 93 */ -+ CHAN6G(6435), /* Channel 97 */ -+ CHAN6G(6455), /* Channel 181 */ -+ CHAN6G(6475), /* Channel 105 */ -+ CHAN6G(6495), /* Channel 109 */ -+ CHAN6G(6515), /* Channel 113 */ -+ CHAN6G(6535), /* Channel 117 */ -+ CHAN6G(6555), /* Channel 121 */ -+ CHAN6G(6575), /* Channel 125 */ -+ CHAN6G(6595), /* Channel 129 */ -+ CHAN6G(6615), /* Channel 133 */ -+ CHAN6G(6635), /* Channel 137 */ -+ CHAN6G(6655), /* Channel 141 */ -+ CHAN6G(6675), /* Channel 145 */ -+ CHAN6G(6695), /* Channel 149 */ -+ CHAN6G(6715), /* Channel 153 */ -+ CHAN6G(6735), /* Channel 157 */ -+ CHAN6G(6755), /* Channel 161 */ -+ CHAN6G(6775), /* Channel 165 */ -+ CHAN6G(6795), /* Channel 169 */ -+ CHAN6G(6815), /* Channel 173 */ -+ CHAN6G(6835), /* Channel 177 */ -+ CHAN6G(6855), /* Channel 181 */ -+ CHAN6G(6875), /* Channel 185 */ -+ CHAN6G(6895), /* Channel 189 */ -+ CHAN6G(6915), /* Channel 193 */ -+ CHAN6G(6935), /* Channel 197 */ -+ CHAN6G(6955), /* Channel 201 */ -+ CHAN6G(6975), /* Channel 205 */ -+ CHAN6G(6995), /* Channel 209 */ -+ CHAN6G(7015), /* Channel 213 */ -+ CHAN6G(7035), /* Channel 217 */ -+ CHAN6G(7055), /* Channel 221 */ -+ CHAN6G(7075), /* Channel 225 */ -+ CHAN6G(7095), /* Channel 229 */ -+ CHAN6G(7115), /* Channel 233 */ -+}; -+ - #define NUM_S1G_CHANS_US 51 - static struct ieee80211_channel hwsim_channels_s1g[NUM_S1G_CHANS_US]; - -@@ -548,6 +616,7 @@ struct mac80211_hwsim_data { - struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; - struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; - struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; -+ struct ieee80211_channel channels_6ghz[ARRAY_SIZE(hwsim_channels_6ghz)]; - struct ieee80211_channel channels_s1g[ARRAY_SIZE(hwsim_channels_s1g)]; - struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; - struct ieee80211_iface_combination if_combination; -@@ -578,7 +647,8 @@ struct mac80211_hwsim_data { - struct ieee80211_channel *channel; - unsigned long next_start, start, end; - } survey_data[ARRAY_SIZE(hwsim_channels_2ghz) + -- ARRAY_SIZE(hwsim_channels_5ghz)]; -+ ARRAY_SIZE(hwsim_channels_5ghz) + -+ ARRAY_SIZE(hwsim_channels_6ghz)]; - - struct ieee80211_channel *channel; - u64 beacon_int /* beacon interval in us */; -@@ -3149,6 +3219,8 @@ static int mac80211_hwsim_new_radio(stru - sizeof(hwsim_channels_2ghz)); - memcpy(data->channels_5ghz, hwsim_channels_5ghz, - sizeof(hwsim_channels_5ghz)); -+ memcpy(data->channels_6ghz, hwsim_channels_6ghz, -+ sizeof(hwsim_channels_6ghz)); - memcpy(data->channels_s1g, hwsim_channels_s1g, - sizeof(hwsim_channels_s1g)); - memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); diff --git a/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch b/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch deleted file mode 100644 index 4bac10eefe7..00000000000 --- a/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch +++ /dev/null @@ -1,74 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Mon, 24 May 2021 11:46:09 +0200 -Subject: [PATCH] mac80211_hwsim: make 6 GHz channels usable - -The previous commit that claimed to add 6 GHz channels didn't actually make -them usable, since the 6 GHz band was not registered with mac80211. - -Fixes: 28881922abd7 ("mac80211_hwsim: add 6GHz channels") -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/drivers/net/wireless/mac80211_hwsim.c -+++ b/drivers/net/wireless/mac80211_hwsim.c -@@ -2968,15 +2968,19 @@ static void mac80211_hwsim_he_capab(stru - { - u16 n_iftype_data; - -- if (sband->band == NL80211_BAND_2GHZ) { -+ switch (sband->band) { -+ case NL80211_BAND_2GHZ: - n_iftype_data = ARRAY_SIZE(he_capa_2ghz); - sband->iftype_data = - (struct ieee80211_sband_iftype_data *)he_capa_2ghz; -- } else if (sband->band == NL80211_BAND_5GHZ) { -+ break; -+ case NL80211_BAND_5GHZ: -+ case NL80211_BAND_6GHZ: - n_iftype_data = ARRAY_SIZE(he_capa_5ghz); - sband->iftype_data = - (struct ieee80211_sband_iftype_data *)he_capa_5ghz; -- } else { -+ break; -+ default: - return; - } - -@@ -3265,6 +3269,12 @@ static int mac80211_hwsim_new_radio(stru - sband->vht_cap.vht_mcs.tx_mcs_map = - sband->vht_cap.vht_mcs.rx_mcs_map; - break; -+ case NL80211_BAND_6GHZ: -+ sband->channels = data->channels_6ghz; -+ sband->n_channels = ARRAY_SIZE(hwsim_channels_6ghz); -+ sband->bitrates = data->rates + 4; -+ sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; -+ break; - case NL80211_BAND_S1GHZ: - memcpy(&sband->s1g_cap, &hwsim_s1g_cap, - sizeof(sband->s1g_cap)); -@@ -3275,6 +3285,13 @@ static int mac80211_hwsim_new_radio(stru - continue; - } - -+ mac80211_hwsim_he_capab(sband); -+ -+ hw->wiphy->bands[band] = sband; -+ -+ if (band == NL80211_BAND_6GHZ) -+ continue; -+ - sband->ht_cap.ht_supported = true; - sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | - IEEE80211_HT_CAP_GRN_FLD | -@@ -3288,10 +3305,6 @@ static int mac80211_hwsim_new_radio(stru - sband->ht_cap.mcs.rx_mask[0] = 0xff; - sband->ht_cap.mcs.rx_mask[1] = 0xff; - sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; -- -- mac80211_hwsim_he_capab(sband); -- -- hw->wiphy->bands[band] = sband; - } - - /* By default all radios belong to the first group */ diff --git a/package/kernel/mac80211/patches/subsys/337-mac80211-minstrel_ht-clean-up-CCK-code.patch b/package/kernel/mac80211/patches/subsys/337-mac80211-minstrel_ht-clean-up-CCK-code.patch deleted file mode 100644 index f667d2c94e5..00000000000 --- a/package/kernel/mac80211/patches/subsys/337-mac80211-minstrel_ht-clean-up-CCK-code.patch +++ /dev/null @@ -1,166 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 25 Dec 2020 16:22:52 +0100 -Subject: [PATCH] mac80211: minstrel_ht: clean up CCK code - -- move ack overhead out of rate duration table -- remove cck_supported, cck_supported_short - -Preparation for adding OFDM legacy rates support - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -136,20 +136,16 @@ - __VHT_GROUP(_streams, _sgi, _bw, \ - VHT_GROUP_SHIFT(_streams, _sgi, _bw)) - --#define CCK_DURATION(_bitrate, _short, _len) \ -+#define CCK_DURATION(_bitrate, _short) \ - (1000 * (10 /* SIFS */ + \ - (_short ? 72 + 24 : 144 + 48) + \ -- (8 * (_len + 4) * 10) / (_bitrate))) -- --#define CCK_ACK_DURATION(_bitrate, _short) \ -- (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \ -- CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE)) -+ (8 * (AVG_PKT_SIZE + 4) * 10) / (_bitrate))) - - #define CCK_DURATION_LIST(_short, _s) \ -- CCK_ACK_DURATION(10, _short) >> _s, \ -- CCK_ACK_DURATION(20, _short) >> _s, \ -- CCK_ACK_DURATION(55, _short) >> _s, \ -- CCK_ACK_DURATION(110, _short) >> _s -+ CCK_DURATION(10, _short) >> _s, \ -+ CCK_DURATION(20, _short) >> _s, \ -+ CCK_DURATION(55, _short) >> _s, \ -+ CCK_DURATION(110, _short) >> _s - - #define __CCK_GROUP(_s) \ - [MINSTREL_CCK_GROUP] = { \ -@@ -163,7 +159,7 @@ - } - - #define CCK_GROUP_SHIFT \ -- GROUP_SHIFT(CCK_ACK_DURATION(10, false)) -+ GROUP_SHIFT(CCK_DURATION(10, false)) - - #define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT) - -@@ -349,15 +345,19 @@ int - minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, - int prob_avg) - { -- unsigned int nsecs = 0; -+ unsigned int nsecs = 0, overhead = mi->overhead; -+ unsigned int ampdu_len = 1; - - /* do not account throughput if sucess prob is below 10% */ - if (prob_avg < MINSTREL_FRAC(10, 100)) - return 0; - -- if (group != MINSTREL_CCK_GROUP) -- nsecs = 1000 * mi->overhead / minstrel_ht_avg_ampdu_len(mi); -+ if (group == MINSTREL_CCK_GROUP) -+ overhead = mi->overhead_legacy; -+ else -+ ampdu_len = minstrel_ht_avg_ampdu_len(mi); - -+ nsecs = 1000 * overhead / ampdu_len; - nsecs += minstrel_mcs_groups[group].duration[rate] << - minstrel_mcs_groups[group].shift; - -@@ -1031,7 +1031,10 @@ minstrel_calc_retransmit(struct minstrel - ctime += (t_slot * cw) >> 1; - cw = min((cw << 1) | 1, mp->cw_max); - -- if (index / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) { -+ if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { -+ overhead = mi->overhead_legacy; -+ overhead_rtscts = mi->overhead_legacy_rtscts; -+ } else { - overhead = mi->overhead; - overhead_rtscts = mi->overhead_rtscts; - } -@@ -1369,18 +1372,14 @@ minstrel_ht_update_cck(struct minstrel_p - if (!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES)) - return; - -- mi->cck_supported = 0; -- mi->cck_supported_short = 0; - for (i = 0; i < 4; i++) { - if (!rate_supported(sta, sband->band, mp->cck_rates[i])) - continue; - -- mi->cck_supported |= BIT(i); -+ mi->supported[MINSTREL_CCK_GROUP] |= BIT(i); - if (sband->bitrates[i].flags & IEEE80211_RATE_SHORT_PREAMBLE) -- mi->cck_supported_short |= BIT(i); -+ mi->supported[MINSTREL_CCK_GROUP] |= BIT(i + 4); - } -- -- mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported; - } - - static void -@@ -1394,12 +1393,13 @@ minstrel_ht_update_caps(void *priv, stru - struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; - u16 ht_cap = sta->ht_cap.cap; - struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; -+ const struct ieee80211_rate *ctl_rate; -+ bool ldpc, erp; - int use_vht; - int n_supported = 0; - int ack_dur; - int stbc; - int i; -- bool ldpc; - - /* fall back to the old minstrel for legacy stations */ - if (!sta->ht_cap.ht_supported) -@@ -1423,6 +1423,14 @@ minstrel_ht_update_caps(void *priv, stru - mi->overhead += ack_dur; - mi->overhead_rtscts = mi->overhead + 2 * ack_dur; - -+ ctl_rate = &sband->bitrates[rate_lowest_index(sband, sta)]; -+ erp = ctl_rate->flags & IEEE80211_RATE_ERP_G; -+ ack_dur = ieee80211_frame_duration(sband->band, 10, -+ ctl_rate->bitrate, erp, 1, -+ ieee80211_chandef_get_shift(chandef)); -+ mi->overhead_legacy = ack_dur; -+ mi->overhead_legacy_rtscts = mi->overhead_legacy + 2 * ack_dur; -+ - mi->avg_ampdu_len = MINSTREL_FRAC(1, 1); - - /* When using MRR, sample more on the first attempt, without delay */ -@@ -1523,8 +1531,6 @@ minstrel_ht_update_caps(void *priv, stru - if (!n_supported) - goto use_legacy; - -- mi->supported[MINSTREL_CCK_GROUP] |= mi->cck_supported_short << 4; -- - /* create an initial rate table with the lowest supported rates */ - minstrel_ht_update_stats(mp, mi, true); - minstrel_ht_update_rates(mp, mi); ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -77,6 +77,8 @@ struct minstrel_ht_sta { - /* overhead time in usec for each frame */ - unsigned int overhead; - unsigned int overhead_rtscts; -+ unsigned int overhead_legacy; -+ unsigned int overhead_legacy_rtscts; - - unsigned int total_packets_last; - unsigned int total_packets_cur; -@@ -97,9 +99,6 @@ struct minstrel_ht_sta { - /* current MCS group to be sampled */ - u8 sample_group; - -- u8 cck_supported; -- u8 cck_supported_short; -- - /* Bitfield of supported MCS rates of all groups */ - u16 supported[MINSTREL_GROUPS_NB]; - diff --git a/package/kernel/mac80211/patches/subsys/338-mac80211-minstrel_ht-add-support-for-OFDM-rates-on-n.patch b/package/kernel/mac80211/patches/subsys/338-mac80211-minstrel_ht-add-support-for-OFDM-rates-on-n.patch deleted file mode 100644 index abefde7109c..00000000000 --- a/package/kernel/mac80211/patches/subsys/338-mac80211-minstrel_ht-add-support-for-OFDM-rates-on-n.patch +++ /dev/null @@ -1,762 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 13:56:42 +0100 -Subject: [PATCH] mac80211: minstrel_ht: add support for OFDM rates on - non-HT clients - -The legacy minstrel code is essentially unmaintained and receives only very -little testing. In order to bring the significant algorithm improvements from -minstrel_ht to legacy clients, this patch adds support for OFDM rates to -minstrel_ht and removes the fallback to the legacy codepath. -This also makes it work much better on hardware with rate selection constraints, -e.g. mt76. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel.h -+++ b/net/mac80211/rc80211_minstrel.h -@@ -152,6 +152,7 @@ struct minstrel_priv { - unsigned int lookaround_rate_mrr; - - u8 cck_rates[4]; -+ u8 ofdm_rates[NUM_NL80211_BANDS][8]; - - #ifdef CPTCFG_MAC80211_DEBUGFS - /* ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -163,6 +163,38 @@ - - #define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT) - -+#define OFDM_DURATION(_bitrate) \ -+ (1000 * (16 /* SIFS + signal ext */ + \ -+ 16 /* T_PREAMBLE */ + \ -+ 4 /* T_SIGNAL */ + \ -+ 4 * (((16 + 80 * (AVG_PKT_SIZE + 4) + 6) / \ -+ ((_bitrate) * 4))))) -+ -+#define OFDM_DURATION_LIST(_s) \ -+ OFDM_DURATION(60) >> _s, \ -+ OFDM_DURATION(90) >> _s, \ -+ OFDM_DURATION(120) >> _s, \ -+ OFDM_DURATION(180) >> _s, \ -+ OFDM_DURATION(240) >> _s, \ -+ OFDM_DURATION(360) >> _s, \ -+ OFDM_DURATION(480) >> _s, \ -+ OFDM_DURATION(540) >> _s -+ -+#define __OFDM_GROUP(_s) \ -+ [MINSTREL_OFDM_GROUP] = { \ -+ .streams = 1, \ -+ .flags = 0, \ -+ .shift = _s, \ -+ .duration = { \ -+ OFDM_DURATION_LIST(_s), \ -+ } \ -+ } -+ -+#define OFDM_GROUP_SHIFT \ -+ GROUP_SHIFT(OFDM_DURATION(60)) -+ -+#define OFDM_GROUP __OFDM_GROUP(OFDM_GROUP_SHIFT) -+ - - static bool minstrel_vht_only = true; - module_param(minstrel_vht_only, bool, 0644); -@@ -199,6 +231,7 @@ const struct mcs_group minstrel_mcs_grou - MCS_GROUP(4, 1, BW_40), - - CCK_GROUP, -+ OFDM_GROUP, - - VHT_GROUP(1, 0, BW_20), - VHT_GROUP(2, 0, BW_20), -@@ -231,6 +264,8 @@ const struct mcs_group minstrel_mcs_grou - VHT_GROUP(4, 1, BW_80), - }; - -+const s16 minstrel_cck_bitrates[4] = { 10, 20, 55, 110 }; -+const s16 minstrel_ofdm_bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 }; - static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly; - - static void -@@ -275,6 +310,13 @@ minstrel_get_valid_vht_rates(int bw, int - return 0x3ff & ~mask; - } - -+static bool -+minstrel_ht_is_legacy_group(int group) -+{ -+ return group == MINSTREL_CCK_GROUP || -+ group == MINSTREL_OFDM_GROUP; -+} -+ - /* - * Look up an MCS group index based on mac80211 rate information - */ -@@ -304,21 +346,34 @@ minstrel_ht_get_stats(struct minstrel_pr - if (rate->flags & IEEE80211_TX_RC_MCS) { - group = minstrel_ht_get_group_idx(rate); - idx = rate->idx % 8; -- } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { -+ goto out; -+ } -+ -+ if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { - group = minstrel_vht_get_group_idx(rate); - idx = ieee80211_rate_get_vht_mcs(rate); -- } else { -- group = MINSTREL_CCK_GROUP; -+ goto out; -+ } - -- for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++) -- if (rate->idx == mp->cck_rates[idx]) -- break; -+ group = MINSTREL_CCK_GROUP; -+ for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++) { -+ if (rate->idx != mp->cck_rates[idx]) -+ continue; - - /* short preamble */ - if ((mi->supported[group] & BIT(idx + 4)) && - (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)) -- idx += 4; -+ idx += 4; -+ goto out; - } -+ -+ group = MINSTREL_OFDM_GROUP; -+ for (idx = 0; idx < ARRAY_SIZE(mp->ofdm_rates[0]); idx++) -+ if (rate->idx == mp->ofdm_rates[mi->band][idx]) -+ goto out; -+ -+ idx = 0; -+out: - return &mi->groups[group].rates[idx]; - } - -@@ -352,7 +407,7 @@ minstrel_ht_get_tp_avg(struct minstrel_h - if (prob_avg < MINSTREL_FRAC(10, 100)) - return 0; - -- if (group == MINSTREL_CCK_GROUP) -+ if (minstrel_ht_is_legacy_group(group)) - overhead = mi->overhead_legacy; - else - ampdu_len = minstrel_ht_avg_ampdu_len(mi); -@@ -439,8 +494,8 @@ minstrel_ht_set_best_prob_rate(struct mi - /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from - * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ - max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES; -- if((index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) && -- (max_tp_group != MINSTREL_CCK_GROUP)) -+ if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) && -+ !minstrel_ht_is_legacy_group(max_tp_group)) - return; - - max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES; -@@ -476,13 +531,13 @@ minstrel_ht_set_best_prob_rate(struct mi - static void - minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi, - u16 tmp_mcs_tp_rate[MAX_THR_RATES], -- u16 tmp_cck_tp_rate[MAX_THR_RATES]) -+ u16 tmp_legacy_tp_rate[MAX_THR_RATES]) - { - unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob; - int i; - -- tmp_group = tmp_cck_tp_rate[0] / MCS_GROUP_RATES; -- tmp_idx = tmp_cck_tp_rate[0] % MCS_GROUP_RATES; -+ tmp_group = tmp_legacy_tp_rate[0] / MCS_GROUP_RATES; -+ tmp_idx = tmp_legacy_tp_rate[0] % MCS_GROUP_RATES; - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); - -@@ -493,7 +548,7 @@ minstrel_ht_assign_best_tp_rates(struct - - if (tmp_cck_tp > tmp_mcs_tp) { - for(i = 0; i < MAX_THR_RATES; i++) { -- minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i], -+ minstrel_ht_sort_best_tp_rates(mi, tmp_legacy_tp_rate[i], - tmp_mcs_tp_rate); - } - } -@@ -511,6 +566,9 @@ minstrel_ht_prob_rate_reduce_streams(str - int tmp_max_streams, group, tmp_idx, tmp_prob; - int tmp_tp = 0; - -+ if (!mi->sta->ht_cap.ht_supported) -+ return; -+ - tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] / - MCS_GROUP_RATES].streams; - for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { -@@ -675,7 +733,8 @@ minstrel_ht_update_stats(struct minstrel - struct minstrel_rate_stats *mrs; - int group, i, j, cur_prob; - u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES]; -- u16 tmp_cck_tp_rate[MAX_THR_RATES], index; -+ u16 tmp_legacy_tp_rate[MAX_THR_RATES], index; -+ bool ht_supported = mi->sta->ht_cap.ht_supported; - - mi->sample_mode = MINSTREL_SAMPLE_IDLE; - -@@ -704,21 +763,29 @@ minstrel_ht_update_stats(struct minstrel - mi->sample_count = 0; - - memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate)); -- memset(tmp_cck_tp_rate, 0, sizeof(tmp_cck_tp_rate)); -+ memset(tmp_legacy_tp_rate, 0, sizeof(tmp_legacy_tp_rate)); - if (mi->supported[MINSTREL_CCK_GROUP]) -- for (j = 0; j < ARRAY_SIZE(tmp_cck_tp_rate); j++) -- tmp_cck_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; -+ for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) -+ tmp_legacy_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; -+ else if (mi->supported[MINSTREL_OFDM_GROUP]) -+ for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) -+ tmp_legacy_tp_rate[j] = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; - - if (mi->supported[MINSTREL_VHT_GROUP_0]) - index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES; -- else -+ else if (ht_supported) - index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES; -+ else if (mi->supported[MINSTREL_CCK_GROUP]) -+ index = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; -+ else -+ index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; - - for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++) - tmp_mcs_tp_rate[j] = index; - - /* Find best rate sets within all MCS groups*/ - for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { -+ u16 *tp_rate = tmp_mcs_tp_rate; - - mg = &mi->groups[group]; - if (!mi->supported[group]) -@@ -730,6 +797,9 @@ minstrel_ht_update_stats(struct minstrel - for(j = 0; j < MAX_THR_RATES; j++) - tmp_group_tp_rate[j] = MCS_GROUP_RATES * group; - -+ if (group == MINSTREL_CCK_GROUP && ht_supported) -+ tp_rate = tmp_legacy_tp_rate; -+ - for (i = 0; i < MCS_GROUP_RATES; i++) { - if (!(mi->supported[group] & BIT(i))) - continue; -@@ -745,13 +815,7 @@ minstrel_ht_update_stats(struct minstrel - continue; - - /* Find max throughput rate set */ -- if (group != MINSTREL_CCK_GROUP) { -- minstrel_ht_sort_best_tp_rates(mi, index, -- tmp_mcs_tp_rate); -- } else if (group == MINSTREL_CCK_GROUP) { -- minstrel_ht_sort_best_tp_rates(mi, index, -- tmp_cck_tp_rate); -- } -+ minstrel_ht_sort_best_tp_rates(mi, index, tp_rate); - - /* Find max throughput rate set within a group */ - minstrel_ht_sort_best_tp_rates(mi, index, -@@ -766,7 +830,8 @@ minstrel_ht_update_stats(struct minstrel - } - - /* Assign new rate set per sta */ -- minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, tmp_cck_tp_rate); -+ minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, -+ tmp_legacy_tp_rate); - memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate)); - - /* Try to increase robustness of max_prob_rate*/ -@@ -795,8 +860,11 @@ minstrel_ht_update_stats(struct minstrel - } - - static bool --minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rate) -+minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, -+ struct ieee80211_tx_rate *rate) - { -+ int i; -+ - if (rate->idx < 0) - return false; - -@@ -807,10 +875,15 @@ minstrel_ht_txstat_valid(struct minstrel - rate->flags & IEEE80211_TX_RC_VHT_MCS) - return true; - -- return rate->idx == mp->cck_rates[0] || -- rate->idx == mp->cck_rates[1] || -- rate->idx == mp->cck_rates[2] || -- rate->idx == mp->cck_rates[3]; -+ for (i = 0; i < ARRAY_SIZE(mp->cck_rates); i++) -+ if (rate->idx == mp->cck_rates[i]) -+ return true; -+ -+ for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++) -+ if (rate->idx == mp->ofdm_rates[mi->band][i]) -+ return true; -+ -+ return false; - } - - static void -@@ -897,11 +970,6 @@ minstrel_ht_tx_status(void *priv, struct - bool sample_status = false; - int i; - -- if (!msp->is_ht) -- return mac80211_minstrel.tx_status_ext(priv, sband, -- &msp->legacy, st); -- -- - /* This packet was aggregated but doesn't carry status info */ - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && - !(info->flags & IEEE80211_TX_STAT_AMPDU)) -@@ -930,10 +998,10 @@ minstrel_ht_tx_status(void *priv, struct - if (mi->sample_mode != MINSTREL_SAMPLE_IDLE) - rate_sample = minstrel_get_ratestats(mi, mi->sample_rate); - -- last = !minstrel_ht_txstat_valid(mp, &ar[0]); -+ last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]); - for (i = 0; !last; i++) { - last = (i == IEEE80211_TX_MAX_RATES - 1) || -- !minstrel_ht_txstat_valid(mp, &ar[i + 1]); -+ !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]); - - rate = minstrel_ht_get_stats(mp, mi, &ar[i]); - if (rate == rate_sample) -@@ -1031,7 +1099,7 @@ minstrel_calc_retransmit(struct minstrel - ctime += (t_slot * cw) >> 1; - cw = min((cw << 1) | 1, mp->cw_max); - -- if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { -+ if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES)) { - overhead = mi->overhead_legacy; - overhead_rtscts = mi->overhead_legacy_rtscts; - } else { -@@ -1064,7 +1132,8 @@ static void - minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, - struct ieee80211_sta_rates *ratetbl, int offset, int index) - { -- const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; -+ int group_idx = index / MCS_GROUP_RATES; -+ const struct mcs_group *group = &minstrel_mcs_groups[group_idx]; - struct minstrel_rate_stats *mrs; - u8 idx; - u16 flags = group->flags; -@@ -1083,13 +1152,17 @@ minstrel_ht_set_rate(struct minstrel_pri - ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts; - } - -- if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) -+ index %= MCS_GROUP_RATES; -+ if (group_idx == MINSTREL_CCK_GROUP) - idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)]; -+ else if (group_idx == MINSTREL_OFDM_GROUP) -+ idx = mp->ofdm_rates[mi->band][index % -+ ARRAY_SIZE(mp->ofdm_rates[0])]; - else if (flags & IEEE80211_TX_RC_VHT_MCS) - idx = ((group->streams - 1) << 4) | -- ((index % MCS_GROUP_RATES) & 0xF); -+ (index & 0xF); - else -- idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8; -+ idx = index + (group->streams - 1) * 8; - - /* enable RTS/CTS if needed: - * - if station is in dynamic SMPS (and streams > 1) -@@ -1304,11 +1377,8 @@ minstrel_ht_get_rate(void *priv, struct - struct minstrel_priv *mp = priv; - int sample_idx; - -- if (!msp->is_ht) -- return mac80211_minstrel.get_rate(priv, sta, &msp->legacy, txrc); -- - if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && -- mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) -+ !minstrel_ht_is_legacy_group(mi->max_prob_rate / MCS_GROUP_RATES)) - minstrel_aggr_check(sta, txrc->skb); - - info->flags |= mi->tx_flags; -@@ -1349,6 +1419,9 @@ minstrel_ht_get_rate(void *priv, struct - if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) { - int idx = sample_idx % ARRAY_SIZE(mp->cck_rates); - rate->idx = mp->cck_rates[idx]; -+ } else if (sample_group == &minstrel_mcs_groups[MINSTREL_OFDM_GROUP]) { -+ int idx = sample_idx % ARRAY_SIZE(mp->ofdm_rates[0]); -+ rate->idx = mp->ofdm_rates[mi->band][idx]; - } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) { - ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES, - sample_group->streams); -@@ -1369,11 +1442,13 @@ minstrel_ht_update_cck(struct minstrel_p - if (sband->band != NL80211_BAND_2GHZ) - return; - -- if (!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES)) -+ if (sta->ht_cap.ht_supported && -+ !ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES)) - return; - - for (i = 0; i < 4; i++) { -- if (!rate_supported(sta, sband->band, mp->cck_rates[i])) -+ if (mp->cck_rates[i] == 0xff || -+ !rate_supported(sta, sband->band, mp->cck_rates[i])) - continue; - - mi->supported[MINSTREL_CCK_GROUP] |= BIT(i); -@@ -1383,9 +1458,30 @@ minstrel_ht_update_cck(struct minstrel_p - } - - static void -+minstrel_ht_update_ofdm(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, -+ struct ieee80211_supported_band *sband, -+ struct ieee80211_sta *sta) -+{ -+ const u8 *rates; -+ int i; -+ -+ if (sta->ht_cap.ht_supported) -+ return; -+ -+ rates = mp->ofdm_rates[sband->band]; -+ for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++) { -+ if (rates[i] == 0xff || -+ !rate_supported(sta, sband->band, rates[i])) -+ continue; -+ -+ mi->supported[MINSTREL_OFDM_GROUP] |= BIT(i); -+ } -+} -+ -+static void - minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, - struct cfg80211_chan_def *chandef, -- struct ieee80211_sta *sta, void *priv_sta) -+ struct ieee80211_sta *sta, void *priv_sta) - { - struct minstrel_priv *mp = priv; - struct minstrel_ht_sta_priv *msp = priv_sta; -@@ -1401,10 +1497,6 @@ minstrel_ht_update_caps(void *priv, stru - int stbc; - int i; - -- /* fall back to the old minstrel for legacy stations */ -- if (!sta->ht_cap.ht_supported) -- goto use_legacy; -- - BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB); - - if (vht_cap->vht_supported) -@@ -1412,10 +1504,10 @@ minstrel_ht_update_caps(void *priv, stru - else - use_vht = 0; - -- msp->is_ht = true; - memset(mi, 0, sizeof(*mi)); - - mi->sta = sta; -+ mi->band = sband->band; - mi->last_stats_update = jiffies; - - ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1, 0); -@@ -1464,10 +1556,8 @@ minstrel_ht_update_caps(void *priv, stru - int bw, nss; - - mi->supported[i] = 0; -- if (i == MINSTREL_CCK_GROUP) { -- minstrel_ht_update_cck(mp, mi, sband, sta); -+ if (minstrel_ht_is_legacy_group(i)) - continue; -- } - - if (gflags & IEEE80211_TX_RC_SHORT_GI) { - if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) { -@@ -1528,22 +1618,12 @@ minstrel_ht_update_caps(void *priv, stru - n_supported++; - } - -- if (!n_supported) -- goto use_legacy; -+ minstrel_ht_update_cck(mp, mi, sband, sta); -+ minstrel_ht_update_ofdm(mp, mi, sband, sta); - - /* create an initial rate table with the lowest supported rates */ - minstrel_ht_update_stats(mp, mi, true); - minstrel_ht_update_rates(mp, mi); -- -- return; -- --use_legacy: -- msp->is_ht = false; -- memset(&msp->legacy, 0, sizeof(msp->legacy)); -- msp->legacy.r = msp->ratelist; -- msp->legacy.sample_table = msp->sample_table; -- return mac80211_minstrel.rate_init(priv, sband, chandef, sta, -- &msp->legacy); - } - - static void -@@ -1611,40 +1691,70 @@ minstrel_ht_free_sta(void *priv, struct - } - - static void --minstrel_ht_init_cck_rates(struct minstrel_priv *mp) -+minstrel_ht_fill_rate_array(u8 *dest, struct ieee80211_supported_band *sband, -+ const s16 *bitrates, int n_rates, u32 rate_flags) - { -- static const int bitrates[4] = { 10, 20, 55, 110 }; -- struct ieee80211_supported_band *sband; -- u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef); - int i, j; - -- sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ]; -- if (!sband) -- return; -- - for (i = 0; i < sband->n_bitrates; i++) { - struct ieee80211_rate *rate = &sband->bitrates[i]; - -- if (rate->flags & IEEE80211_RATE_ERP_G) -- continue; -- - if ((rate_flags & sband->bitrates[i].flags) != rate_flags) - continue; - -- for (j = 0; j < ARRAY_SIZE(bitrates); j++) { -+ for (j = 0; j < n_rates; j++) { - if (rate->bitrate != bitrates[j]) - continue; - -- mp->cck_rates[j] = i; -+ dest[j] = i; - break; - } - } - } - -+static void -+minstrel_ht_init_cck_rates(struct minstrel_priv *mp) -+{ -+ static const s16 bitrates[4] = { 10, 20, 55, 110 }; -+ struct ieee80211_supported_band *sband; -+ u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef); -+ -+ memset(mp->cck_rates, 0xff, sizeof(mp->cck_rates)); -+ sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ]; -+ if (!sband) -+ return; -+ -+ BUILD_BUG_ON(ARRAY_SIZE(mp->cck_rates) != ARRAY_SIZE(bitrates)); -+ minstrel_ht_fill_rate_array(mp->cck_rates, sband, -+ minstrel_cck_bitrates, -+ ARRAY_SIZE(minstrel_cck_bitrates), -+ rate_flags); -+} -+ -+static void -+minstrel_ht_init_ofdm_rates(struct minstrel_priv *mp, enum nl80211_band band) -+{ -+ static const s16 bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 }; -+ struct ieee80211_supported_band *sband; -+ u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef); -+ -+ memset(mp->ofdm_rates[band], 0xff, sizeof(mp->ofdm_rates[band])); -+ sband = mp->hw->wiphy->bands[band]; -+ if (!sband) -+ return; -+ -+ BUILD_BUG_ON(ARRAY_SIZE(mp->ofdm_rates[band]) != ARRAY_SIZE(bitrates)); -+ minstrel_ht_fill_rate_array(mp->ofdm_rates[band], sband, -+ minstrel_ofdm_bitrates, -+ ARRAY_SIZE(minstrel_ofdm_bitrates), -+ rate_flags); -+} -+ - static void * - minstrel_ht_alloc(struct ieee80211_hw *hw) - { - struct minstrel_priv *mp; -+ int i; - - mp = kzalloc(sizeof(struct minstrel_priv), GFP_ATOMIC); - if (!mp) -@@ -1681,6 +1791,8 @@ minstrel_ht_alloc(struct ieee80211_hw *h - mp->new_avg = true; - - minstrel_ht_init_cck_rates(mp); -+ for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++) -+ minstrel_ht_init_ofdm_rates(mp, i); - - return mp; - } -@@ -1713,9 +1825,6 @@ static u32 minstrel_ht_get_expected_thro - struct minstrel_ht_sta *mi = &msp->ht; - int i, j, prob, tp_avg; - -- if (!msp->is_ht) -- return mac80211_minstrel.get_expected_throughput(priv_sta); -- - i = mi->max_tp_rate[0] / MCS_GROUP_RATES; - j = mi->max_tp_rate[0] % MCS_GROUP_RATES; - prob = mi->groups[i].rates[j].prob_avg; ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -18,14 +18,15 @@ - MINSTREL_HT_STREAM_GROUPS) - #define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \ - MINSTREL_VHT_STREAM_GROUPS) --#define MINSTREL_CCK_GROUPS_NB 1 -+#define MINSTREL_LEGACY_GROUPS_NB 2 - #define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \ - MINSTREL_VHT_GROUPS_NB + \ -- MINSTREL_CCK_GROUPS_NB) -+ MINSTREL_LEGACY_GROUPS_NB) - - #define MINSTREL_HT_GROUP_0 0 - #define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB) --#define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1) -+#define MINSTREL_OFDM_GROUP (MINSTREL_CCK_GROUP + 1) -+#define MINSTREL_VHT_GROUP_0 (MINSTREL_OFDM_GROUP + 1) - - #define MCS_GROUP_RATES 10 - -@@ -37,6 +38,8 @@ struct mcs_group { - u16 duration[MCS_GROUP_RATES]; - }; - -+extern const s16 minstrel_cck_bitrates[4]; -+extern const s16 minstrel_ofdm_bitrates[8]; - extern const struct mcs_group minstrel_mcs_groups[]; - - struct minstrel_mcs_group_data { -@@ -99,6 +102,8 @@ struct minstrel_ht_sta { - /* current MCS group to be sampled */ - u8 sample_group; - -+ u8 band; -+ - /* Bitfield of supported MCS rates of all groups */ - u16 supported[MINSTREL_GROUPS_NB]; - -@@ -107,13 +112,9 @@ struct minstrel_ht_sta { - }; - - struct minstrel_ht_sta_priv { -- union { -- struct minstrel_ht_sta ht; -- struct minstrel_sta_info legacy; -- }; -+ struct minstrel_ht_sta ht; - void *ratelist; - void *sample_table; -- bool is_ht; - }; - - void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); ---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c -+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c -@@ -52,7 +52,6 @@ minstrel_ht_stats_dump(struct minstrel_h - - for (j = 0; j < MCS_GROUP_RATES; j++) { - struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; -- static const int bitrates[4] = { 10, 20, 55, 110 }; - int idx = i * MCS_GROUP_RATES + j; - unsigned int duration; - -@@ -67,6 +66,9 @@ minstrel_ht_stats_dump(struct minstrel_h - p += sprintf(p, "VHT%c0 ", htmode); - p += sprintf(p, "%cGI ", gimode); - p += sprintf(p, "%d ", mg->streams); -+ } else if (i == MINSTREL_OFDM_GROUP) { -+ p += sprintf(p, "OFDM "); -+ p += sprintf(p, "1 "); - } else { - p += sprintf(p, "CCK "); - p += sprintf(p, "%cP ", j < 4 ? 'L' : 'S'); -@@ -84,7 +86,12 @@ minstrel_ht_stats_dump(struct minstrel_h - } else if (gflags & IEEE80211_TX_RC_VHT_MCS) { - p += sprintf(p, " MCS%-1u/%1u", j, mg->streams); - } else { -- int r = bitrates[j % 4]; -+ int r; -+ -+ if (i == MINSTREL_OFDM_GROUP) -+ r = minstrel_ofdm_bitrates[j % 8]; -+ else -+ r = minstrel_cck_bitrates[j % 4]; - - p += sprintf(p, " %2u.%1uM", r / 10, r % 10); - } -@@ -124,16 +131,8 @@ minstrel_ht_stats_open(struct inode *ino - struct minstrel_ht_sta *mi = &msp->ht; - struct minstrel_debugfs_info *ms; - unsigned int i; -- int ret; - char *p; - -- if (!msp->is_ht) { -- inode->i_private = &msp->legacy; -- ret = minstrel_stats_open(inode, file); -- inode->i_private = msp; -- return ret; -- } -- - ms = kmalloc(32768, GFP_KERNEL); - if (!ms) - return -ENOMEM; -@@ -199,7 +198,6 @@ minstrel_ht_stats_csv_dump(struct minstr - - for (j = 0; j < MCS_GROUP_RATES; j++) { - struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; -- static const int bitrates[4] = { 10, 20, 55, 110 }; - int idx = i * MCS_GROUP_RATES + j; - unsigned int duration; - -@@ -214,6 +212,8 @@ minstrel_ht_stats_csv_dump(struct minstr - p += sprintf(p, "VHT%c0,", htmode); - p += sprintf(p, "%cGI,", gimode); - p += sprintf(p, "%d,", mg->streams); -+ } else if (i == MINSTREL_OFDM_GROUP) { -+ p += sprintf(p, "OFDM,,1,"); - } else { - p += sprintf(p, "CCK,"); - p += sprintf(p, "%cP,", j < 4 ? 'L' : 'S'); -@@ -231,7 +231,13 @@ minstrel_ht_stats_csv_dump(struct minstr - } else if (gflags & IEEE80211_TX_RC_VHT_MCS) { - p += sprintf(p, ",MCS%-1u/%1u,", j, mg->streams); - } else { -- int r = bitrates[j % 4]; -+ int r; -+ -+ if (i == MINSTREL_OFDM_GROUP) -+ r = minstrel_ofdm_bitrates[j % 8]; -+ else -+ r = minstrel_cck_bitrates[j % 4]; -+ - p += sprintf(p, ",%2u.%1uM,", r / 10, r % 10); - } - -@@ -274,18 +280,9 @@ minstrel_ht_stats_csv_open(struct inode - struct minstrel_ht_sta *mi = &msp->ht; - struct minstrel_debugfs_info *ms; - unsigned int i; -- int ret; - char *p; - -- if (!msp->is_ht) { -- inode->i_private = &msp->legacy; -- ret = minstrel_stats_csv_open(inode, file); -- inode->i_private = msp; -- return ret; -- } -- - ms = kmalloc(32768, GFP_KERNEL); -- - if (!ms) - return -ENOMEM; - diff --git a/package/kernel/mac80211/patches/subsys/339-mac80211-remove-legacy-minstrel-rate-control.patch b/package/kernel/mac80211/patches/subsys/339-mac80211-remove-legacy-minstrel-rate-control.patch deleted file mode 100644 index 1cab2eb1947..00000000000 --- a/package/kernel/mac80211/patches/subsys/339-mac80211-remove-legacy-minstrel-rate-control.patch +++ /dev/null @@ -1,1328 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 14:23:47 +0100 -Subject: [PATCH] mac80211: remove legacy minstrel rate control - -Now that minstrel_ht supports legacy rates, it is no longer needed - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - delete mode 100644 net/mac80211/rc80211_minstrel.c - delete mode 100644 net/mac80211/rc80211_minstrel.h - delete mode 100644 net/mac80211/rc80211_minstrel_debugfs.c - ---- a/net/mac80211/Makefile -+++ b/net/mac80211/Makefile -@@ -56,11 +56,9 @@ mac80211-$(CONFIG_PM) += pm.o - CFLAGS_trace.o := -I$(src) - - rc80211_minstrel-y := \ -- rc80211_minstrel.o \ - rc80211_minstrel_ht.o - - rc80211_minstrel-$(CPTCFG_MAC80211_DEBUGFS) += \ -- rc80211_minstrel_debugfs.o \ - rc80211_minstrel_ht_debugfs.o - - mac80211-$(CPTCFG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) ---- a/net/mac80211/rc80211_minstrel.c -+++ /dev/null -@@ -1,574 +0,0 @@ --/* -- * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org> -- * -- * 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. -- * -- * Based on minstrel.c: -- * Copyright (C) 2005-2007 Derek Smithies <derek@indranet.co.nz> -- * Sponsored by Indranet Technologies Ltd -- * -- * Based on sample.c: -- * Copyright (c) 2005 John Bicket -- * All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer, -- * without modification. -- * 2. Redistributions in binary form must reproduce at minimum a disclaimer -- * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any -- * redistribution must be conditioned upon including a substantially -- * similar Disclaimer requirement for further binary redistribution. -- * 3. Neither the names of the above-listed copyright holders nor the names -- * of any contributors may be used to endorse or promote products derived -- * from this software without specific prior written permission. -- * -- * Alternatively, this software may be distributed under the terms of the -- * GNU General Public License ("GPL") version 2 as published by the Free -- * Software Foundation. -- * -- * NO WARRANTY -- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY -- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -- * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -- * THE POSSIBILITY OF SUCH DAMAGES. -- */ --#include <linux/netdevice.h> --#include <linux/types.h> --#include <linux/skbuff.h> --#include <linux/debugfs.h> --#include <linux/random.h> --#include <linux/ieee80211.h> --#include <linux/slab.h> --#include <net/mac80211.h> --#include "rate.h" --#include "rc80211_minstrel.h" -- --#define SAMPLE_TBL(_mi, _idx, _col) \ -- _mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col] -- --/* convert mac80211 rate index to local array index */ --static inline int --rix_to_ndx(struct minstrel_sta_info *mi, int rix) --{ -- int i = rix; -- for (i = rix; i >= 0; i--) -- if (mi->r[i].rix == rix) -- break; -- return i; --} -- --/* return current EMWA throughput */ --int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg) --{ -- int usecs; -- -- usecs = mr->perfect_tx_time; -- if (!usecs) -- usecs = 1000000; -- -- /* reset thr. below 10% success */ -- if (mr->stats.prob_avg < MINSTREL_FRAC(10, 100)) -- return 0; -- -- if (prob_avg > MINSTREL_FRAC(90, 100)) -- return MINSTREL_TRUNC(100000 * (MINSTREL_FRAC(90, 100) / usecs)); -- else -- return MINSTREL_TRUNC(100000 * (prob_avg / usecs)); --} -- --/* find & sort topmost throughput rates */ --static inline void --minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list) --{ -- int j; -- struct minstrel_rate_stats *tmp_mrs; -- struct minstrel_rate_stats *cur_mrs = &mi->r[i].stats; -- -- for (j = MAX_THR_RATES; j > 0; --j) { -- tmp_mrs = &mi->r[tp_list[j - 1]].stats; -- if (minstrel_get_tp_avg(&mi->r[i], cur_mrs->prob_avg) <= -- minstrel_get_tp_avg(&mi->r[tp_list[j - 1]], tmp_mrs->prob_avg)) -- break; -- } -- -- if (j < MAX_THR_RATES - 1) -- memmove(&tp_list[j + 1], &tp_list[j], MAX_THR_RATES - (j + 1)); -- if (j < MAX_THR_RATES) -- tp_list[j] = i; --} -- --static void --minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl, -- int offset, int idx) --{ -- struct minstrel_rate *r = &mi->r[idx]; -- -- ratetbl->rate[offset].idx = r->rix; -- ratetbl->rate[offset].count = r->adjusted_retry_count; -- ratetbl->rate[offset].count_cts = r->retry_count_cts; -- ratetbl->rate[offset].count_rts = r->stats.retry_count_rtscts; --} -- --static void --minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi) --{ -- struct ieee80211_sta_rates *ratetbl; -- int i = 0; -- -- ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC); -- if (!ratetbl) -- return; -- -- /* Start with max_tp_rate */ -- minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]); -- -- if (mp->hw->max_rates >= 3) { -- /* At least 3 tx rates supported, use max_tp_rate2 next */ -- minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]); -- } -- -- if (mp->hw->max_rates >= 2) { -- /* At least 2 tx rates supported, use max_prob_rate next */ -- minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate); -- } -- -- /* Use lowest rate last */ -- ratetbl->rate[i].idx = mi->lowest_rix; -- ratetbl->rate[i].count = mp->max_retry; -- ratetbl->rate[i].count_cts = mp->max_retry; -- ratetbl->rate[i].count_rts = mp->max_retry; -- -- rate_control_set_rates(mp->hw, mi->sta, ratetbl); --} -- --/* --* Recalculate statistics and counters of a given rate --*/ --void --minstrel_calc_rate_stats(struct minstrel_priv *mp, -- struct minstrel_rate_stats *mrs) --{ -- unsigned int cur_prob; -- -- if (unlikely(mrs->attempts > 0)) { -- mrs->sample_skipped = 0; -- cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); -- if (mp->new_avg) { -- minstrel_filter_avg_add(&mrs->prob_avg, -- &mrs->prob_avg_1, cur_prob); -- } else if (unlikely(!mrs->att_hist)) { -- mrs->prob_avg = cur_prob; -- } else { -- /*update exponential weighted moving avarage */ -- mrs->prob_avg = minstrel_ewma(mrs->prob_avg, -- cur_prob, -- EWMA_LEVEL); -- } -- mrs->att_hist += mrs->attempts; -- mrs->succ_hist += mrs->success; -- } else { -- mrs->sample_skipped++; -- } -- -- mrs->last_success = mrs->success; -- mrs->last_attempts = mrs->attempts; -- mrs->success = 0; -- mrs->attempts = 0; --} -- --static void --minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) --{ -- u8 tmp_tp_rate[MAX_THR_RATES]; -- u8 tmp_prob_rate = 0; -- int i, tmp_cur_tp, tmp_prob_tp; -- -- for (i = 0; i < MAX_THR_RATES; i++) -- tmp_tp_rate[i] = 0; -- -- for (i = 0; i < mi->n_rates; i++) { -- struct minstrel_rate *mr = &mi->r[i]; -- struct minstrel_rate_stats *mrs = &mi->r[i].stats; -- struct minstrel_rate_stats *tmp_mrs = &mi->r[tmp_prob_rate].stats; -- -- /* Update statistics of success probability per rate */ -- minstrel_calc_rate_stats(mp, mrs); -- -- /* Sample less often below the 10% chance of success. -- * Sample less often above the 95% chance of success. */ -- if (mrs->prob_avg > MINSTREL_FRAC(95, 100) || -- mrs->prob_avg < MINSTREL_FRAC(10, 100)) { -- mr->adjusted_retry_count = mrs->retry_count >> 1; -- if (mr->adjusted_retry_count > 2) -- mr->adjusted_retry_count = 2; -- mr->sample_limit = 4; -- } else { -- mr->sample_limit = -1; -- mr->adjusted_retry_count = mrs->retry_count; -- } -- if (!mr->adjusted_retry_count) -- mr->adjusted_retry_count = 2; -- -- minstrel_sort_best_tp_rates(mi, i, tmp_tp_rate); -- -- /* To determine the most robust rate (max_prob_rate) used at -- * 3rd mmr stage we distinct between two cases: -- * (1) if any success probabilitiy >= 95%, out of those rates -- * choose the maximum throughput rate as max_prob_rate -- * (2) if all success probabilities < 95%, the rate with -- * highest success probability is chosen as max_prob_rate */ -- if (mrs->prob_avg >= MINSTREL_FRAC(95, 100)) { -- tmp_cur_tp = minstrel_get_tp_avg(mr, mrs->prob_avg); -- tmp_prob_tp = minstrel_get_tp_avg(&mi->r[tmp_prob_rate], -- tmp_mrs->prob_avg); -- if (tmp_cur_tp >= tmp_prob_tp) -- tmp_prob_rate = i; -- } else { -- if (mrs->prob_avg >= tmp_mrs->prob_avg) -- tmp_prob_rate = i; -- } -- } -- -- /* Assign the new rate set */ -- memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate)); -- mi->max_prob_rate = tmp_prob_rate; -- --#ifdef CPTCFG_MAC80211_DEBUGFS -- /* use fixed index if set */ -- if (mp->fixed_rate_idx != -1) { -- mi->max_tp_rate[0] = mp->fixed_rate_idx; -- mi->max_tp_rate[1] = mp->fixed_rate_idx; -- mi->max_prob_rate = mp->fixed_rate_idx; -- } --#endif -- -- /* Reset update timer */ -- mi->last_stats_update = jiffies; -- -- minstrel_update_rates(mp, mi); --} -- --static void --minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband, -- void *priv_sta, struct ieee80211_tx_status *st) --{ -- struct ieee80211_tx_info *info = st->info; -- struct minstrel_priv *mp = priv; -- struct minstrel_sta_info *mi = priv_sta; -- struct ieee80211_tx_rate *ar = info->status.rates; -- int i, ndx; -- int success; -- -- success = !!(info->flags & IEEE80211_TX_STAT_ACK); -- -- for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { -- if (ar[i].idx < 0 || !ar[i].count) -- break; -- -- ndx = rix_to_ndx(mi, ar[i].idx); -- if (ndx < 0) -- continue; -- -- mi->r[ndx].stats.attempts += ar[i].count; -- -- if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) -- mi->r[ndx].stats.success += success; -- } -- -- if (time_after(jiffies, mi->last_stats_update + -- mp->update_interval / (mp->new_avg ? 2 : 1))) -- minstrel_update_stats(mp, mi); --} -- -- --static inline unsigned int --minstrel_get_retry_count(struct minstrel_rate *mr, -- struct ieee80211_tx_info *info) --{ -- u8 retry = mr->adjusted_retry_count; -- -- if (info->control.use_rts) -- retry = max_t(u8, 2, min(mr->stats.retry_count_rtscts, retry)); -- else if (info->control.use_cts_prot) -- retry = max_t(u8, 2, min(mr->retry_count_cts, retry)); -- return retry; --} -- -- --static int --minstrel_get_next_sample(struct minstrel_sta_info *mi) --{ -- unsigned int sample_ndx; -- sample_ndx = SAMPLE_TBL(mi, mi->sample_row, mi->sample_column); -- mi->sample_row++; -- if ((int) mi->sample_row >= mi->n_rates) { -- mi->sample_row = 0; -- mi->sample_column++; -- if (mi->sample_column >= SAMPLE_COLUMNS) -- mi->sample_column = 0; -- } -- return sample_ndx; --} -- --static void --minstrel_get_rate(void *priv, struct ieee80211_sta *sta, -- void *priv_sta, struct ieee80211_tx_rate_control *txrc) --{ -- struct sk_buff *skb = txrc->skb; -- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -- struct minstrel_sta_info *mi = priv_sta; -- struct minstrel_priv *mp = priv; -- struct ieee80211_tx_rate *rate = &info->control.rates[0]; -- struct minstrel_rate *msr, *mr; -- unsigned int ndx; -- bool mrr_capable; -- bool prev_sample; -- int delta; -- int sampling_ratio; -- -- /* check multi-rate-retry capabilities & adjust lookaround_rate */ -- mrr_capable = mp->has_mrr && -- !txrc->rts && -- !txrc->bss_conf->use_cts_prot; -- if (mrr_capable) -- sampling_ratio = mp->lookaround_rate_mrr; -- else -- sampling_ratio = mp->lookaround_rate; -- -- /* increase sum packet counter */ -- mi->total_packets++; -- --#ifdef CPTCFG_MAC80211_DEBUGFS -- if (mp->fixed_rate_idx != -1) -- return; --#endif -- -- /* Don't use EAPOL frames for sampling on non-mrr hw */ -- if (mp->hw->max_rates == 1 && -- (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) -- return; -- -- delta = (mi->total_packets * sampling_ratio / 100) - -- mi->sample_packets; -- -- /* delta < 0: no sampling required */ -- prev_sample = mi->prev_sample; -- mi->prev_sample = false; -- if (delta < 0 || (!mrr_capable && prev_sample)) -- return; -- -- if (mi->total_packets >= 10000) { -- mi->sample_packets = 0; -- mi->total_packets = 0; -- } else if (delta > mi->n_rates * 2) { -- /* With multi-rate retry, not every planned sample -- * attempt actually gets used, due to the way the retry -- * chain is set up - [max_tp,sample,prob,lowest] for -- * sample_rate < max_tp. -- * -- * If there's too much sampling backlog and the link -- * starts getting worse, minstrel would start bursting -- * out lots of sampling frames, which would result -- * in a large throughput loss. */ -- mi->sample_packets += (delta - mi->n_rates * 2); -- } -- -- /* get next random rate sample */ -- ndx = minstrel_get_next_sample(mi); -- msr = &mi->r[ndx]; -- mr = &mi->r[mi->max_tp_rate[0]]; -- -- /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) -- * rate sampling method should be used. -- * Respect such rates that are not sampled for 20 interations. -- */ -- if (msr->perfect_tx_time < mr->perfect_tx_time || -- msr->stats.sample_skipped >= 20) { -- if (!msr->sample_limit) -- return; -- -- mi->sample_packets++; -- if (msr->sample_limit > 0) -- msr->sample_limit--; -- } -- -- /* If we're not using MRR and the sampling rate already -- * has a probability of >95%, we shouldn't be attempting -- * to use it, as this only wastes precious airtime */ -- if (!mrr_capable && -- (mi->r[ndx].stats.prob_avg > MINSTREL_FRAC(95, 100))) -- return; -- -- mi->prev_sample = true; -- -- rate->idx = mi->r[ndx].rix; -- rate->count = minstrel_get_retry_count(&mi->r[ndx], info); -- info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; --} -- -- --static void --calc_rate_durations(enum nl80211_band band, -- struct minstrel_rate *d, -- struct ieee80211_rate *rate, -- struct cfg80211_chan_def *chandef) --{ -- int erp = !!(rate->flags & IEEE80211_RATE_ERP_G); -- int shift = ieee80211_chandef_get_shift(chandef); -- -- d->perfect_tx_time = ieee80211_frame_duration(band, 1200, -- DIV_ROUND_UP(rate->bitrate, 1 << shift), erp, 1, -- shift); -- d->ack_time = ieee80211_frame_duration(band, 10, -- DIV_ROUND_UP(rate->bitrate, 1 << shift), erp, 1, -- shift); --} -- --static void --init_sample_table(struct minstrel_sta_info *mi) --{ -- unsigned int i, col, new_idx; -- u8 rnd[8]; -- -- mi->sample_column = 0; -- mi->sample_row = 0; -- memset(mi->sample_table, 0xff, SAMPLE_COLUMNS * mi->n_rates); -- -- for (col = 0; col < SAMPLE_COLUMNS; col++) { -- prandom_bytes(rnd, sizeof(rnd)); -- for (i = 0; i < mi->n_rates; i++) { -- new_idx = (i + rnd[i & 7]) % mi->n_rates; -- while (SAMPLE_TBL(mi, new_idx, col) != 0xff) -- new_idx = (new_idx + 1) % mi->n_rates; -- -- SAMPLE_TBL(mi, new_idx, col) = i; -- } -- } --} -- --static void --minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, -- struct cfg80211_chan_def *chandef, -- struct ieee80211_sta *sta, void *priv_sta) --{ -- struct minstrel_sta_info *mi = priv_sta; -- struct minstrel_priv *mp = priv; -- struct ieee80211_rate *ctl_rate; -- unsigned int i, n = 0; -- unsigned int t_slot = 9; /* FIXME: get real slot time */ -- u32 rate_flags; -- -- mi->sta = sta; -- mi->lowest_rix = rate_lowest_index(sband, sta); -- ctl_rate = &sband->bitrates[mi->lowest_rix]; -- mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10, -- ctl_rate->bitrate, -- !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1, -- ieee80211_chandef_get_shift(chandef)); -- -- rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef); -- memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate)); -- mi->max_prob_rate = 0; -- -- for (i = 0; i < sband->n_bitrates; i++) { -- struct minstrel_rate *mr = &mi->r[n]; -- struct minstrel_rate_stats *mrs = &mi->r[n].stats; -- unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0; -- unsigned int tx_time_single; -- unsigned int cw = mp->cw_min; -- int shift; -- -- if (!rate_supported(sta, sband->band, i)) -- continue; -- if ((rate_flags & sband->bitrates[i].flags) != rate_flags) -- continue; -- -- n++; -- memset(mr, 0, sizeof(*mr)); -- memset(mrs, 0, sizeof(*mrs)); -- -- mr->rix = i; -- shift = ieee80211_chandef_get_shift(chandef); -- mr->bitrate = DIV_ROUND_UP(sband->bitrates[i].bitrate, -- (1 << shift) * 5); -- calc_rate_durations(sband->band, mr, &sband->bitrates[i], -- chandef); -- -- /* calculate maximum number of retransmissions before -- * fallback (based on maximum segment size) */ -- mr->sample_limit = -1; -- mrs->retry_count = 1; -- mr->retry_count_cts = 1; -- mrs->retry_count_rtscts = 1; -- tx_time = mr->perfect_tx_time + mi->sp_ack_dur; -- do { -- /* add one retransmission */ -- tx_time_single = mr->ack_time + mr->perfect_tx_time; -- -- /* contention window */ -- tx_time_single += (t_slot * cw) >> 1; -- cw = min((cw << 1) | 1, mp->cw_max); -- -- tx_time += tx_time_single; -- tx_time_cts += tx_time_single + mi->sp_ack_dur; -- tx_time_rtscts += tx_time_single + 2 * mi->sp_ack_dur; -- if ((tx_time_cts < mp->segment_size) && -- (mr->retry_count_cts < mp->max_retry)) -- mr->retry_count_cts++; -- if ((tx_time_rtscts < mp->segment_size) && -- (mrs->retry_count_rtscts < mp->max_retry)) -- mrs->retry_count_rtscts++; -- } while ((tx_time < mp->segment_size) && -- (++mr->stats.retry_count < mp->max_retry)); -- mr->adjusted_retry_count = mrs->retry_count; -- if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G)) -- mr->retry_count_cts = mrs->retry_count; -- } -- -- for (i = n; i < sband->n_bitrates; i++) { -- struct minstrel_rate *mr = &mi->r[i]; -- mr->rix = -1; -- } -- -- mi->n_rates = n; -- mi->last_stats_update = jiffies; -- -- init_sample_table(mi); -- minstrel_update_rates(mp, mi); --} -- --static u32 minstrel_get_expected_throughput(void *priv_sta) --{ -- struct minstrel_sta_info *mi = priv_sta; -- struct minstrel_rate_stats *tmp_mrs; -- int idx = mi->max_tp_rate[0]; -- int tmp_cur_tp; -- -- /* convert pkt per sec in kbps (1200 is the average pkt size used for -- * computing cur_tp -- */ -- tmp_mrs = &mi->r[idx].stats; -- tmp_cur_tp = minstrel_get_tp_avg(&mi->r[idx], tmp_mrs->prob_avg) * 10; -- tmp_cur_tp = tmp_cur_tp * 1200 * 8 / 1024; -- -- return tmp_cur_tp; --} -- --const struct rate_control_ops mac80211_minstrel = { -- .tx_status_ext = minstrel_tx_status, -- .get_rate = minstrel_get_rate, -- .rate_init = minstrel_rate_init, -- .get_expected_throughput = minstrel_get_expected_throughput, --}; ---- a/net/mac80211/rc80211_minstrel.h -+++ /dev/null -@@ -1,185 +0,0 @@ --/* SPDX-License-Identifier: GPL-2.0-only */ --/* -- * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org> -- */ -- --#ifndef __RC_MINSTREL_H --#define __RC_MINSTREL_H -- --#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */ --#define EWMA_DIV 128 --#define SAMPLE_COLUMNS 10 /* number of columns in sample table */ -- --/* scaled fraction values */ --#define MINSTREL_SCALE 12 --#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) --#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) -- --/* number of highest throughput rates to consider*/ --#define MAX_THR_RATES 4 -- --/* -- * Coefficients for moving average with noise filter (period=16), -- * scaled by 10 bits -- * -- * a1 = exp(-pi * sqrt(2) / period) -- * coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period) -- * coeff3 = -sqr(a1) -- * coeff1 = 1 - coeff2 - coeff3 -- */ --#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \ -- MINSTREL_AVG_COEFF2 - \ -- MINSTREL_AVG_COEFF3) --#define MINSTREL_AVG_COEFF2 0x00001499 --#define MINSTREL_AVG_COEFF3 -0x0000092e -- --/* -- * Perform EWMA (Exponentially Weighted Moving Average) calculation -- */ --static inline int --minstrel_ewma(int old, int new, int weight) --{ -- int diff, incr; -- -- diff = new - old; -- incr = (EWMA_DIV - weight) * diff / EWMA_DIV; -- -- return old + incr; --} -- --static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in) --{ -- s32 out_1 = *prev_1; -- s32 out_2 = *prev_2; -- s32 val; -- -- if (!in) -- in += 1; -- -- if (!out_1) { -- val = out_1 = in; -- goto out; -- } -- -- val = MINSTREL_AVG_COEFF1 * in; -- val += MINSTREL_AVG_COEFF2 * out_1; -- val += MINSTREL_AVG_COEFF3 * out_2; -- val >>= MINSTREL_SCALE; -- -- if (val > 1 << MINSTREL_SCALE) -- val = 1 << MINSTREL_SCALE; -- if (val < 0) -- val = 1; -- --out: -- *prev_2 = out_1; -- *prev_1 = val; -- -- return val; --} -- --struct minstrel_rate_stats { -- /* current / last sampling period attempts/success counters */ -- u16 attempts, last_attempts; -- u16 success, last_success; -- -- /* total attempts/success counters */ -- u32 att_hist, succ_hist; -- -- /* prob_avg - moving average of prob */ -- u16 prob_avg; -- u16 prob_avg_1; -- -- /* maximum retry counts */ -- u8 retry_count; -- u8 retry_count_rtscts; -- -- u8 sample_skipped; -- bool retry_updated; --}; -- --struct minstrel_rate { -- int bitrate; -- -- s8 rix; -- u8 retry_count_cts; -- u8 adjusted_retry_count; -- -- unsigned int perfect_tx_time; -- unsigned int ack_time; -- -- int sample_limit; -- -- struct minstrel_rate_stats stats; --}; -- --struct minstrel_sta_info { -- struct ieee80211_sta *sta; -- -- unsigned long last_stats_update; -- unsigned int sp_ack_dur; -- unsigned int rate_avg; -- -- unsigned int lowest_rix; -- -- u8 max_tp_rate[MAX_THR_RATES]; -- u8 max_prob_rate; -- unsigned int total_packets; -- unsigned int sample_packets; -- -- unsigned int sample_row; -- unsigned int sample_column; -- -- int n_rates; -- struct minstrel_rate *r; -- bool prev_sample; -- -- /* sampling table */ -- u8 *sample_table; --}; -- --struct minstrel_priv { -- struct ieee80211_hw *hw; -- bool has_mrr; -- bool new_avg; -- u32 sample_switch; -- unsigned int cw_min; -- unsigned int cw_max; -- unsigned int max_retry; -- unsigned int segment_size; -- unsigned int update_interval; -- unsigned int lookaround_rate; -- unsigned int lookaround_rate_mrr; -- -- u8 cck_rates[4]; -- u8 ofdm_rates[NUM_NL80211_BANDS][8]; -- --#ifdef CPTCFG_MAC80211_DEBUGFS -- /* -- * enable fixed rate processing per RC -- * - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx -- * - write -1 to enable RC processing again -- * - setting will be applied on next update -- */ -- u32 fixed_rate_idx; --#endif --}; -- --struct minstrel_debugfs_info { -- size_t len; -- char buf[]; --}; -- --extern const struct rate_control_ops mac80211_minstrel; --void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); -- --/* Recalculate success probabilities and counters for a given rate using EWMA */ --void minstrel_calc_rate_stats(struct minstrel_priv *mp, -- struct minstrel_rate_stats *mrs); --int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg); -- --/* debugfs */ --int minstrel_stats_open(struct inode *inode, struct file *file); --int minstrel_stats_csv_open(struct inode *inode, struct file *file); -- --#endif ---- a/net/mac80211/rc80211_minstrel_debugfs.c -+++ /dev/null -@@ -1,172 +0,0 @@ --/* -- * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org> -- * -- * 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. -- * -- * Based on minstrel.c: -- * Copyright (C) 2005-2007 Derek Smithies <derek@indranet.co.nz> -- * Sponsored by Indranet Technologies Ltd -- * -- * Based on sample.c: -- * Copyright (c) 2005 John Bicket -- * All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer, -- * without modification. -- * 2. Redistributions in binary form must reproduce at minimum a disclaimer -- * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any -- * redistribution must be conditioned upon including a substantially -- * similar Disclaimer requirement for further binary redistribution. -- * 3. Neither the names of the above-listed copyright holders nor the names -- * of any contributors may be used to endorse or promote products derived -- * from this software without specific prior written permission. -- * -- * Alternatively, this software may be distributed under the terms of the -- * GNU General Public License ("GPL") version 2 as published by the Free -- * Software Foundation. -- * -- * NO WARRANTY -- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY -- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -- * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -- * THE POSSIBILITY OF SUCH DAMAGES. -- */ --#include <linux/netdevice.h> --#include <linux/types.h> --#include <linux/skbuff.h> --#include <linux/debugfs.h> --#include <linux/ieee80211.h> --#include <linux/slab.h> --#include <linux/export.h> --#include <net/mac80211.h> --#include "rc80211_minstrel.h" -- --int --minstrel_stats_open(struct inode *inode, struct file *file) --{ -- struct minstrel_sta_info *mi = inode->i_private; -- struct minstrel_debugfs_info *ms; -- unsigned int i, tp_max, tp_avg, eprob; -- char *p; -- -- ms = kmalloc(2048, GFP_KERNEL); -- if (!ms) -- return -ENOMEM; -- -- file->private_data = ms; -- p = ms->buf; -- p += sprintf(p, "\n"); -- p += sprintf(p, -- "best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n"); -- p += sprintf(p, -- "rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n"); -- -- for (i = 0; i < mi->n_rates; i++) { -- struct minstrel_rate *mr = &mi->r[i]; -- struct minstrel_rate_stats *mrs = &mi->r[i].stats; -- -- *(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' '; -- *(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' '; -- *(p++) = (i == mi->max_tp_rate[2]) ? 'C' : ' '; -- *(p++) = (i == mi->max_tp_rate[3]) ? 'D' : ' '; -- *(p++) = (i == mi->max_prob_rate) ? 'P' : ' '; -- -- p += sprintf(p, " %3u%s ", mr->bitrate / 2, -- (mr->bitrate & 1 ? ".5" : " ")); -- p += sprintf(p, "%3u ", i); -- p += sprintf(p, "%6u ", mr->perfect_tx_time); -- -- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100)); -- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg); -- eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000); -- -- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" -- " %3u %3u %-3u " -- "%9llu %-9llu\n", -- tp_max / 10, tp_max % 10, -- tp_avg / 10, tp_avg % 10, -- eprob / 10, eprob % 10, -- mrs->retry_count, -- mrs->last_success, -- mrs->last_attempts, -- (unsigned long long)mrs->succ_hist, -- (unsigned long long)mrs->att_hist); -- } -- p += sprintf(p, "\nTotal packet count:: ideal %d " -- "lookaround %d\n\n", -- mi->total_packets - mi->sample_packets, -- mi->sample_packets); -- ms->len = p - ms->buf; -- -- WARN_ON(ms->len + sizeof(*ms) > 2048); -- -- return 0; --} -- --int --minstrel_stats_csv_open(struct inode *inode, struct file *file) --{ -- struct minstrel_sta_info *mi = inode->i_private; -- struct minstrel_debugfs_info *ms; -- unsigned int i, tp_max, tp_avg, eprob; -- char *p; -- -- ms = kmalloc(2048, GFP_KERNEL); -- if (!ms) -- return -ENOMEM; -- -- file->private_data = ms; -- p = ms->buf; -- -- for (i = 0; i < mi->n_rates; i++) { -- struct minstrel_rate *mr = &mi->r[i]; -- struct minstrel_rate_stats *mrs = &mi->r[i].stats; -- -- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[0]) ? "A" : "")); -- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[1]) ? "B" : "")); -- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[2]) ? "C" : "")); -- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[3]) ? "D" : "")); -- p += sprintf(p, "%s" ,((i == mi->max_prob_rate) ? "P" : "")); -- -- p += sprintf(p, ",%u%s", mr->bitrate / 2, -- (mr->bitrate & 1 ? ".5," : ",")); -- p += sprintf(p, "%u,", i); -- p += sprintf(p, "%u,",mr->perfect_tx_time); -- -- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100)); -- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg); -- eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000); -- -- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u," -- "%llu,%llu,%d,%d\n", -- tp_max / 10, tp_max % 10, -- tp_avg / 10, tp_avg % 10, -- eprob / 10, eprob % 10, -- mrs->retry_count, -- mrs->last_success, -- mrs->last_attempts, -- (unsigned long long)mrs->succ_hist, -- (unsigned long long)mrs->att_hist, -- mi->total_packets - mi->sample_packets, -- mi->sample_packets); -- -- } -- ms->len = p - ms->buf; -- -- WARN_ON(ms->len + sizeof(*ms) > 2048); -- -- return 0; --} ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -13,7 +13,6 @@ - #include <net/mac80211.h> - #include "rate.h" - #include "sta_info.h" --#include "rc80211_minstrel.h" - #include "rc80211_minstrel_ht.h" - - #define AVG_AMPDU_SIZE 16 -@@ -716,6 +715,83 @@ out: - mi->sample_mode = MINSTREL_SAMPLE_ACTIVE; - } - -+static inline int -+minstrel_ewma(int old, int new, int weight) -+{ -+ int diff, incr; -+ -+ diff = new - old; -+ incr = (EWMA_DIV - weight) * diff / EWMA_DIV; -+ -+ return old + incr; -+} -+ -+static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in) -+{ -+ s32 out_1 = *prev_1; -+ s32 out_2 = *prev_2; -+ s32 val; -+ -+ if (!in) -+ in += 1; -+ -+ if (!out_1) { -+ val = out_1 = in; -+ goto out; -+ } -+ -+ val = MINSTREL_AVG_COEFF1 * in; -+ val += MINSTREL_AVG_COEFF2 * out_1; -+ val += MINSTREL_AVG_COEFF3 * out_2; -+ val >>= MINSTREL_SCALE; -+ -+ if (val > 1 << MINSTREL_SCALE) -+ val = 1 << MINSTREL_SCALE; -+ if (val < 0) -+ val = 1; -+ -+out: -+ *prev_2 = out_1; -+ *prev_1 = val; -+ -+ return val; -+} -+ -+/* -+* Recalculate statistics and counters of a given rate -+*/ -+static void -+minstrel_ht_calc_rate_stats(struct minstrel_priv *mp, -+ struct minstrel_rate_stats *mrs) -+{ -+ unsigned int cur_prob; -+ -+ if (unlikely(mrs->attempts > 0)) { -+ mrs->sample_skipped = 0; -+ cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); -+ if (mp->new_avg) { -+ minstrel_filter_avg_add(&mrs->prob_avg, -+ &mrs->prob_avg_1, cur_prob); -+ } else if (unlikely(!mrs->att_hist)) { -+ mrs->prob_avg = cur_prob; -+ } else { -+ /*update exponential weighted moving avarage */ -+ mrs->prob_avg = minstrel_ewma(mrs->prob_avg, -+ cur_prob, -+ EWMA_LEVEL); -+ } -+ mrs->att_hist += mrs->attempts; -+ mrs->succ_hist += mrs->success; -+ } else { -+ mrs->sample_skipped++; -+ } -+ -+ mrs->last_success = mrs->success; -+ mrs->last_attempts = mrs->attempts; -+ mrs->success = 0; -+ mrs->attempts = 0; -+} -+ - /* - * Update rate statistics and select new primary rates - * -@@ -808,7 +884,7 @@ minstrel_ht_update_stats(struct minstrel - - mrs = &mg->rates[i]; - mrs->retry_updated = false; -- minstrel_calc_rate_stats(mp, mrs); -+ minstrel_ht_calc_rate_stats(mp, mrs); - cur_prob = mrs->prob_avg; - - if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) -@@ -960,8 +1036,7 @@ minstrel_ht_tx_status(void *priv, struct - void *priv_sta, struct ieee80211_tx_status *st) - { - struct ieee80211_tx_info *info = st->info; -- struct minstrel_ht_sta_priv *msp = priv_sta; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = priv_sta; - struct ieee80211_tx_rate *ar = info->status.rates; - struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL; - struct minstrel_priv *mp = priv; -@@ -1372,8 +1447,7 @@ minstrel_ht_get_rate(void *priv, struct - const struct mcs_group *sample_group; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); - struct ieee80211_tx_rate *rate = &info->status.rates[0]; -- struct minstrel_ht_sta_priv *msp = priv_sta; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = priv_sta; - struct minstrel_priv *mp = priv; - int sample_idx; - -@@ -1484,8 +1558,7 @@ minstrel_ht_update_caps(void *priv, stru - struct ieee80211_sta *sta, void *priv_sta) - { - struct minstrel_priv *mp = priv; -- struct minstrel_ht_sta_priv *msp = priv_sta; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = priv_sta; - struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; - u16 ht_cap = sta->ht_cap.cap; - struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; -@@ -1647,7 +1720,7 @@ static void * - minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) - { - struct ieee80211_supported_band *sband; -- struct minstrel_ht_sta_priv *msp; -+ struct minstrel_ht_sta *mi; - struct minstrel_priv *mp = priv; - struct ieee80211_hw *hw = mp->hw; - int max_rates = 0; -@@ -1659,35 +1732,13 @@ minstrel_ht_alloc_sta(void *priv, struct - max_rates = sband->n_bitrates; - } - -- msp = kzalloc(sizeof(*msp), gfp); -- if (!msp) -- return NULL; -- -- msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp); -- if (!msp->ratelist) -- goto error; -- -- msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp); -- if (!msp->sample_table) -- goto error1; -- -- return msp; -- --error1: -- kfree(msp->ratelist); --error: -- kfree(msp); -- return NULL; -+ return kzalloc(sizeof(*mi), gfp); - } - - static void - minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta) - { -- struct minstrel_ht_sta_priv *msp = priv_sta; -- -- kfree(msp->sample_table); -- kfree(msp->ratelist); -- kfree(msp); -+ kfree(priv_sta); - } - - static void -@@ -1768,12 +1819,6 @@ minstrel_ht_alloc(struct ieee80211_hw *h - mp->cw_min = 15; - mp->cw_max = 1023; - -- /* number of packets (in %) to use for sampling other rates -- * sample less often for non-mrr packets, because the overhead -- * is much higher than with mrr */ -- mp->lookaround_rate = 5; -- mp->lookaround_rate_mrr = 10; -- - /* maximum time that the hw is allowed to stay in one MRR segment */ - mp->segment_size = 6000; - -@@ -1821,8 +1866,7 @@ minstrel_ht_free(void *priv) - - static u32 minstrel_ht_get_expected_throughput(void *priv_sta) - { -- struct minstrel_ht_sta_priv *msp = priv_sta; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = priv_sta; - int i, j, prob, tp_avg; - - i = mi->max_tp_rate[0] / MCS_GROUP_RATES; ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -6,6 +6,33 @@ - #ifndef __RC_MINSTREL_HT_H - #define __RC_MINSTREL_HT_H - -+/* number of highest throughput rates to consider*/ -+#define MAX_THR_RATES 4 -+#define SAMPLE_COLUMNS 10 /* number of columns in sample table */ -+ -+/* scaled fraction values */ -+#define MINSTREL_SCALE 12 -+#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) -+#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) -+ -+#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */ -+#define EWMA_DIV 128 -+ -+/* -+ * Coefficients for moving average with noise filter (period=16), -+ * scaled by 10 bits -+ * -+ * a1 = exp(-pi * sqrt(2) / period) -+ * coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period) -+ * coeff3 = -sqr(a1) -+ * coeff1 = 1 - coeff2 - coeff3 -+ */ -+#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \ -+ MINSTREL_AVG_COEFF2 - \ -+ MINSTREL_AVG_COEFF3) -+#define MINSTREL_AVG_COEFF2 0x00001499 -+#define MINSTREL_AVG_COEFF3 -0x0000092e -+ - /* - * The number of streams can be changed to 2 to reduce code - * size and memory footprint. -@@ -30,6 +57,32 @@ - - #define MCS_GROUP_RATES 10 - -+struct minstrel_priv { -+ struct ieee80211_hw *hw; -+ bool has_mrr; -+ bool new_avg; -+ u32 sample_switch; -+ unsigned int cw_min; -+ unsigned int cw_max; -+ unsigned int max_retry; -+ unsigned int segment_size; -+ unsigned int update_interval; -+ -+ u8 cck_rates[4]; -+ u8 ofdm_rates[NUM_NL80211_BANDS][8]; -+ -+#ifdef CPTCFG_MAC80211_DEBUGFS -+ /* -+ * enable fixed rate processing per RC -+ * - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx -+ * - write -1 to enable RC processing again -+ * - setting will be applied on next update -+ */ -+ u32 fixed_rate_idx; -+#endif -+}; -+ -+ - struct mcs_group { - u16 flags; - u8 streams; -@@ -42,6 +95,26 @@ extern const s16 minstrel_cck_bitrates[4 - extern const s16 minstrel_ofdm_bitrates[8]; - extern const struct mcs_group minstrel_mcs_groups[]; - -+struct minstrel_rate_stats { -+ /* current / last sampling period attempts/success counters */ -+ u16 attempts, last_attempts; -+ u16 success, last_success; -+ -+ /* total attempts/success counters */ -+ u32 att_hist, succ_hist; -+ -+ /* prob_avg - moving average of prob */ -+ u16 prob_avg; -+ u16 prob_avg_1; -+ -+ /* maximum retry counts */ -+ u8 retry_count; -+ u8 retry_count_rtscts; -+ -+ u8 sample_skipped; -+ bool retry_updated; -+}; -+ - struct minstrel_mcs_group_data { - u8 index; - u8 column; -@@ -111,12 +184,6 @@ struct minstrel_ht_sta { - struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB]; - }; - --struct minstrel_ht_sta_priv { -- struct minstrel_ht_sta ht; -- void *ratelist; -- void *sample_table; --}; -- - void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); - int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, - int prob_avg); ---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c -+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c -@@ -9,9 +9,13 @@ - #include <linux/ieee80211.h> - #include <linux/export.h> - #include <net/mac80211.h> --#include "rc80211_minstrel.h" - #include "rc80211_minstrel_ht.h" - -+struct minstrel_debugfs_info { -+ size_t len; -+ char buf[]; -+}; -+ - static ssize_t - minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos) - { -@@ -127,8 +131,7 @@ minstrel_ht_stats_dump(struct minstrel_h - static int - minstrel_ht_stats_open(struct inode *inode, struct file *file) - { -- struct minstrel_ht_sta_priv *msp = inode->i_private; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = inode->i_private; - struct minstrel_debugfs_info *ms; - unsigned int i; - char *p; -@@ -276,8 +279,7 @@ minstrel_ht_stats_csv_dump(struct minstr - static int - minstrel_ht_stats_csv_open(struct inode *inode, struct file *file) - { -- struct minstrel_ht_sta_priv *msp = inode->i_private; -- struct minstrel_ht_sta *mi = &msp->ht; -+ struct minstrel_ht_sta *mi = inode->i_private; - struct minstrel_debugfs_info *ms; - unsigned int i; - char *p; -@@ -313,10 +315,8 @@ static const struct file_operations mins - void - minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir) - { -- struct minstrel_ht_sta_priv *msp = priv_sta; -- -- debugfs_create_file("rc_stats", 0444, dir, msp, -+ debugfs_create_file("rc_stats", 0444, dir, priv_sta, - &minstrel_ht_stat_fops); -- debugfs_create_file("rc_stats_csv", 0444, dir, msp, -+ debugfs_create_file("rc_stats_csv", 0444, dir, priv_sta, - &minstrel_ht_stat_csv_fops); - } diff --git a/package/kernel/mac80211/patches/subsys/340-mac80211-minstrel_ht-remove-old-ewma-based-rate-aver.patch b/package/kernel/mac80211/patches/subsys/340-mac80211-minstrel_ht-remove-old-ewma-based-rate-aver.patch deleted file mode 100644 index 9b6a614aa83..00000000000 --- a/package/kernel/mac80211/patches/subsys/340-mac80211-minstrel_ht-remove-old-ewma-based-rate-aver.patch +++ /dev/null @@ -1,96 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 14:34:30 +0100 -Subject: [PATCH] mac80211: minstrel_ht: remove old ewma based rate average - code - -The new noise filter has been the default for a while now with no reported -downside and significant improvement compared to the old code. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -769,17 +769,8 @@ minstrel_ht_calc_rate_stats(struct minst - if (unlikely(mrs->attempts > 0)) { - mrs->sample_skipped = 0; - cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); -- if (mp->new_avg) { -- minstrel_filter_avg_add(&mrs->prob_avg, -- &mrs->prob_avg_1, cur_prob); -- } else if (unlikely(!mrs->att_hist)) { -- mrs->prob_avg = cur_prob; -- } else { -- /*update exponential weighted moving avarage */ -- mrs->prob_avg = minstrel_ewma(mrs->prob_avg, -- cur_prob, -- EWMA_LEVEL); -- } -+ minstrel_filter_avg_add(&mrs->prob_avg, -+ &mrs->prob_avg_1, cur_prob); - mrs->att_hist += mrs->attempts; - mrs->succ_hist += mrs->success; - } else { -@@ -913,10 +904,8 @@ minstrel_ht_update_stats(struct minstrel - /* Try to increase robustness of max_prob_rate*/ - minstrel_ht_prob_rate_reduce_streams(mi); - -- /* try to sample all available rates during each interval */ -- mi->sample_count *= 8; -- if (mp->new_avg) -- mi->sample_count /= 2; -+ /* try to sample half of all available rates during each interval */ -+ mi->sample_count *= 4; - - if (sample) - minstrel_ht_rate_sample_switch(mp, mi); -@@ -1040,7 +1029,7 @@ minstrel_ht_tx_status(void *priv, struct - struct ieee80211_tx_rate *ar = info->status.rates; - struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL; - struct minstrel_priv *mp = priv; -- u32 update_interval = mp->update_interval / 2; -+ u32 update_interval = mp->update_interval; - bool last, update = false; - bool sample_status = false; - int i; -@@ -1090,9 +1079,8 @@ minstrel_ht_tx_status(void *priv, struct - - switch (mi->sample_mode) { - case MINSTREL_SAMPLE_IDLE: -- if (mp->new_avg && -- (mp->hw->max_rates > 1 || -- mi->total_packets_cur < SAMPLE_SWITCH_THR)) -+ if (mp->hw->max_rates > 1 || -+ mi->total_packets_cur < SAMPLE_SWITCH_THR) - update_interval /= 2; - break; - -@@ -1832,8 +1820,7 @@ minstrel_ht_alloc(struct ieee80211_hw *h - mp->has_mrr = true; - - mp->hw = hw; -- mp->update_interval = HZ / 10; -- mp->new_avg = true; -+ mp->update_interval = HZ / 20; - - minstrel_ht_init_cck_rates(mp); - for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++) -@@ -1853,8 +1840,6 @@ static void minstrel_ht_add_debugfs(stru - &mp->fixed_rate_idx); - debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir, - &mp->sample_switch); -- debugfs_create_bool("new_avg", S_IRUGO | S_IWUSR, debugfsdir, -- &mp->new_avg); - } - #endif - ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -60,7 +60,6 @@ - struct minstrel_priv { - struct ieee80211_hw *hw; - bool has_mrr; -- bool new_avg; - u32 sample_switch; - unsigned int cw_min; - unsigned int cw_max; diff --git a/package/kernel/mac80211/patches/subsys/341-mac80211-minstrel_ht-improve-ampdu-length-estimation.patch b/package/kernel/mac80211/patches/subsys/341-mac80211-minstrel_ht-improve-ampdu-length-estimation.patch deleted file mode 100644 index a8e6e899544..00000000000 --- a/package/kernel/mac80211/patches/subsys/341-mac80211-minstrel_ht-improve-ampdu-length-estimation.patch +++ /dev/null @@ -1,67 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 19:08:19 +0100 -Subject: [PATCH] mac80211: minstrel_ht: improve ampdu length estimation - -If the driver does not report A-MPDU length, estimate it based on the rate. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -382,13 +382,37 @@ minstrel_get_ratestats(struct minstrel_h - return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; - } - -+static inline int -+minstrel_get_duration(int index) -+{ -+ const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; -+ unsigned int duration = group->duration[index % MCS_GROUP_RATES]; -+ return duration << group->shift; -+} -+ - static unsigned int - minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi) - { -- if (!mi->avg_ampdu_len) -- return AVG_AMPDU_SIZE; -+ int duration; -+ -+ if (mi->avg_ampdu_len) -+ return MINSTREL_TRUNC(mi->avg_ampdu_len); -+ -+ if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES)) -+ return 1; -+ -+ duration = minstrel_get_duration(mi->max_tp_rate[0]); - -- return MINSTREL_TRUNC(mi->avg_ampdu_len); -+ if (duration > 400 * 1000) -+ return 2; -+ -+ if (duration > 250 * 1000) -+ return 4; -+ -+ if (duration > 150 * 1000) -+ return 8; -+ -+ return 16; - } - - /* -@@ -588,14 +612,6 @@ minstrel_ht_prob_rate_reduce_streams(str - } - } - --static inline int --minstrel_get_duration(int index) --{ -- const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; -- unsigned int duration = group->duration[index % MCS_GROUP_RATES]; -- return duration << group->shift; --} -- - static bool - minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group, - int tp_idx, const struct mcs_group *group) diff --git a/package/kernel/mac80211/patches/subsys/342-mac80211-minstrel_ht-improve-sample-rate-selection.patch b/package/kernel/mac80211/patches/subsys/342-mac80211-minstrel_ht-improve-sample-rate-selection.patch deleted file mode 100644 index e0845252354..00000000000 --- a/package/kernel/mac80211/patches/subsys/342-mac80211-minstrel_ht-improve-sample-rate-selection.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 19:12:22 +0100 -Subject: [PATCH] mac80211: minstrel_ht: improve sample rate selection - -Always allow sampling of rates faster than the primary max throughput rate. -When the second max_tp_rate is higher than the first one, sample attempts were -previously skipped, potentially causing rate control to get stuck at a slightly -lower rate - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -1379,13 +1379,13 @@ minstrel_get_sample_rate(struct minstrel - mrs = &mg->rates[sample_idx]; - sample_idx += sample_group * MCS_GROUP_RATES; - -- /* Set tp_rate1, tp_rate2 to the highest / second highest max_tp_rate */ -+ tp_rate1 = mi->max_tp_rate[0]; -+ -+ /* Set tp_rate2 to the second highest max_tp_rate */ - if (minstrel_get_duration(mi->max_tp_rate[0]) > - minstrel_get_duration(mi->max_tp_rate[1])) { -- tp_rate1 = mi->max_tp_rate[1]; - tp_rate2 = mi->max_tp_rate[0]; - } else { -- tp_rate1 = mi->max_tp_rate[0]; - tp_rate2 = mi->max_tp_rate[1]; - } - diff --git a/package/kernel/mac80211/patches/subsys/343-mac80211-minstrel_ht-fix-max-probability-rate-select.patch b/package/kernel/mac80211/patches/subsys/343-mac80211-minstrel_ht-fix-max-probability-rate-select.patch deleted file mode 100644 index 0dbfa9d4fb4..00000000000 --- a/package/kernel/mac80211/patches/subsys/343-mac80211-minstrel_ht-fix-max-probability-rate-select.patch +++ /dev/null @@ -1,124 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 19:09:08 +0100 -Subject: [PATCH] mac80211: minstrel_ht: fix max probability rate selection - -- do not select rates faster than the max throughput rate if probability is lower -- reset previous rate before sorting again - -This ensures that the max prob rate gets set to a more reliable rate - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -495,12 +495,13 @@ minstrel_ht_sort_best_tp_rates(struct mi - * Find and set the topmost probability rate per sta and per group - */ - static void --minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index) -+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 *dest, u16 index) - { - struct minstrel_mcs_group_data *mg; - struct minstrel_rate_stats *mrs; - int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob; -- int max_tp_group, cur_tp_avg, cur_group, cur_idx; -+ int max_tp_group, max_tp_idx, max_tp_prob; -+ int cur_tp_avg, cur_group, cur_idx; - int max_gpr_group, max_gpr_idx; - int max_gpr_tp_avg, max_gpr_prob; - -@@ -509,18 +510,26 @@ minstrel_ht_set_best_prob_rate(struct mi - mg = &mi->groups[index / MCS_GROUP_RATES]; - mrs = &mg->rates[index % MCS_GROUP_RATES]; - -- tmp_group = mi->max_prob_rate / MCS_GROUP_RATES; -- tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES; -+ tmp_group = *dest / MCS_GROUP_RATES; -+ tmp_idx = *dest % MCS_GROUP_RATES; - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); - - /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from - * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ - max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES; -+ max_tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES; -+ max_tp_prob = mi->groups[max_tp_group].rates[max_tp_idx].prob_avg; -+ - if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) && - !minstrel_ht_is_legacy_group(max_tp_group)) - return; - -+ /* skip rates faster than max tp rate with lower prob */ -+ if (minstrel_get_duration(mi->max_tp_rate[0]) > minstrel_get_duration(index) && -+ mrs->prob_avg < max_tp_prob) -+ return; -+ - max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES; - max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; - max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_avg; -@@ -538,7 +547,7 @@ minstrel_ht_set_best_prob_rate(struct mi - mg->max_group_prob_rate = index; - } else { - if (mrs->prob_avg > tmp_prob) -- mi->max_prob_rate = index; -+ *dest = index; - if (mrs->prob_avg > max_gpr_prob) - mg->max_group_prob_rate = index; - } -@@ -816,7 +825,8 @@ minstrel_ht_update_stats(struct minstrel - struct minstrel_rate_stats *mrs; - int group, i, j, cur_prob; - u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES]; -- u16 tmp_legacy_tp_rate[MAX_THR_RATES], index; -+ u16 tmp_legacy_tp_rate[MAX_THR_RATES], tmp_max_prob_rate; -+ u16 index; - bool ht_supported = mi->sta->ht_cap.ht_supported; - - mi->sample_mode = MINSTREL_SAMPLE_IDLE; -@@ -863,6 +873,7 @@ minstrel_ht_update_stats(struct minstrel - else - index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; - -+ tmp_max_prob_rate = index; - for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++) - tmp_mcs_tp_rate[j] = index; - -@@ -903,9 +914,6 @@ minstrel_ht_update_stats(struct minstrel - /* Find max throughput rate set within a group */ - minstrel_ht_sort_best_tp_rates(mi, index, - tmp_group_tp_rate); -- -- /* Find max probability rate per group and global */ -- minstrel_ht_set_best_prob_rate(mi, index); - } - - memcpy(mg->max_group_tp_rate, tmp_group_tp_rate, -@@ -917,6 +925,27 @@ minstrel_ht_update_stats(struct minstrel - tmp_legacy_tp_rate); - memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate)); - -+ for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { -+ if (!mi->supported[group]) -+ continue; -+ -+ mg = &mi->groups[group]; -+ mg->max_group_prob_rate = MCS_GROUP_RATES * group; -+ -+ for (i = 0; i < MCS_GROUP_RATES; i++) { -+ if (!(mi->supported[group] & BIT(i))) -+ continue; -+ -+ index = MCS_GROUP_RATES * group + i; -+ -+ /* Find max probability rate per group and global */ -+ minstrel_ht_set_best_prob_rate(mi, &tmp_max_prob_rate, -+ index); -+ } -+ } -+ -+ mi->max_prob_rate = tmp_max_prob_rate; -+ - /* Try to increase robustness of max_prob_rate*/ - minstrel_ht_prob_rate_reduce_streams(mi); - diff --git a/package/kernel/mac80211/patches/subsys/344-mac80211-minstrel_ht-increase-stats-update-interval.patch b/package/kernel/mac80211/patches/subsys/344-mac80211-minstrel_ht-increase-stats-update-interval.patch deleted file mode 100644 index 9972a9414e2..00000000000 --- a/package/kernel/mac80211/patches/subsys/344-mac80211-minstrel_ht-increase-stats-update-interval.patch +++ /dev/null @@ -1,20 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 26 Dec 2020 19:14:58 +0100 -Subject: [PATCH] mac80211: minstrel_ht: increase stats update interval - -The shorter interval was leading to too many frames being used for probing - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -1865,7 +1865,7 @@ minstrel_ht_alloc(struct ieee80211_hw *h - mp->has_mrr = true; - - mp->hw = hw; -- mp->update_interval = HZ / 20; -+ mp->update_interval = HZ / 10; - - minstrel_ht_init_cck_rates(mp); - for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++) diff --git a/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch b/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch deleted file mode 100644 index 1df5dec0394..00000000000 --- a/package/kernel/mac80211/patches/subsys/345-mac80211-minstrel_ht-fix-rounding-error-in-throughpu.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 15 Jan 2021 12:15:06 +0100 -Subject: [PATCH] mac80211: minstrel_ht: fix rounding error in throughput - calculation - -On lower data rates, the throughput calculation has a significant rounding -error, causing rates like 48M and 54M OFDM to share the same throughput -value with >= 90% success probablity. - -This is because the result of the division (prob_avg * 1000) / nsecs -is really small (8 in this example). - -Improve accuracy by moving over some zeroes, making better use of the full -range of u32 before the division. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -445,10 +445,9 @@ minstrel_ht_get_tp_avg(struct minstrel_h - * (prob is scaled - see MINSTREL_FRAC above) - */ - if (prob_avg > MINSTREL_FRAC(90, 100)) -- return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000) -- / nsecs)); -- else -- return MINSTREL_TRUNC(100000 * ((prob_avg * 1000) / nsecs)); -+ prob_avg = MINSTREL_FRAC(90, 100); -+ -+ return MINSTREL_TRUNC(100 * ((prob_avg * 1000000) / nsecs)); - } - - /* diff --git a/package/kernel/mac80211/patches/subsys/346-mac80211-minstrel_ht-use-bitfields-to-encode-rate-in.patch b/package/kernel/mac80211/patches/subsys/346-mac80211-minstrel_ht-use-bitfields-to-encode-rate-in.patch deleted file mode 100644 index 6aa6f0ed934..00000000000 --- a/package/kernel/mac80211/patches/subsys/346-mac80211-minstrel_ht-use-bitfields-to-encode-rate-in.patch +++ /dev/null @@ -1,412 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Thu, 21 Jan 2021 18:29:30 +0100 -Subject: [PATCH] mac80211: minstrel_ht: use bitfields to encode rate - indexes - -Get rid of a lot of divisions and modulo operations -Reduces code size and improves performance - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -379,14 +379,14 @@ out: - static inline struct minstrel_rate_stats * - minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index) - { -- return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; -+ return &mi->groups[MI_RATE_GROUP(index)].rates[MI_RATE_IDX(index)]; - } - --static inline int --minstrel_get_duration(int index) -+static inline int minstrel_get_duration(int index) - { -- const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; -- unsigned int duration = group->duration[index % MCS_GROUP_RATES]; -+ const struct mcs_group *group = &minstrel_mcs_groups[MI_RATE_GROUP(index)]; -+ unsigned int duration = group->duration[MI_RATE_IDX(index)]; -+ - return duration << group->shift; - } - -@@ -398,7 +398,7 @@ minstrel_ht_avg_ampdu_len(struct minstre - if (mi->avg_ampdu_len) - return MINSTREL_TRUNC(mi->avg_ampdu_len); - -- if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES)) -+ if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_tp_rate[0]))) - return 1; - - duration = minstrel_get_duration(mi->max_tp_rate[0]); -@@ -465,14 +465,14 @@ minstrel_ht_sort_best_tp_rates(struct mi - int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob; - int j = MAX_THR_RATES; - -- cur_group = index / MCS_GROUP_RATES; -- cur_idx = index % MCS_GROUP_RATES; -+ cur_group = MI_RATE_GROUP(index); -+ cur_idx = MI_RATE_IDX(index); - cur_prob = mi->groups[cur_group].rates[cur_idx].prob_avg; - cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, cur_prob); - - do { -- tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; -- tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES; -+ tmp_group = MI_RATE_GROUP(tp_list[j - 1]); -+ tmp_idx = MI_RATE_IDX(tp_list[j - 1]); - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, - tmp_prob); -@@ -504,23 +504,23 @@ minstrel_ht_set_best_prob_rate(struct mi - int max_gpr_group, max_gpr_idx; - int max_gpr_tp_avg, max_gpr_prob; - -- cur_group = index / MCS_GROUP_RATES; -- cur_idx = index % MCS_GROUP_RATES; -- mg = &mi->groups[index / MCS_GROUP_RATES]; -- mrs = &mg->rates[index % MCS_GROUP_RATES]; -+ cur_group = MI_RATE_GROUP(index); -+ cur_idx = MI_RATE_IDX(index); -+ mg = &mi->groups[cur_group]; -+ mrs = &mg->rates[cur_idx]; - -- tmp_group = *dest / MCS_GROUP_RATES; -- tmp_idx = *dest % MCS_GROUP_RATES; -+ tmp_group = MI_RATE_GROUP(*dest); -+ tmp_idx = MI_RATE_IDX(*dest); - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); - - /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from - * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ -- max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES; -- max_tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES; -+ max_tp_group = MI_RATE_GROUP(mi->max_tp_rate[0]); -+ max_tp_idx = MI_RATE_IDX(mi->max_tp_rate[0]); - max_tp_prob = mi->groups[max_tp_group].rates[max_tp_idx].prob_avg; - -- if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) && -+ if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(index)) && - !minstrel_ht_is_legacy_group(max_tp_group)) - return; - -@@ -529,8 +529,8 @@ minstrel_ht_set_best_prob_rate(struct mi - mrs->prob_avg < max_tp_prob) - return; - -- max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES; -- max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; -+ max_gpr_group = MI_RATE_GROUP(mg->max_group_prob_rate); -+ max_gpr_idx = MI_RATE_IDX(mg->max_group_prob_rate); - max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_avg; - - if (mrs->prob_avg > MINSTREL_FRAC(75, 100)) { -@@ -567,13 +567,13 @@ minstrel_ht_assign_best_tp_rates(struct - unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob; - int i; - -- tmp_group = tmp_legacy_tp_rate[0] / MCS_GROUP_RATES; -- tmp_idx = tmp_legacy_tp_rate[0] % MCS_GROUP_RATES; -+ tmp_group = MI_RATE_GROUP(tmp_legacy_tp_rate[0]); -+ tmp_idx = MI_RATE_IDX(tmp_legacy_tp_rate[0]); - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); - -- tmp_group = tmp_mcs_tp_rate[0] / MCS_GROUP_RATES; -- tmp_idx = tmp_mcs_tp_rate[0] % MCS_GROUP_RATES; -+ tmp_group = MI_RATE_GROUP(tmp_mcs_tp_rate[0]); -+ tmp_idx = MI_RATE_IDX(tmp_mcs_tp_rate[0]); - tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg; - tmp_mcs_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); - -@@ -600,14 +600,14 @@ minstrel_ht_prob_rate_reduce_streams(str - if (!mi->sta->ht_cap.ht_supported) - return; - -- tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] / -- MCS_GROUP_RATES].streams; -+ group = MI_RATE_GROUP(mi->max_tp_rate[0]); -+ tmp_max_streams = minstrel_mcs_groups[group].streams; - for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { - mg = &mi->groups[group]; - if (!mi->supported[group] || group == MINSTREL_CCK_GROUP) - continue; - -- tmp_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; -+ tmp_idx = MI_RATE_IDX(mg->max_group_prob_rate); - tmp_prob = mi->groups[group].rates[tmp_idx].prob_avg; - - if (tmp_tp < minstrel_ht_get_tp_avg(mi, group, tmp_idx, tmp_prob) && -@@ -644,8 +644,8 @@ minstrel_ht_find_probe_rates(struct mins - int i, g, max_dur; - int tp_idx; - -- tp_group = &minstrel_mcs_groups[mi->max_tp_rate[0] / MCS_GROUP_RATES]; -- tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES; -+ tp_group = &minstrel_mcs_groups[MI_RATE_GROUP(mi->max_tp_rate[0])]; -+ tp_idx = MI_RATE_IDX(mi->max_tp_rate[0]); - - max_dur = minstrel_get_duration(mi->max_tp_rate[0]); - if (faster_rate) -@@ -670,7 +670,7 @@ minstrel_ht_find_probe_rates(struct mins - if ((group->duration[i] << group->shift) > max_dur) - continue; - -- idx = g * MCS_GROUP_RATES + i; -+ idx = MI_RATE(g, i); - if (idx == mi->max_tp_rate[0]) - continue; - -@@ -712,10 +712,10 @@ minstrel_ht_rate_sample_switch(struct mi - - /* If no suitable rate was found, try to pick the next one in the group */ - if (!n_rates) { -- int g_idx = mi->max_tp_rate[0] / MCS_GROUP_RATES; -+ int g_idx = MI_RATE_GROUP(mi->max_tp_rate[0]); - u16 supported = mi->supported[g_idx]; - -- supported >>= mi->max_tp_rate[0] % MCS_GROUP_RATES; -+ supported >>= MI_RATE_IDX(mi->max_tp_rate[0]); - for (i = 0; supported; supported >>= 1, i++) { - if (!(supported & 1)) - continue; -@@ -854,24 +854,27 @@ minstrel_ht_update_stats(struct minstrel - mi->sample_slow = 0; - mi->sample_count = 0; - -- memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate)); -- memset(tmp_legacy_tp_rate, 0, sizeof(tmp_legacy_tp_rate)); - if (mi->supported[MINSTREL_CCK_GROUP]) -- for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) -- tmp_legacy_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; -+ group = MINSTREL_CCK_GROUP; - else if (mi->supported[MINSTREL_OFDM_GROUP]) -- for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) -- tmp_legacy_tp_rate[j] = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; -+ group = MINSTREL_OFDM_GROUP; -+ else -+ group = 0; -+ -+ index = MI_RATE(group, 0); -+ for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++) -+ tmp_legacy_tp_rate[j] = index; - - if (mi->supported[MINSTREL_VHT_GROUP_0]) -- index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES; -+ group = MINSTREL_VHT_GROUP_0; - else if (ht_supported) -- index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES; -+ group = MINSTREL_HT_GROUP_0; - else if (mi->supported[MINSTREL_CCK_GROUP]) -- index = MINSTREL_CCK_GROUP * MCS_GROUP_RATES; -+ group = MINSTREL_CCK_GROUP; - else -- index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES; -+ group = MINSTREL_OFDM_GROUP; - -+ index = MI_RATE(group, 0); - tmp_max_prob_rate = index; - for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++) - tmp_mcs_tp_rate[j] = index; -@@ -888,7 +891,7 @@ minstrel_ht_update_stats(struct minstrel - - /* (re)Initialize group rate indexes */ - for(j = 0; j < MAX_THR_RATES; j++) -- tmp_group_tp_rate[j] = MCS_GROUP_RATES * group; -+ tmp_group_tp_rate[j] = MI_RATE(group, 0); - - if (group == MINSTREL_CCK_GROUP && ht_supported) - tp_rate = tmp_legacy_tp_rate; -@@ -897,7 +900,7 @@ minstrel_ht_update_stats(struct minstrel - if (!(mi->supported[group] & BIT(i))) - continue; - -- index = MCS_GROUP_RATES * group + i; -+ index = MI_RATE(group, i); - - mrs = &mg->rates[i]; - mrs->retry_updated = false; -@@ -929,13 +932,13 @@ minstrel_ht_update_stats(struct minstrel - continue; - - mg = &mi->groups[group]; -- mg->max_group_prob_rate = MCS_GROUP_RATES * group; -+ mg->max_group_prob_rate = MI_RATE(group, 0); - - for (i = 0; i < MCS_GROUP_RATES; i++) { - if (!(mi->supported[group] & BIT(i))) - continue; - -- index = MCS_GROUP_RATES * group + i; -+ index = MI_RATE(group, i); - - /* Find max probability rate per group and global */ - minstrel_ht_set_best_prob_rate(mi, &tmp_max_prob_rate, -@@ -1022,7 +1025,7 @@ minstrel_downgrade_rate(struct minstrel_ - { - int group, orig_group; - -- orig_group = group = *idx / MCS_GROUP_RATES; -+ orig_group = group = MI_RATE_GROUP(*idx); - while (group > 0) { - group--; - -@@ -1206,7 +1209,7 @@ minstrel_calc_retransmit(struct minstrel - ctime += (t_slot * cw) >> 1; - cw = min((cw << 1) | 1, mp->cw_max); - -- if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES)) { -+ if (minstrel_ht_is_legacy_group(MI_RATE_GROUP(index))) { - overhead = mi->overhead_legacy; - overhead_rtscts = mi->overhead_legacy_rtscts; - } else { -@@ -1239,7 +1242,7 @@ static void - minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, - struct ieee80211_sta_rates *ratetbl, int offset, int index) - { -- int group_idx = index / MCS_GROUP_RATES; -+ int group_idx = MI_RATE_GROUP(index); - const struct mcs_group *group = &minstrel_mcs_groups[group_idx]; - struct minstrel_rate_stats *mrs; - u8 idx; -@@ -1259,7 +1262,7 @@ minstrel_ht_set_rate(struct minstrel_pri - ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts; - } - -- index %= MCS_GROUP_RATES; -+ index = MI_RATE_IDX(index); - if (group_idx == MINSTREL_CCK_GROUP) - idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)]; - else if (group_idx == MINSTREL_OFDM_GROUP) -@@ -1289,17 +1292,17 @@ minstrel_ht_set_rate(struct minstrel_pri - static inline int - minstrel_ht_get_prob_avg(struct minstrel_ht_sta *mi, int rate) - { -- int group = rate / MCS_GROUP_RATES; -- rate %= MCS_GROUP_RATES; -+ int group = MI_RATE_GROUP(rate); -+ rate = MI_RATE_IDX(rate); - return mi->groups[group].rates[rate].prob_avg; - } - - static int - minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi) - { -- int group = mi->max_prob_rate / MCS_GROUP_RATES; -+ int group = MI_RATE_GROUP(mi->max_prob_rate); - const struct mcs_group *g = &minstrel_mcs_groups[group]; -- int rate = mi->max_prob_rate % MCS_GROUP_RATES; -+ int rate = MI_RATE_IDX(mi->max_prob_rate); - unsigned int duration; - - /* Disable A-MSDU if max_prob_rate is bad */ -@@ -1405,7 +1408,7 @@ minstrel_get_sample_rate(struct minstrel - return -1; - - mrs = &mg->rates[sample_idx]; -- sample_idx += sample_group * MCS_GROUP_RATES; -+ sample_idx += MI_RATE(sample_group, 0); - - tp_rate1 = mi->max_tp_rate[0]; - -@@ -1455,8 +1458,7 @@ minstrel_get_sample_rate(struct minstrel - * if the link is working perfectly. - */ - -- cur_max_tp_streams = minstrel_mcs_groups[tp_rate1 / -- MCS_GROUP_RATES].streams; -+ cur_max_tp_streams = minstrel_mcs_groups[MI_RATE_GROUP(tp_rate1)].streams; - if (sample_dur >= minstrel_get_duration(tp_rate2) && - (cur_max_tp_streams - 1 < - minstrel_mcs_groups[sample_group].streams || -@@ -1484,7 +1486,7 @@ minstrel_ht_get_rate(void *priv, struct - int sample_idx; - - if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && -- !minstrel_ht_is_legacy_group(mi->max_prob_rate / MCS_GROUP_RATES)) -+ !minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_prob_rate))) - minstrel_aggr_check(sta, txrc->skb); - - info->flags |= mi->tx_flags; -@@ -1512,8 +1514,8 @@ minstrel_ht_get_rate(void *priv, struct - if (sample_idx < 0) - return; - -- sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES]; -- sample_idx %= MCS_GROUP_RATES; -+ sample_group = &minstrel_mcs_groups[MI_RATE_GROUP(sample_idx)]; -+ sample_idx = MI_RATE_IDX(sample_idx); - - if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] && - (sample_idx >= 4) != txrc->short_preamble) -@@ -1529,7 +1531,7 @@ minstrel_ht_get_rate(void *priv, struct - int idx = sample_idx % ARRAY_SIZE(mp->ofdm_rates[0]); - rate->idx = mp->ofdm_rates[mi->band][idx]; - } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) { -- ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES, -+ ieee80211_rate_set_vht(rate, MI_RATE_IDX(sample_idx), - sample_group->streams); - } else { - rate->idx = sample_idx + (sample_group->streams - 1) * 8; -@@ -1898,8 +1900,8 @@ static u32 minstrel_ht_get_expected_thro - struct minstrel_ht_sta *mi = priv_sta; - int i, j, prob, tp_avg; - -- i = mi->max_tp_rate[0] / MCS_GROUP_RATES; -- j = mi->max_tp_rate[0] % MCS_GROUP_RATES; -+ i = MI_RATE_GROUP(mi->max_tp_rate[0]); -+ j = MI_RATE_IDX(mi->max_tp_rate[0]); - prob = mi->groups[i].rates[j].prob_avg; - - /* convert tp_avg from pkt per second in kbps */ ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -6,6 +6,8 @@ - #ifndef __RC_MINSTREL_HT_H - #define __RC_MINSTREL_HT_H - -+#include <linux/bitfield.h> -+ - /* number of highest throughput rates to consider*/ - #define MAX_THR_RATES 4 - #define SAMPLE_COLUMNS 10 /* number of columns in sample table */ -@@ -57,6 +59,17 @@ - - #define MCS_GROUP_RATES 10 - -+#define MI_RATE_IDX_MASK GENMASK(3, 0) -+#define MI_RATE_GROUP_MASK GENMASK(15, 4) -+ -+#define MI_RATE(_group, _idx) \ -+ (FIELD_PREP(MI_RATE_GROUP_MASK, _group) | \ -+ FIELD_PREP(MI_RATE_IDX_MASK, _idx)) -+ -+#define MI_RATE_IDX(_rate) FIELD_GET(MI_RATE_IDX_MASK, _rate) -+#define MI_RATE_GROUP(_rate) FIELD_GET(MI_RATE_GROUP_MASK, _rate) -+ -+ - struct minstrel_priv { - struct ieee80211_hw *hw; - bool has_mrr; ---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c -+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c -@@ -56,7 +56,7 @@ minstrel_ht_stats_dump(struct minstrel_h - - for (j = 0; j < MCS_GROUP_RATES; j++) { - struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; -- int idx = i * MCS_GROUP_RATES + j; -+ int idx = MI_RATE(i, j); - unsigned int duration; - - if (!(mi->supported[i] & BIT(j))) -@@ -201,7 +201,7 @@ minstrel_ht_stats_csv_dump(struct minstr - - for (j = 0; j < MCS_GROUP_RATES; j++) { - struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; -- int idx = i * MCS_GROUP_RATES + j; -+ int idx = MI_RATE(i, j); - unsigned int duration; - - if (!(mi->supported[i] & BIT(j))) diff --git a/package/kernel/mac80211/patches/subsys/347-mac80211-minstrel_ht-update-total-packets-counter-in.patch b/package/kernel/mac80211/patches/subsys/347-mac80211-minstrel_ht-update-total-packets-counter-in.patch deleted file mode 100644 index dce8104934f..00000000000 --- a/package/kernel/mac80211/patches/subsys/347-mac80211-minstrel_ht-update-total-packets-counter-in.patch +++ /dev/null @@ -1,54 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 22 Jan 2021 18:21:13 +0100 -Subject: [PATCH] mac80211: minstrel_ht: update total packets counter in tx - status path - -Keep the update in one place and prepare for further rework - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -1092,6 +1092,16 @@ minstrel_ht_tx_status(void *priv, struct - info->status.ampdu_len = 1; - } - -+ /* wraparound */ -+ if (mi->total_packets >= ~0 - info->status.ampdu_len) { -+ mi->total_packets = 0; -+ mi->sample_packets = 0; -+ } -+ -+ mi->total_packets += info->status.ampdu_len; -+ if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) -+ mi->sample_packets += info->status.ampdu_len; -+ - mi->ampdu_packets++; - mi->ampdu_len += info->status.ampdu_len; - -@@ -1103,9 +1113,6 @@ minstrel_ht_tx_status(void *priv, struct - mi->sample_count--; - } - -- if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) -- mi->sample_packets += info->status.ampdu_len; -- - if (mi->sample_mode != MINSTREL_SAMPLE_IDLE) - rate_sample = minstrel_get_ratestats(mi, mi->sample_rate); - -@@ -1503,14 +1510,6 @@ minstrel_ht_get_rate(void *priv, struct - else - sample_idx = minstrel_get_sample_rate(mp, mi); - -- mi->total_packets++; -- -- /* wraparound */ -- if (mi->total_packets == ~0) { -- mi->total_packets = 0; -- mi->sample_packets = 0; -- } -- - if (sample_idx < 0) - return; - diff --git a/package/kernel/mac80211/patches/subsys/348-mac80211-minstrel_ht-reduce-the-need-to-sample-slowe.patch b/package/kernel/mac80211/patches/subsys/348-mac80211-minstrel_ht-reduce-the-need-to-sample-slowe.patch deleted file mode 100644 index dc6f11e4b94..00000000000 --- a/package/kernel/mac80211/patches/subsys/348-mac80211-minstrel_ht-reduce-the-need-to-sample-slowe.patch +++ /dev/null @@ -1,102 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 22 Jan 2021 19:24:59 +0100 -Subject: [PATCH] mac80211: minstrel_ht: reduce the need to sample slower - rates - -In order to more gracefully be able to fall back to lower rates without too -much throughput fluctuations, initialize all untested rates below tested ones -to the maximum probabilty of higher rates. -Usually this leads to untested lower rates getting initialized with a -probability value of 100%, making them better candidates for fallback without -having to rely on random probing - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -791,14 +791,11 @@ minstrel_ht_calc_rate_stats(struct minst - unsigned int cur_prob; - - if (unlikely(mrs->attempts > 0)) { -- mrs->sample_skipped = 0; - cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); - minstrel_filter_avg_add(&mrs->prob_avg, - &mrs->prob_avg_1, cur_prob); - mrs->att_hist += mrs->attempts; - mrs->succ_hist += mrs->success; -- } else { -- mrs->sample_skipped++; - } - - mrs->last_success = mrs->success; -@@ -851,7 +848,6 @@ minstrel_ht_update_stats(struct minstrel - mi->ampdu_packets = 0; - } - -- mi->sample_slow = 0; - mi->sample_count = 0; - - if (mi->supported[MINSTREL_CCK_GROUP]) -@@ -882,6 +878,7 @@ minstrel_ht_update_stats(struct minstrel - /* Find best rate sets within all MCS groups*/ - for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { - u16 *tp_rate = tmp_mcs_tp_rate; -+ u16 last_prob = 0; - - mg = &mi->groups[group]; - if (!mi->supported[group]) -@@ -896,7 +893,7 @@ minstrel_ht_update_stats(struct minstrel - if (group == MINSTREL_CCK_GROUP && ht_supported) - tp_rate = tmp_legacy_tp_rate; - -- for (i = 0; i < MCS_GROUP_RATES; i++) { -+ for (i = MCS_GROUP_RATES - 1; i >= 0; i--) { - if (!(mi->supported[group] & BIT(i))) - continue; - -@@ -905,6 +902,11 @@ minstrel_ht_update_stats(struct minstrel - mrs = &mg->rates[i]; - mrs->retry_updated = false; - minstrel_ht_calc_rate_stats(mp, mrs); -+ -+ if (mrs->att_hist) -+ last_prob = max(last_prob, mrs->prob_avg); -+ else -+ mrs->prob_avg = max(last_prob, mrs->prob_avg); - cur_prob = mrs->prob_avg; - - if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) -@@ -1469,13 +1471,9 @@ minstrel_get_sample_rate(struct minstrel - if (sample_dur >= minstrel_get_duration(tp_rate2) && - (cur_max_tp_streams - 1 < - minstrel_mcs_groups[sample_group].streams || -- sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { -- if (mrs->sample_skipped < 20) -+ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) - return -1; - -- if (mi->sample_slow++ > 2) -- return -1; -- } - mi->sample_tries--; - - return sample_idx; ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -123,7 +123,6 @@ struct minstrel_rate_stats { - u8 retry_count; - u8 retry_count_rtscts; - -- u8 sample_skipped; - bool retry_updated; - }; - -@@ -179,7 +178,6 @@ struct minstrel_ht_sta { - u8 sample_wait; - u8 sample_tries; - u8 sample_count; -- u8 sample_slow; - - enum minstrel_sample_mode sample_mode; - u16 sample_rate; diff --git a/package/kernel/mac80211/patches/subsys/349-mac80211-minstrel_ht-significantly-redesign-the-rate.patch b/package/kernel/mac80211/patches/subsys/349-mac80211-minstrel_ht-significantly-redesign-the-rate.patch deleted file mode 100644 index 09f6fd22144..00000000000 --- a/package/kernel/mac80211/patches/subsys/349-mac80211-minstrel_ht-significantly-redesign-the-rate.patch +++ /dev/null @@ -1,767 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 22 Jan 2021 23:57:50 +0100 -Subject: [PATCH] mac80211: minstrel_ht: significantly redesign the rate - probing strategy - -The biggest flaw in current minstrel_ht is the fact that it needs way too -many probing packets to be able to quickly find the best rate. -Depending on the wifi hardware and operating mode, this can significantly -reduce throughput when not operating at the highest available data rate. - -In order to be able to significantly reduce the amount of rate sampling, -we need a much smarter selection of probing rates. - -The new approach introduced by this patch maintains a limited set of -available rates to be tested during a statistics window. - -They are split into distinct categories: -- MINSTREL_SAMPLE_TYPE_INC - incremental rate upgrade: - Pick the next rate group and find the first rate that is faster than - the current max. throughput rate -- MINSTREL_SAMPLE_TYPE_JUMP - random testing of higher rates: - Pick a random rate from the next group that is faster than the current - max throughput rate. This allows faster adaptation when the link changes - significantly -- MINSTREL_SAMPLE_TYPE_SLOW - test a rate between max_prob, max_tp2 and - max_tp in order to reduce the gap between them - -In order to prioritize sampling, every 6 attempts are split into 3x INC, -2x JUMP, 1x SLOW. - -Available rates are checked and refilled on every stats window update. - -With this approach, we finally get a very small delta in throughput when -comparing setting the optimal data rate as a fixed rate vs normal rate -control operation. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -266,6 +266,14 @@ const struct mcs_group minstrel_mcs_grou - const s16 minstrel_cck_bitrates[4] = { 10, 20, 55, 110 }; - const s16 minstrel_ofdm_bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 }; - static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly; -+static const u8 minstrel_sample_seq[] = { -+ MINSTREL_SAMPLE_TYPE_INC, -+ MINSTREL_SAMPLE_TYPE_JUMP, -+ MINSTREL_SAMPLE_TYPE_INC, -+ MINSTREL_SAMPLE_TYPE_JUMP, -+ MINSTREL_SAMPLE_TYPE_INC, -+ MINSTREL_SAMPLE_TYPE_SLOW, -+}; - - static void - minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi); -@@ -620,77 +628,31 @@ minstrel_ht_prob_rate_reduce_streams(str - } - } - --static bool --minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group, -- int tp_idx, const struct mcs_group *group) --{ -- if (group->bw < tp_group->bw) -- return false; -- -- if (group->streams == tp_group->streams) -- return true; -- -- if (tp_idx < 4 && group->streams == tp_group->streams - 1) -- return true; -- -- return group->streams == tp_group->streams + 1; --} -- --static void --minstrel_ht_find_probe_rates(struct minstrel_ht_sta *mi, u16 *rates, int *n_rates, -- bool faster_rate) -+static u16 -+__minstrel_ht_get_sample_rate(struct minstrel_ht_sta *mi, -+ enum minstrel_sample_type type) - { -- const struct mcs_group *group, *tp_group; -- int i, g, max_dur; -- int tp_idx; -- -- tp_group = &minstrel_mcs_groups[MI_RATE_GROUP(mi->max_tp_rate[0])]; -- tp_idx = MI_RATE_IDX(mi->max_tp_rate[0]); -- -- max_dur = minstrel_get_duration(mi->max_tp_rate[0]); -- if (faster_rate) -- max_dur -= max_dur / 16; -- -- for (g = 0; g < MINSTREL_GROUPS_NB; g++) { -- u16 supported = mi->supported[g]; -- -- if (!supported) -- continue; -+ u16 *rates = mi->sample[type].sample_rates; -+ u16 cur; -+ int i; - -- group = &minstrel_mcs_groups[g]; -- if (!minstrel_ht_probe_group(mi, tp_group, tp_idx, group)) -+ for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) { -+ if (!rates[i]) - continue; - -- for (i = 0; supported; supported >>= 1, i++) { -- int idx; -- -- if (!(supported & 1)) -- continue; -- -- if ((group->duration[i] << group->shift) > max_dur) -- continue; -- -- idx = MI_RATE(g, i); -- if (idx == mi->max_tp_rate[0]) -- continue; -- -- rates[(*n_rates)++] = idx; -- break; -- } -+ cur = rates[i]; -+ rates[i] = 0; -+ return cur; - } -+ -+ return 0; - } - - static void - minstrel_ht_rate_sample_switch(struct minstrel_priv *mp, - struct minstrel_ht_sta *mi) - { -- struct minstrel_rate_stats *mrs; -- u16 rates[MINSTREL_GROUPS_NB]; -- int n_rates = 0; -- int probe_rate = 0; -- bool faster_rate; -- int i; -- u8 random; -+ u16 rate; - - /* - * Use rate switching instead of probing packets for devices with -@@ -699,43 +661,11 @@ minstrel_ht_rate_sample_switch(struct mi - if (mp->hw->max_rates > 1) - return; - -- /* -- * If the current EWMA prob is >75%, look for a rate that's 6.25% -- * faster than the max tp rate. -- * If that fails, look again for a rate that is at least as fast -- */ -- mrs = minstrel_get_ratestats(mi, mi->max_tp_rate[0]); -- faster_rate = mrs->prob_avg > MINSTREL_FRAC(75, 100); -- minstrel_ht_find_probe_rates(mi, rates, &n_rates, faster_rate); -- if (!n_rates && faster_rate) -- minstrel_ht_find_probe_rates(mi, rates, &n_rates, false); -- -- /* If no suitable rate was found, try to pick the next one in the group */ -- if (!n_rates) { -- int g_idx = MI_RATE_GROUP(mi->max_tp_rate[0]); -- u16 supported = mi->supported[g_idx]; -- -- supported >>= MI_RATE_IDX(mi->max_tp_rate[0]); -- for (i = 0; supported; supported >>= 1, i++) { -- if (!(supported & 1)) -- continue; -- -- probe_rate = mi->max_tp_rate[0] + i; -- goto out; -- } -- -+ rate = __minstrel_ht_get_sample_rate(mi, MINSTREL_SAMPLE_TYPE_INC); -+ if (!rate) - return; -- } -- -- i = 0; -- if (n_rates > 1) { -- random = prandom_u32(); -- i = random % n_rates; -- } -- probe_rate = rates[i]; - --out: -- mi->sample_rate = probe_rate; -+ mi->sample_rate = rate; - mi->sample_mode = MINSTREL_SAMPLE_ACTIVE; - } - -@@ -804,6 +734,274 @@ minstrel_ht_calc_rate_stats(struct minst - mrs->attempts = 0; - } - -+static bool -+minstrel_ht_find_sample_rate(struct minstrel_ht_sta *mi, int type, int idx) -+{ -+ int i; -+ -+ for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) { -+ u16 cur = mi->sample[type].sample_rates[i]; -+ -+ if (cur == idx) -+ return true; -+ -+ if (!cur) -+ break; -+ } -+ -+ return false; -+} -+ -+static int -+minstrel_ht_move_sample_rates(struct minstrel_ht_sta *mi, int type, -+ u32 fast_rate_dur, u32 slow_rate_dur) -+{ -+ u16 *rates = mi->sample[type].sample_rates; -+ int i, j; -+ -+ for (i = 0, j = 0; i < MINSTREL_SAMPLE_RATES; i++) { -+ u32 duration; -+ bool valid = false; -+ u16 cur; -+ -+ cur = rates[i]; -+ if (!cur) -+ continue; -+ -+ duration = minstrel_get_duration(cur); -+ switch (type) { -+ case MINSTREL_SAMPLE_TYPE_SLOW: -+ valid = duration > fast_rate_dur && -+ duration < slow_rate_dur; -+ break; -+ case MINSTREL_SAMPLE_TYPE_INC: -+ case MINSTREL_SAMPLE_TYPE_JUMP: -+ valid = duration < fast_rate_dur; -+ break; -+ default: -+ valid = false; -+ break; -+ } -+ -+ if (!valid) { -+ rates[i] = 0; -+ continue; -+ } -+ -+ if (i == j) -+ continue; -+ -+ rates[j++] = cur; -+ rates[i] = 0; -+ } -+ -+ return j; -+} -+ -+static int -+minstrel_ht_group_min_rate_offset(struct minstrel_ht_sta *mi, int group, -+ u32 max_duration) -+{ -+ u16 supported = mi->supported[group]; -+ int i; -+ -+ for (i = 0; i < MCS_GROUP_RATES && supported; i++, supported >>= 1) { -+ if (!(supported & BIT(0))) -+ continue; -+ -+ if (minstrel_get_duration(MI_RATE(group, i)) >= max_duration) -+ continue; -+ -+ return i; -+ } -+ -+ return -1; -+} -+ -+/* -+ * Incremental update rates: -+ * Flip through groups and pick the first group rate that is faster than the -+ * highest currently selected rate -+ */ -+static u16 -+minstrel_ht_next_inc_rate(struct minstrel_ht_sta *mi, u32 fast_rate_dur) -+{ -+ struct minstrel_mcs_group_data *mg; -+ u8 type = MINSTREL_SAMPLE_TYPE_INC; -+ int i, index = 0; -+ u8 group; -+ -+ group = mi->sample[type].sample_group; -+ for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) { -+ group = (group + 1) % ARRAY_SIZE(minstrel_mcs_groups); -+ mg = &mi->groups[group]; -+ -+ index = minstrel_ht_group_min_rate_offset(mi, group, -+ fast_rate_dur); -+ if (index < 0) -+ continue; -+ -+ index = MI_RATE(group, index & 0xf); -+ if (!minstrel_ht_find_sample_rate(mi, type, index)) -+ goto out; -+ } -+ index = 0; -+ -+out: -+ mi->sample[type].sample_group = group; -+ -+ return index; -+} -+ -+static int -+minstrel_ht_next_group_sample_rate(struct minstrel_ht_sta *mi, int group, -+ u16 supported, int offset) -+{ -+ struct minstrel_mcs_group_data *mg = &mi->groups[group]; -+ u16 idx; -+ int i; -+ -+ for (i = 0; i < MCS_GROUP_RATES; i++) { -+ idx = sample_table[mg->column][mg->index]; -+ if (++mg->index >= MCS_GROUP_RATES) { -+ mg->index = 0; -+ if (++mg->column >= ARRAY_SIZE(sample_table)) -+ mg->column = 0; -+ } -+ -+ if (idx < offset) -+ continue; -+ -+ if (!(supported & BIT(idx))) -+ continue; -+ -+ return MI_RATE(group, idx); -+ } -+ -+ return -1; -+} -+ -+/* -+ * Jump rates: -+ * Sample random rates, use those that are faster than the highest -+ * currently selected rate. Rates between the fastest and the slowest -+ * get sorted into the slow sample bucket, but only if it has room -+ */ -+static u16 -+minstrel_ht_next_jump_rate(struct minstrel_ht_sta *mi, u32 fast_rate_dur, -+ u32 slow_rate_dur, int *slow_rate_ofs) -+{ -+ struct minstrel_mcs_group_data *mg; -+ struct minstrel_rate_stats *mrs; -+ u32 max_duration = slow_rate_dur; -+ int i, index, offset; -+ u16 *slow_rates; -+ u16 supported; -+ u32 duration; -+ u8 group; -+ -+ if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) -+ max_duration = fast_rate_dur; -+ -+ slow_rates = mi->sample[MINSTREL_SAMPLE_TYPE_SLOW].sample_rates; -+ group = mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_group; -+ for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) { -+ u8 type; -+ -+ group = (group + 1) % ARRAY_SIZE(minstrel_mcs_groups); -+ mg = &mi->groups[group]; -+ -+ supported = mi->supported[group]; -+ if (!supported) -+ continue; -+ -+ offset = minstrel_ht_group_min_rate_offset(mi, group, -+ max_duration); -+ if (offset < 0) -+ continue; -+ -+ index = minstrel_ht_next_group_sample_rate(mi, group, supported, -+ offset); -+ if (index < 0) -+ continue; -+ -+ duration = minstrel_get_duration(index); -+ if (duration < fast_rate_dur) -+ type = MINSTREL_SAMPLE_TYPE_JUMP; -+ else -+ type = MINSTREL_SAMPLE_TYPE_SLOW; -+ -+ if (minstrel_ht_find_sample_rate(mi, type, index)) -+ continue; -+ -+ if (type == MINSTREL_SAMPLE_TYPE_JUMP) -+ goto found; -+ -+ if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) -+ continue; -+ -+ if (duration >= slow_rate_dur) -+ continue; -+ -+ /* skip slow rates with high success probability */ -+ mrs = minstrel_get_ratestats(mi, index); -+ if (mrs->prob_avg > MINSTREL_FRAC(95, 100)) -+ continue; -+ -+ slow_rates[(*slow_rate_ofs)++] = index; -+ if (*slow_rate_ofs >= MINSTREL_SAMPLE_RATES) -+ max_duration = fast_rate_dur; -+ } -+ index = 0; -+ -+found: -+ mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_group = group; -+ -+ return index; -+} -+ -+static void -+minstrel_ht_refill_sample_rates(struct minstrel_ht_sta *mi) -+{ -+ u32 prob_dur = minstrel_get_duration(mi->max_prob_rate); -+ u32 tp_dur = minstrel_get_duration(mi->max_tp_rate[0]); -+ u32 tp2_dur = minstrel_get_duration(mi->max_tp_rate[1]); -+ u32 fast_rate_dur = min(min(tp_dur, tp2_dur), prob_dur); -+ u32 slow_rate_dur = max(max(tp_dur, tp2_dur), prob_dur); -+ u16 *rates; -+ int i, j; -+ -+ rates = mi->sample[MINSTREL_SAMPLE_TYPE_INC].sample_rates; -+ i = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_INC, -+ fast_rate_dur, slow_rate_dur); -+ while (i < MINSTREL_SAMPLE_RATES) { -+ rates[i] = minstrel_ht_next_inc_rate(mi, tp_dur); -+ if (!rates[i]) -+ break; -+ -+ i++; -+ } -+ -+ rates = mi->sample[MINSTREL_SAMPLE_TYPE_JUMP].sample_rates; -+ i = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_JUMP, -+ fast_rate_dur, slow_rate_dur); -+ j = minstrel_ht_move_sample_rates(mi, MINSTREL_SAMPLE_TYPE_SLOW, -+ fast_rate_dur, slow_rate_dur); -+ while (i < MINSTREL_SAMPLE_RATES) { -+ rates[i] = minstrel_ht_next_jump_rate(mi, fast_rate_dur, -+ slow_rate_dur, &j); -+ if (!rates[i]) -+ break; -+ -+ i++; -+ } -+ -+ for (i = 0; i < ARRAY_SIZE(mi->sample); i++) -+ memcpy(mi->sample[i].cur_sample_rates, mi->sample[i].sample_rates, -+ sizeof(mi->sample[i].cur_sample_rates)); -+} -+ -+ - /* - * Update rate statistics and select new primary rates - * -@@ -848,8 +1046,6 @@ minstrel_ht_update_stats(struct minstrel - mi->ampdu_packets = 0; - } - -- mi->sample_count = 0; -- - if (mi->supported[MINSTREL_CCK_GROUP]) - group = MINSTREL_CCK_GROUP; - else if (mi->supported[MINSTREL_OFDM_GROUP]) -@@ -884,8 +1080,6 @@ minstrel_ht_update_stats(struct minstrel - if (!mi->supported[group]) - continue; - -- mi->sample_count++; -- - /* (re)Initialize group rate indexes */ - for(j = 0; j < MAX_THR_RATES; j++) - tmp_group_tp_rate[j] = MI_RATE(group, 0); -@@ -952,9 +1146,7 @@ minstrel_ht_update_stats(struct minstrel - - /* Try to increase robustness of max_prob_rate*/ - minstrel_ht_prob_rate_reduce_streams(mi); -- -- /* try to sample half of all available rates during each interval */ -- mi->sample_count *= 4; -+ minstrel_ht_refill_sample_rates(mi); - - if (sample) - minstrel_ht_rate_sample_switch(mp, mi); -@@ -971,6 +1163,7 @@ minstrel_ht_update_stats(struct minstrel - - /* Reset update timer */ - mi->last_stats_update = jiffies; -+ mi->sample_time = jiffies; - } - - static bool -@@ -1001,28 +1194,6 @@ minstrel_ht_txstat_valid(struct minstrel - } - - static void --minstrel_set_next_sample_idx(struct minstrel_ht_sta *mi) --{ -- struct minstrel_mcs_group_data *mg; -- -- for (;;) { -- mi->sample_group++; -- mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups); -- mg = &mi->groups[mi->sample_group]; -- -- if (!mi->supported[mi->sample_group]) -- continue; -- -- if (++mg->index >= MCS_GROUP_RATES) { -- mg->index = 0; -- if (++mg->column >= ARRAY_SIZE(sample_table)) -- mg->column = 0; -- } -- break; -- } --} -- --static void - minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary) - { - int group, orig_group; -@@ -1107,14 +1278,6 @@ minstrel_ht_tx_status(void *priv, struct - mi->ampdu_packets++; - mi->ampdu_len += info->status.ampdu_len; - -- if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) { -- int avg_ampdu_len = minstrel_ht_avg_ampdu_len(mi); -- -- mi->sample_wait = 16 + 2 * avg_ampdu_len; -- mi->sample_tries = 1; -- mi->sample_count--; -- } -- - if (mi->sample_mode != MINSTREL_SAMPLE_IDLE) - rate_sample = minstrel_get_ratestats(mi, mi->sample_rate); - -@@ -1386,97 +1549,20 @@ minstrel_ht_update_rates(struct minstrel - rate_control_set_rates(mp->hw, mi->sta, rates); - } - --static int --minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) -+static u16 -+minstrel_ht_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) - { -- struct minstrel_rate_stats *mrs; -- struct minstrel_mcs_group_data *mg; -- unsigned int sample_dur, sample_group, cur_max_tp_streams; -- int tp_rate1, tp_rate2; -- int sample_idx = 0; -- -- if (mp->hw->max_rates == 1 && mp->sample_switch && -- (mi->total_packets_cur >= SAMPLE_SWITCH_THR || -- mp->sample_switch == 1)) -- return -1; -- -- if (mi->sample_wait > 0) { -- mi->sample_wait--; -- return -1; -- } -- -- if (!mi->sample_tries) -- return -1; -- -- sample_group = mi->sample_group; -- mg = &mi->groups[sample_group]; -- sample_idx = sample_table[mg->column][mg->index]; -- minstrel_set_next_sample_idx(mi); -- -- if (!(mi->supported[sample_group] & BIT(sample_idx))) -- return -1; -+ u8 seq; - -- mrs = &mg->rates[sample_idx]; -- sample_idx += MI_RATE(sample_group, 0); -- -- tp_rate1 = mi->max_tp_rate[0]; -- -- /* Set tp_rate2 to the second highest max_tp_rate */ -- if (minstrel_get_duration(mi->max_tp_rate[0]) > -- minstrel_get_duration(mi->max_tp_rate[1])) { -- tp_rate2 = mi->max_tp_rate[0]; -+ if (mp->hw->max_rates > 1) { -+ seq = mi->sample_seq; -+ mi->sample_seq = (seq + 1) % ARRAY_SIZE(minstrel_sample_seq); -+ seq = minstrel_sample_seq[seq]; - } else { -- tp_rate2 = mi->max_tp_rate[1]; -+ seq = MINSTREL_SAMPLE_TYPE_INC; - } - -- /* -- * Sampling might add some overhead (RTS, no aggregation) -- * to the frame. Hence, don't use sampling for the highest currently -- * used highest throughput or probability rate. -- */ -- if (sample_idx == mi->max_tp_rate[0] || sample_idx == mi->max_prob_rate) -- return -1; -- -- /* -- * Do not sample if the probability is already higher than 95%, -- * or if the rate is 3 times slower than the current max probability -- * rate, to avoid wasting airtime. -- */ -- sample_dur = minstrel_get_duration(sample_idx); -- if (mrs->prob_avg > MINSTREL_FRAC(95, 100) || -- minstrel_get_duration(mi->max_prob_rate) * 3 < sample_dur) -- return -1; -- -- -- /* -- * For devices with no configurable multi-rate retry, skip sampling -- * below the per-group max throughput rate, and only use one sampling -- * attempt per rate -- */ -- if (mp->hw->max_rates == 1 && -- (minstrel_get_duration(mg->max_group_tp_rate[0]) < sample_dur || -- mrs->attempts)) -- return -1; -- -- /* Skip already sampled slow rates */ -- if (sample_dur >= minstrel_get_duration(tp_rate1) && mrs->attempts) -- return -1; -- -- /* -- * Make sure that lower rates get sampled only occasionally, -- * if the link is working perfectly. -- */ -- -- cur_max_tp_streams = minstrel_mcs_groups[MI_RATE_GROUP(tp_rate1)].streams; -- if (sample_dur >= minstrel_get_duration(tp_rate2) && -- (cur_max_tp_streams - 1 < -- minstrel_mcs_groups[sample_group].streams || -- sample_dur >= minstrel_get_duration(mi->max_prob_rate))) -- return -1; -- -- mi->sample_tries--; -- -- return sample_idx; -+ return __minstrel_ht_get_sample_rate(mi, seq); - } - - static void -@@ -1488,7 +1574,7 @@ minstrel_ht_get_rate(void *priv, struct - struct ieee80211_tx_rate *rate = &info->status.rates[0]; - struct minstrel_ht_sta *mi = priv_sta; - struct minstrel_priv *mp = priv; -- int sample_idx; -+ u16 sample_idx; - - if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && - !minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_prob_rate))) -@@ -1504,11 +1590,19 @@ minstrel_ht_get_rate(void *priv, struct - /* Don't use EAPOL frames for sampling on non-mrr hw */ - if (mp->hw->max_rates == 1 && - (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) -- sample_idx = -1; -- else -- sample_idx = minstrel_get_sample_rate(mp, mi); -+ return; -+ -+ if (mp->hw->max_rates == 1 && mp->sample_switch && -+ (mi->total_packets_cur >= SAMPLE_SWITCH_THR || -+ mp->sample_switch == 1)) -+ return; -+ -+ if (time_is_before_jiffies(mi->sample_time)) -+ return; - -- if (sample_idx < 0) -+ mi->sample_time = jiffies + MINSTREL_SAMPLE_INTERVAL; -+ sample_idx = minstrel_ht_get_sample_rate(mp, mi); -+ if (!sample_idx) - return; - - sample_group = &minstrel_mcs_groups[MI_RATE_GROUP(sample_idx)]; -@@ -1629,16 +1723,6 @@ minstrel_ht_update_caps(void *priv, stru - - mi->avg_ampdu_len = MINSTREL_FRAC(1, 1); - -- /* When using MRR, sample more on the first attempt, without delay */ -- if (mp->has_mrr) { -- mi->sample_count = 16; -- mi->sample_wait = 0; -- } else { -- mi->sample_count = 8; -- mi->sample_wait = 8; -- } -- mi->sample_tries = 4; -- - if (!use_vht) { - stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >> - IEEE80211_HT_CAP_RX_STBC_SHIFT; ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -69,6 +69,8 @@ - #define MI_RATE_IDX(_rate) FIELD_GET(MI_RATE_IDX_MASK, _rate) - #define MI_RATE_GROUP(_rate) FIELD_GET(MI_RATE_GROUP_MASK, _rate) - -+#define MINSTREL_SAMPLE_RATES 5 /* rates per sample type */ -+#define MINSTREL_SAMPLE_INTERVAL (HZ / 50) - - struct minstrel_priv { - struct ieee80211_hw *hw; -@@ -126,6 +128,13 @@ struct minstrel_rate_stats { - bool retry_updated; - }; - -+enum minstrel_sample_type { -+ MINSTREL_SAMPLE_TYPE_INC, -+ MINSTREL_SAMPLE_TYPE_JUMP, -+ MINSTREL_SAMPLE_TYPE_SLOW, -+ __MINSTREL_SAMPLE_TYPE_MAX -+}; -+ - struct minstrel_mcs_group_data { - u8 index; - u8 column; -@@ -144,6 +153,12 @@ enum minstrel_sample_mode { - MINSTREL_SAMPLE_PENDING, - }; - -+struct minstrel_sample_category { -+ u8 sample_group; -+ u16 sample_rates[MINSTREL_SAMPLE_RATES]; -+ u16 cur_sample_rates[MINSTREL_SAMPLE_RATES]; -+}; -+ - struct minstrel_ht_sta { - struct ieee80211_sta *sta; - -@@ -175,16 +190,14 @@ struct minstrel_ht_sta { - /* tx flags to add for frames for this sta */ - u32 tx_flags; - -- u8 sample_wait; -- u8 sample_tries; -- u8 sample_count; -+ unsigned long sample_time; -+ struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX]; -+ -+ u8 sample_seq; - - enum minstrel_sample_mode sample_mode; - u16 sample_rate; - -- /* current MCS group to be sampled */ -- u8 sample_group; -- - u8 band; - - /* Bitfield of supported MCS rates of all groups */ diff --git a/package/kernel/mac80211/patches/subsys/350-mac80211-minstrel_ht-show-sampling-rates-in-debugfs.patch b/package/kernel/mac80211/patches/subsys/350-mac80211-minstrel_ht-show-sampling-rates-in-debugfs.patch deleted file mode 100644 index 041ba31a378..00000000000 --- a/package/kernel/mac80211/patches/subsys/350-mac80211-minstrel_ht-show-sampling-rates-in-debugfs.patch +++ /dev/null @@ -1,58 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 23 Jan 2021 00:10:34 +0100 -Subject: [PATCH] mac80211: minstrel_ht: show sampling rates in debugfs - -This makes it easier to see what rates are going to be tested next - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c -+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c -@@ -32,6 +32,18 @@ minstrel_stats_release(struct inode *ino - return 0; - } - -+static bool -+minstrel_ht_is_sample_rate(struct minstrel_ht_sta *mi, int idx) -+{ -+ int type, i; -+ -+ for (type = 0; type < ARRAY_SIZE(mi->sample); type++) -+ for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) -+ if (mi->sample[type].cur_sample_rates[i] == idx) -+ return true; -+ return false; -+} -+ - static char * - minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) - { -@@ -84,6 +96,7 @@ minstrel_ht_stats_dump(struct minstrel_h - *(p++) = (idx == mi->max_tp_rate[2]) ? 'C' : ' '; - *(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' '; - *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' '; -+ *(p++) = minstrel_ht_is_sample_rate(mi, idx) ? 'S' : ' '; - - if (gflags & IEEE80211_TX_RC_MCS) { - p += sprintf(p, " MCS%-2u", (mg->streams - 1) * 8 + j); -@@ -145,9 +158,9 @@ minstrel_ht_stats_open(struct inode *ino - - p += sprintf(p, "\n"); - p += sprintf(p, -- " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n"); -+ " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n"); - p += sprintf(p, -- "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n"); -+ "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n"); - - p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p); - for (i = 0; i < MINSTREL_CCK_GROUP; i++) -@@ -228,6 +241,7 @@ minstrel_ht_stats_csv_dump(struct minstr - p += sprintf(p, "%s" ,((idx == mi->max_tp_rate[2]) ? "C" : "")); - p += sprintf(p, "%s" ,((idx == mi->max_tp_rate[3]) ? "D" : "")); - p += sprintf(p, "%s" ,((idx == mi->max_prob_rate) ? "P" : "")); -+ p += sprintf(p, "%s", (minstrel_ht_is_sample_rate(mi, idx) ? "S" : "")); - - if (gflags & IEEE80211_TX_RC_MCS) { - p += sprintf(p, ",MCS%-2u,", (mg->streams - 1) * 8 + j); diff --git a/package/kernel/mac80211/patches/subsys/351-mac80211-minstrel_ht-remove-sample-rate-switching-co.patch b/package/kernel/mac80211/patches/subsys/351-mac80211-minstrel_ht-remove-sample-rate-switching-co.patch deleted file mode 100644 index 8170ff85f8a..00000000000 --- a/package/kernel/mac80211/patches/subsys/351-mac80211-minstrel_ht-remove-sample-rate-switching-co.patch +++ /dev/null @@ -1,279 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 23 Jan 2021 07:18:26 +0100 -Subject: [PATCH] mac80211: minstrel_ht: remove sample rate switching code for - constrained devices - -This was added to mitigate the effects of too much sampling on devices that -use a static global fallback table instead of configurable multi-rate retry. -Now that the sampling algorithm is improved, this code path no longer performs -any better than the standard probing on affected devices. - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -648,27 +648,6 @@ __minstrel_ht_get_sample_rate(struct min - return 0; - } - --static void --minstrel_ht_rate_sample_switch(struct minstrel_priv *mp, -- struct minstrel_ht_sta *mi) --{ -- u16 rate; -- -- /* -- * Use rate switching instead of probing packets for devices with -- * little control over retry fallback behavior -- */ -- if (mp->hw->max_rates > 1) -- return; -- -- rate = __minstrel_ht_get_sample_rate(mi, MINSTREL_SAMPLE_TYPE_INC); -- if (!rate) -- return; -- -- mi->sample_rate = rate; -- mi->sample_mode = MINSTREL_SAMPLE_ACTIVE; --} -- - static inline int - minstrel_ewma(int old, int new, int weight) - { -@@ -1012,8 +991,7 @@ minstrel_ht_refill_sample_rates(struct m - * higher throughput rates, even if the probablity is a bit lower - */ - static void --minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, -- bool sample) -+minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) - { - struct minstrel_mcs_group_data *mg; - struct minstrel_rate_stats *mrs; -@@ -1023,18 +1001,6 @@ minstrel_ht_update_stats(struct minstrel - u16 index; - bool ht_supported = mi->sta->ht_cap.ht_supported; - -- mi->sample_mode = MINSTREL_SAMPLE_IDLE; -- -- if (sample) { -- mi->total_packets_cur = mi->total_packets - -- mi->total_packets_last; -- mi->total_packets_last = mi->total_packets; -- } -- if (!mp->sample_switch) -- sample = false; -- if (mi->total_packets_cur < SAMPLE_SWITCH_THR && mp->sample_switch != 1) -- sample = false; -- - if (mi->ampdu_packets > 0) { - if (!ieee80211_hw_check(mp->hw, TX_STATUS_NO_AMPDU_LEN)) - mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, -@@ -1148,16 +1114,12 @@ minstrel_ht_update_stats(struct minstrel - minstrel_ht_prob_rate_reduce_streams(mi); - minstrel_ht_refill_sample_rates(mi); - -- if (sample) -- minstrel_ht_rate_sample_switch(mp, mi); -- - #ifdef CPTCFG_MAC80211_DEBUGFS - /* use fixed index if set */ - if (mp->fixed_rate_idx != -1) { - for (i = 0; i < 4; i++) - mi->max_tp_rate[i] = mp->fixed_rate_idx; - mi->max_prob_rate = mp->fixed_rate_idx; -- mi->sample_mode = MINSTREL_SAMPLE_IDLE; - } - #endif - -@@ -1247,11 +1209,10 @@ minstrel_ht_tx_status(void *priv, struct - struct ieee80211_tx_info *info = st->info; - struct minstrel_ht_sta *mi = priv_sta; - struct ieee80211_tx_rate *ar = info->status.rates; -- struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL; -+ struct minstrel_rate_stats *rate, *rate2; - struct minstrel_priv *mp = priv; - u32 update_interval = mp->update_interval; - bool last, update = false; -- bool sample_status = false; - int i; - - /* This packet was aggregated but doesn't carry status info */ -@@ -1278,49 +1239,18 @@ minstrel_ht_tx_status(void *priv, struct - mi->ampdu_packets++; - mi->ampdu_len += info->status.ampdu_len; - -- if (mi->sample_mode != MINSTREL_SAMPLE_IDLE) -- rate_sample = minstrel_get_ratestats(mi, mi->sample_rate); -- - last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]); - for (i = 0; !last; i++) { - last = (i == IEEE80211_TX_MAX_RATES - 1) || - !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]); - - rate = minstrel_ht_get_stats(mp, mi, &ar[i]); -- if (rate == rate_sample) -- sample_status = true; -- - if (last) - rate->success += info->status.ampdu_ack_len; - - rate->attempts += ar[i].count * info->status.ampdu_len; - } - -- switch (mi->sample_mode) { -- case MINSTREL_SAMPLE_IDLE: -- if (mp->hw->max_rates > 1 || -- mi->total_packets_cur < SAMPLE_SWITCH_THR) -- update_interval /= 2; -- break; -- -- case MINSTREL_SAMPLE_ACTIVE: -- if (!sample_status) -- break; -- -- mi->sample_mode = MINSTREL_SAMPLE_PENDING; -- update = true; -- break; -- -- case MINSTREL_SAMPLE_PENDING: -- if (sample_status) -- break; -- -- update = true; -- minstrel_ht_update_stats(mp, mi, false); -- break; -- } -- -- - if (mp->hw->max_rates > 1) { - /* - * check for sudden death of spatial multiplexing, -@@ -1343,7 +1273,7 @@ minstrel_ht_tx_status(void *priv, struct - - if (time_after(jiffies, mi->last_stats_update + update_interval)) { - update = true; -- minstrel_ht_update_stats(mp, mi, true); -+ minstrel_ht_update_stats(mp, mi); - } - - if (update) -@@ -1522,18 +1452,14 @@ static void - minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) - { - struct ieee80211_sta_rates *rates; -- u16 first_rate = mi->max_tp_rate[0]; - int i = 0; - -- if (mi->sample_mode == MINSTREL_SAMPLE_ACTIVE) -- first_rate = mi->sample_rate; -- - rates = kzalloc(sizeof(*rates), GFP_ATOMIC); - if (!rates) - return; - - /* Start with max_tp_rate[0] */ -- minstrel_ht_set_rate(mp, mi, rates, i++, first_rate); -+ minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]); - - if (mp->hw->max_rates >= 3) { - /* At least 3 tx rates supported, use max_tp_rate[1] next */ -@@ -1592,11 +1518,6 @@ minstrel_ht_get_rate(void *priv, struct - (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) - return; - -- if (mp->hw->max_rates == 1 && mp->sample_switch && -- (mi->total_packets_cur >= SAMPLE_SWITCH_THR || -- mp->sample_switch == 1)) -- return; -- - if (time_is_before_jiffies(mi->sample_time)) - return; - -@@ -1810,7 +1731,7 @@ minstrel_ht_update_caps(void *priv, stru - minstrel_ht_update_ofdm(mp, mi, sband, sta); - - /* create an initial rate table with the lowest supported rates */ -- minstrel_ht_update_stats(mp, mi, true); -+ minstrel_ht_update_stats(mp, mi); - minstrel_ht_update_rates(mp, mi); - } - -@@ -1926,8 +1847,6 @@ minstrel_ht_alloc(struct ieee80211_hw *h - if (!mp) - return NULL; - -- mp->sample_switch = -1; -- - /* contention window settings - * Just an approximation. Using the per-queue values would complicate - * the calculations and is probably unnecessary */ -@@ -1947,7 +1866,7 @@ minstrel_ht_alloc(struct ieee80211_hw *h - mp->has_mrr = true; - - mp->hw = hw; -- mp->update_interval = HZ / 10; -+ mp->update_interval = HZ / 20; - - minstrel_ht_init_cck_rates(mp); - for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++) -@@ -1965,8 +1884,6 @@ static void minstrel_ht_add_debugfs(stru - mp->fixed_rate_idx = (u32) -1; - debugfs_create_u32("fixed_rate_idx", S_IRUGO | S_IWUGO, debugfsdir, - &mp->fixed_rate_idx); -- debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir, -- &mp->sample_switch); - } - #endif - ---- a/net/mac80211/rc80211_minstrel_ht.h -+++ b/net/mac80211/rc80211_minstrel_ht.h -@@ -75,7 +75,6 @@ - struct minstrel_priv { - struct ieee80211_hw *hw; - bool has_mrr; -- u32 sample_switch; - unsigned int cw_min; - unsigned int cw_max; - unsigned int max_retry; -@@ -147,12 +146,6 @@ struct minstrel_mcs_group_data { - struct minstrel_rate_stats rates[MCS_GROUP_RATES]; - }; - --enum minstrel_sample_mode { -- MINSTREL_SAMPLE_IDLE, -- MINSTREL_SAMPLE_ACTIVE, -- MINSTREL_SAMPLE_PENDING, --}; -- - struct minstrel_sample_category { - u8 sample_group; - u16 sample_rates[MINSTREL_SAMPLE_RATES]; -@@ -182,23 +175,19 @@ struct minstrel_ht_sta { - unsigned int overhead_legacy; - unsigned int overhead_legacy_rtscts; - -- unsigned int total_packets_last; -- unsigned int total_packets_cur; - unsigned int total_packets; - unsigned int sample_packets; - - /* tx flags to add for frames for this sta */ - u32 tx_flags; - -- unsigned long sample_time; -- struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX]; -+ u8 band; - - u8 sample_seq; -- -- enum minstrel_sample_mode sample_mode; - u16 sample_rate; - -- u8 band; -+ unsigned long sample_time; -+ struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX]; - - /* Bitfield of supported MCS rates of all groups */ - u16 supported[MINSTREL_GROUPS_NB]; diff --git a/package/kernel/mac80211/patches/subsys/352-mac80211-minstrel_ht-fix-regression-in-the-max_prob_.patch b/package/kernel/mac80211/patches/subsys/352-mac80211-minstrel_ht-fix-regression-in-the-max_prob_.patch deleted file mode 100644 index a366a921d4f..00000000000 --- a/package/kernel/mac80211/patches/subsys/352-mac80211-minstrel_ht-fix-regression-in-the-max_prob_.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Tue, 26 Jan 2021 16:40:52 +0100 -Subject: [PATCH] mac80211: minstrel_ht: fix regression in the max_prob_rate - fix - -Since mi->max_prob_rate is overwritten after the loop that calls -minstrel_ht_set_best_prob_rate, the new best rate needs to be written to *dest - -Fixes: a7fca4e4037f ("mac80211: minstrel_ht: fix max probability rate selection") -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -545,7 +545,7 @@ minstrel_ht_set_best_prob_rate(struct mi - cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, - mrs->prob_avg); - if (cur_tp_avg > tmp_tp_avg) -- mi->max_prob_rate = index; -+ *dest = index; - - max_gpr_tp_avg = minstrel_ht_get_tp_avg(mi, max_gpr_group, - max_gpr_idx, diff --git a/package/kernel/mac80211/patches/subsys/371-mac80211-don-t-apply-flow-control-on-management-fram.patch b/package/kernel/mac80211/patches/subsys/371-mac80211-don-t-apply-flow-control-on-management-fram.patch deleted file mode 100644 index 8d094a3632e..00000000000 --- a/package/kernel/mac80211/patches/subsys/371-mac80211-don-t-apply-flow-control-on-management-fram.patch +++ /dev/null @@ -1,60 +0,0 @@ -From: Johannes Berg <johannes.berg@intel.com> -Date: Fri, 19 Mar 2021 23:28:01 +0100 -Subject: [PATCH] mac80211: don't apply flow control on management frames - -In some cases (depending on the driver, but it's true e.g. for -iwlwifi) we're using an internal TXQ for management packets, -mostly to simplify the code and to have a place to queue them. -However, it appears that in certain cases we can confuse the -code and management frames are dropped, which is certainly not -what we want. - -Short-circuit the processing of management frames. To keep the -impact minimal, only put them on the frags queue and check the -tid == management only for doing that and to skip the airtime -fairness checks, if applicable. - -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -5,7 +5,7 @@ - * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> - * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> - * Copyright 2013-2014 Intel Mobile Communications GmbH -- * Copyright (C) 2018-2020 Intel Corporation -+ * Copyright (C) 2018-2021 Intel Corporation - * - * Transmit and frame generation functions. - */ -@@ -1401,8 +1401,17 @@ static void ieee80211_txq_enqueue(struct - ieee80211_set_skb_enqueue_time(skb); - - spin_lock_bh(&fq->lock); -- fq_tin_enqueue(fq, tin, flow_idx, skb, -- fq_skb_free_func); -+ /* -+ * For management frames, don't really apply codel etc., -+ * we don't want to apply any shaping or anything we just -+ * want to simplify the driver API by having them on the -+ * txqi. -+ */ -+ if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) -+ __skb_queue_tail(&txqi->frags, skb); -+ else -+ fq_tin_enqueue(fq, tin, flow_idx, skb, -+ fq_skb_free_func); - spin_unlock_bh(&fq->lock); - } - -@@ -3844,6 +3853,9 @@ bool ieee80211_txq_airtime_check(struct - if (!txq->sta) - return true; - -+ if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) -+ return true; -+ - sta = container_of(txq->sta, struct sta_info, sta); - if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < - sta->airtime[txq->ac].aql_limit_low) diff --git a/package/kernel/mac80211/patches/subsys/372-mac80211-set-sk_pacing_shift-for-802.3-txpath.patch b/package/kernel/mac80211/patches/subsys/372-mac80211-set-sk_pacing_shift-for-802.3-txpath.patch deleted file mode 100644 index 5bc1469a3f1..00000000000 --- a/package/kernel/mac80211/patches/subsys/372-mac80211-set-sk_pacing_shift-for-802.3-txpath.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Lorenzo Bianconi <lorenzo@kernel.org> -Date: Mon, 8 Mar 2021 23:01:49 +0100 -Subject: [PATCH] mac80211: set sk_pacing_shift for 802.3 txpath - -Similar to 802.11 txpath, set socket sk_pacing_shift for 802.3 tx path. - -Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> ---- - ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -4171,6 +4171,9 @@ static bool ieee80211_tx_8023(struct iee - unsigned long flags; - int q = info->hw_queue; - -+ if (sta) -+ sk_pacing_shift_update(skb->sk, local->hw.tx_sk_pacing_shift); -+ - if (ieee80211_queue_skb(local, sdata, sta, skb)) - return true; - diff --git a/package/kernel/mac80211/patches/subsys/373-mac80211-support-Rx-timestamp-calculation-for-all-pr.patch b/package/kernel/mac80211/patches/subsys/373-mac80211-support-Rx-timestamp-calculation-for-all-pr.patch deleted file mode 100644 index 117fb35fcf1..00000000000 --- a/package/kernel/mac80211/patches/subsys/373-mac80211-support-Rx-timestamp-calculation-for-all-pr.patch +++ /dev/null @@ -1,134 +0,0 @@ -From: Avraham Stern <avraham.stern@intel.com> -Date: Sun, 6 Dec 2020 14:54:45 +0200 -Subject: [PATCH] mac80211: support Rx timestamp calculation for all preamble - types - -Add support for calculating the Rx timestamp for HE frames. -Since now all frame types are supported, allow setting the Rx -timestamp regardless of the frame type. - -Signed-off-by: Avraham Stern <avraham.stern@intel.com> -Signed-off-by: Luca Coelho <luciano.coelho@intel.com> -Link: https://lore.kernel.org/r/iwlwifi.20201206145305.4786559af475.Ia54486bb0a12e5351f9d5c60ef6fcda7c9e7141c@changeid -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -1587,13 +1587,8 @@ ieee80211_have_rx_timestamp(struct ieee8 - { - WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START && - status->flag & RX_FLAG_MACTIME_END); -- if (status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END)) -- return true; -- /* can't handle non-legacy preamble yet */ -- if (status->flag & RX_FLAG_MACTIME_PLCP_START && -- status->encoding == RX_ENC_LEGACY) -- return true; -- return false; -+ return !!(status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END | -+ RX_FLAG_MACTIME_PLCP_START)); - } - - void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata); ---- a/net/mac80211/util.c -+++ b/net/mac80211/util.c -@@ -3665,6 +3665,7 @@ u64 ieee80211_calculate_rx_timestamp(str - u64 ts = status->mactime; - struct rate_info ri; - u16 rate; -+ u8 n_ltf; - - if (WARN_ON(!ieee80211_have_rx_timestamp(status))) - return 0; -@@ -3675,11 +3676,58 @@ u64 ieee80211_calculate_rx_timestamp(str - - /* Fill cfg80211 rate info */ - switch (status->encoding) { -+ case RX_ENC_HE: -+ ri.flags |= RATE_INFO_FLAGS_HE_MCS; -+ ri.mcs = status->rate_idx; -+ ri.nss = status->nss; -+ ri.he_ru_alloc = status->he_ru; -+ if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) -+ ri.flags |= RATE_INFO_FLAGS_SHORT_GI; -+ -+ /* -+ * See P802.11ax_D6.0, section 27.3.4 for -+ * VHT PPDU format. -+ */ -+ if (status->flag & RX_FLAG_MACTIME_PLCP_START) { -+ mpdu_offset += 2; -+ ts += 36; -+ -+ /* -+ * TODO: -+ * For HE MU PPDU, add the HE-SIG-B. -+ * For HE ER PPDU, add 8us for the HE-SIG-A. -+ * For HE TB PPDU, add 4us for the HE-STF. -+ * Add the HE-LTF durations - variable. -+ */ -+ } -+ -+ break; - case RX_ENC_HT: - ri.mcs = status->rate_idx; - ri.flags |= RATE_INFO_FLAGS_MCS; - if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) - ri.flags |= RATE_INFO_FLAGS_SHORT_GI; -+ -+ /* -+ * See P802.11REVmd_D3.0, section 19.3.2 for -+ * HT PPDU format. -+ */ -+ if (status->flag & RX_FLAG_MACTIME_PLCP_START) { -+ mpdu_offset += 2; -+ if (status->enc_flags & RX_ENC_FLAG_HT_GF) -+ ts += 24; -+ else -+ ts += 32; -+ -+ /* -+ * Add Data HT-LTFs per streams -+ * TODO: add Extension HT-LTFs, 4us per LTF -+ */ -+ n_ltf = ((ri.mcs >> 3) & 3) + 1; -+ n_ltf = n_ltf == 3 ? 4 : n_ltf; -+ ts += n_ltf * 4; -+ } -+ - break; - case RX_ENC_VHT: - ri.flags |= RATE_INFO_FLAGS_VHT_MCS; -@@ -3687,6 +3735,23 @@ u64 ieee80211_calculate_rx_timestamp(str - ri.nss = status->nss; - if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) - ri.flags |= RATE_INFO_FLAGS_SHORT_GI; -+ -+ /* -+ * See P802.11REVmd_D3.0, section 21.3.2 for -+ * VHT PPDU format. -+ */ -+ if (status->flag & RX_FLAG_MACTIME_PLCP_START) { -+ mpdu_offset += 2; -+ ts += 36; -+ -+ /* -+ * Add VHT-LTFs per streams -+ */ -+ n_ltf = (ri.nss != 1) && (ri.nss % 2) ? -+ ri.nss + 1 : ri.nss; -+ ts += 4 * n_ltf; -+ } -+ - break; - default: - WARN_ON(1); -@@ -3710,7 +3775,6 @@ u64 ieee80211_calculate_rx_timestamp(str - ri.legacy = DIV_ROUND_UP(bitrate, (1 << shift)); - - if (status->flag & RX_FLAG_MACTIME_PLCP_START) { -- /* TODO: handle HT/VHT preambles */ - if (status->band == NL80211_BAND_5GHZ) { - ts += 20 << shift; - mpdu_offset += 2; diff --git a/package/kernel/mac80211/patches/subsys/374-mac80211-move-A-MPDU-session-check-from-minstrel_ht-.patch b/package/kernel/mac80211/patches/subsys/374-mac80211-move-A-MPDU-session-check-from-minstrel_ht-.patch deleted file mode 100644 index 031f8e16360..00000000000 --- a/package/kernel/mac80211/patches/subsys/374-mac80211-move-A-MPDU-session-check-from-minstrel_ht-.patch +++ /dev/null @@ -1,126 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Thu, 17 Jun 2021 17:56:54 +0200 -Subject: [PATCH] mac80211: move A-MPDU session check from minstrel_ht to - mac80211 - -This avoids calling back into tx handlers from within the rate control module. -Preparation for deferring rate control until tx dequeue - -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -6160,6 +6160,11 @@ enum rate_control_capabilities { - * otherwise the NSS difference doesn't bother us. - */ - RATE_CTRL_CAPA_VHT_EXT_NSS_BW = BIT(0), -+ /** -+ * @RATE_CTRL_CAPA_AMPDU_TRIGGER: -+ * mac80211 should start A-MPDU sessions on tx -+ */ -+ RATE_CTRL_CAPA_AMPDU_TRIGGER = BIT(1), - }; - - struct rate_control_ops { ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -1153,29 +1153,6 @@ minstrel_downgrade_prob_rate(struct mins - } - - static void --minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb) --{ -- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; -- struct sta_info *sta = container_of(pubsta, struct sta_info, sta); -- u16 tid; -- -- if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO) -- return; -- -- if (unlikely(!ieee80211_is_data_qos(hdr->frame_control))) -- return; -- -- if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE))) -- return; -- -- tid = ieee80211_get_tid(hdr); -- if (likely(sta->ampdu_mlme.tid_tx[tid])) -- return; -- -- ieee80211_start_tx_ba_session(pubsta, tid, 0); --} -- --static void - minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, - void *priv_sta, struct ieee80211_tx_status *st) - { -@@ -1477,10 +1454,6 @@ minstrel_ht_get_rate(void *priv, struct - struct minstrel_priv *mp = priv; - u16 sample_idx; - -- if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && -- !minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_prob_rate))) -- minstrel_aggr_check(sta, txrc->skb); -- - info->flags |= mi->tx_flags; - - #ifdef CPTCFG_MAC80211_DEBUGFS -@@ -1894,6 +1867,7 @@ static u32 minstrel_ht_get_expected_thro - - static const struct rate_control_ops mac80211_minstrel_ht = { - .name = "minstrel_ht", -+ .capa = RATE_CTRL_CAPA_AMPDU_TRIGGER, - .tx_status_ext = minstrel_ht_tx_status, - .get_rate = minstrel_ht_get_rate, - .rate_init = minstrel_ht_rate_init, ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -3931,6 +3931,29 @@ void ieee80211_txq_schedule_start(struct - } - EXPORT_SYMBOL(ieee80211_txq_schedule_start); - -+static void -+ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata, -+ struct sta_info *sta, -+ struct sk_buff *skb) -+{ -+ struct rate_control_ref *ref = sdata->local->rate_ctrl; -+ u16 tid; -+ -+ if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) -+ return; -+ -+ if (!sta || !sta->sta.ht_cap.ht_supported || -+ !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || -+ skb->protocol == sdata->control_port_protocol) -+ return; -+ -+ tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; -+ if (likely(sta->ampdu_mlme.tid_tx[tid])) -+ return; -+ -+ ieee80211_start_tx_ba_session(&sta->sta, tid, 0); -+} -+ - void __ieee80211_subif_start_xmit(struct sk_buff *skb, - struct net_device *dev, - u32 info_flags, -@@ -3961,6 +3984,8 @@ void __ieee80211_subif_start_xmit(struct - skb_get_hash(skb); - } - -+ ieee80211_aggr_check(sdata, sta, skb); -+ - if (sta) { - struct ieee80211_fast_tx *fast_tx; - -@@ -4224,6 +4249,8 @@ static void ieee80211_8023_xmit(struct i - - memset(info, 0, sizeof(*info)); - -+ ieee80211_aggr_check(sdata, sta, skb); -+ - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); - if (tid_tx) { diff --git a/package/kernel/mac80211/patches/subsys/375-mac80211-call-ieee80211_tx_h_rate_ctrl-when-dequeue.patch b/package/kernel/mac80211/patches/subsys/375-mac80211-call-ieee80211_tx_h_rate_ctrl-when-dequeue.patch deleted file mode 100644 index cf84fca68a3..00000000000 --- a/package/kernel/mac80211/patches/subsys/375-mac80211-call-ieee80211_tx_h_rate_ctrl-when-dequeue.patch +++ /dev/null @@ -1,114 +0,0 @@ -From: Ryder Lee <ryder.lee@mediatek.com> -Date: Fri, 28 May 2021 14:05:41 +0800 -Subject: [PATCH] mac80211: call ieee80211_tx_h_rate_ctrl() when dequeue - -Make ieee80211_tx_h_rate_ctrl() get called on dequeue to improve -performance since it reduces the turnaround time for rate control. - -Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> ---- - ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -1778,8 +1778,6 @@ static int invoke_tx_handlers_early(stru - CALL_TXH(ieee80211_tx_h_ps_buf); - CALL_TXH(ieee80211_tx_h_check_control_port_protocol); - CALL_TXH(ieee80211_tx_h_select_key); -- if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) -- CALL_TXH(ieee80211_tx_h_rate_ctrl); - - txh_done: - if (unlikely(res == TX_DROP)) { -@@ -1812,6 +1810,9 @@ static int invoke_tx_handlers_late(struc - goto txh_done; - } - -+ if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) -+ CALL_TXH(ieee80211_tx_h_rate_ctrl); -+ - CALL_TXH(ieee80211_tx_h_michael_mic_add); - CALL_TXH(ieee80211_tx_h_sequence); - CALL_TXH(ieee80211_tx_h_fragment); -@@ -3382,15 +3383,21 @@ out: - * Can be called while the sta lock is held. Anything that can cause packets to - * be generated will cause deadlock! - */ --static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata, -- struct sta_info *sta, u8 pn_offs, -- struct ieee80211_key *key, -- struct sk_buff *skb) -+static ieee80211_tx_result -+ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata, -+ struct sta_info *sta, u8 pn_offs, -+ struct ieee80211_key *key, -+ struct ieee80211_tx_data *tx) - { -+ struct sk_buff *skb = tx->skb; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (void *)skb->data; - u8 tid = IEEE80211_NUM_TIDS; - -+ if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && -+ ieee80211_tx_h_rate_ctrl(tx) != TX_CONTINUE) -+ return TX_DROP; -+ - if (key) - info->control.hw_key = &key->conf; - -@@ -3439,6 +3446,8 @@ static void ieee80211_xmit_fast_finish(s - break; - } - } -+ -+ return TX_CONTINUE; - } - - static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, -@@ -3542,24 +3551,17 @@ static bool ieee80211_xmit_fast(struct i - tx.sta = sta; - tx.key = fast_tx->key; - -- if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { -- tx.skb = skb; -- r = ieee80211_tx_h_rate_ctrl(&tx); -- skb = tx.skb; -- tx.skb = NULL; -- -- if (r != TX_CONTINUE) { -- if (r != TX_QUEUED) -- kfree_skb(skb); -- return true; -- } -- } -- - if (ieee80211_queue_skb(local, sdata, sta, skb)) - return true; - -- ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, -- fast_tx->key, skb); -+ tx.skb = skb; -+ r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, -+ fast_tx->key, &tx); -+ tx.skb = NULL; -+ if (r == TX_DROP) { -+ kfree_skb(skb); -+ return true; -+ } - - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) - sdata = container_of(sdata->bss, -@@ -3670,8 +3672,12 @@ begin: - (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) - pn_offs = ieee80211_hdrlen(hdr->frame_control); - -- ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, -- tx.key, skb); -+ r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, -+ tx.key, &tx); -+ if (r != TX_CONTINUE) { -+ ieee80211_free_txskb(&local->hw, skb); -+ goto begin; -+ } - } else { - if (invoke_tx_handlers_late(&tx)) - goto begin; diff --git a/package/kernel/mac80211/patches/subsys/376-mac80211-add-rate-control-support-for-encap-offload.patch b/package/kernel/mac80211/patches/subsys/376-mac80211-add-rate-control-support-for-encap-offload.patch deleted file mode 100644 index 43a4a1334df..00000000000 --- a/package/kernel/mac80211/patches/subsys/376-mac80211-add-rate-control-support-for-encap-offload.patch +++ /dev/null @@ -1,119 +0,0 @@ -From: Ryder Lee <ryder.lee@mediatek.com> -Date: Fri, 28 May 2021 14:05:43 +0800 -Subject: [PATCH] mac80211: add rate control support for encap offload - -The software rate control cannot deal with encap offload, so fix it. - -Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> ---- - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -2024,6 +2024,15 @@ static inline void ieee80211_tx_skb(stru - ieee80211_tx_skb_tid(sdata, skb, 7); - } - -+static inline bool ieee80211_is_tx_data(struct sk_buff *skb) -+{ -+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; -+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -+ -+ return info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP || -+ ieee80211_is_data(hdr->frame_control); -+} -+ - u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, - struct ieee802_11_elems *elems, - u64 filter, u32 crc, u8 *transmitter_bssid, ---- a/net/mac80211/rate.c -+++ b/net/mac80211/rate.c -@@ -297,15 +297,11 @@ void ieee80211_check_rate_mask(struct ie - static bool rc_no_data_or_no_ack_use_min(struct ieee80211_tx_rate_control *txrc) - { - struct sk_buff *skb = txrc->skb; -- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -- __le16 fc; -- -- fc = hdr->frame_control; - - return (info->flags & (IEEE80211_TX_CTL_NO_ACK | - IEEE80211_TX_CTL_USE_MINRATE)) || -- !ieee80211_is_data(fc); -+ !ieee80211_is_tx_data(skb); - } - - static void rc_send_low_basicrate(struct ieee80211_tx_rate *rate, -@@ -870,7 +866,6 @@ void ieee80211_get_tx_rates(struct ieee8 - int max_rates) - { - struct ieee80211_sub_if_data *sdata; -- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_supported_band *sband; - -@@ -882,7 +877,7 @@ void ieee80211_get_tx_rates(struct ieee8 - sdata = vif_to_sdata(vif); - sband = sdata->local->hw.wiphy->bands[info->band]; - -- if (ieee80211_is_data(hdr->frame_control)) -+ if (ieee80211_is_tx_data(skb)) - rate_control_apply_mask(sdata, sta, sband, dest, max_rates); - - if (dest[0].idx < 0) ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -679,6 +679,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 - u32 len; - struct ieee80211_tx_rate_control txrc; - struct ieee80211_sta_rates *ratetbl = NULL; -+ bool encap = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; - bool assoc = false; - - memset(&txrc, 0, sizeof(txrc)); -@@ -720,7 +721,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 - * just wants a probe response. - */ - if (tx->sdata->vif.bss_conf.use_short_preamble && -- (ieee80211_is_data(hdr->frame_control) || -+ (ieee80211_is_tx_data(tx->skb) || - (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) - txrc.short_preamble = true; - -@@ -742,7 +743,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 - "%s: Dropped data frame as no usable bitrate found while " - "scanning and associated. Target station: " - "%pM on %d GHz band\n", -- tx->sdata->name, hdr->addr1, -+ tx->sdata->name, -+ encap ? ((struct ethhdr *)hdr)->h_dest : hdr->addr1, - info->band ? 5 : 2)) - return TX_DROP; - -@@ -776,7 +778,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 - - if (txrc.reported_rate.idx < 0) { - txrc.reported_rate = tx->rate; -- if (tx->sta && ieee80211_is_data(hdr->frame_control)) -+ if (tx->sta && ieee80211_is_tx_data(tx->skb)) - tx->sta->tx_stats.last_rate = txrc.reported_rate; - } else if (tx->sta) - tx->sta->tx_stats.last_rate = txrc.reported_rate; -@@ -3660,8 +3662,16 @@ begin: - else - info->flags &= ~IEEE80211_TX_CTL_AMPDU; - -- if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) -+ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { -+ if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { -+ r = ieee80211_tx_h_rate_ctrl(&tx); -+ if (r != TX_CONTINUE) { -+ ieee80211_free_txskb(&local->hw, skb); -+ goto begin; -+ } -+ } - goto encap_out; -+ } - - if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { - struct sta_info *sta = container_of(txq->sta, struct sta_info, diff --git a/package/kernel/mac80211/patches/subsys/377-mac80211-minstrel_ht-fix-sample-time-check.patch b/package/kernel/mac80211/patches/subsys/377-mac80211-minstrel_ht-fix-sample-time-check.patch deleted file mode 100644 index d4b327c69c9..00000000000 --- a/package/kernel/mac80211/patches/subsys/377-mac80211-minstrel_ht-fix-sample-time-check.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Thu, 17 Jun 2021 12:05:54 +0200 -Subject: [PATCH] mac80211: minstrel_ht: fix sample time check - -We need to skip sampling if the next sample time is after jiffies, not before. -This patch fixes an issue where in some cases only very little sampling (or none -at all) is performed, leading to really bad data rates - -Fixes: 80d55154b2f8 ("mac80211: minstrel_ht: significantly redesign the rate probing strategy") -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/rc80211_minstrel_ht.c -+++ b/net/mac80211/rc80211_minstrel_ht.c -@@ -1466,7 +1466,7 @@ minstrel_ht_get_rate(void *priv, struct - (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) - return; - -- if (time_is_before_jiffies(mi->sample_time)) -+ if (time_is_after_jiffies(mi->sample_time)) - return; - - mi->sample_time = jiffies + MINSTREL_SAMPLE_INTERVAL; diff --git a/package/kernel/mac80211/patches/subsys/378-mac80211-remove-iwlwifi-specific-workaround-that-bro.patch b/package/kernel/mac80211/patches/subsys/378-mac80211-remove-iwlwifi-specific-workaround-that-bro.patch deleted file mode 100644 index a5ad377e6fb..00000000000 --- a/package/kernel/mac80211/patches/subsys/378-mac80211-remove-iwlwifi-specific-workaround-that-bro.patch +++ /dev/null @@ -1,51 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Sat, 19 Jun 2021 12:10:14 +0200 -Subject: [PATCH] mac80211: remove iwlwifi specific workaround that broke sta - NDP tx - -Sending nulldata packets is important for sw AP link probing and detecting -4-address mode links. The checks that dropped these packets were apparently -added to work around an iwlwifi firmware bug with multi-TID aggregation. - -Fixes: 41cbb0f5a295 ("mac80211: add support for HE") -Cc: stable@vger.kernel.org -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c -+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c -@@ -1085,6 +1085,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mv - if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_INVALID_STA)) - return -1; - -+ if (unlikely(ieee80211_is_any_nullfunc(fc)) && sta->he_cap.has_he) -+ return -1; -+ - if (unlikely(ieee80211_is_probe_resp(fc))) - iwl_mvm_probe_resp_set_noa(mvm, skb); - ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -1094,11 +1094,6 @@ void ieee80211_send_nullfunc(struct ieee - struct ieee80211_hdr_3addr *nullfunc; - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - -- /* Don't send NDPs when STA is connected HE */ -- if (sdata->vif.type == NL80211_IFTYPE_STATION && -- !(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) -- return; -- - skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, - !ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP)); - if (!skb) -@@ -1130,10 +1125,6 @@ static void ieee80211_send_4addr_nullfun - if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) - return; - -- /* Don't send NDPs when connected HE */ -- if (!(sdata->u.mgd.flags & IEEE80211_STA_DISABLE_HE)) -- return; -- - skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); - if (!skb) - return; diff --git a/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch b/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch deleted file mode 100644 index 2ad083f1507..00000000000 --- a/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch +++ /dev/null @@ -1,112 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Tue, 29 Jun 2021 13:25:09 +0200 -Subject: [PATCH] mac80211: fix starting aggregation sessions on mesh - interfaces - -The logic for starting aggregation sessions was recently moved from minstrel_ht -to mac80211, into the subif tx handler just after the sta lookup. -Unfortunately this didn't work for mesh interfaces, since the sta lookup is -deferred until a much later point in time on those. -Fix this by also calling the aggregation check right after the deferred sta -lookup. - -Fixes: 08a46c642001 ("mac80211: move A-MPDU session check from minstrel_ht to mac80211") -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -1159,6 +1159,29 @@ static bool ieee80211_tx_prep_agg(struct - return queued; - } - -+static void -+ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata, -+ struct sta_info *sta, -+ struct sk_buff *skb) -+{ -+ struct rate_control_ref *ref = sdata->local->rate_ctrl; -+ u16 tid; -+ -+ if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) -+ return; -+ -+ if (!sta || !sta->sta.ht_cap.ht_supported || -+ !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || -+ skb->protocol == sdata->control_port_protocol) -+ return; -+ -+ tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; -+ if (likely(sta->ampdu_mlme.tid_tx[tid])) -+ return; -+ -+ ieee80211_start_tx_ba_session(&sta->sta, tid, 0); -+} -+ - /* - * initialises @tx - * pass %NULL for the station if unknown, a valid pointer if known -@@ -1172,6 +1195,7 @@ ieee80211_tx_prepare(struct ieee80211_su - struct ieee80211_local *local = sdata->local; - struct ieee80211_hdr *hdr; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -+ bool aggr_check = false; - int tid; - - memset(tx, 0, sizeof(*tx)); -@@ -1200,8 +1224,10 @@ ieee80211_tx_prepare(struct ieee80211_su - } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { - tx->sta = sta_info_get_bss(sdata, hdr->addr1); - } -- if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) -+ if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { - tx->sta = sta_info_get(sdata, hdr->addr1); -+ aggr_check = true; -+ } - } - - if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && -@@ -1211,8 +1237,12 @@ ieee80211_tx_prepare(struct ieee80211_su - struct tid_ampdu_tx *tid_tx; - - tid = ieee80211_get_tid(hdr); -- - tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); -+ if (!tid_tx && aggr_check) { -+ ieee80211_aggr_check(sdata, tx->sta, skb); -+ tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); -+ } -+ - if (tid_tx) { - bool queued; - -@@ -3947,29 +3977,6 @@ void ieee80211_txq_schedule_start(struct - } - EXPORT_SYMBOL(ieee80211_txq_schedule_start); - --static void --ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata, -- struct sta_info *sta, -- struct sk_buff *skb) --{ -- struct rate_control_ref *ref = sdata->local->rate_ctrl; -- u16 tid; -- -- if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) -- return; -- -- if (!sta || !sta->sta.ht_cap.ht_supported || -- !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || -- skb->protocol == sdata->control_port_protocol) -- return; -- -- tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; -- if (likely(sta->ampdu_mlme.tid_tx[tid])) -- return; -- -- ieee80211_start_tx_ba_session(&sta->sta, tid, 0); --} -- - void __ieee80211_subif_start_xmit(struct sk_buff *skb, - struct net_device *dev, - u32 info_flags, diff --git a/package/kernel/mac80211/patches/subsys/380-mac80211-introduce-aql_enable-node-in-debugfs.patch b/package/kernel/mac80211/patches/subsys/380-mac80211-introduce-aql_enable-node-in-debugfs.patch deleted file mode 100644 index b21b671c10a..00000000000 --- a/package/kernel/mac80211/patches/subsys/380-mac80211-introduce-aql_enable-node-in-debugfs.patch +++ /dev/null @@ -1,111 +0,0 @@ -From: Lorenzo Bianconi <lorenzo@kernel.org> -Date: Sat, 9 Jan 2021 18:57:51 +0100 -Subject: [PATCH] mac80211: introduce aql_enable node in debugfs - -Introduce aql_enable node in debugfs in order to enable/disable aql. -This is useful for debugging purpose. - -Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> -Link: https://lore.kernel.org/r/e7a934d5d84e4796c4f97ea5de4e66c824296b07.1610214851.git.lorenzo@kernel.org -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/net/mac80211/debugfs.c -+++ b/net/mac80211/debugfs.c -@@ -281,6 +281,56 @@ static const struct file_operations aql_ - .llseek = default_llseek, - }; - -+static ssize_t aql_enable_read(struct file *file, char __user *user_buf, -+ size_t count, loff_t *ppos) -+{ -+ char buf[3]; -+ int len; -+ -+ len = scnprintf(buf, sizeof(buf), "%d\n", -+ !static_key_false(&aql_disable.key)); -+ -+ return simple_read_from_buffer(user_buf, count, ppos, buf, len); -+} -+ -+static ssize_t aql_enable_write(struct file *file, const char __user *user_buf, -+ size_t count, loff_t *ppos) -+{ -+ bool aql_disabled = static_key_false(&aql_disable.key); -+ char buf[3]; -+ size_t len; -+ -+ if (count > sizeof(buf)) -+ return -EINVAL; -+ -+ if (copy_from_user(buf, user_buf, count)) -+ return -EFAULT; -+ -+ buf[sizeof(buf) - 1] = '\0'; -+ len = strlen(buf); -+ if (len > 0 && buf[len - 1] == '\n') -+ buf[len - 1] = 0; -+ -+ if (buf[0] == '0' && buf[1] == '\0') { -+ if (!aql_disabled) -+ static_branch_inc(&aql_disable); -+ } else if (buf[0] == '1' && buf[1] == '\0') { -+ if (aql_disabled) -+ static_branch_dec(&aql_disable); -+ } else { -+ return -EINVAL; -+ } -+ -+ return count; -+} -+ -+static const struct file_operations aql_enable_ops = { -+ .write = aql_enable_write, -+ .read = aql_enable_read, -+ .open = simple_open, -+ .llseek = default_llseek, -+}; -+ - static ssize_t force_tx_status_read(struct file *file, - char __user *user_buf, - size_t count, -@@ -569,6 +619,7 @@ void debugfs_hw_add(struct ieee80211_loc - DEBUGFS_ADD(power); - DEBUGFS_ADD(hw_conf); - DEBUGFS_ADD_MODE(force_tx_status, 0600); -+ DEBUGFS_ADD_MODE(aql_enable, 0600); - - if (local->ops->wake_tx_queue) - DEBUGFS_ADD_MODE(aqm, 0600); ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -1140,6 +1140,8 @@ enum mac80211_scan_state { - SCAN_ABORT, - }; - -+DECLARE_STATIC_KEY_FALSE(aql_disable); -+ - struct ieee80211_local { - /* embed the driver visible part. - * don't cast (use the static inlines below), but we keep ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -3887,6 +3887,8 @@ void __ieee80211_schedule_txq(struct iee - } - EXPORT_SYMBOL(__ieee80211_schedule_txq); - -+DEFINE_STATIC_KEY_FALSE(aql_disable); -+ - bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw, - struct ieee80211_txq *txq) - { -@@ -3896,6 +3898,9 @@ bool ieee80211_txq_airtime_check(struct - if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) - return true; - -+ if (static_branch_unlikely(&aql_disable)) -+ return true; -+ - if (!txq->sta) - return true; - diff --git a/package/kernel/mac80211/patches/subsys/381-mac80211-rearrange-struct-txq_info-for-fewer-holes.patch b/package/kernel/mac80211/patches/subsys/381-mac80211-rearrange-struct-txq_info-for-fewer-holes.patch deleted file mode 100644 index 708ad6f4601..00000000000 --- a/package/kernel/mac80211/patches/subsys/381-mac80211-rearrange-struct-txq_info-for-fewer-holes.patch +++ /dev/null @@ -1,39 +0,0 @@ -From: Johannes Berg <johannes.berg@intel.com> -Date: Fri, 18 Jun 2021 13:41:44 +0300 -Subject: [PATCH] mac80211: rearrange struct txq_info for fewer holes - -We can slightly decrease the size of struct txq_info by -rearranging some fields for fewer holes, so do that. - -Signed-off-by: Johannes Berg <johannes.berg@intel.com> -Signed-off-by: Luca Coelho <luciano.coelho@intel.com> -Link: https://lore.kernel.org/r/iwlwifi.20210618133832.1bf019a1fe2e.Ib54622b8d6dc1a9a7dc484e573c073119450538b@changeid -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -5,7 +5,7 @@ - * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> - * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> - * Copyright 2013-2015 Intel Mobile Communications GmbH -- * Copyright (C) 2018-2020 Intel Corporation -+ * Copyright (C) 2018-2021 Intel Corporation - */ - - #ifndef IEEE80211_I_H -@@ -848,9 +848,12 @@ struct txq_info { - struct fq_tin tin; - struct codel_vars def_cvars; - struct codel_stats cstats; -- struct sk_buff_head frags; -- struct list_head schedule_order; -+ - u16 schedule_round; -+ struct list_head schedule_order; -+ -+ struct sk_buff_head frags; -+ - unsigned long flags; - - /* keep last! */ diff --git a/package/kernel/mac80211/patches/subsys/382-mac80211-Switch-to-a-virtual-time-based-airtime-sche.patch b/package/kernel/mac80211/patches/subsys/382-mac80211-Switch-to-a-virtual-time-based-airtime-sche.patch deleted file mode 100644 index ba78f7a1428..00000000000 --- a/package/kernel/mac80211/patches/subsys/382-mac80211-Switch-to-a-virtual-time-based-airtime-sche.patch +++ /dev/null @@ -1,1277 +0,0 @@ -From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com> -Date: Wed, 23 Jun 2021 15:47:55 +0200 -Subject: [PATCH] mac80211: Switch to a virtual time-based airtime scheduler -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This switches the airtime scheduler in mac80211 to use a virtual -time-based scheduler instead of the round-robin scheduler used before. -This has a couple of advantages: - -- No need to sync up the round-robin scheduler in firmware/hardware with - the round-robin airtime scheduler. - -- If several stations are eligible for transmission we can schedule both - of them; no need to hard-block the scheduling rotation until the head - of the queue has used up its quantum. - -- The check of whether a station is eligible for transmission becomes - simpler (in ieee80211_txq_may_transmit()). - -The drawback is that scheduling becomes slightly more expensive, as we -need to maintain an rbtree of TXQs sorted by virtual time. This means -that ieee80211_register_airtime() becomes O(logN) in the number of -currently scheduled TXQs because it can change the order of the -scheduled stations. We mitigate this overhead by only resorting when a -station changes position in the tree, and hopefully N rarely grows too -big (it's only TXQs currently backlogged, not all associated stations), -so it shouldn't be too big of an issue. - -To prevent divisions in the fast path, we maintain both station sums and -pre-computed reciprocals of the sums. This turns the fast-path operation -into a multiplication, with divisions only happening as the number of -active stations change (to re-compute the current sum of all active -station weights). To prevent this re-computation of the reciprocal from -happening too frequently, we use a time-based notion of station -activity, instead of updating the weight every time a station gets -scheduled or de-scheduled. As queues can oscillate between empty and -occupied quite frequently, this can significantly cut down on the number -of re-computations. It also has the added benefit of making the station -airtime calculation independent on whether the queue happened to have -drained at the time an airtime value was accounted. - -Co-developed-by: Yibo Zhao <yiboz@codeaurora.org> -Signed-off-by: Yibo Zhao <yiboz@codeaurora.org> -Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> -Link: https://lore.kernel.org/r/20210623134755.235545-1-toke@redhat.com -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -6552,9 +6552,6 @@ static inline void ieee80211_txq_schedul - { - } - --void __ieee80211_schedule_txq(struct ieee80211_hw *hw, -- struct ieee80211_txq *txq, bool force); -- - /** - * ieee80211_schedule_txq - schedule a TXQ for transmission - * -@@ -6567,11 +6564,7 @@ void __ieee80211_schedule_txq(struct iee - * The driver may call this function if it has buffered packets for - * this TXQ internally. - */ --static inline void --ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) --{ -- __ieee80211_schedule_txq(hw, txq, true); --} -+void ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq); - - /** - * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq() -@@ -6583,12 +6576,8 @@ ieee80211_schedule_txq(struct ieee80211_ - * The driver may set force=true if it has buffered packets for this TXQ - * internally. - */ --static inline void --ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq, -- bool force) --{ -- __ieee80211_schedule_txq(hw, txq, force); --} -+void ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq, -+ bool force); - - /** - * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -1442,6 +1442,38 @@ static void sta_apply_mesh_params(struct - #endif - } - -+static void sta_apply_airtime_params(struct ieee80211_local *local, -+ struct sta_info *sta, -+ struct station_parameters *params) -+{ -+ u8 ac; -+ -+ for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { -+ struct airtime_sched_info *air_sched = &local->airtime[ac]; -+ struct airtime_info *air_info = &sta->airtime[ac]; -+ struct txq_info *txqi; -+ u8 tid; -+ -+ spin_lock_bh(&air_sched->lock); -+ for (tid = 0; tid < IEEE80211_NUM_TIDS + 1; tid++) { -+ if (air_info->weight == params->airtime_weight || -+ !sta->sta.txq[tid] || -+ ac != ieee80211_ac_from_tid(tid)) -+ continue; -+ -+ airtime_weight_set(air_info, params->airtime_weight); -+ -+ txqi = to_txq_info(sta->sta.txq[tid]); -+ if (RB_EMPTY_NODE(&txqi->schedule_order)) -+ continue; -+ -+ ieee80211_update_airtime_weight(local, air_sched, -+ 0, true); -+ } -+ spin_unlock_bh(&air_sched->lock); -+ } -+} -+ - static int sta_apply_parameters(struct ieee80211_local *local, - struct sta_info *sta, - struct station_parameters *params) -@@ -1629,7 +1661,8 @@ static int sta_apply_parameters(struct i - sta_apply_mesh_params(local, sta, params); - - if (params->airtime_weight) -- sta->airtime_weight = params->airtime_weight; -+ sta_apply_airtime_params(local, sta, params); -+ - - /* set the STA state after all sta info from usermode has been set */ - if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) || ---- a/net/mac80211/debugfs.c -+++ b/net/mac80211/debugfs.c -@@ -216,14 +216,14 @@ static ssize_t aql_txq_limit_read(struct - "VI %u %u\n" - "BE %u %u\n" - "BK %u %u\n", -- local->aql_txq_limit_low[IEEE80211_AC_VO], -- local->aql_txq_limit_high[IEEE80211_AC_VO], -- local->aql_txq_limit_low[IEEE80211_AC_VI], -- local->aql_txq_limit_high[IEEE80211_AC_VI], -- local->aql_txq_limit_low[IEEE80211_AC_BE], -- local->aql_txq_limit_high[IEEE80211_AC_BE], -- local->aql_txq_limit_low[IEEE80211_AC_BK], -- local->aql_txq_limit_high[IEEE80211_AC_BK]); -+ local->airtime[IEEE80211_AC_VO].aql_txq_limit_low, -+ local->airtime[IEEE80211_AC_VO].aql_txq_limit_high, -+ local->airtime[IEEE80211_AC_VI].aql_txq_limit_low, -+ local->airtime[IEEE80211_AC_VI].aql_txq_limit_high, -+ local->airtime[IEEE80211_AC_BE].aql_txq_limit_low, -+ local->airtime[IEEE80211_AC_BE].aql_txq_limit_high, -+ local->airtime[IEEE80211_AC_BK].aql_txq_limit_low, -+ local->airtime[IEEE80211_AC_BK].aql_txq_limit_high); - return simple_read_from_buffer(user_buf, count, ppos, - buf, len); - } -@@ -255,11 +255,11 @@ static ssize_t aql_txq_limit_write(struc - if (ac >= IEEE80211_NUM_ACS) - return -EINVAL; - -- q_limit_low_old = local->aql_txq_limit_low[ac]; -- q_limit_high_old = local->aql_txq_limit_high[ac]; -+ q_limit_low_old = local->airtime[ac].aql_txq_limit_low; -+ q_limit_high_old = local->airtime[ac].aql_txq_limit_high; - -- local->aql_txq_limit_low[ac] = q_limit_low; -- local->aql_txq_limit_high[ac] = q_limit_high; -+ local->airtime[ac].aql_txq_limit_low = q_limit_low; -+ local->airtime[ac].aql_txq_limit_high = q_limit_high; - - mutex_lock(&local->sta_mtx); - list_for_each_entry(sta, &local->sta_list, list) { -@@ -382,6 +382,46 @@ static const struct file_operations forc - .llseek = default_llseek, - }; - -+static ssize_t airtime_read(struct file *file, -+ char __user *user_buf, -+ size_t count, -+ loff_t *ppos) -+{ -+ struct ieee80211_local *local = file->private_data; -+ char buf[200]; -+ u64 v_t[IEEE80211_NUM_ACS]; -+ u64 wt[IEEE80211_NUM_ACS]; -+ int len = 0, ac; -+ -+ for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { -+ spin_lock_bh(&local->airtime[ac].lock); -+ v_t[ac] = local->airtime[ac].v_t; -+ wt[ac] = local->airtime[ac].weight_sum; -+ spin_unlock_bh(&local->airtime[ac].lock); -+ } -+ len = scnprintf(buf, sizeof(buf), -+ "\tVO VI BE BK\n" -+ "Virt-t\t%-10llu %-10llu %-10llu %-10llu\n" -+ "Weight\t%-10llu %-10llu %-10llu %-10llu\n", -+ v_t[0], -+ v_t[1], -+ v_t[2], -+ v_t[3], -+ wt[0], -+ wt[1], -+ wt[2], -+ wt[3]); -+ -+ return simple_read_from_buffer(user_buf, count, ppos, -+ buf, len); -+} -+ -+static const struct file_operations airtime_ops = { -+ .read = airtime_read, -+ .open = simple_open, -+ .llseek = default_llseek, -+}; -+ - #ifdef CONFIG_PM - static ssize_t reset_write(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) -@@ -624,7 +664,11 @@ void debugfs_hw_add(struct ieee80211_loc - if (local->ops->wake_tx_queue) - DEBUGFS_ADD_MODE(aqm, 0600); - -- DEBUGFS_ADD_MODE(airtime_flags, 0600); -+ if (wiphy_ext_feature_isset(local->hw.wiphy, -+ NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) { -+ DEBUGFS_ADD_MODE(airtime, 0600); -+ DEBUGFS_ADD_MODE(airtime_flags, 0600); -+ } - - DEBUGFS_ADD(aql_txq_limit); - debugfs_create_u32("aql_threshold", 0600, ---- a/net/mac80211/debugfs_netdev.c -+++ b/net/mac80211/debugfs_netdev.c -@@ -513,6 +513,34 @@ static ssize_t ieee80211_if_fmt_aqm( - } - IEEE80211_IF_FILE_R(aqm); - -+static ssize_t ieee80211_if_fmt_airtime( -+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) -+{ -+ struct ieee80211_local *local = sdata->local; -+ struct ieee80211_txq *txq = sdata->vif.txq; -+ struct airtime_info *air_info; -+ int len; -+ -+ if (!txq) -+ return 0; -+ -+ spin_lock_bh(&local->airtime[txq->ac].lock); -+ air_info = to_airtime_info(txq); -+ len = scnprintf(buf, -+ buflen, -+ "RX: %llu us\nTX: %llu us\nWeight: %u\n" -+ "Virt-T: %lld us\n", -+ air_info->rx_airtime, -+ air_info->tx_airtime, -+ air_info->weight, -+ air_info->v_t); -+ spin_unlock_bh(&local->airtime[txq->ac].lock); -+ -+ return len; -+} -+ -+IEEE80211_IF_FILE_R(airtime); -+ - IEEE80211_IF_FILE(multicast_to_unicast, u.ap.multicast_to_unicast, HEX); - - /* IBSS attributes */ -@@ -661,8 +689,10 @@ static void add_common_files(struct ieee - - if (sdata->local->ops->wake_tx_queue && - sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && -- sdata->vif.type != NL80211_IFTYPE_NAN) -+ sdata->vif.type != NL80211_IFTYPE_NAN) { - DEBUGFS_ADD(aqm); -+ DEBUGFS_ADD(airtime); -+ } - } - - static void add_sta_files(struct ieee80211_sub_if_data *sdata) ---- a/net/mac80211/debugfs_sta.c -+++ b/net/mac80211/debugfs_sta.c -@@ -202,7 +202,7 @@ static ssize_t sta_airtime_read(struct f - size_t bufsz = 400; - char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf; - u64 rx_airtime = 0, tx_airtime = 0; -- s64 deficit[IEEE80211_NUM_ACS]; -+ u64 v_t[IEEE80211_NUM_ACS]; - ssize_t rv; - int ac; - -@@ -210,18 +210,18 @@ static ssize_t sta_airtime_read(struct f - return -ENOMEM; - - for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { -- spin_lock_bh(&local->active_txq_lock[ac]); -+ spin_lock_bh(&local->airtime[ac].lock); - rx_airtime += sta->airtime[ac].rx_airtime; - tx_airtime += sta->airtime[ac].tx_airtime; -- deficit[ac] = sta->airtime[ac].deficit; -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ v_t[ac] = sta->airtime[ac].v_t; -+ spin_unlock_bh(&local->airtime[ac].lock); - } - - p += scnprintf(p, bufsz + buf - p, - "RX: %llu us\nTX: %llu us\nWeight: %u\n" -- "Deficit: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n", -- rx_airtime, tx_airtime, sta->airtime_weight, -- deficit[0], deficit[1], deficit[2], deficit[3]); -+ "Virt-T: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n", -+ rx_airtime, tx_airtime, sta->airtime[0].weight, -+ v_t[0], v_t[1], v_t[2], v_t[3]); - - rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); - kfree(buf); -@@ -236,11 +236,11 @@ static ssize_t sta_airtime_write(struct - int ac; - - for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { -- spin_lock_bh(&local->active_txq_lock[ac]); -+ spin_lock_bh(&local->airtime[ac].lock); - sta->airtime[ac].rx_airtime = 0; - sta->airtime[ac].tx_airtime = 0; -- sta->airtime[ac].deficit = sta->airtime_weight; -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ sta->airtime[ac].v_t = 0; -+ spin_unlock_bh(&local->airtime[ac].lock); - } - - return count; -@@ -263,10 +263,10 @@ static ssize_t sta_aql_read(struct file - return -ENOMEM; - - for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { -- spin_lock_bh(&local->active_txq_lock[ac]); -+ spin_lock_bh(&local->airtime[ac].lock); - q_limit_l[ac] = sta->airtime[ac].aql_limit_low; - q_limit_h[ac] = sta->airtime[ac].aql_limit_high; -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ spin_unlock_bh(&local->airtime[ac].lock); - q_depth[ac] = atomic_read(&sta->airtime[ac].aql_tx_pending); - } - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -840,20 +840,16 @@ enum txq_info_flags { - * @def_flow: used as a fallback flow when a packet destined to @tin hashes to - * a fq_flow which is already owned by a different tin - * @def_cvars: codel vars for @def_flow -- * @frags: used to keep fragments created after dequeue - * @schedule_order: used with ieee80211_local->active_txqs -- * @schedule_round: counter to prevent infinite loops on TXQ scheduling -+ * @frags: used to keep fragments created after dequeue - */ - struct txq_info { - struct fq_tin tin; - struct codel_vars def_cvars; - struct codel_stats cstats; -- -- u16 schedule_round; -- struct list_head schedule_order; -+ struct rb_node schedule_order; - - struct sk_buff_head frags; -- - unsigned long flags; - - /* keep last! */ -@@ -930,6 +926,8 @@ struct ieee80211_sub_if_data { - struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; - struct mac80211_qos_map __rcu *qos_map; - -+ struct airtime_info airtime[IEEE80211_NUM_ACS]; -+ - struct work_struct csa_finalize_work; - bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */ - struct cfg80211_chan_def csa_chandef; -@@ -1143,6 +1141,44 @@ enum mac80211_scan_state { - SCAN_ABORT, - }; - -+/** -+ * struct airtime_sched_info - state used for airtime scheduling and AQL -+ * -+ * @lock: spinlock that protects all the fields in this struct -+ * @active_txqs: rbtree of currently backlogged queues, sorted by virtual time -+ * @schedule_pos: the current position maintained while a driver walks the tree -+ * with ieee80211_next_txq() -+ * @active_list: list of struct airtime_info structs that were active within -+ * the last AIRTIME_ACTIVE_DURATION (100 ms), used to compute -+ * weight_sum -+ * @last_weight_update: used for rate limiting walking active_list -+ * @last_schedule_time: tracks the last time a transmission was scheduled; used -+ * for catching up v_t if no stations are eligible for -+ * transmission. -+ * @v_t: global virtual time; queues with v_t < this are eligible for -+ * transmission -+ * @weight_sum: total sum of all active stations used for dividing airtime -+ * @weight_sum_reciprocal: reciprocal of weight_sum (to avoid divisions in fast -+ * path - see comment above -+ * IEEE80211_RECIPROCAL_DIVISOR_64) -+ * @aql_txq_limit_low: AQL limit when total outstanding airtime -+ * is < IEEE80211_AQL_THRESHOLD -+ * @aql_txq_limit_high: AQL limit when total outstanding airtime -+ * is > IEEE80211_AQL_THRESHOLD -+ */ -+struct airtime_sched_info { -+ spinlock_t lock; -+ struct rb_root_cached active_txqs; -+ struct rb_node *schedule_pos; -+ struct list_head active_list; -+ u64 last_weight_update; -+ u64 last_schedule_activity; -+ u64 v_t; -+ u64 weight_sum; -+ u64 weight_sum_reciprocal; -+ u32 aql_txq_limit_low; -+ u32 aql_txq_limit_high; -+}; - DECLARE_STATIC_KEY_FALSE(aql_disable); - - struct ieee80211_local { -@@ -1156,13 +1192,8 @@ struct ieee80211_local { - struct codel_params cparams; - - /* protects active_txqs and txqi->schedule_order */ -- spinlock_t active_txq_lock[IEEE80211_NUM_ACS]; -- struct list_head active_txqs[IEEE80211_NUM_ACS]; -- u16 schedule_round[IEEE80211_NUM_ACS]; -- -+ struct airtime_sched_info airtime[IEEE80211_NUM_ACS]; - u16 airtime_flags; -- u32 aql_txq_limit_low[IEEE80211_NUM_ACS]; -- u32 aql_txq_limit_high[IEEE80211_NUM_ACS]; - u32 aql_threshold; - atomic_t aql_total_pending_airtime; - -@@ -1581,6 +1612,125 @@ static inline bool txq_has_queue(struct - return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets); - } - -+static inline struct airtime_info *to_airtime_info(struct ieee80211_txq *txq) -+{ -+ struct ieee80211_sub_if_data *sdata; -+ struct sta_info *sta; -+ -+ if (txq->sta) { -+ sta = container_of(txq->sta, struct sta_info, sta); -+ return &sta->airtime[txq->ac]; -+ } -+ -+ sdata = vif_to_sdata(txq->vif); -+ return &sdata->airtime[txq->ac]; -+} -+ -+/* To avoid divisions in the fast path, we keep pre-computed reciprocals for -+ * airtime weight calculations. There are two different weights to keep track -+ * of: The per-station weight and the sum of weights per phy. -+ * -+ * For the per-station weights (kept in airtime_info below), we use 32-bit -+ * reciprocals with a devisor of 2^19. This lets us keep the multiplications and -+ * divisions for the station weights as 32-bit operations at the cost of a bit -+ * of rounding error for high weights; but the choice of divisor keeps rounding -+ * errors <10% for weights <2^15, assuming no more than 8ms of airtime is -+ * reported at a time. -+ * -+ * For the per-phy sum of weights the values can get higher, so we use 64-bit -+ * operations for those with a 32-bit divisor, which should avoid any -+ * significant rounding errors. -+ */ -+#define IEEE80211_RECIPROCAL_DIVISOR_64 0x100000000ULL -+#define IEEE80211_RECIPROCAL_SHIFT_64 32 -+#define IEEE80211_RECIPROCAL_DIVISOR_32 0x80000U -+#define IEEE80211_RECIPROCAL_SHIFT_32 19 -+ -+static inline void airtime_weight_set(struct airtime_info *air_info, u16 weight) -+{ -+ if (air_info->weight == weight) -+ return; -+ -+ air_info->weight = weight; -+ if (weight) { -+ air_info->weight_reciprocal = -+ IEEE80211_RECIPROCAL_DIVISOR_32 / weight; -+ } else { -+ air_info->weight_reciprocal = 0; -+ } -+} -+ -+static inline void airtime_weight_sum_set(struct airtime_sched_info *air_sched, -+ int weight_sum) -+{ -+ if (air_sched->weight_sum == weight_sum) -+ return; -+ -+ air_sched->weight_sum = weight_sum; -+ if (air_sched->weight_sum) { -+ air_sched->weight_sum_reciprocal = IEEE80211_RECIPROCAL_DIVISOR_64; -+ do_div(air_sched->weight_sum_reciprocal, air_sched->weight_sum); -+ } else { -+ air_sched->weight_sum_reciprocal = 0; -+ } -+} -+ -+/* A problem when trying to enforce airtime fairness is that we want to divide -+ * the airtime between the currently *active* stations. However, basing this on -+ * the instantaneous queue state of stations doesn't work, as queues tend to -+ * oscillate very quickly between empty and occupied, leading to the scheduler -+ * thinking only a single station is active when deciding whether to allow -+ * transmission (and thus not throttling correctly). -+ * -+ * To fix this we use a timer-based notion of activity: a station is considered -+ * active if it has been scheduled within the last 100 ms; we keep a separate -+ * list of all the stations considered active in this manner, and lazily update -+ * the total weight of active stations from this list (filtering the stations in -+ * the list by their 'last active' time). -+ * -+ * We add one additional safeguard to guard against stations that manage to get -+ * scheduled every 100 ms but don't transmit a lot of data, and thus don't use -+ * up any airtime. Such stations would be able to get priority for an extended -+ * period of time if they do start transmitting at full capacity again, and so -+ * we add an explicit maximum for how far behind a station is allowed to fall in -+ * the virtual airtime domain. This limit is set to a relatively high value of -+ * 20 ms because the main mechanism for catching up idle stations is the active -+ * state as described above; i.e., the hard limit should only be hit in -+ * pathological cases. -+ */ -+#define AIRTIME_ACTIVE_DURATION (100 * NSEC_PER_MSEC) -+#define AIRTIME_MAX_BEHIND 20000 /* 20 ms */ -+ -+static inline bool airtime_is_active(struct airtime_info *air_info, u64 now) -+{ -+ return air_info->last_scheduled >= now - AIRTIME_ACTIVE_DURATION; -+} -+ -+static inline void airtime_set_active(struct airtime_sched_info *air_sched, -+ struct airtime_info *air_info, u64 now) -+{ -+ air_info->last_scheduled = now; -+ air_sched->last_schedule_activity = now; -+ list_move_tail(&air_info->list, &air_sched->active_list); -+} -+ -+static inline bool airtime_catchup_v_t(struct airtime_sched_info *air_sched, -+ u64 v_t, u64 now) -+{ -+ air_sched->v_t = v_t; -+ return true; -+} -+ -+static inline void init_airtime_info(struct airtime_info *air_info, -+ struct airtime_sched_info *air_sched) -+{ -+ atomic_set(&air_info->aql_tx_pending, 0); -+ air_info->aql_limit_low = air_sched->aql_txq_limit_low; -+ air_info->aql_limit_high = air_sched->aql_txq_limit_high; -+ airtime_weight_set(air_info, IEEE80211_DEFAULT_AIRTIME_WEIGHT); -+ INIT_LIST_HEAD(&air_info->list); -+} -+ - static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) - { - return ether_addr_equal(raddr, addr) || -@@ -1821,6 +1971,14 @@ 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); -+void ieee80211_resort_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq); -+void ieee80211_unschedule_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq, -+ bool purge); -+void ieee80211_update_airtime_weight(struct ieee80211_local *local, -+ struct airtime_sched_info *air_sched, -+ u64 now, bool force); - - /* HT */ - void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, ---- a/net/mac80211/iface.c -+++ b/net/mac80211/iface.c -@@ -2067,6 +2067,9 @@ int ieee80211_if_add(struct ieee80211_lo - } - } - -+ for (i = 0; i < IEEE80211_NUM_ACS; i++) -+ init_airtime_info(&sdata->airtime[i], &local->airtime[i]); -+ - ieee80211_set_default_queues(sdata); - - sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; ---- a/net/mac80211/main.c -+++ b/net/mac80211/main.c -@@ -693,10 +693,13 @@ struct ieee80211_hw *ieee80211_alloc_hw_ - spin_lock_init(&local->queue_stop_reason_lock); - - for (i = 0; i < IEEE80211_NUM_ACS; i++) { -- INIT_LIST_HEAD(&local->active_txqs[i]); -- spin_lock_init(&local->active_txq_lock[i]); -- local->aql_txq_limit_low[i] = IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L; -- local->aql_txq_limit_high[i] = -+ struct airtime_sched_info *air_sched = &local->airtime[i]; -+ -+ air_sched->active_txqs = RB_ROOT_CACHED; -+ INIT_LIST_HEAD(&air_sched->active_list); -+ spin_lock_init(&air_sched->lock); -+ air_sched->aql_txq_limit_low = IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L; -+ air_sched->aql_txq_limit_high = - IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H; - } - ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -1573,12 +1573,8 @@ static void sta_ps_start(struct sta_info - - for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) { - struct ieee80211_txq *txq = sta->sta.txq[tid]; -- struct txq_info *txqi = to_txq_info(txq); - -- spin_lock(&local->active_txq_lock[txq->ac]); -- if (!list_empty(&txqi->schedule_order)) -- list_del_init(&txqi->schedule_order); -- spin_unlock(&local->active_txq_lock[txq->ac]); -+ ieee80211_unschedule_txq(&local->hw, txq, false); - - if (txq_has_queue(txq)) - set_bit(tid, &sta->txq_buffered_tids); ---- a/net/mac80211/sta_info.c -+++ b/net/mac80211/sta_info.c -@@ -426,15 +426,11 @@ struct sta_info *sta_info_alloc(struct i - if (sta_prepare_rate_control(local, sta, gfp)) - goto free_txq; - -- sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; - - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - skb_queue_head_init(&sta->ps_tx_buf[i]); - skb_queue_head_init(&sta->tx_filtered[i]); -- sta->airtime[i].deficit = sta->airtime_weight; -- atomic_set(&sta->airtime[i].aql_tx_pending, 0); -- sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; -- sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; -+ init_airtime_info(&sta->airtime[i], &local->airtime[i]); - } - - for (i = 0; i < IEEE80211_NUM_TIDS; i++) -@@ -1898,24 +1894,59 @@ void ieee80211_sta_set_buffered(struct i - } - EXPORT_SYMBOL(ieee80211_sta_set_buffered); - --void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid, -- u32 tx_airtime, u32 rx_airtime) -+void ieee80211_register_airtime(struct ieee80211_txq *txq, -+ u32 tx_airtime, u32 rx_airtime) - { -- struct sta_info *sta = container_of(pubsta, struct sta_info, sta); -- struct ieee80211_local *local = sta->sdata->local; -- u8 ac = ieee80211_ac_from_tid(tid); -+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->vif); -+ struct ieee80211_local *local = sdata->local; -+ u64 weight_sum, weight_sum_reciprocal; -+ struct airtime_sched_info *air_sched; -+ struct airtime_info *air_info; - u32 airtime = 0; - -- if (sta->local->airtime_flags & AIRTIME_USE_TX) -+ air_sched = &local->airtime[txq->ac]; -+ air_info = to_airtime_info(txq); -+ -+ if (local->airtime_flags & AIRTIME_USE_TX) - airtime += tx_airtime; -- if (sta->local->airtime_flags & AIRTIME_USE_RX) -+ if (local->airtime_flags & AIRTIME_USE_RX) - airtime += rx_airtime; - -- spin_lock_bh(&local->active_txq_lock[ac]); -- sta->airtime[ac].tx_airtime += tx_airtime; -- sta->airtime[ac].rx_airtime += rx_airtime; -- sta->airtime[ac].deficit -= airtime; -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ /* Weights scale so the unit weight is 256 */ -+ airtime <<= 8; -+ -+ spin_lock_bh(&air_sched->lock); -+ -+ air_info->tx_airtime += tx_airtime; -+ air_info->rx_airtime += rx_airtime; -+ -+ if (air_sched->weight_sum) { -+ weight_sum = air_sched->weight_sum; -+ weight_sum_reciprocal = air_sched->weight_sum_reciprocal; -+ } else { -+ weight_sum = air_info->weight; -+ weight_sum_reciprocal = air_info->weight_reciprocal; -+ } -+ -+ /* Round the calculation of global vt */ -+ air_sched->v_t += (u64)((airtime + (weight_sum >> 1)) * -+ weight_sum_reciprocal) >> IEEE80211_RECIPROCAL_SHIFT_64; -+ air_info->v_t += (u32)((airtime + (air_info->weight >> 1)) * -+ air_info->weight_reciprocal) >> IEEE80211_RECIPROCAL_SHIFT_32; -+ ieee80211_resort_txq(&local->hw, txq); -+ -+ spin_unlock_bh(&air_sched->lock); -+} -+ -+void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid, -+ u32 tx_airtime, u32 rx_airtime) -+{ -+ struct ieee80211_txq *txq = pubsta->txq[tid]; -+ -+ if (!txq) -+ return; -+ -+ ieee80211_register_airtime(txq, tx_airtime, rx_airtime); - } - EXPORT_SYMBOL(ieee80211_sta_register_airtime); - -@@ -2364,7 +2395,7 @@ void sta_set_sinfo(struct sta_info *sta, - } - - if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { -- sinfo->airtime_weight = sta->airtime_weight; -+ sinfo->airtime_weight = sta->airtime[0].weight; - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); - } - ---- a/net/mac80211/sta_info.h -+++ b/net/mac80211/sta_info.h -@@ -135,18 +135,25 @@ enum ieee80211_agg_stop_reason { - #define AIRTIME_USE_TX BIT(0) - #define AIRTIME_USE_RX BIT(1) - -+ - struct airtime_info { - u64 rx_airtime; - u64 tx_airtime; -- s64 deficit; -+ u64 v_t; -+ u64 last_scheduled; -+ struct list_head list; - atomic_t aql_tx_pending; /* Estimated airtime for frames pending */ - u32 aql_limit_low; - u32 aql_limit_high; -+ u32 weight_reciprocal; -+ u16 weight; - }; - - void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, - struct sta_info *sta, u8 ac, - u16 tx_airtime, bool tx_completed); -+void ieee80211_register_airtime(struct ieee80211_txq *txq, -+ u32 tx_airtime, u32 rx_airtime); - - struct sta_info; - -@@ -515,7 +522,6 @@ struct ieee80211_fragment_cache { - * @tid_seq: per-TID sequence numbers for sending to this STA - * @airtime: per-AC struct airtime_info describing airtime statistics for this - * station -- * @airtime_weight: station weight for airtime fairness calculation purposes - * @ampdu_mlme: A-MPDU state machine state - * @mesh: mesh STA information - * @debugfs_dir: debug filesystem directory dentry -@@ -646,7 +652,6 @@ struct sta_info { - u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; - - struct airtime_info airtime[IEEE80211_NUM_ACS]; -- u16 airtime_weight; - - /* - * Aggregation information, locked with lock. ---- a/net/mac80211/status.c -+++ b/net/mac80211/status.c -@@ -972,6 +972,25 @@ static void __ieee80211_tx_status(struct - if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked) - ieee80211_frame_acked(sta, skb); - -+ } else if (wiphy_ext_feature_isset(local->hw.wiphy, -+ NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) { -+ struct ieee80211_sub_if_data *sdata; -+ struct ieee80211_txq *txq; -+ u32 airtime; -+ -+ /* Account airtime to multicast queue */ -+ sdata = ieee80211_sdata_from_skb(local, skb); -+ -+ if (sdata && (txq = sdata->vif.txq)) { -+ airtime = info->status.tx_time ?: -+ ieee80211_calc_expected_tx_airtime(hw, -+ &sdata->vif, -+ NULL, -+ skb->len, -+ false); -+ -+ ieee80211_register_airtime(txq, airtime, 0); -+ } - } - - /* SNMP counters ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -18,6 +18,7 @@ - #include <linux/bitmap.h> - #include <linux/rcupdate.h> - #include <linux/export.h> -+#include <linux/timekeeping.h> - #include <net/net_namespace.h> - #include <net/ieee80211_radiotap.h> - #include <net/cfg80211.h> -@@ -1489,7 +1490,7 @@ void ieee80211_txq_init(struct ieee80211 - codel_vars_init(&txqi->def_cvars); - codel_stats_init(&txqi->cstats); - __skb_queue_head_init(&txqi->frags); -- INIT_LIST_HEAD(&txqi->schedule_order); -+ RB_CLEAR_NODE(&txqi->schedule_order); - - txqi->txq.vif = &sdata->vif; - -@@ -1533,9 +1534,7 @@ void ieee80211_txq_purge(struct ieee8021 - ieee80211_purge_tx_queue(&local->hw, &txqi->frags); - spin_unlock_bh(&fq->lock); - -- spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); -- list_del_init(&txqi->schedule_order); -- spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); -+ ieee80211_unschedule_txq(&local->hw, &txqi->txq, true); - } - - void ieee80211_txq_set_params(struct ieee80211_local *local) -@@ -3797,102 +3796,259 @@ EXPORT_SYMBOL(ieee80211_tx_dequeue); - struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) - { - struct ieee80211_local *local = hw_to_local(hw); -+ struct airtime_sched_info *air_sched; -+ u64 now = ktime_get_boottime_ns(); - struct ieee80211_txq *ret = NULL; -- struct txq_info *txqi = NULL, *head = NULL; -- bool found_eligible_txq = false; -+ struct airtime_info *air_info; -+ struct txq_info *txqi = NULL; -+ struct rb_node *node; -+ bool first = false; - -- spin_lock_bh(&local->active_txq_lock[ac]); -+ air_sched = &local->airtime[ac]; -+ spin_lock_bh(&air_sched->lock); - -- begin: -- txqi = list_first_entry_or_null(&local->active_txqs[ac], -- struct txq_info, -- schedule_order); -- if (!txqi) -+ node = air_sched->schedule_pos; -+ -+begin: -+ if (!node) { -+ node = rb_first_cached(&air_sched->active_txqs); -+ first = true; -+ } else { -+ node = rb_next(node); -+ } -+ -+ if (!node) - goto out; - -- if (txqi == head) { -- if (!found_eligible_txq) -- goto out; -- else -- found_eligible_txq = false; -+ txqi = container_of(node, struct txq_info, schedule_order); -+ air_info = to_airtime_info(&txqi->txq); -+ -+ if (air_info->v_t > air_sched->v_t && -+ (!first || !airtime_catchup_v_t(air_sched, air_info->v_t, now))) -+ goto out; -+ -+ if (!ieee80211_txq_airtime_check(hw, &txqi->txq)) { -+ first = false; -+ goto begin; - } - -- if (!head) -- head = txqi; -+ air_sched->schedule_pos = node; -+ air_sched->last_schedule_activity = now; -+ ret = &txqi->txq; -+out: -+ spin_unlock_bh(&air_sched->lock); -+ return ret; -+} -+EXPORT_SYMBOL(ieee80211_next_txq); - -- if (txqi->txq.sta) { -- struct sta_info *sta = container_of(txqi->txq.sta, -- struct sta_info, sta); -- bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); -- s64 deficit = sta->airtime[txqi->txq.ac].deficit; -+static void __ieee80211_insert_txq(struct rb_root_cached *root, -+ struct txq_info *txqi) -+{ -+ struct rb_node **new = &root->rb_root.rb_node; -+ struct airtime_info *old_air, *new_air; -+ struct rb_node *parent = NULL; -+ struct txq_info *__txqi; -+ bool leftmost = true; -+ -+ while (*new) { -+ parent = *new; -+ __txqi = rb_entry(parent, struct txq_info, schedule_order); -+ old_air = to_airtime_info(&__txqi->txq); -+ new_air = to_airtime_info(&txqi->txq); - -- if (aql_check) -- found_eligible_txq = true; -+ if (new_air->v_t <= old_air->v_t) { -+ new = &parent->rb_left; -+ } else { -+ new = &parent->rb_right; -+ leftmost = false; -+ } -+ } - -- if (deficit < 0) -- sta->airtime[txqi->txq.ac].deficit += -- sta->airtime_weight; -- -- if (deficit < 0 || !aql_check) { -- list_move_tail(&txqi->schedule_order, -- &local->active_txqs[txqi->txq.ac]); -- goto begin; -+ rb_link_node(&txqi->schedule_order, parent, new); -+ rb_insert_color_cached(&txqi->schedule_order, root, leftmost); -+} -+ -+void ieee80211_resort_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq) -+{ -+ struct airtime_info *air_info = to_airtime_info(txq); -+ struct ieee80211_local *local = hw_to_local(hw); -+ struct txq_info *txqi = to_txq_info(txq); -+ struct airtime_sched_info *air_sched; -+ -+ air_sched = &local->airtime[txq->ac]; -+ -+ lockdep_assert_held(&air_sched->lock); -+ -+ if (!RB_EMPTY_NODE(&txqi->schedule_order)) { -+ struct airtime_info *a_prev = NULL, *a_next = NULL; -+ struct txq_info *t_prev, *t_next; -+ struct rb_node *n_prev, *n_next; -+ -+ /* Erasing a node can cause an expensive rebalancing operation, -+ * so we check the previous and next nodes first and only remove -+ * and re-insert if the current node is not already in the -+ * correct position. -+ */ -+ if ((n_prev = rb_prev(&txqi->schedule_order)) != NULL) { -+ t_prev = container_of(n_prev, struct txq_info, -+ schedule_order); -+ a_prev = to_airtime_info(&t_prev->txq); -+ } -+ -+ if ((n_next = rb_next(&txqi->schedule_order)) != NULL) { -+ t_next = container_of(n_next, struct txq_info, -+ schedule_order); -+ a_next = to_airtime_info(&t_next->txq); - } -+ -+ if ((!a_prev || a_prev->v_t <= air_info->v_t) && -+ (!a_next || a_next->v_t > air_info->v_t)) -+ return; -+ -+ if (air_sched->schedule_pos == &txqi->schedule_order) -+ air_sched->schedule_pos = n_prev; -+ -+ rb_erase_cached(&txqi->schedule_order, -+ &air_sched->active_txqs); -+ RB_CLEAR_NODE(&txqi->schedule_order); -+ __ieee80211_insert_txq(&air_sched->active_txqs, txqi); - } -+} -+ -+void ieee80211_update_airtime_weight(struct ieee80211_local *local, -+ struct airtime_sched_info *air_sched, -+ u64 now, bool force) -+{ -+ struct airtime_info *air_info, *tmp; -+ u64 weight_sum = 0; -+ -+ if (unlikely(!now)) -+ now = ktime_get_boottime_ns(); -+ -+ lockdep_assert_held(&air_sched->lock); -+ -+ if (!force && (air_sched->last_weight_update < -+ now - AIRTIME_ACTIVE_DURATION)) -+ return; -+ -+ list_for_each_entry_safe(air_info, tmp, -+ &air_sched->active_list, list) { -+ if (airtime_is_active(air_info, now)) -+ weight_sum += air_info->weight; -+ else -+ list_del_init(&air_info->list); -+ } -+ airtime_weight_sum_set(air_sched, weight_sum); -+ air_sched->last_weight_update = now; -+} - -+void ieee80211_schedule_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq) -+ __acquires(txq_lock) __releases(txq_lock) -+{ -+ struct ieee80211_local *local = hw_to_local(hw); -+ struct txq_info *txqi = to_txq_info(txq); -+ struct airtime_sched_info *air_sched; -+ u64 now = ktime_get_boottime_ns(); -+ struct airtime_info *air_info; -+ u8 ac = txq->ac; -+ bool was_active; - -- if (txqi->schedule_round == local->schedule_round[ac]) -+ air_sched = &local->airtime[ac]; -+ air_info = to_airtime_info(txq); -+ -+ spin_lock_bh(&air_sched->lock); -+ was_active = airtime_is_active(air_info, now); -+ airtime_set_active(air_sched, air_info, now); -+ -+ if (!RB_EMPTY_NODE(&txqi->schedule_order)) - goto out; - -- list_del_init(&txqi->schedule_order); -- txqi->schedule_round = local->schedule_round[ac]; -- ret = &txqi->txq; -+ /* If the station has been inactive for a while, catch up its v_t so it -+ * doesn't get indefinite priority; see comment above the definition of -+ * AIRTIME_MAX_BEHIND. -+ */ -+ if ((!was_active && air_info->v_t < air_sched->v_t) || -+ air_info->v_t < air_sched->v_t - AIRTIME_MAX_BEHIND) -+ air_info->v_t = air_sched->v_t; -+ -+ ieee80211_update_airtime_weight(local, air_sched, now, !was_active); -+ __ieee80211_insert_txq(&air_sched->active_txqs, txqi); - - out: -- spin_unlock_bh(&local->active_txq_lock[ac]); -- return ret; -+ spin_unlock_bh(&air_sched->lock); - } --EXPORT_SYMBOL(ieee80211_next_txq); -+EXPORT_SYMBOL(ieee80211_schedule_txq); - --void __ieee80211_schedule_txq(struct ieee80211_hw *hw, -- struct ieee80211_txq *txq, -- bool force) -+static void __ieee80211_unschedule_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq, -+ bool purge) - { - struct ieee80211_local *local = hw_to_local(hw); - struct txq_info *txqi = to_txq_info(txq); -+ struct airtime_sched_info *air_sched; -+ struct airtime_info *air_info; - -- spin_lock_bh(&local->active_txq_lock[txq->ac]); -+ air_sched = &local->airtime[txq->ac]; -+ air_info = to_airtime_info(&txqi->txq); - -- if (list_empty(&txqi->schedule_order) && -- (force || !skb_queue_empty(&txqi->frags) || -- txqi->tin.backlog_packets)) { -- /* If airtime accounting is active, always enqueue STAs at the -- * head of the list to ensure that they only get moved to the -- * back by the airtime DRR scheduler once they have a negative -- * deficit. A station that already has a negative deficit will -- * get immediately moved to the back of the list on the next -- * call to ieee80211_next_txq(). -- */ -- if (txqi->txq.sta && local->airtime_flags && -- wiphy_ext_feature_isset(local->hw.wiphy, -- NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) -- list_add(&txqi->schedule_order, -- &local->active_txqs[txq->ac]); -- else -- list_add_tail(&txqi->schedule_order, -- &local->active_txqs[txq->ac]); -+ lockdep_assert_held(&air_sched->lock); -+ -+ if (purge) { -+ list_del_init(&air_info->list); -+ ieee80211_update_airtime_weight(local, air_sched, 0, true); - } - -- spin_unlock_bh(&local->active_txq_lock[txq->ac]); -+ if (RB_EMPTY_NODE(&txqi->schedule_order)) -+ return; -+ -+ if (air_sched->schedule_pos == &txqi->schedule_order) -+ air_sched->schedule_pos = rb_prev(&txqi->schedule_order); -+ -+ if (!purge) -+ airtime_set_active(air_sched, air_info, -+ ktime_get_boottime_ns()); -+ -+ rb_erase_cached(&txqi->schedule_order, -+ &air_sched->active_txqs); -+ RB_CLEAR_NODE(&txqi->schedule_order); -+} -+ -+void ieee80211_unschedule_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq, -+ bool purge) -+ __acquires(txq_lock) __releases(txq_lock) -+{ -+ struct ieee80211_local *local = hw_to_local(hw); -+ -+ spin_lock_bh(&local->airtime[txq->ac].lock); -+ __ieee80211_unschedule_txq(hw, txq, purge); -+ spin_unlock_bh(&local->airtime[txq->ac].lock); -+} -+ -+void ieee80211_return_txq(struct ieee80211_hw *hw, -+ struct ieee80211_txq *txq, bool force) -+{ -+ struct ieee80211_local *local = hw_to_local(hw); -+ struct txq_info *txqi = to_txq_info(txq); -+ -+ spin_lock_bh(&local->airtime[txq->ac].lock); -+ -+ if (!RB_EMPTY_NODE(&txqi->schedule_order) && !force && -+ !txq_has_queue(txq)) -+ __ieee80211_unschedule_txq(hw, txq, false); -+ -+ spin_unlock_bh(&local->airtime[txq->ac].lock); - } --EXPORT_SYMBOL(__ieee80211_schedule_txq); -+EXPORT_SYMBOL(ieee80211_return_txq); - - DEFINE_STATIC_KEY_FALSE(aql_disable); - - bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw, - struct ieee80211_txq *txq) - { -- struct sta_info *sta; -+ struct airtime_info *air_info = to_airtime_info(txq); - struct ieee80211_local *local = hw_to_local(hw); - - if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) -@@ -3907,15 +4063,12 @@ bool ieee80211_txq_airtime_check(struct - if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) - return true; - -- sta = container_of(txq->sta, struct sta_info, sta); -- if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < -- sta->airtime[txq->ac].aql_limit_low) -+ if (atomic_read(&air_info->aql_tx_pending) < air_info->aql_limit_low) - return true; - - if (atomic_read(&local->aql_total_pending_airtime) < - local->aql_threshold && -- atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < -- sta->airtime[txq->ac].aql_limit_high) -+ atomic_read(&air_info->aql_tx_pending) < air_info->aql_limit_high) - return true; - - return false; -@@ -3925,60 +4078,59 @@ EXPORT_SYMBOL(ieee80211_txq_airtime_chec - bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw, - struct ieee80211_txq *txq) - { -+ struct txq_info *first_txqi = NULL, *txqi = to_txq_info(txq); - struct ieee80211_local *local = hw_to_local(hw); -- struct txq_info *iter, *tmp, *txqi = to_txq_info(txq); -- struct sta_info *sta; -- u8 ac = txq->ac; -+ struct airtime_sched_info *air_sched; -+ struct airtime_info *air_info; -+ struct rb_node *node = NULL; -+ bool ret = false; -+ u64 now; - -- spin_lock_bh(&local->active_txq_lock[ac]); - -- if (!txqi->txq.sta) -- goto out; -+ if (!ieee80211_txq_airtime_check(hw, txq)) -+ return false; -+ -+ air_sched = &local->airtime[txq->ac]; -+ spin_lock_bh(&air_sched->lock); - -- if (list_empty(&txqi->schedule_order)) -+ if (RB_EMPTY_NODE(&txqi->schedule_order)) - goto out; - -- list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], -- schedule_order) { -- if (iter == txqi) -- break; -+ now = ktime_get_boottime_ns(); - -- if (!iter->txq.sta) { -- list_move_tail(&iter->schedule_order, -- &local->active_txqs[ac]); -- continue; -- } -- sta = container_of(iter->txq.sta, struct sta_info, sta); -- if (sta->airtime[ac].deficit < 0) -- sta->airtime[ac].deficit += sta->airtime_weight; -- list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); -+ /* Like in ieee80211_next_txq(), make sure the first station in the -+ * scheduling order is eligible for transmission to avoid starvation. -+ */ -+ node = rb_first_cached(&air_sched->active_txqs); -+ if (node) { -+ first_txqi = container_of(node, struct txq_info, -+ schedule_order); -+ air_info = to_airtime_info(&first_txqi->txq); -+ -+ if (air_sched->v_t < air_info->v_t) -+ airtime_catchup_v_t(air_sched, air_info->v_t, now); - } - -- sta = container_of(txqi->txq.sta, struct sta_info, sta); -- if (sta->airtime[ac].deficit >= 0) -- goto out; -- -- sta->airtime[ac].deficit += sta->airtime_weight; -- list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ air_info = to_airtime_info(&txqi->txq); -+ if (air_info->v_t <= air_sched->v_t) { -+ air_sched->last_schedule_activity = now; -+ ret = true; -+ } - -- return false; - out: -- if (!list_empty(&txqi->schedule_order)) -- list_del_init(&txqi->schedule_order); -- spin_unlock_bh(&local->active_txq_lock[ac]); -- -- return true; -+ spin_unlock_bh(&air_sched->lock); -+ return ret; - } - EXPORT_SYMBOL(ieee80211_txq_may_transmit); - - void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) - { - struct ieee80211_local *local = hw_to_local(hw); -+ struct airtime_sched_info *air_sched = &local->airtime[ac]; - -- spin_lock_bh(&local->active_txq_lock[ac]); -- local->schedule_round[ac]++; -- spin_unlock_bh(&local->active_txq_lock[ac]); -+ spin_lock_bh(&air_sched->lock); -+ air_sched->schedule_pos = NULL; -+ spin_unlock_bh(&air_sched->lock); - } - EXPORT_SYMBOL(ieee80211_txq_schedule_start); - diff --git a/package/kernel/mac80211/patches/subsys/383-mac80211-fix-enabling-4-address-mode-on-a-sta-vif-af.patch b/package/kernel/mac80211/patches/subsys/383-mac80211-fix-enabling-4-address-mode-on-a-sta-vif-af.patch deleted file mode 100644 index 5a82f00c9e7..00000000000 --- a/package/kernel/mac80211/patches/subsys/383-mac80211-fix-enabling-4-address-mode-on-a-sta-vif-af.patch +++ /dev/null @@ -1,72 +0,0 @@ -From: Felix Fietkau <nbd@nbd.name> -Date: Fri, 2 Jul 2021 06:57:53 +0200 -Subject: [PATCH] mac80211: fix enabling 4-address mode on a sta vif after - assoc - -Notify the driver about the 4-address mode change and also send a nulldata -packet to the AP to notify it about the change - -Fixes: 1ff4e8f2dec8 ("mac80211: notify the driver when a sta uses 4-address mode") -Signed-off-by: Felix Fietkau <nbd@nbd.name> ---- - ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -152,6 +152,8 @@ static int ieee80211_change_iface(struct - struct vif_params *params) - { - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); -+ struct ieee80211_local *local = sdata->local; -+ struct sta_info *sta; - int ret; - - ret = ieee80211_if_change_type(sdata, type); -@@ -162,7 +164,24 @@ static int ieee80211_change_iface(struct - RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); - ieee80211_check_fast_rx_iface(sdata); - } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) { -+ struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; -+ -+ if (params->use_4addr == ifmgd->use_4addr) -+ return 0; -+ - sdata->u.mgd.use_4addr = params->use_4addr; -+ if (!ifmgd->associated) -+ return 0; -+ -+ mutex_lock(&local->sta_mtx); -+ sta = sta_info_get(sdata, ifmgd->bssid); -+ if (sta) -+ drv_sta_set_4addr(local, sdata, &sta->sta, -+ params->use_4addr); -+ mutex_unlock(&local->sta_mtx); -+ -+ if (params->use_4addr) -+ ieee80211_send_4addr_nullfunc(local, sdata); - } - - if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -2224,6 +2224,8 @@ 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_send_4addr_nullfunc(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata); - 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 -@@ -1115,8 +1115,8 @@ void ieee80211_send_nullfunc(struct ieee - ieee80211_tx_skb(sdata, skb); - } - --static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -- struct ieee80211_sub_if_data *sdata) -+void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata) - { - struct sk_buff *skb; - struct ieee80211_hdr *nullfunc; diff --git a/package/kernel/mac80211/patches/subsys/384-nl80211-add-common-API-to-configure-SAR-power-limita.patch b/package/kernel/mac80211/patches/subsys/384-nl80211-add-common-API-to-configure-SAR-power-limita.patch deleted file mode 100644 index 0c9ae3595d8..00000000000 --- a/package/kernel/mac80211/patches/subsys/384-nl80211-add-common-API-to-configure-SAR-power-limita.patch +++ /dev/null @@ -1,398 +0,0 @@ -From: Carl Huang <cjhuang@codeaurora.org> -Date: Thu, 3 Dec 2020 05:37:26 -0500 -Subject: [PATCH] nl80211: add common API to configure SAR power limitations - -NL80211_CMD_SET_SAR_SPECS is added to configure SAR from -user space. NL80211_ATTR_SAR_SPEC is used to pass the SAR -power specification when used with NL80211_CMD_SET_SAR_SPECS. - -Wireless driver needs to register SAR type, supported frequency -ranges to wiphy, so user space can query it. The index in -frequency range is used to specify which sub band the power -limitation applies to. The SAR type is for compatibility, so later -other SAR mechanism can be implemented without breaking the user -space SAR applications. - -Normal process is user space queries the SAR capability, and -gets the index of supported frequency ranges and associates the -power limitation with this index and sends to kernel. - -Here is an example of message send to kernel: -8c 00 00 00 08 00 01 00 00 00 00 00 38 00 2b 81 -08 00 01 00 00 00 00 00 2c 00 02 80 14 00 00 80 -08 00 02 00 00 00 00 00 08 00 01 00 38 00 00 00 -14 00 01 80 08 00 02 00 01 00 00 00 08 00 01 00 -48 00 00 00 - -NL80211_CMD_SET_SAR_SPECS: 0x8c -NL80211_ATTR_WIPHY: 0x01(phy idx is 0) -NL80211_ATTR_SAR_SPEC: 0x812b (NLA_NESTED) -NL80211_SAR_ATTR_TYPE: 0x00 (NL80211_SAR_TYPE_POWER) -NL80211_SAR_ATTR_SPECS: 0x8002 (NLA_NESTED) -freq range 0 power: 0x38 in 0.25dbm unit (14dbm) -freq range 1 power: 0x48 in 0.25dbm unit (18dbm) - -Signed-off-by: Carl Huang <cjhuang@codeaurora.org> -Reviewed-by: Brian Norris <briannorris@chromium.org> -Reviewed-by: Abhishek Kumar <kuabhs@chromium.org> -Link: https://lore.kernel.org/r/20201203103728.3034-2-cjhuang@codeaurora.org -[minor edits, NLA parse cleanups] -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/cfg80211.h -+++ b/include/net/cfg80211.h -@@ -1737,6 +1737,54 @@ struct station_info { - u8 connected_to_as; - }; - -+/** -+ * struct cfg80211_sar_sub_specs - sub specs limit -+ * @power: power limitation in 0.25dbm -+ * @freq_range_index: index the power limitation applies to -+ */ -+struct cfg80211_sar_sub_specs { -+ s32 power; -+ u32 freq_range_index; -+}; -+ -+/** -+ * struct cfg80211_sar_specs - sar limit specs -+ * @type: it's set with power in 0.25dbm or other types -+ * @num_sub_specs: number of sar sub specs -+ * @sub_specs: memory to hold the sar sub specs -+ */ -+struct cfg80211_sar_specs { -+ enum nl80211_sar_type type; -+ u32 num_sub_specs; -+ struct cfg80211_sar_sub_specs sub_specs[]; -+}; -+ -+ -+/** -+ * @struct cfg80211_sar_chan_ranges - sar frequency ranges -+ * @start_freq: start range edge frequency -+ * @end_freq: end range edge frequency -+ */ -+struct cfg80211_sar_freq_ranges { -+ u32 start_freq; -+ u32 end_freq; -+}; -+ -+/** -+ * struct cfg80211_sar_capa - sar limit capability -+ * @type: it's set via power in 0.25dbm or other types -+ * @num_freq_ranges: number of frequency ranges -+ * @freq_ranges: memory to hold the freq ranges. -+ * -+ * Note: WLAN driver may append new ranges or split an existing -+ * range to small ones and then append them. -+ */ -+struct cfg80211_sar_capa { -+ enum nl80211_sar_type type; -+ u32 num_freq_ranges; -+ const struct cfg80211_sar_freq_ranges *freq_ranges; -+}; -+ - #if IS_ENABLED(CPTCFG_CFG80211) - /** - * cfg80211_get_station - retrieve information about a given station -@@ -4259,6 +4307,8 @@ struct cfg80211_ops { - struct cfg80211_tid_config *tid_conf); - int (*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev, - const u8 *peer, u8 tids); -+ int (*set_sar_specs)(struct wiphy *wiphy, -+ struct cfg80211_sar_specs *sar); - }; - - /* -@@ -5030,6 +5080,8 @@ struct wiphy { - - u8 max_data_retry_count; - -+ const struct cfg80211_sar_capa *sar_capa; -+ - char priv[] __aligned(NETDEV_ALIGN); - }; - ---- a/net/wireless/nl80211.c -+++ b/net/wireless/nl80211.c -@@ -405,6 +405,18 @@ nl80211_unsol_bcast_probe_resp_policy[NL - .len = IEEE80211_MAX_DATA_LEN } - }; - -+static const struct nla_policy -+sar_specs_policy[NL80211_SAR_ATTR_SPECS_MAX + 1] = { -+ [NL80211_SAR_ATTR_SPECS_POWER] = { .type = NLA_S32 }, -+ [NL80211_SAR_ATTR_SPECS_RANGE_INDEX] = {.type = NLA_U32 }, -+}; -+ -+static const struct nla_policy -+sar_policy[NL80211_SAR_ATTR_MAX + 1] = { -+ [NL80211_SAR_ATTR_TYPE] = NLA_POLICY_MAX(NLA_U32, NUM_NL80211_SAR_TYPE), -+ [NL80211_SAR_ATTR_SPECS] = NLA_POLICY_NESTED_ARRAY(sar_specs_policy), -+}; -+ - static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { - [0] = { .strict_start_type = NL80211_ATTR_HE_OBSS_PD }, - [NL80211_ATTR_WIPHY] = { .type = NLA_U32 }, -@@ -739,6 +751,7 @@ static const struct nla_policy nl80211_p - [NL80211_ATTR_SAE_PWE] = - NLA_POLICY_RANGE(NLA_U8, NL80211_SAE_PWE_HUNT_AND_PECK, - NL80211_SAE_PWE_BOTH), -+ [NL80211_ATTR_SAR_SPEC] = NLA_POLICY_NESTED(sar_policy), - [NL80211_ATTR_RECONNECT_REQUESTED] = { .type = NLA_REJECT }, - }; - -@@ -2117,6 +2130,56 @@ fail: - return -ENOBUFS; - } - -+static int -+nl80211_put_sar_specs(struct cfg80211_registered_device *rdev, -+ struct sk_buff *msg) -+{ -+ struct nlattr *sar_capa, *specs, *sub_freq_range; -+ u8 num_freq_ranges; -+ int i; -+ -+ if (!rdev->wiphy.sar_capa) -+ return 0; -+ -+ num_freq_ranges = rdev->wiphy.sar_capa->num_freq_ranges; -+ -+ sar_capa = nla_nest_start(msg, NL80211_ATTR_SAR_SPEC); -+ if (!sar_capa) -+ return -ENOSPC; -+ -+ if (nla_put_u32(msg, NL80211_SAR_ATTR_TYPE, rdev->wiphy.sar_capa->type)) -+ goto fail; -+ -+ specs = nla_nest_start(msg, NL80211_SAR_ATTR_SPECS); -+ if (!specs) -+ goto fail; -+ -+ /* report supported freq_ranges */ -+ for (i = 0; i < num_freq_ranges; i++) { -+ sub_freq_range = nla_nest_start(msg, i + 1); -+ if (!sub_freq_range) -+ goto fail; -+ -+ if (nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_START_FREQ, -+ rdev->wiphy.sar_capa->freq_ranges[i].start_freq)) -+ goto fail; -+ -+ if (nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_END_FREQ, -+ rdev->wiphy.sar_capa->freq_ranges[i].end_freq)) -+ goto fail; -+ -+ nla_nest_end(msg, sub_freq_range); -+ } -+ -+ nla_nest_end(msg, specs); -+ nla_nest_end(msg, sar_capa); -+ -+ return 0; -+fail: -+ nla_nest_cancel(msg, sar_capa); -+ return -ENOBUFS; -+} -+ - struct nl80211_dump_wiphy_state { - s64 filter_wiphy; - long start; -@@ -2366,6 +2429,8 @@ static int nl80211_send_wiphy(struct cfg - CMD(set_multicast_to_unicast, SET_MULTICAST_TO_UNICAST); - CMD(update_connect_params, UPDATE_CONNECT_PARAMS); - CMD(update_ft_ies, UPDATE_FT_IES); -+ if (rdev->wiphy.sar_capa) -+ CMD(set_sar_specs, SET_SAR_SPECS); - } - #undef CMD - -@@ -2691,6 +2756,11 @@ static int nl80211_send_wiphy(struct cfg - - if (nl80211_put_tid_config_support(rdev, msg)) - goto nla_put_failure; -+ state->split_start++; -+ break; -+ case 16: -+ if (nl80211_put_sar_specs(rdev, msg)) -+ goto nla_put_failure; - - /* done */ - state->split_start = 0; -@@ -14713,6 +14783,111 @@ static void nl80211_post_doit(__genl_con - } - } - -+static int nl80211_set_sar_sub_specs(struct cfg80211_registered_device *rdev, -+ struct cfg80211_sar_specs *sar_specs, -+ struct nlattr *spec[], int index) -+{ -+ u32 range_index, i; -+ -+ if (!sar_specs || !spec) -+ return -EINVAL; -+ -+ if (!spec[NL80211_SAR_ATTR_SPECS_POWER] || -+ !spec[NL80211_SAR_ATTR_SPECS_RANGE_INDEX]) -+ return -EINVAL; -+ -+ range_index = nla_get_u32(spec[NL80211_SAR_ATTR_SPECS_RANGE_INDEX]); -+ -+ /* check if range_index exceeds num_freq_ranges */ -+ if (range_index >= rdev->wiphy.sar_capa->num_freq_ranges) -+ return -EINVAL; -+ -+ /* check if range_index duplicates */ -+ for (i = 0; i < index; i++) { -+ if (sar_specs->sub_specs[i].freq_range_index == range_index) -+ return -EINVAL; -+ } -+ -+ sar_specs->sub_specs[index].power = -+ nla_get_s32(spec[NL80211_SAR_ATTR_SPECS_POWER]); -+ -+ sar_specs->sub_specs[index].freq_range_index = range_index; -+ -+ return 0; -+} -+ -+static int nl80211_set_sar_specs(struct sk_buff *skb, struct genl_info *info) -+{ -+ struct cfg80211_registered_device *rdev = info->user_ptr[0]; -+ struct nlattr *spec[NL80211_SAR_ATTR_SPECS_MAX + 1]; -+ struct nlattr *tb[NL80211_SAR_ATTR_MAX + 1]; -+ struct cfg80211_sar_specs *sar_spec; -+ enum nl80211_sar_type type; -+ struct nlattr *spec_list; -+ u32 specs; -+ int rem, err; -+ -+ if (!rdev->wiphy.sar_capa || !rdev->ops->set_sar_specs) -+ return -EOPNOTSUPP; -+ -+ if (!info->attrs[NL80211_ATTR_SAR_SPEC]) -+ return -EINVAL; -+ -+ nla_parse_nested(tb, NL80211_SAR_ATTR_MAX, -+ info->attrs[NL80211_ATTR_SAR_SPEC], -+ NULL, NULL); -+ -+ if (!tb[NL80211_SAR_ATTR_TYPE] || !tb[NL80211_SAR_ATTR_SPECS]) -+ return -EINVAL; -+ -+ type = nla_get_u32(tb[NL80211_SAR_ATTR_TYPE]); -+ if (type != rdev->wiphy.sar_capa->type) -+ return -EINVAL; -+ -+ specs = 0; -+ nla_for_each_nested(spec_list, tb[NL80211_SAR_ATTR_SPECS], rem) -+ specs++; -+ -+ if (specs > rdev->wiphy.sar_capa->num_freq_ranges) -+ return -EINVAL; -+ -+ sar_spec = kzalloc(sizeof(*sar_spec) + -+ specs * sizeof(struct cfg80211_sar_sub_specs), -+ GFP_KERNEL); -+ if (!sar_spec) -+ return -ENOMEM; -+ -+ sar_spec->type = type; -+ specs = 0; -+ nla_for_each_nested(spec_list, tb[NL80211_SAR_ATTR_SPECS], rem) { -+ nla_parse_nested(spec, NL80211_SAR_ATTR_SPECS_MAX, -+ spec_list, NULL, NULL); -+ -+ switch (type) { -+ case NL80211_SAR_TYPE_POWER: -+ if (nl80211_set_sar_sub_specs(rdev, sar_spec, -+ spec, specs)) { -+ err = -EINVAL; -+ goto error; -+ } -+ break; -+ default: -+ err = -EINVAL; -+ goto error; -+ } -+ specs++; -+ } -+ -+ sar_spec->num_sub_specs = specs; -+ -+ rdev->cur_cmd_info = info; -+ err = rdev_set_sar_specs(rdev, sar_spec); -+ rdev->cur_cmd_info = NULL; -+error: -+ kfree(sar_spec); -+ return err; -+} -+ - static __genl_const struct genl_ops nl80211_ops[] = { - { - .cmd = NL80211_CMD_GET_WIPHY, -@@ -15576,6 +15751,14 @@ static const struct genl_small_ops nl802 - .internal_flags = NL80211_FLAG_NEED_NETDEV | - NL80211_FLAG_NEED_RTNL, - }, -+ { -+ .cmd = NL80211_CMD_SET_SAR_SPECS, -+ .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, -+ .doit = nl80211_set_sar_specs, -+ .flags = GENL_UNS_ADMIN_PERM, -+ .internal_flags = NL80211_FLAG_NEED_WIPHY | -+ NL80211_FLAG_NEED_RTNL, -+ }, - }; - - static struct genl_family nl80211_fam __genl_ro_after_init = { ---- a/net/wireless/rdev-ops.h -+++ b/net/wireless/rdev-ops.h -@@ -1356,4 +1356,16 @@ static inline int rdev_reset_tid_config( - return ret; - } - -+static inline int rdev_set_sar_specs(struct cfg80211_registered_device *rdev, -+ struct cfg80211_sar_specs *sar) -+{ -+ int ret; -+ -+ trace_rdev_set_sar_specs(&rdev->wiphy, sar); -+ ret = rdev->ops->set_sar_specs(&rdev->wiphy, sar); -+ trace_rdev_return_int(&rdev->wiphy, ret); -+ -+ return ret; -+} -+ - #endif /* __CFG80211_RDEV_OPS */ ---- a/net/wireless/trace.h -+++ b/net/wireless/trace.h -@@ -3551,6 +3551,25 @@ TRACE_EVENT(rdev_reset_tid_config, - TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", tids: 0x%x", - WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->tids) - ); -+ -+TRACE_EVENT(rdev_set_sar_specs, -+ TP_PROTO(struct wiphy *wiphy, struct cfg80211_sar_specs *sar), -+ TP_ARGS(wiphy, sar), -+ TP_STRUCT__entry( -+ WIPHY_ENTRY -+ __field(u16, type) -+ __field(u16, num) -+ ), -+ TP_fast_assign( -+ WIPHY_ASSIGN; -+ __entry->type = sar->type; -+ __entry->num = sar->num_sub_specs; -+ -+ ), -+ TP_printk(WIPHY_PR_FMT ", Set type:%d, num_specs:%d", -+ WIPHY_PR_ARG, __entry->type, __entry->num) -+); -+ - #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ - - #undef TRACE_INCLUDE_PATH diff --git a/package/kernel/mac80211/patches/subsys/385-mac80211-add-ieee80211_set_sar_specs.patch b/package/kernel/mac80211/patches/subsys/385-mac80211-add-ieee80211_set_sar_specs.patch deleted file mode 100644 index c351bc812a2..00000000000 --- a/package/kernel/mac80211/patches/subsys/385-mac80211-add-ieee80211_set_sar_specs.patch +++ /dev/null @@ -1,51 +0,0 @@ -From: Carl Huang <cjhuang@codeaurora.org> -Date: Thu, 3 Dec 2020 05:37:27 -0500 -Subject: [PATCH] mac80211: add ieee80211_set_sar_specs - -This change registers ieee80211_set_sar_specs to -mac80211_config_ops, so cfg80211 can call it. - -Signed-off-by: Carl Huang <cjhuang@codeaurora.org> -Reviewed-by: Brian Norris <briannorris@chromium.org> -Reviewed-by: Abhishek Kumar <kuabhs@chromium.org> -Link: https://lore.kernel.org/r/20201203103728.3034-3-cjhuang@codeaurora.org -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -4207,6 +4207,8 @@ struct ieee80211_ops { - struct ieee80211_vif *vif); - void (*sta_set_4addr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, bool enabled); -+ int (*set_sar_specs)(struct ieee80211_hw *hw, -+ const struct cfg80211_sar_specs *sar); - void (*sta_set_decap_offload)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, bool enabled); ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -4136,6 +4136,17 @@ static int ieee80211_reset_tid_config(st - return ret; - } - -+static int ieee80211_set_sar_specs(struct wiphy *wiphy, -+ struct cfg80211_sar_specs *sar) -+{ -+ struct ieee80211_local *local = wiphy_priv(wiphy); -+ -+ if (!local->ops->set_sar_specs) -+ return -EOPNOTSUPP; -+ -+ return local->ops->set_sar_specs(&local->hw, sar); -+} -+ - const struct cfg80211_ops mac80211_config_ops = { - .add_virtual_intf = ieee80211_add_iface, - .del_virtual_intf = ieee80211_del_iface, -@@ -4239,4 +4250,5 @@ const struct cfg80211_ops mac80211_confi - .probe_mesh_link = ieee80211_probe_mesh_link, - .set_tid_config = ieee80211_set_tid_config, - .reset_tid_config = ieee80211_reset_tid_config, -+ .set_sar_specs = ieee80211_set_sar_specs, - }; diff --git a/package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch b/package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch index f9c4caa51c8..ad24dfda5a7 100644 --- a/package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch +++ b/package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch @@ -1,11 +1,22 @@ -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 +From: Hauke Mehrtens <hauke@hauke-m.de> +Date: Mon, 24 Feb 2020 00:00:00 +0100 +Subject: [PATCH] mac80211: Allow IBSS mode and different beacon intervals + +ath10k-ct supports the combination to select IBSS (ADHOC) mode and +different beacon intervals together. mac80211 does not like this +combination, but Ben says this is ok, so remove this check. + +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. +--- + net/wireless/core.c | 15 --------------- + 1 file changed, 15 deletions(-) --- a/net/wireless/core.c +++ b/net/wireless/core.c -@@ -614,21 +614,6 @@ static int wiphy_verify_combinations(str +@@ -649,21 +649,6 @@ static int wiphy_verify_combinations(str c->limits[j].max > 1)) return -EINVAL; diff --git a/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch b/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch deleted file mode 100644 index b2ee61a6dc9..00000000000 --- a/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch +++ /dev/null @@ -1,160 +0,0 @@ ---- a/include/net/cfg80211.h -+++ b/include/net/cfg80211.h -@@ -3793,6 +3793,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 - * -@@ -4115,6 +4116,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 -@@ -1561,6 +1561,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 -@@ -1581,6 +1582,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 -@@ -2560,6 +2560,9 @@ enum nl80211_commands { - * disassoc events to indicate that an immediate reconnect to the AP - * is desired. - * -+ * @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 -@@ -3057,6 +3060,8 @@ enum nl80211_attrs { - - NL80211_ATTR_DISABLE_HE, - -+ 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 -@@ -2761,6 +2761,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) - { -@@ -4202,6 +4215,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 -@@ -1426,6 +1426,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 -@@ -753,6 +753,7 @@ static const struct nla_policy nl80211_p - NL80211_SAE_PWE_BOTH), - [NL80211_ATTR_SAR_SPEC] = NLA_POLICY_NESTED(sar_policy), - [NL80211_ATTR_RECONNECT_REQUESTED] = { .type = NLA_REJECT }, -+ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 }, - }; - - /* policy for the key attributes */ -@@ -3318,6 +3319,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/package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch b/package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch new file mode 100644 index 00000000000..4bbd7860436 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch @@ -0,0 +1,34 @@ +From: David Bauer <mail@david-bauer.net> +Date: Thu, 30 Nov 2023 07:32:52 +0100 +Subject: [PATCH] mac80211: avoid crashing on invalid band info + +Frequent crashes have been observed on MT7916 based platforms. While the +root of these crashes are currently unknown, they happen when decoding +rate information of connected STAs in AP mode. The rate-information is +associated with a band which is not available on the PHY. + +Check for this condition in order to avoid crashing the whole system. +This patch should be removed once the roout cause has been found and +fixed. + +Link: https://github.com/freifunk-gluon/gluon/issues/2980 + +Signed-off-by: David Bauer <mail@david-bauer.net> +--- + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -2423,6 +2423,13 @@ static void sta_stats_decode_rate(struct + + sband = local->hw.wiphy->bands[band]; + ++ if (!sband) { ++ wiphy_warn(local->hw.wiphy, ++ "Invalid band %d\n", ++ band); ++ break; ++ } ++ + if (WARN_ON_ONCE(!sband->bitrates)) + break; + diff --git a/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch b/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch new file mode 100644 index 00000000000..26af6a2fb98 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch @@ -0,0 +1,29 @@ +--- a/backport-include/linux/of_net.h ++++ /dev/null +@@ -1,26 +0,0 @@ +-#ifndef _BP_OF_NET_H +-#define _BP_OF_NET_H +-#include_next <linux/of_net.h> +-#include <linux/version.h> +-#include <linux/etherdevice.h> +- +-/* The behavior of of_get_mac_address() changed in kernel 5.2, it now +- * returns an error code and not NULL in case of an error. +- */ +-#if LINUX_VERSION_IS_LESS(5,13,0) +-static inline int backport_of_get_mac_address(struct device_node *np, u8 *mac_out) +-{ +- const void *mac = of_get_mac_address(np); +- +- if (!mac) +- return -ENODEV; +- if (IS_ERR(mac)) +- return PTR_ERR(mac); +- ether_addr_copy(mac_out, mac); +- +- return 0; +-} +-#define of_get_mac_address LINUX_BACKPORT(of_get_mac_address) +-#endif /* < 5.2 */ +- +-#endif /* _BP_OF_NET_H */ diff --git a/package/kernel/mac80211/ralink.mk b/package/kernel/mac80211/ralink.mk index 7bbdc1c22c6..83d208ee1a0 100644 --- a/package/kernel/mac80211/ralink.mk +++ b/package/kernel/mac80211/ralink.mk @@ -1,8 +1,6 @@ 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 + rt2800-lib rt2800-mmio rt2800-pci rt2800-soc rt2800-usb PKG_CONFIG_DEPENDS += \ CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS \ @@ -90,36 +88,12 @@ 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 + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +kmod-lib-crc-ccitt 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) @@ -155,18 +129,3 @@ $(call KernelPackage/rt2x00/Default) 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/package/kernel/mac80211/realtek.mk b/package/kernel/mac80211/realtek.mk index 75cb94d7b60..04057b31069 100644 --- a/package/kernel/mac80211/realtek.mk +++ b/package/kernel/mac80211/realtek.mk @@ -1,11 +1,9 @@ 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 + rtl8xxxu rtw88 rtw88-pci rtw88-usb rtw88-8821c rtw88-8822b rtw88-8822c \ + rtw88-8723d rtw88-8821ce rtw88-8821cu rtw88-8822be rtw88-8822bu \ + rtw88-8822ce rtw88-8822cu rtw88-8723de config-$(call config_package,rtlwifi) += RTL_CARDS RTLWIFI config-$(call config_package,rtlwifi-pci) += RTLWIFI_PCI @@ -25,31 +23,22 @@ 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 +config-$(call config_package,rtw88) += RTW88 RTW88_CORE +config-$(call config_package,rtw88-pci) += RTW88_PCI +config-$(call config_package,rtw88-usb) += RTW88_USB +config-$(call config_package,rtw88-8821c) += RTW88_8821C +config-$(call config_package,rtw88-8821ce) += RTW88_8821CE +config-$(call config_package,rtw88-8821cu) += RTW88_8821CU +config-$(call config_package,rtw88-8822b) += RTW88_8822B +config-$(call config_package,rtw88-8822be) += RTW88_8822BE +config-$(call config_package,rtw88-8822bu) += RTW88_8822BU +config-$(call config_package,rtw88-8822c) += RTW88_8822C +config-$(call config_package,rtw88-8822ce) += RTW88_8822CE +config-$(call config_package,rtw88-8822cu) += RTW88_8822CU +config-$(call config_package,rtw88-8723d) += RTW88_8723D +config-$(call config_package,rtw88-8723de) += RTW88_8723DE +config-$(CONFIG_PACKAGE_RTW88_DEBUG) += RTW88_DEBUG +config-$(CONFIG_PACKAGE_RTW88_DEBUGFS) += RTW88_DEBUGFS define KernelPackage/rtlwifi/config config PACKAGE_RTLWIFI_DEBUG @@ -63,7 +52,7 @@ endef define KernelPackage/rtlwifi $(call KernelPackage/mac80211/Default) TITLE:=Realtek common driver part - DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT) +kmod-mac80211 +@DRIVER_11N_SUPPORT + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT) +kmod-mac80211 FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtlwifi/rtlwifi.ko HIDDEN:=1 endef @@ -175,20 +164,139 @@ define KernelPackage/rtl8xxxu/description Please report your results! endef +define KernelPackage/rtw88/config + config PACKAGE_RTW88_DEBUG + bool "Realtek wireless debugging (rtw88)" + depends on PACKAGE_kmod-rtw88 + help + Enable debugging output for rtw88 devices + + config PACKAGE_RTW88_DEBUGFS + bool "Enable rtw88 debugfS support" + select KERNEL_DEBUG_FS + depends on PACKAGE_kmod-rtw88 + help + Select this to see extensive information about + the internal state of rtw88 in debugfs. +endef + define KernelPackage/rtw88 $(call KernelPackage/mac80211/Default) - TITLE:=Realtek RTL8822BE/RTL8822CE/RTL8723DE - DEPENDS+= @(PCI_SUPPORT) +kmod-mac80211 +@DRIVER_11AC_SUPPORT +@DRIVER_11N_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) + TITLE:=Realtek RTW88 common part + DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT) +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_core.ko + AUTOLOAD:=$(call AutoProbe,rtw88_core) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-pci + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTW88 PCI chips support + DEPENDS+= @PCI_SUPPORT +kmod-rtw88 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_pci.ko + AUTOLOAD:=$(call AutoProbe,rtw88_pci) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-usb + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTW88 USB chips support + DEPENDS+= @USB_SUPPORT +kmod-rtw88 +kmod-usb-core + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_usb.ko + AUTOLOAD:=$(call AutoProbe,rtw88_usb) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-8821c + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8821C family support + DEPENDS+= +kmod-rtw88 +rtl8821ce-firmware +@DRIVER_11AC_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8821c.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8821c) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-8822b + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822B family support + DEPENDS+= +kmod-rtw88 +rtl8822be-firmware +@DRIVER_11AC_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822b.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822b) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-8822c + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822C family support + DEPENDS+= +kmod-rtw88 +rtl8822ce-firmware +@DRIVER_11AC_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822c.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822c) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-8723d + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8723D family support + DEPENDS+= +kmod-rtw88 +rtl8723de-firmware + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8723d.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8723d) + HIDDEN:=1 +endef + +define KernelPackage/rtw88-8821ce + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8821CE support + DEPENDS+= +kmod-rtw88-pci +kmod-rtw88-8821c + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8821ce.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8821ce) +endef + +define KernelPackage/rtw88-8821cu + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8821CU support + DEPENDS+= +kmod-rtw88-usb +kmod-rtw88-8821c + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8821cu.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8821cu) +endef + +define KernelPackage/rtw88-8822be + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822BE support + DEPENDS+= +kmod-rtw88-pci +kmod-rtw88-8822b + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822be.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822be) +endef + +define KernelPackage/rtw88-8822bu + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822BU support + DEPENDS+= +kmod-rtw88-usb +kmod-rtw88-8822b + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822bu.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822bu) +endef + +define KernelPackage/rtw88-8822ce + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822CE support + DEPENDS+= +kmod-rtw88-pci +kmod-rtw88-8822c + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822ce.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822ce) +endef + +define KernelPackage/rtw88-8822cu + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8822CU support + DEPENDS+= +kmod-rtw88-usb +kmod-rtw88-8822c + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8822cu.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8822cu) +endef + +define KernelPackage/rtw88-8723de + $(call KernelPackage/mac80211/Default) + TITLE:=Realtek RTL8723DE support + DEPENDS+= +kmod-rtw88-pci +kmod-rtw88-8723d + FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/realtek/rtw88/rtw88_8723de.ko + AUTOLOAD:=$(call AutoProbe,rtw88_8723) endef define KernelPackage/rtl8723bs diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 431c57a240a..4f0fb5f69d0 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -1,16 +1,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mt76 -PKG_RELEASE=4 +PKG_RELEASE=1 PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2021-07-15 -PKG_SOURCE_VERSION:=bbebea7d6dc64313132226adc3f7369d36e9359d -PKG_MIRROR_HASH:=17cd74e72c1f6c8742b698bf6772afacc6fba71b233af8c4d59530600cf44d5b +PKG_SOURCE_DATE:=2024-02-03 +PKG_SOURCE_VERSION:=6124ea9135ed512671933f5520c46842906c78bc +PKG_MIRROR_HASH:=acc326d7b15c9c72b494ed601300be329553f896e65c7f045e6a09327304c34a PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> PKG_USE_NINJA:=0 @@ -40,7 +40,8 @@ define KernelPackage/mt76-default SUBMENU:=Wireless Drivers DEPENDS:= \ +kmod-mac80211 \ - +@DRIVER_11AC_SUPPORT +@DRIVER_11N_SUPPORT + +@DRIVER_11AC_SUPPORT \ + +@KERNEL_PAGE_POOL endef define KernelPackage/mt76 @@ -152,6 +153,14 @@ define KernelPackage/mt76-connac FILES:= $(PKG_BUILD_DIR)/mt76-connac-lib.ko endef +define KernelPackage/mt76-sdio + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7615/MT79xx SDIO driver common code + HIDDEN:=1 + DEPENDS+=+kmod-mt76-core +kmod-mmc + FILES:= $(PKG_BUILD_DIR)/mt76-sdio.ko +endef + define KernelPackage/mt7615-common $(KernelPackage/mt76-default) TITLE:=MediaTek MT7615 wireless driver common code @@ -163,7 +172,7 @@ endef define KernelPackage/mt7615-firmware $(KernelPackage/mt76-default) TITLE:=MediaTek MT7615e firmware - DEFAULT:=PACKAGE_kmod-mt7615e + DEPENDS+=+kmod-mt7615e endef define KernelPackage/mt7615e @@ -174,6 +183,12 @@ define KernelPackage/mt7615e AUTOLOAD:=$(call AutoProbe,mt7615e) endef +define KernelPackage/mt7622-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7622 firmware + DEPENDS+=+kmod-mt7615e +endef + define KernelPackage/mt7663-firmware-ap $(KernelPackage/mt76-default) TITLE:=MediaTek MT7663e firmware (optimized for AP) @@ -196,9 +211,8 @@ endef define KernelPackage/mt7663s $(KernelPackage/mt76-default) TITLE:=MediaTek MT7663s wireless driver - DEPENDS+=+kmod-mmc +kmod-mt7615-common +kmod-mt7663-usb-sdio + DEPENDS+=+kmod-mt76-sdio +kmod-mt7615-common +kmod-mt7663-usb-sdio FILES:= \ - $(PKG_BUILD_DIR)/mt76-sdio.ko \ $(PKG_BUILD_DIR)/mt7615/mt7663s.ko AUTOLOAD:=$(call AutoProbe,mt7663s) endef @@ -211,22 +225,134 @@ define KernelPackage/mt7663u AUTOLOAD:=$(call AutoProbe,mt7663u) endef +define KernelPackage/mt7915-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7915 firmware + DEPENDS+=+kmod-mt7915e +endef + define KernelPackage/mt7915e $(KernelPackage/mt76-default) TITLE:=MediaTek MT7915e wireless driver - DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common +kmod-hwmon-core +kmod-thermal +@DRIVER_11AX_SUPPORT + DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core +kmod-thermal +@DRIVER_11AX_SUPPORT +@KERNEL_RELAY FILES:= $(PKG_BUILD_DIR)/mt7915/mt7915e.ko AUTOLOAD:=$(call AutoProbe,mt7915e) endef +define KernelPackage/mt7916-firmware + $(KernelPackage/mt76-default) + DEPENDS+=+kmod-mt7915e + TITLE:=MediaTek MT7916 firmware +endef + +define KernelPackage/mt7981-firmware + $(KernelPackage/mt76-default) + DEPENDS:=@TARGET_mediatek_filogic + TITLE:=MediaTek MT7981 firmware +endef + +define KernelPackage/mt7986-firmware + $(KernelPackage/mt76-default) + DEPENDS:=@TARGET_mediatek_filogic + TITLE:=MediaTek MT7986 firmware +endef + +define KernelPackage/mt7921-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7921 firmware +endef + +define KernelPackage/mt7922-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7922 firmware +endef + +define KernelPackage/mt792x-common + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT792x wireless driver common code + HIDDEN:=1 + DEPENDS+=+kmod-mt76-connac +@DRIVER_11AX_SUPPORT + FILES:= $(PKG_BUILD_DIR)/mt792x-lib.ko +endef + +define KernelPackage/mt792x-usb + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT792x wireless driver USB code + HIDDEN:=1 + DEPENDS+=+kmod-mt792x-common +kmod-mt76-usb +@DRIVER_11AX_SUPPORT + FILES:= $(PKG_BUILD_DIR)/mt792x-usb.ko +endef + +define KernelPackage/mt7921-common + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7921 wireless driver common code + HIDDEN:=1 + DEPENDS+=+kmod-mt792x-common +kmod-mt7921-firmware +@DRIVER_11AX_SUPPORT +kmod-hwmon-core + FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921-common.ko +endef + +define KernelPackage/mt7921u + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7921U wireless driver + DEPENDS+=+kmod-mt792x-usb +kmod-mt7921-common + FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921u.ko + AUTOLOAD:=$(call AutoProbe,mt7921u) +endef + +define KernelPackage/mt7921s + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7921S wireless driver + DEPENDS+=+kmod-mt76-sdio +kmod-mt7921-common + FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921s.ko + AUTOLOAD:=$(call AutoProbe,mt7921s) +endef + define KernelPackage/mt7921e $(KernelPackage/mt76-default) TITLE:=MediaTek MT7921e wireless driver - DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac + DEPENDS+=@PCI_SUPPORT +kmod-mt7921-common FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921e.ko AUTOLOAD:=$(call AutoProbe,mt7921e) endef +define KernelPackage/mt7996e + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996E wireless driver + DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core + FILES:= $(PKG_BUILD_DIR)/mt7996/mt7996e.ko + AUTOLOAD:=$(call AutoProbe,mt7996e) +endef + +define KernelPackage/mt7996-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996 firmware + DEPENDS+=+kmod-mt7996e +endef + +define KernelPackage/mt7925-common + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7925 wireless driver common code + HIDDEN:=1 + DEPENDS+=+kmod-mt792x-common +@DRIVER_11AX_SUPPORT +kmod-hwmon-core + FILES:= $(PKG_BUILD_DIR)/mt7925/mt7925-common.ko +endef + +define KernelPackage/mt7925u + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7925U wireless driver + DEPENDS+=+kmod-mt792x-usb +kmod-mt7925-common + FILES:= $(PKG_BUILD_DIR)/mt7925/mt7925u.ko + AUTOLOAD:=$(call AutoProbe,mt7921u) +endef + +define KernelPackage/mt7925e + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7925e wireless driver + DEPENDS+=@PCI_SUPPORT +kmod-mt7925-common + FILES:= $(PKG_BUILD_DIR)/mt7925/mt7925e.ko + AUTOLOAD:=$(call AutoProbe,mt7921e) +endef + define Package/mt76-test SECTION:=devel CATEGORY:=Development @@ -288,6 +414,9 @@ endif ifdef CONFIG_PACKAGE_kmod-mt76-connac PKG_MAKE_FLAGS += CONFIG_MT76_CONNAC_LIB=m endif +ifdef CONFIG_PACKAGE_kmod-mt76-sdio + PKG_MAKE_FLAGS += CONFIG_MT76_SDIO=m +endif ifdef CONFIG_PACKAGE_kmod-mt7615-common PKG_MAKE_FLAGS += CONFIG_MT7615_COMMON=m endif @@ -302,7 +431,6 @@ ifdef CONFIG_PACKAGE_kmod-mt7663-usb-sdio PKG_MAKE_FLAGS += CONFIG_MT7663_USB_SDIO_COMMON=m endif ifdef CONFIG_PACKAGE_kmod-mt7663s - PKG_MAKE_FLAGS += CONFIG_MT76_SDIO=m PKG_MAKE_FLAGS += CONFIG_MT7663S=m endif ifdef CONFIG_PACKAGE_kmod-mt7663u @@ -310,14 +438,44 @@ ifdef CONFIG_PACKAGE_kmod-mt7663u endif ifdef CONFIG_PACKAGE_kmod-mt7915e PKG_MAKE_FLAGS += CONFIG_MT7915E=m + ifdef CONFIG_TARGET_mediatek_filogic + PKG_MAKE_FLAGS += CONFIG_MT798X_WMAC=y + NOSTDINC_FLAGS += -DCONFIG_MT798X_WMAC + endif +endif +ifdef CONFIG_PACKAGE_kmod-mt792x-common + PKG_MAKE_FLAGS += CONFIG_MT792x_LIB=m +endif +ifdef CONFIG_PACKAGE_kmod-mt792x-usb + PKG_MAKE_FLAGS += CONFIG_MT792x_USB=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7921-common + PKG_MAKE_FLAGS += CONFIG_MT7921_COMMON=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7921u + PKG_MAKE_FLAGS += CONFIG_MT7921U=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7921s + PKG_MAKE_FLAGS += CONFIG_MT7921S=m endif ifdef CONFIG_PACKAGE_kmod-mt7921e PKG_MAKE_FLAGS += CONFIG_MT7921E=m endif +ifdef CONFIG_PACKAGE_kmod-mt7996e + PKG_MAKE_FLAGS += CONFIG_MT7996E=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7925-common + PKG_MAKE_FLAGS += CONFIG_MT7925_COMMON=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7925u + PKG_MAKE_FLAGS += CONFIG_MT7925U=m +endif +ifdef CONFIG_PACKAGE_kmod-mt7925e + PKG_MAKE_FLAGS += CONFIG_MT7925E=m +endif define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ + +$(KERNEL_MAKE) $(PKG_JOBS) \ $(PKG_MAKE_FLAGS) \ M="$(PKG_BUILD_DIR)" \ NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ @@ -377,9 +535,14 @@ define KernelPackage/mt7615-firmware/install $(PKG_BUILD_DIR)/firmware/mt7615_cr4.bin \ $(PKG_BUILD_DIR)/firmware/mt7615_n9.bin \ $(PKG_BUILD_DIR)/firmware/mt7615_rom_patch.bin \ - $(if $(CONFIG_TARGET_mediatek_mt7622), \ - $(PKG_BUILD_DIR)/firmware/mt7622_n9.bin \ - $(PKG_BUILD_DIR)/firmware/mt7622_rom_patch.bin) \ + $(1)/lib/firmware/mediatek +endef + +define KernelPackage/mt7622-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek + cp \ + $(PKG_BUILD_DIR)/firmware/mt7622_n9.bin \ + $(PKG_BUILD_DIR)/firmware/mt7622_rom_patch.bin \ $(1)/lib/firmware/mediatek endef @@ -399,7 +562,7 @@ define KernelPackage/mt7663-firmware-sta/install $(1)/lib/firmware/mediatek endef -define KernelPackage/mt7915e/install +define KernelPackage/mt7915-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/mediatek cp \ $(PKG_BUILD_DIR)/firmware/mt7915_wa.bin \ @@ -408,7 +571,36 @@ define KernelPackage/mt7915e/install $(1)/lib/firmware/mediatek endef -define KernelPackage/mt7921e/install +define KernelPackage/mt7916-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek + cp \ + $(PKG_BUILD_DIR)/firmware/mt7916_wa.bin \ + $(PKG_BUILD_DIR)/firmware/mt7916_wm.bin \ + $(PKG_BUILD_DIR)/firmware/mt7916_rom_patch.bin \ + $(1)/lib/firmware/mediatek +endef + +define KernelPackage/mt7981-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek + cp \ + $(PKG_BUILD_DIR)/firmware/mt7981_wa.bin \ + $(PKG_BUILD_DIR)/firmware/mt7981_wm.bin \ + $(PKG_BUILD_DIR)/firmware/mt7981_rom_patch.bin \ + $(1)/lib/firmware/mediatek +endef + +define KernelPackage/mt7986-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek + cp \ + $(PKG_BUILD_DIR)/firmware/mt7986_wa.bin \ + $(PKG_BUILD_DIR)/firmware/mt7986_wm_mt7975.bin \ + $(PKG_BUILD_DIR)/firmware/mt7986_wm.bin \ + $(PKG_BUILD_DIR)/firmware/mt7986_rom_patch_mt7975.bin \ + $(PKG_BUILD_DIR)/firmware/mt7986_rom_patch.bin \ + $(1)/lib/firmware/mediatek +endef + +define KernelPackage/mt7921-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/mediatek cp \ $(PKG_BUILD_DIR)/firmware/WIFI_MT7961_patch_mcu_1_2_hdr.bin \ @@ -416,6 +608,25 @@ define KernelPackage/mt7921e/install $(1)/lib/firmware/mediatek endef +define KernelPackage/mt7922-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek + cp \ + $(PKG_BUILD_DIR)/firmware/WIFI_MT7922_patch_mcu_1_1_hdr.bin \ + $(PKG_BUILD_DIR)/firmware/WIFI_RAM_CODE_MT7922_1.bin \ + $(1)/lib/firmware/mediatek +endef + +define KernelPackage/mt7996-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 + cp \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_dsp.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_rom_patch.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wa.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wm.bin \ + $(1)/lib/firmware/mediatek/mt7996 +endef + define Package/mt76-test/install mkdir -p $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin @@ -433,15 +644,33 @@ $(eval $(call KernelPackage,mt76x2u)) $(eval $(call KernelPackage,mt76x2)) $(eval $(call KernelPackage,mt7603)) $(eval $(call KernelPackage,mt76-connac)) +$(eval $(call KernelPackage,mt76-sdio)) $(eval $(call KernelPackage,mt7615-common)) $(eval $(call KernelPackage,mt7615-firmware)) +$(eval $(call KernelPackage,mt7622-firmware)) $(eval $(call KernelPackage,mt7615e)) $(eval $(call KernelPackage,mt7663-firmware-ap)) $(eval $(call KernelPackage,mt7663-firmware-sta)) $(eval $(call KernelPackage,mt7663-usb-sdio)) $(eval $(call KernelPackage,mt7663u)) $(eval $(call KernelPackage,mt7663s)) +$(eval $(call KernelPackage,mt7915-firmware)) $(eval $(call KernelPackage,mt7915e)) +$(eval $(call KernelPackage,mt7916-firmware)) +$(eval $(call KernelPackage,mt7981-firmware)) +$(eval $(call KernelPackage,mt7986-firmware)) +$(eval $(call KernelPackage,mt7921-firmware)) +$(eval $(call KernelPackage,mt7922-firmware)) +$(eval $(call KernelPackage,mt792x-common)) +$(eval $(call KernelPackage,mt792x-usb)) +$(eval $(call KernelPackage,mt7921-common)) +$(eval $(call KernelPackage,mt7925-common)) +$(eval $(call KernelPackage,mt7921u)) +$(eval $(call KernelPackage,mt7921s)) $(eval $(call KernelPackage,mt7921e)) +$(eval $(call KernelPackage,mt7925u)) +$(eval $(call KernelPackage,mt7925e)) +$(eval $(call KernelPackage,mt7996e)) +$(eval $(call KernelPackage,mt7996-firmware)) $(eval $(call KernelPackage,mt76)) $(eval $(call BuildPackage,mt76-test)) diff --git a/package/kernel/mwlwifi/Makefile b/package/kernel/mwlwifi/Makefile index eb986dca03c..2e6cd3a31e5 100644 --- a/package/kernel/mwlwifi/Makefile +++ b/package/kernel/mwlwifi/Makefile @@ -8,16 +8,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwlwifi -PKG_RELEASE=2 +PKG_RELEASE=1 PKG_LICENSE:=ISC PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/kaloz/mwlwifi PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2020-02-06 -PKG_SOURCE_VERSION:=a2fd00bb74c35820dfe233d762690c0433a87ef5 -PKG_MIRROR_HASH:=0eda0e774a87e58e611d6436350e1cf2be3de50fddde334909a07a15b0c9862b +PKG_SOURCE_DATE:=2023-11-29 +PKG_SOURCE_VERSION:=ebf3167445f108346dcff9a31a708534c0bd7cc5 +PKG_MIRROR_HASH:=1d39ad25f4ad1fafff03a70341c2dabde8db4075f56163d40f8ae8aef2e2bb2d PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org> PKG_BUILD_PARALLEL:=1 @@ -29,7 +29,7 @@ include $(INCLUDE_DIR)/package.mk define KernelPackage/mwlwifi SUBMENU:=Wireless Drivers TITLE:=Marvell 88W8864/88W8897/88W8964/88W8997 wireless driver - DEPENDS:=+kmod-mac80211 +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT @PCI_SUPPORT @TARGET_mvebu + DEPENDS:=+kmod-mac80211 +@DRIVER_11AC_SUPPORT @PCI_SUPPORT @TARGET_mvebu FILES:=$(PKG_BUILD_DIR)/mwlwifi.ko AUTOLOAD:=$(call AutoLoad,50,mwlwifi) endef @@ -41,11 +41,11 @@ NOSTDINC_FLAGS := \ -I$(STAGING_DIR)/usr/include/mac80211-backport \ -I$(STAGING_DIR)/usr/include/mac80211/uapi \ -I$(STAGING_DIR)/usr/include/mac80211 \ - -include backport/backport.h + -include backport/backport.h \ + -Wno-unused-result define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ + +$(KERNEL_MAKE) $(PKG_JOBS) \ M="$(PKG_BUILD_DIR)" \ NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ modules diff --git a/package/kernel/mwlwifi/patches/001-Fix-compilation-warning-with-64-bit-system.patch b/package/kernel/mwlwifi/patches/001-Fix-compilation-warning-with-64-bit-system.patch new file mode 100644 index 00000000000..ee64e050473 --- /dev/null +++ b/package/kernel/mwlwifi/patches/001-Fix-compilation-warning-with-64-bit-system.patch @@ -0,0 +1,165 @@ +From ed4422e98ababf956674da3438ac42b3aa32c66e Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Wed, 10 May 2023 00:41:06 +0200 +Subject: [PATCH] Fix compilation warning with 64 bit system + +Use %zu and %zd where possible for ssize_t and size_t. +Use PTR_ERR to correctly convert to negative error. +Use universal pointer to support both 32 and 64bit systems. + +Fix compilation warning: +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c: In function 'mwl_fwcmd_get_fw_core_dump': +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/fwcmd.c:3608:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] + 3608 | (const void *)((u32)pcmd + + | ^ +In file included from ./include/linux/device.h:15, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3, + from ./include/linux/dma-mapping.h:7, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3, + from ./include/linux/skbuff.h:31, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3, + from ./include/linux/if_ether.h:19, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3, + from ./include/linux/etherdevice.h:20, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3, + from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:20: +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c: In function 'pcie_tx_init_ndp': +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Werror=format=] + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap' + 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ + | ^~~ +./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt' + 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) + | ^~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err' + 8828 | dev_err(&(wiphy)->dev, format, ##args) + | ^~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err' + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ^~~~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:67: note: format string is defined here + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ~^ + | | + | int + | %ld +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:38: error: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Werror=format=] + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +./include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap' + 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ + | ^~~ +./include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt' + 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) + | ^~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err' + 8828 | dev_err(&(wiphy)->dev, format, ##args) + | ^~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:17: note: in expansion of macro 'wiphy_err' + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ^~~~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.c:338:71: note: format string is defined here + 338 | wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", + | ~^ + | | + | int + | %ld + CC [M] /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.o +In file included from ./include/linux/device.h:15, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/device.h:3, + from ./include/linux/dma-mapping.h:7, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/dma-mapping.h:3, + from ./include/linux/skbuff.h:31, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/skbuff.h:3, + from ./include/linux/if_ether.h:19, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/if_ether.h:3, + from ./include/linux/etherdevice.h:20, + from /home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/etherdevice.h:3, + from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:19: +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c: In function 'pcie_bf_mimo_ctrl_decode': +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1325:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] + 1325 | filename, (unsigned int)fp_data); + | ^ +./include/linux/dev_printk.h:110:37: note: in definition of macro 'dev_printk_index_wrap' + 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ + | ^~~~~~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211/net/cfg80211.h:8828:9: note: in expansion of macro 'dev_err' + 8828 | dev_err(&(wiphy)->dev, format, ##args) + | ^~~~~~~ +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.c:1324:17: note: in expansion of macro 'wiphy_err' + 1324 | wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n", + | ^~~~~~~~~ +cc1: all warnings being treated as errors +make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/tx_ndp.o] Error 1 +make[4]: *** Waiting for unfinished jobs.... +cc1: all warnings being treated as errors +make[4]: *** [scripts/Makefile.build:289: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/hif/pcie/pcie.o] Error 1 +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c: In function 'mwl_debugfs_regrdwr_read': +/home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/mwlwifi-2023-04-29-6a436714/debugfs.c:1335:43: error: format '%d' expects argument of type 'int', but argument 4 has type 'ssize_t' {aka 'long int'} [-Werror=format=] + 1335 | "error: %d(%u 0x%08x 0x%08x)\n", + | ~^ + | | + | int + | %ld + 1336 | ret, priv->reg_type, priv->reg_offset, + | ~~~ + | | + | ssize_t {aka long int} +cc1: all warnings being treated as errors + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + debugfs.c | 2 +- + hif/fwcmd.c | 2 +- + hif/pcie/8964/tx_ndp.c | 2 +- + hif/pcie/pcie.c | 4 ++-- + 4 files changed, 5 insertions(+), 5 deletions(-) + +--- a/debugfs.c ++++ b/debugfs.c +@@ -1342,7 +1342,7 @@ done: + priv->reg_value); + else + len += scnprintf(p + len, size - len, +- "error: %d(%u 0x%08x 0x%08x)\n", ++ "error: %zd(%u 0x%08x 0x%08x)\n", + ret, priv->reg_type, priv->reg_offset, + priv->reg_value); + +--- a/hif/fwcmd.c ++++ b/hif/fwcmd.c +@@ -3623,7 +3623,7 @@ int mwl_fwcmd_get_fw_core_dump(struct ie + core_dump->size_kb = pcmd->cmd_data.coredump.size_kb; + core_dump->flags = pcmd->cmd_data.coredump.flags; + memcpy(buff, +- (const void *)((u32)pcmd + ++ (const void *)((uintptr_t)pcmd + + sizeof(struct hostcmd_cmd_get_fw_core_dump) - + sizeof(struct hostcmd_cmd_get_fw_core_dump_)), + MAX_CORE_DUMP_BUFFER); +--- a/hif/pcie/8964/tx_ndp.c ++++ b/hif/pcie/8964/tx_ndp.c +@@ -336,7 +336,7 @@ int pcie_tx_init_ndp(struct ieee80211_hw + + if (sizeof(struct pcie_tx_ctrl_ndp) > + sizeof(tx_info->driver_data)) { +- wiphy_err(hw->wiphy, "driver data is not enough: %d (%d)\n", ++ wiphy_err(hw->wiphy, "driver data is not enough: %zu (%zu)\n", + sizeof(struct pcie_tx_ctrl_ndp), + sizeof(tx_info->driver_data)); + return -ENOMEM; +--- a/hif/pcie/pcie.c ++++ b/hif/pcie/pcie.c +@@ -1466,8 +1466,8 @@ static void pcie_bf_mimo_ctrl_decode(struct mwl_priv *priv, + &fp_data->f_pos); + filp_close(fp_data, current->files); + } else { +- wiphy_err(priv->hw->wiphy, "Error opening %s! %x\n", +- filename, (unsigned int)fp_data); ++ wiphy_err(priv->hw->wiphy, "Error opening %s! %ld\n", ++ filename, PTR_ERR(fp_data)); + } + + #if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) diff --git a/package/kernel/mwlwifi/patches/001-Fix-compile-with-mac80211-backports-5_3+.patch b/package/kernel/mwlwifi/patches/001-Fix-compile-with-mac80211-backports-5_3+.patch deleted file mode 100644 index fdba575f04b..00000000000 --- a/package/kernel/mwlwifi/patches/001-Fix-compile-with-mac80211-backports-5_3+.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 182391a3c96ff6ad79bbba0758338a16a66abbd8 Mon Sep 17 00:00:00 2001 -From: DENG Qingfang <dengqf6@mail2.sysu.edu.cn> -Date: Wed, 12 Feb 2020 14:18:58 +0800 -Subject: [PATCH] Fix driver loading with backports 5.3+ - -Commit 747796b2f126 did not solve the issue that it crashes when an older kernel -with a newer backport tries loading it, because it only detects kernel version. - -As net/cfg80211.h in 5.3+ defines VENDOR_CMD_RAW_DATA, use it as a condition. - -Signed-off-by: DENG Qingfang <dqfext@gmail.com> ---- - vendor_cmd.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/vendor_cmd.c -+++ b/vendor_cmd.c -@@ -92,7 +92,7 @@ static const struct wiphy_vendor_command - .subcmd = MWL_VENDOR_CMD_SET_BF_TYPE}, - .flags = WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = mwl_vendor_cmd_set_bf_type, --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)) -+#ifdef VENDOR_CMD_RAW_DATA - .policy = mwl_vendor_attr_policy, - #endif - }, -@@ -101,7 +101,7 @@ static const struct wiphy_vendor_command - .subcmd = MWL_VENDOR_CMD_GET_BF_TYPE}, - .flags = WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = mwl_vendor_cmd_get_bf_type, --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)) -+#ifdef VENDOR_CMD_RAW_DATA - .policy = mwl_vendor_attr_policy, - #endif - } diff --git a/package/kernel/mwlwifi/patches/004-mwlwifi-fix-PCIe-DT-node-null-pointer-dereference.patch b/package/kernel/mwlwifi/patches/004-mwlwifi-fix-PCIe-DT-node-null-pointer-dereference.patch new file mode 100644 index 00000000000..f37d2f8171a --- /dev/null +++ b/package/kernel/mwlwifi/patches/004-mwlwifi-fix-PCIe-DT-node-null-pointer-dereference.patch @@ -0,0 +1,31 @@ +From 8e809b241695252e397bf0d7fc5f36e115c38831 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robert.marko@sartura.hr> +Date: Fri, 5 Mar 2021 11:47:59 +0100 +Subject: [PATCH] mwlwifi: fix PCIe DT node null pointer dereference + +pci_bus_to_OF_node() used to get the PCI bus DT node +returns node if found or NULL if none is found. + +Since the return of pci_bus_to_OF_node() is not checked in +the DT node name print it will cause a null pointer +dereference and crash the kernel. + +So first check whether the node is not NULL and then print. + +Signed-off-by: Robert Marko <robert.marko@sartura.hr> +--- + hif/pcie/pcie.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/hif/pcie/pcie.c ++++ b/hif/pcie/pcie.c +@@ -685,7 +685,8 @@ static struct device_node *pcie_get_devi + struct device_node *dev_node; + + dev_node = pci_bus_to_OF_node(pcie_priv->pdev->bus); +- wiphy_info(priv->hw->wiphy, "device node: %s\n", dev_node->full_name); ++ if (dev_node) ++ wiphy_info(priv->hw->wiphy, "device node: %s\n", dev_node->full_name); + + return dev_node; + } diff --git a/package/kernel/mwlwifi/patches/005-mac80211_update.patch b/package/kernel/mwlwifi/patches/005-mac80211_update.patch new file mode 100644 index 00000000000..92a8f2f70fd --- /dev/null +++ b/package/kernel/mwlwifi/patches/005-mac80211_update.patch @@ -0,0 +1,400 @@ +--- a/core.c ++++ b/core.c +@@ -718,7 +718,7 @@ static void mwl_chnl_switch_event(struct + vif = container_of((void *)mwl_vif, struct ieee80211_vif, + drv_priv); + +- if (vif->csa_active) ++ if (vif->bss_conf.csa_active) + ieee80211_csa_finish(vif); + } + spin_unlock_bh(&priv->vif_lock); +--- a/debugfs.c ++++ b/debugfs.c +@@ -498,9 +498,9 @@ static ssize_t mwl_debugfs_vif_read(stru + switch (vif->type) { + case NL80211_IFTYPE_AP: + len += scnprintf(p + len, size - len, "type: ap\n"); +- memcpy(ssid, vif->bss_conf.ssid, +- vif->bss_conf.ssid_len); +- ssid[vif->bss_conf.ssid_len] = 0; ++ memcpy(ssid, vif->cfg.ssid, ++ vif->cfg.ssid_len); ++ ssid[vif->cfg.ssid_len] = 0; + len += scnprintf(p + len, size - len, + "ssid: %s\n", ssid); + len += scnprintf(p + len, size - len, +@@ -522,8 +522,8 @@ static ssize_t mwl_debugfs_vif_read(stru + "type: unknown\n"); + break; + } +- if (vif->chanctx_conf) { +- chan_def = &vif->chanctx_conf->def; ++ if (vif->bss_conf.chanctx_conf) { ++ chan_def = &vif->bss_conf.chanctx_conf->def; + len += scnprintf(p + len, size - len, + "channel: %d: width: %d\n", + chan_def->chan->hw_value, +@@ -596,18 +596,18 @@ static ssize_t mwl_debugfs_sta_read(stru + sta_info->wds ? "true" : "false", + sta_info->ba_hist.enable ? "enable" : "disable", + sta_info->is_amsdu_allowed ? sta_info->amsdu_ctrl.cap : 0 , +- sta->ht_cap.ht_supported ? sta->ht_cap.cap : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.ampdu_factor : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.ampdu_density : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.mcs.rx_mask[0] : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.mcs.rx_mask[1] : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.mcs.rx_mask[2] : 0, +- sta->ht_cap.ht_supported ? sta->ht_cap.mcs.rx_mask[3] : 0, +- sta->vht_cap.vht_supported ? sta->vht_cap.cap : 0, +- sta->vht_cap.vht_supported ? sta->vht_cap.vht_mcs.rx_mcs_map : 0, +- sta->vht_cap.vht_supported ? sta->vht_cap.vht_mcs.tx_mcs_map : 0, +- sta->bandwidth, +- sta->rx_nss, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.cap : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.ampdu_factor : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.ampdu_density : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.mcs.rx_mask[0] : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.mcs.rx_mask[1] : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.mcs.rx_mask[2] : 0, ++ sta->deflink.ht_cap.ht_supported ? sta->deflink.ht_cap.mcs.rx_mask[3] : 0, ++ sta->deflink.vht_cap.vht_supported ? sta->deflink.vht_cap.cap : 0, ++ sta->deflink.vht_cap.vht_supported ? sta->deflink.vht_cap.vht_mcs.rx_mcs_map : 0, ++ sta->deflink.vht_cap.vht_supported ? sta->deflink.vht_cap.vht_mcs.tx_mcs_map : 0, ++ sta->deflink.bandwidth, ++ sta->deflink.rx_nss, + sta->tdls, + sta->tdls_initiator, + sta->wme, +--- a/hif/fwcmd.c ++++ b/hif/fwcmd.c +@@ -633,11 +633,15 @@ einval: + } + + static int mwl_fwcmd_set_ap_beacon(struct mwl_priv *priv, +- struct mwl_vif *mwl_vif, +- struct ieee80211_bss_conf *bss_conf) ++ struct ieee80211_vif *vif) + { + struct hostcmd_cmd_ap_beacon *pcmd; + struct ds_params *phy_ds_param_set; ++ struct mwl_vif *mwl_vif; ++ struct ieee80211_bss_conf *bss_conf; ++ ++ mwl_vif = mwl_dev_get_vif(vif); ++ bss_conf = &vif->bss_conf; + + /* wmm structure of start command is defined less one byte, + * due to following field country is not used, add byte one +@@ -664,7 +668,7 @@ static int mwl_fwcmd_set_ap_beacon(struc + pcmd->cmd_hdr.macid = mwl_vif->macid; + + ether_addr_copy(pcmd->start_cmd.sta_mac_addr, mwl_vif->bssid); +- memcpy(pcmd->start_cmd.ssid, bss_conf->ssid, bss_conf->ssid_len); ++ memcpy(pcmd->start_cmd.ssid, vif->cfg.ssid, vif->cfg.ssid_len); + if (priv->chip_type == MWL8997) + ether_addr_copy(pcmd->start_cmd.bssid, mwl_vif->bssid); + pcmd->start_cmd.bss_type = 1; +@@ -2090,7 +2094,7 @@ int mwl_fwcmd_set_beacon(struct ieee8021 + if (mwl_fwcmd_set_wsc_ie(hw, b_inf->ie_wsc_len, b_inf->ie_wsc_ptr)) + goto err; + +- if (mwl_fwcmd_set_ap_beacon(priv, mwl_vif, &vif->bss_conf)) ++ if (mwl_fwcmd_set_ap_beacon(priv, vif)) + goto err; + + if (b_inf->cap_info & WLAN_CAPABILITY_SPECTRUM_MGMT) +@@ -2152,38 +2156,38 @@ int mwl_fwcmd_set_new_stn_add(struct iee + ether_addr_copy(pcmd->mac_addr, sta->addr); + + if (hw->conf.chandef.chan->band == NL80211_BAND_2GHZ) +- rates = sta->supp_rates[NL80211_BAND_2GHZ]; ++ rates = sta->deflink.supp_rates[NL80211_BAND_2GHZ]; + else +- rates = sta->supp_rates[NL80211_BAND_5GHZ] << 5; ++ rates = sta->deflink.supp_rates[NL80211_BAND_5GHZ] << 5; + pcmd->peer_info.legacy_rate_bitmap = cpu_to_le32(rates); + +- if (sta->ht_cap.ht_supported) { ++ if (sta->deflink.ht_cap.ht_supported) { + int i; + + for (i = 0; i < 4; i++) { +- if (i < sta->rx_nss) { ++ if (i < sta->deflink.rx_nss) { + pcmd->peer_info.ht_rates[i] = +- sta->ht_cap.mcs.rx_mask[i]; ++ sta->deflink.ht_cap.mcs.rx_mask[i]; + } else { + pcmd->peer_info.ht_rates[i] = 0; + } + } +- pcmd->peer_info.ht_cap_info = cpu_to_le16(sta->ht_cap.cap); ++ pcmd->peer_info.ht_cap_info = cpu_to_le16(sta->deflink.ht_cap.cap); + pcmd->peer_info.mac_ht_param_info = +- (sta->ht_cap.ampdu_factor & 3) | +- ((sta->ht_cap.ampdu_density & 7) << 2); ++ (sta->deflink.ht_cap.ampdu_factor & 3) | ++ ((sta->deflink.ht_cap.ampdu_density & 7) << 2); + } + +- if (sta->vht_cap.vht_supported) { ++ if (sta->deflink.vht_cap.vht_supported) { + u32 rx_mcs_map_mask = 0; + +- rx_mcs_map_mask = ((0x0000FFFF) >> (sta->rx_nss * 2)) +- << (sta->rx_nss * 2); ++ rx_mcs_map_mask = ((0x0000FFFF) >> (sta->deflink.rx_nss * 2)) ++ << (sta->deflink.rx_nss * 2); + pcmd->peer_info.vht_max_rx_mcs = + cpu_to_le32((*((u32 *) +- &sta->vht_cap.vht_mcs.rx_mcs_map)) | rx_mcs_map_mask); +- pcmd->peer_info.vht_cap = cpu_to_le32(sta->vht_cap.cap); +- pcmd->peer_info.vht_rx_channel_width = sta->bandwidth; ++ &sta->deflink.vht_cap.vht_mcs.rx_mcs_map)) | rx_mcs_map_mask); ++ pcmd->peer_info.vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); ++ pcmd->peer_info.vht_rx_channel_width = sta->deflink.bandwidth; + } + + pcmd->is_qos_sta = sta->wme; +@@ -2239,38 +2243,38 @@ int mwl_fwcmd_set_new_stn_add_sc4(struct + ether_addr_copy(pcmd->mac_addr, sta->addr); + + if (hw->conf.chandef.chan->band == NL80211_BAND_2GHZ) +- rates = sta->supp_rates[NL80211_BAND_2GHZ]; ++ rates = sta->deflink.supp_rates[NL80211_BAND_2GHZ]; + else +- rates = sta->supp_rates[NL80211_BAND_5GHZ] << 5; ++ rates = sta->deflink.supp_rates[NL80211_BAND_5GHZ] << 5; + pcmd->peer_info.legacy_rate_bitmap = cpu_to_le32(rates); + +- if (sta->ht_cap.ht_supported) { ++ if (sta->deflink.ht_cap.ht_supported) { + int i; + + for (i = 0; i < 4; i++) { +- if (i < sta->rx_nss) { ++ if (i < sta->deflink.rx_nss) { + pcmd->peer_info.ht_rates[i] = +- sta->ht_cap.mcs.rx_mask[i]; ++ sta->deflink.ht_cap.mcs.rx_mask[i]; + } else { + pcmd->peer_info.ht_rates[i] = 0; + } + } +- pcmd->peer_info.ht_cap_info = cpu_to_le16(sta->ht_cap.cap); ++ pcmd->peer_info.ht_cap_info = cpu_to_le16(sta->deflink.ht_cap.cap); + pcmd->peer_info.mac_ht_param_info = +- (sta->ht_cap.ampdu_factor & 3) | +- ((sta->ht_cap.ampdu_density & 7) << 2); ++ (sta->deflink.ht_cap.ampdu_factor & 3) | ++ ((sta->deflink.ht_cap.ampdu_density & 7) << 2); + } + +- if (sta->vht_cap.vht_supported) { ++ if (sta->deflink.vht_cap.vht_supported) { + u32 rx_mcs_map_mask = 0; + +- rx_mcs_map_mask = ((0x0000FFFF) >> (sta->rx_nss * 2)) +- << (sta->rx_nss * 2); ++ rx_mcs_map_mask = ((0x0000FFFF) >> (sta->deflink.rx_nss * 2)) ++ << (sta->deflink.rx_nss * 2); + pcmd->peer_info.vht_max_rx_mcs = + cpu_to_le32((*((u32 *) +- &sta->vht_cap.vht_mcs.rx_mcs_map)) | rx_mcs_map_mask); +- pcmd->peer_info.vht_cap = cpu_to_le32(sta->vht_cap.cap); +- pcmd->peer_info.vht_rx_channel_width = sta->bandwidth; ++ &sta->deflink.vht_cap.vht_mcs.rx_mcs_map)) | rx_mcs_map_mask); ++ pcmd->peer_info.vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); ++ pcmd->peer_info.vht_rx_channel_width = sta->deflink.bandwidth; + } + + pcmd->is_qos_sta = sta->wme; +@@ -2787,9 +2791,9 @@ int mwl_fwcmd_create_ba(struct ieee80211 + pcmd->ba_info.create_params.flags = cpu_to_le32(ba_flags); + pcmd->ba_info.create_params.queue_id = stream->idx; + pcmd->ba_info.create_params.param_info = +- (stream->sta->ht_cap.ampdu_factor & ++ (stream->sta->deflink.ht_cap.ampdu_factor & + IEEE80211_HT_AMPDU_PARM_FACTOR) | +- ((stream->sta->ht_cap.ampdu_density << 2) & ++ ((stream->sta->deflink.ht_cap.ampdu_density << 2) & + IEEE80211_HT_AMPDU_PARM_DENSITY); + if (direction == BA_FLAG_DIRECTION_UP) { + pcmd->ba_info.create_params.reset_seq_no = 0; +@@ -2799,9 +2803,9 @@ int mwl_fwcmd_create_ba(struct ieee80211 + pcmd->ba_info.create_params.current_seq = cpu_to_le16(0); + } + if (priv->chip_type == MWL8964 && +- stream->sta->vht_cap.vht_supported) { ++ stream->sta->deflink.vht_cap.vht_supported) { + pcmd->ba_info.create_params.vht_rx_factor = +- cpu_to_le32((stream->sta->vht_cap.cap & ++ cpu_to_le32((stream->sta->deflink.vht_cap.cap & + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK) >> + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); + } +--- a/hif/pcie/8864/tx.c ++++ b/hif/pcie/8864/tx.c +@@ -743,7 +743,7 @@ void pcie_8864_tx_xmit(struct ieee80211_ + index = SYSADPT_TX_WMM_QUEUES - index - 1; + txpriority = index; + +- if (sta && sta->ht_cap.ht_supported && ++ if (sta && sta->deflink.ht_cap.ht_supported && + !(xmitcontrol & EAGLE_TXD_XMITCTRL_USE_MC_RATE) && + ieee80211_is_data_qos(wh->frame_control)) { + tid = qos & 0xf; +--- a/hif/pcie/8964/tx_ndp.c ++++ b/hif/pcie/8964/tx_ndp.c +@@ -607,7 +607,7 @@ void pcie_tx_xmit_ndp(struct ieee80211_h + pcie_tx_encapsulate_frame(priv, skb, k_conf); + } else { + tid = qos & 0x7; +- if (sta && sta->ht_cap.ht_supported && !eapol_frame && ++ if (sta && sta->deflink.ht_cap.ht_supported && !eapol_frame && + qos != 0xFFFF) { + pcie_tx_count_packet(sta, tid); + spin_lock_bh(&priv->stream_lock); +--- a/hif/pcie/8997/tx.c ++++ b/hif/pcie/8997/tx.c +@@ -81,7 +81,7 @@ static int pcie_txbd_ring_create(struct + wiphy_info(priv->hw->wiphy, + "TX ring: - base: %p, pbase: 0x%x, len: %d\n", + pcie_priv->txbd_ring_vbase, +- pcie_priv->txbd_ring_pbase, ++ (u32)pcie_priv->txbd_ring_pbase, + pcie_priv->txbd_ring_size); + + for (num = 0; num < PCIE_MAX_TXRX_BD; num++) { +@@ -694,7 +694,7 @@ void pcie_8997_tx_xmit(struct ieee80211_ + index = SYSADPT_TX_WMM_QUEUES - index - 1; + txpriority = index; + +- if (sta && sta->ht_cap.ht_supported && ++ if (sta && sta->deflink.ht_cap.ht_supported && + !(xmitcontrol & EAGLE_TXD_XMITCTRL_USE_MC_RATE) && + ieee80211_is_data_qos(wh->frame_control)) { + tid = qos & 0xf; +--- a/mac80211.c ++++ b/mac80211.c +@@ -368,15 +368,15 @@ static void mwl_mac80211_bss_info_change + } + } + +- if ((changed & BSS_CHANGED_ASSOC) && vif->bss_conf.assoc) ++ if ((changed & BSS_CHANGED_ASSOC) && vif->cfg.assoc) + mwl_fwcmd_set_aid(hw, vif, (u8 *)vif->bss_conf.bssid, +- vif->bss_conf.aid); ++ vif->cfg.aid); + } + + static void mwl_mac80211_bss_info_changed_ap(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *info, +- u32 changed) ++ u64 changed) + { + struct mwl_priv *priv = hw->priv; + struct mwl_vif *mwl_vif; +@@ -426,8 +426,8 @@ static void mwl_mac80211_bss_info_change + if (changed & (BSS_CHANGED_BEACON_INT | BSS_CHANGED_BEACON)) { + struct sk_buff *skb; + +- if ((info->ssid[0] != '\0') && +- (info->ssid_len != 0) && ++ if ((vif->cfg.ssid[0] != '\0') && ++ (vif->cfg.ssid_len != 0) && + (!info->hidden_ssid)) { + if (mwl_vif->broadcast_ssid != true) { + mwl_fwcmd_broadcast_ssid_enable(hw, vif, true); +@@ -441,7 +441,7 @@ static void mwl_mac80211_bss_info_change + } + + if (!mwl_vif->set_beacon) { +- skb = ieee80211_beacon_get(hw, vif); ++ skb = ieee80211_beacon_get(hw, vif, 0); + + if (skb) { + mwl_fwcmd_set_beacon(hw, vif, skb->data, skb->len); +@@ -458,7 +458,7 @@ static void mwl_mac80211_bss_info_change + static void mwl_mac80211_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *info, +- u32 changed) ++ u64 changed) + { + switch (vif->type) { + case NL80211_IFTYPE_AP: +@@ -583,10 +583,10 @@ static int mwl_mac80211_sta_add(struct i + if (vif->type == NL80211_IFTYPE_MESH_POINT) + sta_info->is_mesh_node = true; + +- if (sta->ht_cap.ht_supported) { ++ if (sta->deflink.ht_cap.ht_supported) { + sta_info->is_ampdu_allowed = true; + sta_info->is_amsdu_allowed = false; +- if (sta->ht_cap.cap & IEEE80211_HT_CAP_MAX_AMSDU) { ++ if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_MAX_AMSDU) { + sta_info->amsdu_ctrl.cap = MWL_AMSDU_SIZE_8K; + sta_info->amsdu_ctrl.amsdu_allow_size = SYSADPT_AMSDU_8K_MAX_SIZE; + } +@@ -670,7 +670,7 @@ static int mwl_mac80211_sta_remove(struc + + static int mwl_mac80211_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, +- u16 queue, ++ unsigned int link_id, u16 queue, + const struct ieee80211_tx_queue_params *params) + { + struct mwl_priv *priv = hw->priv; +@@ -934,4 +934,5 @@ const struct ieee80211_ops mwl_mac80211_ + .pre_channel_switch = mwl_mac80211_chnl_switch, + .sw_scan_start = mwl_mac80211_sw_scan_start, + .sw_scan_complete = mwl_mac80211_sw_scan_complete, ++ .wake_tx_queue = ieee80211_handle_wake_tx_queue, + }; +--- a/utils.c ++++ b/utils.c +@@ -173,9 +173,9 @@ u32 utils_get_init_tx_rate(struct mwl_pr + u32 tx_rate; + u16 format, nss, bw, rate_mcs; + +- if (sta->vht_cap.vht_supported) ++ if (sta->deflink.vht_cap.vht_supported) + format = TX_RATE_FORMAT_11AC; +- else if (sta->ht_cap.ht_supported) ++ else if (sta->deflink.ht_cap.ht_supported) + format = TX_RATE_FORMAT_11N; + else + format = TX_RATE_FORMAT_LEGACY; +@@ -192,11 +192,11 @@ u32 utils_get_init_tx_rate(struct mwl_pr + nss = 3; + break; + default: +- nss = sta->rx_nss; ++ nss = sta->deflink.rx_nss; + break; + } +- if (nss > sta->rx_nss) +- nss = sta->rx_nss; ++ if (nss > sta->deflink.rx_nss) ++ nss = sta->deflink.rx_nss; + + switch (conf->chandef.width) { + case NL80211_CHAN_WIDTH_20_NOHT: +@@ -213,11 +213,11 @@ u32 utils_get_init_tx_rate(struct mwl_pr + bw = TX_RATE_BANDWIDTH_160; + break; + default: +- bw = sta->bandwidth; ++ bw = sta->deflink.bandwidth; + break; + } +- if (bw > sta->bandwidth) +- bw = sta->bandwidth; ++ if (bw > sta->deflink.bandwidth) ++ bw = sta->deflink.bandwidth; + + switch (format) { + case TX_RATE_FORMAT_LEGACY: diff --git a/package/kernel/nat46/Makefile b/package/kernel/nat46/Makefile index ef1a90ed8cb..5e5efbe101a 100644 --- a/package/kernel/nat46/Makefile +++ b/package/kernel/nat46/Makefile @@ -3,11 +3,11 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=nat46 -PKG_MIRROR_HASH:=3b424241de42b96d47217decf6f9071153cd0c11651f1ee006700836c6660fe8 +PKG_MIRROR_HASH:=aeff95aa278ec1e197b59700284c0210f32b92c1fb757e5c3088bd00b3b403d4 PKG_SOURCE_URL:=https://github.com/ayourtch/nat46.git -PKG_SOURCE_DATE:=2021-05-17 +PKG_SOURCE_DATE:=2022-09-19 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=0d5860d63a8037e001e293091ebf6219cc2f9255 +PKG_SOURCE_VERSION:=4c5beee236841724219598fabb1edc93d4f08ce5 PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com> PKG_LICENSE:=GPL-2.0 @@ -15,7 +15,7 @@ PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk define KernelPackage/nat46 - DEPENDS:=@IPV6 + DEPENDS:=@IPV6 +kmod-nf-conntrack6 TITLE:=Stateless NAT46 translation kernel module SECTION:=kernel SUBMENU:=Network Support diff --git a/package/kernel/om-watchdog/Makefile b/package/kernel/om-watchdog/Makefile deleted file mode 100644 index b0de3de74ed..00000000000 --- a/package/kernel/om-watchdog/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (C) 2011 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:=om-watchdog -PKG_RELEASE:=4 - -include $(INCLUDE_DIR)/package.mk - -define Package/om-watchdog - SECTION:=base - CATEGORY:=Base system - TITLE:=om watchdog - URL:=http://openwrt.org/ -endef - -define Package/om-watchdog/description - This package contains the hw watchdog script for the OM1P and OM2P device. -endef - -define Build/Compile -endef - -define Package/om-watchdog/install - $(INSTALL_DIR) $(1)/etc/init.d/ - $(INSTALL_DIR) $(1)/sbin/ - $(INSTALL_BIN) ./files/om-watchdog.init $(1)/etc/init.d/om-watchdog - $(INSTALL_BIN) ./files/om-watchdog $(1)/sbin/om-watchdog -endef - -$(eval $(call BuildPackage,om-watchdog)) diff --git a/package/kernel/om-watchdog/files/om-watchdog b/package/kernel/om-watchdog/files/om-watchdog deleted file mode 100644 index d730c68447e..00000000000 --- a/package/kernel/om-watchdog/files/om-watchdog +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -GPIO=$1 - -trap "" INT HUP - -echo $GPIO > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio${GPIO}/direction - -while true; do - echo 1 > /sys/class/gpio/gpio${GPIO}/value - sleep 1 - echo 0 > /sys/class/gpio/gpio${GPIO}/value - sleep 180 -done diff --git a/package/kernel/om-watchdog/files/om-watchdog.init b/package/kernel/om-watchdog/files/om-watchdog.init deleted file mode 100644 index 8cbac043e43..00000000000 --- a/package/kernel/om-watchdog/files/om-watchdog.init +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh /etc/rc.common -# -# Copyright (C) 2011 OpenWrt.org -# - -START=11 -STOP=11 - -USE_PROCD=1 -NAME=om-watchdog -PROG=/sbin/om-watchdog - -get_gpio() { - local board=$(board_name) - - if [ "$board" = "teltonika,rut5xx" ]; then - # ramips - return 11 - else - #we assume it is om1p in this case - return 3 - fi - - return 255 -} - -start_service() { - get_gpio - gpio="$?" - [ "$gpio" != "255" ] || return - - procd_open_instance - procd_set_param command "${PROG}" "${gpio}" - procd_set_param respawn - procd_close_instance -} diff --git a/package/kernel/qca-nss-dp/Makefile b/package/kernel/qca-nss-dp/Makefile new file mode 100644 index 00000000000..f9e992f246a --- /dev/null +++ b/package/kernel/qca-nss-dp/Makefile @@ -0,0 +1,54 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-nss-dp +PKG_RELEASE:=2 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-dp.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-06-06 +PKG_SOURCE_VERSION:=fa67464466f69f00967cc373d1bdd6025f57eb89 +PKG_MIRROR_HASH:=51bf524382a5cb542c2c80d12a91f87b9736de3ac3c1d4a351c97b3502d68574 + +PKG_BUILD_PARALLEL:=1 +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/qca-nss-dp + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + DEPENDS:=@TARGET_qualcommax +kmod-qca-ssdk + TITLE:=Qualcom NSS dataplane ethernet driver + FILES:=$(PKG_BUILD_DIR)/qca-nss-dp.ko + AUTOLOAD:=$(call AutoLoad,31,qca-nss-dp,1) +endef + +define KernelPackage/qca-nss-dp/Description + NSS dataplane ethernet driver for Qualcom SoCs. +endef + +define Build/InstallDev + mkdir -p $(1)/usr/include/qca-nss-dp + $(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-dp/ +endef + +EXTRA_CFLAGS+= \ + -I$(STAGING_DIR)/usr/include/qca-ssdk + +NSS_DP_HAL_DIR:=$(PKG_BUILD_DIR)/hal +define Build/Configure + $(LN) $(NSS_DP_HAL_DIR)/soc_ops/$(CONFIG_TARGET_SUBTARGET)/nss_$(CONFIG_TARGET_SUBTARGET).h \ + $(PKG_BUILD_DIR)/exports/nss_dp_arch.h +endef + +define Build/Compile + +$(KERNEL_MAKE) $(PKG_JOBS) \ + -C "$(LINUX_DIR)" \ + M="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC="$(CONFIG_TARGET_SUBTARGET)" \ + modules +endef + +$(eval $(call KernelPackage,qca-nss-dp)) diff --git a/package/kernel/qca-nss-dp/patches/0001-nss-dp-Drop-_nocache-variants-of-ioremap.patch b/package/kernel/qca-nss-dp/patches/0001-nss-dp-Drop-_nocache-variants-of-ioremap.patch new file mode 100644 index 00000000000..c998874d4e6 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0001-nss-dp-Drop-_nocache-variants-of-ioremap.patch @@ -0,0 +1,48 @@ +From 946381fd6fdabedf2b5a1d8647a49e3da8f1894e Mon Sep 17 00:00:00 2001 +From: Baruch Siach <baruch@tkos.co.il> +Date: Fri, 23 Jun 2023 11:28:02 +0200 +Subject: [PATCH 1/8] nss-dp: Drop _nocache variants of ioremap() + +ioremap_nocache was made equivelant to ioremap and was dropped. + +Signed-off-by: Baruch Siach <baruch@tkos.co.il> +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 2 +- + hal/gmac_ops/syn/gmac/syn_if.c | 2 +- + hal/soc_ops/ipq50xx/nss_ipq50xx.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c +@@ -279,7 +279,7 @@ int edma_init(void) + /* + * Remap register resource + */ +- edma_hw.reg_base = ioremap_nocache((edma_hw.reg_resource)->start, ++ edma_hw.reg_base = ioremap((edma_hw.reg_resource)->start, + resource_size(edma_hw.reg_resource)); + if (!edma_hw.reg_base) { + pr_warn("Unable to remap EDMA register memory.\n"); +--- a/hal/gmac_ops/syn/gmac/syn_if.c ++++ b/hal/gmac_ops/syn/gmac/syn_if.c +@@ -806,7 +806,7 @@ static void *syn_init(struct nss_gmac_ha + * Populate the mac base addresses + */ + shd->nghd.mac_base = +- devm_ioremap_nocache(&dp_priv->pdev->dev, res->start, ++ devm_ioremap(&dp_priv->pdev->dev, res->start, + resource_size(res)); + if (!shd->nghd.mac_base) { + netdev_dbg(ndev, "ioremap fail.\n"); +--- a/hal/soc_ops/ipq50xx/nss_ipq50xx.c ++++ b/hal/soc_ops/ipq50xx/nss_ipq50xx.c +@@ -89,7 +89,7 @@ static void nss_dp_hal_tcsr_set(void) + pr_err("%s: SCM TCSR write error: %d\n", __func__, err); + } + } else { +- tcsr_addr = ioremap_nocache((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET), ++ tcsr_addr = ioremap((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET), + TCSR_GMAC_AXI_CACHE_OVERRIDE_REG_SIZE); + if (!tcsr_addr) { + pr_err("%s: ioremap failed\n", __func__); diff --git a/package/kernel/qca-nss-dp/patches/0002-edma_tx_rx-support-newer-kernels-time-stamping-API.patch b/package/kernel/qca-nss-dp/patches/0002-edma_tx_rx-support-newer-kernels-time-stamping-API.patch new file mode 100644 index 00000000000..d091311b975 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0002-edma_tx_rx-support-newer-kernels-time-stamping-API.patch @@ -0,0 +1,47 @@ +From 3357c64b3fc63fe003d5ef02ba7f6abca64d80bf Mon Sep 17 00:00:00 2001 +From: Baruch Siach <baruch@tkos.co.il> +Date: Mon, 3 May 2021 20:07:36 +0300 +Subject: [PATCH 2/8] edma_tx_rx: support newer kernels time stamping API + +Timestamping API has changed in kernel 5.6, so update the implementation +for newer kernels. + +Signed-off-by: Baruch Siach <baruch@tkos.co.il> +--- + hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c +@@ -227,10 +227,16 @@ void nss_phy_tstamp_rx_buf(__attribute__ + * set to the correct PTP class value by calling ptp_classify_raw + * in drv->rxtstamp function. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) + if (ndev && ndev->phydev && ndev->phydev->drv && + ndev->phydev->drv->rxtstamp) + if(ndev->phydev->drv->rxtstamp(ndev->phydev, skb, 0)) + return; ++#else ++ if (ndev && phy_has_rxtstamp(ndev->phydev)) ++ if (phy_rxtstamp(ndev->phydev, skb, 0)) ++ return; ++#endif + + netif_receive_skb(skb); + } +@@ -248,9 +254,14 @@ void nss_phy_tstamp_tx_buf(struct net_de + * set to the correct PTP class value by calling ptp_classify_raw + * in the drv->txtstamp function. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) + if (ndev && ndev->phydev && ndev->phydev->drv && + ndev->phydev->drv->txtstamp) + ndev->phydev->drv->txtstamp(ndev->phydev, skb, 0); ++#else ++ if (ndev && phy_has_txtstamp(ndev->phydev)) ++ phy_txtstamp(ndev->phydev, skb, 0); ++#endif + } + EXPORT_SYMBOL(nss_phy_tstamp_tx_buf); + diff --git a/package/kernel/qca-nss-dp/patches/0003-EDMA-Fix-NAPI-packet-counting.patch b/package/kernel/qca-nss-dp/patches/0003-EDMA-Fix-NAPI-packet-counting.patch new file mode 100644 index 00000000000..a2268010d4c --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0003-EDMA-Fix-NAPI-packet-counting.patch @@ -0,0 +1,31 @@ +From c36420c219bf0e03842a11f69193c802eb42030a Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Thu, 20 May 2021 14:56:46 +0200 +Subject: [PATCH 3/8] EDMA: Fix NAPI packet counting + +There is a bug in the NAPI packet counting that will +cause NAPI over budget warnings. + +Signed-off-by: Baruch Siach <baruch@tkos.co.il> +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c +@@ -459,12 +459,12 @@ int edma_napi(struct napi_struct *napi, + + for (i = 0; i < ehw->txcmpl_rings; i++) { + txcmpl_ring = &ehw->txcmpl_ring[i]; +- work_done += edma_clean_tx(ehw, txcmpl_ring); ++ edma_clean_tx(ehw, txcmpl_ring); + } + + for (i = 0; i < ehw->rxfill_rings; i++) { + rxfill_ring = &ehw->rxfill_ring[i]; +- work_done += edma_alloc_rx_buffer(ehw, rxfill_ring); ++ edma_alloc_rx_buffer(ehw, rxfill_ring); + } + + /* diff --git a/package/kernel/qca-nss-dp/patches/0004-EDMA-Use-NAPI_POLL_WEIGHT-as-NAPI-weight.patch b/package/kernel/qca-nss-dp/patches/0004-EDMA-Use-NAPI_POLL_WEIGHT-as-NAPI-weight.patch new file mode 100644 index 00000000000..84fb02a92a5 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0004-EDMA-Use-NAPI_POLL_WEIGHT-as-NAPI-weight.patch @@ -0,0 +1,41 @@ +From 158032d3d4e5089afa2aa38c27c6e222ac427820 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Thu, 20 May 2021 14:57:46 +0200 +Subject: [PATCH 4/8] EDMA: Use NAPI_POLL_WEIGHT as NAPI weight + +Currently a weight of 100 is used by the EDMA, according +to upstream max of 64 should be used and that is used for +almost any driver. + +They also introduced NAPI_POLL_WEIGHT define which equals +to 64. + +So use NAPI_POLL_WEIGHT as the weight. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 2 +- + hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h | 1 - + 2 files changed, 1 insertion(+), 2 deletions(-) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c +@@ -845,7 +845,7 @@ static int edma_register_netdevice(struc + */ + if (!edma_hw.napi_added) { + netif_napi_add(netdev, &edma_hw.napi, edma_napi, +- EDMA_NAPI_WORK); ++ NAPI_POLL_WEIGHT); + /* + * Register the interrupt handlers and enable interrupts + */ +--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h +@@ -26,7 +26,6 @@ + #define EDMA_RX_PREHDR_SIZE (sizeof(struct edma_rx_preheader)) + #define EDMA_TX_PREHDR_SIZE (sizeof(struct edma_tx_preheader)) + #define EDMA_RING_SIZE 128 +-#define EDMA_NAPI_WORK 100 + #define EDMA_START_GMACS NSS_DP_HAL_START_IFNUM + #define EDMA_MAX_GMACS NSS_DP_HAL_MAX_PORTS + #define EDMA_TX_PKT_MIN_SIZE 33 /* IPQ807x EDMA needs a minimum packet size of 33 bytes */ diff --git a/package/kernel/qca-nss-dp/patches/0005-nss-dp-adapt-to-netif_napi_add-changes.patch b/package/kernel/qca-nss-dp/patches/0005-nss-dp-adapt-to-netif_napi_add-changes.patch new file mode 100644 index 00000000000..d5b0f624783 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0005-nss-dp-adapt-to-netif_napi_add-changes.patch @@ -0,0 +1,46 @@ +From e46c4d526d77916c00fff4fff3237b9c9d0d774d Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Fri, 23 Jun 2023 12:04:11 +0200 +Subject: [PATCH 5/8] nss-dp: adapt to netif_napi_add() changes + +netif_napi_add() removed the weight argument and just uses the default +NAPI_POLL_WEIGHT in background, so for those requiring custom weight use +netif_napi_add_weight() instead. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 4 ++++ + hal/dp_ops/syn_gmac_dp/syn_dp.c | 5 +++++ + 2 files changed, 9 insertions(+) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c +@@ -844,8 +844,12 @@ static int edma_register_netdevice(struc + * NAPI add + */ + if (!edma_hw.napi_added) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) + netif_napi_add(netdev, &edma_hw.napi, edma_napi, + NAPI_POLL_WEIGHT); ++#else ++ netif_napi_add(netdev, &edma_hw.napi, edma_napi); ++#endif + /* + * Register the interrupt handlers and enable interrupts + */ +--- a/hal/dp_ops/syn_gmac_dp/syn_dp.c ++++ b/hal/dp_ops/syn_gmac_dp/syn_dp.c +@@ -189,8 +189,13 @@ static int syn_dp_if_init(struct nss_dp_ + } + + if (!dev_info->napi_added) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) + netif_napi_add(netdev, &rx_info->napi_rx, syn_dp_napi_poll_rx, SYN_DP_NAPI_BUDGET_RX); + netif_napi_add(netdev, &tx_info->napi_tx, syn_dp_napi_poll_tx, SYN_DP_NAPI_BUDGET_TX); ++#else ++ netif_napi_add_weight(netdev, &rx_info->napi_rx, syn_dp_napi_poll_rx, SYN_DP_NAPI_BUDGET_RX); ++ netif_napi_add_weight(netdev, &tx_info->napi_tx, syn_dp_napi_poll_tx, SYN_DP_NAPI_BUDGET_TX); ++#endif + + /* + * Requesting irq. Set IRQ_DISABLE_UNLAZY flag, this flag diff --git a/package/kernel/qca-nss-dp/patches/0006-nss_dp_main-Use-a-phy-handle-property-to-connect-to-.patch b/package/kernel/qca-nss-dp/patches/0006-nss_dp_main-Use-a-phy-handle-property-to-connect-to-.patch new file mode 100644 index 00000000000..0432b82dda3 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0006-nss_dp_main-Use-a-phy-handle-property-to-connect-to-.patch @@ -0,0 +1,180 @@ +From 5b05b1d7a2d2001d9711856608f61abaf7b9a9a5 Mon Sep 17 00:00:00 2001 +From: Alexandru Gagniuc <mr.nuke.me@gmail.com> +Date: Fri, 23 Jun 2023 13:34:56 +0200 +Subject: [PATCH 6/8] nss_dp_main: Use a 'phy-handle' property to connect to + the PHY + +The original method of connecting a PHY to the ethernet controller +requires the "qcom,link-poll", and "qcom,phy-mdio-addr" devicetree +properties. This is redundant. The PHY node already contains the MDIO +address, and attaching a PHY implies "link-poll". + +Allow using a "phy-handle" property. Remove the following properties, +as they are no longer used: + * "qcom,link-poll" + * "qcom,phy-mdio-addr" + * "mdio-bus" + * "qcom,forced-speed" + * "qcom,forced-duplex" + +Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + include/nss_dp_dev.h | 5 +-- + nss_dp_main.c | 91 +++++++------------------------------------- + 2 files changed, 14 insertions(+), 82 deletions(-) + +--- a/include/nss_dp_dev.h ++++ b/include/nss_dp_dev.h +@@ -202,13 +202,10 @@ struct nss_dp_dev { + unsigned long drv_flags; /* Driver specific feature flags */ + + /* Phy related stuff */ ++ struct device_node *phy_node; /* Phy device OF node */ + struct phy_device *phydev; /* Phy device */ + struct mii_bus *miibus; /* MII bus */ + uint32_t phy_mii_type; /* RGMII/SGMII/QSGMII */ +- uint32_t phy_mdio_addr; /* Mdio address */ +- bool link_poll; /* Link polling enable? */ +- uint32_t forced_speed; /* Forced speed? */ +- uint32_t forced_duplex; /* Forced duplex? */ + uint32_t link_state; /* Current link state */ + uint32_t pause; /* Current flow control settings */ + +--- a/nss_dp_main.c ++++ b/nss_dp_main.c +@@ -418,7 +418,7 @@ static int nss_dp_open(struct net_device + + netif_start_queue(netdev); + +- if (!dp_priv->link_poll) { ++ if (!dp_priv->phydev) { + /* Notify data plane link is up */ + if (dp_priv->data_plane_ops->link_state(dp_priv->dpc, 1)) { + netdev_dbg(netdev, "Data plane set link failed\n"); +@@ -615,6 +615,12 @@ static int32_t nss_dp_of_get_pdata(struc + return -EFAULT; + } + ++ dp_priv->phy_node = of_parse_phandle(np, "phy-handle", 0); ++ if (!dp_priv->phy_node) { ++ pr_err("%s: error parsing phy-handle\n", np->name); ++ return -EFAULT; ++ } ++ + if (of_property_read_u32(np, "qcom,mactype", &hal_pdata->mactype)) { + pr_err("%s: error reading mactype\n", np->name); + return -EFAULT; +@@ -635,18 +641,6 @@ static int32_t nss_dp_of_get_pdata(struc + return -EFAULT; + #endif + +- dp_priv->link_poll = of_property_read_bool(np, "qcom,link-poll"); +- if (of_property_read_u32(np, "qcom,phy-mdio-addr", +- &dp_priv->phy_mdio_addr) && dp_priv->link_poll) { +- pr_err("%s: mdio addr required if link polling is enabled\n", +- np->name); +- return -EFAULT; +- } +- +- of_property_read_u32(np, "qcom,forced-speed", &dp_priv->forced_speed); +- of_property_read_u32(np, "qcom,forced-duplex", &dp_priv->forced_duplex); +- +- + #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) + maddr = (uint8_t *)of_get_mac_address(np); + #if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 4, 0)) +@@ -695,56 +689,6 @@ static int32_t nss_dp_of_get_pdata(struc + return 0; + } + +-/* +- * nss_dp_mdio_attach() +- */ +-static struct mii_bus *nss_dp_mdio_attach(struct platform_device *pdev) +-{ +- struct device_node *mdio_node; +- struct platform_device *mdio_plat; +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0)) +- struct ipq40xx_mdio_data *mdio_data; +-#endif +- +- /* +- * Find mii_bus using "mdio-bus" handle. +- */ +- mdio_node = of_parse_phandle(pdev->dev.of_node, "mdio-bus", 0); +- if (mdio_node) { +- return of_mdio_find_bus(mdio_node); +- } +- +- mdio_node = of_find_compatible_node(NULL, NULL, "qcom,qca-mdio"); +- if (!mdio_node) { +- mdio_node = of_find_compatible_node(NULL, NULL, +- "qcom,ipq40xx-mdio"); +- if (!mdio_node) { +- dev_err(&pdev->dev, "cannot find mdio node by phandle\n"); +- return NULL; +- } +- } +- +- mdio_plat = of_find_device_by_node(mdio_node); +- if (!mdio_plat) { +- dev_err(&pdev->dev, "cannot find platform device from mdio node\n"); +- of_node_put(mdio_node); +- return NULL; +- } +- +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) +- return dev_get_drvdata(&mdio_plat->dev); +-#else +- mdio_data = dev_get_drvdata(&mdio_plat->dev); +- if (!mdio_data) { +- dev_err(&pdev->dev, "cannot get mii bus reference from device data\n"); +- of_node_put(mdio_node); +- return NULL; +- } +- +- return mdio_data->mii_bus; +-#endif +-} +- + #ifdef CONFIG_NET_SWITCHDEV + /* + * nss_dp_is_phy_dev() +@@ -803,7 +747,6 @@ static int32_t nss_dp_probe(struct platf + struct device_node *np = pdev->dev.of_node; + struct nss_gmac_hal_platform_data gmac_hal_pdata; + int32_t ret = 0; +- uint8_t phy_id[MII_BUS_ID_SIZE + 3]; + #if defined(NSS_DP_PPE_SUPPORT) + uint32_t vsi_id; + fal_port_t port_id; +@@ -880,22 +823,14 @@ static int32_t nss_dp_probe(struct platf + + dp_priv->drv_flags |= NSS_DP_PRIV_FLAG(INIT_DONE); + +- if (dp_priv->link_poll) { +- dp_priv->miibus = nss_dp_mdio_attach(pdev); +- if (!dp_priv->miibus) { +- netdev_dbg(netdev, "failed to find miibus\n"); +- goto phy_setup_fail; +- } +- snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, +- dp_priv->miibus->id, dp_priv->phy_mdio_addr); +- ++ if (dp_priv->phy_node) { + SET_NETDEV_DEV(netdev, &pdev->dev); + +- dp_priv->phydev = phy_connect(netdev, phy_id, +- &nss_dp_adjust_link, +- dp_priv->phy_mii_type); +- if (IS_ERR(dp_priv->phydev)) { +- netdev_dbg(netdev, "failed to connect to phy device\n"); ++ dp_priv->phydev = of_phy_connect(netdev, dp_priv->phy_node, ++ &nss_dp_adjust_link, 0, ++ dp_priv->phy_mii_type); ++ if (!(dp_priv->phydev)) { ++ netdev_err(netdev, "failed to connect to phy device\n"); + goto phy_setup_fail; + } + } diff --git a/package/kernel/qca-nss-dp/patches/0007-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch b/package/kernel/qca-nss-dp/patches/0007-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch new file mode 100644 index 00000000000..6fbe75dc1c4 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0007-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch @@ -0,0 +1,56 @@ +From c2df713569fe3bb671d1444c7bf758681081053c Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Thu, 23 Jun 2022 14:18:50 +0200 +Subject: [PATCH 7/8] nss-dp: edma-v1: use NAPI GRO by default + +Utilize napi_gro_receive instead of plain netif_receive_skb on EDMA v1. + +Usually it provides quite a lot of RX speed improvements, however in some +cases it may lead to decreased performance as there is no checksum +offloading implemented. + +In cases where reduced performance is experienced its possible to disable +GRO by using ethtool. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 10 ++++++---- + hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 8 ++++++-- + 2 files changed, 12 insertions(+), 6 deletions(-) + +--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c +@@ -597,10 +597,12 @@ drop: + */ + static void edma_if_set_features(struct nss_dp_data_plane_ctx *dpc) + { +- /* +- * TODO - add flags to support HIGHMEM/cksum offload VLAN +- * the features are enabled. +- */ ++ struct net_device *netdev = dpc->dev; ++ ++ netdev->features |= NETIF_F_GRO; ++ netdev->hw_features |= NETIF_F_GRO; ++ netdev->vlan_features |= NETIF_F_GRO; ++ netdev->wanted_features |= NETIF_F_GRO; + } + + /* TODO - check if this is needed */ +--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c ++++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c +@@ -410,8 +410,12 @@ static uint32_t edma_clean_rx(struct edm + if (unlikely(EDMA_RXPH_SERVICE_CODE_GET(rxph) == + NSS_PTP_EVENT_SERVICE_CODE)) + nss_phy_tstamp_rx_buf(ndev, skb); +- else +- netif_receive_skb(skb); ++ else { ++ if (likely(ndev->features & NETIF_F_GRO)) ++ napi_gro_receive(&ehw->napi, skb); ++ else ++ netif_receive_skb(skb); ++ } + + next_rx_desc: + /* diff --git a/package/kernel/qca-nss-dp/patches/0008-nss-dp-allow-setting-netdev-name-from-DTS.patch b/package/kernel/qca-nss-dp/patches/0008-nss-dp-allow-setting-netdev-name-from-DTS.patch new file mode 100644 index 00000000000..e90bf32ced7 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0008-nss-dp-allow-setting-netdev-name-from-DTS.patch @@ -0,0 +1,50 @@ +From 53b044f7a21d5cd65ada90a228910e6efbad00fa Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Sun, 4 Dec 2022 18:41:36 +0100 +Subject: [PATCH 8/8] nss-dp: allow setting netdev name from DTS + +Allow reading the desired netdev name from DTS like DSA allows and then +set it as the netdev name during registration. + +If label is not defined, simply fallback to kernel ethN enumeration. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + nss_dp_main.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +--- a/nss_dp_main.c ++++ b/nss_dp_main.c +@@ -746,18 +746,29 @@ static int32_t nss_dp_probe(struct platf + struct nss_dp_dev *dp_priv; + struct device_node *np = pdev->dev.of_node; + struct nss_gmac_hal_platform_data gmac_hal_pdata; ++ const char *name = of_get_property(np, "label", NULL); + int32_t ret = 0; ++ int assign_type; + #if defined(NSS_DP_PPE_SUPPORT) + uint32_t vsi_id; + fal_port_t port_id; + #endif + ++ if (name) { ++ assign_type = NET_NAME_PREDICTABLE; ++ } else { ++ name = "eth%d"; ++ assign_type = NET_NAME_ENUM; ++ } ++ + /* TODO: See if we need to do some SoC level common init */ + +- netdev = alloc_etherdev_mqs(sizeof(struct nss_dp_dev), +- NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM); ++ netdev = alloc_netdev_mqs(sizeof(struct nss_dp_dev), ++ name, assign_type, ++ ether_setup, ++ NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM); + if (!netdev) { +- pr_info("alloc_etherdev() failed\n"); ++ dev_err(&pdev->dev, "alloc_netdev_mqs() failed\n"); + return -ENOMEM; + } + diff --git a/package/kernel/qca-nss-dp/patches/0009-nss-dp-switchdev-fix-FDB-roaming.patch b/package/kernel/qca-nss-dp/patches/0009-nss-dp-switchdev-fix-FDB-roaming.patch new file mode 100644 index 00000000000..ec10bdc2d98 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0009-nss-dp-switchdev-fix-FDB-roaming.patch @@ -0,0 +1,111 @@ +From 25ca3308edb67aa0c6c70b83edf0e22b8ae7533f Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Thu, 29 Jun 2023 13:52:58 +0200 +Subject: [PATCH] nss-dp: switchdev: fix FDB roaming + +Try and solve the roaming issue by trying to replicate what NSS bridge +module is doing, but by utilizing switchdev FDB notifiers instead of +adding new notifiers to the bridge code. + +We register a new non-blocking switchdev notifier and simply wait for +notification, and then process the SWITCHDEV_FDB_DEL_TO_DEVICE +notifications. + +Those tell us that a certain FDB entry should be removed, then a VSI ID +is fetched for the physical PPE port and using that VSI ID and the +notification provided MAC adress existing FDB entry gets removed. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + nss_dp_switchdev.c | 73 +++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 72 insertions(+), 1 deletion(-) + +--- a/nss_dp_switchdev.c ++++ b/nss_dp_switchdev.c +@@ -29,6 +29,8 @@ + #include "nss_dp_dev.h" + #include "fal/fal_stp.h" + #include "fal/fal_ctrlpkt.h" ++#include "fal/fal_fdb.h" ++#include "ref/ref_vsi.h" + + #define NSS_DP_SWITCH_ID 0 + #define NSS_DP_SW_ETHTYPE_PID 0 /* PPE ethtype profile ID for slow protocols */ +@@ -521,7 +523,76 @@ static struct notifier_block *nss_dp_sw_ + + #else + +-static struct notifier_block *nss_dp_sw_ev_nb; ++/* ++ * nss_dp_switchdev_fdb_del_event ++ * ++ * Used for EDMA v1 to remove old MAC in order to preventing having ++ * duplicate MAC entries in FDB thus and avoid roaming issues. ++ */ ++ ++static int nss_dp_switchdev_fdb_del_event(struct net_device *netdev, ++ struct switchdev_notifier_fdb_info *fdb_info) ++{ ++ struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(netdev); ++ fal_fdb_entry_t entry; ++ a_uint32_t vsi_id; ++ sw_error_t rv; ++ ++ netdev_dbg(netdev, "FDB DEL %pM port %d\n", fdb_info->addr, dp_priv->macid); ++ ++ rv = ppe_port_vsi_get(NSS_DP_SWITCH_ID, dp_priv->macid, &vsi_id); ++ if (rv) { ++ netdev_err(netdev, "cannot get VSI ID for port %d\n", dp_priv->macid); ++ return notifier_from_errno(rv); ++ } ++ ++ memset(&entry, 0, sizeof(entry)); ++ memcpy(&entry.addr, fdb_info->addr, ETH_ALEN); ++ entry.fid = vsi_id; ++ ++ rv = fal_fdb_entry_del_bymac(NSS_DP_SWITCH_ID, &entry); ++ if (rv) { ++ netdev_err(netdev, "FDB entry delete failed with MAC %pM and fid %d\n", ++ &entry.addr, entry.fid); ++ return notifier_from_errno(rv); ++ } ++ ++ return notifier_from_errno(rv); ++} ++ ++/* ++ * nss_dp_switchdev_event_nb ++ * ++ * Non blocking switchdev event for netdevice. ++ * Used for EDMA v1 to remove old MAC and avoid roaming issues. ++ */ ++static int nss_dp_switchdev_event_nb(struct notifier_block *unused, ++ unsigned long event, void *ptr) ++{ ++ struct net_device *dev = switchdev_notifier_info_to_dev(ptr); ++ ++ /* ++ * Handle switchdev event only for physical devices ++ */ ++ if (!nss_dp_is_phy_dev(dev)) { ++ return NOTIFY_DONE; ++ } ++ ++ switch (event) { ++ case SWITCHDEV_FDB_DEL_TO_DEVICE: ++ return nss_dp_switchdev_fdb_del_event(dev, ptr); ++ default: ++ netdev_dbg(dev, "Switchdev event %lu is not supported\n", event); ++ } ++ ++ return NOTIFY_DONE; ++} ++ ++static struct notifier_block nss_dp_switchdev_notifier_nb = { ++ .notifier_call = nss_dp_switchdev_event_nb, ++}; ++ ++static struct notifier_block *nss_dp_sw_ev_nb = &nss_dp_switchdev_notifier_nb; + + /* + * nss_dp_bridge_attr_set() diff --git a/package/kernel/qca-ssdk/Makefile b/package/kernel/qca-ssdk/Makefile new file mode 100644 index 00000000000..f1fb09c52a2 --- /dev/null +++ b/package/kernel/qca-ssdk/Makefile @@ -0,0 +1,90 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=qca-ssdk +PKG_RELEASE:=5 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/qca-ssdk.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2023-10-04 +PKG_SOURCE_VERSION:=23a5aa4a4d5834da7a07efb58baebfbee91786b0 +PKG_MIRROR_HASH:=9d169ce924a46a4e530031061d3183b92f23c7f46b3106f0b9ba3587846a73ee + +PKG_FLAGS:=nonshared +PKG_BUILD_FLAGS:=no-lto + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/qca-ssdk + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Devices + TITLE:=Qualcom SSDK switch driver + DEPENDS:=@(TARGET_qualcommax) + FILES:=$(PKG_BUILD_DIR)/build/bin/qca-ssdk.ko + AUTOLOAD:=$(call AutoLoad,30,qca-ssdk) +endef + +define KernelPackage/qca-ssdk/Description + Driver for Qualcomm Atheros switches. +endef + +GCC_VERSION=$(shell echo "$(CONFIG_GCC_VERSION)" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') + +LNX_CONFIG_OPTS = LNX_MAKEOPTS='$(KERNEL_MAKEOPTS)' MODULE_TYPE=KSLIB modules + +MAKE_FLAGS+= \ + TARGET_NAME=$(CONFIG_TARGET_NAME) \ + TOOL_PATH=$(firstword $(TOOLCHAIN_BIN_DIRS)) \ + SYS_PATH=$(LINUX_DIR) \ + TOOLPREFIX=$(TARGET_CROSS) \ + KVER=$(LINUX_VERSION) \ + ARCH=$(LINUX_KARCH) \ + TARGET_SUFFIX=$(CONFIG_TARGET_SUFFIX) \ + GCC_VERSION=$(GCC_VERSION) \ + EXTRA_CFLAGS=-fno-stack-protector -I$(STAGING_DIR)/usr/include \ + SoC=$(CONFIG_TARGET_SUBTARGET) \ + PTP_FEATURE=disable SWCONFIG_FEATURE=disable \ + ISISC_ENABLE=disable IN_QCA803X_PHY=FALSE \ + IN_QCA808X_PHY=FALSE IN_MALIBU_PHY=FALSE \ + $(LNX_CONFIG_OPTS) + +ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq807x") + MAKE_FLAGS+= CHIP_TYPE=HPPE +endif + +ifeq ($(CONFIG_TARGET_SUBTARGET), "ipq60xx") + MAKE_FLAGS+= CHIP_TYPE=CPPE +endif + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk/api + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk/ref + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk/fal + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk/sal + $(INSTALL_DIR) $(1)/usr/include/qca-ssdk/init + $(CP) -rf $(PKG_BUILD_DIR)/include/api/sw_ioctl.h $(1)/usr/include/qca-ssdk/api + if [ -f $(PKG_BUILD_DIR)/include/ref/ref_vsi.h ]; then \ + $(CP) -rf $(PKG_BUILD_DIR)/include/ref/ref_vsi.h $(1)/usr/include/qca-ssdk/ref/; \ + fi + if [ -f $(PKG_BUILD_DIR)/include/ref/ref_fdb.h ]; then \ + $(CP) -rf $(PKG_BUILD_DIR)/include/ref/ref_fdb.h $(1)/usr/include/qca-ssdk/ref/; \ + fi + if [ -f $(PKG_BUILD_DIR)/include/ref/ref_port_ctrl.h ]; then \ + $(CP) -rf $(PKG_BUILD_DIR)/include/ref/ref_port_ctrl.h $(1)/usr/include/qca-ssdk/ref/; \ + fi + if [ -f $(PKG_BUILD_DIR)/include/init/ssdk_init.h ]; then \ + $(CP) -rf $(PKG_BUILD_DIR)/include/init/ssdk_init.h $(1)/usr/include/qca-ssdk/init/; \ + fi + if [ -f $(PKG_BUILD_DIR)/include/init/ssdk_netlink.h ]; then \ + $(CP) -rf $(PKG_BUILD_DIR)/include/init/ssdk_netlink.h $(1)/usr/include/qca-ssdk/init/; \ + fi + $(CP) -rf $(PKG_BUILD_DIR)/include/fal $(1)/usr/include/qca-ssdk + $(CP) -rf $(PKG_BUILD_DIR)/include/common/*.h $(1)/usr/include/qca-ssdk + $(CP) -rf $(PKG_BUILD_DIR)/include/sal/os/linux/*.h $(1)/usr/include/qca-ssdk + $(CP) -rf $(PKG_BUILD_DIR)/include/sal/os/*.h $(1)/usr/include/qca-ssdk + +endef + +$(eval $(call KernelPackage,qca-ssdk)) diff --git a/package/kernel/qca-ssdk/patches/0003-Revert-qca-ssdk-enable-invoking-fdb-del-function-for.patch b/package/kernel/qca-ssdk/patches/0003-Revert-qca-ssdk-enable-invoking-fdb-del-function-for.patch new file mode 100644 index 00000000000..e69edbd3a31 --- /dev/null +++ b/package/kernel/qca-ssdk/patches/0003-Revert-qca-ssdk-enable-invoking-fdb-del-function-for.patch @@ -0,0 +1,30 @@ +From 73c0992a36bc13e9bb373f98ba246dfc1e29a393 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Tue, 7 Nov 2023 14:21:43 +0100 +Subject: [PATCH 3/3] Revert "[qca-ssdk]: enable invoking fdb del function for + kernel6.1" + +This reverts commit a86765ee6a87145f64344f4872cfe8c5e629dd62. + +Upstream kernel does not have this call present at all, we currently +also dont use it, so revert the commit enabling it. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + src/ref/ref_acl.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/src/ref/ref_acl.c ++++ b/src/ref/ref_acl.c +@@ -229,7 +229,11 @@ _ref_acl_mac_entry_create_rule(a_uint32_ + eth_dev = dev_get_by_name(&init_net, entry->ifname); + if (eth_dev) + { ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) ++ // TODO: replace with corresponding ver ++#else + br_fdb_delete_by_netdev(eth_dev, entry->src_mac.uc, 0); ++#endif + dev_put(eth_dev); + } + } diff --git a/package/kernel/qca-ssdk/patches/101-hsl_phy-add-support-for-detection-PSGMII-PHY-mode.patch b/package/kernel/qca-ssdk/patches/101-hsl_phy-add-support-for-detection-PSGMII-PHY-mode.patch new file mode 100644 index 00000000000..c27902c4ce1 --- /dev/null +++ b/package/kernel/qca-ssdk/patches/101-hsl_phy-add-support-for-detection-PSGMII-PHY-mode.patch @@ -0,0 +1,25 @@ +From e3763fd77e41b2f2495672c6a5898d69892fbf9f Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Wed, 15 Nov 2023 00:57:41 +0100 +Subject: [PATCH] hsl_phy: add support for detection PSGMII PHY mode + +Add support for detection of PSGMII PHY mode to correctly detect qca807x +PHY upstream driver. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + src/hsl/phy/hsl_phy.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/src/hsl/phy/hsl_phy.c ++++ b/src/hsl/phy/hsl_phy.c +@@ -1335,6 +1335,9 @@ hsl_port_phydev_interface_mode_status_ge + case PHY_INTERFACE_MODE_10GKR: + *interface_mode_status = PORT_10GBASE_R; + break; ++ case PHY_INTERFACE_MODE_PSGMII: ++ *interface_mode_status = PHY_PSGMII_BASET; ++ break; + case PHY_INTERFACE_MODE_QSGMII: + *interface_mode_status = PORT_QSGMII; + break; diff --git a/package/kernel/rtc-rv5c386a/Makefile b/package/kernel/rtc-rv5c386a/Makefile index 0cca78548a2..7c18942ffec 100644 --- a/package/kernel/rtc-rv5c386a/Makefile +++ b/package/kernel/rtc-rv5c386a/Makefile @@ -22,8 +22,7 @@ define KernelPackage/rtc-rv5c386a endef define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ + $(KERNEL_MAKE) \ M="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(BUILDFLAGS)" \ modules diff --git a/package/kernel/rtl8812au-ct/Makefile b/package/kernel/rtl8812au-ct/Makefile index fa2cd295ab6..b0440a68589 100644 --- a/package/kernel/rtl8812au-ct/Makefile +++ b/package/kernel/rtl8812au-ct/Makefile @@ -7,10 +7,10 @@ PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/greearb/rtl8812AU_8821AU_linux.git -PKG_MIRROR_HASH:=aee819df4ba83251b59bd1d4f412287b27105e5de9284bb09579f0e1a1538328 +PKG_MIRROR_HASH:=748f5c58aa3f391222c0c43db35b9ff4c30c9c987ca052a5a3cdf36193e5821b PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2020-12-07 -PKG_SOURCE_VERSION:=1e9689c89fa627d2d764ba0e8359fd444fe8458f +PKG_SOURCE_DATE:=2022-10-26 +PKG_SOURCE_VERSION:=9b2b203a217e1320602a0eb07c338a1bfca0f5a6 PKG_MAINTAINER:=Ben Greear <greearb@candelatech.com> PKG_BUILD_PARALLEL:=1 @@ -24,7 +24,7 @@ include $(INCLUDE_DIR)/package.mk define KernelPackage/rtl8812au-ct SUBMENU:=Wireless Drivers TITLE:=Driver for Realtek 8812 AU devices comfast 912-ac, etc - DEPENDS:=+kmod-cfg80211 +kmod-usb-core +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT + DEPENDS:=+kmod-cfg80211 +kmod-usb-core +@DRIVER_11AC_SUPPORT FILES:=\ $(PKG_BUILD_DIR)/rtl8812au.ko AUTOLOAD:=$(call AutoProbe,rtl8812au) @@ -39,13 +39,14 @@ NOSTDINC_FLAGS := \ -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \ -I$(STAGING_DIR)/usr/include/mac80211 \ -I$(STAGING_DIR)/usr/include/mac80211/uapi \ - -include backport/backport.h + -include backport/backport.h \ + -Wno-error=address \ + -Wno-error=stringop-overread NOSTDINC_FLAGS+=-DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -DBUILD_OPENWRT define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ + +$(KERNEL_MAKE) $(PKG_JOBS) \ M="$(PKG_BUILD_DIR)" \ NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ modules diff --git a/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch b/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch index 67ebb82b387..f84adebe0ad 100644 --- a/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch +++ b/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch @@ -1,6 +1,6 @@ --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c -@@ -5177,6 +5177,15 @@ exit: +@@ -5196,6 +5196,15 @@ exit: return ret; } @@ -16,7 +16,7 @@ #if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy, struct net_device *ndev, -@@ -5990,7 +5999,10 @@ static struct cfg80211_ops rtw_cfg80211_ +@@ -6009,7 +6018,10 @@ static struct cfg80211_ops rtw_cfg80211_ .cancel_remain_on_channel = cfg80211_rtw_cancel_remain_on_channel, #endif diff --git a/package/kernel/rtl8812au-ct/patches/004-remove-extern-inline.patch b/package/kernel/rtl8812au-ct/patches/004-remove-extern-inline.patch new file mode 100644 index 00000000000..871fe106364 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/004-remove-extern-inline.patch @@ -0,0 +1,24 @@ +--- a/include/ieee80211.h ++++ b/include/ieee80211.h +@@ -1313,18 +1313,18 @@ enum ieee80211_state { + (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ + (((Addr[5]) & 0xff) == 0xff)) + #else +-extern __inline int is_multicast_mac_addr(const u8 *addr) ++__inline static int is_multicast_mac_addr(const u8 *addr) + { + return ((addr[0] != 0xff) && (0x01 & addr[0])); + } + +-extern __inline int is_broadcast_mac_addr(const u8 *addr) ++__inline static int is_broadcast_mac_addr(const u8 *addr) + { + return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ + (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); + } + +-extern __inline int is_zero_mac_addr(const u8 *addr) ++__inline static int is_zero_mac_addr(const u8 *addr) + { + return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ + (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); diff --git a/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch b/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch new file mode 100644 index 00000000000..c645c1e8e39 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch @@ -0,0 +1,72 @@ +From dc4024894c9deefc56f8dd6b2d2822b277f268a5 Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Sun, 30 Jul 2023 11:18:48 +0200 +Subject: [PATCH 2/5] treewide: fix always TRUE condition warning + +Fix always TRUE condition warning an drop redundant check. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +--- + core/rtw_sta_mgt.c | 3 +-- + hal/OUTSRC/phydm_debug.c | 16 ++++++---------- + os_dep/linux/ioctl_cfg80211.c | 3 +-- + 3 files changed, 8 insertions(+), 14 deletions(-) + +--- a/core/rtw_sta_mgt.c ++++ b/core/rtw_sta_mgt.c +@@ -207,8 +207,7 @@ void rtw_mfree_stainfo(struct sta_info * + { + _func_enter_; + +- if(&psta->lock != NULL) +- _rtw_spinlock_free(&psta->lock); ++ _rtw_spinlock_free(&psta->lock); + + _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); + _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); +--- a/hal/OUTSRC/phydm_debug.c ++++ b/hal/OUTSRC/phydm_debug.c +@@ -870,12 +870,10 @@ phydm_cmd_parser( + case PHYDM_RA: + + for(i=0; i<5; i++) { +- if(input[i+1]) { +- PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]); ++ PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]); + +- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); +- input_idx++; +- } ++ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); ++ input_idx++; + } + + if(input_idx>=1) { +@@ -891,12 +889,10 @@ phydm_cmd_parser( + case PHYDM_PATHDIV: + + for(i=0; i<5; i++) { +- if(input[i+1]) { +- PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]); ++ PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]); + +- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i])); +- input_idx++; +- } ++ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i])); ++ input_idx++; + } + + if(input_idx>=1) { +--- a/os_dep/linux/ioctl_cfg80211.c ++++ b/os_dep/linux/ioctl_cfg80211.c +@@ -2185,8 +2185,7 @@ static int cfg80211_rtw_scan(struct wiph + + #ifdef CONFIG_P2P + if( pwdinfo->driver_interface == DRIVER_CFG80211 ) { +- if(ssids->ssid != NULL +- && _rtw_memcmp(ssids->ssid, "DIRECT-", 7) ++ if(_rtw_memcmp(ssids->ssid, "DIRECT-", 7) + && rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL) + ) { + if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { diff --git a/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch b/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch new file mode 100644 index 00000000000..bb644a9ace4 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch @@ -0,0 +1,86 @@ +From 30fc9d96fa2ce16209306237e677d3d3cbb12685 Mon Sep 17 00:00:00 2001 +From: John Thomson <git@johnthomson.fastmail.com.au> +Date: Sun, 28 May 2023 13:26:46 +1000 +Subject: [PATCH] Revert "fix kernel 6.1 80211 link_id" + +This reverts commit a027da58e8d8e95827f97222ca321cd0b2d377dd. +--- + os_dep/linux/ioctl_cfg80211.c | 29 +++++------------------------ + 1 file changed, 5 insertions(+), 24 deletions(-) + +--- a/os_dep/linux/ioctl_cfg80211.c ++++ b/os_dep/linux/ioctl_cfg80211.c +@@ -797,14 +797,9 @@ check_bss: + #endif + + DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) +- roam_info.links[0].channel = notify_channel; +- roam_info.links[0].bssid = cur_network->network.MacAddress; +-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + roam_info.channel = notify_channel; + roam_info.bssid = cur_network->network.MacAddress; +-#endif +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2; + roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2; + roam_info.resp_ie = pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6; +@@ -1393,9 +1388,7 @@ exit: + } + + static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1535,9 +1528,7 @@ addkey_end: + } + + static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1570,9 +1561,7 @@ static int cfg80211_rtw_get_key(struct w + } + + static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr) +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr) + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr) +@@ -1592,11 +1581,7 @@ static int cfg80211_rtw_del_key(struct w + } + + static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, +- struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, +-#endif +- u8 key_index ++ struct net_device *ndev, u8 key_index + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) + , bool unicast, bool multicast + #endif +@@ -4033,11 +4018,7 @@ static int cfg80211_rtw_change_beacon(st + return ret; + } + +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)) +-static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) +-#else + static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +-#endif + { + DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); + return 0; diff --git a/package/kernel/rtl8812au-ct/patches/100-api_update.patch b/package/kernel/rtl8812au-ct/patches/100-api_update.patch new file mode 100644 index 00000000000..e7ca4b05f34 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/100-api_update.patch @@ -0,0 +1,56 @@ +--- a/os_dep/linux/ioctl_cfg80211.c ++++ b/os_dep/linux/ioctl_cfg80211.c +@@ -798,8 +798,8 @@ check_bss: + + DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) +- roam_info.channel = notify_channel; +- roam_info.bssid = cur_network->network.MacAddress; ++ roam_info.links[0].channel = notify_channel; ++ roam_info.links[0].bssid = cur_network->network.MacAddress; + roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2; + roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2; + roam_info.resp_ie = pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6; +@@ -1389,6 +1389,7 @@ exit: + + static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++ int link_id, + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1529,6 +1530,7 @@ addkey_end: + + static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++ int link_id, + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1562,6 +1564,7 @@ static int cfg80211_rtw_get_key(struct w + + static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++ int link_id, + u8 key_index, bool pairwise, const u8 *mac_addr) + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr) +@@ -1581,7 +1584,7 @@ static int cfg80211_rtw_del_key(struct w + } + + static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, +- struct net_device *ndev, u8 key_index ++ struct net_device *ndev, int link_id, u8 key_index + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) + , bool unicast, bool multicast + #endif +@@ -4018,7 +4021,8 @@ static int cfg80211_rtw_change_beacon(st + return ret; + } + +-static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) ++static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, ++ unsigned int link_id) + { + DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); + return 0; diff --git a/package/kernel/ubnt-ledbar/Makefile b/package/kernel/ubnt-ledbar/Makefile new file mode 100644 index 00000000000..69236ffbb33 --- /dev/null +++ b/package/kernel/ubnt-ledbar/Makefile @@ -0,0 +1,34 @@ +# +# Copyright (C) 2008-2010 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:=ubnt-ledbar +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/leds-ubnt-ledbar + SUBMENU:=LED modules + TITLE:=Ubiquiti UniFi 6 LR LED support + FILES:= \ + $(PKG_BUILD_DIR)/leds-ubnt-ledbar.ko + AUTOLOAD:=$(call AutoProbe,leds-ubnt-ledbar,1) + DEPENDS:=@TARGET_mediatek_mt7622||TARGET_ramips_mt7621 +kmod-i2c-core +endef + +define KernelPackage/leds-ubnt-ledbar/description + LED support for some Ubiquiti UniFi access points. +endef + +define Build/Compile + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules +endef + +$(eval $(call KernelPackage,leds-ubnt-ledbar)) diff --git a/package/kernel/ubnt-ledbar/src/Makefile b/package/kernel/ubnt-ledbar/src/Makefile new file mode 100644 index 00000000000..a81d9377c0a --- /dev/null +++ b/package/kernel/ubnt-ledbar/src/Makefile @@ -0,0 +1 @@ +obj-m := leds-ubnt-ledbar.o diff --git a/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c b/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c new file mode 100644 index 00000000000..ee9d34601c6 --- /dev/null +++ b/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c @@ -0,0 +1,262 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/leds.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/gpio/consumer.h> +#include <linux/version.h> + +/** + * Driver for the Ubiquiti RGB LED controller (LEDBAR). + * This Controller is based on a Holtek HT32F52241 and connected + * via I2C. + * + * - The Controller needs an enable signal set to high when + * performing a transaction. On the U6-LR, this is located + * at Pin 18 (R6902) + * + * - The Pin is also printed when calling the "usetled" function + * contained in the ubntapp bootloader application. + */ + +#define UBNT_LEDBAR_MAX_BRIGHTNESS 0xff + +#define UBNT_LEDBAR_TRANSACTION_LENGTH 8 +#define UBNT_LEDBAR_TRANSACTION_SUCCESS (char) 0xaa + +#define UBNT_LEDBAR_TRANSACTION_BLUE_IDX 2 +#define UBNT_LEDBAR_TRANSACTION_GREEN_IDX 3 +#define UBNT_LEDBAR_TRANSACTION_RED_IDX 4 +#define UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX 6 + +struct ubnt_ledbar { + struct mutex lock; + u32 led_count; + struct i2c_client *client; + struct led_classdev led_red; + struct led_classdev led_green; + struct led_classdev led_blue; + struct gpio_desc *enable_gpio; + struct gpio_desc *reset_gpio; +}; + +static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, + const char *transaction, int len, + char *result, int result_len) +{ + int i; + + for (i = 0; i < len; i++) + i2c_smbus_write_byte(ledbar->client, transaction[i]); + + for (i = 0; i < result_len; i++) + result[i] = i2c_smbus_read_byte(ledbar->client); +} + +static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) +{ + char setup_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x11}; + char led_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + char i2c_response; + int ret = 0; + + mutex_lock(&ledbar->lock); + + led_msg[UBNT_LEDBAR_TRANSACTION_BLUE_IDX] = ledbar->led_blue.brightness; + led_msg[UBNT_LEDBAR_TRANSACTION_GREEN_IDX] = ledbar->led_green.brightness; + led_msg[UBNT_LEDBAR_TRANSACTION_RED_IDX] = ledbar->led_red.brightness; + led_msg[UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX] = ledbar->led_count; + + gpiod_set_value(ledbar->enable_gpio, 1); + + msleep(10); + + ubnt_ledbar_perform_transaction(ledbar, setup_msg, sizeof(setup_msg), &i2c_response, sizeof(i2c_response)); + if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { + dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response); + ret = -EINVAL; + goto out_gpio; + } + + ubnt_ledbar_perform_transaction(ledbar, led_msg, sizeof(led_msg), &i2c_response, sizeof(i2c_response)); + if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { + dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response); + ret = -EINVAL; + goto out_gpio; + } + + msleep(10); +out_gpio: + gpiod_set_value(ledbar->enable_gpio, 0); + + mutex_unlock(&ledbar->lock); + + return ret; +} + +static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar) +{ + static const char init_msg[16] = {0x02, 0x81, 0xfd, 0x7e, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + char init_response[4]; + + if (!ledbar->reset_gpio) + return; + + mutex_lock(&ledbar->lock); + + gpiod_set_value(ledbar->reset_gpio, 1); + msleep(10); + gpiod_set_value(ledbar->reset_gpio, 0); + + msleep(10); + + gpiod_set_value(ledbar->enable_gpio, 1); + msleep(10); + ubnt_ledbar_perform_transaction(ledbar, init_msg, sizeof(init_msg), init_response, sizeof(init_response)); + msleep(10); + gpiod_set_value(ledbar->enable_gpio, 0); + + mutex_unlock(&ledbar->lock); +} + +#define UBNT_LEDBAR_CONTROL_RGBS(name) \ +static int ubnt_ledbar_set_##name##_brightness(struct led_classdev *led_cdev,\ + enum led_brightness value) \ +{ \ + struct ubnt_ledbar *ledbar = \ + container_of(led_cdev, struct ubnt_ledbar, led_##name); \ + int ret; \ + led_cdev->brightness = value; \ + ret = ubnt_ledbar_apply_state(ledbar); \ + return ret; \ +} + +UBNT_LEDBAR_CONTROL_RGBS(red); +UBNT_LEDBAR_CONTROL_RGBS(green); +UBNT_LEDBAR_CONTROL_RGBS(blue); + + +static int ubnt_ledbar_init_led(struct device_node *np, struct ubnt_ledbar *ledbar, + struct led_classdev *led_cdev) +{ + struct led_init_data init_data = {}; + int ret; + + if (!np) + return 0; + + init_data.fwnode = of_fwnode_handle(np); + + led_cdev->max_brightness = UBNT_LEDBAR_MAX_BRIGHTNESS; + + ret = devm_led_classdev_register_ext(&ledbar->client->dev, led_cdev, + &init_data); + if (ret) + dev_err(&ledbar->client->dev, "led register err: %d\n", ret); + + return ret; +} + + +static int ubnt_ledbar_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device_node *np = client->dev.of_node; + struct ubnt_ledbar *ledbar; + int ret; + + ledbar = devm_kzalloc(&client->dev, sizeof(*ledbar), GFP_KERNEL); + if (!ledbar) + return -ENOMEM; + + ledbar->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); + + if (IS_ERR(ledbar->enable_gpio)) { + ret = PTR_ERR(ledbar->enable_gpio); + dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret); + return ret; + } + + ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); + + if (IS_ERR(ledbar->reset_gpio)) { + ret = PTR_ERR(ledbar->reset_gpio); + dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret); + return ret; + } + + ledbar->led_count = 1; + of_property_read_u32(np, "led-count", &ledbar->led_count); + + ledbar->client = client; + + mutex_init(&ledbar->lock); + + i2c_set_clientdata(client, ledbar); + + // Reset and initialize the MCU + ubnt_ledbar_reset(ledbar); + + ledbar->led_red.brightness_set_blocking = ubnt_ledbar_set_red_brightness; + ubnt_ledbar_init_led(of_get_child_by_name(np, "red"), ledbar, &ledbar->led_red); + + ledbar->led_green.brightness_set_blocking = ubnt_ledbar_set_green_brightness; + ubnt_ledbar_init_led(of_get_child_by_name(np, "green"), ledbar, &ledbar->led_green); + + ledbar->led_blue.brightness_set_blocking = ubnt_ledbar_set_blue_brightness; + ubnt_ledbar_init_led(of_get_child_by_name(np, "blue"), ledbar, &ledbar->led_blue); + + return ubnt_ledbar_apply_state(ledbar); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) +static int ubnt_ledbar_remove(struct i2c_client *client) +#else +static void ubnt_ledbar_remove(struct i2c_client *client) +#endif +{ + struct ubnt_ledbar *ledbar = i2c_get_clientdata(client); + + mutex_destroy(&ledbar->lock); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) + return 0; +#endif +} + +static const struct i2c_device_id ubnt_ledbar_id[] = { + { "ubnt-ledbar", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ubnt_ledbar_id); + +static const struct of_device_id of_ubnt_ledbar_match[] = { + { .compatible = "ubnt,ledbar", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_ubnt_ledbar_match); + +static struct i2c_driver ubnt_ledbar_driver = { + .driver = { + .name = "ubnt-ledbar", + .of_match_table = of_ubnt_ledbar_match, + }, + .probe = ubnt_ledbar_probe, + .remove = ubnt_ledbar_remove, + .id_table = ubnt_ledbar_id, +}; +module_i2c_driver(ubnt_ledbar_driver); + +MODULE_DESCRIPTION("Ubiquiti LEDBAR driver"); +MODULE_AUTHOR("David Bauer <mail@david-bauer.net>"); +MODULE_LICENSE("GPL v2"); diff --git a/package/kernel/ubootenv-nvram/Makefile b/package/kernel/ubootenv-nvram/Makefile new file mode 100644 index 00000000000..0574ea61d7d --- /dev/null +++ b/package/kernel/ubootenv-nvram/Makefile @@ -0,0 +1,30 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=ubootenv-nvram +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ubootenv-nvram + SUBMENU:=Other modules + TITLE:=NVRAM environment for uboot-envtools + FILES:=$(PKG_BUILD_DIR)/ubootenv-nvram.ko + AUTOLOAD:=$(call AutoLoad,30,ubootenv-nvram,1) + KCONFIG:= +endef + +define KernelPackage/ubootenv-nvram/description + Support vendor modified U-Boot storing the environment + in RAM. This driver exports the environment memory + region as a misc device named "ubootenv", pretending + it is a NOR mtd device to let existing userspace tools + work without modifications. +endef + +define Build/Compile + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules +endef + +$(eval $(call KernelPackage,ubootenv-nvram)) diff --git a/package/kernel/ubootenv-nvram/src/Makefile b/package/kernel/ubootenv-nvram/src/Makefile new file mode 100644 index 00000000000..469cb801f3b --- /dev/null +++ b/package/kernel/ubootenv-nvram/src/Makefile @@ -0,0 +1 @@ +obj-m += ubootenv-nvram.o diff --git a/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c b/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c new file mode 100644 index 00000000000..f6244142167 --- /dev/null +++ b/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2022 Bjørn Mork <bjorn@mork.no> + */ + +#include <linux/fs.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/miscdevice.h> +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/mtd/mtd.h> +#include <linux/of.h> +#include <linux/of_reserved_mem.h> +#include <linux/platform_device.h> + +#define NAME "ubootenv" + +struct ubootenv_drvdata { + void *env; + struct reserved_mem *rmem; + struct miscdevice misc; +}; + +static inline struct ubootenv_drvdata *to_ubootenv_drvdata(struct file *file) +{ + return container_of(file->private_data, struct ubootenv_drvdata, misc); +} + +static ssize_t ubootenv_write(struct file *file, const char __user *buffer, size_t count, + loff_t *ppos) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + if (!data->env) + return -EIO; + return simple_write_to_buffer(data->env, data->rmem->size, ppos, buffer, count); +} + +static ssize_t ubootenv_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + if (!data->env) + return 0; + return simple_read_from_buffer(buffer, count, ppos, data->env, data->rmem->size); +} + +static loff_t ubootenv_llseek(struct file *file, loff_t off, int whence) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + return fixed_size_llseek(file, off, whence, data->rmem->size); +} + +/* Faking the minimal mtd ioctl subset required by the fw_env.c */ +static long ubootenv_ioctl(struct file *file, u_int cmd, u_long arg) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + void __user *argp = (void __user *)arg; + struct mtd_info_user info = { + .type = MTD_NORFLASH, + .size = data->rmem->size, + }; + + switch (cmd) { + case MEMISLOCKED: + case MEMERASE: + break; + case MEMGETINFO: + if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) + return -EFAULT; + break; + default: + return -ENOTTY; + } + return 0; +} + +static const struct file_operations ubootenv_fops = { + .owner = THIS_MODULE, + .read = ubootenv_read, + .write = ubootenv_write, + .llseek = ubootenv_llseek, + .unlocked_ioctl = ubootenv_ioctl, +}; + +/* We can only map a single reserved-memory range */ +static struct ubootenv_drvdata drvdata = { + .misc = { + .fops = &ubootenv_fops, + .minor = MISC_DYNAMIC_MINOR, + .name = NAME, + }, +}; + +const struct of_device_id of_ubootenv_match[] = { + { .compatible = "ubootenv" }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_ubootenv_match); + +static int ubootenv_probe(struct platform_device *pdev) +{ + struct ubootenv_drvdata *data = &drvdata; + struct device *dev = &pdev->dev; + struct device_node *np; + + /* enforce single instance */ + if (data->env) + return -EINVAL; + + np = of_parse_phandle(dev->of_node, "memory-region", 0); + if (!np) + return -ENODEV; + + data->rmem = of_reserved_mem_lookup(np); + of_node_put(np); + if (!data->rmem) + return -ENODEV; + + if (!data->rmem->size || (data->rmem->size > ULONG_MAX)) + return -EINVAL; + + if (!PAGE_ALIGNED(data->rmem->base) || !PAGE_ALIGNED(data->rmem->size)) + return -EINVAL; + + data->env = devm_memremap(&pdev->dev, data->rmem->base, data->rmem->size, MEMREMAP_WB); + platform_set_drvdata(pdev, data); + + data->misc.parent = &pdev->dev; + return misc_register(&data->misc); +} + +static int ubootenv_remove(struct platform_device *pdev) +{ + struct ubootenv_drvdata *data = platform_get_drvdata(pdev); + + data->env = NULL; + misc_deregister(&data->misc); + return 0; +} + +static struct platform_driver ubootenv_driver = { + .probe = ubootenv_probe, + .remove = ubootenv_remove, + .driver = { + .name = NAME, + .owner = THIS_MODULE, + .of_match_table = of_ubootenv_match, + }, +}; + +module_platform_driver(ubootenv_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>"); +MODULE_DESCRIPTION("Access u-boot environment in RAM"); |
