From 492c1e5597103c4e42a0cb4751b2ed92b898b9c0 Mon Sep 17 00:00:00 2001 From: hanwckf Date: Wed, 31 Jan 2024 18:25:32 +0800 Subject: [PATCH] mediatek: reverse WAN/LAN port for glinet mt7981 devices to fix hnat issues --- .../boot/dts/mediatek/mt7981-gl-mt2500.dts | 23 ++----------- .../boot/dts/mediatek/mt7981-gl-mt3000.dts | 7 ++-- .../boot/dts/mediatek/mt7981-gl-x3000.dts | 31 ++---------------- .../boot/dts/mediatek/mt7981-gl-xe3000.dts | 32 ++----------------- .../ethernet/mediatek/mtk_hnat/hnat_nf_hook.c | 6 ---- .../mt7981/base-files/etc/board.d/02_network | 2 +- 6 files changed, 13 insertions(+), 88 deletions(-) diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts index e5d793cd1f..bd1f477711 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts @@ -1,7 +1,7 @@ /dts-v1/; #include "mt7981.dtsi" / { - model = "GL.iNet GL-MT2500"; + model = "GL.iNet GL-MT2500 (wan/lan reversed)"; compatible = "glinet,mt2500-emmc", "mediatek,mt7981"; chosen { @@ -20,22 +20,6 @@ regulator-always-on; }; - gl-hw { - compatible = "gl-hw-info"; - model = "mt2500"; - wan = "eth0"; - lan = "eth1"; - usb-port = "1-1"; - flash_size = <8192>; - temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp"; - factory_data { - device_mac = "/dev/mmcblk0boot1", "0x0a"; - device_ddns = "/dev/mmcblk0boot1", "0x10"; - device_sn_bak = "/dev/mmcblk0boot1", "0x20"; - device_sn = "/dev/mmcblk0boot1", "0x30"; - }; - }; - gpio-keys { compatible = "gpio-keys"; @@ -141,9 +125,8 @@ }; &hnat { - mtketh-wan = "eth0"; - mtketh-lan = "eth1"; - mtketh-ppd = "eth1"; + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; mtketh-max-gmac = <2>; status = "okay"; }; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt3000.dts index 19b4907e14..0751cd6c92 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt3000.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt3000.dts @@ -4,7 +4,7 @@ #include "mt7981.dtsi" / { - model = "GL.iNet GL-MT3000"; + model = "GL.iNet GL-MT3000 (wan/lan reversed)"; compatible = "glinet,mt3000-snand", "mediatek,mt7981"; aliases { @@ -206,9 +206,8 @@ }; &hnat { - mtketh-wan = "eth0"; - mtketh-lan = "eth1"; - mtketh-ppd = "eth1"; + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; mtketh-max-gmac = <2>; status = "okay"; }; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts index 457b67fc7d..f2a1494e16 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts @@ -1,7 +1,7 @@ /dts-v1/; #include "mt7981.dtsi" / { - model = "GL.iNet GL-X3000"; + model = "GL.iNet GL-X3000 (wan/lan reversed)"; compatible = "glinet,x3000-emmc", "mediatek,mt7981"; chosen { @@ -20,30 +20,6 @@ regulator-always-on; }; - gl-hw { - compatible = "gl-hw-info"; - model = "x3000"; - wan = "eth0"; - lan = "eth1"; - build-in-modem = "0001:01:00.0"; - pcie-bus = "0001:01:00.0"; - usb-port = "1-1.3"; - fan = "pwmchip0"; - flash_size = <7456>; - temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp"; - reset-button = "gpio-456"; - radio = "mt798111 mt798112"; - cfg-partition = "/dev/mmcblk0p5"; - dfs; - factory_data { - device_mac = "/dev/mmcblk0p3", "0x0a"; - device_ddns = "/dev/mmcblk0p3", "0x10"; - device_sn_bak = "/dev/mmcblk0p3", "0x20"; - device_sn = "/dev/mmcblk0p3", "0x30"; - country_code = "/dev/mmcblk0p3", "0x88"; - }; - }; - gpio-keys { compatible = "gpio-keys"; @@ -251,9 +227,8 @@ }; &hnat { - mtketh-wan = "eth0"; - mtketh-lan = "eth1"; - mtketh-ppd = "eth1"; + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; mtketh-max-gmac = <2>; status = "okay"; }; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts index 4c8d2113ee..49bbf44a13 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts @@ -1,7 +1,7 @@ /dts-v1/; #include "mt7981.dtsi" / { - model = "GL.iNet GL-XE3000"; + model = "GL.iNet GL-XE3000 (wan/lan reversed)"; compatible = "glinet,xe3000-emmc", "mediatek,mt7981"; chosen { @@ -20,31 +20,6 @@ regulator-always-on; }; - gl-hw { - compatible = "gl-hw-info"; - model = "xe3000"; - wan = "eth0"; - lan = "eth1"; - build-in-modem = "0001:01:00.0"; - pcie-bus = "0001:01:00.0"; - usb-port = "1-1.3"; - fan = "pwmchip0"; - flash_size = <7456>; - temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp"; - reset-button = "gpio-456"; - radio = "mt798111 mt798112"; - mcu = "/dev/ttyS1,9600"; - cfg-partition = "/dev/mmcblk0p5"; - dfs; - factory_data { - device_mac = "/dev/mmcblk0p3", "0x0a"; - device_ddns = "/dev/mmcblk0p3", "0x10"; - device_sn_bak = "/dev/mmcblk0p3", "0x20"; - device_sn = "/dev/mmcblk0p3", "0x30"; - country_code = "/dev/mmcblk0p3", "0x88"; - }; - }; - gpio-keys { compatible = "gpio-keys"; @@ -240,9 +215,8 @@ }; &hnat { - mtketh-wan = "eth0"; - mtketh-lan = "eth1"; - mtketh-ppd = "eth1"; + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; mtketh-max-gmac = <2>; status = "okay"; }; diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c index 10c532e77e..dc662a6872 100644 --- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c +++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c @@ -1651,9 +1651,6 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb, gmac = ((skb_hnat_entry(skb) >> 1) % hnat_priv->gmac_num) ? NR_GMAC2_PORT : NR_GMAC1_PORT; else { - if (of_machine_is_compatible("glinet,mt2500-emmc")||of_machine_is_compatible("glinet,mt3000-snand")) - gmac = NR_GMAC2_PORT; - else gmac = NR_GMAC1_PORT; } } else if (IS_WAN(dev)) { @@ -1666,9 +1663,6 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb, /* Set act_dp = wan_dev */ entry.ipv4_hnapt.act_dp = dev->ifindex; } else { - if (of_machine_is_compatible("glinet,mt2500-emmc")||of_machine_is_compatible("glinet,mt3000-snand")) - gmac = NR_GMAC1_PORT; - else gmac = (IS_GMAC1_MODE) ? NR_GMAC1_PORT : NR_GMAC2_PORT; } } else if (IS_EXT(dev) && (FROM_GE_PPD(skb) || FROM_GE_LAN(skb) || diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network index 7c733cb8d4..49638ecbb6 100755 --- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network @@ -66,7 +66,7 @@ mediatek_setup_interfaces() glinet,x3000-emmc |\ *xe3000* |\ *mt2500*) - ucidef_set_interfaces_lan_wan "eth1" "eth0" + ucidef_set_interfaces_lan_wan "eth0" "eth1" ;; *zr-3020*) ucidef_set_interfaces_lan_wan "eth0" "eth1"