diff --git a/include/kernel.mk b/include/kernel.mk index 01b737f132..ffc9ea5260 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -101,7 +101,7 @@ endif KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS) KERNEL_MAKE_FLAGS = \ - KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \ + KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))" \ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ CROSS_COMPILE="$(KERNEL_CROSS)" \ ARCH="$(LINUX_KARCH)" \ diff --git a/include/netfilter.mk b/include/netfilter.mk index e49725fd31..50a002be65 100644 --- a/include/netfilter.mk +++ b/include/netfilter.mk @@ -361,6 +361,8 @@ $(eval $(if $(NF_KMOD),$(call nf_add,NFT_TPROXY,CONFIG_NFT_TPROXY, $(P_XT)nft_tp $(eval $(if $(NF_KMOD),$(call nf_add,NFT_COMPAT,CONFIG_NFT_COMPAT, $(P_XT)nft_compat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_XFRM,CONFIG_NFT_XFRM, $(P_XT)nft_xfrm),)) + # userland only IPT_BUILTIN += $(NF_IPT-y) $(NF_IPT-m) IPT_BUILTIN += $(IPT_CORE-y) $(IPT_CORE-m) diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index f90de71d40..9ab2e8bd4d 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -40,35 +40,39 @@ fs_wait_for_key () { rm -f $keypress_wait } & - [ "$pi_preinit_no_failsafe" != "y" ] && echo "Press the [$1] key and hit [enter] $2" - echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level" - # if we're on the console we wait for input - { - while [ -r $keypress_wait ]; do - timer="$(cat $keypress_sec)" + local consoles="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | sed -e 's/^console=//' -e 's/,.*//')" + [ -n "$consoles" ] || consoles=console + for console in $consoles; do + [ -c "/dev/$console" ] || continue + [ "$pi_preinit_no_failsafe" != "y" ] && echo "Press the [$1] key and hit [enter] $2" > "/dev/$console" + echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level" > "/dev/$console" + { + while [ -r $keypress_wait ]; do + timer="$(cat $keypress_sec)" - [ -n "$timer" ] || timer=1 - timer="${timer%%\ *}" - [ $timer -ge 1 ] || timer=1 - do_keypress="" - { - read -t "$timer" do_keypress - case "$do_keypress" in - $1) - echo "true" >$keypress_true - ;; - 1 | 2 | 3 | 4) - echo "$do_keypress" >/tmp/debug_level - ;; - *) - continue; - ;; - esac - lock -u $keypress_wait - rm -f $keypress_wait - } - done - } + [ -n "$timer" ] || timer=1 + timer="${timer%%\ *}" + [ $timer -ge 1 ] || timer=1 + do_keypress="" + { + read -t "$timer" do_keypress < "/dev/$console" + case "$do_keypress" in + $1) + echo "true" >$keypress_true + ;; + 1 | 2 | 3 | 4) + echo "$do_keypress" >/tmp/debug_level + ;; + *) + continue; + ;; + esac + lock -u $keypress_wait + rm -f $keypress_wait + } + done + } & + done lock -w $keypress_wait keypressed=1 diff --git a/package/base-files/files/lib/preinit/99_10_failsafe_login b/package/base-files/files/lib/preinit/99_10_failsafe_login index 1410c5f0db..6f4af3f28b 100644 --- a/package/base-files/files/lib/preinit/99_10_failsafe_login +++ b/package/base-files/files/lib/preinit/99_10_failsafe_login @@ -2,13 +2,14 @@ # Copyright (C) 2010 Vertical Communications failsafe_shell() { - local console="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | head -1 | sed -e 's/^console=//' -e 's/,.*//')" - [ -n "$console" ] || console=console - [ -c "/dev/$console" ] || return 0 - while true; do - ash --login <"/dev/$console" >"/dev/$console" 2>"/dev/$console" - sleep 1 - done & + local consoles="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | sed -e 's/^console=//' -e 's/,.*//')" + [ -n "$consoles" ] || consoles=console + for console in $consoles; do + [ -c "/dev/$console" ] && while true; do + ash --login <"/dev/$console" >"/dev/$console" 2>"/dev/$console" + sleep 1 + done & + done } boot_hook_add failsafe failsafe_shell diff --git a/package/base-files/files/lib/upgrade/fwtool.sh b/package/base-files/files/lib/upgrade/fwtool.sh index a45f3bbc73..8bd00a3332 100644 --- a/package/base-files/files/lib/upgrade/fwtool.sh +++ b/package/base-files/files/lib/upgrade/fwtool.sh @@ -71,6 +71,7 @@ fwtool_check_image() { # minor compat version -> sysupgrade with -n required if [ "${devicecompat#.*}" != "${imagecompat#.*}" ] && [ "$SAVE_CONFIG" = "1" ]; then + [ "$IGNORE_MINOR_COMPAT" = 1 ] && return 0 v "The device is supported, but the config is incompatible to the new image ($devicecompat->$imagecompat). Please upgrade without keeping config (sysupgrade -n)." [ -n "$compatmessage" ] && v "$compatmessage" return 1 diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 7e0a00e13b..9315091302 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -19,6 +19,7 @@ export CONF_IMAGE= export CONF_BACKUP_LIST=0 export CONF_BACKUP= export CONF_RESTORE= +export IGNORE_MINOR_COMPAT=0 export NEED_IMAGE= export HELP=0 export FORCE=0 @@ -44,6 +45,7 @@ while [ -n "$1" ]; do -F|--force) export FORCE=1;; -T|--test) export TEST=1;; -h|--help) export HELP=1; break;; + --ignore-minor-compat-version) export IGNORE_MINOR_COMPAT=1;; -*) echo "Invalid option: $1" >&2 exit 1 @@ -80,6 +82,8 @@ upgrade-option: Verify image and config .tar.gz but do not actually flash. -F | --force Flash image even if image checks fail, this is dangerous! + --ignore-minor-compat-version + Flash image even if the minor compat version is incompatible. -q less verbose -v more verbose -h | --help display this help diff --git a/package/boot/uboot-envtools/files/apm821xx b/package/boot/uboot-envtools/files/apm821xx index 690fbba332..e73aaab7a0 100644 --- a/package/boot/uboot-envtools/files/apm821xx +++ b/package/boot/uboot-envtools/files/apm821xx @@ -19,6 +19,10 @@ netgear,wndap620|\ netgear,wndap660) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000" "4" ;; +wd,mybooklive) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000" "1" + ubootenv_add_uci_config "/dev/mtd1" "0x1000" "0x1000" "0x1000" "1" + ;; esac config_load ubootenv diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 98aa426c6b..e1a4423497 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -104,6 +104,7 @@ netgear,wndr3700-v2|\ netgear,wndrmac-v1) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x10000" ;; +netgear,pgzng1|\ netgear,wndr3700-v4|\ netgear,wndr4300|\ netgear,wndr4300tn|\ diff --git a/package/boot/uboot-envtools/files/realtek b/package/boot/uboot-envtools/files/realtek index af48d27078..93cccfdc3e 100644 --- a/package/boot/uboot-envtools/files/realtek +++ b/package/boot/uboot-envtools/files/realtek @@ -9,6 +9,7 @@ board=$(board_name) case "$board" in d-link,dgs-1210-16|\ +d-link,dgs-1210-20|\ d-link,dgs-1210-28|\ d-link,dgs-1210-10p|\ zyxel,gs1900-8|\ diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index bd380702db..defae03028 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -68,7 +68,7 @@ endef define U-Boot/mt7622_ubnt_unifi-6-lr NAME:=Ubiquiti UniFi 6 LR UBOOT_CONFIG:=mt7622_ubnt_unifi-6-lr - BUILD_DEVICES:=ubnt_unifi-6-lr-ubootmod + BUILD_DEVICES:=ubnt_unifi-6-lr-v1-ubootmod ubnt_unifi-6-lr-v2-ubootmod BUILD_SUBTARGET:=mt7622 UBOOT_IMAGE:=u-boot.fip BL2_BOOTDEV:=nor diff --git a/package/boot/uboot-rockchip/Makefile b/package/boot/uboot-rockchip/Makefile index 41a0ccd971..b4a8b858ba 100644 --- a/package/boot/uboot-rockchip/Makefile +++ b/package/boot/uboot-rockchip/Makefile @@ -133,7 +133,6 @@ ifneq ($(OF_PLATDATA),) endif $(SED) 's#CONFIG_MKIMAGE_DTC_PATH=.*#CONFIG_MKIMAGE_DTC_PATH="$(PKG_BUILD_DIR)/scripts/dtc/dtc"#g' $(PKG_BUILD_DIR)/.config - echo 'CONFIG_IDENT_STRING=" OpenWrt"' >> $(PKG_BUILD_DIR)/.config endef define Build/InstallDev diff --git a/package/kernel/linux/modules/leds.mk b/package/kernel/linux/modules/leds.mk index 33b9f612ae..7b5609a84c 100644 --- a/package/kernel/linux/modules/leds.mk +++ b/package/kernel/linux/modules/leds.mk @@ -131,6 +131,25 @@ endef $(eval $(call KernelPackage,leds-apu)) +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 diff --git a/package/kernel/linux/modules/netfilter.mk b/package/kernel/linux/modules/netfilter.mk index 4ab975b53d..0172fb662c 100644 --- a/package/kernel/linux/modules/netfilter.mk +++ b/package/kernel/linux/modules/netfilter.mk @@ -1271,3 +1271,14 @@ define KernelPackage/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)) diff --git a/package/kernel/mac80211/patches/ath10k/081-01-ath10k-improve-tx-status-reporting.patch b/package/kernel/mac80211/patches/ath10k/081-01-ath10k-improve-tx-status-reporting.patch new file mode 100644 index 0000000000..c024850918 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/081-01-ath10k-improve-tx-status-reporting.patch @@ -0,0 +1,69 @@ +From 2587d5198aa5adcbd8896aae4a2404dc13d48637 Mon Sep 17 00:00:00 2001 +From: Sergey Ryazanov +Date: Wed, 18 May 2022 10:27:26 +0300 +Subject: ath10k: improve tx status reporting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We use ieee80211_tx_status() to report each completed tx frame. +Internally, this function calls sta_info_get_by_addrs(), what has a +couple of drawbacks: +1. additional station lookup causes a performance degradation; +2. mac80211 can not properly account Ethernet encapsulated frames due + to the inability to properly determine the destination (station) MAC + address since ieee80211_tx_status() assumes the frame has a 802.11 + header. + +The latter is especially destructive if we want to use hardware frames +encapsulation. + +To fix both of these issues, replace ieee80211_tx_status() with +ieee80211_tx_status_ext() call and feed it station pointer from the tx +queue associated with the transmitted frame. + +Tested-on: QCA9888 hw2.0 PCI 10.4-3.9.0.2-00131 +Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00157-QCARMSWPZ-1 + +Signed-off-by: Sergey Ryazanov +Tested-by: Oldřich Jedlička # TP-Link Archer C7 v4 & v5 (QCA9563 + QCA9880) +Tested-by: Edward Matijevic # TP-Link Archer C2600 (IPQ8064 + QCA9980 10.4.1.00030-1) +Tested-by: Edward Matijevic # QCA9377 PCI in Sta mode +Tested-by: Zhijun You # NETGEAR R7800 (QCA9984 10.4-3.9.0.2-00159) +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20220516032519.29831-2-ryazanov.s.a@gmail.com +--- + drivers/net/wireless/ath/ath10k/txrx.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath10k/txrx.c ++++ b/drivers/net/wireless/ath/ath10k/txrx.c +@@ -43,6 +43,7 @@ out: + int ath10k_txrx_tx_unref(struct ath10k_htt *htt, + const struct htt_tx_done *tx_done) + { ++ struct ieee80211_tx_status status; + struct ath10k *ar = htt->ar; + struct device *dev = ar->dev; + struct ieee80211_tx_info *info; +@@ -128,7 +129,19 @@ int ath10k_txrx_tx_unref(struct ath10k_h + info->status.is_valid_ack_signal = true; + } + +- ieee80211_tx_status(htt->ar->hw, msdu); ++ memset(&status, 0, sizeof(status)); ++ status.skb = msdu; ++ status.info = info; ++ ++ rcu_read_lock(); ++ ++ if (txq) ++ status.sta = txq->sta; ++ ++ ieee80211_tx_status_ext(htt->ar->hw, &status); ++ ++ rcu_read_unlock(); ++ + /* we do not own the msdu anymore */ + + return 0; diff --git a/package/kernel/mac80211/patches/ath10k/081-02-ath10k-turn-rawmode-into-frame-mode.patch b/package/kernel/mac80211/patches/ath10k/081-02-ath10k-turn-rawmode-into-frame-mode.patch new file mode 100644 index 0000000000..e672815522 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/081-02-ath10k-turn-rawmode-into-frame-mode.patch @@ -0,0 +1,74 @@ +From a09740548275a74b897654b3aca5af589289b57a Mon Sep 17 00:00:00 2001 +From: Sergey Ryazanov +Date: Mon, 16 May 2022 13:26:00 +0300 +Subject: ath10k: turn rawmode into frame_mode + +Turn boolean rawmode module param into integer frame_mode param that +contains value from ath10k_hw_txrx_mode enum. As earlier the default +param value is non-RAW (native Wi-Fi) encapsulation. The param name +is selected to be consistent with the similar ath11k param. + +This is a preparation step for upcoming encapsulation offloading +support. + +Signed-off-by: Sergey Ryazanov +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20220516032519.29831-4-ryazanov.s.a@gmail.com +--- + drivers/net/wireless/ath/ath10k/core.c | 11 +++++++---- + drivers/net/wireless/ath/ath10k/core.h | 1 + + 2 files changed, 8 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath10k/core.c ++++ b/drivers/net/wireless/ath/ath10k/core.c +@@ -32,9 +32,11 @@ EXPORT_SYMBOL(ath10k_debug_mask); + static unsigned int ath10k_cryptmode_param; + static bool uart_print; + static bool skip_otp; +-static bool rawmode; + static bool fw_diag_log; + ++/* frame mode values are mapped as per enum ath10k_hw_txrx_mode */ ++unsigned int ath10k_frame_mode = ATH10K_HW_TXRX_NATIVE_WIFI; ++ + unsigned long ath10k_coredump_mask = BIT(ATH10K_FW_CRASH_DUMP_REGISTERS) | + BIT(ATH10K_FW_CRASH_DUMP_CE_DATA); + +@@ -43,15 +45,16 @@ module_param_named(debug_mask, ath10k_de + module_param_named(cryptmode, ath10k_cryptmode_param, uint, 0644); + module_param(uart_print, bool, 0644); + module_param(skip_otp, bool, 0644); +-module_param(rawmode, bool, 0644); + module_param(fw_diag_log, bool, 0644); ++module_param_named(frame_mode, ath10k_frame_mode, uint, 0644); + module_param_named(coredump_mask, ath10k_coredump_mask, ulong, 0444); + + MODULE_PARM_DESC(debug_mask, "Debugging mask"); + MODULE_PARM_DESC(uart_print, "Uart target debugging"); + MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode"); + MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software"); +-MODULE_PARM_DESC(rawmode, "Use raw 802.11 frame datapath"); ++MODULE_PARM_DESC(frame_mode, ++ "Datapath frame mode (0: raw, 1: native wifi (default))"); + MODULE_PARM_DESC(coredump_mask, "Bitfield of what to include in firmware crash file"); + MODULE_PARM_DESC(fw_diag_log, "Diag based fw log debugging"); + +@@ -2487,7 +2490,7 @@ static int ath10k_core_init_firmware_fea + ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT; + ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT; + +- if (rawmode) { ++ if (ath10k_frame_mode == ATH10K_HW_TXRX_RAW) { + if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT, + fw_file->fw_features)) { + ath10k_err(ar, "rawmode = 1 requires support from firmware"); +--- a/drivers/net/wireless/ath/ath10k/core.h ++++ b/drivers/net/wireless/ath/ath10k/core.h +@@ -1311,6 +1311,7 @@ static inline bool ath10k_peer_stats_ena + return false; + } + ++extern unsigned int ath10k_frame_mode; + extern unsigned long ath10k_coredump_mask; + + void ath10k_core_napi_sync_disable(struct ath10k *ar); diff --git a/package/kernel/mac80211/patches/ath10k/081-03-ath10k-htt-tx-do-not-interpret-Eth-frames-as-WiFi.patch b/package/kernel/mac80211/patches/ath10k/081-03-ath10k-htt-tx-do-not-interpret-Eth-frames-as-WiFi.patch new file mode 100644 index 0000000000..a669c77fe2 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/081-03-ath10k-htt-tx-do-not-interpret-Eth-frames-as-WiFi.patch @@ -0,0 +1,163 @@ +From 70f119fb82af7f7417dc659faf02c91e1f853739 Mon Sep 17 00:00:00 2001 +From: Sergey Ryazanov +Date: Mon, 16 May 2022 13:26:00 +0300 +Subject: ath10k: htt_tx: do not interpret Eth frames as WiFi + +The xmit path for the Ethernet encapsulated frames become more or less +usable since d740d8fd2439 ("ath10k: unify tx mode and dispatch"). This +change reorganize the xmit path in a manageable way to properly support +various tx modes, but misses that the Ethernet encapsulated frame is a +special case. We do not have an IEEE 802.11 header at the begining of +them. But the HTT Tx handler still interprets first bytes of each frame +as an IEEE 802.11 Frame Control field. + +Than this code was copied by e62ee5c381c5 ("ath10k: Add support for +htt_data_tx_desc_64 descriptor") and a2097d6444c3 ("ath10k: htt: High +latency TX support") to another handlers. In fact the issue in the high +latency (HL) handler was introduced by 83ac260151e7 ("ath10k: add mic +bytes for pmf management packet"). + +Ethernet encapsulated frame tx mode stay unused until 75d85fd9993c +("ath10k: introduce basic tdls functionality") started using it for TDLS +frames to avoid key selection issue in some firmwares. + +Trying to interpret the begining of an Ethernet encapsulated frame as an +IEEE 802.11 header was not hurt us noticeably since we need to meet two +conditions: (1) xmit should be performed towards a TDLS peer, and (2) +the TDLS peer should have a specific OUI part of its MAC address. Looks +like that the rareness in TDLS communications of OUIs that can be +interpreted as an 802.11 management frame saves users from facing this +issue earlier. + +Improve Ethernet tx mode support in the HTT Tx handler by avoiding +interpreting its first bytes as an IEEE 802.11 header. While at it, make +the ieee80211_hdr variable local to the code block that is guarded by +!is_eth check. In this way, we clarify in which cases a frame can be +interpreted as IEEE 802.11, and saves us from similar issues in the +future. + +Credits: this change as part of xmit encapsulation offloading support +was originally made by QCA and then submitted for inclusion by John +Crispin [1]. But the whole work was not accepted due to the lack of a +part for 64-bits descriptors [2]. Zhijun You then pointed this out to me +in a reply to my initial RFC patch series. And I made this slightly +reworked version that covered all the HTT Tx handler variants. + +1. https://lore.kernel.org/all/20191216092207.31032-1-john@phrozen.org/ +2. https://patchwork.kernel.org/project/linux-wireless/patch/20191216092207.31032-1-john@phrozen.org/ + +Reported-by: Zhijun You +Signed-off-by: Vasanthakumar Thiagarajan +Signed-off-by: John Crispin +Signed-off-by: Sergey Ryazanov +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20220516032519.29831-3-ryazanov.s.a@gmail.com +--- + drivers/net/wireless/ath/ath10k/htt_tx.c | 61 ++++++++++++++++++-------------- + 1 file changed, 35 insertions(+), 26 deletions(-) + +--- a/drivers/net/wireless/ath/ath10k/htt_tx.c ++++ b/drivers/net/wireless/ath/ath10k/htt_tx.c +@@ -1295,7 +1295,6 @@ static int ath10k_htt_tx_hl(struct ath10 + struct ath10k *ar = htt->ar; + int res, data_len; + struct htt_cmd_hdr *cmd_hdr; +- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; + struct htt_data_tx_desc *tx_desc; + struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu); + struct sk_buff *tmp_skb; +@@ -1306,11 +1305,15 @@ static int ath10k_htt_tx_hl(struct ath10 + u16 flags1 = 0; + u16 msdu_id = 0; + +- if ((ieee80211_is_action(hdr->frame_control) || +- ieee80211_is_deauth(hdr->frame_control) || +- ieee80211_is_disassoc(hdr->frame_control)) && +- ieee80211_has_protected(hdr->frame_control)) { +- skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ if (!is_eth) { ++ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; ++ ++ if ((ieee80211_is_action(hdr->frame_control) || ++ ieee80211_is_deauth(hdr->frame_control) || ++ ieee80211_is_disassoc(hdr->frame_control)) && ++ ieee80211_has_protected(hdr->frame_control)) { ++ skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ } + } + + data_len = msdu->len; +@@ -1407,7 +1410,6 @@ static int ath10k_htt_tx_32(struct ath10 + { + struct ath10k *ar = htt->ar; + struct device *dev = ar->dev; +- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(msdu); + struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu); + struct ath10k_hif_sg_item sg_items[2]; +@@ -1439,15 +1441,19 @@ static int ath10k_htt_tx_32(struct ath10 + txbuf_paddr = htt->txbuf.paddr + + (sizeof(struct ath10k_htt_txbuf_32) * msdu_id); + +- if ((ieee80211_is_action(hdr->frame_control) || +- ieee80211_is_deauth(hdr->frame_control) || +- ieee80211_is_disassoc(hdr->frame_control)) && +- ieee80211_has_protected(hdr->frame_control)) { +- skb_put(msdu, IEEE80211_CCMP_MIC_LEN); +- } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) && +- txmode == ATH10K_HW_TXRX_RAW && +- ieee80211_has_protected(hdr->frame_control)) { +- skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ if (!is_eth) { ++ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; ++ ++ if ((ieee80211_is_action(hdr->frame_control) || ++ ieee80211_is_deauth(hdr->frame_control) || ++ ieee80211_is_disassoc(hdr->frame_control)) && ++ ieee80211_has_protected(hdr->frame_control)) { ++ skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) && ++ txmode == ATH10K_HW_TXRX_RAW && ++ ieee80211_has_protected(hdr->frame_control)) { ++ skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ } + } + + skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len, +@@ -1609,7 +1615,6 @@ static int ath10k_htt_tx_64(struct ath10 + { + struct ath10k *ar = htt->ar; + struct device *dev = ar->dev; +- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(msdu); + struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu); + struct ath10k_hif_sg_item sg_items[2]; +@@ -1641,15 +1646,19 @@ static int ath10k_htt_tx_64(struct ath10 + txbuf_paddr = htt->txbuf.paddr + + (sizeof(struct ath10k_htt_txbuf_64) * msdu_id); + +- if ((ieee80211_is_action(hdr->frame_control) || +- ieee80211_is_deauth(hdr->frame_control) || +- ieee80211_is_disassoc(hdr->frame_control)) && +- ieee80211_has_protected(hdr->frame_control)) { +- skb_put(msdu, IEEE80211_CCMP_MIC_LEN); +- } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) && +- txmode == ATH10K_HW_TXRX_RAW && +- ieee80211_has_protected(hdr->frame_control)) { +- skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ if (!is_eth) { ++ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; ++ ++ if ((ieee80211_is_action(hdr->frame_control) || ++ ieee80211_is_deauth(hdr->frame_control) || ++ ieee80211_is_disassoc(hdr->frame_control)) && ++ ieee80211_has_protected(hdr->frame_control)) { ++ skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) && ++ txmode == ATH10K_HW_TXRX_RAW && ++ ieee80211_has_protected(hdr->frame_control)) { ++ skb_put(msdu, IEEE80211_CCMP_MIC_LEN); ++ } + } + + skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len, diff --git a/package/kernel/mac80211/patches/ath10k/081-04-ath10k-add-encapsulation-offloading-support.patch b/package/kernel/mac80211/patches/ath10k/081-04-ath10k-add-encapsulation-offloading-support.patch new file mode 100644 index 0000000000..cb02dede64 --- /dev/null +++ b/package/kernel/mac80211/patches/ath10k/081-04-ath10k-add-encapsulation-offloading-support.patch @@ -0,0 +1,194 @@ +From af6d8265c47e46881b80c6b073f53c8c4af52d28 Mon Sep 17 00:00:00 2001 +From: Sergey Ryazanov +Date: Mon, 16 May 2022 13:26:00 +0300 +Subject: ath10k: add encapsulation offloading support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Frame encapsulation from Ethernet into the IEEE 802.11 frame format +takes a considerable host CPU time on the xmit path. The firmware is +able to do this operation for us, so enable encapsulation offloading for +AP and Sta interface types to improve overall system performance. + +The driver is almost ready for encapsulation offloading support. There +are only a few places where the driver assumes the frame format is IEEE +802.11 that need to be fixed. + +Encapsulation offloading is currently disabled by default and the driver +utilizes mac80211 encapsulation support. To activate offloading, the +frame_mode=2 parameter should be passed during module loading. + +On a QCA9563+QCA9888-based access point in bridged mode, encapsulation +offloading increases TCP 16-streams DL throughput from 365 to 396 mbps +(+8%) and UDP DL throughput from 436 to 483 mbps (+11%). + +Tested-on: QCA9888 hw2.0 PCI 10.4-3.9.0.2-00131 +Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00157-QCARMSWPZ-1 +Signed-off-by: Sergey Ryazanov +Tested-by: Oldřich Jedlička # TP-Link Archer C7 v4 & v5 (QCA9563 + QCA9880) +Tested-by: Edward Matijevic # TP-Link Archer C2600 (IPQ8064 + QCA9980 10.4.1.00030-1) +Tested-by: Edward Matijevic # QCA9377 PCI in Sta mode +Tested-by: Zhijun You # NETGEAR R7800 (QCA9984 10.4-3.9.0.2-00159) +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20220516032519.29831-5-ryazanov.s.a@gmail.com +--- + drivers/net/wireless/ath/ath10k/core.c | 2 +- + drivers/net/wireless/ath/ath10k/mac.c | 67 +++++++++++++++++++++++++++------- + 2 files changed, 55 insertions(+), 14 deletions(-) + +--- a/drivers/net/wireless/ath/ath10k/core.c ++++ b/drivers/net/wireless/ath/ath10k/core.c +@@ -54,7 +54,7 @@ MODULE_PARM_DESC(uart_print, "Uart targe + MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode"); + MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software"); + MODULE_PARM_DESC(frame_mode, +- "Datapath frame mode (0: raw, 1: native wifi (default))"); ++ "Datapath frame mode (0: raw, 1: native wifi (default), 2: ethernet)"); + MODULE_PARM_DESC(coredump_mask, "Bitfield of what to include in firmware crash file"); + MODULE_PARM_DESC(fw_diag_log, "Diag based fw log debugging"); + +--- a/drivers/net/wireless/ath/ath10k/mac.c ++++ b/drivers/net/wireless/ath/ath10k/mac.c +@@ -3710,6 +3710,9 @@ ath10k_mac_tx_h_get_txmode(struct ath10k + const struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); + __le16 fc = hdr->frame_control; + ++ if (IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ++ return ATH10K_HW_TXRX_ETHERNET; ++ + if (!vif || vif->type == NL80211_IFTYPE_MONITOR) + return ATH10K_HW_TXRX_RAW; + +@@ -3870,6 +3873,12 @@ static void ath10k_mac_tx_h_fill_cb(stru + bool noack = false; + + cb->flags = 0; ++ ++ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { ++ cb->flags |= ATH10K_SKB_F_QOS; /* Assume data frames are QoS */ ++ goto finish_cb_fill; ++ } ++ + if (!ath10k_tx_h_use_hwcrypto(vif, skb)) + cb->flags |= ATH10K_SKB_F_NO_HWCRYPT; + +@@ -3908,6 +3917,7 @@ static void ath10k_mac_tx_h_fill_cb(stru + cb->flags |= ATH10K_SKB_F_RAW_TX; + } + ++finish_cb_fill: + cb->vif = vif; + cb->txq = txq; + cb->airtime_est = airtime; +@@ -4031,7 +4041,11 @@ static int ath10k_mac_tx(struct ath10k * + ath10k_tx_h_seq_no(vif, skb); + break; + case ATH10K_HW_TXRX_ETHERNET: +- ath10k_tx_h_8023(skb); ++ /* Convert 802.11->802.3 header only if the frame was erlier ++ * encapsulated to 802.11 by mac80211. Otherwise pass it as is. ++ */ ++ if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) ++ ath10k_tx_h_8023(skb); + break; + case ATH10K_HW_TXRX_RAW: + if (!test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags) && +@@ -4643,12 +4657,10 @@ static void ath10k_mac_op_tx(struct ieee + struct ieee80211_vif *vif = info->control.vif; + struct ieee80211_sta *sta = control->sta; + struct ieee80211_txq *txq = NULL; +- struct ieee80211_hdr *hdr = (void *)skb->data; + enum ath10k_hw_txrx_mode txmode; + enum ath10k_mac_tx_path txpath; + bool is_htt; + bool is_mgmt; +- bool is_presp; + int ret; + u16 airtime; + +@@ -4662,8 +4674,14 @@ static void ath10k_mac_op_tx(struct ieee + is_mgmt = (txpath == ATH10K_MAC_TX_HTT_MGMT); + + if (is_htt) { ++ bool is_presp = false; ++ + spin_lock_bh(&ar->htt.tx_lock); +- is_presp = ieee80211_is_probe_resp(hdr->frame_control); ++ if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) { ++ struct ieee80211_hdr *hdr = (void *)skb->data; ++ ++ is_presp = ieee80211_is_probe_resp(hdr->frame_control); ++ } + + ret = ath10k_htt_tx_inc_pending(htt); + if (ret) { +@@ -5447,6 +5465,30 @@ static int ath10k_mac_set_txbf_conf(stru + ar->wmi.vdev_param->txbf, value); + } + ++static void ath10k_update_vif_offload(struct ieee80211_hw *hw, ++ struct ieee80211_vif *vif) ++{ ++ struct ath10k_vif *arvif = (void *)vif->drv_priv; ++ struct ath10k *ar = hw->priv; ++ u32 vdev_param; ++ int ret; ++ ++ if (ath10k_frame_mode != ATH10K_HW_TXRX_ETHERNET || ++ ar->wmi.vdev_param->tx_encap_type == WMI_VDEV_PARAM_UNSUPPORTED || ++ (vif->type != NL80211_IFTYPE_STATION && ++ vif->type != NL80211_IFTYPE_AP)) ++ vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; ++ ++ vdev_param = ar->wmi.vdev_param->tx_encap_type; ++ ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, ++ ATH10K_HW_TXRX_NATIVE_WIFI); ++ /* 10.X firmware does not support this VDEV parameter. Do not warn */ ++ if (ret && ret != -EOPNOTSUPP) { ++ ath10k_warn(ar, "failed to set vdev %i TX encapsulation: %d\n", ++ arvif->vdev_id, ret); ++ } ++} ++ + /* + * TODO: + * Figure out how to handle WMI_VDEV_SUBTYPE_P2P_DEVICE, +@@ -5656,15 +5698,7 @@ static int ath10k_add_interface(struct i + + arvif->def_wep_key_idx = -1; + +- vdev_param = ar->wmi.vdev_param->tx_encap_type; +- ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, +- ATH10K_HW_TXRX_NATIVE_WIFI); +- /* 10.X firmware does not support this VDEV parameter. Do not warn */ +- if (ret && ret != -EOPNOTSUPP) { +- ath10k_warn(ar, "failed to set vdev %i TX encapsulation: %d\n", +- arvif->vdev_id, ret); +- goto err_vdev_delete; +- } ++ ath10k_update_vif_offload(hw, vif); + + /* Configuring number of spatial stream for monitor interface is causing + * target assert in qca9888 and qca6174. +@@ -9352,6 +9386,7 @@ static const struct ieee80211_ops ath10k + .stop = ath10k_stop, + .config = ath10k_config, + .add_interface = ath10k_add_interface, ++ .update_vif_offload = ath10k_update_vif_offload, + .remove_interface = ath10k_remove_interface, + .configure_filter = ath10k_configure_filter, + .bss_info_changed = ath10k_bss_info_changed, +@@ -10021,6 +10056,12 @@ int ath10k_mac_register(struct ath10k *a + if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, ar->wmi.svc_map)) + ieee80211_hw_set(ar->hw, SUPPORTS_TDLS_BUFFER_STA); + ++ if (ath10k_frame_mode == ATH10K_HW_TXRX_ETHERNET) { ++ if (ar->wmi.vdev_param->tx_encap_type != ++ WMI_VDEV_PARAM_UNSUPPORTED) ++ ieee80211_hw_set(ar->hw, SUPPORTS_TX_ENCAP_OFFLOAD); ++ } ++ + ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; + ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; + ar->hw->wiphy->max_remain_on_channel_duration = 5000; diff --git a/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch b/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch index 74d5b374fb..7ef418e506 100644 --- a/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch +++ b/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch @@ -34,7 +34,7 @@ Link: https://lore.kernel.org/r/20211009221711.2315352-1-robimarko@gmail.com --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c -@@ -1199,6 +1199,7 @@ success: +@@ -1202,6 +1202,7 @@ success: static int ath10k_core_fetch_board_data_api_1(struct ath10k *ar, int bd_ie_type) { const struct firmware *fw; @@ -42,7 +42,7 @@ Link: https://lore.kernel.org/r/20211009221711.2315352-1-robimarko@gmail.com if (bd_ie_type == ATH10K_BD_IE_BOARD) { if (!ar->hw_params.fw.board) { -@@ -1206,9 +1207,19 @@ static int ath10k_core_fetch_board_data_ +@@ -1209,9 +1210,19 @@ static int ath10k_core_fetch_board_data_ return -EINVAL; } diff --git a/package/kernel/mac80211/patches/ath10k/120-ath10k-fetch-calibration-data-via-nvmem-subsystem.patch b/package/kernel/mac80211/patches/ath10k/120-ath10k-fetch-calibration-data-via-nvmem-subsystem.patch index ab42c6e1e0..c7a00b7e4b 100644 --- a/package/kernel/mac80211/patches/ath10k/120-ath10k-fetch-calibration-data-via-nvmem-subsystem.patch +++ b/package/kernel/mac80211/patches/ath10k/120-ath10k-fetch-calibration-data-via-nvmem-subsystem.patch @@ -34,7 +34,7 @@ Signed-off-by: Christian Lamparter #include #include "core.h" -@@ -952,7 +953,8 @@ static int ath10k_core_get_board_id_from +@@ -955,7 +956,8 @@ static int ath10k_core_get_board_id_from } if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT || @@ -44,7 +44,7 @@ Signed-off-by: Christian Lamparter bmi_board_id_param = BMI_PARAM_GET_FLASH_BOARD_ID; else bmi_board_id_param = BMI_PARAM_GET_EEPROM_BOARD_ID; -@@ -1754,7 +1756,8 @@ static int ath10k_download_and_run_otp(s +@@ -1757,7 +1759,8 @@ static int ath10k_download_and_run_otp(s /* As of now pre-cal is valid for 10_4 variants */ if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT || @@ -54,7 +54,7 @@ Signed-off-by: Christian Lamparter bmi_otp_exe_param = BMI_PARAM_FLASH_SECTION_ALL; ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result); -@@ -1881,6 +1884,39 @@ out_free: +@@ -1884,6 +1887,39 @@ out_free: return ret; } @@ -94,7 +94,7 @@ Signed-off-by: Christian Lamparter int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, struct ath10k_fw_file *fw_file) { -@@ -2115,6 +2151,18 @@ static int ath10k_core_pre_cal_download( +@@ -2118,6 +2154,18 @@ static int ath10k_core_pre_cal_download( { int ret; @@ -113,7 +113,7 @@ Signed-off-by: Christian Lamparter ret = ath10k_download_cal_file(ar, ar->pre_cal_file); if (ret == 0) { ar->cal_mode = ATH10K_PRE_CAL_MODE_FILE; -@@ -2181,6 +2229,18 @@ static int ath10k_download_cal_data(stru +@@ -2184,6 +2232,18 @@ static int ath10k_download_cal_data(stru "pre cal download procedure failed, try cal file: %d\n", ret); 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 5362c2436d..e47fb012fa 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 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c -@@ -3440,6 +3440,16 @@ int ath10k_core_register(struct ath10k * +@@ -3443,6 +3443,16 @@ int ath10k_core_register(struct ath10k * queue_work(ar->workqueue, &ar->register_work); 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 b60db19464..9cbc52b88f 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 -@@ -9843,6 +9843,21 @@ static int ath10k_mac_init_rd(struct ath +@@ -9878,6 +9878,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[] = { -@@ -10195,6 +10210,12 @@ int ath10k_mac_register(struct ath10k *a +@@ -10236,6 +10251,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 f63f45d108..f1e7f5ecc6 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 @@ -132,7 +132,7 @@ v13: unsigned int ath10k_debug_mask; EXPORT_SYMBOL(ath10k_debug_mask); -@@ -62,6 +63,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, -@@ -135,6 +137,7 @@ static const struct ath10k_hw_params ath +@@ -138,6 +140,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, -@@ -352,6 +355,7 @@ static const struct ath10k_hw_params ath +@@ -355,6 +358,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, -@@ -394,6 +398,7 @@ static const struct ath10k_hw_params ath +@@ -397,6 +401,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, -@@ -443,6 +448,7 @@ static const struct ath10k_hw_params ath +@@ -446,6 +451,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, -@@ -3155,6 +3161,10 @@ int ath10k_core_start(struct ath10k *ar, +@@ -3158,6 +3164,10 @@ int ath10k_core_start(struct ath10k *ar, goto err_hif_stop; } @@ -183,7 +183,7 @@ v13: return 0; err_hif_stop: -@@ -3413,9 +3423,18 @@ static void ath10k_core_register_work(st +@@ -3416,9 +3426,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: -@@ -3461,6 +3480,8 @@ void ath10k_core_unregister(struct ath10 +@@ -3464,6 +3483,8 @@ void ath10k_core_unregister(struct ath10 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags)) return; 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 da31ad578a..4c1b73b1c1 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 @@ -42,7 +42,7 @@ Signed-off-by: Mathias Kresin if (ret) --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -10212,7 +10212,7 @@ int ath10k_mac_register(struct ath10k *a +@@ -10253,7 +10253,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/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 d94a8a8596..80da07de8a 100644 --- a/package/kernel/mac80211/patches/ath10k/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 @@ -26,7 +26,7 @@ Signed-off-by: Ansuel Smith #include #include #include -@@ -3331,6 +3332,8 @@ static int ath10k_core_probe_fw(struct a +@@ -3334,6 +3335,8 @@ static int ath10k_core_probe_fw(struct a device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr)); diff --git a/package/kernel/mac80211/patches/subsys/330-mac80211-fix-overflow-issues-in-airtime-fairness-cod.patch b/package/kernel/mac80211/patches/subsys/330-mac80211-fix-overflow-issues-in-airtime-fairness-cod.patch deleted file mode 100644 index 037ab8e180..0000000000 --- a/package/kernel/mac80211/patches/subsys/330-mac80211-fix-overflow-issues-in-airtime-fairness-cod.patch +++ /dev/null @@ -1,132 +0,0 @@ -From: Felix Fietkau -Date: Sat, 28 May 2022 16:44:53 +0200 -Subject: [PATCH] mac80211: fix overflow issues in airtime fairness code - -The airtime weight calculation overflows with a default weight value of 256 -whenever more than 8ms worth of airtime is reported. -Bigger weight values impose even smaller limits on maximum airtime values. -This can mess up airtime based calculations for drivers that don't report -per-PPDU airtime values, but batch up values instead. - -Fix this by reordering multiplications/shifts and by reducing unnecessary -intermediate precision (which was lost in a later stage anyway). - -The new shift value limits the maximum weight to 4096, which should be more -than enough. Any values bigger than that will be clamped to the upper limit. - -Signed-off-by: Felix Fietkau ---- - ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -1666,50 +1666,34 @@ static inline struct airtime_info *to_ai - /* 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. -+ * The per-sta shift value supports weight values of 1-4096 - */ --#define IEEE80211_RECIPROCAL_DIVISOR_64 0x100000000ULL --#define IEEE80211_RECIPROCAL_SHIFT_64 32 --#define IEEE80211_RECIPROCAL_DIVISOR_32 0x80000U --#define IEEE80211_RECIPROCAL_SHIFT_32 19 -+#define IEEE80211_RECIPROCAL_SHIFT_SUM 24 -+#define IEEE80211_RECIPROCAL_SHIFT_STA 12 -+#define IEEE80211_WEIGHT_SHIFT 8 - --static inline void airtime_weight_set(struct airtime_info *air_info, u16 weight) -+static inline void airtime_weight_set(struct airtime_info *air_info, u32 weight) - { -+ weight = min_t(u32, weight, BIT(IEEE80211_RECIPROCAL_SHIFT_STA)); - 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; -- } -+ if (weight) -+ weight = BIT(IEEE80211_RECIPROCAL_SHIFT_STA) / weight; -+ air_info->weight_reciprocal = weight; - } - - static inline void airtime_weight_sum_set(struct airtime_sched_info *air_sched, -- int weight_sum) -+ u32 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; -- } -+ if (weight_sum) -+ weight_sum = BIT(IEEE80211_RECIPROCAL_SHIFT_SUM) / weight_sum; -+ air_sched->weight_sum_reciprocal = weight_sum; - } - - /* A problem when trying to enforce airtime fairness is that we want to divide ---- a/net/mac80211/sta_info.c -+++ b/net/mac80211/sta_info.c -@@ -1894,9 +1894,9 @@ void ieee80211_register_airtime(struct i - { - 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; -+ u64 weight_sum_reciprocal; - u32 airtime = 0; - - air_sched = &local->airtime[txq->ac]; -@@ -1907,27 +1907,21 @@ void ieee80211_register_airtime(struct i - if (local->airtime_flags & AIRTIME_USE_RX) - airtime += rx_airtime; - -- /* 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; -+ if (air_sched->weight_sum) - weight_sum_reciprocal = air_sched->weight_sum_reciprocal; -- } else { -- weight_sum = air_info->weight; -+ else - 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; -+ air_sched->v_t += ((u64)airtime * weight_sum_reciprocal) >> -+ (IEEE80211_RECIPROCAL_SHIFT_SUM - IEEE80211_WEIGHT_SHIFT); -+ air_info->v_t += (airtime * air_info->weight_reciprocal) >> -+ (IEEE80211_RECIPROCAL_SHIFT_STA - IEEE80211_WEIGHT_SHIFT); - ieee80211_resort_txq(&local->hw, txq); - - spin_unlock_bh(&air_sched->lock); diff --git a/package/kernel/mac80211/patches/subsys/331-mac80211-rework-the-airtime-fairness-implementation.patch b/package/kernel/mac80211/patches/subsys/331-mac80211-rework-the-airtime-fairness-implementation.patch deleted file mode 100644 index 39538b122e..0000000000 --- a/package/kernel/mac80211/patches/subsys/331-mac80211-rework-the-airtime-fairness-implementation.patch +++ /dev/null @@ -1,852 +0,0 @@ -From: Felix Fietkau -Date: Sat, 28 May 2022 16:51:51 +0200 -Subject: [PATCH] mac80211: rework the airtime fairness implementation - -The current ATF implementation has a number of issues which have shown up -during testing. Since it does not take into account the AQL budget of -pending packets, the implementation might queue up large amounts of packets -for a single txq until airtime gets reported after tx completion. -The same then happens to the next txq afterwards. While the end result could -still be considered fair, the bursty behavior introduces a large amount of -latency. -The current code also tries to avoid frequent re-sorting of txq entries in -order to avoid having to re-balance the rbtree often. - -In order to fix these issues, introduce skip lists as a data structure, which -offer similar lookup/insert/delete times as rbtree, but avoids the need for -rebalacing by being probabilistic. -Use this to keep tx entries sorted by virtual time + pending AQL budget and -re-sort after each ieee80211_return_txq call. - -Since multiple txqs share a single air_time struct with a virtual time value, -switch the active_txqs list to queue up air_time structs instead of queues. -This helps avoid imbalance between shared txqs by servicing them round robin. - -ieee80211_next_txq now only dequeues the first element of active_txqs. To -make that work for non-AQL or non-ATF drivers as well, add estimated tx -airtime directly to air_info virtual time if either AQL or ATF is not -supported. - -Signed-off-by: Felix Fietkau ---- - create mode 100644 include/linux/skiplist.h - ---- /dev/null -+++ b/include/linux/skiplist.h -@@ -0,0 +1,250 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+/* -+ * A skip list is a probabilistic alternative to balanced trees. Unlike the -+ * red-black tree, it does not require rebalancing. -+ * -+ * This implementation uses only unidirectional next pointers and is optimized -+ * for use in a priority queue where elements are mostly deleted from the front -+ * of the queue. -+ * -+ * When storing up to 2^n elements in a n-level skiplist. lookup and deletion -+ * for the first element happens in O(1) time, other than that, insertion and -+ * deletion takes O(log n) time, assuming that the number of elements for an -+ * n-level list does not exceed 2^n. -+ * -+ * Usage: -+ * DECLARE_SKIPLIST_TYPE(foo, 5) will define the data types for a 5-level list: -+ * struct foo_list: the list data type -+ * struct foo_node: the node data for an element in the list -+ * -+ * DECLARE_SKIPLIST_IMPL(foo, foo_cmp_fn) -+ * -+ * Adds the skip list implementation. It depends on a provided function: -+ * int foo_cmp_fn(struct foo_list *list, struct foo_node *n1, struct foo_node *n2) -+ * This compares two elements given by their node pointers, returning values <0 -+ * if n1 is less than n2, =0 and >0 for equal or bigger than respectively. -+ * -+ * This macro implements the following functions: -+ * -+ * void foo_list_init(struct foo_list *list) -+ * initializes the skip list -+ * -+ * void foo_node_init(struct foo_node *node) -+ * initializes a node. must be called before adding the node to the list -+ * -+ * struct foo_node *foo_node_next(struct foo_node *node) -+ * gets the node directly after the provided node, or NULL if it was the last -+ * element in the list. -+ * -+ * bool foo_is_queued(struct foo_node *node) -+ * returns true if the node is on a list -+ * -+ * struct foo_node *foo_dequeue(struct foo_list *list) -+ * deletes and returns the first element of the list (or returns NULL if empty) -+ * -+ * struct foo_node *foo_peek(struct foo_list *list) -+ * returns the first element of the list -+ * -+ * void foo_insert(struct foo_list *list, struct foo_node *node) -+ * inserts the node into the list. the node must be initialized and not on a -+ * list already. -+ * -+ * void foo_delete(struct foo_list *list, struct foo_node *node) -+ * deletes the node from the list, or does nothing if it's not on the list -+ */ -+#ifndef __SKIPLIST_H -+#define __SKIPLIST_H -+ -+#include -+#include -+#include -+#include -+ -+#define SKIPLIST_POISON ((void *)1) -+ -+#define DECLARE_SKIPLIST_TYPE(name, levels) \ -+struct name##_node { \ -+ struct name##_node *next[levels]; \ -+}; \ -+struct name##_list { \ -+ struct name##_node head; \ -+ unsigned int max_level; \ -+ unsigned int count; \ -+}; -+ -+#define DECLARE_SKIPLIST_IMPL(name, cmp_fn) \ -+static inline void \ -+name##_list_init(struct name##_list *list) \ -+{ \ -+ memset(list, 0, sizeof(*list)); \ -+} \ -+static inline void \ -+name##_node_init(struct name##_node *node) \ -+{ \ -+ node->next[0] = SKIPLIST_POISON; \ -+} \ -+static inline struct name##_node * \ -+name##_node_next(struct name##_node *node) \ -+{ \ -+ return node->next[0]; \ -+} \ -+static inline bool \ -+name##_is_queued(struct name##_node *node) \ -+{ \ -+ return node->next[0] != SKIPLIST_POISON; \ -+} \ -+static inline int \ -+__skiplist_##name##_cmp_impl(void *head, void *n1, void *n2) \ -+{ \ -+ return cmp_fn(head, n1, n2); \ -+} \ -+static inline void \ -+__##name##_delete(struct name##_list *list) \ -+{ \ -+ list->count--; \ -+ while (list->max_level && \ -+ !list->head.next[list->max_level]) \ -+ list->max_level--; \ -+} \ -+static inline struct name##_node * \ -+name##_dequeue(struct name##_list *list) \ -+{ \ -+ struct name##_node *ret; \ -+ unsigned int max_level = ARRAY_SIZE(list->head.next) - 1; \ -+ ret = (void *)__skiplist_dequeue((void **)&list->head, \ -+ max_level); \ -+ if (!ret) \ -+ return NULL; \ -+ __##name##_delete(list); \ -+ return ret; \ -+} \ -+static inline struct name##_node * \ -+name##_peek(struct name##_list *list) \ -+{ \ -+ return list->head.next[0]; \ -+} \ -+static inline void \ -+name##_insert(struct name##_list *list, struct name##_node *node) \ -+{ \ -+ int level = __skiplist_level(ARRAY_SIZE(list->head.next) - 1, \ -+ list->count, prandom_u32()); \ -+ level = min_t(int, level, list->max_level + 1); \ -+ __skiplist_insert((void *)&list->head, (void *)node, level, \ -+ __skiplist_##name##_cmp_impl); \ -+ if (level > list->max_level) \ -+ list->max_level = level; \ -+ list->count++; \ -+} \ -+static inline void \ -+name##_delete(struct name##_list *list, struct name##_node *node) \ -+{ \ -+ if (node->next[0] == SKIPLIST_POISON) \ -+ return; \ -+ __skiplist_delete((void *)&list->head, (void *)node, \ -+ ARRAY_SIZE(list->head.next) - 1, \ -+ __skiplist_##name##_cmp_impl); \ -+ __##name##_delete(list); \ -+} -+ -+ -+typedef int (*__skiplist_cmp_t)(void *head, void *n1, void *n2); -+ -+#define __skiplist_cmp(cmp, head, cur, node) \ -+ ({ \ -+ int cmp_val = cmp(head, cur, node); \ -+ if (!cmp_val) \ -+ cmp_val = (unsigned long)(cur) - \ -+ (unsigned long)(node); \ -+ cmp_val; \ -+ }) -+ -+static inline void * -+__skiplist_dequeue(void **list, int max_level) -+{ -+ void **node = list[0]; -+ unsigned int i; -+ -+ if (!node) -+ return NULL; -+ -+ list[0] = node[0]; -+ for (i = 1; i <= max_level; i++) { -+ if (list[i] != node) -+ break; -+ -+ list[i] = node[i]; -+ } -+ node[0] = SKIPLIST_POISON; -+ -+ return node; -+} -+ -+static inline void -+__skiplist_insert(void **list, void **node, int level, __skiplist_cmp_t cmp) -+{ -+ void **head = list; -+ -+ if (WARN(node[0] != SKIPLIST_POISON, "Insert on already inserted or uninitialized node")) -+ return; -+ for (; level >= 0; level--) { -+ while (list[level] && -+ __skiplist_cmp(cmp, head, list[level], node) < 0) -+ list = list[level]; -+ -+ node[level] = list[level]; -+ list[level] = node; -+ } -+} -+ -+ -+static inline void -+__skiplist_delete(void **list, void **node, int max_level, __skiplist_cmp_t cmp) -+{ -+ void *head = list; -+ int i; -+ -+ for (i = max_level; i >= 0; i--) { -+ while (list[i] && list[i] != node && -+ __skiplist_cmp(cmp, head, list[i], node) <= 0) -+ list = list[i]; -+ -+ if (list[i] != node) -+ continue; -+ -+ list[i] = node[i]; -+ } -+ node[0] = SKIPLIST_POISON; -+} -+ -+static inline unsigned int -+__skiplist_level(unsigned int max_level, unsigned int count, unsigned int seed) -+{ -+ unsigned int level = 0; -+ -+ if (max_level >= 16 && !(seed & GENMASK(15, 0))) { -+ level += 16; -+ seed >>= 16; -+ } -+ -+ if (max_level >= 8 && !(seed & GENMASK(7, 0))) { -+ level += 8; -+ seed >>= 8; -+ } -+ -+ if (max_level >= 4 && !(seed & GENMASK(3, 0))) { -+ level += 4; -+ seed >>= 4; -+ } -+ -+ if (!(seed & GENMASK(1, 0))) { -+ level += 2; -+ seed >>= 2; -+ } -+ -+ if (!(seed & BIT(0))) -+ level++; -+ -+ return min(level, max_level); -+} -+ -+#endif ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -1563,7 +1563,6 @@ static void sta_apply_airtime_params(str - 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); -@@ -1575,10 +1574,6 @@ static void sta_apply_airtime_params(str - - 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); - } ---- a/net/mac80211/ieee80211_i.h -+++ b/net/mac80211/ieee80211_i.h -@@ -25,7 +25,8 @@ - #include - #include - #include --#include -+#include -+#include - #include - #include - #include -@@ -854,6 +855,7 @@ enum txq_info_flags { - IEEE80211_TXQ_AMPDU, - IEEE80211_TXQ_NO_AMSDU, - IEEE80211_TXQ_STOP_NETIF_TX, -+ IEEE80211_TXQ_FORCE_ACTIVE, - }; - - /** -@@ -870,7 +872,6 @@ struct txq_info { - struct fq_tin tin; - struct codel_vars def_cvars; - struct codel_stats cstats; -- struct rb_node schedule_order; - - struct sk_buff_head frags; - unsigned long flags; -@@ -1185,8 +1186,7 @@ enum mac80211_scan_state { - * - * @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() -+ * @schedule_pos: last used airtime_info node while a driver walks the tree - * @active_list: list of struct airtime_info structs that were active within - * the last AIRTIME_ACTIVE_DURATION (100 ms), used to compute - * weight_sum -@@ -1207,8 +1207,8 @@ enum mac80211_scan_state { - */ - struct airtime_sched_info { - spinlock_t lock; -- struct rb_root_cached active_txqs; -- struct rb_node *schedule_pos; -+ struct airtime_sched_list active_txqs; -+ struct airtime_sched_node *schedule_pos; - struct list_head active_list; - u64 last_weight_update; - u64 last_schedule_activity; -@@ -1663,6 +1663,20 @@ static inline struct airtime_info *to_ai - return &sdata->airtime[txq->ac]; - } - -+static inline int -+airtime_sched_cmp(struct airtime_sched_list *list, -+ struct airtime_sched_node *n1, struct airtime_sched_node *n2) -+{ -+ struct airtime_info *a1, *a2; -+ -+ a1 = container_of(n1, struct airtime_info, schedule_order); -+ a2 = container_of(n2, struct airtime_info, schedule_order); -+ -+ return a1->v_t_cur - a2->v_t_cur; -+} -+ -+DECLARE_SKIPLIST_IMPL(airtime_sched, airtime_sched_cmp); -+ - /* 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. -@@ -1750,6 +1764,7 @@ static inline void init_airtime_info(str - 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); -+ airtime_sched_node_init(&air_info->schedule_order); - } - - static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) ---- a/net/mac80211/main.c -+++ b/net/mac80211/main.c -@@ -709,7 +709,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_ - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - struct airtime_sched_info *air_sched = &local->airtime[i]; - -- air_sched->active_txqs = RB_ROOT_CACHED; -+ airtime_sched_list_init(&air_sched->active_txqs); - 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; ---- a/net/mac80211/sta_info.c -+++ b/net/mac80211/sta_info.c -@@ -1902,8 +1902,7 @@ void ieee80211_register_airtime(struct i - air_sched = &local->airtime[txq->ac]; - air_info = to_airtime_info(txq); - -- if (local->airtime_flags & AIRTIME_USE_TX) -- airtime += tx_airtime; -+ airtime += tx_airtime; - if (local->airtime_flags & AIRTIME_USE_RX) - airtime += rx_airtime; - ---- a/net/mac80211/sta_info.h -+++ b/net/mac80211/sta_info.h -@@ -135,11 +135,14 @@ enum ieee80211_agg_stop_reason { - #define AIRTIME_USE_TX BIT(0) - #define AIRTIME_USE_RX BIT(1) - -+DECLARE_SKIPLIST_TYPE(airtime_sched, 5); - - struct airtime_info { -+ struct airtime_sched_node schedule_order; -+ struct ieee80211_txq *txq[3]; - u64 rx_airtime; - u64 tx_airtime; -- u64 v_t; -+ u64 v_t, v_t_cur; - u64 last_scheduled; - struct list_head list; - atomic_t aql_tx_pending; /* Estimated airtime for frames pending */ -@@ -147,6 +150,7 @@ struct airtime_info { - u32 aql_limit_high; - u32 weight_reciprocal; - u16 weight; -+ u8 txq_idx; - }; - - void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -1476,11 +1477,12 @@ void ieee80211_txq_init(struct ieee80211 - struct sta_info *sta, - struct txq_info *txqi, int tid) - { -+ struct airtime_info *air_info; -+ - fq_tin_init(&txqi->tin); - codel_vars_init(&txqi->def_cvars); - codel_stats_init(&txqi->cstats); - __skb_queue_head_init(&txqi->frags); -- RB_CLEAR_NODE(&txqi->schedule_order); - - txqi->txq.vif = &sdata->vif; - -@@ -1489,7 +1491,7 @@ void ieee80211_txq_init(struct ieee80211 - txqi->txq.tid = 0; - txqi->txq.ac = IEEE80211_AC_BE; - -- return; -+ goto out; - } - - if (tid == IEEE80211_NUM_TIDS) { -@@ -1511,6 +1513,12 @@ void ieee80211_txq_init(struct ieee80211 - txqi->txq.sta = &sta->sta; - txqi->txq.tid = tid; - sta->sta.txq[tid] = &txqi->txq; -+ -+out: -+ air_info = to_airtime_info(&txqi->txq); -+ air_info->txq[air_info->txq_idx++] = &txqi->txq; -+ if (air_info->txq_idx == ARRAY_SIZE(air_info->txq)) -+ air_info->txq_idx--; - } - - void ieee80211_txq_purge(struct ieee80211_local *local, -@@ -3633,6 +3641,8 @@ struct sk_buff *ieee80211_tx_dequeue(str - struct ieee80211_tx_data tx; - ieee80211_tx_result r; - struct ieee80211_vif *vif = txq->vif; -+ u32 airtime; -+ bool ampdu; - - WARN_ON_ONCE(softirq_count() == 0); - -@@ -3791,21 +3801,26 @@ begin: - encap_out: - IEEE80211_SKB_CB(skb)->control.vif = vif; - -- if (vif && -- wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { -- bool ampdu = txq->ac != IEEE80211_AC_VO; -- u32 airtime; -- -- airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, -- skb->len, ampdu); -- if (airtime) { -- airtime = ieee80211_info_set_tx_time_est(info, airtime); -- ieee80211_sta_update_pending_airtime(local, tx.sta, -- txq->ac, -- airtime, -- false); -- } -- } -+ if (!vif) -+ return skb; -+ -+ ampdu = txq->ac != IEEE80211_AC_VO; -+ airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, -+ skb->len, ampdu); -+ if (!airtime) -+ return skb; -+ -+ if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL) || -+ !wiphy_ext_feature_isset(local->hw.wiphy, -+ NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) -+ ieee80211_register_airtime(txq, airtime, 0); -+ -+ if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) -+ return skb; -+ -+ airtime = ieee80211_info_set_tx_time_est(info, airtime); -+ ieee80211_sta_update_pending_airtime(local, tx.sta, txq->ac, -+ airtime, false); - - return skb; - -@@ -3816,85 +3831,95 @@ out: - } - EXPORT_SYMBOL(ieee80211_tx_dequeue); - -+static void -+airtime_info_next_txq_idx(struct airtime_info *air_info) -+{ -+ air_info->txq_idx++; -+ if (air_info->txq_idx >= ARRAY_SIZE(air_info->txq) || -+ !air_info->txq[air_info->txq_idx]) -+ air_info->txq_idx = 0; -+} -+ - 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_coarse_boottime_ns(); -- struct ieee80211_txq *ret = NULL; -+ struct airtime_sched_node *node = NULL; -+ struct ieee80211_txq *txq; - struct airtime_info *air_info; - struct txq_info *txqi = NULL; -- struct rb_node *node; -- bool first = false; -+ u8 txq_idx; - - air_sched = &local->airtime[ac]; - spin_lock_bh(&air_sched->lock); - -- node = air_sched->schedule_pos; -- - begin: -- if (!node) { -- node = rb_first_cached(&air_sched->active_txqs); -- first = true; -- } else { -- node = rb_next(node); -- } -+ txq = NULL; -+ if (airtime_sched_peek(&air_sched->active_txqs) == -+ air_sched->schedule_pos) -+ goto out; - -+ node = airtime_sched_dequeue(&air_sched->active_txqs); - if (!node) - goto out; - -- txqi = container_of(node, struct txq_info, schedule_order); -- air_info = to_airtime_info(&txqi->txq); -+ air_info = container_of(node, struct airtime_info, schedule_order); - -- 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; -+ airtime_info_next_txq_idx(air_info); -+ txq_idx = air_info->txq_idx; -+ txq = air_info->txq[txq_idx]; -+ if (!txq || !ieee80211_txq_airtime_check(hw, txq)) - goto begin; -+ -+ while (1) { -+ txqi = to_txq_info(txq); -+ if (test_and_clear_bit(IEEE80211_TXQ_FORCE_ACTIVE, &txqi->flags)) -+ break; -+ -+ if (txq_has_queue(txq)) -+ break; -+ -+ airtime_info_next_txq_idx(air_info); -+ txq = air_info->txq[air_info->txq_idx]; -+ if (txq_idx == air_info->txq_idx) -+ goto begin; -+ } -+ -+ if (air_info->v_t_cur > air_sched->v_t) { -+ if (node == airtime_sched_peek(&air_sched->active_txqs)) -+ airtime_catchup_v_t(air_sched, air_info->v_t_cur, now); - } - - air_sched->schedule_pos = node; - air_sched->last_schedule_activity = now; -- ret = &txqi->txq; - out: - spin_unlock_bh(&air_sched->lock); -- return ret; -+ return txq; - } - EXPORT_SYMBOL(ieee80211_next_txq); - --static void __ieee80211_insert_txq(struct rb_root_cached *root, -+static void __ieee80211_insert_txq(struct ieee80211_local *local, -+ struct airtime_sched_info *air_sched, - 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); -+ struct airtime_info *air_info = to_airtime_info(&txqi->txq); -+ u32 aql_time = 0; - -- if (new_air->v_t <= old_air->v_t) { -- new = &parent->rb_left; -- } else { -- new = &parent->rb_right; -- leftmost = false; -- } -+ if (wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { -+ aql_time = atomic_read(&air_info->aql_tx_pending); -+ aql_time *= air_info->weight_reciprocal; -+ aql_time >>= IEEE80211_RECIPROCAL_SHIFT_STA - IEEE80211_WEIGHT_SHIFT; - } - -- rb_link_node(&txqi->schedule_order, parent, new); -- rb_insert_color_cached(&txqi->schedule_order, root, leftmost); -+ airtime_sched_delete(&air_sched->active_txqs, &air_info->schedule_order); -+ air_info->v_t_cur = air_info->v_t + aql_time; -+ airtime_sched_insert(&air_sched->active_txqs, &air_info->schedule_order); - } - - 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; -@@ -3902,41 +3927,7 @@ void ieee80211_resort_txq(struct ieee802 - 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); -- } -+ __ieee80211_insert_txq(local, air_sched, txqi); - } - - void ieee80211_update_airtime_weight(struct ieee80211_local *local, -@@ -3985,7 +3976,7 @@ void ieee80211_schedule_txq(struct ieee8 - was_active = airtime_is_active(air_info, now); - airtime_set_active(air_sched, air_info, now); - -- if (!RB_EMPTY_NODE(&txqi->schedule_order)) -+ if (airtime_sched_is_queued(&air_info->schedule_order)) - goto out; - - /* If the station has been inactive for a while, catch up its v_t so it -@@ -3997,7 +3988,7 @@ void ieee80211_schedule_txq(struct ieee8 - 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); -+ __ieee80211_insert_txq(local, air_sched, txqi); - - out: - spin_unlock_bh(&air_sched->lock); -@@ -4023,19 +4014,10 @@ static void __ieee80211_unschedule_txq(s - ieee80211_update_airtime_weight(local, air_sched, 0, true); - } - -- 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); -- -+ airtime_sched_delete(&air_sched->active_txqs, &air_info->schedule_order); - if (!purge) - airtime_set_active(air_sched, air_info, - ktime_get_coarse_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, -@@ -4055,14 +4037,24 @@ void ieee80211_return_txq(struct ieee802 - { - 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->airtime[txq->ac].lock); -+ air_sched = &local->airtime[txq->ac]; -+ air_info = to_airtime_info(&txqi->txq); - -- if (!RB_EMPTY_NODE(&txqi->schedule_order) && !force && -- !txq_has_queue(txq)) -- __ieee80211_unschedule_txq(hw, txq, false); -+ if (force) -+ set_bit(IEEE80211_TXQ_FORCE_ACTIVE, &txqi->flags); - -- spin_unlock_bh(&local->airtime[txq->ac].lock); -+ spin_lock_bh(&air_sched->lock); -+ if (!ieee80211_txq_airtime_check(hw, &txqi->txq)) -+ airtime_sched_delete(&air_sched->active_txqs, -+ &air_info->schedule_order); -+ else if (txq_has_queue(txq) || force) -+ __ieee80211_insert_txq(local, air_sched, txqi); -+ else -+ __ieee80211_unschedule_txq(hw, txq, false); -+ spin_unlock_bh(&air_sched->lock); - } - EXPORT_SYMBOL(ieee80211_return_txq); - -@@ -4101,46 +4093,48 @@ 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 txq_info *txqi = to_txq_info(txq); - struct ieee80211_local *local = hw_to_local(hw); - struct airtime_sched_info *air_sched; -+ struct airtime_sched_node *node = NULL; - struct airtime_info *air_info; -- struct rb_node *node = NULL; - bool ret = false; -+ u32 aql_slack; - u64 now; - -- - if (!ieee80211_txq_airtime_check(hw, txq)) - return false; - - air_sched = &local->airtime[txq->ac]; - spin_lock_bh(&air_sched->lock); - -- if (RB_EMPTY_NODE(&txqi->schedule_order)) -- goto out; -- - now = ktime_get_coarse_boottime_ns(); - - /* 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); -+ node = airtime_sched_peek(&air_sched->active_txqs); - if (node) { -- first_txqi = container_of(node, struct txq_info, -- schedule_order); -- air_info = to_airtime_info(&first_txqi->txq); -+ air_info = container_of(node, struct airtime_info, -+ schedule_order); - - if (air_sched->v_t < air_info->v_t) - airtime_catchup_v_t(air_sched, air_info->v_t, now); - } - - air_info = to_airtime_info(&txqi->txq); -- if (air_info->v_t <= air_sched->v_t) { -+ aql_slack = air_info->aql_limit_low; -+ aql_slack *= air_info->weight_reciprocal; -+ aql_slack >>= IEEE80211_RECIPROCAL_SHIFT_STA - IEEE80211_WEIGHT_SHIFT; -+ /* -+ * add extra slack of aql_limit_low in order to avoid queue -+ * starvation when bypassing normal scheduling order -+ */ -+ if (air_info->v_t <= air_sched->v_t + aql_slack) { - air_sched->last_schedule_activity = now; - ret = true; - } - --out: - spin_unlock_bh(&air_sched->lock); - return ret; - } -@@ -4151,9 +4145,7 @@ void ieee80211_txq_schedule_start(struct - struct ieee80211_local *local = hw_to_local(hw); - struct airtime_sched_info *air_sched = &local->airtime[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/500-mac80211_configure_antenna_gain.patch b/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch index 7473f1ab38..612b9d66ee 100644 --- a/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch +++ b/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch @@ -57,7 +57,7 @@ __NL80211_ATTR_AFTER_LAST, --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c -@@ -2840,6 +2840,19 @@ static int ieee80211_get_tx_power(struct +@@ -2845,6 +2845,19 @@ static int ieee80211_get_tx_power(struct return 0; } @@ -77,7 +77,7 @@ static void ieee80211_rfkill_poll(struct wiphy *wiphy) { struct ieee80211_local *local = wiphy_priv(wiphy); -@@ -4544,6 +4557,7 @@ const struct cfg80211_ops mac80211_confi +@@ -4549,6 +4562,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, diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile index 6b80b3848d..fc26468c49 100644 --- a/package/libs/libusb/Makefile +++ b/package/libs/libusb/Makefile @@ -56,7 +56,7 @@ endef define Package/libusb-1.0/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.so* $(1)/usr/lib/ endef $(eval $(call BuildPackage,libusb-1.0)) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index ee78d72070..36441ea64f 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -9,9 +9,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall4.git -PKG_SOURCE_DATE:=2022-05-31 -PKG_SOURCE_VERSION:=210991df51587bdb736b4fc74b1200ec6cf6ecc7 -PKG_MIRROR_HASH:=486c3fdf7201db8ae51dee7ffac1e80e7b652b27eca9a8174e0fc6f286a457fa +PKG_SOURCE_DATE:=2022-06-17 +PKG_SOURCE_VERSION:=15c38317eff2bdef963cc3032512ce6cf191dadb +PKG_MIRROR_HASH:=cff2beca5ef6c337ce8f0e93466509071dc8c614216b974c4adf4848d67f52e0 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC diff --git a/package/network/config/swconfig/src/uci.c b/package/network/config/swconfig/src/uci.c index f99583b483..200069f94f 100644 --- a/package/network/config/swconfig/src/uci.c +++ b/package/network/config/swconfig/src/uci.c @@ -164,32 +164,7 @@ found: struct uci_element *os; s = uci_to_section(e); - if (!strcmp(s->type, "switch_port")) { - char *devn = NULL, *port = NULL, *port_err = NULL; - int port_n; - - uci_foreach_element(&s->options, os) { - o = uci_to_option(os); - if (o->type != UCI_TYPE_STRING) - continue; - - if (!strcmp(os->name, "device")) { - devn = o->v.string; - if (!swlib_match_name(dev, devn)) - devn = NULL; - } else if (!strcmp(os->name, "port")) { - port = o->v.string; - } - } - if (!devn || !port || !port[0]) - continue; - - port_n = strtoul(port, &port_err, 0); - if (port_err && port_err[0]) - continue; - - swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s); - } else if (!strcmp(s->type, "switch_vlan")) { + if (!strcmp(s->type, "switch_vlan")) { char *devn = NULL, *vlan = NULL, *vlan_err = NULL; int vlan_n; @@ -216,6 +191,38 @@ found: swlib_map_settings(dev, SWLIB_ATTR_GROUP_VLAN, vlan_n, s); } } + uci_foreach_element(&p->sections, e) { + struct uci_element *os; + char *devn = NULL, *port = NULL, *port_err = NULL; + int port_n; + + s = uci_to_section(e); + + if (strcmp(s->type, "switch_port")) + continue; + + uci_foreach_element(&s->options, os) { + o = uci_to_option(os); + if (o->type != UCI_TYPE_STRING) + continue; + + if (!strcmp(os->name, "device")) { + devn = o->v.string; + if (!swlib_match_name(dev, devn)) + devn = NULL; + } else if (!strcmp(os->name, "port")) { + port = o->v.string; + } + } + if (!devn || !port || !port[0]) + continue; + + port_n = strtoul(port, &port_err, 0); + if (port_err && port_err[0]) + continue; + + swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s); + } for (i = 0; i < ARRAY_SIZE(early_settings); i++) { struct swlib_setting *st = &early_settings[i]; diff --git a/package/network/ipv6/464xlat/Makefile b/package/network/ipv6/464xlat/Makefile index c792323235..ab09b1e6dd 100644 --- a/package/network/ipv6/464xlat/Makefile +++ b/package/network/ipv6/464xlat/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=464xlat -PKG_RELEASE:=12 +PKG_RELEASE:=13 PKG_SOURCE_DATE:=2018-01-16 PKG_MAINTAINER:=Hans Dedecker diff --git a/package/network/ipv6/464xlat/files/464xlat.sh b/package/network/ipv6/464xlat/files/464xlat.sh index c90ac1af59..dbe38b3cac 100755 --- a/package/network/ipv6/464xlat/files/464xlat.sh +++ b/package/network/ipv6/464xlat/files/464xlat.sh @@ -98,6 +98,9 @@ proto_464xlat_teardown() { ip -6 rule del from all lookup local ip -6 rule add from all lookup local pref 0 fi + + # Kill conntracks SNATed to 192.0.0.1 + echo 192.0.0.1 > /proc/net/nf_conntrack } proto_464xlat_init_config() { diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index a4640f1197..a3274c8d4d 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -9,9 +9,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_URL:=http://w1.fi/hostap.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2022-05-08 -PKG_SOURCE_VERSION:=b859b9bceadccd882252ff0aa2fdba0d3b91764e -PKG_MIRROR_HASH:=4655a747c197d7622b41865203d6601a080b9750fcd68073688cbb6076d13894 +PKG_SOURCE_DATE:=2022-06-02 +PKG_SOURCE_VERSION:=4383528e01955d995d3b3db201e4c0f9840e8236 +PKG_MIRROR_HASH:=1b533287661d4877d56aca8a5b2a53d84d2a90eebe246d8d9b3adf943da7f0a1 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=BSD-3-Clause diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index 6a3ac7b05f..ea6fb2e591 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -338,6 +338,7 @@ hostapd_common_add_bss_config() { config_add_int sae_pwe config_add_string 'owe_transition_bssid:macaddr' 'owe_transition_ssid:string' + config_add_string owe_transition_ifname config_add_boolean iw_enabled iw_internet iw_asra iw_esr iw_uesa config_add_int iw_access_network_type iw_venue_group iw_venue_type @@ -638,10 +639,11 @@ hostapd_set_bss_options() { case "$auth_type" in none|owe) - json_get_vars owe_transition_bssid owe_transition_ssid + json_get_vars owe_transition_bssid owe_transition_ssid owe_transition_ifname [ -n "$owe_transition_ssid" ] && append bss_conf "owe_transition_ssid=\"$owe_transition_ssid\"" "$N" [ -n "$owe_transition_bssid" ] && append bss_conf "owe_transition_bssid=$owe_transition_bssid" "$N" + [ -n "$owe_transition_ifname" ] && append bss_conf "owe_transition_ifname=$owe_transition_ifname" "$N" wps_possible=1 # Here we make the assumption that if we're in open mode diff --git a/package/network/services/hostapd/patches/991-fix-compile.patch b/package/network/services/hostapd/patches/991-fix-compile.patch new file mode 100644 index 0000000000..d08efa08bd --- /dev/null +++ b/package/network/services/hostapd/patches/991-fix-compile.patch @@ -0,0 +1,19 @@ +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -8104,6 +8104,7 @@ int wpas_network_disabled(struct wpa_sup + !ssid->mem_only_psk) + return 1; + ++#ifdef CONFIG_IEEE8021X_EAPOL + #ifdef CRYPTO_RSA_OAEP_SHA256 + if (ssid->eap.imsi_privacy_cert) { + struct crypto_rsa_key *key; +@@ -8121,7 +8122,7 @@ int wpas_network_disabled(struct wpa_sup + } + } + #endif /* CRYPTO_RSA_OAEP_SHA256 */ +- ++#endif /* CONFIG_IEEE8021X_EAPOL */ + return 0; + } + diff --git a/target/linux/apm821xx/Makefile b/target/linux/apm821xx/Makefile index f36274bd98..875ff225a9 100644 --- a/target/linux/apm821xx/Makefile +++ b/target/linux/apm821xx/Makefile @@ -21,6 +21,6 @@ include $(INCLUDE_DIR)/target.mk KERNELNAME:=uImage DEFAULT_PACKAGES += \ - kmod-leds-gpio kmod-i2c-core kmod-gpio-button-hotplug + kmod-leds-gpio kmod-i2c-core kmod-gpio-button-hotplug uboot-envtools $(eval $(call BuildTarget)) diff --git a/target/linux/apm821xx/dts/meraki-mr24.dts b/target/linux/apm821xx/dts/meraki-mr24.dts index 4b43c683e1..14bedc5984 100644 --- a/target/linux/apm821xx/dts/meraki-mr24.dts +++ b/target/linux/apm821xx/dts/meraki-mr24.dts @@ -180,7 +180,7 @@ keys { compatible = "gpio-keys"; - reset { + button-restart { /* Label as per Meraki's "MR24 Installation Guide" */ label = "Factory Reset Button"; linux,code = ; diff --git a/target/linux/apm821xx/dts/meraki-mx60.dts b/target/linux/apm821xx/dts/meraki-mx60.dts index 79e055c2ea..33f9a3d9f7 100644 --- a/target/linux/apm821xx/dts/meraki-mx60.dts +++ b/target/linux/apm821xx/dts/meraki-mx60.dts @@ -175,7 +175,7 @@ keys { compatible = "gpio-keys"; - reset { + button-restart { label = "Reset button"; linux,code = ; gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>; diff --git a/target/linux/apm821xx/dts/netgear-wndap6x0.dtsi b/target/linux/apm821xx/dts/netgear-wndap6x0.dtsi index 8a15a78dce..144b17950e 100644 --- a/target/linux/apm821xx/dts/netgear-wndap6x0.dtsi +++ b/target/linux/apm821xx/dts/netgear-wndap6x0.dtsi @@ -130,7 +130,7 @@ keys { compatible = "gpio-keys"; - reset { + button-restart { label = "Reset Button"; gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>; linux,code = ; diff --git a/target/linux/apm821xx/dts/netgear-wndr4700.dts b/target/linux/apm821xx/dts/netgear-wndr4700.dts index 342f9a01db..cbfe1235e9 100644 --- a/target/linux/apm821xx/dts/netgear-wndr4700.dts +++ b/target/linux/apm821xx/dts/netgear-wndr4700.dts @@ -355,7 +355,7 @@ keys { compatible = "gpio-keys"; - reset { + button-restart { label = "Reset button"; gpios = <&GPIO0 15 GPIO_ACTIVE_LOW>; linux,code = ; @@ -364,7 +364,7 @@ debounce-interval = <60>; }; - backup_hd { + button-backup_hd { label = "Backup HD button"; gpios = <&GPIO0 19 GPIO_ACTIVE_LOW>; linux,code = ; @@ -373,7 +373,7 @@ debounce-interval = <60>; }; - rfkill { + button-rfkill { label = "RFKILL button"; gpios = <&GPIO0 20 GPIO_ACTIVE_LOW>; linux,code = ; @@ -382,7 +382,7 @@ debounce-interval = <60>; }; - wps { + button-wps { label = "WPS button"; gpios = <&GPIO0 23 GPIO_ACTIVE_LOW>; linux,code = ; diff --git a/target/linux/apm821xx/dts/wd-mybooklive.dts b/target/linux/apm821xx/dts/wd-mybooklive.dts index 2cc4dd8b79..588f45078c 100644 --- a/target/linux/apm821xx/dts/wd-mybooklive.dts +++ b/target/linux/apm821xx/dts/wd-mybooklive.dts @@ -22,7 +22,7 @@ ebc { nor_flash@0,0 { status = "okay"; - compatible = "amd,s29gl512n", "jedec-probe", "cfi-flash", "mtd-rom"; + compatible = "microchip,sst39vf040", "jedec-flash"; bank-width = <1>; reg = <0x00000000 0x00000000 0x00080000>; #address-cells = <1>; @@ -32,16 +32,19 @@ /* Part of bootrom - Don't use it without a jump */ label = "free"; reg = <0x00000000 0x0001e000>; + read-only; }; partition@1e000 { label = "env"; reg = <0x0001e000 0x00002000>; + read-only; }; partition@20000 { label = "uboot"; reg = <0x00020000 0x00050000>; + read-only; }; }; }; @@ -113,7 +116,7 @@ poll-interval = <60>; /* 3 * 20 = 60ms */ autorepeat; - reset-button { + button-restart { label = "Reset button"; linux,code = ; gpios = <&GPIO2 2 GPIO_ACTIVE_LOW>; diff --git a/target/linux/apm821xx/sata/config-default b/target/linux/apm821xx/sata/config-default index e8e595641d..563fa60478 100644 --- a/target/linux/apm821xx/sata/config-default +++ b/target/linux/apm821xx/sata/config-default @@ -35,6 +35,8 @@ CONFIG_MD_RAID0=y CONFIG_MD_RAID1=y # CONFIG_MD_RAID10 is not set # CONFIG_MD_RAID456 is not set +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_JEDECPROBE=y CONFIG_PM=y CONFIG_PM_AUTOSLEEP=y CONFIG_PM_CLK=y diff --git a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi index 5b4b6e3dda..aa696f6ab5 100644 --- a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi +++ b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi @@ -58,8 +58,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; }; diff --git a/target/linux/ath79/dts/ar7161_aruba_ap-105.dts b/target/linux/ath79/dts/ar7161_aruba_ap-105.dts index 8180e0d6bd..da68ada2c0 100644 --- a/target/linux/ath79/dts/ar7161_aruba_ap-105.dts +++ b/target/linux/ath79/dts/ar7161_aruba_ap-105.dts @@ -125,8 +125,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; }; diff --git a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts index f2809f0549..8188027c4c 100644 --- a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts +++ b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts @@ -103,8 +103,6 @@ #size-cells = <0>; status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts index 826b45ff51..4ee99432d4 100644 --- a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts +++ b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts @@ -73,8 +73,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar7161_meraki_mr16.dts b/target/linux/ath79/dts/ar7161_meraki_mr16.dts index d672364e56..eb27e16e56 100644 --- a/target/linux/ath79/dts/ar7161_meraki_mr16.dts +++ b/target/linux/ath79/dts/ar7161_meraki_mr16.dts @@ -107,8 +107,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; }; diff --git a/target/linux/ath79/dts/ar7161_netgear_wndap360.dts b/target/linux/ath79/dts/ar7161_netgear_wndap360.dts index aeb7c56773..37a475d3ac 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndap360.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndap360.dts @@ -62,7 +62,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x0f>; phy1: ethernet-phy@1 { reg = <0x1>; }; diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi b/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi index afbccb8016..c66348e71e 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi +++ b/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi @@ -110,8 +110,6 @@ #size-cells = <0>; status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi b/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi index df28111598..18e524f802 100644 --- a/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi +++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi @@ -123,8 +123,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts index fa3c47354e..f454725f6a 100644 --- a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts +++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts @@ -179,8 +179,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar7242_ubnt_edgeswitch-8xp.dts b/target/linux/ath79/dts/ar7242_ubnt_edgeswitch-8xp.dts index 0c2fe394d4..915b4414dd 100644 --- a/target/linux/ath79/dts/ar7242_ubnt_edgeswitch-8xp.dts +++ b/target/linux/ath79/dts/ar7242_ubnt_edgeswitch-8xp.dts @@ -110,8 +110,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x10>; - ethernet-switch@1e { compatible = "brcm,bcm53128"; reg = <0x1e>; diff --git a/target/linux/ath79/dts/ar9132_buffalo_wzr-hp-g300nh.dtsi b/target/linux/ath79/dts/ar9132_buffalo_wzr-hp-g300nh.dtsi index 7b0c09f68e..a84e794c0b 100644 --- a/target/linux/ath79/dts/ar9132_buffalo_wzr-hp-g300nh.dtsi +++ b/target/linux/ath79/dts/ar9132_buffalo_wzr-hp-g300nh.dtsi @@ -191,7 +191,6 @@ #address-cells = <1>; #size-cells = <0>; - phy-mask = <0x10>; phy4: ethernet-phy@4 { reg = <4>; diff --git a/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts index 82ab3ba91e..6435393a73 100644 --- a/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts +++ b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts @@ -200,8 +200,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; }; diff --git a/target/linux/ath79/dts/ar9342_ubnt_aircube-ac.dts b/target/linux/ath79/dts/ar9342_ubnt_aircube-ac.dts index 15e23f2421..e93c1b8dab 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_aircube-ac.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_aircube-ac.dts @@ -78,7 +78,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy0: ethernet-phy@0 { phy-mode = "rgmii"; reg = <0>; diff --git a/target/linux/ath79/dts/ar9342_ubnt_bullet-m-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_bullet-m-xw.dts index 0101820ecd..c448ac4e61 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_bullet-m-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_bullet-m-xw.dts @@ -10,7 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy4: ethernet-phy@4 { phy-mode = "rgmii"; reg = <4>; diff --git a/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5-xw.dts index 86a5e3a751..9b9b217f24 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5-xw.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy1: ethernet-phy@1 { reg = <1>; phy-mode = "mii"; diff --git a/target/linux/ath79/dts/ar9342_ubnt_nanostation-loco-m-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_nanostation-loco-m-xw.dts index 5a7448eb19..c71cf11dd2 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_nanostation-loco-m-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_nanostation-loco-m-xw.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy1: ethernet-phy@1 { reg = <1>; phy-mode = "mii"; diff --git a/target/linux/ath79/dts/ar9342_ubnt_nanostation-m-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_nanostation-m-xw.dts index c8e153e54f..e359297661 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_nanostation-m-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_nanostation-m-xw.dts @@ -11,7 +11,6 @@ status = "okay"; phy4-mii-enable; - phy-mask = <0x23>; phy0: ethernet-phy@0 { reg = <0>; diff --git a/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m2-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m2-xw.dts index 046715b00a..762a17b177 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m2-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m2-xw.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; - phy1: ethernet-phy@1 { reg = <1>; }; diff --git a/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m5-xw.dts b/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m5-xw.dts index e5a9af3905..978a05fed6 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m5-xw.dts +++ b/target/linux/ath79/dts/ar9342_ubnt_powerbeam-m5-xw.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; - phy4: ethernet-phy@4 { reg = <4>; }; diff --git a/target/linux/ath79/dts/ar9342_ubnt_wa_1port.dtsi b/target/linux/ath79/dts/ar9342_ubnt_wa_1port.dtsi index 045cbe8985..2b943fe7ea 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_wa_1port.dtsi +++ b/target/linux/ath79/dts/ar9342_ubnt_wa_1port.dtsi @@ -5,8 +5,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; - phy4: ethernet-phy@4 { reg = <4>; }; diff --git a/target/linux/ath79/dts/ar9342_ubnt_wa_2port.dtsi b/target/linux/ath79/dts/ar9342_ubnt_wa_2port.dtsi index 2567c77759..13ddd800d3 100644 --- a/target/linux/ath79/dts/ar9342_ubnt_wa_2port.dtsi +++ b/target/linux/ath79/dts/ar9342_ubnt_wa_2port.dtsi @@ -5,8 +5,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; - phy0: ethernet-phy@0 { phy-mode = "rgmii"; reg = <0>; diff --git a/target/linux/ath79/dts/ar9344_atheros_db120.dts b/target/linux/ath79/dts/ar9344_atheros_db120.dts index 625a8e4fa2..906335ed6f 100644 --- a/target/linux/ath79/dts/ar9344_atheros_db120.dts +++ b/target/linux/ath79/dts/ar9344_atheros_db120.dts @@ -159,8 +159,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; diff --git a/target/linux/ath79/dts/ar9344_compex_wpj344-16m.dts b/target/linux/ath79/dts/ar9344_compex_wpj344-16m.dts index 8d42f0c211..e456f1f0e5 100644 --- a/target/linux/ath79/dts/ar9344_compex_wpj344-16m.dts +++ b/target/linux/ath79/dts/ar9344_compex_wpj344-16m.dts @@ -116,8 +116,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi b/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi index e591ecd1b8..dded9d6655 100644 --- a/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi +++ b/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi @@ -36,8 +36,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; qca,ar8327-initvals = < diff --git a/target/linux/ath79/dts/ar9344_netgear_pgzng1.dts b/target/linux/ath79/dts/ar9344_netgear_pgzng1.dts new file mode 100644 index 0000000000..5b91dd1e4d --- /dev/null +++ b/target/linux/ath79/dts/ar9344_netgear_pgzng1.dts @@ -0,0 +1,333 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include "ar9344.dtsi" + +#include +#include +#include +#include + +/ { + model = "Netgear PGZNG1"; + compatible = "netgear,pgzng1", "qca,ar9344"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_red; + led-running = &led_power_green; + led-upgrade = &led_power_green; + label-mac-device = ð0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + i2c { + compatible = "i2c-gpio"; + sda-gpios = <&gpio 14 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio 13 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + #address-cells = <1>; + #size-cells = <0>; + + expander0: pca9551@60 { + compatible = "nxp,pca9551"; + reg = <0x60>; + #address-cells = <1>; + #size-cells = <0>; + + led_power_green: led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_BOOT; + type = ; + chan-name = "green:boot"; + }; + + led_power_red: led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_BOOT; + type = ; + chan-name = "red:boot"; + }; + + led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_WAN; + function-enumerator = <1>; + type = ; + }; + + led@3 { + reg = <3>; + color = ; + function = LED_FUNCTION_WAN; + type = ; + }; + + led@4 { + reg = <4>; + color = ; + function = LED_FUNCTION_WLAN; + type = ; + }; + + led@5 { + reg = <5>; + color = ; + function = LED_FUNCTION_WLAN; + type = ; + }; + + led@6 { + reg = <6>; + color = ; + function = LED_FUNCTION_INDICATOR; + type = ; + }; + + led@7 { + reg = <7>; + color = ; + function = LED_FUNCTION_INDICATOR; + type = ; + }; + }; + + expander1: pca9551@61 { + compatible = "nxp,pca9551"; + reg = <0x61>; + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + /* zwave_rst - Resets ZWave */ + gpio@4 { + reg = <4>; + type = ; + }; + + /* em_rst - Unknown */ + gpio@5 { + reg = <5>; + type = ; + }; + + /* tp34 - Test point on PCB? */ + gpio@6 { + reg = <6>; + type = ; + }; + + /* sw_rst - resets SoC */ + gpio@7 { + reg = <7>; + type = ; + }; + }; + + rtc@6f { + compatible = "isil,isl1208"; + reg = <0x6f>; + }; + }; + + leds { + compatible = "gpio-leds"; + + eth1_link { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + }; + + eth1_act { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; + + eth0_link { + color = ; + function = LED_FUNCTION_WAN; + function-enumerator = <0>; + gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + }; + + eth0_act { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + }; +}; + +ð0 { + status = "okay"; + phy-handle = <&swphy0>; + + nvmem-cells = <&macaddr_caldata_6>; + nvmem-cell-names = "mac-address"; +}; + +ð1 { + status = "okay"; + phy-handle = <&swphy4>; + + nvmem-cells = <&macaddr_caldata_0>; + nvmem-cell-names = "mac-address"; + + gmac-config { + device = <&gmac>; + switch-phy-swap = <1>; + switch-only-mode = <1>; + }; +}; + +&gpio { + gpio_ext_lna0 { + gpio-hog; + line-name = "ext:lna0"; + gpios = <18 GPIO_ACTIVE_HIGH>; + output-high; + }; + + gpio_ext_lna1 { + gpio-hog; + line-name = "ext:lna1"; + gpios = <19 GPIO_ACTIVE_HIGH>; + output-high; + }; + + gpio_enable_rs422 { + gpio-hog; + line-name = "power:rs422"; + gpios = <20 GPIO_ACTIVE_HIGH>; + output-high; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x40000 0x40000>; + read-only; + }; + + /* factory kernel used to be reg = <0x80000 0x200000> */ + partition@80000 { + label = "kernel"; + reg = <0x80000 0x500000>; + }; + + /* factory rootfs used to be reg = <0x280000 0x5000000> */ + partition@580000 { + label = "ubi"; + reg = <0x580000 0x4d00000>; + }; + + partition@5280000 { + label = "uImage2"; + reg = <0x5280000 0x200000>; + read-only; + }; + + partition@5480000 { + label = "rootfs_bak"; + reg = <0x5480000 0x5000000>; + read-only; + }; + + partition@a480000 { + label = "config"; + reg = <0xa480000 0x1400000>; + read-only; + }; + + partition@b880000 { + label = "storage"; + reg = <0xb880000 0x4700000>; + read-only; + }; + + partition@ff80000 { + label = "dummy"; + reg = <0xff80000 0x60000>; + read-only; + }; + + caldata: partition@ffe0000 { + label = "caldata"; + reg = <0xffe0000 0x20000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_caldata_0: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_caldata_6: macaddr@6 { + reg = <0x6 0x6>; + }; + + cal_caldata_1000: cal@1000 { + reg = <0x1000 0x440>; + }; + }; + }; +}; + +&ref { + clock-frequency = <40000000>; +}; + +/* zWave is wired up via SPI and UART1 (no idea on pins sadly) */ +&spi { + status = "okay"; +}; + +&wmac { + status = "okay"; + + nvmem-cells = <&cal_caldata_1000>; + nvmem-cell-names = "calibration"; +}; + +&usb { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi index c075c38557..077bbe4bf1 100644 --- a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi +++ b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi @@ -192,8 +192,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts b/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts index 0bbeb2b533..8ac035f125 100644 --- a/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts +++ b/target/linux/ath79/dts/ar9344_ocedo_raccoon.dts @@ -148,8 +148,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/ar9344_openmesh_mr600.dtsi b/target/linux/ath79/dts/ar9344_openmesh_mr600.dtsi index bbbcc3e0b6..5a6ef3b0fc 100644 --- a/target/linux/ath79/dts/ar9344_openmesh_mr600.dtsi +++ b/target/linux/ath79/dts/ar9344_openmesh_mr600.dtsi @@ -82,8 +82,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts b/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts index e15e296f82..1925031e0b 100644 --- a/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts +++ b/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts @@ -160,8 +160,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x80>; - phy7: ethernet-phy@7 { reg = <7>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/ar9344_pcs_cap324.dts b/target/linux/ath79/dts/ar9344_pcs_cap324.dts index 6ebd6a43bb..ea7077d2c8 100644 --- a/target/linux/ath79/dts/ar9344_pcs_cap324.dts +++ b/target/linux/ath79/dts/ar9344_pcs_cap324.dts @@ -142,8 +142,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_pcs_cr5000.dts b/target/linux/ath79/dts/ar9344_pcs_cr5000.dts index 7b99ef7373..d4b198b3f5 100644 --- a/target/linux/ath79/dts/ar9344_pcs_cr5000.dts +++ b/target/linux/ath79/dts/ar9344_pcs_cr5000.dts @@ -135,8 +135,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-16m.dts b/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-16m.dts index 195ab9db20..ecc3d8b8cd 100644 --- a/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-16m.dts +++ b/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-16m.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-8m.dts b/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-8m.dts index b81a7f7778..e2152ff464 100644 --- a/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-8m.dts +++ b/target/linux/ath79/dts/ar9344_qxwlan_e750g-v8-8m.dts @@ -10,8 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300.dtsi b/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300.dtsi index 262c6f713e..546cf49f34 100644 --- a/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300.dtsi +++ b/target/linux/ath79/dts/ar9344_tplink_tl-wdr4300.dtsi @@ -93,8 +93,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; diff --git a/target/linux/ath79/dts/ar9344_wd_mynet-n750.dts b/target/linux/ath79/dts/ar9344_wd_mynet-n750.dts index d1f63c5064..f4a18b051f 100644 --- a/target/linux/ath79/dts/ar9344_wd_mynet-n750.dts +++ b/target/linux/ath79/dts/ar9344_wd_mynet-n750.dts @@ -94,8 +94,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - switch0@1f { compatible = "qca,ar8327"; reg = <0x1f>; diff --git a/target/linux/ath79/dts/ar9344_wd_mynet-wifi-rangeextender.dts b/target/linux/ath79/dts/ar9344_wd_mynet-wifi-rangeextender.dts index 7313e9acc2..20dad6a675 100644 --- a/target/linux/ath79/dts/ar9344_wd_mynet-wifi-rangeextender.dts +++ b/target/linux/ath79/dts/ar9344_wd_mynet-wifi-rangeextender.dts @@ -134,8 +134,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; }; diff --git a/target/linux/ath79/dts/ar9344_winchannel_wb2000.dts b/target/linux/ath79/dts/ar9344_winchannel_wb2000.dts index 2586a174cb..f27a58b8d7 100644 --- a/target/linux/ath79/dts/ar9344_winchannel_wb2000.dts +++ b/target/linux/ath79/dts/ar9344_winchannel_wb2000.dts @@ -187,8 +187,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; }; diff --git a/target/linux/ath79/dts/qca9533_dlink_dap-2230-a1.dts b/target/linux/ath79/dts/qca9533_dlink_dap-2230-a1.dts index 3717a35ae3..90383690b9 100644 --- a/target/linux/ath79/dts/qca9533_dlink_dap-2230-a1.dts +++ b/target/linux/ath79/dts/qca9533_dlink_dap-2230-a1.dts @@ -46,10 +46,4 @@ reg = <0xf50000 0xa0000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x10000>; - read-only; - }; }; diff --git a/target/linux/ath79/dts/qca9533_dlink_dap-3320-a1.dts b/target/linux/ath79/dts/qca9533_dlink_dap-3320-a1.dts index c186a7ee44..5758b0d2a3 100644 --- a/target/linux/ath79/dts/qca9533_dlink_dap-3320-a1.dts +++ b/target/linux/ath79/dts/qca9533_dlink_dap-3320-a1.dts @@ -46,10 +46,4 @@ reg = <0xf60000 0x90000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x10000>; - read-only; - }; }; diff --git a/target/linux/ath79/dts/qca953x_dlink_dap-2xxx.dtsi b/target/linux/ath79/dts/qca953x_dlink_dap-2xxx.dtsi index 71d9fffbe3..13d41f7bd5 100644 --- a/target/linux/ath79/dts/qca953x_dlink_dap-2xxx.dtsi +++ b/target/linux/ath79/dts/qca953x_dlink_dap-2xxx.dtsi @@ -41,6 +41,20 @@ reg = <0x60000 0x10000>; read-only; }; + + partition@ff0000 { + label = "art"; + reg = <0xff0000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + cal_ath9k: calibration@1000 { + reg = <0x1000 0x440>; + }; + }; }; }; }; @@ -48,5 +62,6 @@ &wmac { status = "okay"; - mtd-cal-data = <&art 0x1000>; + nvmem-cells = <&cal_ath9k>; + nvmem-cell-names = "calibration"; }; diff --git a/target/linux/ath79/dts/qca9557_dlink_dap-2660-a1.dts b/target/linux/ath79/dts/qca9557_dlink_dap-2660-a1.dts index 622f4410b3..93e2fc0d97 100644 --- a/target/linux/ath79/dts/qca9557_dlink_dap-2660-a1.dts +++ b/target/linux/ath79/dts/qca9557_dlink_dap-2660-a1.dts @@ -51,12 +51,6 @@ reg = <0xf50000 0xa0000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x10000>; - read-only; - }; }; &mdio0 { @@ -85,4 +79,18 @@ &pcie0 { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + nvmem-cells = <&cal_ath10k>; + nvmem-cell-names = "calibration"; + }; +}; + +&art { + cal_ath10k: calibration@5000 { + reg = <0x5000 0x844>; + }; }; diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts index 7549c0a697..c398dd637f 100644 --- a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts +++ b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts @@ -51,12 +51,6 @@ reg = <0xf50000 0xa0000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x10000>; - read-only; - }; }; &mdio0 { @@ -85,4 +79,18 @@ &pcie0 { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + nvmem-cells = <&precal_ath10k>; + nvmem-cell-names = "pre-calibration"; + }; +}; + +&art { + precal_ath10k: pre-calibration@5000 { + reg = <0x5000 0x2f20>; + }; }; diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-2695-a1.dts b/target/linux/ath79/dts/qca9558_dlink_dap-2695-a1.dts index f5a350b33f..1985fa48d8 100644 --- a/target/linux/ath79/dts/qca9558_dlink_dap-2695-a1.dts +++ b/target/linux/ath79/dts/qca9558_dlink_dap-2695-a1.dts @@ -63,12 +63,6 @@ reg = <0xfe0000 0x010000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x010000>; - read-only; - }; }; &mdio0 { @@ -101,7 +95,6 @@ ð1 { status = "okay"; - phy-mask = <0>; pll-data = <0x03000101 0x00000101 0x00001616>; fixed-link { @@ -112,4 +105,18 @@ &pcie0 { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + nvmem-cells = <&cal_ath10k>; + nvmem-cell-names = "calibration"; + }; +}; + +&art { + cal_ath10k: calibration@5000 { + reg = <0x5000 0x844>; + }; }; diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-3662-a1.dts b/target/linux/ath79/dts/qca9558_dlink_dap-3662-a1.dts index 55ac061a56..27883f721c 100644 --- a/target/linux/ath79/dts/qca9558_dlink_dap-3662-a1.dts +++ b/target/linux/ath79/dts/qca9558_dlink_dap-3662-a1.dts @@ -51,12 +51,6 @@ reg = <0xf60000 0x90000>; read-only; }; - - art: partition@ff0000 { - label = "art"; - reg = <0xff0000 0x10000>; - read-only; - }; }; &mdio0 { @@ -99,4 +93,18 @@ &pcie0 { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + nvmem-cells = <&cal_ath10k>; + nvmem-cell-names = "calibration"; + }; +}; + +&art { + cal_ath10k: calibration@5000 { + reg = <0x5000 0x844>; + }; }; diff --git a/target/linux/ath79/dts/qca9558_openmesh_a60.dtsi b/target/linux/ath79/dts/qca9558_openmesh_a60.dtsi index 05d3a4f341..c2062a800a 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_a60.dtsi +++ b/target/linux/ath79/dts/qca9558_openmesh_a60.dtsi @@ -119,8 +119,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x6>; - phy1: ethernet-phy@1 { reg = <1>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/qca9558_openmesh_mr.dtsi b/target/linux/ath79/dts/qca9558_openmesh_mr.dtsi index 8c4856f1ea..8e11760daf 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_mr.dtsi +++ b/target/linux/ath79/dts/qca9558_openmesh_mr.dtsi @@ -127,8 +127,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x20>; - phy5: ethernet-phy@5 { reg = <5>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts index de21f0119f..147b98f925 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts @@ -138,8 +138,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x6>; - phy1: ethernet-phy@1 { reg = <1>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts index 91a53343ae..1ce924b8a0 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts @@ -168,8 +168,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; eee-broken-100tx; @@ -180,8 +178,6 @@ &mdio1 { status = "okay"; - phy-mask = <0x2>; - phy1: ethernet-phy@1 { reg = <1>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/qca9558_sophos_ap.dtsi b/target/linux/ath79/dts/qca9558_sophos_ap.dtsi index 5c79d19de0..c9f3aefbbf 100644 --- a/target/linux/ath79/dts/qca9558_sophos_ap.dtsi +++ b/target/linux/ath79/dts/qca9558_sophos_ap.dtsi @@ -121,8 +121,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; eee-broken-100tx; diff --git a/target/linux/ath79/dts/qca9558_ubnt_nanobeam-ac-xc.dts b/target/linux/ath79/dts/qca9558_ubnt_nanobeam-ac-xc.dts index 14388079b6..dce88ac218 100644 --- a/target/linux/ath79/dts/qca9558_ubnt_nanobeam-ac-xc.dts +++ b/target/linux/ath79/dts/qca9558_ubnt_nanobeam-ac-xc.dts @@ -81,7 +81,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy4: ethernet-phy@4 { phy-mode = "sgmii"; reg = <4>; diff --git a/target/linux/ath79/dts/qca9558_ubnt_powerbeam-5ac-500.dts b/target/linux/ath79/dts/qca9558_ubnt_powerbeam-5ac-500.dts index 9d3d1395f9..3827a94b24 100644 --- a/target/linux/ath79/dts/qca9558_ubnt_powerbeam-5ac-500.dts +++ b/target/linux/ath79/dts/qca9558_ubnt_powerbeam-5ac-500.dts @@ -21,7 +21,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy4: ethernet-phy@4 { phy-mode = "sgmii"; reg = <4>; diff --git a/target/linux/ath79/dts/qca9558_ubnt_rocket-5ac-lite.dts b/target/linux/ath79/dts/qca9558_ubnt_rocket-5ac-lite.dts index 0458fcaa4d..836211ccd5 100644 --- a/target/linux/ath79/dts/qca9558_ubnt_rocket-5ac-lite.dts +++ b/target/linux/ath79/dts/qca9558_ubnt_rocket-5ac-lite.dts @@ -21,7 +21,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy4: ethernet-phy@4 { phy-mode = "sgmii"; reg = <4>; diff --git a/target/linux/ath79/dts/qca955x_dlink_dap-2xxx.dtsi b/target/linux/ath79/dts/qca955x_dlink_dap-2xxx.dtsi index 1047dfddeb..3e254fa494 100644 --- a/target/linux/ath79/dts/qca955x_dlink_dap-2xxx.dtsi +++ b/target/linux/ath79/dts/qca955x_dlink_dap-2xxx.dtsi @@ -41,6 +41,20 @@ reg = <0x60000 0x10000>; read-only; }; + + art: partition@ff0000 { + label = "art"; + reg = <0xff0000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + cal_ath9k: calibration@1000 { + reg = <0x1000 0x440>; + }; + }; }; }; }; @@ -48,5 +62,6 @@ &wmac { status = "okay"; - mtd-cal-data = <&art 0x1000>; + nvmem-cells = <&cal_ath9k>; + nvmem-cell-names = "calibration"; }; diff --git a/target/linux/ath79/dts/qca9561_tplink_eap225-wall-v2.dts b/target/linux/ath79/dts/qca9561_tplink_eap225-wall-v2.dts index ecb427029d..439549d142 100644 --- a/target/linux/ath79/dts/qca9561_tplink_eap225-wall-v2.dts +++ b/target/linux/ath79/dts/qca9561_tplink_eap225-wall-v2.dts @@ -58,6 +58,16 @@ &pcie { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&precalibration_ath10k>; + nvmem-cell-names = "mac-address", "pre-calibration"; + }; }; &spi { @@ -121,6 +131,18 @@ label = "art"; reg = <0xff0000 0x010000>; read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + calibration_ath9k: calibration@1000 { + reg = <0x1000 0x440>; + }; + + precalibration_ath10k: pre-calibration@5000 { + reg = <0x5000 0x2f20>; + }; }; }; }; @@ -136,9 +158,8 @@ &wmac { status = "okay"; - mtd-cal-data = <&art 0x1000>; - nvmem-cells = <&macaddr_info_8>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_info_8>, <&calibration_ath9k>; + nvmem-cell-names = "mac-address", "calibration"; }; &info { diff --git a/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts b/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts index c4b6483497..ac3551d115 100644 --- a/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts +++ b/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts @@ -134,8 +134,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@3 { reg = <0x3>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_comfast_cf-e375ac.dts b/target/linux/ath79/dts/qca9563_comfast_cf-e375ac.dts index 1337341b0b..20c9700952 100644 --- a/target/linux/ath79/dts/qca9563_comfast_cf-e375ac.dts +++ b/target/linux/ath79/dts/qca9563_comfast_cf-e375ac.dts @@ -104,8 +104,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_compex_wpj563.dts b/target/linux/ath79/dts/qca9563_compex_wpj563.dts index ba31f40fe2..ceac53f415 100644 --- a/target/linux/ath79/dts/qca9563_compex_wpj563.dts +++ b/target/linux/ath79/dts/qca9563_compex_wpj563.dts @@ -99,8 +99,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_dlink_dir-842-c.dtsi b/target/linux/ath79/dts/qca9563_dlink_dir-842-c.dtsi index 1366e68a8f..a42deaddaf 100644 --- a/target/linux/ath79/dts/qca9563_dlink_dir-842-c.dtsi +++ b/target/linux/ath79/dts/qca9563_dlink_dir-842-c.dtsi @@ -121,8 +121,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; qca,mib-poll-interval = <500>; diff --git a/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts b/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts index e409b5da3e..804f3434c3 100644 --- a/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts +++ b/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts @@ -128,8 +128,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi index 878a740cfd..d3562398bc 100644 --- a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi @@ -139,8 +139,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi index 6090fdf527..0fdabb6f19 100644 --- a/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi +++ b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi @@ -176,8 +176,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_phicomm_k2t.dts b/target/linux/ath79/dts/qca9563_phicomm_k2t.dts index 63e2e53aa5..9dbb291295 100644 --- a/target/linux/ath79/dts/qca9563_phicomm_k2t.dts +++ b/target/linux/ath79/dts/qca9563_phicomm_k2t.dts @@ -99,8 +99,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_qxwlan_e1700ac.dtsi b/target/linux/ath79/dts/qca9563_qxwlan_e1700ac.dtsi index 91c73567d8..8902e1726c 100644 --- a/target/linux/ath79/dts/qca9563_qxwlan_e1700ac.dtsi +++ b/target/linux/ath79/dts/qca9563_qxwlan_e1700ac.dtsi @@ -96,8 +96,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_rosinson_wr818.dts b/target/linux/ath79/dts/qca9563_rosinson_wr818.dts index c08291560b..c80e1c9d7a 100644 --- a/target/linux/ath79/dts/qca9563_rosinson_wr818.dts +++ b/target/linux/ath79/dts/qca9563_rosinson_wr818.dts @@ -92,7 +92,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-c2-v3.dts b/target/linux/ath79/dts/qca9563_tplink_archer-c2-v3.dts index 81c25fc01d..6d5a21c138 100644 --- a/target/linux/ath79/dts/qca9563_tplink_archer-c2-v3.dts +++ b/target/linux/ath79/dts/qca9563_tplink_archer-c2-v3.dts @@ -141,7 +141,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts b/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts index 4334475ff7..2fdce55d0e 100644 --- a/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts +++ b/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts @@ -226,8 +226,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-x6-v2.dtsi b/target/linux/ath79/dts/qca9563_tplink_archer-x6-v2.dtsi index fc6206d891..34f639f40b 100644 --- a/target/linux/ath79/dts/qca9563_tplink_archer-x6-v2.dtsi +++ b/target/linux/ath79/dts/qca9563_tplink_archer-x6-v2.dtsi @@ -12,8 +12,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi b/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi index 6763fe9d3d..fd0f10ff27 100644 --- a/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi +++ b/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi @@ -137,8 +137,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_cpe710-v1.dts b/target/linux/ath79/dts/qca9563_tplink_cpe710-v1.dts index c97d1652cb..9421ea225a 100644 --- a/target/linux/ath79/dts/qca9563_tplink_cpe710-v1.dts +++ b/target/linux/ath79/dts/qca9563_tplink_cpe710-v1.dts @@ -117,8 +117,6 @@ pinctrl-names = "default"; pinctrl-0 = <&mdio_pins>; - phy-mask = <0x10>; - phy4: ethernet-phy@4 { reg = <4>; reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9563_tplink_deco-m4r-v1.dts b/target/linux/ath79/dts/qca9563_tplink_deco-m4r-v1.dts index 26bb906910..4b2d80aa82 100644 --- a/target/linux/ath79/dts/qca9563_tplink_deco-m4r-v1.dts +++ b/target/linux/ath79/dts/qca9563_tplink_deco-m4r-v1.dts @@ -57,7 +57,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; diff --git a/target/linux/ath79/dts/qca9563_tplink_eap225-outdoor-v1.dts b/target/linux/ath79/dts/qca9563_tplink_eap225-outdoor-v1.dts index fc6d3365a0..79c45f1ea8 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap225-outdoor-v1.dts +++ b/target/linux/ath79/dts/qca9563_tplink_eap225-outdoor-v1.dts @@ -28,3 +28,33 @@ }; }; }; + +&art { + precalibration_ath10k: pre-calibration@5000 { + reg = <0x5000 0x2f20>; + }; +}; + +ð0 { + phy-handle = <&phy4>; + phy-mode = "sgmii"; +}; + +&mdio0 { + phy4: ethernet-phy@4 { + reg = <4>; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; +}; + +&pcie { + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&precalibration_ath10k>; + nvmem-cell-names = "mac-address", "pre-calibration"; + }; +}; diff --git a/target/linux/ath79/dts/qca9563_tplink_eap225-v1.dts b/target/linux/ath79/dts/qca9563_tplink_eap225-v1.dts index 20fd55b409..8423daf602 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap225-v1.dts +++ b/target/linux/ath79/dts/qca9563_tplink_eap225-v1.dts @@ -49,3 +49,33 @@ }; }; }; + +&art { + calibration_ath10k: calibration@5000 { + reg = <0x5000 0x844>; + }; +}; + +ð0 { + phy-handle = <&phy4>; + phy-mode = "sgmii"; +}; + +&mdio0 { + phy4: ethernet-phy@4 { + reg = <4>; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; +}; + +&pcie { + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&calibration_ath10k>; + nvmem-cell-names = "mac-address", "calibration"; + }; +}; diff --git a/target/linux/ath79/dts/qca9563_tplink_eap225-v3.dts b/target/linux/ath79/dts/qca9563_tplink_eap225-v3.dts index 3d4950eaf0..290172b0cc 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap225-v3.dts +++ b/target/linux/ath79/dts/qca9563_tplink_eap225-v3.dts @@ -28,3 +28,33 @@ }; }; }; + +&art { + precalibration_ath10k: pre-calibration@5000 { + reg = <0x5000 0x2f20>; + }; +}; + +ð0 { + phy-handle = <&phy4>; + phy-mode = "sgmii"; +}; + +&mdio0 { + phy4: ethernet-phy@4 { + reg = <4>; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; +}; + +&pcie { + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&precalibration_ath10k>; + nvmem-cell-names = "mac-address", "pre-calibration"; + }; +}; diff --git a/target/linux/ath79/dts/qca9563_tplink_eap245-v1.dts b/target/linux/ath79/dts/qca9563_tplink_eap245-v1.dts index 3da450192c..236c9e7457 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap245-v1.dts +++ b/target/linux/ath79/dts/qca9563_tplink_eap245-v1.dts @@ -42,3 +42,33 @@ }; }; }; + +&art { + calibration_ath10k: calibration@5000 { + reg = <0x5000 0x844>; + }; +}; + +ð0 { + phy-handle = <&phy4>; + phy-mode = "sgmii"; +}; + +&mdio0 { + phy4: ethernet-phy@4 { + reg = <4>; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; +}; + +&pcie { + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&calibration_ath10k>; + nvmem-cell-names = "mac-address", "calibration"; + }; +}; diff --git a/target/linux/ath79/dts/qca9563_tplink_eap245-v3.dts b/target/linux/ath79/dts/qca9563_tplink_eap245-v3.dts index 5d789d7869..ab5bc7b1a9 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap245-v3.dts +++ b/target/linux/ath79/dts/qca9563_tplink_eap245-v3.dts @@ -46,6 +46,16 @@ &pcie { status = "okay"; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + mac-address-increment = <1>; + + nvmem-cells = <&macaddr_info_8>, <&calibration_ath10k>; + nvmem-cell-names = "mac-address", "pre-calibration"; + }; }; &spi { @@ -85,10 +95,22 @@ read-only; }; - art: partition@a0000 { + partition@a0000 { label = "art"; reg = <0x0a0000 0x010000>; read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + calibration_ath9k: calibration@1000 { + reg = <0x1000 0x440>; + }; + + calibration_ath10k: calibration@5000 { + reg = <0x5000 0x2f20>; + }; }; partition@b0000 { @@ -127,8 +149,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; @@ -153,9 +173,8 @@ &wmac { status = "okay"; - mtd-cal-data = <&art 0x1000>; - nvmem-cells = <&macaddr_info_8>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_info_8>, <&calibration_ath9k>; + nvmem-cell-names = "mac-address", "calibration"; }; &info { diff --git a/target/linux/ath79/dts/qca9563_tplink_eap2x5-1port.dtsi b/target/linux/ath79/dts/qca9563_tplink_eap2x5-1port.dtsi index e10c5dbb73..f384031335 100644 --- a/target/linux/ath79/dts/qca9563_tplink_eap2x5-1port.dtsi +++ b/target/linux/ath79/dts/qca9563_tplink_eap2x5-1port.dtsi @@ -81,6 +81,14 @@ label = "art"; reg = <0xff0000 0x010000>; read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + calibration_ath9k: calibration@1000 { + reg = <0x1000 0x440>; + }; }; }; }; @@ -98,20 +106,11 @@ pinctrl-names = "default"; pinctrl-0 = <&mdio_pins>; - - phy-mask = <0x10>; - - phy4: ethernet-phy@4 { - reg = <4>; - reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; - }; }; ð0 { status = "okay"; - phy-handle = <&phy4>; - phy-mode = "sgmii"; pll-data = <0x03000000 0x00000101 0x00001313>; nvmem-cells = <&macaddr_info_8>; @@ -127,9 +126,8 @@ &wmac { status = "okay"; - mtd-cal-data = <&art 0x1000>; - nvmem-cells = <&macaddr_info_8>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_info_8>, <&calibration_ath9k>; + nvmem-cell-names = "mac-address", "calibration"; }; &info { diff --git a/target/linux/ath79/dts/qca9563_tplink_tl-wpa8630.dtsi b/target/linux/ath79/dts/qca9563_tplink_tl-wpa8630.dtsi index 431c990815..560aae9694 100644 --- a/target/linux/ath79/dts/qca9563_tplink_tl-wpa8630.dtsi +++ b/target/linux/ath79/dts/qca9563_tplink_tl-wpa8630.dtsi @@ -105,8 +105,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_tplink_tl-wr1043n.dtsi b/target/linux/ath79/dts/qca9563_tplink_tl-wr1043n.dtsi index b99412eb79..2e3ac952e2 100644 --- a/target/linux/ath79/dts/qca9563_tplink_tl-wr1043n.dtsi +++ b/target/linux/ath79/dts/qca9563_tplink_tl-wr1043n.dtsi @@ -86,7 +86,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_ubnt_unifiac-lite.dtsi b/target/linux/ath79/dts/qca9563_ubnt_unifiac-lite.dtsi index 5eb358014b..c6438d8d15 100644 --- a/target/linux/ath79/dts/qca9563_ubnt_unifiac-lite.dtsi +++ b/target/linux/ath79/dts/qca9563_ubnt_unifiac-lite.dtsi @@ -11,7 +11,6 @@ &mdio0 { status = "okay"; - phy-mask = <4>; phy4: ethernet-phy@4 { phy-mode = "sgmii"; reg = <4>; diff --git a/target/linux/ath79/dts/qca9563_ubnt_unifiac-pro.dtsi b/target/linux/ath79/dts/qca9563_ubnt_unifiac-pro.dtsi index dbf6c27146..bb00643377 100644 --- a/target/linux/ath79/dts/qca9563_ubnt_unifiac-pro.dtsi +++ b/target/linux/ath79/dts/qca9563_ubnt_unifiac-pro.dtsi @@ -10,7 +10,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; diff --git a/target/linux/ath79/dts/qca9563_xiaomi_aiot-ac2350.dts b/target/linux/ath79/dts/qca9563_xiaomi_aiot-ac2350.dts index a7a73ad2fb..b6206b046d 100644 --- a/target/linux/ath79/dts/qca9563_xiaomi_aiot-ac2350.dts +++ b/target/linux/ath79/dts/qca9563_xiaomi_aiot-ac2350.dts @@ -135,8 +135,6 @@ &mdio0 { status = "okay"; - phy-mask = <0x1>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_yuncore_xd4200.dtsi b/target/linux/ath79/dts/qca9563_yuncore_xd4200.dtsi index f8dec2bc6b..6f729a21fe 100644 --- a/target/linux/ath79/dts/qca9563_yuncore_xd4200.dtsi +++ b/target/linux/ath79/dts/qca9563_yuncore_xd4200.dtsi @@ -35,8 +35,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qca9563_zte_mf286.dtsi b/target/linux/ath79/dts/qca9563_zte_mf286.dtsi index 76dd7b6be6..f794195c3f 100644 --- a/target/linux/ath79/dts/qca9563_zte_mf286.dtsi +++ b/target/linux/ath79/dts/qca9563_zte_mf286.dtsi @@ -104,7 +104,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts b/target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts index c095bbd2ed..9af119b560 100644 --- a/target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts +++ b/target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts @@ -95,8 +95,6 @@ &mdio0 { status = "okay"; - phy-mask = <0>; - phy0: ethernet-phy@0 { reg = <0>; phy-mode = "sgmii"; diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c index a58ee3346b..fd05dbd0ca 100644 --- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c +++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c @@ -201,10 +201,6 @@ static int ag71xx_mdio_probe(struct platform_device *pdev) mii_bus->parent = amdev; snprintf(mii_bus->id, MII_BUS_ID_SIZE, "%s.%d", np->name, bus_count++); - if (!builtin_switch && - of_property_read_u32(np, "phy-mask", &mii_bus->phy_mask)) - mii_bus->phy_mask = 0; - for (i = 0; i < PHY_MAX_ADDR; i++) mii_bus->irq[i] = PHY_POLL; diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 668fd76af3..5c42ae4fac 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -67,12 +67,6 @@ case "$FIRMWARE" in caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) -1) ;; - dlink,dap-2660-a1|\ - dlink,dap-2695-a1|\ - dlink,dap-3662-a1) - caldata_extract "art" 0x5000 0x844 - ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a) - ;; dlink,dir-859-a1) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac") @@ -145,14 +139,6 @@ case "$FIRMWARE" in caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary romfs 0xf100) 2) ;; - tplink,eap225-v1|\ - tplink,eap245-v1|\ - tplink,re450-v2|\ - tplink,re450-v3|\ - tplink,re455-v1) - caldata_extract "art" 0x5000 0x844 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) 1) - ;; tplink,re350k-v1) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) 2) @@ -162,6 +148,12 @@ case "$FIRMWARE" in caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; + tplink,re450-v2|\ + tplink,re450-v3|\ + tplink,re455-v1) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) 1) + ;; tplink,tl-wpa8630-v1) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x0fc00) 1) @@ -199,12 +191,6 @@ case "$FIRMWARE" in /lib/firmware/ath10k/QCA9888/hw2.0/board.bin rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin ;; - dlink,dap-2680-a1) - caldata_extract "art" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a) - ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ - /lib/firmware/ath10k/QCA9888/hw2.0/board.bin - ;; dlink,dir-842-c1|\ dlink,dir-842-c2|\ dlink,dir-842-c3) @@ -252,18 +238,6 @@ case "$FIRMWARE" in ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; - tplink,eap225-outdoor-v1|\ - tplink,eap225-v3|\ - tplink,eap225-wall-v2) - caldata_extract "art" 0x5000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) 1) - ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ - /lib/firmware/ath10k/QCA9888/hw2.0/board.bin - ;; - tplink,eap245-v3) - caldata_extract "art" 0x5000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) 1) - ;; xiaomi,aiot-ac2350) caldata_extract "art" 0x5000 0x2f20 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index a4f82c54e2..95ff6083c7 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -30,6 +30,8 @@ case "$board" in dlink,dap-2680-a1|\ dlink,dap-2695-a1|\ dlink,dap-3662-a1) + [ "$PHYNBR" -eq 0 ] && \ + mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress [ "$PHYNBR" -eq 1 ] && \ mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress ;; diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index 726fab068f..4e1ac216a5 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -231,6 +231,23 @@ define Device/netgear_ath79_nand UBINIZE_OPTS := -E 5 endef +define Device/netgear_pgzng1 + SOC := ar9344 + DEVICE_MODEL := PGZNG1 + DEVICE_VENDOR := NETGEAR + DEVICE_ALT0_MODEL := Pulse Gateway + DEVICE_ALT0_VENDOR := ADT + DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport kmod-i2c-gpio \ + kmod-leds-pca955x kmod-rtc-isl1208 kmod-spi-dev + KERNEL_SIZE := 5120k + IMAGE_SIZE := 83968k + PAGESIZE := 2048 + BLOCKSIZE := 128k + KERNEL := kernel-bin | append-dtb | lzma | uImage lzma + IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata +endef +TARGET_DEVICES += netgear_pgzng1 + define Device/netgear_r6100 SOC := ar9344 DEVICE_MODEL := R6100 diff --git a/target/linux/ath79/nand/base-files/etc/board.d/01_leds b/target/linux/ath79/nand/base-files/etc/board.d/01_leds index e493298457..41c4fa2527 100644 --- a/target/linux/ath79/nand/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/nand/base-files/etc/board.d/01_leds @@ -18,6 +18,14 @@ glinet,gl-xe300) ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1" ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x10" ;; +netgear,pgzng1) + ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt" + ucidef_set_led_switch "wan" "WAN" "green:wan-1" "switch0" "0x02" "0xf" "link tx rx" + ucidef_set_led_switch "wan-green" "wan link" "green:wan-0" "switch0" "0x02" "0xf" "link" + ucidef_set_led_switch "wan-amber" "wan act" "amber:wan" "switch0" "0x02" "0xf" "tx rx" + ucidef_set_led_netdev "lan-green" "lan link" "green:lan" "eth1" "link" + ucidef_set_led_netdev "lan-amber" "lan act" "amber:lan" "eth1" "tx rx" + ;; netgear,r6100) ucidef_set_led_netdev "wan-green" "WAN (green)" "green:wan" "eth1" ;; diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network b/target/linux/ath79/nand/base-files/etc/board.d/02_network index bda4eeb917..01f26fb39d 100644 --- a/target/linux/ath79/nand/base-files/etc/board.d/02_network +++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network @@ -30,6 +30,9 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "4:lan" ;; + netgear,pgzng1) + ucidef_set_interfaces_lan_wan "eth1" "eth0" + ;; netgear,r6100) ucidef_set_interface_wan "eth1" ucidef_add_switch "switch0" \ diff --git a/target/linux/ath79/nand/base-files/etc/init.d/boot-leds b/target/linux/ath79/nand/base-files/etc/init.d/boot-leds new file mode 100644 index 0000000000..f2a1cc13b8 --- /dev/null +++ b/target/linux/ath79/nand/base-files/etc/init.d/boot-leds @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# SPDX-License-Identifier: GPL-2.0-only + +START=11 + +# To support LEDs on boards that have drivers loaded after rootfs, let's +# re-run diag.sh AFTER kmodloader has finished, but before boot is complete. +# This is useful for userspace LED drivers, LEDs that rely on i2c, etc. + +boot() { + case $(board_name) in + netgear,pgzng1) + . /etc/diag.sh + set_led_state preinit_regular + ;; + esac +} diff --git a/target/linux/bcm53xx/base-files/lib/preinit/07_set_preinit_iface_bcm53xx b/target/linux/bcm53xx/base-files/lib/preinit/07_set_preinit_iface_bcm53xx deleted file mode 100644 index 9e7c4b821e..0000000000 --- a/target/linux/bcm53xx/base-files/lib/preinit/07_set_preinit_iface_bcm53xx +++ /dev/null @@ -1,14 +0,0 @@ -set_preinit_iface() { - . /lib/functions.sh - - case $(board_name) in - meraki,mr32) - # switch needs to be out of the vlan mode. - swconfig dev switch0 set reset 1 - swconfig dev switch0 set enable_vlan 0 - swconfig dev switch0 set apply 1 - ;; - esac -} - -boot_hook_add preinit_main set_preinit_iface diff --git a/target/linux/bcm53xx/patches-5.10/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch b/target/linux/bcm53xx/patches-5.10/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch new file mode 100644 index 0000000000..2c2eb07b82 --- /dev/null +++ b/target/linux/bcm53xx/patches-5.10/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch @@ -0,0 +1,33 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 10 Jun 2022 13:10:47 +0200 +Subject: [PATCH] bgmac: reduce max frame size to support just MTU 1500 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +bgmac allocates new replacement buffer before handling each received +frame. Allocating & DMA-preparing 9724 B each time consumes a lot of CPU +time. Ideally bgmac should just respect currently set MTU but it isn't +the case right now. For now just revert back to the old limited frame +size. + +This change bumps NAT masquarade speed by ~95%. + +Ref: 8c7da63978f1 ("bgmac: configure MTU and add support for frames beyond 8192 byte size") +Signed-off-by: Rafał Miłecki +--- + drivers/net/ethernet/broadcom/bgmac.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bgmac.h ++++ b/drivers/net/ethernet/broadcom/bgmac.h +@@ -366,8 +366,7 @@ + #define BGMAC_RX_FRAME_OFFSET 30 /* There are 2 unused bytes between header and real data */ + #define BGMAC_RX_BUF_OFFSET (NET_SKB_PAD + NET_IP_ALIGN - \ + BGMAC_RX_FRAME_OFFSET) +-/* Jumbo frame size with FCS */ +-#define BGMAC_RX_MAX_FRAME_SIZE 9724 ++#define BGMAC_RX_MAX_FRAME_SIZE 1536 + #define BGMAC_RX_BUF_SIZE (BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE) + #define BGMAC_RX_ALLOC_SIZE (SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) diff --git a/target/linux/bcm53xx/patches-5.15/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch b/target/linux/bcm53xx/patches-5.15/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch new file mode 100644 index 0000000000..3a2f4b06ed --- /dev/null +++ b/target/linux/bcm53xx/patches-5.15/700-bgmac-reduce-max-frame-size-to-support-just-MTU-1500.patch @@ -0,0 +1,33 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 10 Jun 2022 13:10:47 +0200 +Subject: [PATCH] bgmac: reduce max frame size to support just MTU 1500 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +bgmac allocates new replacement buffer before handling each received +frame. Allocating & DMA-preparing 9724 B each time consumes a lot of CPU +time. Ideally bgmac should just respect currently set MTU but it isn't +the case right now. For now just revert back to the old limited frame +size. + +This change bumps NAT masquarade speed by ~95%. + +Ref: 8c7da63978f1 ("bgmac: configure MTU and add support for frames beyond 8192 byte size") +Signed-off-by: Rafał Miłecki +--- + drivers/net/ethernet/broadcom/bgmac.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bgmac.h ++++ b/drivers/net/ethernet/broadcom/bgmac.h +@@ -328,8 +328,7 @@ + #define BGMAC_RX_FRAME_OFFSET 30 /* There are 2 unused bytes between header and real data */ + #define BGMAC_RX_BUF_OFFSET (NET_SKB_PAD + NET_IP_ALIGN - \ + BGMAC_RX_FRAME_OFFSET) +-/* Jumbo frame size with FCS */ +-#define BGMAC_RX_MAX_FRAME_SIZE 9724 ++#define BGMAC_RX_MAX_FRAME_SIZE 1536 + #define BGMAC_RX_BUF_SIZE (BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE) + #define BGMAC_RX_ALLOC_SIZE (SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) diff --git a/target/linux/generic/backport-5.10/411-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch b/target/linux/generic/backport-5.10/411-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch new file mode 100644 index 0000000000..5ed6fd1b3b --- /dev/null +++ b/target/linux/generic/backport-5.10/411-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch @@ -0,0 +1,301 @@ +From 9b78ef0c7997052e9eaa0f7a4513d546fa17358c Mon Sep 17 00:00:00 2001 +From: Mikhail Zhilkin +Date: Sun, 29 May 2022 11:07:14 +0000 +Subject: [PATCH] mtd: parsers: add support for Sercomm partitions + +This adds an MTD partition parser for the Sercomm partition table that +is used in some Beeline, Netgear and Sercomm routers. + +The Sercomm partition map table contains real partition offsets, which +may differ from device to device depending on the number and location of +bad blocks on NAND. + +Original patch (proposed by NOGUCHI Hiroshi): +Link: https://github.com/openwrt/openwrt/pull/1318#issuecomment-420607394 + +Signed-off-by: NOGUCHI Hiroshi +Signed-off-by: Mikhail Zhilkin +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20220529110714.189732-1-csharper2005@gmail.com +--- + drivers/mtd/parsers/Kconfig | 9 ++ + drivers/mtd/parsers/Makefile | 1 + + drivers/mtd/parsers/scpart.c | 248 +++++++++++++++++++++++++++++++++++ + 3 files changed, 258 insertions(+) + create mode 100644 drivers/mtd/parsers/scpart.c + +--- a/drivers/mtd/parsers/Kconfig ++++ b/drivers/mtd/parsers/Kconfig +@@ -179,3 +179,12 @@ config MTD_REDBOOT_PARTS_READONLY + 'FIS directory' images, enable this option. + + endif # MTD_REDBOOT_PARTS ++ ++config MTD_SERCOMM_PARTS ++ tristate "Sercomm partition table parser" ++ depends on MTD && RALINK ++ help ++ This provides partitions table parser for devices with Sercomm ++ partition map. This partition table contains real partition ++ offsets, which may differ from device to device depending on the ++ number and location of bad blocks on NAND. +--- a/drivers/mtd/parsers/Makefile ++++ b/drivers/mtd/parsers/Makefile +@@ -10,5 +10,6 @@ ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS) + obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o + obj-$(CONFIG_MTD_AFS_PARTS) += afs.o + obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o ++obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o + obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o +--- /dev/null ++++ b/drivers/mtd/parsers/scpart.c +@@ -0,0 +1,248 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * drivers/mtd/scpart.c: Sercomm Partition Parser ++ * ++ * Copyright (C) 2018 NOGUCHI Hiroshi ++ * Copyright (C) 2022 Mikhail Zhilkin ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define MOD_NAME "scpart" ++ ++#ifdef pr_fmt ++#undef pr_fmt ++#endif ++ ++#define pr_fmt(fmt) MOD_NAME ": " fmt ++ ++#define ID_ALREADY_FOUND 0xffffffffUL ++ ++#define MAP_OFFS_IN_BLK 0x800 ++#define MAP_MIRROR_NUM 2 ++ ++static const char sc_part_magic[] = { ++ 'S', 'C', 'F', 'L', 'M', 'A', 'P', 'O', 'K', '\0', ++}; ++#define PART_MAGIC_LEN sizeof(sc_part_magic) ++ ++/* assumes that all fields are set by CPU native endian */ ++struct sc_part_desc { ++ uint32_t part_id; ++ uint32_t part_offs; ++ uint32_t part_bytes; ++}; ++ ++static uint32_t scpart_desc_is_valid(struct sc_part_desc *pdesc) ++{ ++ return ((pdesc->part_id != 0xffffffffUL) && ++ (pdesc->part_offs != 0xffffffffUL) && ++ (pdesc->part_bytes != 0xffffffffUL)); ++} ++ ++static int scpart_scan_partmap(struct mtd_info *master, loff_t partmap_offs, ++ struct sc_part_desc **ppdesc) ++{ ++ int cnt = 0; ++ int res = 0; ++ int res2; ++ loff_t offs; ++ size_t retlen; ++ struct sc_part_desc *pdesc = NULL; ++ struct sc_part_desc *tmpdesc; ++ uint8_t *buf; ++ ++ buf = kzalloc(master->erasesize, GFP_KERNEL); ++ if (!buf) { ++ res = -ENOMEM; ++ goto out; ++ } ++ ++ res2 = mtd_read(master, partmap_offs, master->erasesize, &retlen, buf); ++ if (res2 || retlen != master->erasesize) { ++ res = -EIO; ++ goto free; ++ } ++ ++ for (offs = MAP_OFFS_IN_BLK; ++ offs < master->erasesize - sizeof(*tmpdesc); ++ offs += sizeof(*tmpdesc)) { ++ tmpdesc = (struct sc_part_desc *)&buf[offs]; ++ if (!scpart_desc_is_valid(tmpdesc)) ++ break; ++ cnt++; ++ } ++ ++ if (cnt > 0) { ++ int bytes = cnt * sizeof(*pdesc); ++ ++ pdesc = kcalloc(cnt, sizeof(*pdesc), GFP_KERNEL); ++ if (!pdesc) { ++ res = -ENOMEM; ++ goto free; ++ } ++ memcpy(pdesc, &(buf[MAP_OFFS_IN_BLK]), bytes); ++ ++ *ppdesc = pdesc; ++ res = cnt; ++ } ++ ++free: ++ kfree(buf); ++ ++out: ++ return res; ++} ++ ++static int scpart_find_partmap(struct mtd_info *master, ++ struct sc_part_desc **ppdesc) ++{ ++ int magic_found = 0; ++ int res = 0; ++ int res2; ++ loff_t offs = 0; ++ size_t retlen; ++ uint8_t rdbuf[PART_MAGIC_LEN]; ++ ++ while ((magic_found < MAP_MIRROR_NUM) && ++ (offs < master->size) && ++ !mtd_block_isbad(master, offs)) { ++ res2 = mtd_read(master, offs, PART_MAGIC_LEN, &retlen, rdbuf); ++ if (res2 || retlen != PART_MAGIC_LEN) { ++ res = -EIO; ++ goto out; ++ } ++ if (!memcmp(rdbuf, sc_part_magic, PART_MAGIC_LEN)) { ++ pr_debug("Signature found at 0x%llx\n", offs); ++ magic_found++; ++ res = scpart_scan_partmap(master, offs, ppdesc); ++ if (res > 0) ++ goto out; ++ } ++ offs += master->erasesize; ++ } ++ ++out: ++ if (res > 0) ++ pr_info("Valid 'SC PART MAP' (%d partitions) found at 0x%llx\n", res, offs); ++ else ++ pr_info("No valid 'SC PART MAP' was found\n"); ++ ++ return res; ++} ++ ++static int scpart_parse(struct mtd_info *master, ++ const struct mtd_partition **pparts, ++ struct mtd_part_parser_data *data) ++{ ++ const char *partname; ++ int n; ++ int nr_scparts; ++ int nr_parts = 0; ++ int res = 0; ++ struct sc_part_desc *scpart_map = NULL; ++ struct mtd_partition *parts = NULL; ++ struct device_node *mtd_node; ++ struct device_node *ofpart_node; ++ struct device_node *pp; ++ ++ mtd_node = mtd_get_of_node(master); ++ if (!mtd_node) { ++ res = -ENOENT; ++ goto out; ++ } ++ ++ ofpart_node = of_get_child_by_name(mtd_node, "partitions"); ++ if (!ofpart_node) { ++ pr_info("%s: 'partitions' subnode not found on %pOF.\n", ++ master->name, mtd_node); ++ res = -ENOENT; ++ goto out; ++ } ++ ++ nr_scparts = scpart_find_partmap(master, &scpart_map); ++ if (nr_scparts <= 0) { ++ pr_info("No any partitions was found in 'SC PART MAP'.\n"); ++ res = -ENOENT; ++ goto free; ++ } ++ ++ parts = kcalloc(of_get_child_count(ofpart_node), sizeof(*parts), ++ GFP_KERNEL); ++ if (!parts) { ++ res = -ENOMEM; ++ goto free; ++ } ++ ++ for_each_child_of_node(ofpart_node, pp) { ++ u32 scpart_id; ++ ++ if (of_property_read_u32(pp, "sercomm,scpart-id", &scpart_id)) ++ continue; ++ ++ for (n = 0 ; n < nr_scparts ; n++) ++ if ((scpart_map[n].part_id != ID_ALREADY_FOUND) && ++ (scpart_id == scpart_map[n].part_id)) ++ break; ++ if (n >= nr_scparts) ++ /* not match */ ++ continue; ++ ++ /* add the partition found in OF into MTD partition array */ ++ parts[nr_parts].offset = scpart_map[n].part_offs; ++ parts[nr_parts].size = scpart_map[n].part_bytes; ++ parts[nr_parts].of_node = pp; ++ ++ if (!of_property_read_string(pp, "label", &partname)) ++ parts[nr_parts].name = partname; ++ if (of_property_read_bool(pp, "read-only")) ++ parts[nr_parts].mask_flags |= MTD_WRITEABLE; ++ if (of_property_read_bool(pp, "lock")) ++ parts[nr_parts].mask_flags |= MTD_POWERUP_LOCK; ++ ++ /* mark as 'done' */ ++ scpart_map[n].part_id = ID_ALREADY_FOUND; ++ ++ nr_parts++; ++ } ++ ++ if (nr_parts > 0) { ++ *pparts = parts; ++ res = nr_parts; ++ } else ++ pr_info("No partition in OF matches partition ID with 'SC PART MAP'.\n"); ++ ++ of_node_put(pp); ++ ++free: ++ kfree(scpart_map); ++ if (res <= 0) ++ kfree(parts); ++ ++out: ++ return res; ++} ++ ++static const struct of_device_id scpart_parser_of_match_table[] = { ++ { .compatible = "sercomm,sc-partitions" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, scpart_parser_of_match_table); ++ ++static struct mtd_part_parser scpart_parser = { ++ .parse_fn = scpart_parse, ++ .name = "scpart", ++ .of_match_table = scpart_parser_of_match_table, ++}; ++module_mtd_part_parser(scpart_parser); ++ ++/* mtd parsers will request the module by parser name */ ++MODULE_ALIAS("scpart"); ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("NOGUCHI Hiroshi "); ++MODULE_AUTHOR("Mikhail Zhilkin "); ++MODULE_DESCRIPTION("Sercomm partition parser"); diff --git a/target/linux/generic/backport-5.10/840-v5.15-leds-pca955x-clean-up-code-formatting.patch b/target/linux/generic/backport-5.10/840-v5.15-leds-pca955x-clean-up-code-formatting.patch new file mode 100644 index 0000000000..41199dd93e --- /dev/null +++ b/target/linux/generic/backport-5.10/840-v5.15-leds-pca955x-clean-up-code-formatting.patch @@ -0,0 +1,178 @@ +From 2420ae02ce0a926819ebe18f809a57bff3edeac2 Mon Sep 17 00:00:00 2001 +From: Eddie James +Date: Fri, 16 Jul 2021 17:03:27 -0500 +Subject: [PATCH] leds: pca955x: Clean up code formatting + +Format the code. Add some variables to help shorten lines. + +Signed-off-by: Eddie James +Signed-off-by: Pavel Machek +--- + drivers/leds/leds-pca955x.c | 63 ++++++++++++++++++------------------- + 1 file changed, 30 insertions(+), 33 deletions(-) + +diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c +index 7087ca4592fc96..f0d841cb59fcc8 100644 +--- a/drivers/leds/leds-pca955x.c ++++ b/drivers/leds/leds-pca955x.c +@@ -166,11 +166,10 @@ static inline u8 pca955x_ledsel(u8 oldval, int led_num, int state) + static int pca955x_write_psc(struct i2c_client *client, int n, u8 val) + { + struct pca955x *pca955x = i2c_get_clientdata(client); ++ u8 cmd = pca95xx_num_input_regs(pca955x->chipdef->bits) + (2 * n); + int ret; + +- ret = i2c_smbus_write_byte_data(client, +- pca95xx_num_input_regs(pca955x->chipdef->bits) + 2*n, +- val); ++ ret = i2c_smbus_write_byte_data(client, cmd, val); + if (ret < 0) + dev_err(&client->dev, "%s: reg 0x%x, val 0x%x, err %d\n", + __func__, n, val, ret); +@@ -187,11 +186,10 @@ static int pca955x_write_psc(struct i2c_client *client, int n, u8 val) + static int pca955x_write_pwm(struct i2c_client *client, int n, u8 val) + { + struct pca955x *pca955x = i2c_get_clientdata(client); ++ u8 cmd = pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + (2 * n); + int ret; + +- ret = i2c_smbus_write_byte_data(client, +- pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + 2*n, +- val); ++ ret = i2c_smbus_write_byte_data(client, cmd, val); + if (ret < 0) + dev_err(&client->dev, "%s: reg 0x%x, val 0x%x, err %d\n", + __func__, n, val, ret); +@@ -205,11 +203,10 @@ static int pca955x_write_pwm(struct i2c_client *client, int n, u8 val) + static int pca955x_write_ls(struct i2c_client *client, int n, u8 val) + { + struct pca955x *pca955x = i2c_get_clientdata(client); ++ u8 cmd = pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n; + int ret; + +- ret = i2c_smbus_write_byte_data(client, +- pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n, +- val); ++ ret = i2c_smbus_write_byte_data(client, cmd, val); + if (ret < 0) + dev_err(&client->dev, "%s: reg 0x%x, val 0x%x, err %d\n", + __func__, n, val, ret); +@@ -223,10 +220,10 @@ static int pca955x_write_ls(struct i2c_client *client, int n, u8 val) + static int pca955x_read_ls(struct i2c_client *client, int n, u8 *val) + { + struct pca955x *pca955x = i2c_get_clientdata(client); ++ u8 cmd = pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n; + int ret; + +- ret = i2c_smbus_read_byte_data(client, +- pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); ++ ret = i2c_smbus_read_byte_data(client, cmd); + if (ret < 0) { + dev_err(&client->dev, "%s: reg 0x%x, err %d\n", + __func__, n, ret); +@@ -371,6 +368,7 @@ static struct pca955x_platform_data * + pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + { + struct pca955x_platform_data *pdata; ++ struct pca955x_led *led; + struct fwnode_handle *child; + int count; + +@@ -401,13 +399,13 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + if ((res != 0) && is_of_node(child)) + name = to_of_node(child)->name; + +- snprintf(pdata->leds[reg].name, sizeof(pdata->leds[reg].name), +- "%s", name); ++ led = &pdata->leds[reg]; ++ snprintf(led->name, sizeof(led->name), "%s", name); + +- pdata->leds[reg].type = PCA955X_TYPE_LED; +- fwnode_property_read_u32(child, "type", &pdata->leds[reg].type); ++ led->type = PCA955X_TYPE_LED; ++ fwnode_property_read_u32(child, "type", &led->type); + fwnode_property_read_string(child, "linux,default-trigger", +- &pdata->leds[reg].default_trigger); ++ &led->default_trigger); + } + + pdata->num_leds = chip->bits; +@@ -426,11 +424,12 @@ static const struct of_device_id of_pca955x_match[] = { + MODULE_DEVICE_TABLE(of, of_pca955x_match); + + static int pca955x_probe(struct i2c_client *client, +- const struct i2c_device_id *id) ++ const struct i2c_device_id *id) + { + struct pca955x *pca955x; + struct pca955x_led *pca955x_led; + struct pca955x_chipdef *chip; ++ struct led_classdev *led; + struct i2c_adapter *adapter; + int i, err; + struct pca955x_platform_data *pdata; +@@ -449,13 +448,13 @@ static int pca955x_probe(struct i2c_client *client, + if ((client->addr & ~((1 << chip->slv_addr_shift) - 1)) != + chip->slv_addr) { + dev_err(&client->dev, "invalid slave address %02x\n", +- client->addr); ++ client->addr); + return -ENODEV; + } + + dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " +- "slave address 0x%02x\n", +- client->name, chip->bits, client->addr); ++ "slave address 0x%02x\n", client->name, chip->bits, ++ client->addr); + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -EIO; +@@ -471,8 +470,8 @@ static int pca955x_probe(struct i2c_client *client, + if (!pca955x) + return -ENOMEM; + +- pca955x->leds = devm_kcalloc(&client->dev, +- chip->bits, sizeof(*pca955x_led), GFP_KERNEL); ++ pca955x->leds = devm_kcalloc(&client->dev, chip->bits, ++ sizeof(*pca955x_led), GFP_KERNEL); + if (!pca955x->leds) + return -ENOMEM; + +@@ -501,27 +500,25 @@ static int pca955x_probe(struct i2c_client *client, + */ + if (pdata->leds[i].name[0] == '\0') + snprintf(pdata->leds[i].name, +- sizeof(pdata->leds[i].name), "%d", i); ++ sizeof(pdata->leds[i].name), "%d", i); + +- snprintf(pca955x_led->name, +- sizeof(pca955x_led->name), "pca955x:%s", +- pdata->leds[i].name); ++ snprintf(pca955x_led->name, sizeof(pca955x_led->name), ++ "pca955x:%s", pdata->leds[i].name); + ++ led = &pca955x_led->led_cdev; + if (pdata->leds[i].default_trigger) +- pca955x_led->led_cdev.default_trigger = ++ led->default_trigger = + pdata->leds[i].default_trigger; + +- pca955x_led->led_cdev.name = pca955x_led->name; +- pca955x_led->led_cdev.brightness_set_blocking = +- pca955x_led_set; ++ led->name = pca955x_led->name; ++ led->brightness_set_blocking = pca955x_led_set; + +- err = devm_led_classdev_register(&client->dev, +- &pca955x_led->led_cdev); ++ err = devm_led_classdev_register(&client->dev, led); + if (err) + return err; + + /* Turn off LED */ +- err = pca955x_led_set(&pca955x_led->led_cdev, LED_OFF); ++ err = pca955x_led_set(led, LED_OFF); + if (err) + return err; + } diff --git a/target/linux/generic/backport-5.10/841-v5.15-leds-pca955x-add-brightness-get-function.patch b/target/linux/generic/backport-5.10/841-v5.15-leds-pca955x-add-brightness-get-function.patch new file mode 100644 index 0000000000..c3344be4fd --- /dev/null +++ b/target/linux/generic/backport-5.10/841-v5.15-leds-pca955x-add-brightness-get-function.patch @@ -0,0 +1,83 @@ +From 7086625fde6538b2c0623eb767ad23c7ac3d7f3a Mon Sep 17 00:00:00 2001 +From: Eddie James +Date: Fri, 16 Jul 2021 17:03:28 -0500 +Subject: [PATCH] leds: pca955x: Add brightness_get function + +Add a function to fetch the state of the hardware LED. + +Signed-off-by: Eddie James +Signed-off-by: Pavel Machek +--- + drivers/leds/leds-pca955x.c | 52 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 52 insertions(+) + +diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c +index f0d841cb59fcc8..e47ba7c3b7c7d8 100644 +--- a/drivers/leds/leds-pca955x.c ++++ b/drivers/leds/leds-pca955x.c +@@ -233,6 +233,57 @@ static int pca955x_read_ls(struct i2c_client *client, int n, u8 *val) + return 0; + } + ++static int pca955x_read_pwm(struct i2c_client *client, int n, u8 *val) ++{ ++ struct pca955x *pca955x = i2c_get_clientdata(client); ++ u8 cmd = pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + (2 * n); ++ int ret; ++ ++ ret = i2c_smbus_read_byte_data(client, cmd); ++ if (ret < 0) { ++ dev_err(&client->dev, "%s: reg 0x%x, err %d\n", ++ __func__, n, ret); ++ return ret; ++ } ++ *val = (u8)ret; ++ return 0; ++} ++ ++static enum led_brightness pca955x_led_get(struct led_classdev *led_cdev) ++{ ++ struct pca955x_led *pca955x_led = container_of(led_cdev, ++ struct pca955x_led, ++ led_cdev); ++ struct pca955x *pca955x = pca955x_led->pca955x; ++ u8 ls, pwm; ++ int ret; ++ ++ ret = pca955x_read_ls(pca955x->client, pca955x_led->led_num / 4, &ls); ++ if (ret) ++ return ret; ++ ++ ls = (ls >> ((pca955x_led->led_num % 4) << 1)) & 0x3; ++ switch (ls) { ++ case PCA955X_LS_LED_ON: ++ ret = LED_FULL; ++ break; ++ case PCA955X_LS_LED_OFF: ++ ret = LED_OFF; ++ break; ++ case PCA955X_LS_BLINK0: ++ ret = LED_HALF; ++ break; ++ case PCA955X_LS_BLINK1: ++ ret = pca955x_read_pwm(pca955x->client, 1, &pwm); ++ if (ret) ++ return ret; ++ ret = 255 - pwm; ++ break; ++ } ++ ++ return ret; ++} ++ + static int pca955x_led_set(struct led_classdev *led_cdev, + enum led_brightness value) + { +@@ -512,6 +563,7 @@ static int pca955x_probe(struct i2c_client *client, + + led->name = pca955x_led->name; + led->brightness_set_blocking = pca955x_led_set; ++ led->brightness_get = pca955x_led_get; + + err = devm_led_classdev_register(&client->dev, led); + if (err) diff --git a/target/linux/generic/backport-5.10/842-v5.15-leds-pca955x-implement-the-default-state-property.patch b/target/linux/generic/backport-5.10/842-v5.15-leds-pca955x-implement-the-default-state-property.patch new file mode 100644 index 0000000000..055801f096 --- /dev/null +++ b/target/linux/generic/backport-5.10/842-v5.15-leds-pca955x-implement-the-default-state-property.patch @@ -0,0 +1,119 @@ +From e46cb6d0c760a5b15e38138845fad99628fafcb8 Mon Sep 17 00:00:00 2001 +From: Eddie James +Date: Fri, 16 Jul 2021 17:03:29 -0500 +Subject: [PATCH] leds: pca955x: Implement the default-state property + +In order to retain the LED state after a system reboot, check the +documented default-state device tree property during initialization. +Modify the behavior of the probe according to the property. + +Signed-off-by: Eddie James +Signed-off-by: Pavel Machek +--- + drivers/leds/leds-pca955x.c | 54 +++++++++++++++++++++++++++++++------ + 1 file changed, 46 insertions(+), 8 deletions(-) + +diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c +index e47ba7c3b7c7d8..fa1d77d86ef67b 100644 +--- a/drivers/leds/leds-pca955x.c ++++ b/drivers/leds/leds-pca955x.c +@@ -129,6 +129,7 @@ struct pca955x_led { + int led_num; /* 0 .. 15 potentially */ + char name[32]; + u32 type; ++ int default_state; + const char *default_trigger; + }; + +@@ -439,6 +440,7 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + + device_for_each_child_node(&client->dev, child) { + const char *name; ++ const char *state; + u32 reg; + int res; + +@@ -457,6 +459,18 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + fwnode_property_read_u32(child, "type", &led->type); + fwnode_property_read_string(child, "linux,default-trigger", + &led->default_trigger); ++ ++ if (!fwnode_property_read_string(child, "default-state", ++ &state)) { ++ if (!strcmp(state, "keep")) ++ led->default_state = LEDS_GPIO_DEFSTATE_KEEP; ++ else if (!strcmp(state, "on")) ++ led->default_state = LEDS_GPIO_DEFSTATE_ON; ++ else ++ led->default_state = LEDS_GPIO_DEFSTATE_OFF; ++ } else { ++ led->default_state = LEDS_GPIO_DEFSTATE_OFF; ++ } + } + + pdata->num_leds = chip->bits; +@@ -485,6 +499,7 @@ static int pca955x_probe(struct i2c_client *client, + int i, err; + struct pca955x_platform_data *pdata; + int ngpios = 0; ++ bool keep_pwm = false; + + chip = &pca955x_chipdefs[id->driver_data]; + adapter = client->adapter; +@@ -565,14 +580,35 @@ static int pca955x_probe(struct i2c_client *client, + led->brightness_set_blocking = pca955x_led_set; + led->brightness_get = pca955x_led_get; + ++ if (pdata->leds[i].default_state == ++ LEDS_GPIO_DEFSTATE_OFF) { ++ err = pca955x_led_set(led, LED_OFF); ++ if (err) ++ return err; ++ } else if (pdata->leds[i].default_state == ++ LEDS_GPIO_DEFSTATE_ON) { ++ err = pca955x_led_set(led, LED_FULL); ++ if (err) ++ return err; ++ } ++ + err = devm_led_classdev_register(&client->dev, led); + if (err) + return err; + +- /* Turn off LED */ +- err = pca955x_led_set(led, LED_OFF); +- if (err) +- return err; ++ /* ++ * For default-state == "keep", let the core update the ++ * brightness from the hardware, then check the ++ * brightness to see if it's using PWM1. If so, PWM1 ++ * should not be written below. ++ */ ++ if (pdata->leds[i].default_state == ++ LEDS_GPIO_DEFSTATE_KEEP) { ++ if (led->brightness != LED_FULL && ++ led->brightness != LED_OFF && ++ led->brightness != LED_HALF) ++ keep_pwm = true; ++ } + } + } + +@@ -581,10 +617,12 @@ static int pca955x_probe(struct i2c_client *client, + if (err) + return err; + +- /* PWM1 is used for variable brightness, default to OFF */ +- err = pca955x_write_pwm(client, 1, 0); +- if (err) +- return err; ++ if (!keep_pwm) { ++ /* PWM1 is used for variable brightness, default to OFF */ ++ err = pca955x_write_pwm(client, 1, 0); ++ if (err) ++ return err; ++ } + + /* Set to fast frequency so we do not see flashing */ + err = pca955x_write_psc(client, 0, 0); diff --git a/target/linux/generic/backport-5.10/843-v5.15-leds-pca955x-let-the-core-process-the-fwnode.patch b/target/linux/generic/backport-5.10/843-v5.15-leds-pca955x-let-the-core-process-the-fwnode.patch new file mode 100644 index 0000000000..7a091d9716 --- /dev/null +++ b/target/linux/generic/backport-5.10/843-v5.15-leds-pca955x-let-the-core-process-the-fwnode.patch @@ -0,0 +1,138 @@ +From 7c4815929276b2e223eb6f2e49afe5071d4294a5 Mon Sep 17 00:00:00 2001 +From: Eddie James +Date: Fri, 16 Jul 2021 17:03:30 -0500 +Subject: [PATCH] leds: pca955x: Let the core process the fwnode + +Much of the fwnode processing in the PCA955x driver is now in the +LEDs core driver, so pass the fwnode in the init data when +registering the LED device. In order to preserve the existing naming +scheme, check for an empty name and set it to the LED number. + +Signed-off-by: Eddie James +Signed-off-by: Pavel Machek +--- + drivers/leds/leds-pca955x.c | 58 +++++++++++++++++++------------------ + 1 file changed, 30 insertions(+), 28 deletions(-) + +diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c +index fa1d77d86ef67b..a6aa4b9abde8c4 100644 +--- a/drivers/leds/leds-pca955x.c ++++ b/drivers/leds/leds-pca955x.c +@@ -127,10 +127,9 @@ struct pca955x_led { + struct pca955x *pca955x; + struct led_classdev led_cdev; + int led_num; /* 0 .. 15 potentially */ +- char name[32]; + u32 type; + int default_state; +- const char *default_trigger; ++ struct fwnode_handle *fwnode; + }; + + struct pca955x_platform_data { +@@ -439,7 +438,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + return ERR_PTR(-ENOMEM); + + device_for_each_child_node(&client->dev, child) { +- const char *name; + const char *state; + u32 reg; + int res; +@@ -448,17 +446,10 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) + if ((res != 0) || (reg >= chip->bits)) + continue; + +- res = fwnode_property_read_string(child, "label", &name); +- if ((res != 0) && is_of_node(child)) +- name = to_of_node(child)->name; +- + led = &pdata->leds[reg]; +- snprintf(led->name, sizeof(led->name), "%s", name); +- + led->type = PCA955X_TYPE_LED; ++ led->fwnode = child; + fwnode_property_read_u32(child, "type", &led->type); +- fwnode_property_read_string(child, "linux,default-trigger", +- &led->default_trigger); + + if (!fwnode_property_read_string(child, "default-state", + &state)) { +@@ -495,11 +486,14 @@ static int pca955x_probe(struct i2c_client *client, + struct pca955x_led *pca955x_led; + struct pca955x_chipdef *chip; + struct led_classdev *led; ++ struct led_init_data init_data; + struct i2c_adapter *adapter; + int i, err; + struct pca955x_platform_data *pdata; + int ngpios = 0; ++ bool set_default_label = false; + bool keep_pwm = false; ++ char default_label[8]; + + chip = &pca955x_chipdefs[id->driver_data]; + adapter = client->adapter; +@@ -547,6 +541,9 @@ static int pca955x_probe(struct i2c_client *client, + pca955x->client = client; + pca955x->chipdef = chip; + ++ init_data.devname_mandatory = false; ++ init_data.devicename = "pca955x"; ++ + for (i = 0; i < chip->bits; i++) { + pca955x_led = &pca955x->leds[i]; + pca955x_led->led_num = i; +@@ -560,23 +557,7 @@ static int pca955x_probe(struct i2c_client *client, + ngpios++; + break; + case PCA955X_TYPE_LED: +- /* +- * Platform data can specify LED names and +- * default triggers +- */ +- if (pdata->leds[i].name[0] == '\0') +- snprintf(pdata->leds[i].name, +- sizeof(pdata->leds[i].name), "%d", i); +- +- snprintf(pca955x_led->name, sizeof(pca955x_led->name), +- "pca955x:%s", pdata->leds[i].name); +- + led = &pca955x_led->led_cdev; +- if (pdata->leds[i].default_trigger) +- led->default_trigger = +- pdata->leds[i].default_trigger; +- +- led->name = pca955x_led->name; + led->brightness_set_blocking = pca955x_led_set; + led->brightness_get = pca955x_led_get; + +@@ -592,7 +573,28 @@ static int pca955x_probe(struct i2c_client *client, + return err; + } + +- err = devm_led_classdev_register(&client->dev, led); ++ init_data.fwnode = pdata->leds[i].fwnode; ++ ++ if (is_of_node(init_data.fwnode)) { ++ if (to_of_node(init_data.fwnode)->name[0] == ++ '\0') ++ set_default_label = true; ++ else ++ set_default_label = false; ++ } else { ++ set_default_label = true; ++ } ++ ++ if (set_default_label) { ++ snprintf(default_label, sizeof(default_label), ++ "%d", i); ++ init_data.default_label = default_label; ++ } else { ++ init_data.default_label = NULL; ++ } ++ ++ err = devm_led_classdev_register_ext(&client->dev, led, ++ &init_data); + if (err) + return err; + diff --git a/target/linux/generic/backport-5.10/844-v5.15-leds-pca955x-switch-to-i2c-probe-new.patch b/target/linux/generic/backport-5.10/844-v5.15-leds-pca955x-switch-to-i2c-probe-new.patch new file mode 100644 index 0000000000..77ac4e7dc9 --- /dev/null +++ b/target/linux/generic/backport-5.10/844-v5.15-leds-pca955x-switch-to-i2c-probe-new.patch @@ -0,0 +1,64 @@ +From 239f32b4f161c1584cd4b386d6ab8766432a6ede Mon Sep 17 00:00:00 2001 +From: Eddie James +Date: Fri, 16 Jul 2021 17:03:31 -0500 +Subject: [PATCH] leds: pca955x: Switch to i2c probe_new + +The deprecated i2c probe functionality doesn't work with OF +compatible strings, as it only checks for the i2c device id. Switch +to the new way of probing and grab the match data to select the +chip type. + +Signed-off-by: Eddie James +Signed-off-by: Pavel Machek +--- + drivers/leds/leds-pca955x.c | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c +index a6aa4b9abde8c4..a6b5699aeae4fe 100644 +--- a/drivers/leds/leds-pca955x.c ++++ b/drivers/leds/leds-pca955x.c +@@ -479,8 +479,7 @@ static const struct of_device_id of_pca955x_match[] = { + }; + MODULE_DEVICE_TABLE(of, of_pca955x_match); + +-static int pca955x_probe(struct i2c_client *client, +- const struct i2c_device_id *id) ++static int pca955x_probe(struct i2c_client *client) + { + struct pca955x *pca955x; + struct pca955x_led *pca955x_led; +@@ -494,8 +493,24 @@ static int pca955x_probe(struct i2c_client *client, + bool set_default_label = false; + bool keep_pwm = false; + char default_label[8]; ++ enum pca955x_type chip_type; ++ const void *md = device_get_match_data(&client->dev); + +- chip = &pca955x_chipdefs[id->driver_data]; ++ if (md) { ++ chip_type = (enum pca955x_type)md; ++ } else { ++ const struct i2c_device_id *id = i2c_match_id(pca955x_id, ++ client); ++ ++ if (id) { ++ chip_type = (enum pca955x_type)id->driver_data; ++ } else { ++ dev_err(&client->dev, "unknown chip\n"); ++ return -ENODEV; ++ } ++ } ++ ++ chip = &pca955x_chipdefs[chip_type]; + adapter = client->adapter; + pdata = dev_get_platdata(&client->dev); + if (!pdata) { +@@ -670,7 +685,7 @@ static struct i2c_driver pca955x_driver = { + .name = "leds-pca955x", + .of_match_table = of_pca955x_match, + }, +- .probe = pca955x_probe, ++ .probe_new = pca955x_probe, + .id_table = pca955x_id, + }; diff --git a/target/linux/generic/backport-5.15/401-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch b/target/linux/generic/backport-5.15/401-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch new file mode 100644 index 0000000000..ffc92fe9aa --- /dev/null +++ b/target/linux/generic/backport-5.15/401-v5.20-mtd-parsers-add-support-for-Sercomm-partitions.patch @@ -0,0 +1,302 @@ +From 9b78ef0c7997052e9eaa0f7a4513d546fa17358c Mon Sep 17 00:00:00 2001 +From: Mikhail Zhilkin +Date: Sun, 29 May 2022 11:07:14 +0000 +Subject: [PATCH] mtd: parsers: add support for Sercomm partitions + +This adds an MTD partition parser for the Sercomm partition table that +is used in some Beeline, Netgear and Sercomm routers. + +The Sercomm partition map table contains real partition offsets, which +may differ from device to device depending on the number and location of +bad blocks on NAND. + +Original patch (proposed by NOGUCHI Hiroshi): +Link: https://github.com/openwrt/openwrt/pull/1318#issuecomment-420607394 + +Signed-off-by: NOGUCHI Hiroshi +Signed-off-by: Mikhail Zhilkin +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20220529110714.189732-1-csharper2005@gmail.com +--- + drivers/mtd/parsers/Kconfig | 9 ++ + drivers/mtd/parsers/Makefile | 1 + + drivers/mtd/parsers/scpart.c | 248 +++++++++++++++++++++++++++++++++++ + 3 files changed, 258 insertions(+) + create mode 100644 drivers/mtd/parsers/scpart.c + +--- a/drivers/mtd/parsers/Kconfig ++++ b/drivers/mtd/parsers/Kconfig +@@ -186,3 +186,12 @@ config MTD_QCOMSMEM_PARTS + help + This provides support for parsing partitions from Shared Memory (SMEM) + for NAND and SPI flash on Qualcomm platforms. ++ ++config MTD_SERCOMM_PARTS ++ tristate "Sercomm partition table parser" ++ depends on MTD && RALINK ++ help ++ This provides partitions table parser for devices with Sercomm ++ partition map. This partition table contains real partition ++ offsets, which may differ from device to device depending on the ++ number and location of bad blocks on NAND. +--- a/drivers/mtd/parsers/Makefile ++++ b/drivers/mtd/parsers/Makefile +@@ -10,6 +10,7 @@ ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o + obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o + obj-$(CONFIG_MTD_AFS_PARTS) += afs.o + obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o ++obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o + obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o + obj-$(CONFIG_MTD_QCOMSMEM_PARTS) += qcomsmempart.o +--- /dev/null ++++ b/drivers/mtd/parsers/scpart.c +@@ -0,0 +1,248 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * drivers/mtd/scpart.c: Sercomm Partition Parser ++ * ++ * Copyright (C) 2018 NOGUCHI Hiroshi ++ * Copyright (C) 2022 Mikhail Zhilkin ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define MOD_NAME "scpart" ++ ++#ifdef pr_fmt ++#undef pr_fmt ++#endif ++ ++#define pr_fmt(fmt) MOD_NAME ": " fmt ++ ++#define ID_ALREADY_FOUND 0xffffffffUL ++ ++#define MAP_OFFS_IN_BLK 0x800 ++#define MAP_MIRROR_NUM 2 ++ ++static const char sc_part_magic[] = { ++ 'S', 'C', 'F', 'L', 'M', 'A', 'P', 'O', 'K', '\0', ++}; ++#define PART_MAGIC_LEN sizeof(sc_part_magic) ++ ++/* assumes that all fields are set by CPU native endian */ ++struct sc_part_desc { ++ uint32_t part_id; ++ uint32_t part_offs; ++ uint32_t part_bytes; ++}; ++ ++static uint32_t scpart_desc_is_valid(struct sc_part_desc *pdesc) ++{ ++ return ((pdesc->part_id != 0xffffffffUL) && ++ (pdesc->part_offs != 0xffffffffUL) && ++ (pdesc->part_bytes != 0xffffffffUL)); ++} ++ ++static int scpart_scan_partmap(struct mtd_info *master, loff_t partmap_offs, ++ struct sc_part_desc **ppdesc) ++{ ++ int cnt = 0; ++ int res = 0; ++ int res2; ++ loff_t offs; ++ size_t retlen; ++ struct sc_part_desc *pdesc = NULL; ++ struct sc_part_desc *tmpdesc; ++ uint8_t *buf; ++ ++ buf = kzalloc(master->erasesize, GFP_KERNEL); ++ if (!buf) { ++ res = -ENOMEM; ++ goto out; ++ } ++ ++ res2 = mtd_read(master, partmap_offs, master->erasesize, &retlen, buf); ++ if (res2 || retlen != master->erasesize) { ++ res = -EIO; ++ goto free; ++ } ++ ++ for (offs = MAP_OFFS_IN_BLK; ++ offs < master->erasesize - sizeof(*tmpdesc); ++ offs += sizeof(*tmpdesc)) { ++ tmpdesc = (struct sc_part_desc *)&buf[offs]; ++ if (!scpart_desc_is_valid(tmpdesc)) ++ break; ++ cnt++; ++ } ++ ++ if (cnt > 0) { ++ int bytes = cnt * sizeof(*pdesc); ++ ++ pdesc = kcalloc(cnt, sizeof(*pdesc), GFP_KERNEL); ++ if (!pdesc) { ++ res = -ENOMEM; ++ goto free; ++ } ++ memcpy(pdesc, &(buf[MAP_OFFS_IN_BLK]), bytes); ++ ++ *ppdesc = pdesc; ++ res = cnt; ++ } ++ ++free: ++ kfree(buf); ++ ++out: ++ return res; ++} ++ ++static int scpart_find_partmap(struct mtd_info *master, ++ struct sc_part_desc **ppdesc) ++{ ++ int magic_found = 0; ++ int res = 0; ++ int res2; ++ loff_t offs = 0; ++ size_t retlen; ++ uint8_t rdbuf[PART_MAGIC_LEN]; ++ ++ while ((magic_found < MAP_MIRROR_NUM) && ++ (offs < master->size) && ++ !mtd_block_isbad(master, offs)) { ++ res2 = mtd_read(master, offs, PART_MAGIC_LEN, &retlen, rdbuf); ++ if (res2 || retlen != PART_MAGIC_LEN) { ++ res = -EIO; ++ goto out; ++ } ++ if (!memcmp(rdbuf, sc_part_magic, PART_MAGIC_LEN)) { ++ pr_debug("Signature found at 0x%llx\n", offs); ++ magic_found++; ++ res = scpart_scan_partmap(master, offs, ppdesc); ++ if (res > 0) ++ goto out; ++ } ++ offs += master->erasesize; ++ } ++ ++out: ++ if (res > 0) ++ pr_info("Valid 'SC PART MAP' (%d partitions) found at 0x%llx\n", res, offs); ++ else ++ pr_info("No valid 'SC PART MAP' was found\n"); ++ ++ return res; ++} ++ ++static int scpart_parse(struct mtd_info *master, ++ const struct mtd_partition **pparts, ++ struct mtd_part_parser_data *data) ++{ ++ const char *partname; ++ int n; ++ int nr_scparts; ++ int nr_parts = 0; ++ int res = 0; ++ struct sc_part_desc *scpart_map = NULL; ++ struct mtd_partition *parts = NULL; ++ struct device_node *mtd_node; ++ struct device_node *ofpart_node; ++ struct device_node *pp; ++ ++ mtd_node = mtd_get_of_node(master); ++ if (!mtd_node) { ++ res = -ENOENT; ++ goto out; ++ } ++ ++ ofpart_node = of_get_child_by_name(mtd_node, "partitions"); ++ if (!ofpart_node) { ++ pr_info("%s: 'partitions' subnode not found on %pOF.\n", ++ master->name, mtd_node); ++ res = -ENOENT; ++ goto out; ++ } ++ ++ nr_scparts = scpart_find_partmap(master, &scpart_map); ++ if (nr_scparts <= 0) { ++ pr_info("No any partitions was found in 'SC PART MAP'.\n"); ++ res = -ENOENT; ++ goto free; ++ } ++ ++ parts = kcalloc(of_get_child_count(ofpart_node), sizeof(*parts), ++ GFP_KERNEL); ++ if (!parts) { ++ res = -ENOMEM; ++ goto free; ++ } ++ ++ for_each_child_of_node(ofpart_node, pp) { ++ u32 scpart_id; ++ ++ if (of_property_read_u32(pp, "sercomm,scpart-id", &scpart_id)) ++ continue; ++ ++ for (n = 0 ; n < nr_scparts ; n++) ++ if ((scpart_map[n].part_id != ID_ALREADY_FOUND) && ++ (scpart_id == scpart_map[n].part_id)) ++ break; ++ if (n >= nr_scparts) ++ /* not match */ ++ continue; ++ ++ /* add the partition found in OF into MTD partition array */ ++ parts[nr_parts].offset = scpart_map[n].part_offs; ++ parts[nr_parts].size = scpart_map[n].part_bytes; ++ parts[nr_parts].of_node = pp; ++ ++ if (!of_property_read_string(pp, "label", &partname)) ++ parts[nr_parts].name = partname; ++ if (of_property_read_bool(pp, "read-only")) ++ parts[nr_parts].mask_flags |= MTD_WRITEABLE; ++ if (of_property_read_bool(pp, "lock")) ++ parts[nr_parts].mask_flags |= MTD_POWERUP_LOCK; ++ ++ /* mark as 'done' */ ++ scpart_map[n].part_id = ID_ALREADY_FOUND; ++ ++ nr_parts++; ++ } ++ ++ if (nr_parts > 0) { ++ *pparts = parts; ++ res = nr_parts; ++ } else ++ pr_info("No partition in OF matches partition ID with 'SC PART MAP'.\n"); ++ ++ of_node_put(pp); ++ ++free: ++ kfree(scpart_map); ++ if (res <= 0) ++ kfree(parts); ++ ++out: ++ return res; ++} ++ ++static const struct of_device_id scpart_parser_of_match_table[] = { ++ { .compatible = "sercomm,sc-partitions" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, scpart_parser_of_match_table); ++ ++static struct mtd_part_parser scpart_parser = { ++ .parse_fn = scpart_parse, ++ .name = "scpart", ++ .of_match_table = scpart_parser_of_match_table, ++}; ++module_mtd_part_parser(scpart_parser); ++ ++/* mtd parsers will request the module by parser name */ ++MODULE_ALIAS("scpart"); ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("NOGUCHI Hiroshi "); ++MODULE_AUTHOR("Mikhail Zhilkin "); ++MODULE_DESCRIPTION("Sercomm partition parser"); diff --git a/target/linux/generic/pending-5.15/701-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch b/target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch rename to target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch diff --git a/target/linux/generic/pending-5.15/701-01-arm64-dts-mediatek-mt7622-add-support-for-coherent-D.patch b/target/linux/generic/backport-5.15/702-v5.19-01-arm64-dts-mediatek-mt7622-add-support-for-coherent-D.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-01-arm64-dts-mediatek-mt7622-add-support-for-coherent-D.patch rename to target/linux/generic/backport-5.15/702-v5.19-01-arm64-dts-mediatek-mt7622-add-support-for-coherent-D.patch diff --git a/target/linux/generic/pending-5.15/701-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch b/target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch rename to target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch diff --git a/target/linux/generic/pending-5.15/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch b/target/linux/generic/backport-5.15/702-v5.19-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch rename to target/linux/generic/backport-5.15/702-v5.19-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch diff --git a/target/linux/generic/pending-5.15/701-04-arm64-dts-mediatek-mt7622-introduce-nodes-for-Wirele.patch b/target/linux/generic/backport-5.15/702-v5.19-04-arm64-dts-mediatek-mt7622-introduce-nodes-for-Wirele.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-04-arm64-dts-mediatek-mt7622-introduce-nodes-for-Wirele.patch rename to target/linux/generic/backport-5.15/702-v5.19-04-arm64-dts-mediatek-mt7622-introduce-nodes-for-Wirele.patch diff --git a/target/linux/generic/pending-5.15/701-05-net-ethernet-mtk_eth_soc-add-ipv6-flow-offload-suppo.patch b/target/linux/generic/backport-5.15/702-v5.19-05-net-ethernet-mtk_eth_soc-add-ipv6-flow-offload-suppo.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-05-net-ethernet-mtk_eth_soc-add-ipv6-flow-offload-suppo.patch rename to target/linux/generic/backport-5.15/702-v5.19-05-net-ethernet-mtk_eth_soc-add-ipv6-flow-offload-suppo.patch diff --git a/target/linux/generic/pending-5.15/701-06-net-ethernet-mtk_eth_soc-support-TC_SETUP_BLOCK-for-.patch b/target/linux/generic/backport-5.15/702-v5.19-06-net-ethernet-mtk_eth_soc-support-TC_SETUP_BLOCK-for-.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-06-net-ethernet-mtk_eth_soc-support-TC_SETUP_BLOCK-for-.patch rename to target/linux/generic/backport-5.15/702-v5.19-06-net-ethernet-mtk_eth_soc-support-TC_SETUP_BLOCK-for-.patch diff --git a/target/linux/generic/pending-5.15/701-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch b/target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch rename to target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch diff --git a/target/linux/generic/pending-5.15/701-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch b/target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch rename to target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch diff --git a/target/linux/generic/pending-5.15/701-09-net-ethernet-mtk_eth_soc-remove-bridge-flow-offload-.patch b/target/linux/generic/backport-5.15/702-v5.19-09-net-ethernet-mtk_eth_soc-remove-bridge-flow-offload-.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-09-net-ethernet-mtk_eth_soc-remove-bridge-flow-offload-.patch rename to target/linux/generic/backport-5.15/702-v5.19-09-net-ethernet-mtk_eth_soc-remove-bridge-flow-offload-.patch diff --git a/target/linux/generic/pending-5.15/701-10-net-ethernet-mtk_eth_soc-support-creating-mac-addres.patch b/target/linux/generic/backport-5.15/702-v5.19-10-net-ethernet-mtk_eth_soc-support-creating-mac-addres.patch similarity index 100% rename from target/linux/generic/pending-5.15/701-10-net-ethernet-mtk_eth_soc-support-creating-mac-addres.patch rename to target/linux/generic/backport-5.15/702-v5.19-10-net-ethernet-mtk_eth_soc-support-creating-mac-addres.patch diff --git a/target/linux/generic/backport-5.15/702-v5.19-11-net-ethernet-mtk_eth_soc-wed-fix-sparse-endian-warni.patch b/target/linux/generic/backport-5.15/702-v5.19-11-net-ethernet-mtk_eth_soc-wed-fix-sparse-endian-warni.patch new file mode 100644 index 0000000000..8f3dfe8239 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-11-net-ethernet-mtk_eth_soc-wed-fix-sparse-endian-warni.patch @@ -0,0 +1,56 @@ +From: Felix Fietkau +Date: Fri, 8 Apr 2022 10:59:45 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc/wed: fix sparse endian warnings + +Descriptor fields are little-endian + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Reported-by: kernel test robot +Signed-off-by: Felix Fietkau +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -144,16 +144,17 @@ mtk_wed_buffer_alloc(struct mtk_wed_devi + + for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) { + u32 txd_size; ++ u32 ctrl; + + txd_size = dev->wlan.init_buf(buf, buf_phys, token++); + +- desc->buf0 = buf_phys; +- desc->buf1 = buf_phys + txd_size; +- desc->ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, +- txd_size) | +- FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, +- MTK_WED_BUF_SIZE - txd_size) | +- MTK_WDMA_DESC_CTRL_LAST_SEG1; ++ desc->buf0 = cpu_to_le32(buf_phys); ++ desc->buf1 = cpu_to_le32(buf_phys + txd_size); ++ ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size) | ++ FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, ++ MTK_WED_BUF_SIZE - txd_size) | ++ MTK_WDMA_DESC_CTRL_LAST_SEG1; ++ desc->ctrl = cpu_to_le32(ctrl); + desc->info = 0; + desc++; + +@@ -184,12 +185,14 @@ mtk_wed_free_buffer(struct mtk_wed_devic + + for (i = 0, page_idx = 0; i < dev->buf_ring.size; i += MTK_WED_BUF_PER_PAGE) { + void *page = page_list[page_idx++]; ++ dma_addr_t buf_addr; + + if (!page) + break; + +- dma_unmap_page(dev->hw->dev, desc[i].buf0, +- PAGE_SIZE, DMA_BIDIRECTIONAL); ++ buf_addr = le32_to_cpu(desc[i].buf0); ++ dma_unmap_page(dev->hw->dev, buf_addr, PAGE_SIZE, ++ DMA_BIDIRECTIONAL); + __free_page(page); + } + diff --git a/target/linux/generic/backport-5.15/702-v5.19-12-net-ethernet-mtk_eth_soc-fix-return-value-check-in-m.patch b/target/linux/generic/backport-5.15/702-v5.19-12-net-ethernet-mtk_eth_soc-fix-return-value-check-in-m.patch new file mode 100644 index 0000000000..4ec8fe74bc --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-12-net-ethernet-mtk_eth_soc-fix-return-value-check-in-m.patch @@ -0,0 +1,25 @@ +From: Yang Yingliang +Date: Fri, 8 Apr 2022 11:22:46 +0800 +Subject: [PATCH] net: ethernet: mtk_eth_soc: fix return value check in + mtk_wed_add_hw() + +If syscon_regmap_lookup_by_phandle() fails, it never return NULL pointer, +change the check to IS_ERR(). + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Reported-by: Hulk Robot +Signed-off-by: Yang Yingliang +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -816,7 +816,7 @@ void mtk_wed_add_hw(struct device_node * + return; + + regs = syscon_regmap_lookup_by_phandle(np, NULL); +- if (!regs) ++ if (IS_ERR(regs)) + return; + + rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops); diff --git a/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch b/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch new file mode 100644 index 0000000000..285430d033 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch @@ -0,0 +1,35 @@ +From: Lorenzo Bianconi +Date: Mon, 11 Apr 2022 12:13:25 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: use standard property for + cci-control-port + +Rely on standard cci-control-port property to identify CCI port +reference. +Update mt7622 dts binding. + +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi ++++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi +@@ -962,7 +962,7 @@ + power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>; + mediatek,ethsys = <ðsys>; + mediatek,sgmiisys = <&sgmiisys>; +- mediatek,cci-control = <&cci_control2>; ++ cci-control-port = <&cci_control2>; + mediatek,wed = <&wed0>, <&wed1>; + mediatek,pcie-mirror = <&pcie_mirror>; + mediatek,hifsys = <&hifsys>; +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -3165,7 +3165,7 @@ static int mtk_probe(struct platform_dev + struct regmap *cci; + + cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, +- "mediatek,cci-control"); ++ "cci-control-port"); + /* enable CPU/bus coherency */ + if (!IS_ERR(cci)) + regmap_write(cci, 0, 3); diff --git a/target/linux/generic/backport-5.15/702-v5.19-14-net-ethernet-mtk_eth_soc-use-after-free-in-__mtk_ppe.patch b/target/linux/generic/backport-5.15/702-v5.19-14-net-ethernet-mtk_eth_soc-use-after-free-in-__mtk_ppe.patch new file mode 100644 index 0000000000..656b3a159e --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-14-net-ethernet-mtk_eth_soc-use-after-free-in-__mtk_ppe.patch @@ -0,0 +1,33 @@ +From: Dan Carpenter +Date: Tue, 12 Apr 2022 12:24:19 +0300 +Subject: [PATCH] net: ethernet: mtk_eth_soc: use after free in + __mtk_ppe_check_skb() + +The __mtk_foe_entry_clear() function frees "entry" so we have to use +the _safe() version of hlist_for_each_entry() to prevent a use after +free. + +Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.c +@@ -600,6 +600,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe + struct mtk_foe_entry *hwe = &ppe->foe_table[hash]; + struct mtk_flow_entry *entry; + struct mtk_foe_bridge key = {}; ++ struct hlist_node *n; + struct ethhdr *eh; + bool found = false; + u8 *tag; +@@ -609,7 +610,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe + if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND) + goto out; + +- hlist_for_each_entry(entry, head, list) { ++ hlist_for_each_entry_safe(entry, n, head, list) { + if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) { + if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == + MTK_FOE_STATE_BIND)) diff --git a/target/linux/generic/backport-5.15/702-v5.19-15-net-ethernet-mtk_eth_soc-add-check-for-allocation-fa.patch b/target/linux/generic/backport-5.15/702-v5.19-15-net-ethernet-mtk_eth_soc-add-check-for-allocation-fa.patch new file mode 100644 index 0000000000..714163c86b --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-15-net-ethernet-mtk_eth_soc-add-check-for-allocation-fa.patch @@ -0,0 +1,22 @@ +From: Dan Carpenter +Date: Thu, 21 Apr 2022 18:49:02 +0300 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add check for allocation failure + +Check if the kzalloc() failed. + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -827,6 +827,8 @@ void mtk_wed_add_hw(struct device_node * + goto unlock; + + hw = kzalloc(sizeof(*hw), GFP_KERNEL); ++ if (!hw) ++ goto unlock; + hw->node = np; + hw->regs = regs; + hw->eth = eth; diff --git a/target/linux/generic/backport-5.15/702-v5.19-16-eth-mtk_eth_soc-silence-the-GCC-12-array-bounds-warn.patch b/target/linux/generic/backport-5.15/702-v5.19-16-eth-mtk_eth_soc-silence-the-GCC-12-array-bounds-warn.patch new file mode 100644 index 0000000000..aa98745ac6 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-16-eth-mtk_eth_soc-silence-the-GCC-12-array-bounds-warn.patch @@ -0,0 +1,26 @@ +From: Jakub Kicinski +Date: Fri, 20 May 2022 12:56:03 -0700 +Subject: [PATCH] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning + +GCC 12 gets upset because in mtk_foe_entry_commit_subflow() +this driver allocates a partial structure. The writes are +within bounds. + +Silence these warnings for now, our build bot runs GCC 12 +so we won't allow any new instances. + +Signed-off-by: Jakub Kicinski +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/Makefile ++++ b/drivers/net/ethernet/mediatek/Makefile +@@ -11,3 +11,8 @@ mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) + + endif + obj-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_ops.o + obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o ++ ++# FIXME: temporarily silence -Warray-bounds on non W=1+ builds ++ifndef KBUILD_EXTRA_WARN ++CFLAGS_mtk_ppe.o += -Wno-array-bounds ++endif diff --git a/target/linux/generic/backport-5.15/702-v5.19-17-net-ethernet-mtk_eth_soc-rely-on-GFP_KERNEL-for-dma_.patch b/target/linux/generic/backport-5.15/702-v5.19-17-net-ethernet-mtk_eth_soc-rely-on-GFP_KERNEL-for-dma_.patch new file mode 100644 index 0000000000..db4d9b34d3 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-17-net-ethernet-mtk_eth_soc-rely-on-GFP_KERNEL-for-dma_.patch @@ -0,0 +1,52 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:26 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on GFP_KERNEL for + dma_alloc_coherent whenever possible + +Rely on GFP_KERNEL for dma descriptors mappings in mtk_tx_alloc(), +mtk_rx_alloc() and mtk_init_fq_dma() since they are run in non-irq +context. + +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -834,7 +834,7 @@ static int mtk_init_fq_dma(struct mtk_et + eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, + cnt * sizeof(struct mtk_tx_dma), + ð->phy_scratch_ring, +- GFP_ATOMIC); ++ GFP_KERNEL); + if (unlikely(!eth->scratch_ring)) + return -ENOMEM; + +@@ -1609,7 +1609,7 @@ static int mtk_tx_alloc(struct mtk_eth * + goto no_tx_mem; + + ring->dma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, +- &ring->phys, GFP_ATOMIC); ++ &ring->phys, GFP_KERNEL); + if (!ring->dma) + goto no_tx_mem; + +@@ -1627,8 +1627,7 @@ static int mtk_tx_alloc(struct mtk_eth * + */ + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { + ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, +- &ring->phys_pdma, +- GFP_ATOMIC); ++ &ring->phys_pdma, GFP_KERNEL); + if (!ring->dma_pdma) + goto no_tx_mem; + +@@ -1740,7 +1739,7 @@ static int mtk_rx_alloc(struct mtk_eth * + + ring->dma = dma_alloc_coherent(eth->dma_dev, + rx_dma_size * sizeof(*ring->dma), +- &ring->phys, GFP_ATOMIC); ++ &ring->phys, GFP_KERNEL); + if (!ring->dma) + return -ENOMEM; + diff --git a/target/linux/generic/backport-5.15/702-v5.19-18-net-ethernet-mtk_eth_soc-move-tx-dma-desc-configurat.patch b/target/linux/generic/backport-5.15/702-v5.19-18-net-ethernet-mtk_eth_soc-move-tx-dma-desc-configurat.patch new file mode 100644 index 0000000000..09638b4580 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-18-net-ethernet-mtk_eth_soc-move-tx-dma-desc-configurat.patch @@ -0,0 +1,206 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:27 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: move tx dma desc configuration in + mtk_tx_set_dma_desc + +Move tx dma descriptor configuration in mtk_tx_set_dma_desc routine. +This is a preliminary patch to introduce mt7986 ethernet support since +it relies on a different tx dma descriptor layout. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -960,18 +960,51 @@ static void setup_tx_buf(struct mtk_eth + } + } + ++static void mtk_tx_set_dma_desc(struct net_device *dev, struct mtk_tx_dma *desc, ++ struct mtk_tx_dma_desc_info *info) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ u32 data; ++ ++ WRITE_ONCE(desc->txd1, info->addr); ++ ++ data = TX_DMA_SWC | TX_DMA_PLEN0(info->size); ++ if (info->last) ++ data |= TX_DMA_LS0; ++ WRITE_ONCE(desc->txd3, data); ++ ++ data = (mac->id + 1) << TX_DMA_FPORT_SHIFT; /* forward port */ ++ if (info->first) { ++ if (info->gso) ++ data |= TX_DMA_TSO; ++ /* tx checksum offload */ ++ if (info->csum) ++ data |= TX_DMA_CHKSUM; ++ /* vlan header offload */ ++ if (info->vlan) ++ data |= TX_DMA_INS_VLAN | info->vlan_tci; ++ } ++ WRITE_ONCE(desc->txd4, data); ++} ++ + static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, + int tx_num, struct mtk_tx_ring *ring, bool gso) + { ++ struct mtk_tx_dma_desc_info txd_info = { ++ .size = skb_headlen(skb), ++ .gso = gso, ++ .csum = skb->ip_summed == CHECKSUM_PARTIAL, ++ .vlan = skb_vlan_tag_present(skb), ++ .vlan_tci = skb_vlan_tag_get(skb), ++ .first = true, ++ .last = !skb_is_nonlinear(skb), ++ }; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + struct mtk_tx_dma *itxd, *txd; + struct mtk_tx_dma *itxd_pdma, *txd_pdma; + struct mtk_tx_buf *itx_buf, *tx_buf; +- dma_addr_t mapped_addr; +- unsigned int nr_frags; + int i, n_desc = 1; +- u32 txd4 = 0, fport; + int k = 0; + + itxd = ring->next_free; +@@ -979,49 +1012,32 @@ static int mtk_tx_map(struct sk_buff *sk + if (itxd == ring->last_free) + return -ENOMEM; + +- /* set the forward port */ +- fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; +- txd4 |= fport; +- + itx_buf = mtk_desc_to_tx_buf(ring, itxd); + memset(itx_buf, 0, sizeof(*itx_buf)); + +- if (gso) +- txd4 |= TX_DMA_TSO; +- +- /* TX Checksum offload */ +- if (skb->ip_summed == CHECKSUM_PARTIAL) +- txd4 |= TX_DMA_CHKSUM; +- +- /* VLAN header offload */ +- if (skb_vlan_tag_present(skb)) +- txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb); +- +- mapped_addr = dma_map_single(eth->dma_dev, skb->data, +- skb_headlen(skb), DMA_TO_DEVICE); +- if (unlikely(dma_mapping_error(eth->dma_dev, mapped_addr))) ++ txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, ++ DMA_TO_DEVICE); ++ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) + return -ENOMEM; + +- WRITE_ONCE(itxd->txd1, mapped_addr); ++ mtk_tx_set_dma_desc(dev, itxd, &txd_info); ++ + itx_buf->flags |= MTK_TX_FLAGS_SINGLE0; + itx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : + MTK_TX_FLAGS_FPORT1; +- setup_tx_buf(eth, itx_buf, itxd_pdma, mapped_addr, skb_headlen(skb), ++ setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size, + k++); + + /* TX SG offload */ + txd = itxd; + txd_pdma = qdma_to_pdma(ring, txd); +- nr_frags = skb_shinfo(skb)->nr_frags; + +- for (i = 0; i < nr_frags; i++) { ++ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + unsigned int offset = 0; + int frag_size = skb_frag_size(frag); + + while (frag_size) { +- bool last_frag = false; +- unsigned int frag_map_size; + bool new_desc = true; + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) || +@@ -1036,23 +1052,17 @@ static int mtk_tx_map(struct sk_buff *sk + new_desc = false; + } + +- +- frag_map_size = min(frag_size, MTK_TX_DMA_BUF_LEN); +- mapped_addr = skb_frag_dma_map(eth->dma_dev, frag, offset, +- frag_map_size, +- DMA_TO_DEVICE); +- if (unlikely(dma_mapping_error(eth->dma_dev, mapped_addr))) ++ memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); ++ txd_info.size = min(frag_size, MTK_TX_DMA_BUF_LEN); ++ txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 && ++ !(frag_size - txd_info.size); ++ txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, ++ offset, txd_info.size, ++ DMA_TO_DEVICE); ++ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) + goto err_dma; + +- if (i == nr_frags - 1 && +- (frag_size - frag_map_size) == 0) +- last_frag = true; +- +- WRITE_ONCE(txd->txd1, mapped_addr); +- WRITE_ONCE(txd->txd3, (TX_DMA_SWC | +- TX_DMA_PLEN0(frag_map_size) | +- last_frag * TX_DMA_LS0)); +- WRITE_ONCE(txd->txd4, fport); ++ mtk_tx_set_dma_desc(dev, txd, &txd_info); + + tx_buf = mtk_desc_to_tx_buf(ring, txd); + if (new_desc) +@@ -1062,20 +1072,17 @@ static int mtk_tx_map(struct sk_buff *sk + tx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : + MTK_TX_FLAGS_FPORT1; + +- setup_tx_buf(eth, tx_buf, txd_pdma, mapped_addr, +- frag_map_size, k++); ++ setup_tx_buf(eth, tx_buf, txd_pdma, txd_info.addr, ++ txd_info.size, k++); + +- frag_size -= frag_map_size; +- offset += frag_map_size; ++ frag_size -= txd_info.size; ++ offset += txd_info.size; + } + } + + /* store skb to cleanup */ + itx_buf->skb = skb; + +- WRITE_ONCE(itxd->txd4, txd4); +- WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | +- (!nr_frags * TX_DMA_LS0))); + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { + if (k & 0x1) + txd_pdma->txd2 |= TX_DMA_LS0; +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -842,6 +842,17 @@ enum mkt_eth_capabilities { + MTK_MUX_U3_GMAC2_TO_QPHY | \ + MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA) + ++struct mtk_tx_dma_desc_info { ++ dma_addr_t addr; ++ u32 size; ++ u16 vlan_tci; ++ u8 gso:1; ++ u8 csum:1; ++ u8 vlan:1; ++ u8 first:1; ++ u8 last:1; ++}; ++ + /* struct mtk_eth_data - This is the structure holding all differences + * among various plaforms + * @ana_rgc3: The offset for register ANA_RGC3 related to diff --git a/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch b/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch new file mode 100644 index 0000000000..d40d177638 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch @@ -0,0 +1,167 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:28 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add txd_size to mtk_soc_data + +In order to remove mtk_tx_dma size dependency, introduce txd_size in +mtk_soc_data data structure. Rely on txd_size in mtk_init_fq_dma() and +mtk_dma_free() routines. +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -826,20 +826,20 @@ static inline bool mtk_rx_get_desc(struc + /* the qdma core needs scratch memory to be setup */ + static int mtk_init_fq_dma(struct mtk_eth *eth) + { ++ const struct mtk_soc_data *soc = eth->soc; + dma_addr_t phy_ring_tail; + int cnt = MTK_DMA_SIZE; + dma_addr_t dma_addr; + int i; + + eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, +- cnt * sizeof(struct mtk_tx_dma), ++ cnt * soc->txrx.txd_size, + ð->phy_scratch_ring, + GFP_KERNEL); + if (unlikely(!eth->scratch_ring)) + return -ENOMEM; + +- eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, +- GFP_KERNEL); ++ eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, GFP_KERNEL); + if (unlikely(!eth->scratch_head)) + return -ENOMEM; + +@@ -849,16 +849,19 @@ static int mtk_init_fq_dma(struct mtk_et + if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) + return -ENOMEM; + +- phy_ring_tail = eth->phy_scratch_ring + +- (sizeof(struct mtk_tx_dma) * (cnt - 1)); ++ phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1); + + for (i = 0; i < cnt; i++) { +- eth->scratch_ring[i].txd1 = +- (dma_addr + (i * MTK_QDMA_PAGE_SIZE)); ++ struct mtk_tx_dma *txd; ++ ++ txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size; ++ txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; + if (i < cnt - 1) +- eth->scratch_ring[i].txd2 = (eth->phy_scratch_ring + +- ((i + 1) * sizeof(struct mtk_tx_dma))); +- eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE); ++ txd->txd2 = eth->phy_scratch_ring + ++ (i + 1) * soc->txrx.txd_size; ++ ++ txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE); ++ txd->txd4 = 0; + } + + mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD); +@@ -2149,6 +2152,7 @@ static int mtk_dma_init(struct mtk_eth * + + static void mtk_dma_free(struct mtk_eth *eth) + { ++ const struct mtk_soc_data *soc = eth->soc; + int i; + + for (i = 0; i < MTK_MAC_COUNT; i++) +@@ -2156,9 +2160,8 @@ static void mtk_dma_free(struct mtk_eth + netdev_reset_queue(eth->netdev[i]); + if (eth->scratch_ring) { + dma_free_coherent(eth->dma_dev, +- MTK_DMA_SIZE * sizeof(struct mtk_tx_dma), +- eth->scratch_ring, +- eth->phy_scratch_ring); ++ MTK_DMA_SIZE * soc->txrx.txd_size, ++ eth->scratch_ring, eth->phy_scratch_ring); + eth->scratch_ring = NULL; + eth->phy_scratch_ring = 0; + } +@@ -3368,6 +3371,9 @@ static const struct mtk_soc_data mt2701_ + .hw_features = MTK_HW_FEATURES, + .required_clks = MT7623_CLKS_BITMAP, + .required_pctl = true, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + static const struct mtk_soc_data mt7621_data = { +@@ -3376,6 +3382,9 @@ static const struct mtk_soc_data mt7621_ + .required_clks = MT7621_CLKS_BITMAP, + .required_pctl = false, + .offload_version = 2, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + static const struct mtk_soc_data mt7622_data = { +@@ -3385,6 +3394,9 @@ static const struct mtk_soc_data mt7622_ + .required_clks = MT7622_CLKS_BITMAP, + .required_pctl = false, + .offload_version = 2, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + static const struct mtk_soc_data mt7623_data = { +@@ -3393,6 +3405,9 @@ static const struct mtk_soc_data mt7623_ + .required_clks = MT7623_CLKS_BITMAP, + .required_pctl = true, + .offload_version = 2, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + static const struct mtk_soc_data mt7629_data = { +@@ -3401,6 +3416,9 @@ static const struct mtk_soc_data mt7629_ + .hw_features = MTK_HW_FEATURES, + .required_clks = MT7629_CLKS_BITMAP, + .required_pctl = false, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + static const struct mtk_soc_data rt5350_data = { +@@ -3408,6 +3426,9 @@ static const struct mtk_soc_data rt5350_ + .hw_features = MTK_HW_FEATURES_MT7628, + .required_clks = MT7628_CLKS_BITMAP, + .required_pctl = false, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma), ++ }, + }; + + const struct of_device_id of_mtk_match[] = { +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -863,6 +863,7 @@ struct mtk_tx_dma_desc_info { + * the target SoC + * @required_pctl A bool value to show whether the SoC requires + * the extra setup for those pins used by GMAC. ++ * @txd_size Tx DMA descriptor size. + */ + struct mtk_soc_data { + u32 ana_rgc3; +@@ -871,6 +872,9 @@ struct mtk_soc_data { + bool required_pctl; + u8 offload_version; + netdev_features_t hw_features; ++ struct { ++ u32 txd_size; ++ } txrx; + }; + + /* currently no SoC has more than 2 macs */ diff --git a/target/linux/generic/backport-5.15/702-v5.19-20-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_tx_.patch b/target/linux/generic/backport-5.15/702-v5.19-20-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_tx_.patch new file mode 100644 index 0000000000..13f1300d55 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-20-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_tx_.patch @@ -0,0 +1,78 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:29 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in + mtk_tx_alloc/mtk_tx_clean + +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1610,8 +1610,10 @@ static int mtk_napi_rx(struct napi_struc + + static int mtk_tx_alloc(struct mtk_eth *eth) + { ++ const struct mtk_soc_data *soc = eth->soc; + struct mtk_tx_ring *ring = ð->tx_ring; +- int i, sz = sizeof(*ring->dma); ++ int i, sz = soc->txrx.txd_size; ++ struct mtk_tx_dma *txd; + + ring->buf = kcalloc(MTK_DMA_SIZE, sizeof(*ring->buf), + GFP_KERNEL); +@@ -1627,8 +1629,10 @@ static int mtk_tx_alloc(struct mtk_eth * + int next = (i + 1) % MTK_DMA_SIZE; + u32 next_ptr = ring->phys + next * sz; + +- ring->dma[i].txd2 = next_ptr; +- ring->dma[i].txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; ++ txd = (void *)ring->dma + i * sz; ++ txd->txd2 = next_ptr; ++ txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; ++ txd->txd4 = 0; + } + + /* On MT7688 (PDMA only) this driver uses the ring->dma structs +@@ -1650,7 +1654,7 @@ static int mtk_tx_alloc(struct mtk_eth * + ring->dma_size = MTK_DMA_SIZE; + atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); + ring->next_free = &ring->dma[0]; +- ring->last_free = &ring->dma[MTK_DMA_SIZE - 1]; ++ ring->last_free = (void *)txd; + ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); + ring->thresh = MAX_SKB_FRAGS; + +@@ -1683,6 +1687,7 @@ no_tx_mem: + + static void mtk_tx_clean(struct mtk_eth *eth) + { ++ const struct mtk_soc_data *soc = eth->soc; + struct mtk_tx_ring *ring = ð->tx_ring; + int i; + +@@ -1695,17 +1700,15 @@ static void mtk_tx_clean(struct mtk_eth + + if (ring->dma) { + dma_free_coherent(eth->dma_dev, +- MTK_DMA_SIZE * sizeof(*ring->dma), +- ring->dma, +- ring->phys); ++ MTK_DMA_SIZE * soc->txrx.txd_size, ++ ring->dma, ring->phys); + ring->dma = NULL; + } + + if (ring->dma_pdma) { + dma_free_coherent(eth->dma_dev, +- MTK_DMA_SIZE * sizeof(*ring->dma_pdma), +- ring->dma_pdma, +- ring->phys_pdma); ++ MTK_DMA_SIZE * soc->txrx.txd_size, ++ ring->dma_pdma, ring->phys_pdma); + ring->dma_pdma = NULL; + } + } diff --git a/target/linux/generic/backport-5.15/702-v5.19-21-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_des.patch b/target/linux/generic/backport-5.15/702-v5.19-21-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_des.patch new file mode 100644 index 0000000000..70362a0412 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-21-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_des.patch @@ -0,0 +1,109 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:30 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in + mtk_desc_to_tx_buf + +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -879,10 +879,11 @@ static inline void *mtk_qdma_phys_to_vir + return ret + (desc - ring->phys); + } + +-static inline struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, +- struct mtk_tx_dma *txd) ++static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, ++ struct mtk_tx_dma *txd, ++ u32 txd_size) + { +- int idx = txd - ring->dma; ++ int idx = ((void *)txd - (void *)ring->dma) / txd_size; + + return &ring->buf[idx]; + } +@@ -1004,6 +1005,7 @@ static int mtk_tx_map(struct sk_buff *sk + }; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; ++ const struct mtk_soc_data *soc = eth->soc; + struct mtk_tx_dma *itxd, *txd; + struct mtk_tx_dma *itxd_pdma, *txd_pdma; + struct mtk_tx_buf *itx_buf, *tx_buf; +@@ -1015,7 +1017,7 @@ static int mtk_tx_map(struct sk_buff *sk + if (itxd == ring->last_free) + return -ENOMEM; + +- itx_buf = mtk_desc_to_tx_buf(ring, itxd); ++ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size); + memset(itx_buf, 0, sizeof(*itx_buf)); + + txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, +@@ -1043,7 +1045,7 @@ static int mtk_tx_map(struct sk_buff *sk + while (frag_size) { + bool new_desc = true; + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) || ++ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA) || + (i & 0x1)) { + txd = mtk_qdma_phys_to_virt(ring, txd->txd2); + txd_pdma = qdma_to_pdma(ring, txd); +@@ -1067,7 +1069,8 @@ static int mtk_tx_map(struct sk_buff *sk + + mtk_tx_set_dma_desc(dev, txd, &txd_info); + +- tx_buf = mtk_desc_to_tx_buf(ring, txd); ++ tx_buf = mtk_desc_to_tx_buf(ring, txd, ++ soc->txrx.txd_size); + if (new_desc) + memset(tx_buf, 0, sizeof(*tx_buf)); + tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; +@@ -1086,7 +1089,7 @@ static int mtk_tx_map(struct sk_buff *sk + /* store skb to cleanup */ + itx_buf->skb = skb; + +- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { ++ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { + if (k & 0x1) + txd_pdma->txd2 |= TX_DMA_LS0; + else +@@ -1104,7 +1107,7 @@ static int mtk_tx_map(struct sk_buff *sk + */ + wmb(); + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { ++ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { + if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || + !netdev_xmit_more()) + mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); +@@ -1118,13 +1121,13 @@ static int mtk_tx_map(struct sk_buff *sk + + err_dma: + do { +- tx_buf = mtk_desc_to_tx_buf(ring, itxd); ++ tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size); + + /* unmap dma */ + mtk_tx_unmap(eth, tx_buf, false); + + itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; +- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) ++ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) + itxd_pdma->txd2 = TX_DMA_DESP2_DEF; + + itxd = mtk_qdma_phys_to_virt(ring, itxd->txd2); +@@ -1435,7 +1438,8 @@ static int mtk_poll_tx_qdma(struct mtk_e + if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0) + break; + +- tx_buf = mtk_desc_to_tx_buf(ring, desc); ++ tx_buf = mtk_desc_to_tx_buf(ring, desc, ++ eth->soc->txrx.txd_size); + if (tx_buf->flags & MTK_TX_FLAGS_FPORT1) + mac = 1; + diff --git a/target/linux/generic/backport-5.15/702-v5.19-22-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-txd_to_.patch b/target/linux/generic/backport-5.15/702-v5.19-22-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-txd_to_.patch new file mode 100644 index 0000000000..8c97327bd0 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-22-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-txd_to_.patch @@ -0,0 +1,39 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:31 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in txd_to_idx + +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -894,9 +894,10 @@ static struct mtk_tx_dma *qdma_to_pdma(s + return ring->dma_pdma - ring->dma + dma; + } + +-static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma) ++static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma, ++ u32 txd_size) + { +- return ((void *)dma - (void *)ring->dma) / sizeof(*dma); ++ return ((void *)dma - (void *)ring->dma) / txd_size; + } + + static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, +@@ -1112,8 +1113,10 @@ static int mtk_tx_map(struct sk_buff *sk + !netdev_xmit_more()) + mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); + } else { +- int next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd), +- ring->dma_size); ++ int next_idx; ++ ++ next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->txrx.txd_size), ++ ring->dma_size); + mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0); + } + diff --git a/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch b/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch new file mode 100644 index 0000000000..72c14d67b7 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch @@ -0,0 +1,102 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:32 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add rxd_size to mtk_soc_data + +Similar to tx counterpart, introduce rxd_size in mtk_soc_data data +structure. +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1758,7 +1758,7 @@ static int mtk_rx_alloc(struct mtk_eth * + } + + ring->dma = dma_alloc_coherent(eth->dma_dev, +- rx_dma_size * sizeof(*ring->dma), ++ rx_dma_size * eth->soc->txrx.rxd_size, + &ring->phys, GFP_KERNEL); + if (!ring->dma) + return -ENOMEM; +@@ -1816,9 +1816,8 @@ static void mtk_rx_clean(struct mtk_eth + + if (ring->dma) { + dma_free_coherent(eth->dma_dev, +- ring->dma_size * sizeof(*ring->dma), +- ring->dma, +- ring->phys); ++ ring->dma_size * eth->soc->txrx.rxd_size, ++ ring->dma, ring->phys); + ring->dma = NULL; + } + } +@@ -3383,6 +3382,7 @@ static const struct mtk_soc_data mt2701_ + .required_pctl = true, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +@@ -3394,6 +3394,7 @@ static const struct mtk_soc_data mt7621_ + .offload_version = 2, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +@@ -3406,6 +3407,7 @@ static const struct mtk_soc_data mt7622_ + .offload_version = 2, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +@@ -3417,6 +3419,7 @@ static const struct mtk_soc_data mt7623_ + .offload_version = 2, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +@@ -3428,6 +3431,7 @@ static const struct mtk_soc_data mt7629_ + .required_pctl = false, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +@@ -3438,6 +3442,7 @@ static const struct mtk_soc_data rt5350_ + .required_pctl = false, + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), ++ .rxd_size = sizeof(struct mtk_rx_dma), + }, + }; + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -864,6 +864,7 @@ struct mtk_tx_dma_desc_info { + * @required_pctl A bool value to show whether the SoC requires + * the extra setup for those pins used by GMAC. + * @txd_size Tx DMA descriptor size. ++ * @rxd_size Rx DMA descriptor size. + */ + struct mtk_soc_data { + u32 ana_rgc3; +@@ -874,6 +875,7 @@ struct mtk_soc_data { + netdev_features_t hw_features; + struct { + u32 txd_size; ++ u32 rxd_size; + } txrx; + }; + diff --git a/target/linux/generic/backport-5.15/702-v5.19-24-net-ethernet-mtk_eth_soc-rely-on-txd_size-field-in-m.patch b/target/linux/generic/backport-5.15/702-v5.19-24-net-ethernet-mtk_eth_soc-rely-on-txd_size-field-in-m.patch new file mode 100644 index 0000000000..12e88db464 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-24-net-ethernet-mtk_eth_soc-rely-on-txd_size-field-in-m.patch @@ -0,0 +1,46 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:33 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size field in + mtk_poll_tx/mtk_poll_rx + +This is a preliminary to ad mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1253,9 +1253,12 @@ static struct mtk_rx_ring *mtk_get_rx_ri + return ð->rx_ring[0]; + + for (i = 0; i < MTK_MAX_RX_RING_NUM; i++) { ++ struct mtk_rx_dma *rxd; ++ + ring = ð->rx_ring[i]; + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- if (ring->dma[idx].rxd2 & RX_DMA_DONE) { ++ rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; ++ if (rxd->rxd2 & RX_DMA_DONE) { + ring->calc_idx_update = true; + return ring; + } +@@ -1306,7 +1309,7 @@ static int mtk_poll_rx(struct napi_struc + goto rx_done; + + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- rxd = &ring->dma[idx]; ++ rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; + data = ring->data[idx]; + + if (!mtk_rx_get_desc(&trxd, rxd)) +@@ -1495,7 +1498,7 @@ static int mtk_poll_tx_pdma(struct mtk_e + + mtk_tx_unmap(eth, tx_buf, true); + +- desc = &ring->dma[cpu]; ++ desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size; + ring->last_free = desc; + atomic_inc(&ring->free_count); + diff --git a/target/linux/generic/backport-5.15/702-v5.19-25-net-ethernet-mtk_eth_soc-rely-on-rxd_size-field-in-m.patch b/target/linux/generic/backport-5.15/702-v5.19-25-net-ethernet-mtk_eth_soc-rely-on-rxd_size-field-in-m.patch new file mode 100644 index 0000000000..2ce2d1c0d0 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-25-net-ethernet-mtk_eth_soc-rely-on-rxd_size-field-in-m.patch @@ -0,0 +1,68 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:34 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on rxd_size field in + mtk_rx_alloc/mtk_rx_clean + +Remove mtk_rx_dma structure layout dependency in mtk_rx_alloc/mtk_rx_clean. +Initialize to 0 rxd3 and rxd4 in mtk_rx_alloc. +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1767,18 +1767,25 @@ static int mtk_rx_alloc(struct mtk_eth * + return -ENOMEM; + + for (i = 0; i < rx_dma_size; i++) { ++ struct mtk_rx_dma *rxd; ++ + dma_addr_t dma_addr = dma_map_single(eth->dma_dev, + ring->data[i] + NET_SKB_PAD + eth->ip_align, + ring->buf_size, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) + return -ENOMEM; +- ring->dma[i].rxd1 = (unsigned int)dma_addr; ++ ++ rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; ++ rxd->rxd1 = (unsigned int)dma_addr; + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) +- ring->dma[i].rxd2 = RX_DMA_LSO; ++ rxd->rxd2 = RX_DMA_LSO; + else +- ring->dma[i].rxd2 = RX_DMA_PLEN0(ring->buf_size); ++ rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); ++ ++ rxd->rxd3 = 0; ++ rxd->rxd4 = 0; + } + ring->dma_size = rx_dma_size; + ring->calc_idx_update = false; +@@ -1803,14 +1810,17 @@ static void mtk_rx_clean(struct mtk_eth + + if (ring->data && ring->dma) { + for (i = 0; i < ring->dma_size; i++) { ++ struct mtk_rx_dma *rxd; ++ + if (!ring->data[i]) + continue; +- if (!ring->dma[i].rxd1) ++ ++ rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; ++ if (!rxd->rxd1) + continue; +- dma_unmap_single(eth->dma_dev, +- ring->dma[i].rxd1, +- ring->buf_size, +- DMA_FROM_DEVICE); ++ ++ dma_unmap_single(eth->dma_dev, rxd->rxd1, ++ ring->buf_size, DMA_FROM_DEVICE); + skb_free_frag(ring->data[i]); + } + kfree(ring->data); diff --git a/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch b/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch new file mode 100644 index 0000000000..95562328fe --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch @@ -0,0 +1,814 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:35 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce device register map + +Introduce reg_map structure to add the capability to support different +register definitions. Move register definitions in mtk_regmap structure. +This is a preliminary patch to introduce mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -34,6 +34,59 @@ MODULE_PARM_DESC(msg_level, "Message lev + #define MTK_ETHTOOL_STAT(x) { #x, \ + offsetof(struct mtk_hw_stats, x) / sizeof(u64) } + ++static const struct mtk_reg_map mtk_reg_map = { ++ .tx_irq_mask = 0x1a1c, ++ .tx_irq_status = 0x1a18, ++ .pdma = { ++ .rx_ptr = 0x0900, ++ .rx_cnt_cfg = 0x0904, ++ .pcrx_ptr = 0x0908, ++ .glo_cfg = 0x0a04, ++ .rst_idx = 0x0a08, ++ .delay_irq = 0x0a0c, ++ .irq_status = 0x0a20, ++ .irq_mask = 0x0a28, ++ .int_grp = 0x0a50, ++ }, ++ .qdma = { ++ .qtx_cfg = 0x1800, ++ .rx_ptr = 0x1900, ++ .rx_cnt_cfg = 0x1904, ++ .qcrx_ptr = 0x1908, ++ .glo_cfg = 0x1a04, ++ .rst_idx = 0x1a08, ++ .delay_irq = 0x1a0c, ++ .fc_th = 0x1a10, ++ .int_grp = 0x1a20, ++ .hred = 0x1a44, ++ .ctx_ptr = 0x1b00, ++ .dtx_ptr = 0x1b04, ++ .crx_ptr = 0x1b10, ++ .drx_ptr = 0x1b14, ++ .fq_head = 0x1b20, ++ .fq_tail = 0x1b24, ++ .fq_count = 0x1b28, ++ .fq_blen = 0x1b2c, ++ }, ++ .gdm1_cnt = 0x2400, ++}; ++ ++static const struct mtk_reg_map mt7628_reg_map = { ++ .tx_irq_mask = 0x0a28, ++ .tx_irq_status = 0x0a20, ++ .pdma = { ++ .rx_ptr = 0x0900, ++ .rx_cnt_cfg = 0x0904, ++ .pcrx_ptr = 0x0908, ++ .glo_cfg = 0x0a04, ++ .rst_idx = 0x0a08, ++ .delay_irq = 0x0a0c, ++ .irq_status = 0x0a20, ++ .irq_mask = 0x0a28, ++ .int_grp = 0x0a50, ++ }, ++}; ++ + /* strings used by ethtool */ + static const struct mtk_ethtool_stats { + char str[ETH_GSTRING_LEN]; +@@ -618,8 +671,8 @@ static inline void mtk_tx_irq_disable(st + u32 val; + + spin_lock_irqsave(ð->tx_irq_lock, flags); +- val = mtk_r32(eth, eth->tx_int_mask_reg); +- mtk_w32(eth, val & ~mask, eth->tx_int_mask_reg); ++ val = mtk_r32(eth, eth->soc->reg_map->tx_irq_mask); ++ mtk_w32(eth, val & ~mask, eth->soc->reg_map->tx_irq_mask); + spin_unlock_irqrestore(ð->tx_irq_lock, flags); + } + +@@ -629,8 +682,8 @@ static inline void mtk_tx_irq_enable(str + u32 val; + + spin_lock_irqsave(ð->tx_irq_lock, flags); +- val = mtk_r32(eth, eth->tx_int_mask_reg); +- mtk_w32(eth, val | mask, eth->tx_int_mask_reg); ++ val = mtk_r32(eth, eth->soc->reg_map->tx_irq_mask); ++ mtk_w32(eth, val | mask, eth->soc->reg_map->tx_irq_mask); + spin_unlock_irqrestore(ð->tx_irq_lock, flags); + } + +@@ -640,8 +693,8 @@ static inline void mtk_rx_irq_disable(st + u32 val; + + spin_lock_irqsave(ð->rx_irq_lock, flags); +- val = mtk_r32(eth, MTK_PDMA_INT_MASK); +- mtk_w32(eth, val & ~mask, MTK_PDMA_INT_MASK); ++ val = mtk_r32(eth, eth->soc->reg_map->pdma.irq_mask); ++ mtk_w32(eth, val & ~mask, eth->soc->reg_map->pdma.irq_mask); + spin_unlock_irqrestore(ð->rx_irq_lock, flags); + } + +@@ -651,8 +704,8 @@ static inline void mtk_rx_irq_enable(str + u32 val; + + spin_lock_irqsave(ð->rx_irq_lock, flags); +- val = mtk_r32(eth, MTK_PDMA_INT_MASK); +- mtk_w32(eth, val | mask, MTK_PDMA_INT_MASK); ++ val = mtk_r32(eth, eth->soc->reg_map->pdma.irq_mask); ++ mtk_w32(eth, val | mask, eth->soc->reg_map->pdma.irq_mask); + spin_unlock_irqrestore(ð->rx_irq_lock, flags); + } + +@@ -703,39 +756,39 @@ void mtk_stats_update_mac(struct mtk_mac + hw_stats->rx_checksum_errors += + mtk_r32(mac->hw, MT7628_SDM_CS_ERR); + } else { ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + unsigned int offs = hw_stats->reg_offset; + u64 stats; + +- hw_stats->rx_bytes += mtk_r32(mac->hw, +- MTK_GDM1_RX_GBCNT_L + offs); +- stats = mtk_r32(mac->hw, MTK_GDM1_RX_GBCNT_H + offs); ++ hw_stats->rx_bytes += mtk_r32(mac->hw, reg_map->gdm1_cnt + offs); ++ stats = mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x4 + offs); + if (stats) + hw_stats->rx_bytes += (stats << 32); + hw_stats->rx_packets += +- mtk_r32(mac->hw, MTK_GDM1_RX_GPCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x8 + offs); + hw_stats->rx_overflow += +- mtk_r32(mac->hw, MTK_GDM1_RX_OERCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x10 + offs); + hw_stats->rx_fcs_errors += +- mtk_r32(mac->hw, MTK_GDM1_RX_FERCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x14 + offs); + hw_stats->rx_short_errors += +- mtk_r32(mac->hw, MTK_GDM1_RX_SERCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x18 + offs); + hw_stats->rx_long_errors += +- mtk_r32(mac->hw, MTK_GDM1_RX_LENCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x1c + offs); + hw_stats->rx_checksum_errors += +- mtk_r32(mac->hw, MTK_GDM1_RX_CERCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x20 + offs); + hw_stats->rx_flow_control_packets += +- mtk_r32(mac->hw, MTK_GDM1_RX_FCCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x24 + offs); + hw_stats->tx_skip += +- mtk_r32(mac->hw, MTK_GDM1_TX_SKIPCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x28 + offs); + hw_stats->tx_collisions += +- mtk_r32(mac->hw, MTK_GDM1_TX_COLCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x2c + offs); + hw_stats->tx_bytes += +- mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_L + offs); +- stats = mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_H + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x30 + offs); ++ stats = mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x34 + offs); + if (stats) + hw_stats->tx_bytes += (stats << 32); + hw_stats->tx_packets += +- mtk_r32(mac->hw, MTK_GDM1_TX_GPCNT + offs); ++ mtk_r32(mac->hw, reg_map->gdm1_cnt + 0x38 + offs); + } + + u64_stats_update_end(&hw_stats->syncp); +@@ -864,10 +917,10 @@ static int mtk_init_fq_dma(struct mtk_et + txd->txd4 = 0; + } + +- mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD); +- mtk_w32(eth, phy_ring_tail, MTK_QDMA_FQ_TAIL); +- mtk_w32(eth, (cnt << 16) | cnt, MTK_QDMA_FQ_CNT); +- mtk_w32(eth, MTK_QDMA_PAGE_SIZE << 16, MTK_QDMA_FQ_BLEN); ++ mtk_w32(eth, eth->phy_scratch_ring, soc->reg_map->qdma.fq_head); ++ mtk_w32(eth, phy_ring_tail, soc->reg_map->qdma.fq_tail); ++ mtk_w32(eth, (cnt << 16) | cnt, soc->reg_map->qdma.fq_count); ++ mtk_w32(eth, MTK_QDMA_PAGE_SIZE << 16, soc->reg_map->qdma.fq_blen); + + return 0; + } +@@ -1111,7 +1164,7 @@ static int mtk_tx_map(struct sk_buff *sk + if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { + if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || + !netdev_xmit_more()) +- mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); ++ mtk_w32(eth, txd->txd2, soc->reg_map->qdma.ctx_ptr); + } else { + int next_idx; + +@@ -1425,6 +1478,7 @@ rx_done: + static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, + unsigned int *done, unsigned int *bytes) + { ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + struct mtk_tx_ring *ring = ð->tx_ring; + struct mtk_tx_dma *desc; + struct sk_buff *skb; +@@ -1432,7 +1486,7 @@ static int mtk_poll_tx_qdma(struct mtk_e + u32 cpu, dma; + + cpu = ring->last_free_ptr; +- dma = mtk_r32(eth, MTK_QTX_DRX_PTR); ++ dma = mtk_r32(eth, reg_map->qdma.drx_ptr); + + desc = mtk_qdma_phys_to_virt(ring, cpu); + +@@ -1467,7 +1521,7 @@ static int mtk_poll_tx_qdma(struct mtk_e + } + + ring->last_free_ptr = cpu; +- mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); ++ mtk_w32(eth, cpu, reg_map->qdma.crx_ptr); + + return budget; + } +@@ -1560,24 +1614,25 @@ static void mtk_handle_status_irq(struct + static int mtk_napi_tx(struct napi_struct *napi, int budget) + { + struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi); ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + int tx_done = 0; + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) + mtk_handle_status_irq(eth); +- mtk_w32(eth, MTK_TX_DONE_INT, eth->tx_int_status_reg); ++ mtk_w32(eth, MTK_TX_DONE_INT, reg_map->tx_irq_status); + tx_done = mtk_poll_tx(eth, budget); + + if (unlikely(netif_msg_intr(eth))) { + dev_info(eth->dev, + "done tx %d, intr 0x%08x/0x%x\n", tx_done, +- mtk_r32(eth, eth->tx_int_status_reg), +- mtk_r32(eth, eth->tx_int_mask_reg)); ++ mtk_r32(eth, reg_map->tx_irq_status), ++ mtk_r32(eth, reg_map->tx_irq_mask)); + } + + if (tx_done == budget) + return budget; + +- if (mtk_r32(eth, eth->tx_int_status_reg) & MTK_TX_DONE_INT) ++ if (mtk_r32(eth, reg_map->tx_irq_status) & MTK_TX_DONE_INT) + return budget; + + if (napi_complete_done(napi, tx_done)) +@@ -1589,6 +1644,7 @@ static int mtk_napi_tx(struct napi_struc + static int mtk_napi_rx(struct napi_struct *napi, int budget) + { + struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi); ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + int rx_done_total = 0; + + mtk_handle_status_irq(eth); +@@ -1596,21 +1652,21 @@ static int mtk_napi_rx(struct napi_struc + do { + int rx_done; + +- mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_STATUS); ++ mtk_w32(eth, MTK_RX_DONE_INT, reg_map->pdma.irq_status); + rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth); + rx_done_total += rx_done; + + if (unlikely(netif_msg_intr(eth))) { + dev_info(eth->dev, + "done rx %d, intr 0x%08x/0x%x\n", rx_done, +- mtk_r32(eth, MTK_PDMA_INT_STATUS), +- mtk_r32(eth, MTK_PDMA_INT_MASK)); ++ mtk_r32(eth, reg_map->pdma.irq_status), ++ mtk_r32(eth, reg_map->pdma.irq_mask)); + } + + if (rx_done_total == budget) + return budget; + +- } while (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT); ++ } while (mtk_r32(eth, reg_map->pdma.irq_status) & MTK_RX_DONE_INT); + + if (napi_complete_done(napi, rx_done_total)) + mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); +@@ -1673,20 +1729,20 @@ static int mtk_tx_alloc(struct mtk_eth * + */ + wmb(); + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { +- mtk_w32(eth, ring->phys, MTK_QTX_CTX_PTR); +- mtk_w32(eth, ring->phys, MTK_QTX_DTX_PTR); ++ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { ++ mtk_w32(eth, ring->phys, soc->reg_map->qdma.ctx_ptr); ++ mtk_w32(eth, ring->phys, soc->reg_map->qdma.dtx_ptr); + mtk_w32(eth, + ring->phys + ((MTK_DMA_SIZE - 1) * sz), +- MTK_QTX_CRX_PTR); +- mtk_w32(eth, ring->last_free_ptr, MTK_QTX_DRX_PTR); ++ soc->reg_map->qdma.crx_ptr); ++ mtk_w32(eth, ring->last_free_ptr, soc->reg_map->qdma.drx_ptr); + mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, +- MTK_QTX_CFG(0)); ++ soc->reg_map->qdma.qtx_cfg); + } else { + mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0); + mtk_w32(eth, MTK_DMA_SIZE, MT7628_TX_MAX_CNT0); + mtk_w32(eth, 0, MT7628_TX_CTX_IDX0); +- mtk_w32(eth, MT7628_PST_DTX_IDX0, MTK_PDMA_RST_IDX); ++ mtk_w32(eth, MT7628_PST_DTX_IDX0, soc->reg_map->pdma.rst_idx); + } + + return 0; +@@ -1725,6 +1781,7 @@ static void mtk_tx_clean(struct mtk_eth + + static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) + { ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + struct mtk_rx_ring *ring; + int rx_data_len, rx_dma_size; + int i; +@@ -1790,16 +1847,18 @@ static int mtk_rx_alloc(struct mtk_eth * + ring->dma_size = rx_dma_size; + ring->calc_idx_update = false; + ring->calc_idx = rx_dma_size - 1; +- ring->crx_idx_reg = MTK_PRX_CRX_IDX_CFG(ring_no); ++ ring->crx_idx_reg = reg_map->pdma.pcrx_ptr + ring_no * MTK_QRX_OFFSET; + /* make sure that all changes to the dma ring are flushed before we + * continue + */ + wmb(); + +- mtk_w32(eth, ring->phys, MTK_PRX_BASE_PTR_CFG(ring_no) + offset); +- mtk_w32(eth, rx_dma_size, MTK_PRX_MAX_CNT_CFG(ring_no) + offset); ++ mtk_w32(eth, ring->phys, ++ reg_map->pdma.rx_ptr + ring_no * MTK_QRX_OFFSET + offset); ++ mtk_w32(eth, rx_dma_size, ++ reg_map->pdma.rx_cnt_cfg + ring_no * MTK_QRX_OFFSET + offset); + mtk_w32(eth, ring->calc_idx, ring->crx_idx_reg + offset); +- mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), MTK_PDMA_RST_IDX + offset); ++ mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), reg_map->pdma.rst_idx + offset); + + return 0; + } +@@ -2105,9 +2164,9 @@ static int mtk_dma_busy_wait(struct mtk_ + u32 val; + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) +- reg = MTK_QDMA_GLO_CFG; ++ reg = eth->soc->reg_map->qdma.glo_cfg; + else +- reg = MTK_PDMA_GLO_CFG; ++ reg = eth->soc->reg_map->pdma.glo_cfg; + + ret = readx_poll_timeout_atomic(__raw_readl, eth->base + reg, val, + !(val & (MTK_RX_DMA_BUSY | MTK_TX_DMA_BUSY)), +@@ -2165,8 +2224,8 @@ static int mtk_dma_init(struct mtk_eth * + * automatically + */ + mtk_w32(eth, FC_THRES_DROP_MODE | FC_THRES_DROP_EN | +- FC_THRES_MIN, MTK_QDMA_FC_THRES); +- mtk_w32(eth, 0x0, MTK_QDMA_HRED2); ++ FC_THRES_MIN, eth->soc->reg_map->qdma.fc_th); ++ mtk_w32(eth, 0x0, eth->soc->reg_map->qdma.hred); + } + + return 0; +@@ -2240,13 +2299,14 @@ static irqreturn_t mtk_handle_irq_tx(int + static irqreturn_t mtk_handle_irq(int irq, void *_eth) + { + struct mtk_eth *eth = _eth; ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + +- if (mtk_r32(eth, MTK_PDMA_INT_MASK) & MTK_RX_DONE_INT) { +- if (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT) ++ if (mtk_r32(eth, reg_map->pdma.irq_mask) & MTK_RX_DONE_INT) { ++ if (mtk_r32(eth, reg_map->pdma.irq_status) & MTK_RX_DONE_INT) + mtk_handle_irq_rx(irq, _eth); + } +- if (mtk_r32(eth, eth->tx_int_mask_reg) & MTK_TX_DONE_INT) { +- if (mtk_r32(eth, eth->tx_int_status_reg) & MTK_TX_DONE_INT) ++ if (mtk_r32(eth, reg_map->tx_irq_mask) & MTK_TX_DONE_INT) { ++ if (mtk_r32(eth, reg_map->tx_irq_status) & MTK_TX_DONE_INT) + mtk_handle_irq_tx(irq, _eth); + } + +@@ -2270,6 +2330,7 @@ static void mtk_poll_controller(struct n + static int mtk_start_dma(struct mtk_eth *eth) + { + u32 rx_2b_offset = (NET_IP_ALIGN == 2) ? MTK_RX_2B_OFFSET : 0; ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + int err; + + err = mtk_dma_init(eth); +@@ -2284,16 +2345,15 @@ static int mtk_start_dma(struct mtk_eth + MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO | + MTK_RX_DMA_EN | MTK_RX_2B_OFFSET | + MTK_RX_BT_32DWORDS, +- MTK_QDMA_GLO_CFG); +- ++ reg_map->qdma.glo_cfg); + mtk_w32(eth, + MTK_RX_DMA_EN | rx_2b_offset | + MTK_RX_BT_32DWORDS | MTK_MULTI_EN, +- MTK_PDMA_GLO_CFG); ++ reg_map->pdma.glo_cfg); + } else { + mtk_w32(eth, MTK_TX_WB_DDONE | MTK_TX_DMA_EN | MTK_RX_DMA_EN | + MTK_MULTI_EN | MTK_PDMA_SIZE_8DWORDS, +- MTK_PDMA_GLO_CFG); ++ reg_map->pdma.glo_cfg); + } + + return 0; +@@ -2417,8 +2477,8 @@ static int mtk_stop(struct net_device *d + cancel_work_sync(ð->tx_dim.work); + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) +- mtk_stop_dma(eth, MTK_QDMA_GLO_CFG); +- mtk_stop_dma(eth, MTK_PDMA_GLO_CFG); ++ mtk_stop_dma(eth, eth->soc->reg_map->qdma.glo_cfg); ++ mtk_stop_dma(eth, eth->soc->reg_map->pdma.glo_cfg); + + mtk_dma_free(eth); + +@@ -2472,6 +2532,7 @@ static void mtk_dim_rx(struct work_struc + { + struct dim *dim = container_of(work, struct dim, work); + struct mtk_eth *eth = container_of(dim, struct mtk_eth, rx_dim); ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + struct dim_cq_moder cur_profile; + u32 val, cur; + +@@ -2479,7 +2540,7 @@ static void mtk_dim_rx(struct work_struc + dim->profile_ix); + spin_lock_bh(ð->dim_lock); + +- val = mtk_r32(eth, MTK_PDMA_DELAY_INT); ++ val = mtk_r32(eth, reg_map->pdma.delay_irq); + val &= MTK_PDMA_DELAY_TX_MASK; + val |= MTK_PDMA_DELAY_RX_EN; + +@@ -2489,9 +2550,9 @@ static void mtk_dim_rx(struct work_struc + cur = min_t(u32, cur_profile.pkts, MTK_PDMA_DELAY_PINT_MASK); + val |= cur << MTK_PDMA_DELAY_RX_PINT_SHIFT; + +- mtk_w32(eth, val, MTK_PDMA_DELAY_INT); ++ mtk_w32(eth, val, reg_map->pdma.delay_irq); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) +- mtk_w32(eth, val, MTK_QDMA_DELAY_INT); ++ mtk_w32(eth, val, reg_map->qdma.delay_irq); + + spin_unlock_bh(ð->dim_lock); + +@@ -2502,6 +2563,7 @@ static void mtk_dim_tx(struct work_struc + { + struct dim *dim = container_of(work, struct dim, work); + struct mtk_eth *eth = container_of(dim, struct mtk_eth, tx_dim); ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + struct dim_cq_moder cur_profile; + u32 val, cur; + +@@ -2509,7 +2571,7 @@ static void mtk_dim_tx(struct work_struc + dim->profile_ix); + spin_lock_bh(ð->dim_lock); + +- val = mtk_r32(eth, MTK_PDMA_DELAY_INT); ++ val = mtk_r32(eth, reg_map->pdma.delay_irq); + val &= MTK_PDMA_DELAY_RX_MASK; + val |= MTK_PDMA_DELAY_TX_EN; + +@@ -2519,9 +2581,9 @@ static void mtk_dim_tx(struct work_struc + cur = min_t(u32, cur_profile.pkts, MTK_PDMA_DELAY_PINT_MASK); + val |= cur << MTK_PDMA_DELAY_TX_PINT_SHIFT; + +- mtk_w32(eth, val, MTK_PDMA_DELAY_INT); ++ mtk_w32(eth, val, reg_map->pdma.delay_irq); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) +- mtk_w32(eth, val, MTK_QDMA_DELAY_INT); ++ mtk_w32(eth, val, reg_map->qdma.delay_irq); + + spin_unlock_bh(ð->dim_lock); + +@@ -2532,6 +2594,7 @@ static int mtk_hw_init(struct mtk_eth *e + { + u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA | + ETHSYS_DMA_AG_MAP_PPE; ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; + int i, val, ret; + + if (test_and_set_bit(MTK_HW_INIT, ð->state)) +@@ -2606,10 +2669,10 @@ static int mtk_hw_init(struct mtk_eth *e + mtk_rx_irq_disable(eth, ~0); + + /* FE int grouping */ +- mtk_w32(eth, MTK_TX_DONE_INT, MTK_PDMA_INT_GRP1); +- mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_GRP2); +- mtk_w32(eth, MTK_TX_DONE_INT, MTK_QDMA_INT_GRP1); +- mtk_w32(eth, MTK_RX_DONE_INT, MTK_QDMA_INT_GRP2); ++ mtk_w32(eth, MTK_TX_DONE_INT, reg_map->pdma.int_grp); ++ mtk_w32(eth, MTK_RX_DONE_INT, reg_map->pdma.int_grp + 4); ++ mtk_w32(eth, MTK_TX_DONE_INT, reg_map->qdma.int_grp); ++ mtk_w32(eth, MTK_RX_DONE_INT, reg_map->qdma.int_grp + 4); + mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP); + + return 0; +@@ -3148,14 +3211,6 @@ static int mtk_probe(struct platform_dev + if (IS_ERR(eth->base)) + return PTR_ERR(eth->base); + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { +- eth->tx_int_mask_reg = MTK_QDMA_INT_MASK; +- eth->tx_int_status_reg = MTK_QDMA_INT_STATUS; +- } else { +- eth->tx_int_mask_reg = MTK_PDMA_INT_MASK; +- eth->tx_int_status_reg = MTK_PDMA_INT_STATUS; +- } +- + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { + eth->rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA; + eth->ip_align = NET_IP_ALIGN; +@@ -3389,6 +3444,7 @@ static int mtk_remove(struct platform_de + } + + static const struct mtk_soc_data mt2701_data = { ++ .reg_map = &mtk_reg_map, + .caps = MT7623_CAPS | MTK_HWLRO, + .hw_features = MTK_HW_FEATURES, + .required_clks = MT7623_CLKS_BITMAP, +@@ -3400,6 +3456,7 @@ static const struct mtk_soc_data mt2701_ + }; + + static const struct mtk_soc_data mt7621_data = { ++ .reg_map = &mtk_reg_map, + .caps = MT7621_CAPS, + .hw_features = MTK_HW_FEATURES, + .required_clks = MT7621_CLKS_BITMAP, +@@ -3412,6 +3469,7 @@ static const struct mtk_soc_data mt7621_ + }; + + static const struct mtk_soc_data mt7622_data = { ++ .reg_map = &mtk_reg_map, + .ana_rgc3 = 0x2028, + .caps = MT7622_CAPS | MTK_HWLRO, + .hw_features = MTK_HW_FEATURES, +@@ -3425,6 +3483,7 @@ static const struct mtk_soc_data mt7622_ + }; + + static const struct mtk_soc_data mt7623_data = { ++ .reg_map = &mtk_reg_map, + .caps = MT7623_CAPS | MTK_HWLRO, + .hw_features = MTK_HW_FEATURES, + .required_clks = MT7623_CLKS_BITMAP, +@@ -3437,6 +3496,7 @@ static const struct mtk_soc_data mt7623_ + }; + + static const struct mtk_soc_data mt7629_data = { ++ .reg_map = &mtk_reg_map, + .ana_rgc3 = 0x128, + .caps = MT7629_CAPS | MTK_HWLRO, + .hw_features = MTK_HW_FEATURES, +@@ -3449,6 +3509,7 @@ static const struct mtk_soc_data mt7629_ + }; + + static const struct mtk_soc_data rt5350_data = { ++ .reg_map = &mt7628_reg_map, + .caps = MT7628_CAPS, + .hw_features = MTK_HW_FEATURES_MT7628, + .required_clks = MT7628_CLKS_BITMAP, +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -48,6 +48,8 @@ + #define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM) + #define NEXT_DESP_IDX(X, Y) (((X) + 1) & ((Y) - 1)) + ++#define MTK_QRX_OFFSET 0x10 ++ + #define MTK_MAX_RX_RING_NUM 4 + #define MTK_HW_LRO_DMA_SIZE 8 + +@@ -100,18 +102,6 @@ + /* Unicast Filter MAC Address Register - High */ + #define MTK_GDMA_MAC_ADRH(x) (0x50C + (x * 0x1000)) + +-/* PDMA RX Base Pointer Register */ +-#define MTK_PRX_BASE_PTR0 0x900 +-#define MTK_PRX_BASE_PTR_CFG(x) (MTK_PRX_BASE_PTR0 + (x * 0x10)) +- +-/* PDMA RX Maximum Count Register */ +-#define MTK_PRX_MAX_CNT0 0x904 +-#define MTK_PRX_MAX_CNT_CFG(x) (MTK_PRX_MAX_CNT0 + (x * 0x10)) +- +-/* PDMA RX CPU Pointer Register */ +-#define MTK_PRX_CRX_IDX0 0x908 +-#define MTK_PRX_CRX_IDX_CFG(x) (MTK_PRX_CRX_IDX0 + (x * 0x10)) +- + /* PDMA HW LRO Control Registers */ + #define MTK_PDMA_LRO_CTRL_DW0 0x980 + #define MTK_LRO_EN BIT(0) +@@ -126,18 +116,19 @@ + #define MTK_ADMA_MODE BIT(15) + #define MTK_LRO_MIN_RXD_SDL (MTK_HW_LRO_SDL_REMAIN_ROOM << 16) + +-/* PDMA Global Configuration Register */ +-#define MTK_PDMA_GLO_CFG 0xa04 ++#define MTK_RX_DMA_LRO_EN BIT(8) + #define MTK_MULTI_EN BIT(10) + #define MTK_PDMA_SIZE_8DWORDS (1 << 4) + ++/* PDMA Global Configuration Register */ ++#define MTK_PDMA_LRO_SDL 0x3000 ++#define MTK_RX_CFG_SDL_OFFSET 16 ++ + /* PDMA Reset Index Register */ +-#define MTK_PDMA_RST_IDX 0xa08 + #define MTK_PST_DRX_IDX0 BIT(16) + #define MTK_PST_DRX_IDX_CFG(x) (MTK_PST_DRX_IDX0 << (x)) + + /* PDMA Delay Interrupt Register */ +-#define MTK_PDMA_DELAY_INT 0xa0c + #define MTK_PDMA_DELAY_RX_MASK GENMASK(15, 0) + #define MTK_PDMA_DELAY_RX_EN BIT(15) + #define MTK_PDMA_DELAY_RX_PINT_SHIFT 8 +@@ -151,19 +142,9 @@ + #define MTK_PDMA_DELAY_PINT_MASK 0x7f + #define MTK_PDMA_DELAY_PTIME_MASK 0xff + +-/* PDMA Interrupt Status Register */ +-#define MTK_PDMA_INT_STATUS 0xa20 +- +-/* PDMA Interrupt Mask Register */ +-#define MTK_PDMA_INT_MASK 0xa28 +- + /* PDMA HW LRO Alter Flow Delta Register */ + #define MTK_PDMA_LRO_ALT_SCORE_DELTA 0xa4c + +-/* PDMA Interrupt grouping registers */ +-#define MTK_PDMA_INT_GRP1 0xa50 +-#define MTK_PDMA_INT_GRP2 0xa54 +- + /* PDMA HW LRO IP Setting Registers */ + #define MTK_LRO_RX_RING0_DIP_DW0 0xb04 + #define MTK_LRO_DIP_DW0_CFG(x) (MTK_LRO_RX_RING0_DIP_DW0 + (x * 0x40)) +@@ -185,26 +166,9 @@ + #define MTK_RING_MAX_AGG_CNT_H ((MTK_HW_LRO_MAX_AGG_CNT >> 6) & 0x3) + + /* QDMA TX Queue Configuration Registers */ +-#define MTK_QTX_CFG(x) (0x1800 + (x * 0x10)) + #define QDMA_RES_THRES 4 + +-/* QDMA TX Queue Scheduler Registers */ +-#define MTK_QTX_SCH(x) (0x1804 + (x * 0x10)) +- +-/* QDMA RX Base Pointer Register */ +-#define MTK_QRX_BASE_PTR0 0x1900 +- +-/* QDMA RX Maximum Count Register */ +-#define MTK_QRX_MAX_CNT0 0x1904 +- +-/* QDMA RX CPU Pointer Register */ +-#define MTK_QRX_CRX_IDX0 0x1908 +- +-/* QDMA RX DMA Pointer Register */ +-#define MTK_QRX_DRX_IDX0 0x190C +- + /* QDMA Global Configuration Register */ +-#define MTK_QDMA_GLO_CFG 0x1A04 + #define MTK_RX_2B_OFFSET BIT(31) + #define MTK_RX_BT_32DWORDS (3 << 11) + #define MTK_NDP_CO_PRO BIT(10) +@@ -216,20 +180,12 @@ + #define MTK_TX_DMA_EN BIT(0) + #define MTK_DMA_BUSY_TIMEOUT_US 1000000 + +-/* QDMA Reset Index Register */ +-#define MTK_QDMA_RST_IDX 0x1A08 +- +-/* QDMA Delay Interrupt Register */ +-#define MTK_QDMA_DELAY_INT 0x1A0C +- + /* QDMA Flow Control Register */ +-#define MTK_QDMA_FC_THRES 0x1A10 + #define FC_THRES_DROP_MODE BIT(20) + #define FC_THRES_DROP_EN (7 << 16) + #define FC_THRES_MIN 0x4444 + + /* QDMA Interrupt Status Register */ +-#define MTK_QDMA_INT_STATUS 0x1A18 + #define MTK_RX_DONE_DLY BIT(30) + #define MTK_TX_DONE_DLY BIT(28) + #define MTK_RX_DONE_INT3 BIT(19) +@@ -244,55 +200,8 @@ + #define MTK_TX_DONE_INT MTK_TX_DONE_DLY + + /* QDMA Interrupt grouping registers */ +-#define MTK_QDMA_INT_GRP1 0x1a20 +-#define MTK_QDMA_INT_GRP2 0x1a24 + #define MTK_RLS_DONE_INT BIT(0) + +-/* QDMA Interrupt Status Register */ +-#define MTK_QDMA_INT_MASK 0x1A1C +- +-/* QDMA Interrupt Mask Register */ +-#define MTK_QDMA_HRED2 0x1A44 +- +-/* QDMA TX Forward CPU Pointer Register */ +-#define MTK_QTX_CTX_PTR 0x1B00 +- +-/* QDMA TX Forward DMA Pointer Register */ +-#define MTK_QTX_DTX_PTR 0x1B04 +- +-/* QDMA TX Release CPU Pointer Register */ +-#define MTK_QTX_CRX_PTR 0x1B10 +- +-/* QDMA TX Release DMA Pointer Register */ +-#define MTK_QTX_DRX_PTR 0x1B14 +- +-/* QDMA FQ Head Pointer Register */ +-#define MTK_QDMA_FQ_HEAD 0x1B20 +- +-/* QDMA FQ Head Pointer Register */ +-#define MTK_QDMA_FQ_TAIL 0x1B24 +- +-/* QDMA FQ Free Page Counter Register */ +-#define MTK_QDMA_FQ_CNT 0x1B28 +- +-/* QDMA FQ Free Page Buffer Length Register */ +-#define MTK_QDMA_FQ_BLEN 0x1B2C +- +-/* GMA1 counter / statics register */ +-#define MTK_GDM1_RX_GBCNT_L 0x2400 +-#define MTK_GDM1_RX_GBCNT_H 0x2404 +-#define MTK_GDM1_RX_GPCNT 0x2408 +-#define MTK_GDM1_RX_OERCNT 0x2410 +-#define MTK_GDM1_RX_FERCNT 0x2414 +-#define MTK_GDM1_RX_SERCNT 0x2418 +-#define MTK_GDM1_RX_LENCNT 0x241c +-#define MTK_GDM1_RX_CERCNT 0x2420 +-#define MTK_GDM1_RX_FCCNT 0x2424 +-#define MTK_GDM1_TX_SKIPCNT 0x2428 +-#define MTK_GDM1_TX_COLCNT 0x242c +-#define MTK_GDM1_TX_GBCNT_L 0x2430 +-#define MTK_GDM1_TX_GBCNT_H 0x2434 +-#define MTK_GDM1_TX_GPCNT 0x2438 + #define MTK_STAT_OFFSET 0x40 + + #define MTK_WDMA0_BASE 0x2800 +@@ -853,8 +762,46 @@ struct mtk_tx_dma_desc_info { + u8 last:1; + }; + ++struct mtk_reg_map { ++ u32 tx_irq_mask; ++ u32 tx_irq_status; ++ struct { ++ u32 rx_ptr; /* rx base pointer */ ++ u32 rx_cnt_cfg; /* rx max count configuration */ ++ u32 pcrx_ptr; /* rx cpu pointer */ ++ u32 glo_cfg; /* global configuration */ ++ u32 rst_idx; /* reset index */ ++ u32 delay_irq; /* delay interrupt */ ++ u32 irq_status; /* interrupt status */ ++ u32 irq_mask; /* interrupt mask */ ++ u32 int_grp; ++ } pdma; ++ struct { ++ u32 qtx_cfg; /* tx queue configuration */ ++ u32 rx_ptr; /* rx base pointer */ ++ u32 rx_cnt_cfg; /* rx max count configuration */ ++ u32 qcrx_ptr; /* rx cpu pointer */ ++ u32 glo_cfg; /* global configuration */ ++ u32 rst_idx; /* reset index */ ++ u32 delay_irq; /* delay interrupt */ ++ u32 fc_th; /* flow control */ ++ u32 int_grp; ++ u32 hred; /* interrupt mask */ ++ u32 ctx_ptr; /* tx acquire cpu pointer */ ++ u32 dtx_ptr; /* tx acquire dma pointer */ ++ u32 crx_ptr; /* tx release cpu pointer */ ++ u32 drx_ptr; /* tx release dma pointer */ ++ u32 fq_head; /* fq head pointer */ ++ u32 fq_tail; /* fq tail pointer */ ++ u32 fq_count; /* fq free page count */ ++ u32 fq_blen; /* fq free page buffer length */ ++ } qdma; ++ u32 gdm1_cnt; ++}; ++ + /* struct mtk_eth_data - This is the structure holding all differences + * among various plaforms ++ * @reg_map Soc register map. + * @ana_rgc3: The offset for register ANA_RGC3 related to + * sgmiisys syscon + * @caps Flags shown the extra capability for the SoC +@@ -867,6 +814,7 @@ struct mtk_tx_dma_desc_info { + * @rxd_size Rx DMA descriptor size. + */ + struct mtk_soc_data { ++ const struct mtk_reg_map *reg_map; + u32 ana_rgc3; + u32 caps; + u32 required_clks; +@@ -994,8 +942,6 @@ struct mtk_eth { + u32 tx_bytes; + struct dim tx_dim; + +- u32 tx_int_mask_reg; +- u32 tx_int_status_reg; + u32 rx_dma_l4_valid; + int ip_align; + diff --git a/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch b/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch new file mode 100644 index 0000000000..5780ee9029 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch @@ -0,0 +1,917 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:36 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce MTK_NETSYS_V2 support + +Introduce MTK_NETSYS_V2 support. MTK_NETSYS_V2 defines 32B TX/RX DMA +descriptors. +This is a preliminary patch to add mt7986 ethernet support. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -862,8 +862,8 @@ static inline int mtk_max_buf_size(int f + return buf_size; + } + +-static inline bool mtk_rx_get_desc(struct mtk_rx_dma *rxd, +- struct mtk_rx_dma *dma_rxd) ++static bool mtk_rx_get_desc(struct mtk_eth *eth, struct mtk_rx_dma_v2 *rxd, ++ struct mtk_rx_dma_v2 *dma_rxd) + { + rxd->rxd2 = READ_ONCE(dma_rxd->rxd2); + if (!(rxd->rxd2 & RX_DMA_DONE)) +@@ -872,6 +872,10 @@ static inline bool mtk_rx_get_desc(struc + rxd->rxd1 = READ_ONCE(dma_rxd->rxd1); + rxd->rxd3 = READ_ONCE(dma_rxd->rxd3); + rxd->rxd4 = READ_ONCE(dma_rxd->rxd4); ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ rxd->rxd5 = READ_ONCE(dma_rxd->rxd5); ++ rxd->rxd6 = READ_ONCE(dma_rxd->rxd6); ++ } + + return true; + } +@@ -905,7 +909,7 @@ static int mtk_init_fq_dma(struct mtk_et + phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1); + + for (i = 0; i < cnt; i++) { +- struct mtk_tx_dma *txd; ++ struct mtk_tx_dma_v2 *txd; + + txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size; + txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; +@@ -915,6 +919,12 @@ static int mtk_init_fq_dma(struct mtk_et + + txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE); + txd->txd4 = 0; ++ if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) { ++ txd->txd5 = 0; ++ txd->txd6 = 0; ++ txd->txd7 = 0; ++ txd->txd8 = 0; ++ } + } + + mtk_w32(eth, eth->phy_scratch_ring, soc->reg_map->qdma.fq_head); +@@ -1018,10 +1028,12 @@ static void setup_tx_buf(struct mtk_eth + } + } + +-static void mtk_tx_set_dma_desc(struct net_device *dev, struct mtk_tx_dma *desc, +- struct mtk_tx_dma_desc_info *info) ++static void mtk_tx_set_dma_desc_v1(struct net_device *dev, void *txd, ++ struct mtk_tx_dma_desc_info *info) + { + struct mtk_mac *mac = netdev_priv(dev); ++ struct mtk_eth *eth = mac->hw; ++ struct mtk_tx_dma *desc = txd; + u32 data; + + WRITE_ONCE(desc->txd1, info->addr); +@@ -1045,6 +1057,59 @@ static void mtk_tx_set_dma_desc(struct n + WRITE_ONCE(desc->txd4, data); + } + ++static void mtk_tx_set_dma_desc_v2(struct net_device *dev, void *txd, ++ struct mtk_tx_dma_desc_info *info) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ struct mtk_tx_dma_v2 *desc = txd; ++ struct mtk_eth *eth = mac->hw; ++ u32 data; ++ ++ WRITE_ONCE(desc->txd1, info->addr); ++ ++ data = TX_DMA_PLEN0(info->size); ++ if (info->last) ++ data |= TX_DMA_LS0; ++ WRITE_ONCE(desc->txd3, data); ++ ++ if (!info->qid && mac->id) ++ info->qid = MTK_QDMA_GMAC2_QID; ++ ++ data = (mac->id + 1) << TX_DMA_FPORT_SHIFT_V2; /* forward port */ ++ data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid); ++ WRITE_ONCE(desc->txd4, data); ++ ++ data = 0; ++ if (info->first) { ++ if (info->gso) ++ data |= TX_DMA_TSO_V2; ++ /* tx checksum offload */ ++ if (info->csum) ++ data |= TX_DMA_CHKSUM_V2; ++ } ++ WRITE_ONCE(desc->txd5, data); ++ ++ data = 0; ++ if (info->first && info->vlan) ++ data |= TX_DMA_INS_VLAN_V2 | info->vlan_tci; ++ WRITE_ONCE(desc->txd6, data); ++ ++ WRITE_ONCE(desc->txd7, 0); ++ WRITE_ONCE(desc->txd8, 0); ++} ++ ++static void mtk_tx_set_dma_desc(struct net_device *dev, void *txd, ++ struct mtk_tx_dma_desc_info *info) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ struct mtk_eth *eth = mac->hw; ++ ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) ++ mtk_tx_set_dma_desc_v2(dev, txd, info); ++ else ++ mtk_tx_set_dma_desc_v1(dev, txd, info); ++} ++ + static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, + int tx_num, struct mtk_tx_ring *ring, bool gso) + { +@@ -1053,6 +1118,7 @@ static int mtk_tx_map(struct sk_buff *sk + .gso = gso, + .csum = skb->ip_summed == CHECKSUM_PARTIAL, + .vlan = skb_vlan_tag_present(skb), ++ .qid = skb->mark & MTK_QDMA_TX_MASK, + .vlan_tci = skb_vlan_tag_get(skb), + .first = true, + .last = !skb_is_nonlinear(skb), +@@ -1112,7 +1178,9 @@ static int mtk_tx_map(struct sk_buff *sk + } + + memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); +- txd_info.size = min(frag_size, MTK_TX_DMA_BUF_LEN); ++ txd_info.size = min_t(unsigned int, frag_size, ++ soc->txrx.dma_max_len); ++ txd_info.qid = skb->mark & MTK_QDMA_TX_MASK; + txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 && + !(frag_size - txd_info.size); + txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, +@@ -1193,17 +1261,16 @@ err_dma: + return -ENOMEM; + } + +-static inline int mtk_cal_txd_req(struct sk_buff *skb) ++static int mtk_cal_txd_req(struct mtk_eth *eth, struct sk_buff *skb) + { +- int i, nfrags; ++ int i, nfrags = 1; + skb_frag_t *frag; + +- nfrags = 1; + if (skb_is_gso(skb)) { + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + frag = &skb_shinfo(skb)->frags[i]; + nfrags += DIV_ROUND_UP(skb_frag_size(frag), +- MTK_TX_DMA_BUF_LEN); ++ eth->soc->txrx.dma_max_len); + } + } else { + nfrags += skb_shinfo(skb)->nr_frags; +@@ -1255,7 +1322,7 @@ static netdev_tx_t mtk_start_xmit(struct + if (unlikely(test_bit(MTK_RESETTING, ð->state))) + goto drop; + +- tx_num = mtk_cal_txd_req(skb); ++ tx_num = mtk_cal_txd_req(eth, skb); + if (unlikely(atomic_read(&ring->free_count) <= tx_num)) { + netif_stop_queue(dev); + netif_err(eth, tx_queued, dev, +@@ -1347,7 +1414,7 @@ static int mtk_poll_rx(struct napi_struc + int idx; + struct sk_buff *skb; + u8 *data, *new_data; +- struct mtk_rx_dma *rxd, trxd; ++ struct mtk_rx_dma_v2 *rxd, trxd; + int done = 0, bytes = 0; + + while (done < budget) { +@@ -1355,7 +1422,7 @@ static int mtk_poll_rx(struct napi_struc + unsigned int pktlen; + dma_addr_t dma_addr; + u32 hash, reason; +- int mac; ++ int mac = 0; + + ring = mtk_get_rx_ring(eth); + if (unlikely(!ring)) +@@ -1365,16 +1432,15 @@ static int mtk_poll_rx(struct napi_struc + rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; + data = ring->data[idx]; + +- if (!mtk_rx_get_desc(&trxd, rxd)) ++ if (!mtk_rx_get_desc(eth, &trxd, rxd)) + break; + + /* find out which mac the packet come from. values start at 1 */ +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) || +- (trxd.rxd4 & RX_DMA_SPECIAL_TAG)) +- mac = 0; +- else +- mac = ((trxd.rxd4 >> RX_DMA_FPORT_SHIFT) & +- RX_DMA_FPORT_MASK) - 1; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) ++ mac = RX_DMA_GET_SPORT_V2(trxd.rxd5) - 1; ++ else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) && ++ !(trxd.rxd4 & RX_DMA_SPECIAL_TAG)) ++ mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1; + + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || + !eth->netdev[mac])) +@@ -1417,7 +1483,7 @@ static int mtk_poll_rx(struct napi_struc + pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); + skb->dev = netdev; + skb_put(skb, pktlen); +- if (trxd.rxd4 & eth->rx_dma_l4_valid) ++ if (trxd.rxd4 & eth->soc->txrx.rx_dma_l4_valid) + skb->ip_summed = CHECKSUM_UNNECESSARY; + else + skb_checksum_none_assert(skb); +@@ -1435,10 +1501,25 @@ static int mtk_poll_rx(struct napi_struc + mtk_ppe_check_skb(eth->ppe, skb, + trxd.rxd4 & MTK_RXD4_FOE_ENTRY); + +- if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && +- (trxd.rxd2 & RX_DMA_VTAG)) +- __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), +- RX_DMA_VID(trxd.rxd3)); ++ if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) { ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ if (trxd.rxd3 & RX_DMA_VTAG_V2) ++ __vlan_hwaccel_put_tag(skb, ++ htons(RX_DMA_VPID(trxd.rxd4)), ++ RX_DMA_VID(trxd.rxd4)); ++ } else if (trxd.rxd2 & RX_DMA_VTAG) { ++ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), ++ RX_DMA_VID(trxd.rxd3)); ++ } ++ ++ /* If the device is attached to a dsa switch, the special ++ * tag inserted in VLAN field by hw switch can * be offloaded ++ * by RX HW VLAN offload. Clear vlan info. ++ */ ++ if (netdev_uses_dsa(netdev)) ++ __vlan_hwaccel_clear_tag(skb); ++ } ++ + skb_record_rx_queue(skb, 0); + napi_gro_receive(napi, skb); + +@@ -1450,7 +1531,7 @@ release_desc: + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) + rxd->rxd2 = RX_DMA_LSO; + else +- rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); ++ rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size); + + ring->calc_idx = idx; + +@@ -1652,7 +1733,8 @@ static int mtk_napi_rx(struct napi_struc + do { + int rx_done; + +- mtk_w32(eth, MTK_RX_DONE_INT, reg_map->pdma.irq_status); ++ mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, ++ reg_map->pdma.irq_status); + rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth); + rx_done_total += rx_done; + +@@ -1666,10 +1748,11 @@ static int mtk_napi_rx(struct napi_struc + if (rx_done_total == budget) + return budget; + +- } while (mtk_r32(eth, reg_map->pdma.irq_status) & MTK_RX_DONE_INT); ++ } while (mtk_r32(eth, reg_map->pdma.irq_status) & ++ eth->soc->txrx.rx_irq_done_mask); + + if (napi_complete_done(napi, rx_done_total)) +- mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask); + + return rx_done_total; + } +@@ -1679,7 +1762,7 @@ static int mtk_tx_alloc(struct mtk_eth * + const struct mtk_soc_data *soc = eth->soc; + struct mtk_tx_ring *ring = ð->tx_ring; + int i, sz = soc->txrx.txd_size; +- struct mtk_tx_dma *txd; ++ struct mtk_tx_dma_v2 *txd; + + ring->buf = kcalloc(MTK_DMA_SIZE, sizeof(*ring->buf), + GFP_KERNEL); +@@ -1699,13 +1782,19 @@ static int mtk_tx_alloc(struct mtk_eth * + txd->txd2 = next_ptr; + txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; + txd->txd4 = 0; ++ if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) { ++ txd->txd5 = 0; ++ txd->txd6 = 0; ++ txd->txd7 = 0; ++ txd->txd8 = 0; ++ } + } + + /* On MT7688 (PDMA only) this driver uses the ring->dma structs + * only as the framework. The real HW descriptors are the PDMA + * descriptors in ring->dma_pdma. + */ +- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { ++ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { + ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, + &ring->phys_pdma, GFP_KERNEL); + if (!ring->dma_pdma) +@@ -1785,13 +1874,11 @@ static int mtk_rx_alloc(struct mtk_eth * + struct mtk_rx_ring *ring; + int rx_data_len, rx_dma_size; + int i; +- u32 offset = 0; + + if (rx_flag == MTK_RX_FLAGS_QDMA) { + if (ring_no) + return -EINVAL; + ring = ð->rx_ring_qdma; +- offset = 0x1000; + } else { + ring = ð->rx_ring[ring_no]; + } +@@ -1824,7 +1911,7 @@ static int mtk_rx_alloc(struct mtk_eth * + return -ENOMEM; + + for (i = 0; i < rx_dma_size; i++) { +- struct mtk_rx_dma *rxd; ++ struct mtk_rx_dma_v2 *rxd; + + dma_addr_t dma_addr = dma_map_single(eth->dma_dev, + ring->data[i] + NET_SKB_PAD + eth->ip_align, +@@ -1839,26 +1926,47 @@ static int mtk_rx_alloc(struct mtk_eth * + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) + rxd->rxd2 = RX_DMA_LSO; + else +- rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); ++ rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size); + + rxd->rxd3 = 0; + rxd->rxd4 = 0; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ rxd->rxd5 = 0; ++ rxd->rxd6 = 0; ++ rxd->rxd7 = 0; ++ rxd->rxd8 = 0; ++ } + } + ring->dma_size = rx_dma_size; + ring->calc_idx_update = false; + ring->calc_idx = rx_dma_size - 1; +- ring->crx_idx_reg = reg_map->pdma.pcrx_ptr + ring_no * MTK_QRX_OFFSET; ++ if (rx_flag == MTK_RX_FLAGS_QDMA) ++ ring->crx_idx_reg = reg_map->qdma.qcrx_ptr + ++ ring_no * MTK_QRX_OFFSET; ++ else ++ ring->crx_idx_reg = reg_map->pdma.pcrx_ptr + ++ ring_no * MTK_QRX_OFFSET; + /* make sure that all changes to the dma ring are flushed before we + * continue + */ + wmb(); + +- mtk_w32(eth, ring->phys, +- reg_map->pdma.rx_ptr + ring_no * MTK_QRX_OFFSET + offset); +- mtk_w32(eth, rx_dma_size, +- reg_map->pdma.rx_cnt_cfg + ring_no * MTK_QRX_OFFSET + offset); +- mtk_w32(eth, ring->calc_idx, ring->crx_idx_reg + offset); +- mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), reg_map->pdma.rst_idx + offset); ++ if (rx_flag == MTK_RX_FLAGS_QDMA) { ++ mtk_w32(eth, ring->phys, ++ reg_map->qdma.rx_ptr + ring_no * MTK_QRX_OFFSET); ++ mtk_w32(eth, rx_dma_size, ++ reg_map->qdma.rx_cnt_cfg + ring_no * MTK_QRX_OFFSET); ++ mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), ++ reg_map->qdma.rst_idx); ++ } else { ++ mtk_w32(eth, ring->phys, ++ reg_map->pdma.rx_ptr + ring_no * MTK_QRX_OFFSET); ++ mtk_w32(eth, rx_dma_size, ++ reg_map->pdma.rx_cnt_cfg + ring_no * MTK_QRX_OFFSET); ++ mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), ++ reg_map->pdma.rst_idx); ++ } ++ mtk_w32(eth, ring->calc_idx, ring->crx_idx_reg); + + return 0; + } +@@ -2277,7 +2385,7 @@ static irqreturn_t mtk_handle_irq_rx(int + eth->rx_events++; + if (likely(napi_schedule_prep(ð->rx_napi))) { + __napi_schedule(ð->rx_napi); +- mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask); + } + + return IRQ_HANDLED; +@@ -2301,8 +2409,10 @@ static irqreturn_t mtk_handle_irq(int ir + struct mtk_eth *eth = _eth; + const struct mtk_reg_map *reg_map = eth->soc->reg_map; + +- if (mtk_r32(eth, reg_map->pdma.irq_mask) & MTK_RX_DONE_INT) { +- if (mtk_r32(eth, reg_map->pdma.irq_status) & MTK_RX_DONE_INT) ++ if (mtk_r32(eth, reg_map->pdma.irq_mask) & ++ eth->soc->txrx.rx_irq_done_mask) { ++ if (mtk_r32(eth, reg_map->pdma.irq_status) & ++ eth->soc->txrx.rx_irq_done_mask) + mtk_handle_irq_rx(irq, _eth); + } + if (mtk_r32(eth, reg_map->tx_irq_mask) & MTK_TX_DONE_INT) { +@@ -2320,16 +2430,16 @@ static void mtk_poll_controller(struct n + struct mtk_eth *eth = mac->hw; + + mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); +- mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask); + mtk_handle_irq_rx(eth->irq[2], dev); + mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); +- mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask); + } + #endif + + static int mtk_start_dma(struct mtk_eth *eth) + { +- u32 rx_2b_offset = (NET_IP_ALIGN == 2) ? MTK_RX_2B_OFFSET : 0; ++ u32 val, rx_2b_offset = (NET_IP_ALIGN == 2) ? MTK_RX_2B_OFFSET : 0; + const struct mtk_reg_map *reg_map = eth->soc->reg_map; + int err; + +@@ -2340,12 +2450,19 @@ static int mtk_start_dma(struct mtk_eth + } + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { +- mtk_w32(eth, +- MTK_TX_WB_DDONE | MTK_TX_DMA_EN | +- MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO | +- MTK_RX_DMA_EN | MTK_RX_2B_OFFSET | +- MTK_RX_BT_32DWORDS, +- reg_map->qdma.glo_cfg); ++ val = mtk_r32(eth, reg_map->qdma.glo_cfg); ++ val |= MTK_TX_DMA_EN | MTK_RX_DMA_EN | ++ MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO | ++ MTK_RX_2B_OFFSET | MTK_TX_WB_DDONE; ++ ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) ++ val |= MTK_MUTLI_CNT | MTK_RESV_BUF | ++ MTK_WCOMP_EN | MTK_DMAD_WR_WDONE | ++ MTK_CHK_DDONE_EN; ++ else ++ val |= MTK_RX_BT_32DWORDS; ++ mtk_w32(eth, val, reg_map->qdma.glo_cfg); ++ + mtk_w32(eth, + MTK_RX_DMA_EN | rx_2b_offset | + MTK_RX_BT_32DWORDS | MTK_MULTI_EN, +@@ -2417,7 +2534,7 @@ static int mtk_open(struct net_device *d + napi_enable(ð->tx_napi); + napi_enable(ð->rx_napi); + mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); +- mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask); + refcount_set(ð->dma_refcnt, 1); + } + else +@@ -2469,7 +2586,7 @@ static int mtk_stop(struct net_device *d + mtk_gdm_config(eth, MTK_GDMA_DROP_ALL); + + mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); +- mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); ++ mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask); + napi_disable(ð->tx_napi); + napi_disable(ð->rx_napi); + +@@ -2629,9 +2746,25 @@ static int mtk_hw_init(struct mtk_eth *e + return 0; + } + +- /* Non-MT7628 handling... */ +- ethsys_reset(eth, RSTCTRL_FE); +- ethsys_reset(eth, RSTCTRL_PPE); ++ val = RSTCTRL_FE | RSTCTRL_PPE; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0); ++ ++ val |= RSTCTRL_ETH; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1)) ++ val |= RSTCTRL_PPE1; ++ } ++ ++ ethsys_reset(eth, val); ++ ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, ++ 0x3ffffff); ++ ++ /* Set FE to PDMAv2 if necessary */ ++ val = mtk_r32(eth, MTK_FE_GLO_MISC); ++ mtk_w32(eth, val | BIT(4), MTK_FE_GLO_MISC); ++ } + + if (eth->pctl) { + /* Set GE2 driving and slew rate */ +@@ -2670,11 +2803,47 @@ static int mtk_hw_init(struct mtk_eth *e + + /* FE int grouping */ + mtk_w32(eth, MTK_TX_DONE_INT, reg_map->pdma.int_grp); +- mtk_w32(eth, MTK_RX_DONE_INT, reg_map->pdma.int_grp + 4); ++ mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->pdma.int_grp + 4); + mtk_w32(eth, MTK_TX_DONE_INT, reg_map->qdma.int_grp); +- mtk_w32(eth, MTK_RX_DONE_INT, reg_map->qdma.int_grp + 4); ++ mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp + 4); + mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP); + ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { ++ /* PSE should not drop port8 and port9 packets */ ++ mtk_w32(eth, 0x00000300, PSE_DROP_CFG); ++ ++ /* PSE Free Queue Flow Control */ ++ mtk_w32(eth, 0x01fa01f4, PSE_FQFC_CFG2); ++ ++ /* PSE config input queue threshold */ ++ mtk_w32(eth, 0x001a000e, PSE_IQ_REV(1)); ++ mtk_w32(eth, 0x01ff001a, PSE_IQ_REV(2)); ++ mtk_w32(eth, 0x000e01ff, PSE_IQ_REV(3)); ++ mtk_w32(eth, 0x000e000e, PSE_IQ_REV(4)); ++ mtk_w32(eth, 0x000e000e, PSE_IQ_REV(5)); ++ mtk_w32(eth, 0x000e000e, PSE_IQ_REV(6)); ++ mtk_w32(eth, 0x000e000e, PSE_IQ_REV(7)); ++ mtk_w32(eth, 0x000e000e, PSE_IQ_REV(8)); ++ ++ /* PSE config output queue threshold */ ++ mtk_w32(eth, 0x000f000a, PSE_OQ_TH(1)); ++ mtk_w32(eth, 0x001a000f, PSE_OQ_TH(2)); ++ mtk_w32(eth, 0x000f001a, PSE_OQ_TH(3)); ++ mtk_w32(eth, 0x01ff000f, PSE_OQ_TH(4)); ++ mtk_w32(eth, 0x000f000f, PSE_OQ_TH(5)); ++ mtk_w32(eth, 0x0006000f, PSE_OQ_TH(6)); ++ mtk_w32(eth, 0x00060006, PSE_OQ_TH(7)); ++ mtk_w32(eth, 0x00060006, PSE_OQ_TH(8)); ++ ++ /* GDM and CDM Threshold */ ++ mtk_w32(eth, 0x00000004, MTK_GDM2_THRES); ++ mtk_w32(eth, 0x00000004, MTK_CDMW0_THRES); ++ mtk_w32(eth, 0x00000004, MTK_CDMW1_THRES); ++ mtk_w32(eth, 0x00000004, MTK_CDME0_THRES); ++ mtk_w32(eth, 0x00000004, MTK_CDME1_THRES); ++ mtk_w32(eth, 0x00000004, MTK_CDMM_THRES); ++ } ++ + return 0; + + err_disable_pm: +@@ -3211,12 +3380,8 @@ static int mtk_probe(struct platform_dev + if (IS_ERR(eth->base)) + return PTR_ERR(eth->base); + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { +- eth->rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) + eth->ip_align = NET_IP_ALIGN; +- } else { +- eth->rx_dma_l4_valid = RX_DMA_L4_VALID; +- } + + spin_lock_init(ð->page_lock); + spin_lock_init(ð->tx_irq_lock); +@@ -3452,6 +3617,10 @@ static const struct mtk_soc_data mt2701_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +@@ -3465,6 +3634,10 @@ static const struct mtk_soc_data mt7621_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +@@ -3479,6 +3652,10 @@ static const struct mtk_soc_data mt7622_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +@@ -3492,6 +3669,10 @@ static const struct mtk_soc_data mt7623_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +@@ -3505,6 +3686,10 @@ static const struct mtk_soc_data mt7629_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +@@ -3517,6 +3702,10 @@ static const struct mtk_soc_data rt5350_ + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), ++ .rx_irq_done_mask = MTK_RX_DONE_INT, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN, ++ .dma_len_offset = 16, + }, + }; + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -23,6 +23,7 @@ + #define MTK_MAX_RX_LENGTH 1536 + #define MTK_MAX_RX_LENGTH_2K 2048 + #define MTK_TX_DMA_BUF_LEN 0x3fff ++#define MTK_TX_DMA_BUF_LEN_V2 0xffff + #define MTK_DMA_SIZE 512 + #define MTK_NAPI_WEIGHT 64 + #define MTK_MAC_COUNT 2 +@@ -83,6 +84,10 @@ + #define MTK_CDMQ_IG_CTRL 0x1400 + #define MTK_CDMQ_STAG_EN BIT(0) + ++/* CDMP Ingress Control Register */ ++#define MTK_CDMP_IG_CTRL 0x400 ++#define MTK_CDMP_STAG_EN BIT(0) ++ + /* CDMP Exgress Control Register */ + #define MTK_CDMP_EG_CTRL 0x404 + +@@ -102,13 +107,38 @@ + /* Unicast Filter MAC Address Register - High */ + #define MTK_GDMA_MAC_ADRH(x) (0x50C + (x * 0x1000)) + ++/* FE global misc reg*/ ++#define MTK_FE_GLO_MISC 0x124 ++ ++/* PSE Free Queue Flow Control */ ++#define PSE_FQFC_CFG1 0x100 ++#define PSE_FQFC_CFG2 0x104 ++#define PSE_DROP_CFG 0x108 ++ ++/* PSE Input Queue Reservation Register*/ ++#define PSE_IQ_REV(x) (0x140 + (((x) - 1) << 2)) ++ ++/* PSE Output Queue Threshold Register*/ ++#define PSE_OQ_TH(x) (0x160 + (((x) - 1) << 2)) ++ ++/* GDM and CDM Threshold */ ++#define MTK_GDM2_THRES 0x1530 ++#define MTK_CDMW0_THRES 0x164c ++#define MTK_CDMW1_THRES 0x1650 ++#define MTK_CDME0_THRES 0x1654 ++#define MTK_CDME1_THRES 0x1658 ++#define MTK_CDMM_THRES 0x165c ++ + /* PDMA HW LRO Control Registers */ + #define MTK_PDMA_LRO_CTRL_DW0 0x980 + #define MTK_LRO_EN BIT(0) + #define MTK_L3_CKS_UPD_EN BIT(7) ++#define MTK_L3_CKS_UPD_EN_V2 BIT(19) + #define MTK_LRO_ALT_PKT_CNT_MODE BIT(21) + #define MTK_LRO_RING_RELINQUISH_REQ (0x7 << 26) ++#define MTK_LRO_RING_RELINQUISH_REQ_V2 (0xf << 24) + #define MTK_LRO_RING_RELINQUISH_DONE (0x7 << 29) ++#define MTK_LRO_RING_RELINQUISH_DONE_V2 (0xf << 28) + + #define MTK_PDMA_LRO_CTRL_DW1 0x984 + #define MTK_PDMA_LRO_CTRL_DW2 0x988 +@@ -180,6 +210,13 @@ + #define MTK_TX_DMA_EN BIT(0) + #define MTK_DMA_BUSY_TIMEOUT_US 1000000 + ++/* QDMA V2 Global Configuration Register */ ++#define MTK_CHK_DDONE_EN BIT(28) ++#define MTK_DMAD_WR_WDONE BIT(26) ++#define MTK_WCOMP_EN BIT(24) ++#define MTK_RESV_BUF (0x40 << 16) ++#define MTK_MUTLI_CNT (0x4 << 12) ++ + /* QDMA Flow Control Register */ + #define FC_THRES_DROP_MODE BIT(20) + #define FC_THRES_DROP_EN (7 << 16) +@@ -199,11 +236,32 @@ + #define MTK_RX_DONE_INT MTK_RX_DONE_DLY + #define MTK_TX_DONE_INT MTK_TX_DONE_DLY + ++#define MTK_RX_DONE_INT_V2 BIT(14) ++ + /* QDMA Interrupt grouping registers */ + #define MTK_RLS_DONE_INT BIT(0) + + #define MTK_STAT_OFFSET 0x40 + ++/* QDMA TX NUM */ ++#define MTK_QDMA_TX_NUM 16 ++#define MTK_QDMA_TX_MASK (MTK_QDMA_TX_NUM - 1) ++#define QID_BITS_V2(x) (((x) & 0x3f) << 16) ++#define MTK_QDMA_GMAC2_QID 8 ++ ++#define MTK_TX_DMA_BUF_SHIFT 8 ++ ++/* QDMA V2 descriptor txd6 */ ++#define TX_DMA_INS_VLAN_V2 BIT(16) ++/* QDMA V2 descriptor txd5 */ ++#define TX_DMA_CHKSUM_V2 (0x7 << 28) ++#define TX_DMA_TSO_V2 BIT(31) ++ ++/* QDMA V2 descriptor txd4 */ ++#define TX_DMA_FPORT_SHIFT_V2 8 ++#define TX_DMA_FPORT_MASK_V2 0xf ++#define TX_DMA_SWC_V2 BIT(30) ++ + #define MTK_WDMA0_BASE 0x2800 + #define MTK_WDMA1_BASE 0x2c00 + +@@ -217,10 +275,9 @@ + /* QDMA descriptor txd3 */ + #define TX_DMA_OWNER_CPU BIT(31) + #define TX_DMA_LS0 BIT(30) +-#define TX_DMA_PLEN0(_x) (((_x) & MTK_TX_DMA_BUF_LEN) << 16) +-#define TX_DMA_PLEN1(_x) ((_x) & MTK_TX_DMA_BUF_LEN) ++#define TX_DMA_PLEN0(x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset) ++#define TX_DMA_PLEN1(x) ((x) & eth->soc->txrx.dma_max_len) + #define TX_DMA_SWC BIT(14) +-#define TX_DMA_SDL(_x) (((_x) & 0x3fff) << 16) + + /* PDMA on MT7628 */ + #define TX_DMA_DONE BIT(31) +@@ -230,12 +287,14 @@ + /* QDMA descriptor rxd2 */ + #define RX_DMA_DONE BIT(31) + #define RX_DMA_LSO BIT(30) +-#define RX_DMA_PLEN0(_x) (((_x) & 0x3fff) << 16) +-#define RX_DMA_GET_PLEN0(_x) (((_x) >> 16) & 0x3fff) ++#define RX_DMA_PREP_PLEN0(x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset) ++#define RX_DMA_GET_PLEN0(x) (((x) >> eth->soc->txrx.dma_len_offset) & eth->soc->txrx.dma_max_len) + #define RX_DMA_VTAG BIT(15) + + /* QDMA descriptor rxd3 */ +-#define RX_DMA_VID(_x) ((_x) & 0xfff) ++#define RX_DMA_VID(x) ((x) & VLAN_VID_MASK) ++#define RX_DMA_TCI(x) ((x) & (VLAN_PRIO_MASK | VLAN_VID_MASK)) ++#define RX_DMA_VPID(x) (((x) >> 16) & 0xffff) + + /* QDMA descriptor rxd4 */ + #define MTK_RXD4_FOE_ENTRY GENMASK(13, 0) +@@ -246,10 +305,15 @@ + /* QDMA descriptor rxd4 */ + #define RX_DMA_L4_VALID BIT(24) + #define RX_DMA_L4_VALID_PDMA BIT(30) /* when PDMA is used */ +-#define RX_DMA_FPORT_SHIFT 19 +-#define RX_DMA_FPORT_MASK 0x7 + #define RX_DMA_SPECIAL_TAG BIT(22) + ++#define RX_DMA_GET_SPORT(x) (((x) >> 19) & 0xf) ++#define RX_DMA_GET_SPORT_V2(x) (((x) >> 26) & 0x7) ++ ++/* PDMA V2 descriptor rxd3 */ ++#define RX_DMA_VTAG_V2 BIT(0) ++#define RX_DMA_L4_VALID_V2 BIT(2) ++ + /* PHY Indirect Access Control registers */ + #define MTK_PHY_IAC 0x10004 + #define PHY_IAC_ACCESS BIT(31) +@@ -370,6 +434,16 @@ + #define ETHSYS_TRGMII_MT7621_DDR_PLL BIT(5) + + /* ethernet reset control register */ ++#define ETHSYS_RSTCTRL 0x34 ++#define RSTCTRL_FE BIT(6) ++#define RSTCTRL_PPE BIT(31) ++#define RSTCTRL_PPE1 BIT(30) ++#define RSTCTRL_ETH BIT(23) ++ ++/* ethernet reset check idle register */ ++#define ETHSYS_FE_RST_CHK_IDLE_EN 0x28 ++ ++/* ethernet reset control register */ + #define ETHSYS_RSTCTRL 0x34 + #define RSTCTRL_FE BIT(6) + #define RSTCTRL_PPE BIT(31) +@@ -453,6 +527,17 @@ struct mtk_rx_dma { + unsigned int rxd4; + } __packed __aligned(4); + ++struct mtk_rx_dma_v2 { ++ unsigned int rxd1; ++ unsigned int rxd2; ++ unsigned int rxd3; ++ unsigned int rxd4; ++ unsigned int rxd5; ++ unsigned int rxd6; ++ unsigned int rxd7; ++ unsigned int rxd8; ++} __packed __aligned(4); ++ + struct mtk_tx_dma { + unsigned int txd1; + unsigned int txd2; +@@ -460,6 +545,17 @@ struct mtk_tx_dma { + unsigned int txd4; + } __packed __aligned(4); + ++struct mtk_tx_dma_v2 { ++ unsigned int txd1; ++ unsigned int txd2; ++ unsigned int txd3; ++ unsigned int txd4; ++ unsigned int txd5; ++ unsigned int txd6; ++ unsigned int txd7; ++ unsigned int txd8; ++} __packed __aligned(4); ++ + struct mtk_eth; + struct mtk_mac; + +@@ -646,7 +742,9 @@ enum mkt_eth_capabilities { + MTK_SHARED_INT_BIT, + MTK_TRGMII_MT7621_CLK_BIT, + MTK_QDMA_BIT, ++ MTK_NETSYS_V2_BIT, + MTK_SOC_MT7628_BIT, ++ MTK_RSTCTRL_PPE1_BIT, + + /* MUX BITS*/ + MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT, +@@ -678,7 +776,9 @@ enum mkt_eth_capabilities { + #define MTK_SHARED_INT BIT(MTK_SHARED_INT_BIT) + #define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT) + #define MTK_QDMA BIT(MTK_QDMA_BIT) ++#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT) + #define MTK_SOC_MT7628 BIT(MTK_SOC_MT7628_BIT) ++#define MTK_RSTCTRL_PPE1 BIT(MTK_RSTCTRL_PPE1_BIT) + + #define MTK_ETH_MUX_GDM1_TO_GMAC1_ESW \ + BIT(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT) +@@ -755,6 +855,7 @@ struct mtk_tx_dma_desc_info { + dma_addr_t addr; + u32 size; + u16 vlan_tci; ++ u16 qid; + u8 gso:1; + u8 csum:1; + u8 vlan:1; +@@ -812,6 +913,10 @@ struct mtk_reg_map { + * the extra setup for those pins used by GMAC. + * @txd_size Tx DMA descriptor size. + * @rxd_size Rx DMA descriptor size. ++ * @rx_irq_done_mask Rx irq done register mask. ++ * @rx_dma_l4_valid Rx DMA valid register mask. ++ * @dma_max_len Max DMA tx/rx buffer length. ++ * @dma_len_offset Tx/Rx DMA length field offset. + */ + struct mtk_soc_data { + const struct mtk_reg_map *reg_map; +@@ -824,6 +929,10 @@ struct mtk_soc_data { + struct { + u32 txd_size; + u32 rxd_size; ++ u32 rx_irq_done_mask; ++ u32 rx_dma_l4_valid; ++ u32 dma_max_len; ++ u32 dma_len_offset; + } txrx; + }; + +@@ -942,7 +1051,6 @@ struct mtk_eth { + u32 tx_bytes; + struct dim tx_dim; + +- u32 rx_dma_l4_valid; + int ip_align; + + struct mtk_ppe *ppe; diff --git a/target/linux/generic/backport-5.15/702-v5.19-28-net-ethernet-mtk_eth_soc-convert-ring-dma-pointer-to.patch b/target/linux/generic/backport-5.15/702-v5.19-28-net-ethernet-mtk_eth_soc-convert-ring-dma-pointer-to.patch new file mode 100644 index 0000000000..75944f56bf --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-28-net-ethernet-mtk_eth_soc-convert-ring-dma-pointer-to.patch @@ -0,0 +1,135 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:37 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: convert ring dma pointer to void + +Simplify the code converting {tx,rx} ring dma pointer to void + +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -935,18 +935,15 @@ static int mtk_init_fq_dma(struct mtk_et + return 0; + } + +-static inline void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc) ++static void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc) + { +- void *ret = ring->dma; +- +- return ret + (desc - ring->phys); ++ return ring->dma + (desc - ring->phys); + } + + static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, +- struct mtk_tx_dma *txd, +- u32 txd_size) ++ void *txd, u32 txd_size) + { +- int idx = ((void *)txd - (void *)ring->dma) / txd_size; ++ int idx = (txd - ring->dma) / txd_size; + + return &ring->buf[idx]; + } +@@ -954,13 +951,12 @@ static struct mtk_tx_buf *mtk_desc_to_tx + static struct mtk_tx_dma *qdma_to_pdma(struct mtk_tx_ring *ring, + struct mtk_tx_dma *dma) + { +- return ring->dma_pdma - ring->dma + dma; ++ return ring->dma_pdma - (struct mtk_tx_dma *)ring->dma + dma; + } + +-static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma, +- u32 txd_size) ++static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_size) + { +- return ((void *)dma - (void *)ring->dma) / txd_size; ++ return (dma - ring->dma) / txd_size; + } + + static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, +@@ -1377,7 +1373,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri + + ring = ð->rx_ring[i]; + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; ++ rxd = ring->dma + idx * eth->soc->txrx.rxd_size; + if (rxd->rxd2 & RX_DMA_DONE) { + ring->calc_idx_update = true; + return ring; +@@ -1429,7 +1425,7 @@ static int mtk_poll_rx(struct napi_struc + goto rx_done; + + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; ++ rxd = ring->dma + idx * eth->soc->txrx.rxd_size; + data = ring->data[idx]; + + if (!mtk_rx_get_desc(eth, &trxd, rxd)) +@@ -1633,7 +1629,7 @@ static int mtk_poll_tx_pdma(struct mtk_e + + mtk_tx_unmap(eth, tx_buf, true); + +- desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size; ++ desc = ring->dma + cpu * eth->soc->txrx.txd_size; + ring->last_free = desc; + atomic_inc(&ring->free_count); + +@@ -1778,7 +1774,7 @@ static int mtk_tx_alloc(struct mtk_eth * + int next = (i + 1) % MTK_DMA_SIZE; + u32 next_ptr = ring->phys + next * sz; + +- txd = (void *)ring->dma + i * sz; ++ txd = ring->dma + i * sz; + txd->txd2 = next_ptr; + txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; + txd->txd4 = 0; +@@ -1808,7 +1804,7 @@ static int mtk_tx_alloc(struct mtk_eth * + + ring->dma_size = MTK_DMA_SIZE; + atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); +- ring->next_free = &ring->dma[0]; ++ ring->next_free = ring->dma; + ring->last_free = (void *)txd; + ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); + ring->thresh = MAX_SKB_FRAGS; +@@ -1920,7 +1916,7 @@ static int mtk_rx_alloc(struct mtk_eth * + if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) + return -ENOMEM; + +- rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; ++ rxd = ring->dma + i * eth->soc->txrx.rxd_size; + rxd->rxd1 = (unsigned int)dma_addr; + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) +@@ -1982,7 +1978,7 @@ static void mtk_rx_clean(struct mtk_eth + if (!ring->data[i]) + continue; + +- rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; ++ rxd = ring->dma + i * eth->soc->txrx.rxd_size; + if (!rxd->rxd1) + continue; + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -688,7 +688,7 @@ struct mtk_tx_buf { + * are present + */ + struct mtk_tx_ring { +- struct mtk_tx_dma *dma; ++ void *dma; + struct mtk_tx_buf *buf; + dma_addr_t phys; + struct mtk_tx_dma *next_free; +@@ -718,7 +718,7 @@ enum mtk_rx_flags { + * @calc_idx: The current head of ring + */ + struct mtk_rx_ring { +- struct mtk_rx_dma *dma; ++ void *dma; + u8 **data; + dma_addr_t phys; + u16 frag_size; diff --git a/target/linux/generic/backport-5.15/702-v5.19-29-net-ethernet-mtk_eth_soc-convert-scratch_ring-pointe.patch b/target/linux/generic/backport-5.15/702-v5.19-29-net-ethernet-mtk_eth_soc-convert-scratch_ring-pointe.patch new file mode 100644 index 0000000000..0032dc7629 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-29-net-ethernet-mtk_eth_soc-convert-scratch_ring-pointe.patch @@ -0,0 +1,33 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:38 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: convert scratch_ring pointer to + void + +Simplify the code converting scratch_ring pointer to void + +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -911,7 +911,7 @@ static int mtk_init_fq_dma(struct mtk_et + for (i = 0; i < cnt; i++) { + struct mtk_tx_dma_v2 *txd; + +- txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size; ++ txd = eth->scratch_ring + i * soc->txrx.txd_size; + txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; + if (i < cnt - 1) + txd->txd2 = eth->phy_scratch_ring + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -1028,7 +1028,7 @@ struct mtk_eth { + struct mtk_rx_ring rx_ring_qdma; + struct napi_struct tx_napi; + struct napi_struct rx_napi; +- struct mtk_tx_dma *scratch_ring; ++ void *scratch_ring; + dma_addr_t phy_scratch_ring; + void *scratch_head; + struct clk *clks[MTK_CLK_MAX]; diff --git a/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch b/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch new file mode 100644 index 0000000000..ed4b7abb2c --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch @@ -0,0 +1,138 @@ +From: Lorenzo Bianconi +Date: Fri, 20 May 2022 20:11:39 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce support for mt7986 + chipset + +Add support for mt7986-eth driver available on mt7986 soc. + +Tested-by: Sam Shih +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -87,6 +87,43 @@ static const struct mtk_reg_map mt7628_r + }, + }; + ++static const struct mtk_reg_map mt7986_reg_map = { ++ .tx_irq_mask = 0x461c, ++ .tx_irq_status = 0x4618, ++ .pdma = { ++ .rx_ptr = 0x6100, ++ .rx_cnt_cfg = 0x6104, ++ .pcrx_ptr = 0x6108, ++ .glo_cfg = 0x6204, ++ .rst_idx = 0x6208, ++ .delay_irq = 0x620c, ++ .irq_status = 0x6220, ++ .irq_mask = 0x6228, ++ .int_grp = 0x6250, ++ }, ++ .qdma = { ++ .qtx_cfg = 0x4400, ++ .rx_ptr = 0x4500, ++ .rx_cnt_cfg = 0x4504, ++ .qcrx_ptr = 0x4508, ++ .glo_cfg = 0x4604, ++ .rst_idx = 0x4608, ++ .delay_irq = 0x460c, ++ .fc_th = 0x4610, ++ .int_grp = 0x4620, ++ .hred = 0x4644, ++ .ctx_ptr = 0x4700, ++ .dtx_ptr = 0x4704, ++ .crx_ptr = 0x4710, ++ .drx_ptr = 0x4714, ++ .fq_head = 0x4720, ++ .fq_tail = 0x4724, ++ .fq_count = 0x4728, ++ .fq_blen = 0x472c, ++ }, ++ .gdm1_cnt = 0x1c00, ++}; ++ + /* strings used by ethtool */ + static const struct mtk_ethtool_stats { + char str[ETH_GSTRING_LEN]; +@@ -110,7 +147,7 @@ static const char * const mtk_clks_sourc + "ethif", "sgmiitop", "esw", "gp0", "gp1", "gp2", "fe", "trgpll", + "sgmii_tx250m", "sgmii_rx250m", "sgmii_cdr_ref", "sgmii_cdr_fb", + "sgmii2_tx250m", "sgmii2_rx250m", "sgmii2_cdr_ref", "sgmii2_cdr_fb", +- "sgmii_ck", "eth2pll", ++ "sgmii_ck", "eth2pll", "wocpu0", "wocpu1", "netsys0", "netsys1" + }; + + void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg) +@@ -3689,6 +3726,21 @@ static const struct mtk_soc_data mt7629_ + }, + }; + ++static const struct mtk_soc_data mt7986_data = { ++ .reg_map = &mt7986_reg_map, ++ .ana_rgc3 = 0x128, ++ .caps = MT7986_CAPS, ++ .required_clks = MT7986_CLKS_BITMAP, ++ .required_pctl = false, ++ .txrx = { ++ .txd_size = sizeof(struct mtk_tx_dma_v2), ++ .rxd_size = sizeof(struct mtk_rx_dma_v2), ++ .rx_irq_done_mask = MTK_RX_DONE_INT_V2, ++ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, ++ .dma_len_offset = 8, ++ }, ++}; ++ + static const struct mtk_soc_data rt5350_data = { + .reg_map = &mt7628_reg_map, + .caps = MT7628_CAPS, +@@ -3711,6 +3763,7 @@ const struct of_device_id of_mtk_match[] + { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, + { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, + { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, ++ { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data}, + { .compatible = "ralink,rt5350-eth", .data = &rt5350_data}, + {}, + }; +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -623,6 +623,10 @@ enum mtk_clks_map { + MTK_CLK_SGMII2_CDR_FB, + MTK_CLK_SGMII_CK, + MTK_CLK_ETH2PLL, ++ MTK_CLK_WOCPU0, ++ MTK_CLK_WOCPU1, ++ MTK_CLK_NETSYS0, ++ MTK_CLK_NETSYS1, + MTK_CLK_MAX + }; + +@@ -653,6 +657,16 @@ enum mtk_clks_map { + BIT(MTK_CLK_SGMII2_CDR_FB) | \ + BIT(MTK_CLK_SGMII_CK) | \ + BIT(MTK_CLK_ETH2PLL) | BIT(MTK_CLK_SGMIITOP)) ++#define MT7986_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \ ++ BIT(MTK_CLK_WOCPU1) | BIT(MTK_CLK_WOCPU0) | \ ++ BIT(MTK_CLK_SGMII_TX_250M) | \ ++ BIT(MTK_CLK_SGMII_RX_250M) | \ ++ BIT(MTK_CLK_SGMII_CDR_REF) | \ ++ BIT(MTK_CLK_SGMII_CDR_FB) | \ ++ BIT(MTK_CLK_SGMII2_TX_250M) | \ ++ BIT(MTK_CLK_SGMII2_RX_250M) | \ ++ BIT(MTK_CLK_SGMII2_CDR_REF) | \ ++ BIT(MTK_CLK_SGMII2_CDR_FB)) + + enum mtk_dev_state { + MTK_HW_INIT, +@@ -851,6 +865,10 @@ enum mkt_eth_capabilities { + MTK_MUX_U3_GMAC2_TO_QPHY | \ + MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA) + ++#define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \ ++ MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \ ++ MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1) ++ + struct mtk_tx_dma_desc_info { + dma_addr_t addr; + u32 size; diff --git a/target/linux/generic/backport-5.15/702-v5.19-31-net-ethernet-mtk_eth_soc-fix-error-code-in-mtk_flow_.patch b/target/linux/generic/backport-5.15/702-v5.19-31-net-ethernet-mtk_eth_soc-fix-error-code-in-mtk_flow_.patch new file mode 100644 index 0000000000..e490333a9b --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-31-net-ethernet-mtk_eth_soc-fix-error-code-in-mtk_flow_.patch @@ -0,0 +1,25 @@ +From: Dan Carpenter +Date: Thu, 19 May 2022 17:08:00 +0300 +Subject: [PATCH] net: ethernet: mtk_eth_soc: fix error code in + mtk_flow_offload_replace() + +Preserve the error code from mtk_foe_entry_commit(). Do not return +success. + +Fixes: c4f033d9e03e ("net: ethernet: mtk_eth_soc: rework hardware flow table management") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +@@ -434,7 +434,8 @@ mtk_flow_offload_replace(struct mtk_eth + memcpy(&entry->data, &foe, sizeof(entry->data)); + entry->wed_index = wed_index; + +- if (mtk_foe_entry_commit(eth->ppe, entry) < 0) ++ err = mtk_foe_entry_commit(eth->ppe, entry); ++ if (err < 0) + goto free; + + err = rhashtable_insert_fast(ð->flow_table, &entry->node, diff --git a/target/linux/generic/backport-5.15/702-v5.19-32-net-ethernet-mtk_eth_soc-out-of-bounds-read-in-mtk_h.patch b/target/linux/generic/backport-5.15/702-v5.19-32-net-ethernet-mtk_eth_soc-out-of-bounds-read-in-mtk_h.patch new file mode 100644 index 0000000000..e3250e9284 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-32-net-ethernet-mtk_eth_soc-out-of-bounds-read-in-mtk_h.patch @@ -0,0 +1,25 @@ +From: Dan Carpenter +Date: Thu, 26 May 2022 11:02:42 +0300 +Subject: [PATCH] net: ethernet: mtk_eth_soc: out of bounds read in + mtk_hwlro_get_fdir_entry() + +The "fsp->location" variable comes from user via ethtool_get_rxnfc(). +Check that it is valid to prevent an out of bounds read. + +Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -2230,6 +2230,9 @@ static int mtk_hwlro_get_fdir_entry(stru + struct ethtool_rx_flow_spec *fsp = + (struct ethtool_rx_flow_spec *)&cmd->fs; + ++ if (fsp->location >= ARRAY_SIZE(mac->hwlro_ip)) ++ return -EINVAL; ++ + /* only tcp dst ipv4 is meaningful, others are meaningless */ + fsp->flow_type = TCP_V4_FLOW; + fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]); diff --git a/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch b/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch new file mode 100644 index 0000000000..6341190917 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch @@ -0,0 +1,47 @@ +From: Lorenzo Bianconi +Date: Mon, 6 Jun 2022 21:49:00 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: enable rx cksum offload for + MTK_NETSYS_V2 + +Enable rx checksum offload for mt7986 chipset. + +Signed-off-by: Lorenzo Bianconi +Link: https://lore.kernel.org/r/c8699805c18f7fd38315fcb8da2787676d83a32c.1654544585.git.lorenzo@kernel.org +Signed-off-by: Jakub Kicinski +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1451,8 +1451,8 @@ static int mtk_poll_rx(struct napi_struc + int done = 0, bytes = 0; + + while (done < budget) { ++ unsigned int pktlen, *rxdcsum; + struct net_device *netdev; +- unsigned int pktlen; + dma_addr_t dma_addr; + u32 hash, reason; + int mac = 0; +@@ -1516,7 +1516,13 @@ static int mtk_poll_rx(struct napi_struc + pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); + skb->dev = netdev; + skb_put(skb, pktlen); +- if (trxd.rxd4 & eth->soc->txrx.rx_dma_l4_valid) ++ ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) ++ rxdcsum = &trxd.rxd3; ++ else ++ rxdcsum = &trxd.rxd4; ++ ++ if (*rxdcsum & eth->soc->txrx.rx_dma_l4_valid) + skb->ip_summed = CHECKSUM_UNNECESSARY; + else + skb_checksum_none_assert(skb); +@@ -3739,6 +3745,7 @@ static const struct mtk_soc_data mt7986_ + .txd_size = sizeof(struct mtk_tx_dma_v2), + .rxd_size = sizeof(struct mtk_rx_dma_v2), + .rx_irq_done_mask = MTK_RX_DONE_INT_V2, ++ .rx_dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + }, diff --git a/target/linux/generic/backport-5.15/702-v5.19-34-net-ethernet-mtk_eth_soc-fix-misuse-of-mem-alloc-int.patch b/target/linux/generic/backport-5.15/702-v5.19-34-net-ethernet-mtk_eth_soc-fix-misuse-of-mem-alloc-int.patch new file mode 100644 index 0000000000..9c86413ce7 --- /dev/null +++ b/target/linux/generic/backport-5.15/702-v5.19-34-net-ethernet-mtk_eth_soc-fix-misuse-of-mem-alloc-int.patch @@ -0,0 +1,61 @@ +From: Chen Lin +Date: Wed, 8 Jun 2022 20:46:53 +0800 +Subject: [PATCH] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface + netdev[napi]_alloc_frag + +When rx_flag == MTK_RX_FLAGS_HWLRO, +rx_data_len = MTK_MAX_LRO_RX_LENGTH(4096 * 3) > PAGE_SIZE. +netdev_alloc_frag is for alloction of page fragment only. +Reference to other drivers and Documentation/vm/page_frags.rst + +Branch to use __get_free_pages when ring->frag_size > PAGE_SIZE. + +Signed-off-by: Chen Lin +Link: https://lore.kernel.org/r/1654692413-2598-1-git-send-email-chen45464546@163.com +Signed-off-by: Jakub Kicinski +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -917,6 +917,17 @@ static bool mtk_rx_get_desc(struct mtk_e + return true; + } + ++static void *mtk_max_lro_buf_alloc(gfp_t gfp_mask) ++{ ++ unsigned int size = mtk_max_frag_size(MTK_MAX_LRO_RX_LENGTH); ++ unsigned long data; ++ ++ data = __get_free_pages(gfp_mask | __GFP_COMP | __GFP_NOWARN, ++ get_order(size)); ++ ++ return (void *)data; ++} ++ + /* the qdma core needs scratch memory to be setup */ + static int mtk_init_fq_dma(struct mtk_eth *eth) + { +@@ -1485,7 +1496,10 @@ static int mtk_poll_rx(struct napi_struc + goto release_desc; + + /* alloc new buffer */ +- new_data = napi_alloc_frag(ring->frag_size); ++ if (ring->frag_size <= PAGE_SIZE) ++ new_data = napi_alloc_frag(ring->frag_size); ++ else ++ new_data = mtk_max_lro_buf_alloc(GFP_ATOMIC); + if (unlikely(!new_data)) { + netdev->stats.rx_dropped++; + goto release_desc; +@@ -1938,7 +1952,10 @@ static int mtk_rx_alloc(struct mtk_eth * + return -ENOMEM; + + for (i = 0; i < rx_dma_size; i++) { +- ring->data[i] = netdev_alloc_frag(ring->frag_size); ++ if (ring->frag_size <= PAGE_SIZE) ++ ring->data[i] = netdev_alloc_frag(ring->frag_size); ++ else ++ ring->data[i] = mtk_max_lro_buf_alloc(GFP_KERNEL); + if (!ring->data[i]) + return -ENOMEM; + } diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 4a2522419a..e4f999f740 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -3681,6 +3681,7 @@ CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 CONFIG_MTD_ROOTFS_ROOT_DEV=y # CONFIG_MTD_ROUTERBOOT_PARTS is not set # CONFIG_MTD_SBC_GXX is not set +# CONFIG_MTD_SERCOMM_PARTS is not set # CONFIG_MTD_SLRAM is not set # CONFIG_MTD_SM_COMMON is not set # CONFIG_MTD_SPINAND_MT29F is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 27d30e34eb..06264e1b6d 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -3822,6 +3822,7 @@ CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 CONFIG_MTD_ROOTFS_ROOT_DEV=y # CONFIG_MTD_ROUTERBOOT_PARTS is not set # CONFIG_MTD_SBC_GXX is not set +# CONFIG_MTD_SERCOMM_PARTS is not set # CONFIG_MTD_SLRAM is not set # CONFIG_MTD_SM_COMMON is not set # CONFIG_MTD_SPINAND_MT29F is not set diff --git a/target/linux/generic/hack-5.15/710-net-dsa-mv88e6xxx-default-VID-1.patch b/target/linux/generic/hack-5.15/710-net-dsa-mv88e6xxx-default-VID-1.patch deleted file mode 100644 index f85b558fef..0000000000 --- a/target/linux/generic/hack-5.15/710-net-dsa-mv88e6xxx-default-VID-1.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/drivers/net/dsa/mv88e6xxx/chip.c -+++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -2321,6 +2321,7 @@ static int mv88e6xxx_port_fdb_add(struct - struct mv88e6xxx_chip *chip = ds->priv; - int err; - -+ vid = vid ? : 1; - mv88e6xxx_reg_lock(chip); - err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, - MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); -@@ -2335,6 +2336,7 @@ static int mv88e6xxx_port_fdb_del(struct - struct mv88e6xxx_chip *chip = ds->priv; - int err; - -+ vid = vid ? : 1; - mv88e6xxx_reg_lock(chip); - err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); - mv88e6xxx_reg_unlock(chip); diff --git a/target/linux/generic/pending-5.10/201-extra_optimization.patch b/target/linux/generic/pending-5.10/201-extra_optimization.patch index cb1de80764..dcf39c574f 100644 --- a/target/linux/generic/pending-5.10/201-extra_optimization.patch +++ b/target/linux/generic/pending-5.10/201-extra_optimization.patch @@ -14,18 +14,12 @@ Signed-off-by: Felix Fietkau --- a/Makefile +++ b/Makefile -@@ -735,11 +735,11 @@ KBUILD_CFLAGS += $(call cc-disable-warni - KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) - - ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE --KBUILD_CFLAGS += -O2 -+KBUILD_CFLAGS += -O2 $(EXTRA_OPTIMIZATION) +@@ -739,7 +739,7 @@ KBUILD_CFLAGS += -O2 else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 --KBUILD_CFLAGS += -O3 -+KBUILD_CFLAGS += -O3 $(EXTRA_OPTIMIZATION) + KBUILD_CFLAGS += -O3 else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += -Os -+KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION) ++KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch endif # Tell gcc to never replace conditional load with a non-conditional one diff --git a/target/linux/generic/pending-5.10/435-mtd-add-routerbootpart-parser-config.patch b/target/linux/generic/pending-5.10/435-mtd-add-routerbootpart-parser-config.patch index ab1e09a5f1..446bc0bef1 100644 --- a/target/linux/generic/pending-5.10/435-mtd-add-routerbootpart-parser-config.patch +++ b/target/linux/generic/pending-5.10/435-mtd-add-routerbootpart-parser-config.patch @@ -16,10 +16,10 @@ Signed-off-by: Thibaut VARÈNE --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig -@@ -195,3 +195,12 @@ config MTD_REDBOOT_PARTS_READONLY - 'FIS directory' images, enable this option. - - endif # MTD_REDBOOT_PARTS +@@ -204,3 +204,12 @@ config MTD_SERCOMM_PARTS + partition map. This partition table contains real partition + offsets, which may differ from device to device depending on the + number and location of bad blocks on NAND. + +config MTD_ROUTERBOOT_PARTS + tristate "RouterBoot flash partition parser" @@ -31,8 +31,8 @@ Signed-off-by: Thibaut VARÈNE + formatted DTS. --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile -@@ -13,3 +13,4 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o - obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o +@@ -14,3 +14,4 @@ obj-$(CONFIG_MTD_PARSER_TRX) += parser_ + obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o +obj-$(CONFIG_MTD_ROUTERBOOT_PARTS) += routerbootpart.o diff --git a/target/linux/generic/pending-5.15/201-extra_optimization.patch b/target/linux/generic/pending-5.15/201-extra_optimization.patch index 5300a5c4ab..96e93dde9b 100644 --- a/target/linux/generic/pending-5.15/201-extra_optimization.patch +++ b/target/linux/generic/pending-5.15/201-extra_optimization.patch @@ -14,18 +14,12 @@ Signed-off-by: Felix Fietkau --- a/Makefile +++ b/Makefile -@@ -752,11 +752,11 @@ KBUILD_CFLAGS += $(call cc-disable-warni - KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) - - ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE --KBUILD_CFLAGS += -O2 -+KBUILD_CFLAGS += -O2 $(EXTRA_OPTIMIZATION) +@@ -756,7 +756,7 @@ KBUILD_CFLAGS += -O2 else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 --KBUILD_CFLAGS += -O3 -+KBUILD_CFLAGS += -O3 $(EXTRA_OPTIMIZATION) + KBUILD_CFLAGS += -O3 else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += -Os -+KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION) ++KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch endif # Tell gcc to never replace conditional load with a non-conditional one diff --git a/target/linux/generic/pending-5.15/435-mtd-add-routerbootpart-parser-config.patch b/target/linux/generic/pending-5.15/435-mtd-add-routerbootpart-parser-config.patch index 721a4d3a5d..30f5334af4 100644 --- a/target/linux/generic/pending-5.15/435-mtd-add-routerbootpart-parser-config.patch +++ b/target/linux/generic/pending-5.15/435-mtd-add-routerbootpart-parser-config.patch @@ -16,10 +16,10 @@ Signed-off-by: Thibaut VARÈNE --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig -@@ -202,3 +202,12 @@ config MTD_QCOMSMEM_PARTS - help - This provides support for parsing partitions from Shared Memory (SMEM) - for NAND and SPI flash on Qualcomm platforms. +@@ -211,3 +211,12 @@ config MTD_SERCOMM_PARTS + partition map. This partition table contains real partition + offsets, which may differ from device to device depending on the + number and location of bad blocks on NAND. + +config MTD_ROUTERBOOT_PARTS + tristate "RouterBoot flash partition parser" @@ -31,7 +31,7 @@ Signed-off-by: Thibaut VARÈNE + formatted DTS. --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile -@@ -14,3 +14,4 @@ obj-$(CONFIG_MTD_PARSER_TRX) += parser_ +@@ -15,3 +15,4 @@ obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpa obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o obj-$(CONFIG_MTD_QCOMSMEM_PARTS) += qcomsmempart.o diff --git a/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch b/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch index af57b4c5bb..354c3eacc0 100644 --- a/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch +++ b/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch @@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -2068,6 +2068,8 @@ struct net_device { +@@ -2075,6 +2075,8 @@ struct net_device { struct netdev_hw_addr_list mc; struct netdev_hw_addr_list dev_addrs; @@ -32,7 +32,7 @@ Signed-off-by: Felix Fietkau __u8 inner_protocol_type:1; --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -6051,6 +6051,9 @@ static enum gro_result dev_gro_receive(s +@@ -6055,6 +6055,9 @@ static enum gro_result dev_gro_receive(s int same_flow; int grow; @@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau if (netif_elide_gro(skb->dev)) goto normal; -@@ -8065,6 +8068,48 @@ static void __netdev_adjacent_dev_unlink +@@ -8069,6 +8072,48 @@ static void __netdev_adjacent_dev_unlink &upper_dev->adj_list.lower); } @@ -91,7 +91,7 @@ Signed-off-by: Felix Fietkau static int __netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev, bool master, void *upper_priv, void *upper_info, -@@ -8116,6 +8161,7 @@ static int __netdev_upper_dev_link(struc +@@ -8120,6 +8165,7 @@ static int __netdev_upper_dev_link(struc if (ret) return ret; @@ -99,7 +99,7 @@ Signed-off-by: Felix Fietkau ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); ret = notifier_to_errno(ret); -@@ -8212,6 +8258,7 @@ static void __netdev_upper_dev_unlink(st +@@ -8216,6 +8262,7 @@ static void __netdev_upper_dev_unlink(st __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); @@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); -@@ -9031,6 +9078,7 @@ int dev_set_mac_address(struct net_devic +@@ -9035,6 +9082,7 @@ int dev_set_mac_address(struct net_devic if (err) return err; dev->addr_assign_type = NET_ADDR_SET; diff --git a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index 4365359e00..4b5c474204 100644 --- a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -10,17 +10,17 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -2186,8 +2186,8 @@ static irqreturn_t mtk_handle_irq_rx(int +@@ -2443,8 +2443,8 @@ static irqreturn_t mtk_handle_irq_rx(int eth->rx_events++; if (likely(napi_schedule_prep(ð->rx_napi))) { - __napi_schedule(ð->rx_napi); - mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); + mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask); + __napi_schedule(ð->rx_napi); } return IRQ_HANDLED; -@@ -2199,8 +2199,8 @@ static irqreturn_t mtk_handle_irq_tx(int +@@ -2456,8 +2456,8 @@ static irqreturn_t mtk_handle_irq_tx(int eth->tx_events++; if (likely(napi_schedule_prep(ð->tx_napi))) { @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau } return IRQ_HANDLED; -@@ -3313,6 +3313,8 @@ static int mtk_probe(struct platform_dev +@@ -3623,6 +3623,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index c8f5e713b3..8fec24da7b 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -29,6 +29,7 @@ ipq40xx_setup_interfaces() engenius,eap1300|\ engenius,emd1|\ meraki,mr33|\ + meraki,mr74|\ mikrotik,lhgg-60ad|\ mikrotik,sxtsq-5-ac|\ netgear,ex6100v2|\ diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 0ba83c4646..da896017b3 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -9,7 +9,8 @@ board=$(board_name) case "$FIRMWARE" in "ath10k/cal-pci-0000:01:00.0.bin") case "$board" in - meraki,mr33) + meraki,mr33 |\ + meraki,mr74) caldata_extract_ubi "ART" 0x9000 0x844 caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 1) @@ -111,7 +112,8 @@ case "$FIRMWARE" in caldata_extract "ART" 0x1000 0x2f20 ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2) ;; - meraki,mr33) + meraki,mr33 |\ + meraki,mr74) caldata_extract_ubi "ART" 0x1000 0x2f20 caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 2) @@ -191,7 +193,8 @@ case "$FIRMWARE" in caldata_extract "ART" 0x5000 0x2f20 ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3) ;; - meraki,mr33) + meraki,mr33 |\ + meraki,mr74) caldata_extract_ubi "ART" 0x5000 0x2f20 caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 3) diff --git a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh index 2609a55d27..cf89624ea3 100644 --- a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh +++ b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh @@ -21,7 +21,8 @@ preinit_set_mac_address() { ip link set dev eth0 address "$base_mac" ip link set dev eth1 address $(macaddr_add "$base_mac" 1) ;; - meraki,mr33) + meraki,mr33|\ + meraki,mr74) mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) [ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan" ;; diff --git a/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh b/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh index 18c13c602c..a8a4469e6c 100644 --- a/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh +++ b/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh @@ -11,6 +11,7 @@ set_preinit_iface() { linksys,ea8300| \ linksys,mr8300| \ meraki,mr33| \ + meraki,mr74| \ zyxel,nbg6617) ifname=eth0 ;; diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index 276682313d..fd8f56d2e4 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -167,7 +167,8 @@ platform_do_upgrade() { linksys,whw01-v1) platform_do_upgrade_linksys "$1" ;; - meraki,mr33) + meraki,mr33 |\ + meraki,mr74) CI_KERNPART="part.safe" nand_do_upgrade "$1" ;; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi new file mode 100644 index 0000000000..47646e4b3c --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi @@ -0,0 +1,407 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Device Tree Source for Meraki "Insect" series + * + * Copyright (C) 2017 Chris Blake + * Copyright (C) 2017 Christian Lamparter + * + * Based on Cisco Meraki DTS from GPL release r25-linux-3.14-20170427 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +#include "qcom-ipq4019.dtsi" +#include +#include +#include +#include + +/ { + aliases { + led-boot = &status_green; + led-failsafe = &status_red; + led-running = &status_green; + led-upgrade = &power_orange; + }; + + /* Do we really need this defined? */ + memory { + device_type = "memory"; + reg = <0x80000000 0x10000000>; + }; + + soc { + rng@22000 { + status = "okay"; + }; + + mdio@90000 { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + }; + + /* It is a 56-bit counter that supplies the count to the ARM arch + timers and without upstream driver */ + counter@4a1000 { + compatible = "qcom,qca-gcnt"; + reg = <0x4a1000 0x4>; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + + serial@78b0000 { + pinctrl-0 = <&serial_1_pins>; + pinctrl-names = "default"; + status = "okay"; + + bluetooth { + compatible = "ti,cc2650"; + enable-gpios = <&tlmm 12 GPIO_ACTIVE_LOW>; + }; + }; + + crypto@8e3a000 { + status = "okay"; + }; + + watchdog@b017000 { + status = "okay"; + }; + + ess-switch@c000000 { + switch_mac_mode = <0x3>; /* mac mode for RGMII RMII */ + switch_lan_bmp = <0x0>; /* lan port bitmap */ + switch_wan_bmp = <0x10>; /* wan port bitmap */ + }; + + edma@c080000 { + qcom,single-phy; + qcom,num_gmac = <1>; + phy-mode = "rgmii-rxid"; + status = "okay"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + power_orange: power { + label = "orange:power"; + gpios = <&tlmm 49 GPIO_ACTIVE_LOW>; + panic-indicator; + }; + }; +}; + +&blsp_dma { + status = "okay"; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&gmac0 { + qcom,phy_mdio_addr = <1>; + qcom,poll_required = <1>; + vlan_tag = <0 0x20>; +}; + +&blsp1_i2c3 { + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + status = "okay"; + at24@50 { + compatible = "atmel,24c64"; + pagesize = <32>; + reg = <0x50>; + read-only; /* This holds our MAC & Meraki board-data */ + }; +}; + +&blsp1_i2c4 { + pinctrl-0 = <&i2c_1_pins>; + pinctrl-names = "default"; + status = "okay"; + + tricolor: led-controller@30 { + compatible = "ti,lp5562"; + reg = <0x30>; + clock-mode = /bits/8 <2>; + #address-cells = <1>; + #size-cells = <0>; + + /* RGB led */ + status_red: chan@0 { + chan-name = "red:status"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + reg = <0>; + color = ; + }; + + status_green: chan@1 { + chan-name = "green:status"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + reg = <1>; + color = ; + }; + + chan@2 { + chan-name = "blue:status"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + reg = <2>; + color = ; + }; + + chan@3 { + chan-name = "white:status"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + reg = <3>; + color = ; + }; + }; +}; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "sbl1"; + reg = <0x00000000 0x00100000>; + read-only; + }; + partition@100000 { + label = "mibib"; + reg = <0x00100000 0x00100000>; + read-only; + }; + partition@200000 { + label = "bootconfig"; + reg = <0x00200000 0x00100000>; + read-only; + }; + partition@300000 { + label = "qsee"; + reg = <0x00300000 0x00100000>; + read-only; + }; + partition@400000 { + label = "qsee_alt"; + reg = <0x00400000 0x00100000>; + read-only; + }; + partition@500000 { + label = "cdt"; + reg = <0x00500000 0x00080000>; + read-only; + }; + partition@580000 { + label = "cdt_alt"; + reg = <0x00580000 0x00080000>; + read-only; + }; + partition@600000 { + label = "ddrparams"; + reg = <0x00600000 0x00080000>; + read-only; + }; + partition@700000 { + label = "u-boot"; + reg = <0x00700000 0x00200000>; + read-only; + }; + partition@900000 { + label = "u-boot-backup"; + reg = <0x00900000 0x00200000>; + read-only; + }; + partition@b00000 { + label = "ART"; + reg = <0x00b00000 0x00080000>; + read-only; + }; + partition@c00000 { + label = "ubi"; + reg = <0x00c00000 0x07000000>; + /* + * Do not try to allocate the remaining + * 4 MiB to this ubi partition. It will + * confuse the u-boot and it might not + * find the kernel partition anymore. + */ + }; + }; + }; +}; + +&pcie0 { + status = "okay"; + perst-gpio = <&tlmm 38 GPIO_ACTIVE_LOW>; + wake-gpio = <&tlmm 50 GPIO_ACTIVE_LOW>; + + bridge@0,0 { + reg = <0x00000000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + wifi2: wifi@1,0 { + compatible = "qcom,ath10k"; + status = "okay"; + reg = <0x00010000 0 0 0 0>; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&tlmm { + /* + * GPIO43 should be 0/1 whenever the unit is + * powered through PoE or AC-Adapter. + * That said, playing with this seems to + * reset the AP. + */ + + mdio_pins: mdio_pinmux { + mux_1 { + pins = "gpio6"; + function = "mdio"; + bias-pull-up; + }; + mux_2 { + pins = "gpio7"; + function = "mdc"; + bias-pull-up; + }; + }; + + serial_0_pins: serial_pinmux { + mux { + pins = "gpio16", "gpio17"; + function = "blsp_uart0"; + bias-disable; + }; + }; + + serial_1_pins: serial1_pinmux { + mux { + /* We use the i2c-0 pins for serial_1 */ + pins = "gpio8", "gpio9"; + function = "blsp_uart1"; + bias-disable; + }; + }; + + i2c_0_pins: i2c_0_pinmux { + pinmux { + function = "blsp_i2c0"; + pins = "gpio20", "gpio21"; + }; + pinconf { + pins = "gpio20", "gpio21"; + drive-strength = <16>; + bias-disable; + }; + }; + + i2c_1_pins: i2c_1_pinmux { + pinmux { + function = "blsp_i2c1"; + pins = "gpio34", "gpio35"; + }; + pinconf { + pins = "gpio34", "gpio35"; + drive-strength = <16>; + bias-disable; + }; + }; + + nand_pins: nand_pins { + /* + * There are 18 pins. 15 pins are common between LCD and NAND. + * The QPIC controller arbitrates between LCD and NAND. Of the + * remaining 4, 2 are for NAND and 2 are for LCD exclusively. + * + * The meraki source hints that the bluetooth module claims + * pin 52 as well. But sadly, there's no data whenever this + * is a NAND or LCD exclusive pin or not. + */ + + pullups { + pins = "gpio52", "gpio53", "gpio58", + "gpio59"; + function = "qpic"; + bias-pull-up; + }; + + pulldowns { + pins = "gpio54", "gpio55", "gpio56", + "gpio57", "gpio60", "gpio61", + "gpio62", "gpio63", "gpio64", + "gpio65", "gpio66", "gpio67", + "gpio68", "gpio69"; + function = "qpic"; + bias-pull-down; + }; + }; +}; + +&wifi0 { + status = "okay"; + qcom,ath10k-calibration-variant = "Meraki-MR33"; +}; + +&wifi1 { + status = "okay"; + qcom,ath10k-calibration-variant = "Meraki-MR33"; +}; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr33.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr33.dts index 9f311b1973..8c8b1b3150 100644 --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr33.dts +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr33.dts @@ -1,411 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/* - * Device Tree Source for Meraki MR33 (Stinkbug) - * - * Copyright (C) 2017 Chris Blake - * Copyright (C) 2017 Christian Lamparter - * - * Based on Cisco Meraki DTS from GPL release r25-linux-3.14-20170427 - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without - * any warranty of any kind, whether express or implied. - */ +// Device Tree Source for Meraki MR33 (Stinkbug) -#include "qcom-ipq4019.dtsi" -#include -#include -#include -#include +#include "qcom-ipq4029-insect-common.dtsi" / { model = "Meraki MR33 Access Point"; compatible = "meraki,mr33"; - - aliases { - led-boot = &status_green; - led-failsafe = &status_red; - led-running = &status_green; - led-upgrade = &power_orange; - }; - - /* Do we really need this defined? */ - memory { - device_type = "memory"; - reg = <0x80000000 0x10000000>; - }; - - soc { - rng@22000 { - status = "okay"; - }; - - mdio@90000 { - status = "okay"; - pinctrl-0 = <&mdio_pins>; - pinctrl-names = "default"; - }; - - /* It is a 56-bit counter that supplies the count to the ARM arch - timers and without upstream driver */ - counter@4a1000 { - compatible = "qcom,qca-gcnt"; - reg = <0x4a1000 0x4>; - }; - - ess_tcsr@1953000 { - compatible = "qcom,tcsr"; - reg = <0x1953000 0x1000>; - qcom,ess-interface-select = ; - }; - - tcsr@1949000 { - compatible = "qcom,tcsr"; - reg = <0x1949000 0x100>; - qcom,wifi_glb_cfg = ; - }; - - tcsr@1957000 { - compatible = "qcom,tcsr"; - reg = <0x1957000 0x100>; - qcom,wifi_noc_memtype_m0_m2 = ; - }; - - serial@78b0000 { - pinctrl-0 = <&serial_1_pins>; - pinctrl-names = "default"; - status = "okay"; - - bluetooth { - compatible = "ti,cc2650"; - enable-gpios = <&tlmm 12 GPIO_ACTIVE_LOW>; - }; - }; - - crypto@8e3a000 { - status = "okay"; - }; - - watchdog@b017000 { - status = "okay"; - }; - - ess-switch@c000000 { - switch_mac_mode = <0x3>; /* mac mode for RGMII RMII */ - switch_lan_bmp = <0x0>; /* lan port bitmap */ - switch_wan_bmp = <0x10>; /* wan port bitmap */ - }; - - edma@c080000 { - qcom,single-phy; - qcom,num_gmac = <1>; - phy-mode = "rgmii-rxid"; - status = "okay"; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - - leds { - compatible = "gpio-leds"; - - power_orange: power { - label = "orange:power"; - gpios = <&tlmm 49 GPIO_ACTIVE_LOW>; - panic-indicator; - }; - }; }; -&blsp_dma { - status = "okay"; -}; - -&blsp1_uart1 { - pinctrl-0 = <&serial_0_pins>; - pinctrl-names = "default"; - status = "okay"; -}; - -&cryptobam { - status = "okay"; -}; - -&gmac0 { - qcom,phy_mdio_addr = <1>; - qcom,poll_required = <1>; - vlan_tag = <0 0x20>; -}; - -&blsp1_i2c3 { - pinctrl-0 = <&i2c_0_pins>; - pinctrl-names = "default"; - status = "okay"; - at24@50 { - compatible = "atmel,24c64"; - pagesize = <32>; - reg = <0x50>; - read-only; /* This holds our MAC & Meraki board-data */ - }; -}; - -&blsp1_i2c4 { - pinctrl-0 = <&i2c_1_pins>; - pinctrl-names = "default"; - status = "okay"; - - led-controller@30 { - compatible = "ti,lp5562"; - reg = <0x30>; - clock-mode = /bits/8 <2>; - enable-gpio = <&tlmm 48 GPIO_ACTIVE_HIGH>; - #address-cells = <1>; - #size-cells = <0>; - - /* RGB led */ - status_red: chan@0 { - chan-name = "red:status"; - led-cur = /bits/ 8 <0x20>; - max-cur = /bits/ 8 <0x60>; - reg = <0>; - color = ; - }; - - status_green: chan@1 { - chan-name = "green:status"; - led-cur = /bits/ 8 <0x20>; - max-cur = /bits/ 8 <0x60>; - reg = <1>; - color = ; - }; - - chan@2 { - chan-name = "blue:status"; - led-cur = /bits/ 8 <0x20>; - max-cur = /bits/ 8 <0x60>; - reg = <2>; - color = ; - }; - - chan@3 { - chan-name = "white:status"; - led-cur = /bits/ 8 <0x20>; - max-cur = /bits/ 8 <0x60>; - reg = <3>; - color = ; - }; - }; -}; - -&nand { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - status = "okay"; - - nand@0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "sbl1"; - reg = <0x00000000 0x00100000>; - read-only; - }; - partition@100000 { - label = "mibib"; - reg = <0x00100000 0x00100000>; - read-only; - }; - partition@200000 { - label = "bootconfig"; - reg = <0x00200000 0x00100000>; - read-only; - }; - partition@300000 { - label = "qsee"; - reg = <0x00300000 0x00100000>; - read-only; - }; - partition@400000 { - label = "qsee_alt"; - reg = <0x00400000 0x00100000>; - read-only; - }; - partition@500000 { - label = "cdt"; - reg = <0x00500000 0x00080000>; - read-only; - }; - partition@580000 { - label = "cdt_alt"; - reg = <0x00580000 0x00080000>; - read-only; - }; - partition@600000 { - label = "ddrparams"; - reg = <0x00600000 0x00080000>; - read-only; - }; - partition@700000 { - label = "u-boot"; - reg = <0x00700000 0x00200000>; - read-only; - }; - partition@900000 { - label = "u-boot-backup"; - reg = <0x00900000 0x00200000>; - read-only; - }; - partition@b00000 { - label = "ART"; - reg = <0x00b00000 0x00080000>; - read-only; - }; - partition@c00000 { - label = "ubi"; - reg = <0x00c00000 0x07000000>; - /* - * Do not try to allocate the remaining - * 4 MiB to this ubi partition. It will - * confuse the u-boot and it might not - * find the kernel partition anymore. - */ - }; - }; - }; -}; - -&pcie0 { - status = "okay"; - perst-gpio = <&tlmm 38 GPIO_ACTIVE_LOW>; - wake-gpio = <&tlmm 50 GPIO_ACTIVE_LOW>; - - bridge@0,0 { - reg = <0x00000000 0 0 0 0>; - #address-cells = <3>; - #size-cells = <2>; - ranges; - - wifi2: wifi@1,0 { - compatible = "qcom,ath10k"; - status = "okay"; - reg = <0x00010000 0 0 0 0>; - }; - }; -}; - -&qpic_bam { - status = "okay"; -}; - -&tlmm { - /* - * GPIO43 should be 0/1 whenever the unit is - * powered through PoE or AC-Adapter. - * That said, playing with this seems to - * reset the AP. - */ - - mdio_pins: mdio_pinmux { - mux_1 { - pins = "gpio6"; - function = "mdio"; - bias-pull-up; - }; - mux_2 { - pins = "gpio7"; - function = "mdc"; - bias-pull-up; - }; - }; - - serial_0_pins: serial_pinmux { - mux { - pins = "gpio16", "gpio17"; - function = "blsp_uart0"; - bias-disable; - }; - }; - - serial_1_pins: serial1_pinmux { - mux { - /* We use the i2c-0 pins for serial_1 */ - pins = "gpio8", "gpio9"; - function = "blsp_uart1"; - bias-disable; - }; - }; - - i2c_0_pins: i2c_0_pinmux { - pinmux { - function = "blsp_i2c0"; - pins = "gpio20", "gpio21"; - }; - pinconf { - pins = "gpio20", "gpio21"; - drive-strength = <16>; - bias-disable; - }; - }; - - i2c_1_pins: i2c_1_pinmux { - pinmux { - function = "blsp_i2c1"; - pins = "gpio34", "gpio35"; - }; - pinconf { - pins = "gpio34", "gpio35"; - drive-strength = <16>; - bias-disable; - }; - }; - - nand_pins: nand_pins { - /* - * There are 18 pins. 15 pins are common between LCD and NAND. - * The QPIC controller arbitrates between LCD and NAND. Of the - * remaining 4, 2 are for NAND and 2 are for LCD exclusively. - * - * The meraki source hints that the bluetooth module claims - * pin 52 as well. But sadly, there's no data whenever this - * is a NAND or LCD exclusive pin or not. - */ - - pullups { - pins = "gpio52", "gpio53", "gpio58", - "gpio59"; - function = "qpic"; - bias-pull-up; - }; - - pulldowns { - pins = "gpio54", "gpio55", "gpio56", - "gpio57", "gpio60", "gpio61", - "gpio62", "gpio63", "gpio64", - "gpio65", "gpio66", "gpio67", - "gpio68", "gpio69"; - function = "qpic"; - bias-pull-down; - }; - }; -}; - -&wifi0 { - status = "okay"; - qcom,ath10k-calibration-variant = "Meraki-MR33"; -}; - -&wifi1 { - status = "okay"; - qcom,ath10k-calibration-variant = "Meraki-MR33"; +&tricolor { + enable-gpio = <&tlmm 48 GPIO_ACTIVE_HIGH>; }; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr74.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr74.dts new file mode 100644 index 0000000000..904f724652 --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-mr74.dts @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Device Tree Source for Meraki MR74 (Ladybug) + +#include "qcom-ipq4029-insect-common.dtsi" + +/ { + model = "Meraki MR74 Access Point"; + compatible = "meraki,mr74"; +}; + +&tricolor { + enable-gpio = <&tlmm 14 GPIO_ACTIVE_LOW>; +}; diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index 0ddff52ef8..26d9082638 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -704,6 +704,18 @@ define Device/meraki_mr33 endef TARGET_DEVICES += meraki_mr33 +define Device/meraki_mr74 + $(call Device/FitImage) + DEVICE_VENDOR := Cisco Meraki + DEVICE_MODEL := MR74 + SOC := qcom-ipq4029 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_PACKAGES := -swconfig ath10k-firmware-qca9887-ct + DEVICE_DTS_CONFIG := config@3 +endef +TARGET_DEVICES += meraki_mr74 + define Device/mobipromo_cm520-79f $(call Device/FitzImage) $(call Device/UbiFit) diff --git a/target/linux/generic/pending-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch b/target/linux/ipq40xx/patches-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch similarity index 84% rename from target/linux/generic/pending-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch rename to target/linux/ipq40xx/patches-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch index bafdaccd25..91919b2894 100644 --- a/target/linux/generic/pending-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch +++ b/target/linux/ipq40xx/patches-5.10/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch @@ -13,19 +13,16 @@ has 128 bytes OOB. This adds a static NAND ID entry to correct this. Tested on FRITZ!Box 7530 flashed with OpenWrt. Signed-off-by: Andreas Böhler -(changed id_len to 8) +(changed id_len to 8, added comment about possible counterfeits) --- - drivers/mtd/nand/raw/nand_ids.c | 3 +++ - 1 file changed, 3 insertions(+) - --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -29,6 +29,9 @@ struct nand_flash_dev nand_flash_ids[] = {"TC58NVG0S3E 1G 3.3V 8-bit", { .id = {0x98, 0xd1, 0x90, 0x15, 0x76, 0x14, 0x01, 0x00} }, SZ_2K, SZ_128, SZ_128K, 0, 8, 64, NAND_ECC_INFO(1, SZ_512), }, -+ {"TC58NVG0S3HTA00 1G 3.3V 8-bit", -+ { .id = {0x98, 0xf1, 0x80, 0x15} }, ++ {"TC58NVG0S3HTA00 1G 3.3V 8-bit", /* possibly counterfeit chip - see commit */ ++ { .id = {0x98, 0xf1, 0x80, 0x15} }, /* should be more bytes */ + SZ_2K, SZ_128, SZ_128K, 0, 8, 128, NAND_ECC_INFO(8, SZ_512), }, {"TC58NVG2S0F 4G 3.3V 8-bit", { .id = {0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08} }, diff --git a/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch index 99ea2e423e..70e8c9d27f 100644 --- a/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -903,11 +903,77 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -903,11 +903,78 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -85,6 +85,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-gl-b2200.dtb \ + qcom-ipq4029-gl-s1300.dtb \ + qcom-ipq4029-mr33.dtb \ ++ qcom-ipq4029-mr74.dtb \ qcom-ipq8064-ap148.dtb \ qcom-ipq8064-rb3011.dtb \ qcom-msm8660-surf.dtb \ diff --git a/target/linux/generic/pending-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch b/target/linux/ipq40xx/patches-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch similarity index 84% rename from target/linux/generic/pending-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch rename to target/linux/ipq40xx/patches-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch index bafdaccd25..91919b2894 100644 --- a/target/linux/generic/pending-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch +++ b/target/linux/ipq40xx/patches-5.15/444-mtd-nand-rawnand-add-support-for-Toshiba-TC58NVG0S3H.patch @@ -13,19 +13,16 @@ has 128 bytes OOB. This adds a static NAND ID entry to correct this. Tested on FRITZ!Box 7530 flashed with OpenWrt. Signed-off-by: Andreas Böhler -(changed id_len to 8) +(changed id_len to 8, added comment about possible counterfeits) --- - drivers/mtd/nand/raw/nand_ids.c | 3 +++ - 1 file changed, 3 insertions(+) - --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -29,6 +29,9 @@ struct nand_flash_dev nand_flash_ids[] = {"TC58NVG0S3E 1G 3.3V 8-bit", { .id = {0x98, 0xd1, 0x90, 0x15, 0x76, 0x14, 0x01, 0x00} }, SZ_2K, SZ_128, SZ_128K, 0, 8, 64, NAND_ECC_INFO(1, SZ_512), }, -+ {"TC58NVG0S3HTA00 1G 3.3V 8-bit", -+ { .id = {0x98, 0xf1, 0x80, 0x15} }, ++ {"TC58NVG0S3HTA00 1G 3.3V 8-bit", /* possibly counterfeit chip - see commit */ ++ { .id = {0x98, 0xf1, 0x80, 0x15} }, /* should be more bytes */ + SZ_2K, SZ_128, SZ_128K, 0, 8, 128, NAND_ECC_INFO(8, SZ_512), }, {"TC58NVG2S0F 4G 3.3V 8-bit", { .id = {0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08} }, diff --git a/target/linux/ipq40xx/patches-5.15/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.15/901-arm-boot-add-dts-files.patch index f9b3c513bb..19d6b4bb34 100644 --- a/target/linux/ipq40xx/patches-5.15/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.15/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -951,11 +951,76 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -951,11 +951,77 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-ipq4018-ap120c-ac.dtb \ qcom-ipq4018-ap120c-ac-bit.dtb \ qcom-ipq4018-jalapeno.dtb \ @@ -84,6 +84,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-gl-b2200.dtb \ + qcom-ipq4029-gl-s1300.dtb \ + qcom-ipq4029-mr33.dtb \ ++ qcom-ipq4029-mr74.dtb \ qcom-ipq8064-ap148.dtb \ qcom-ipq8064-rb3011.dtb \ qcom-msm8226-samsung-s3ve3g.dtb \ diff --git a/target/linux/ipq806x/patches-5.10/101-5.12-mtd-parsers-Add-Qcom-SMEM-parser.patch b/target/linux/ipq806x/patches-5.10/101-5.12-mtd-parsers-Add-Qcom-SMEM-parser.patch index a78dc82a47..8079c19350 100644 --- a/target/linux/ipq806x/patches-5.10/101-5.12-mtd-parsers-Add-Qcom-SMEM-parser.patch +++ b/target/linux/ipq806x/patches-5.10/101-5.12-mtd-parsers-Add-Qcom-SMEM-parser.patch @@ -19,9 +19,9 @@ Link: https://lore.kernel.org/linux-mtd/20210104041137.113075-3-manivannan.sadha --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig -@@ -196,6 +196,14 @@ config MTD_REDBOOT_PARTS_READONLY - - endif # MTD_REDBOOT_PARTS +@@ -205,6 +205,14 @@ config MTD_SERCOMM_PARTS + offsets, which may differ from device to device depending on the + number and location of bad blocks on NAND. +config MTD_QCOMSMEM_PARTS + tristate "Qualcomm SMEM NAND flash partition parser" @@ -36,8 +36,8 @@ Link: https://lore.kernel.org/linux-mtd/20210104041137.113075-3-manivannan.sadha depends on MTD && OF --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile -@@ -13,4 +13,5 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o - obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o +@@ -14,4 +14,5 @@ obj-$(CONFIG_MTD_PARSER_TRX) += parser_ + obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o +obj-$(CONFIG_MTD_QCOMSMEM_PARTS) += qcomsmempart.o diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9.dtsi index 61283f5621..98aca38fe2 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9.dtsi @@ -415,6 +415,8 @@ req-mask = <0x1>; device_type = "pci"; + + resets = <&reset0 13 13>; }; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube.dtsi index a18183a2de..9d9946fbb5 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube.dtsi @@ -328,6 +328,8 @@ req-mask = <0x1>; /* GNT1 */ device_type = "pci"; + + resets = <&reset0 13 13>; }; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi index 27858be28f..1089cdc80c 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi @@ -555,6 +555,8 @@ req-mask = <0x1>; /* GNT1 */ device_type = "pci"; + + resets = <&reset0 13 13>; }; }; diff --git a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi index 0827f18e48..4231cc1f79 100644 --- a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi +++ b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi @@ -203,6 +203,12 @@ }; }; +&rtc { + status = "disabled"; + + /* No RTC battery */ +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pins>; diff --git a/target/linux/mediatek/patches-5.15/510-net-mediatek-add-flow-offload-for-mt7623.patch b/target/linux/mediatek/patches-5.15/510-net-mediatek-add-flow-offload-for-mt7623.patch index 8c506e41cc..deb25e652d 100644 --- a/target/linux/mediatek/patches-5.15/510-net-mediatek-add-flow-offload-for-mt7623.patch +++ b/target/linux/mediatek/patches-5.15/510-net-mediatek-add-flow-offload-for-mt7623.patch @@ -14,11 +14,11 @@ Signed-off-by: Frank Wunderlich --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3364,6 +3364,7 @@ static const struct mtk_soc_data mt2701_ +@@ -3675,6 +3675,7 @@ static const struct mtk_soc_data mt2701_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, + .offload_version = 2, - }; - - static const struct mtk_soc_data mt7621_data = { + .txrx = { + .txd_size = sizeof(struct mtk_tx_dma), + .rxd_size = sizeof(struct mtk_rx_dma), diff --git a/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch b/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch index 289398ce3a..45c650b34a 100644 --- a/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch +++ b/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch @@ -20,7 +20,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -106,13 +106,35 @@ static int _mtk_mdio_write(struct mtk_et +@@ -196,13 +196,35 @@ static int _mtk_mdio_write(struct mtk_et if (ret < 0) return ret; @@ -63,7 +63,7 @@ Signed-off-by: David S. Miller ret = mtk_mdio_busy_wait(eth); if (ret < 0) -@@ -129,12 +151,33 @@ static int _mtk_mdio_read(struct mtk_eth +@@ -219,12 +241,33 @@ static int _mtk_mdio_read(struct mtk_eth if (ret < 0) return ret; @@ -103,7 +103,7 @@ Signed-off-by: David S. Miller ret = mtk_mdio_busy_wait(eth); if (ret < 0) -@@ -593,6 +636,7 @@ static int mtk_mdio_init(struct mtk_eth +@@ -683,6 +726,7 @@ static int mtk_mdio_init(struct mtk_eth eth->mii_bus->name = "mdio"; eth->mii_bus->read = mtk_mdio_read; eth->mii_bus->write = mtk_mdio_write; @@ -113,7 +113,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h -@@ -349,9 +349,12 @@ +@@ -322,9 +322,12 @@ #define PHY_IAC_ADDR_MASK GENMASK(24, 20) #define PHY_IAC_ADDR(x) FIELD_PREP(PHY_IAC_ADDR_MASK, (x)) #define PHY_IAC_CMD_MASK GENMASK(19, 18) diff --git a/target/linux/mediatek/patches-5.15/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch b/target/linux/mediatek/patches-5.15/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch index e9d4188a45..a7878ecb1b 100644 --- a/target/linux/mediatek/patches-5.15/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch +++ b/target/linux/mediatek/patches-5.15/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch @@ -1,6 +1,6 @@ --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -577,6 +577,7 @@ static void mtk_validate(struct phylink_ +@@ -667,6 +667,7 @@ static void mtk_validate(struct phylink_ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) { phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); diff --git a/target/linux/mpc85xx/Makefile b/target/linux/mpc85xx/Makefile index 6bf096740e..398e578882 100644 --- a/target/linux/mpc85xx/Makefile +++ b/target/linux/mpc85xx/Makefile @@ -8,7 +8,7 @@ ARCH:=powerpc BOARD:=mpc85xx BOARDNAME:=Freescale MPC85xx CPU_TYPE:=8540 -FEATURES:=squashfs ramdisk +FEATURES:=squashfs ramdisk nand SUBTARGETS:=p1010 p1020 p2020 KERNEL_PATCHVER:=5.10 diff --git a/target/linux/mpc85xx/p1010/target.mk b/target/linux/mpc85xx/p1010/target.mk index 12ed78ace1..019536ff1a 100644 --- a/target/linux/mpc85xx/p1010/target.mk +++ b/target/linux/mpc85xx/p1010/target.mk @@ -1,5 +1,4 @@ BOARDNAME:=P1010 -FEATURES+=nand KERNELNAME:=simpleImage.tl-wdr4900-v1 define Target/Description diff --git a/target/linux/mpc85xx/p1020/target.mk b/target/linux/mpc85xx/p1020/target.mk index a25409eebb..000fc64644 100644 --- a/target/linux/mpc85xx/p1020/target.mk +++ b/target/linux/mpc85xx/p1020/target.mk @@ -1,5 +1,4 @@ BOARDNAME:=P1020 -FEATURES+=nand define Target/Description Build firmware images for Freescale P1020 based boards. diff --git a/target/linux/mpc85xx/p2020/config-default b/target/linux/mpc85xx/p2020/config-default index de7f09e1f3..e4ed758d95 100644 --- a/target/linux/mpc85xx/p2020/config-default +++ b/target/linux/mpc85xx/p2020/config-default @@ -21,6 +21,7 @@ CONFIG_PCI_MSI=y CONFIG_PPC_MSI_BITMAP=y CONFIG_RFS_ACCEL=y CONFIG_RPS=y +CONFIG_RTC_DRV_DS1307=y CONFIG_RWSEM_SPIN_ON_OWNER=y CONFIG_SMP=y CONFIG_TREE_RCU=y diff --git a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network index f3c59bf2ad..6a5861084e 100644 --- a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network +++ b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network @@ -29,6 +29,9 @@ marvell,armada8040-db) marvell,armada7040-db) ucidef_set_interfaces_lan_wan "eth0 eth2" "eth1" ;; +marvell,armada8040-clearfog-gt-8k) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 eth2" "eth0 eth1" + ;; *) ucidef_set_interface_lan "eth0" ;; diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh index 18fdb01959..dc964a3117 100755 --- a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh +++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh @@ -13,7 +13,8 @@ platform_check_image() { iei,puzzle-m901|\ iei,puzzle-m902|\ marvell,armada8040-mcbin-doubleshot|\ - marvell,armada8040-mcbin-singleshot) + marvell,armada8040-mcbin-singleshot|\ + marvell,armada8040-clearfog-gt-8k) legacy_sdcard_check_image "$1" ;; *) @@ -30,7 +31,8 @@ platform_do_upgrade() { ;; globalscale,mochabin|\ marvell,armada8040-mcbin-doubleshot|\ - marvell,armada8040-mcbin-singleshot) + marvell,armada8040-mcbin-singleshot|\ + marvell,armada8040-clearfog-gt-8k) legacy_sdcard_do_upgrade "$1" ;; *) @@ -44,7 +46,8 @@ platform_copy_config() { iei,puzzle-m901|\ iei,puzzle-m902|\ marvell,armada8040-mcbin-doubleshot|\ - marvell,armada8040-mcbin-singleshot) + marvell,armada8040-mcbin-singleshot|\ + marvell,armada8040-clearfog-gt-8k) legacy_sdcard_copy_config ;; esac diff --git a/target/linux/mvebu/image/cortexa72.mk b/target/linux/mvebu/image/cortexa72.mk index f95ce533ea..84ce0cda9a 100644 --- a/target/linux/mvebu/image/cortexa72.mk +++ b/target/linux/mvebu/image/cortexa72.mk @@ -52,6 +52,17 @@ define Device/marvell_macchiatobin-singleshot endef TARGET_DEVICES += marvell_macchiatobin-singleshot +define Device/marvell_clearfog-gt-8k + $(call Device/Default-arm64) + DEVICE_VENDOR := SolidRun + DEVICE_MODEL := Clearfog + DEVICE_VARIANT := GT-8K + DEVICE_PACKAGES += kmod-i2c-mux-pca954x kmod-crypto-hw-safexcel + DEVICE_DTS := armada-8040-clearfog-gt-8k + SUPPORTED_DEVICES := marvell,armada8040-clearfog-gt-8k +endef +TARGET_DEVICES += marvell_clearfog-gt-8k + define Device/iei_puzzle-m901 $(call Device/Default-arm64) DEVICE_VENDOR := iEi diff --git a/target/linux/qoriq/image/Makefile b/target/linux/qoriq/image/Makefile index a3c8dd38c2..ec46e4d543 100644 --- a/target/linux/qoriq/image/Makefile +++ b/target/linux/qoriq/image/Makefile @@ -8,7 +8,7 @@ SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS) define Build/sdcard-img rm -fR $@.boot mkdir -p $@.boot - $(CP) $(KDIR)/$(DEVICE_NAME)-kernel.bin $@.boot + $(CP) $(KDIR)/$(DEVICE_NAME)$(KERNEL_SUFFIX) $@.boot $(if $(DEVICE_DTS),\ $(foreach dtb,$(DEVICE_DTS),$(CP) $(KDIR)/image-$(dtb).dtb $@.boot), \ $(CP) $(KDIR)/image-/*.dtb $@.boot) diff --git a/target/linux/qoriq/image/generic.mk b/target/linux/qoriq/image/generic.mk index 0d7f5e4c10..b8ffc69ba0 100644 --- a/target/linux/qoriq/image/generic.mk +++ b/target/linux/qoriq/image/generic.mk @@ -1,10 +1,14 @@ define Device/watchguard_firebox-m300 DEVICE_VENDOR := WatchGuard DEVICE_MODEL := Firebox M300 + DEVICE_COMPAT_MESSAGE := \ + Kernel switched to FIT uImage. Update U-Boot environment. + DEVICE_COMPAT_VERSION := 1.1 DEVICE_DTS_DIR := $(DTS_DIR)/fsl DEVICE_PACKAGES := \ kmod-hwmon-w83793 kmod-ptp-qoriq kmod-rtc-rs5c372a kmod-tpm-i2c-atmel - KERNEL := kernel-bin | gzip | uImage gzip + KERNEL := kernel-bin | gzip | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + KERNEL_SUFFIX := -fit-uImage.itb IMAGES := sdcard.img.gz sysupgrade.img.gz IMAGE/sysupgrade.img.gz := sdcard-img | gzip | append-metadata IMAGE/sdcard.img.gz := sdcard-img | gzip diff --git a/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts b/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts index 2c6b3f53e6..60ab3e1646 100644 --- a/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts +++ b/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts @@ -37,7 +37,7 @@ wps { label = "wps"; - gpios = <&gpio 43 GPIO_ACTIVE_HIGH>; + gpios = <&gpio 43 GPIO_ACTIVE_LOW>; linux,code = ; debounce-interval = <60>; }; diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts index b701e88d1a..e149834d44 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts @@ -2,7 +2,34 @@ #include "rtl8380_netgear_gigabit_1xx.dtsi" +#include + / { compatible = "netgear,gs108t-v3", "realtek,rtl838x-soc"; model = "Netgear GS108T v3"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_amber; + led-running = &led_power_green; + led-upgrade = &led_power_amber; + }; + + leds { + compatible = "gpio-leds"; + + led_power_amber: led-0 { + label = "amber:power"; + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio1 32 GPIO_ACTIVE_LOW>; + }; + + led_power_green: led-1 { + label = "green:power"; + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio1 31 GPIO_ACTIVE_LOW>; + }; + }; }; diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs308t-v1.dts b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs308t-v1.dts index 016ed8beb6..cd69e80186 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs308t-v1.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs308t-v1.dts @@ -2,7 +2,34 @@ #include "rtl8380_netgear_gigabit_3xx.dtsi" +#include + / { compatible = "netgear,gs308t-v1", "realtek,rtl838x-soc"; model = "Netgear GS308T v1"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_amber; + led-running = &led_power_green; + led-upgrade = &led_power_amber; + }; + + leds { + compatible = "gpio-leds"; + + led_power_amber: led-0 { + label = "amber:power"; + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio1 32 GPIO_ACTIVE_LOW>; + }; + + led_power_green: led-1 { + label = "green:power"; + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio1 31 GPIO_ACTIVE_LOW>; + }; + }; }; diff --git a/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-20.dts b/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-20.dts new file mode 100644 index 0000000000..cd495bc343 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-20.dts @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl8382_d-link_dgs-1210.dtsi" + +/ { + compatible = "d-link,dgs-1210-20", "realtek,rtl838x-soc"; + model = "D-Link DGS-1210-20"; + + gpio-restart { + compatible = "gpio-restart"; + gpios = <&gpio1 34 GPIO_ACTIVE_LOW>; + open-source; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <20>; + + reset { + label = "reset"; + gpios = <&gpio1 33 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + gpio1: rtl8231-gpio { + compatible = "realtek,rtl8231-gpio"; + #gpio-cells = <2>; + gpio-controller; + indirect-access-bus-id = <0>; + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + regmap = <ðernet0>; + #address-cells = <1>; + #size-cells = <0>; + + EXTERNAL_PHY(0) + EXTERNAL_PHY(1) + EXTERNAL_PHY(2) + EXTERNAL_PHY(3) + EXTERNAL_PHY(4) + EXTERNAL_PHY(5) + EXTERNAL_PHY(6) + EXTERNAL_PHY(7) + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + + EXTERNAL_SFP_PHY(24) + EXTERNAL_SFP_PHY(25) + EXTERNAL_SFP_PHY(26) + EXTERNAL_SFP_PHY(27) + }; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(0, 1, qsgmii) + SWITCH_PORT(1, 2, qsgmii) + SWITCH_PORT(2, 3, qsgmii) + SWITCH_PORT(3, 4, qsgmii) + SWITCH_PORT(4, 5, qsgmii) + SWITCH_PORT(5, 6, qsgmii) + SWITCH_PORT(6, 7, qsgmii) + SWITCH_PORT(7, 8, qsgmii) + + SWITCH_PORT(8, 9, internal) + SWITCH_PORT(9, 10, internal) + SWITCH_PORT(10, 11, internal) + SWITCH_PORT(11, 12, internal) + SWITCH_PORT(12, 13, internal) + SWITCH_PORT(13, 14, internal) + SWITCH_PORT(14, 15, internal) + SWITCH_PORT(15, 16, internal) + + SWITCH_PORT(24, 17, qsgmii) + SWITCH_PORT(25, 18, qsgmii) + SWITCH_PORT(26, 19, qsgmii) + SWITCH_PORT(27, 20, qsgmii) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 289e37db16..df145cfb69 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -30,6 +30,12 @@ define Device/d-link_dgs-1210-16 endef TARGET_DEVICES += d-link_dgs-1210-16 +define Device/d-link_dgs-1210-20 + $(Device/d-link_dgs-1210) + DEVICE_MODEL := DGS-1210-20 +endef +TARGET_DEVICES += d-link_dgs-1210-20 + define Device/d-link_dgs-1210-28 $(Device/d-link_dgs-1210) DEVICE_MODEL := DGS-1210-28 diff --git a/target/linux/rockchip/patches-5.15/005-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch b/target/linux/rockchip/patches-5.15/005-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch new file mode 100644 index 0000000000..792028b292 --- /dev/null +++ b/target/linux/rockchip/patches-5.15/005-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch @@ -0,0 +1,31 @@ +From af20b3384e8723077cc6484160b0cf4e9be321de Mon Sep 17 00:00:00 2001 +From: Tianling Shen +Date: Mon, 7 Jun 2021 15:45:37 +0800 +Subject: [PATCH] arm64: dts: rockchip: add EEPROM node for NanoPi R4S + +NanoPi R4S has a EEPROM attached to the 2nd I2C bus (U92), which +stores the MAC address. + +Signed-off-by: Tianling Shen +--- + arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts +@@ -68,6 +68,15 @@ + status = "disabled"; + }; + ++&i2c2 { ++ eeprom@51 { ++ compatible = "microchip,24c02", "atmel,24c02"; ++ reg = <0x51>; ++ pagesize = <16>; ++ read-only; /* This holds our MAC */ ++ }; ++}; ++ + &i2c4 { + status = "disabled"; + }; diff --git a/tools/libressl/Makefile b/tools/libressl/Makefile index da7cd6201b..0679961d17 100644 --- a/tools/libressl/Makefile +++ b/tools/libressl/Makefile @@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libressl -PKG_VERSION:=3.4.2 -PKG_HASH:=cb82ca7d547336917352fbd23db2fc483c6c44d35157b32780214ec74197b3ce +PKG_VERSION:=3.4.3 +PKG_HASH:=ff88bffe354818b3ccf545e3cafe454c5031c7a77217074f533271d63c37f08d PKG_RELEASE:=1 PKG_CPE_ID:=cpe:/a:openbsd:libressl