From 303b463394c151aa3962f9e837c0da54b1340a73 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Thu, 4 Jun 2020 13:35:33 +0200 Subject: [PATCH 1/8] netifd: update to latest HEAD db275e1 interface-ip: fix build on non-linux systems 3392046 system-dummy: fix missing return a56b457 netifd: wireless: add support for tracking wifi-station sections 4ce33ce netifd: wireless: add support for tracking wifi-vlan sections Signed-off-by: John Crispin --- package/network/config/netifd/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile index 9937cdf822..7b2e6a0afd 100644 --- a/package/network/config/netifd/Makefile +++ b/package/network/config/netifd/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=netifd -PKG_RELEASE:=3 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2020-05-17 -PKG_SOURCE_VERSION:=74e0222eeb9e62f4d5073a5b3d9208678782a198 -PKG_MIRROR_HASH:=5caa2472ab569d5bd908850c4089366c53c3309ea43cc0ea81b7ec60f912b721 +PKG_SOURCE_DATE:=2020-06-04 +PKG_SOURCE_VERSION:=db275e12bfc7849c220a173c68403ae41cb251b7 +PKG_MIRROR_HASH:=959427b7b6eae52e788c15306d3f929ca6e445b745e60cbaf093db2733f27d8d PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 From 5aa2ddd0d6b9759c62bbb7bb11b72a7f4269c16b Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 25 May 2020 11:39:40 +0200 Subject: [PATCH 2/8] hostapd: add support for wifi-station and wifi-vlan sections This patch adds support for 2 new uci sections. config wifi-vlan # iface is optional. if it is not defined the vlan will apply # to all interfaces option iface default_radio0 option name guest option vid 100 option network guest config wifi-station # iface is optional. if it is not defined the station will apply # to all interfaces option iface default_radio0 # mac is optional. if it is not defined it will be a catch all # for any sta using this key option mac '00:11:22:33:44:55' # vid is optional. if it is not defined, the sta will be part of # the primary iface. option vid 100 option key testtest With this patch applied it is possible to use multiple PSKs on a single BSS. Signed-off-by: John Crispin --- .../files/lib/netifd/wireless/mac80211.sh | 8 +++- .../network/services/hostapd/files/hostapd.sh | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh index be637379e3..4171af2f60 100644 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -506,7 +506,7 @@ mac80211_iw_interface_add() { mac80211_prepare_vif() { json_select config - json_get_vars ifname mode ssid wds powersave macaddr enable + json_get_vars ifname mode ssid wds powersave macaddr enable wpa_psk_file vlan_file [ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}" if_idx=$((${if_idx:-0} + 1)) @@ -524,6 +524,12 @@ mac80211_prepare_vif() { json_add_object data json_add_string ifname "$ifname" json_close_object + + [ "$mode" == "ap" ] && { + [ -z "$wpa_psk_file" ] && hostapd_set_psk "$ifname" + [ -z "$vlan_file" ] && hostapd_set_vlan "$ifname" + } + json_select config # It is far easier to delete and create the desired interface diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index 09de3994b8..f04d8229a7 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -262,6 +262,39 @@ hostapd_common_add_bss_config() { config_add_string 'owe_transition_bssid:macaddr' 'owe_transition_ssid:string' } +hostapd_set_vlan_file() { + local ifname="$1" + local vlan="$2" + json_get_vars name vid + echo "${vid} ${ifname}-${name}" >> /var/run/hostapd-${ifname}.vlan + wireless_add_vlan "${vlan}" "${ifname}-${name}" +} + +hostapd_set_vlan() { + local ifname="$1" + + rm /var/run/hostapd-${ifname}.vlan + for_each_vlan hostapd_set_vlan_file ${ifname} +} + +hostapd_set_psk_file() { + local ifname="$1" + local vlan="$2" + local vlan_id="" + + json_get_vars mac vid key + set_default isolate "00:00:00:00:00:00" + [ -n "$vid" ] && vlan_id="vlanid=$vid " + echo "${vlan_id} ${mac} ${key}" >> /var/run/hostapd-${ifname}.psk +} + +hostapd_set_psk() { + local ifname="$1" + + rm /var/run/hostapd-${ifname}.psk + for_each_station hostapd_set_psk_file ${ifname} +} + hostapd_set_bss_options() { local var="$1" local phy="$2" @@ -377,12 +410,15 @@ hostapd_set_bss_options() { else append bss_conf "wpa_passphrase=$key" "$N" fi + [ -z "$wpa_psk_file" ] && set_default wpa_psk_file /var/run/hostapd-$ifname.psk [ -n "$wpa_psk_file" ] && { [ -e "$wpa_psk_file" ] || touch "$wpa_psk_file" append bss_conf "wpa_psk_file=$wpa_psk_file" "$N" } [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N" + set_default dynamic_vlan 0 + vlan_possible=1 wps_possible=1 ;; eap|eap192|eap-eap192) @@ -639,6 +675,7 @@ hostapd_set_bss_options() { [ -n "$vlan_possible" -a -n "$dynamic_vlan" ] && { json_get_vars vlan_naming vlan_tagged_interface vlan_bridge vlan_file set_default vlan_naming 1 + [ -z "$vlan_file" ] && set_default vlan_file /var/run/hostapd-$ifname.vlan append bss_conf "dynamic_vlan=$dynamic_vlan" "$N" append bss_conf "vlan_naming=$vlan_naming" "$N" [ -n "$vlan_bridge" ] && \ From 2dd26fda16a4574c91d02f4b1ccb2ce121e764c8 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 12 May 2020 15:23:01 +0200 Subject: [PATCH 3/8] kernel: fix portability issue with perf on linux 5.4 Remove dependencies on core kernel headers in host tools used to build perf, which break on any non-linux system Signed-off-by: Felix Fietkau --- package/devel/perf/Makefile | 3 ++ ...lity.patch => 212-tools_portability.patch} | 51 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) rename target/linux/generic/hack-5.4/{212-byteshift_portability.patch => 212-tools_portability.patch} (56%) diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile index aa478a0431..3bb403916b 100644 --- a/package/devel/perf/Makefile +++ b/package/devel/perf/Makefile @@ -36,6 +36,8 @@ define Package/perf/description perf is the Linux performance monitoring tool endef +HOST_CFLAGS += -I$(LINUX_DIR)/tools/include + MAKE_FLAGS = \ ARCH="$(LINUX_KARCH)" \ NO_LIBPERL=1 \ @@ -54,6 +56,7 @@ MAKE_FLAGS = \ LD="$(TARGET_CROSS)ld" \ CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ LDFLAGS="$(TARGET_LDFLAGS)" \ + KBUILD_HOSTCFLAGS="$(HOST_CFLAGS)" \ $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ WERROR=0 \ O=$(PKG_BUILD_DIR) \ diff --git a/target/linux/generic/hack-5.4/212-byteshift_portability.patch b/target/linux/generic/hack-5.4/212-tools_portability.patch similarity index 56% rename from target/linux/generic/hack-5.4/212-byteshift_portability.patch rename to target/linux/generic/hack-5.4/212-tools_portability.patch index 1a5ac87988..0d8eb6fb9d 100644 --- a/target/linux/generic/hack-5.4/212-byteshift_portability.patch +++ b/target/linux/generic/hack-5.4/212-tools_portability.patch @@ -1,9 +1,8 @@ From 48232d3d931c95953ce2ddfe7da7bb164aef6a73 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 7 Jul 2017 17:03:16 +0200 -Subject: linux-3.6: fix portability of some includes files in tools/ used on the host +Subject: fix portability of some includes files in tools/ used on the host -lede-commit: 6040b1d29ab1f047c5e49b748abcb6a3196add28 Signed-off-by: Felix Fietkau --- tools/include/tools/be_byteshift.h | 4 ++++ @@ -40,26 +39,72 @@ Signed-off-by: Felix Fietkau static inline uint16_t __get_unaligned_le16(const uint8_t *p) --- /dev/null +++ b/tools/include/tools/linux_types.h -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +#ifndef __LINUX_TYPES_H +#define __LINUX_TYPES_H + +#include + ++typedef int8_t __s8; +typedef uint8_t __u8; +typedef uint8_t __be8; +typedef uint8_t __le8; + ++typedef int16_t __s16; +typedef uint16_t __u16; +typedef uint16_t __be16; +typedef uint16_t __le16; + ++typedef int32_t __s32; +typedef uint32_t __u32; +typedef uint32_t __be32; +typedef uint32_t __le32; + ++typedef int64_t __s64; +typedef uint64_t __u64; +typedef uint64_t __be64; +typedef uint64_t __le64; + +#endif +--- a/tools/include/linux/types.h ++++ b/tools/include/linux/types.h +@@ -7,8 +7,12 @@ + #include + + #define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */ ++#ifndef __linux__ ++#include ++#else + #include + #include ++#endif + + struct page; + struct kmem_cache; +--- a/tools/perf/pmu-events/jevents.c ++++ b/tools/perf/pmu-events/jevents.c +@@ -1,4 +1,6 @@ ++#ifdef __linux__ + #define _XOPEN_SOURCE 500 /* needed for nftw() */ ++#endif + #define _GNU_SOURCE /* needed for asprintf() */ + + /* Parse event JSON files */ +@@ -35,6 +37,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- a/tools/perf/pmu-events/json.c ++++ b/tools/perf/pmu-events/json.c +@@ -38,7 +38,6 @@ + #include + #include "jsmn.h" + #include "json.h" +-#include + + + static char *mapfile(const char *fn, size_t *size) From 81b59efefd4c88187a519d09129c97e63900731e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 3 Jun 2020 18:55:55 +0200 Subject: [PATCH 4/8] ramips/mediatek: select kmod-mt7615-firmware where kmod-mt7615e is selected The new mt76 version splits out the firmware, because the driver can also be used for MT7663/MT7613 Signed-off-by: Felix Fietkau --- target/linux/mediatek/image/mt7622.mk | 3 +- target/linux/mediatek/mt7622/target.mk | 2 +- target/linux/ramips/image/mt7621.mk | 52 +++++++++++++------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk index a386bf1ee2..b570ce9d82 100644 --- a/target/linux/mediatek/image/mt7622.mk +++ b/target/linux/mediatek/image/mt7622.mk @@ -25,7 +25,8 @@ define Device/elecom-wrc-2533gent DEVICE_DTS := mt7622-elecom-wrc-2533gent DEVICE_DTS_DIR := $(DTS_DIR)/mediatek DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 \ - kmod-mt7615e mt7622bt-firmware swconfig + kmod-mt7615e kmod-mt7615-firmware \ + mt7622bt-firmware swconfig SUPPORTED_DEVICES := elecom,wrc-2533gent endef TARGET_DEVICES += elecom-wrc-2533gent diff --git a/target/linux/mediatek/mt7622/target.mk b/target/linux/mediatek/mt7622/target.mk index d4ec3cb661..dd4459724e 100644 --- a/target/linux/mediatek/mt7622/target.mk +++ b/target/linux/mediatek/mt7622/target.mk @@ -2,7 +2,7 @@ ARCH:=aarch64 SUBTARGET:=mt7622 BOARDNAME:=MT7622 CPU_TYPE:=cortex-a53 -DEFAULT_PACKAGES += kmod-mt7615e wpad-basic +DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic KERNELNAME:=Image dtbs define Target/Description diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 524364d8b0..c2e96160cf 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -160,7 +160,7 @@ define Device/asus_rt-ac65p IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ check-size - DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e wpad-basic uboot-envtools + DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools endef TARGET_DEVICES += asus_rt-ac65p @@ -176,7 +176,7 @@ define Device/asus_rt-ac85p IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ check-size - DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e wpad-basic uboot-envtools + DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools endef TARGET_DEVICES += asus_rt-ac85p @@ -199,7 +199,7 @@ define Device/buffalo_wsr-2533dhpl DEVICE_ALT0_VENDOR := Buffalo DEVICE_ALT0_MODEL := WSR-2533DHP IMAGE/sysupgrade.bin := trx | pad-rootfs | append-metadata - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += buffalo_wsr-2533dhpl @@ -257,7 +257,7 @@ define Device/edimax_ra21s IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ elx-header 02020040 8844A2D168B45A2D - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += edimax_ra21s @@ -268,7 +268,7 @@ define Device/edimax_rg21s IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ elx-header 02020038 8844A2D168B45A2D - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += edimax_rg21s @@ -279,7 +279,7 @@ define Device/elecom_wrc-1167ghbk2-s IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ elecom-wrc-factory WRC-1167GHBK2-S 0.00 - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += elecom_wrc-1167ghbk2-s @@ -384,7 +384,7 @@ define Device/iodata_wn-ax1167gr2 DEVICE_MODEL := WN-AX1167GR2 KERNEL_INITRAMFS := $(KERNEL_DTB) | loader-kernel | lzma | \ custom-initramfs-uimage 3.10(XBC.1)b10 | iodata-mstc-header - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += iodata_wn-ax1167gr2 @@ -394,7 +394,7 @@ define Device/iodata_wn-ax2033gr DEVICE_MODEL := WN-AX2033GR KERNEL_INITRAMFS := $(KERNEL_DTB) | loader-kernel | lzma | \ custom-initramfs-uimage 3.10(VST.1)C10 | iodata-mstc-header - DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += iodata_wn-ax2033gr @@ -404,7 +404,7 @@ define Device/iodata_wn-dx1167r DEVICE_MODEL := WN-DX1167R KERNEL_INITRAMFS := $(KERNEL_DTB) | loader-kernel | lzma | \ custom-initramfs-uimage 3.10(XIK.1)b10 | iodata-mstc-header - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += iodata_wn-dx1167r @@ -425,7 +425,7 @@ define Device/iodata_wnpr2600g IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ elx-header 0104003a 8844A2D168B45A2D - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += iodata_wnpr2600g @@ -434,7 +434,7 @@ define Device/iptime_a6ns-m UIMAGE_NAME := a6nm DEVICE_VENDOR := ipTIME DEVICE_MODEL := A6ns-M - DEVICE_PACKAGES := kmod-mt7615e kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic endef TARGET_DEVICES += iptime_a6ns-m @@ -443,7 +443,7 @@ define Device/iptime_a8004t UIMAGE_NAME := a8004t DEVICE_VENDOR := ipTIME DEVICE_MODEL := A8004T - DEVICE_PACKAGES := kmod-mt7615e kmod-usb3 wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 wpad-basic endef TARGET_DEVICES += iptime_a8004t @@ -454,7 +454,7 @@ define Device/jcg_jhr-ac876m JCG_MAXSIZE := 16064k DEVICE_VENDOR := JCG DEVICE_MODEL := JHR-AC876M - DEVICE_PACKAGES := kmod-mt7615e kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic endef TARGET_DEVICES += jcg_jhr-ac876m @@ -478,7 +478,7 @@ define Device/linksys_ea7500-v2 DEVICE_VENDOR := Linksys DEVICE_MODEL := EA7500 DEVICE_VARIANT := v2 - DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e wpad-basic uboot-envtools + DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools UBINIZE_OPTS := -E 5 IMAGES := sysupgrade.bin factory.bin IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | check-size @@ -617,7 +617,7 @@ define Device/netgear_r6260 SERCOMM_HWVER := A001 SERCOMM_SWVER := 0x0052 IMAGE_SIZE := 40960k - DEVICE_PACKAGES += kmod-mt7615e + DEVICE_PACKAGES += kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += netgear_r6260 @@ -629,7 +629,7 @@ define Device/netgear_r6350 SERCOMM_HWVER := A001 SERCOMM_SWVER := 0x0052 IMAGE_SIZE := 40960k - DEVICE_PACKAGES += kmod-mt7615e + DEVICE_PACKAGES += kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += netgear_r6350 @@ -648,7 +648,7 @@ define Device/netgear_r6700-v2 SERCOMM_HWVER := A001 SERCOMM_SWVER := 0x1032 IMAGE_SIZE := 40960k - DEVICE_PACKAGES += kmod-mt7615e + DEVICE_PACKAGES += kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += netgear_r6700-v2 @@ -660,7 +660,7 @@ define Device/netgear_r6800 SERCOMM_HWVER := A001 SERCOMM_SWVER := 0x0062 IMAGE_SIZE := 40960k - DEVICE_PACKAGES += kmod-mt7615e + DEVICE_PACKAGES += kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += netgear_r6800 @@ -672,7 +672,7 @@ define Device/netgear_r6850 SERCOMM_HWVER := A001 SERCOMM_SWVER := 0x0052 IMAGE_SIZE := 40960k - DEVICE_PACKAGES += kmod-mt7615e + DEVICE_PACKAGES += kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += netgear_r6850 @@ -725,7 +725,7 @@ define Device/phicomm_k2p DEVICE_ALT0_VENDOR := Phicomm DEVICE_ALT0_MODEL := KE 2P SUPPORTED_DEVICES += k2p - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += phicomm_k2p @@ -781,7 +781,7 @@ define Device/totolink_a7000r UIMAGE_NAME := C8340R1C-9999 DEVICE_VENDOR := TOTOLINK DEVICE_MODEL := A7000R - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += totolink_a7000r @@ -789,7 +789,7 @@ define Device/adslr_g7 IMAGE_SIZE := 16064k DEVICE_VENDOR := ADSLR DEVICE_MODEL := G7 - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic endef TARGET_DEVICES += adslr_g7 @@ -808,7 +808,7 @@ define Device/tplink_re650-v1 $(Device/tplink-safeloader) DEVICE_MODEL := RE650 DEVICE_VARIANT := v1 - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic TPLINK_BOARD_ID := RE650-V1 IMAGE_SIZE := 14208k endef @@ -843,7 +843,7 @@ TARGET_DEVICES += ubnt_edgerouter-x-sfp define Device/ubnt_unifi-nanohd DEVICE_VENDOR := Ubiquiti DEVICE_MODEL := UniFi nanoHD - DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e wpad-basic + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware wpad-basic IMAGE_SIZE := 15552k endef TARGET_DEVICES += ubnt_unifi-nanohd @@ -937,7 +937,7 @@ define Device/xiaomi_mir3p IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ check-size - DEVICE_PACKAGES := kmod-mt7615e kmod-usb3 kmod-usb-ledtrig-usbport \ + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport \ wpad-basic uboot-envtools endef TARGET_DEVICES += xiaomi_mir3p @@ -955,7 +955,7 @@ define Device/xiaomi_redmi-router-ac2100 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata DEVICE_VENDOR := Xiaomi DEVICE_MODEL := Redmi Router AC2100 - DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e wpad-basic uboot-envtools + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools endef TARGET_DEVICES += xiaomi_redmi-router-ac2100 From d56d05f01f03f9cc2afa7d91a2033f2288a51f9c Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Thu, 14 May 2020 11:00:58 +0800 Subject: [PATCH 5/8] generic: mt7530: set CPU port to fallback mode Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port: bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1 # br0 cannot send untagged frames out of sw0p0 anymore That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation. Set the CPU port to fallback mode so untagged frames can pass through. Signed-off-by: DENG Qingfang --- ...mt7530-set-CPU-port-to-fallback-mode.patch | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 target/linux/generic/backport-5.4/751-v5.8-net-dsa-mt7530-set-CPU-port-to-fallback-mode.patch diff --git a/target/linux/generic/backport-5.4/751-v5.8-net-dsa-mt7530-set-CPU-port-to-fallback-mode.patch b/target/linux/generic/backport-5.4/751-v5.8-net-dsa-mt7530-set-CPU-port-to-fallback-mode.patch new file mode 100644 index 0000000000..7b68fac8be --- /dev/null +++ b/target/linux/generic/backport-5.4/751-v5.8-net-dsa-mt7530-set-CPU-port-to-fallback-mode.patch @@ -0,0 +1,65 @@ +From 38152ea37d8bdaffa22603e0a5b5b86cfa8714c9 Mon Sep 17 00:00:00 2001 +From: DENG Qingfang +Date: Wed, 13 May 2020 23:37:17 +0800 +Subject: net: dsa: mt7530: set CPU port to fallback mode + +Currently, setting a bridge's self PVID to other value and deleting +the default VID 1 renders untagged ports of that VLAN unable to talk to +the CPU port: + + bridge vlan add dev br0 vid 2 pvid untagged self + bridge vlan del dev br0 vid 1 self + bridge vlan add dev sw0p0 vid 2 pvid untagged + bridge vlan del dev sw0p0 vid 1 + # br0 cannot send untagged frames out of sw0p0 anymore + +That is because the CPU port is set to security mode and its PVID is +still 1, and untagged frames are dropped due to VLAN member violation. + +Set the CPU port to fallback mode so untagged frames can pass through. + +Fixes: 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530") +Signed-off-by: DENG Qingfang +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/dsa/mt7530.c | 11 ++++++++--- + drivers/net/dsa/mt7530.h | 6 ++++++ + 2 files changed, 14 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -821,10 +821,15 @@ mt7530_port_set_vlan_aware(struct dsa_sw + PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS)); + + /* Trapped into security mode allows packet forwarding through VLAN +- * table lookup. ++ * table lookup. CPU port is set to fallback mode to let untagged ++ * frames pass through. + */ +- mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, +- MT7530_PORT_SECURITY_MODE); ++ if (dsa_is_cpu_port(ds, port)) ++ mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, ++ MT7530_PORT_FALLBACK_MODE); ++ else ++ mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, ++ MT7530_PORT_SECURITY_MODE); + + /* Set the port as a user port which is to be able to recognize VID + * from incoming packets before fetching entry within the VLAN table. +--- a/drivers/net/dsa/mt7530.h ++++ b/drivers/net/dsa/mt7530.h +@@ -152,6 +152,12 @@ enum mt7530_port_mode { + /* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */ + MT7530_PORT_MATRIX_MODE = PORT_VLAN(0), + ++ /* Fallback Mode: Forward received frames with ingress ports that do ++ * not belong to the VLAN member. Frames whose VID is not listed on ++ * the VLAN table are forwarded by the PCR_MATRIX members. ++ */ ++ MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1), ++ + /* Security Mode: Discard any frame due to ingress membership + * violation or VID missed on the VLAN table. + */ From dc4ffaa5ab6830ba9c5b9d9569db2c2aef26755a Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Mon, 20 Apr 2020 21:37:17 +0800 Subject: [PATCH 6/8] generic: fix DSA VLAN filtering Currently enabling VLAN filtering blocks all traffic in the bridge immediately. That is because DSA ignores all VLAN setup when VLAN filtering is disabled, and when it is enabled, there is no VLAN entry in the VLAN table, causing all traffic to be blocked. Add patches to allow VLAN setup even if VLAN filtering is disabled. Signed-off-by: DENG Qingfang --- ...an-option-for-drivers-to-always-rece.patch | 121 ++++++++++++++++++ ...3-v5.8-net-dsa-mt7530-fix-VLAN-setup.patch | 51 ++++++++ ...760-net-dsa-mv88e6xxx-fix-vlan-setup.patch | 27 ++++ 3 files changed, 199 insertions(+) create mode 100644 target/linux/generic/backport-5.4/752-v5.8-net-dsa-provide-an-option-for-drivers-to-always-rece.patch create mode 100644 target/linux/generic/backport-5.4/753-v5.8-net-dsa-mt7530-fix-VLAN-setup.patch create mode 100644 target/linux/generic/pending-5.4/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch diff --git a/target/linux/generic/backport-5.4/752-v5.8-net-dsa-provide-an-option-for-drivers-to-always-rece.patch b/target/linux/generic/backport-5.4/752-v5.8-net-dsa-provide-an-option-for-drivers-to-always-rece.patch new file mode 100644 index 0000000000..97ac6e2acd --- /dev/null +++ b/target/linux/generic/backport-5.4/752-v5.8-net-dsa-provide-an-option-for-drivers-to-always-rece.patch @@ -0,0 +1,121 @@ +From 54a0ed0df49609f4e3f098f8943e38e389dc2e15 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 12 May 2020 20:20:25 +0300 +Subject: net: dsa: provide an option for drivers to always receive bridge + VLANs + +DSA assumes that a bridge which has vlan filtering disabled is not +vlan aware, and ignores all vlan configuration. However, the kernel +software bridge code allows configuration in this state. + +This causes the kernel's idea of the bridge vlan state and the +hardware state to disagree, so "bridge vlan show" indicates a correct +configuration but the hardware lacks all configuration. Even worse, +enabling vlan filtering on a DSA bridge immediately blocks all traffic +which, given the output of "bridge vlan show", is very confusing. + +Provide an option that drivers can set to indicate they want to receive +vlan configuration even when vlan filtering is disabled. At the very +least, this is safe for Marvell DSA bridges, which do not look up +ingress traffic in the VTU if the port is in 8021Q disabled state. It is +also safe for the Ocelot switch family. Whether this change is suitable +for all DSA bridges is not known. + +Signed-off-by: Russell King +Signed-off-by: Vladimir Oltean +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + include/net/dsa.h | 7 +++++++ + net/dsa/dsa_priv.h | 1 + + net/dsa/port.c | 14 ++++++++++++++ + net/dsa/slave.c | 8 ++++---- + 4 files changed, 26 insertions(+), 4 deletions(-) + +--- a/include/net/dsa.h ++++ b/include/net/dsa.h +@@ -270,6 +270,13 @@ struct dsa_switch { + */ + bool vlan_filtering_is_global; + ++ /* Pass .port_vlan_add and .port_vlan_del to drivers even for bridges ++ * that have vlan_filtering=0. All drivers should ideally set this (and ++ * then the option would get removed), but it is unknown whether this ++ * would break things or not. ++ */ ++ bool configure_vlan_while_not_filtering; ++ + /* In case vlan_filtering_is_global is set, the VLAN awareness state + * should be retrieved from here and not from the per-port settings. + */ +--- a/net/dsa/dsa_priv.h ++++ b/net/dsa/dsa_priv.h +@@ -136,6 +136,7 @@ int dsa_port_bridge_join(struct dsa_port + void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br); + int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, + struct switchdev_trans *trans); ++bool dsa_port_skip_vlan_configuration(struct dsa_port *dp); + int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock, + struct switchdev_trans *trans); + int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, +--- a/net/dsa/port.c ++++ b/net/dsa/port.c +@@ -238,6 +238,20 @@ int dsa_port_vlan_filtering(struct dsa_p + return 0; + } + ++/* This enforces legacy behavior for switch drivers which assume they can't ++ * receive VLAN configuration when enslaved to a bridge with vlan_filtering=0 ++ */ ++bool dsa_port_skip_vlan_configuration(struct dsa_port *dp) ++{ ++ struct dsa_switch *ds = dp->ds; ++ ++ if (!dp->bridge_dev) ++ return false; ++ ++ return (!ds->configure_vlan_while_not_filtering && ++ !br_vlan_enabled(dp->bridge_dev)); ++} ++ + int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock, + struct switchdev_trans *trans) + { +--- a/net/dsa/slave.c ++++ b/net/dsa/slave.c +@@ -319,7 +319,7 @@ static int dsa_slave_vlan_add(struct net + if (obj->orig_dev != dev) + return -EOPNOTSUPP; + +- if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev)) ++ if (dsa_port_skip_vlan_configuration(dp)) + return 0; + + vlan = *SWITCHDEV_OBJ_PORT_VLAN(obj); +@@ -386,7 +386,7 @@ static int dsa_slave_vlan_del(struct net + if (obj->orig_dev != dev) + return -EOPNOTSUPP; + +- if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev)) ++ if (dsa_port_skip_vlan_configuration(dp)) + return 0; + + /* Do not deprogram the CPU port as it may be shared with other user +@@ -1118,7 +1118,7 @@ static int dsa_slave_vlan_rx_add_vid(str + * need to emulate the switchdev prepare + commit phase. + */ + if (dp->bridge_dev) { +- if (!br_vlan_enabled(dp->bridge_dev)) ++ if (dsa_port_skip_vlan_configuration(dp)) + return 0; + + /* br_vlan_get_info() returns -EINVAL or -ENOENT if the +@@ -1152,7 +1152,7 @@ static int dsa_slave_vlan_rx_kill_vid(st + * need to emulate the switchdev prepare + commit phase. + */ + if (dp->bridge_dev) { +- if (!br_vlan_enabled(dp->bridge_dev)) ++ if (dsa_port_skip_vlan_configuration(dp)) + return 0; + + /* br_vlan_get_info() returns -EINVAL or -ENOENT if the diff --git a/target/linux/generic/backport-5.4/753-v5.8-net-dsa-mt7530-fix-VLAN-setup.patch b/target/linux/generic/backport-5.4/753-v5.8-net-dsa-mt7530-fix-VLAN-setup.patch new file mode 100644 index 0000000000..8d64d2e672 --- /dev/null +++ b/target/linux/generic/backport-5.4/753-v5.8-net-dsa-mt7530-fix-VLAN-setup.patch @@ -0,0 +1,51 @@ +From 0141792f8b7300006b874dda1c35acd0abd90d9d Mon Sep 17 00:00:00 2001 +From: DENG Qingfang +Date: Fri, 15 May 2020 23:25:55 +0800 +Subject: net: dsa: mt7530: fix VLAN setup + +Allow DSA to add VLAN entries even if VLAN filtering is disabled, so +enabling it will not block the traffic of existent ports in the bridge + +Signed-off-by: DENG Qingfang +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/dsa/mt7530.c | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -1096,12 +1096,6 @@ mt7530_port_vlan_add(struct dsa_switch * + struct mt7530_priv *priv = ds->priv; + u16 vid; + +- /* The port is kept as VLAN-unaware if bridge with vlan_filtering not +- * being set. +- */ +- if (!dsa_port_is_vlan_filtering(&ds->ports[port])) +- return; +- + mutex_lock(&priv->reg_mutex); + + for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { +@@ -1127,12 +1121,6 @@ mt7530_port_vlan_del(struct dsa_switch * + struct mt7530_priv *priv = ds->priv; + u16 vid, pvid; + +- /* The port is kept as VLAN-unaware if bridge with vlan_filtering not +- * being set. +- */ +- if (!dsa_port_is_vlan_filtering(&ds->ports[port])) +- return 0; +- + mutex_lock(&priv->reg_mutex); + + pvid = priv->ports[port].pvid; +@@ -1245,6 +1233,7 @@ mt7530_setup(struct dsa_switch *ds) + * as two netdev instances. + */ + dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent; ++ ds->configure_vlan_while_not_filtering = true; + + if (priv->id == ID_MT7530) { + regulator_set_voltage(priv->core_pwr, 1000000, 1000000); diff --git a/target/linux/generic/pending-5.4/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch b/target/linux/generic/pending-5.4/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch new file mode 100644 index 0000000000..535c753a7b --- /dev/null +++ b/target/linux/generic/pending-5.4/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch @@ -0,0 +1,27 @@ +From a1b291f3f6c80a6c5ccad7283fc472d77a2a4763 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sun, 22 Dec 2019 12:40:11 +0000 +Subject: [PATCH] net: dsa: mv88e6xxx: fix vlan setup + +Provide an option that drivers can set to indicate they want to receive +vlan configuration even when vlan filtering is disabled. This is safe +for Marvell DSA bridges, which do not look up ingress traffic in the +VTU if the port is in 8021Q disabled state. Whether this change is +suitable for all DSA bridges is not known. + +Signed-off-by: Russell King +Signed-off-by: DENG Qingfang +--- + drivers/net/dsa/mv88e6xxx/chip.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -2657,6 +2657,7 @@ static int mv88e6xxx_setup(struct dsa_sw + + chip->ds = ds; + ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); ++ ds->configure_vlan_while_not_filtering = true; + + mv88e6xxx_reg_lock(chip); + From 7c47f6601d6da216b811a00fd6dcc5e1a96c2e09 Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Sat, 25 Apr 2020 20:08:00 +0800 Subject: [PATCH 7/8] generic: mt7530: fix roaming from DSA user ports When a client moves from a DSA user port to a software port in a bridge, it cannot reach any other clients that connected to the DSA user ports. That is because SA learning on the CPU port is disabled, so the switch ignores the client's frames from the CPU port and still thinks it is at the user port. Fix it by enabling SA learning on the CPU port. To prevent the switch from learning from flooding frames from the CPU port, set skb->offload_fwd_mark to 1 for unicast and broadcast frames, and let the switch flood them instead of trapping to the CPU port. Multicast frames still need to be trapped to the CPU port for snooping, so set the SA_DIS bit of the MTK tag to 1 when transmitting those frames to disable SA learning. Signed-off-by: DENG Qingfang --- ...7530-fix-roaming-from-DSA-user-ports.patch | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 target/linux/generic/backport-5.4/754-v5.7-net-dsa-mt7530-fix-roaming-from-DSA-user-ports.patch diff --git a/target/linux/generic/backport-5.4/754-v5.7-net-dsa-mt7530-fix-roaming-from-DSA-user-ports.patch b/target/linux/generic/backport-5.4/754-v5.7-net-dsa-mt7530-fix-roaming-from-DSA-user-ports.patch new file mode 100644 index 0000000000..1dcc9e44f7 --- /dev/null +++ b/target/linux/generic/backport-5.4/754-v5.7-net-dsa-mt7530-fix-roaming-from-DSA-user-ports.patch @@ -0,0 +1,116 @@ +From 5e5502e012b8129e11be616acb0f9c34bc8f8adb Mon Sep 17 00:00:00 2001 +From: DENG Qingfang +Date: Wed, 13 May 2020 23:10:16 +0800 +Subject: net: dsa: mt7530: fix roaming from DSA user ports + +When a client moves from a DSA user port to a software port in a bridge, +it cannot reach any other clients that connected to the DSA user ports. +That is because SA learning on the CPU port is disabled, so the switch +ignores the client's frames from the CPU port and still thinks it is at +the user port. + +Fix it by enabling SA learning on the CPU port. + +To prevent the switch from learning from flooding frames from the CPU +port, set skb->offload_fwd_mark to 1 for unicast and broadcast frames, +and let the switch flood them instead of trapping to the CPU port. +Multicast frames still need to be trapped to the CPU port for snooping, +so set the SA_DIS bit of the MTK tag to 1 when transmitting those frames +to disable SA learning. + +Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") +Signed-off-by: DENG Qingfang +Signed-off-by: David S. Miller +--- + drivers/net/dsa/mt7530.c | 9 ++------- + drivers/net/dsa/mt7530.h | 1 + + net/dsa/tag_mtk.c | 15 +++++++++++++++ + 3 files changed, 18 insertions(+), 7 deletions(-) + +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -639,11 +639,8 @@ mt7530_cpu_port_enable(struct mt7530_pri + mt7530_write(priv, MT7530_PVC_P(port), + PORT_SPEC_TAG); + +- /* Disable auto learning on the cpu port */ +- mt7530_set(priv, MT7530_PSC_P(port), SA_DIS); +- +- /* Unknown unicast frame fordwarding to the cpu port */ +- mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(port))); ++ /* Unknown multicast frame forwarding to the cpu port */ ++ mt7530_rmw(priv, MT7530_MFC, UNM_FFP_MASK, UNM_FFP(BIT(port))); + + /* Set CPU port number */ + if (priv->id == ID_MT7621) +@@ -1298,8 +1295,6 @@ mt7530_setup(struct dsa_switch *ds) + /* Enable and reset MIB counters */ + mt7530_mib_reset(ds); + +- mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK); +- + for (i = 0; i < MT7530_NUM_PORTS; i++) { + /* Disable forwarding by default on all ports */ + mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, +--- a/drivers/net/dsa/mt7530.h ++++ b/drivers/net/dsa/mt7530.h +@@ -31,6 +31,7 @@ enum { + #define MT7530_MFC 0x10 + #define BC_FFP(x) (((x) & 0xff) << 24) + #define UNM_FFP(x) (((x) & 0xff) << 16) ++#define UNM_FFP_MASK UNM_FFP(~0) + #define UNU_FFP(x) (((x) & 0xff) << 8) + #define UNU_FFP_MASK UNU_FFP(~0) + #define CPU_EN BIT(7) +--- a/net/dsa/tag_mtk.c ++++ b/net/dsa/tag_mtk.c +@@ -15,6 +15,7 @@ + #define MTK_HDR_XMIT_TAGGED_TPID_8100 1 + #define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) + #define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) ++#define MTK_HDR_XMIT_SA_DIS BIT(6) + + static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, + struct net_device *dev) +@@ -22,6 +23,9 @@ static struct sk_buff *mtk_tag_xmit(stru + struct dsa_port *dp = dsa_slave_to_port(dev); + u8 *mtk_tag; + bool is_vlan_skb = true; ++ unsigned char *dest = eth_hdr(skb)->h_dest; ++ bool is_multicast_skb = is_multicast_ether_addr(dest) && ++ !is_broadcast_ether_addr(dest); + + /* Build the special tag after the MAC Source Address. If VLAN header + * is present, it's required that VLAN header and special tag is +@@ -47,6 +51,10 @@ static struct sk_buff *mtk_tag_xmit(stru + MTK_HDR_XMIT_UNTAGGED; + mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; + ++ /* Disable SA learning for multicast frames */ ++ if (unlikely(is_multicast_skb)) ++ mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS; ++ + /* Tag control information is kept for 802.1Q */ + if (!is_vlan_skb) { + mtk_tag[2] = 0; +@@ -61,6 +69,9 @@ static struct sk_buff *mtk_tag_rcv(struc + { + int port; + __be16 *phdr, hdr; ++ unsigned char *dest = eth_hdr(skb)->h_dest; ++ bool is_multicast_skb = is_multicast_ether_addr(dest) && ++ !is_broadcast_ether_addr(dest); + + if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) + return NULL; +@@ -86,6 +97,10 @@ static struct sk_buff *mtk_tag_rcv(struc + if (!skb->dev) + return NULL; + ++ /* Only unicast or broadcast frames are offloaded */ ++ if (likely(!is_multicast_skb)) ++ skb->offload_fwd_mark = 1; ++ + return skb; + } + From 5b9ba4a93e83b731b9f315e0afb5fbb6f032b1b8 Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Thu, 28 May 2020 15:04:17 +0800 Subject: [PATCH 8/8] generic: mt7530: support adjusting EEE Add support for adjusting EEE with ethtool Signed-off-by: DENG Qingfang --- ...-net-dsa-mt7530-Support-EEE-features.patch | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 target/linux/generic/pending-5.4/761-net-dsa-mt7530-Support-EEE-features.patch diff --git a/target/linux/generic/pending-5.4/761-net-dsa-mt7530-Support-EEE-features.patch b/target/linux/generic/pending-5.4/761-net-dsa-mt7530-Support-EEE-features.patch new file mode 100644 index 0000000000..1822647ff1 --- /dev/null +++ b/target/linux/generic/pending-5.4/761-net-dsa-mt7530-Support-EEE-features.patch @@ -0,0 +1,121 @@ +From 9cfb2d426c38272f245e9e6f62b3552d1ed5852b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= +Date: Tue, 21 Apr 2020 00:18:08 +0200 +Subject: [PATCH] net: dsa: mt7530: Support EEE features +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: René van Dorst +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -1419,9 +1419,13 @@ static void mt7530_phylink_mac_config(st + switch (state->speed) { + case SPEED_1000: + mcr_new |= PMCR_FORCE_SPEED_1000; ++ if (priv->eee_enable & BIT(port)) ++ mcr_new |= PMCR_FORCE_EEE1G; + break; + case SPEED_100: + mcr_new |= PMCR_FORCE_SPEED_100; ++ if (priv->eee_enable & BIT(port)) ++ mcr_new |= PMCR_FORCE_EEE100; + break; + } + if (state->duplex == DUPLEX_FULL) { +@@ -1557,6 +1561,54 @@ mt7530_phylink_mac_link_state(struct dsa + return 1; + } + ++static int mt7530_get_mac_eee(struct dsa_switch *ds, int port, ++ struct ethtool_eee *e) ++{ ++ struct mt7530_priv *priv = ds->priv; ++ u32 eeecr, pmsr; ++ ++ e->eee_enabled = !!(priv->eee_enable & BIT(port)); ++ ++ if (e->eee_enabled) { ++ eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port)); ++ e->tx_lpi_enabled = !(eeecr & LPI_MODE_EN); ++ e->tx_lpi_timer = (eeecr >> 4) & 0xFFF; ++ pmsr = mt7530_read(priv, MT7530_PMSR_P(port)); ++ e->eee_active = e->eee_enabled && !!(pmsr & PMSR_EEE1G); ++ } else { ++ e->tx_lpi_enabled = 0; ++ e->tx_lpi_timer = 0; ++ e->eee_active = 0; ++ } ++ ++ return 0; ++} ++ ++static int mt7530_set_mac_eee(struct dsa_switch *ds, int port, ++ struct ethtool_eee *e) ++{ ++ struct mt7530_priv *priv = ds->priv; ++ u32 eeecr; ++ ++ if (e->tx_lpi_enabled && e->tx_lpi_timer > 0xFFF) ++ return -EINVAL; ++ ++ if (e->eee_enabled) { ++ priv->eee_enable |= BIT(port); ++ //MT7530_PMEEECR_P ++ eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port)); ++ eeecr &= 0xFFFF0000; ++ if (!e->tx_lpi_enabled) ++ eeecr |= LPI_MODE_EN; ++ eeecr = LPI_THRESH(e->tx_lpi_timer); ++ mt7530_write(priv, MT7530_PMEEECR_P(port), eeecr); ++ } else { ++ priv->eee_enable &= ~(BIT(port)); ++ } ++ ++ return 0; ++} ++ + static const struct dsa_switch_ops mt7530_switch_ops = { + .get_tag_protocol = mtk_get_tag_protocol, + .setup = mt7530_setup, +@@ -1584,6 +1636,8 @@ static const struct dsa_switch_ops mt753 + .phylink_mac_config = mt7530_phylink_mac_config, + .phylink_mac_link_down = mt7530_phylink_mac_link_down, + .phylink_mac_link_up = mt7530_phylink_mac_link_up, ++ .get_mac_eee = mt7530_get_mac_eee, ++ .set_mac_eee = mt7530_set_mac_eee, + }; + + static const struct of_device_id mt7530_of_match[] = { +--- a/drivers/net/dsa/mt7530.h ++++ b/drivers/net/dsa/mt7530.h +@@ -212,6 +212,8 @@ enum mt7530_vlan_port_attr { + #define PMCR_RX_EN BIT(13) + #define PMCR_BACKOFF_EN BIT(9) + #define PMCR_BACKPR_EN BIT(8) ++#define PMCR_FORCE_EEE1G BIT(7) ++#define PMCR_FORCE_EEE100 BIT(6) + #define PMCR_TX_FC_EN BIT(5) + #define PMCR_RX_FC_EN BIT(4) + #define PMCR_FORCE_SPEED_1000 BIT(3) +@@ -233,6 +235,12 @@ enum mt7530_vlan_port_attr { + #define PMSR_DPX BIT(1) + #define PMSR_LINK BIT(0) + ++#define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100) ++#define WAKEUP_TIME_1000(x) ((x & 0xFF) << 24) ++#define WAKEUP_TIME_100(x) ((x & 0xFF) << 16) ++#define LPI_THRESH(x) ((x & 0xFFF) << 4) ++#define LPI_MODE_EN BIT(0) ++ + /* Register for MIB */ + #define MT7530_PORT_MIB_COUNTER(x) (0x4000 + (x) * 0x100) + #define MT7530_MIB_CCR 0x4fe0 +@@ -471,6 +479,7 @@ struct mt7530_priv { + unsigned int p5_intf_sel; + u8 mirror_rx; + u8 mirror_tx; ++ u8 eee_enable; + + struct mt7530_port ports[MT7530_NUM_PORTS]; + /* protect among processes for registers access*/