mediatek: reverse WAN/LAN port for glinet mt7981 devices to fix hnat issues

This commit is contained in:
hanwckf 2024-01-31 18:25:32 +08:00
parent 929cd0f9d2
commit 492c1e5597
6 changed files with 13 additions and 88 deletions

View File

@ -1,7 +1,7 @@
/dts-v1/; /dts-v1/;
#include "mt7981.dtsi" #include "mt7981.dtsi"
/ { / {
model = "GL.iNet GL-MT2500"; model = "GL.iNet GL-MT2500 (wan/lan reversed)";
compatible = "glinet,mt2500-emmc", "mediatek,mt7981"; compatible = "glinet,mt2500-emmc", "mediatek,mt7981";
chosen { chosen {
@ -20,22 +20,6 @@
regulator-always-on; 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 { gpio-keys {
compatible = "gpio-keys"; compatible = "gpio-keys";
@ -141,9 +125,8 @@
}; };
&hnat { &hnat {
mtketh-wan = "eth0"; mtketh-wan = "eth1";
mtketh-lan = "eth1"; mtketh-lan = "eth0";
mtketh-ppd = "eth1";
mtketh-max-gmac = <2>; mtketh-max-gmac = <2>;
status = "okay"; status = "okay";
}; };

View File

@ -4,7 +4,7 @@
#include "mt7981.dtsi" #include "mt7981.dtsi"
/ { / {
model = "GL.iNet GL-MT3000"; model = "GL.iNet GL-MT3000 (wan/lan reversed)";
compatible = "glinet,mt3000-snand", "mediatek,mt7981"; compatible = "glinet,mt3000-snand", "mediatek,mt7981";
aliases { aliases {
@ -206,9 +206,8 @@
}; };
&hnat { &hnat {
mtketh-wan = "eth0"; mtketh-wan = "eth1";
mtketh-lan = "eth1"; mtketh-lan = "eth0";
mtketh-ppd = "eth1";
mtketh-max-gmac = <2>; mtketh-max-gmac = <2>;
status = "okay"; status = "okay";
}; };

View File

@ -1,7 +1,7 @@
/dts-v1/; /dts-v1/;
#include "mt7981.dtsi" #include "mt7981.dtsi"
/ { / {
model = "GL.iNet GL-X3000"; model = "GL.iNet GL-X3000 (wan/lan reversed)";
compatible = "glinet,x3000-emmc", "mediatek,mt7981"; compatible = "glinet,x3000-emmc", "mediatek,mt7981";
chosen { chosen {
@ -20,30 +20,6 @@
regulator-always-on; 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 { gpio-keys {
compatible = "gpio-keys"; compatible = "gpio-keys";
@ -251,9 +227,8 @@
}; };
&hnat { &hnat {
mtketh-wan = "eth0"; mtketh-wan = "eth1";
mtketh-lan = "eth1"; mtketh-lan = "eth0";
mtketh-ppd = "eth1";
mtketh-max-gmac = <2>; mtketh-max-gmac = <2>;
status = "okay"; status = "okay";
}; };

View File

@ -1,7 +1,7 @@
/dts-v1/; /dts-v1/;
#include "mt7981.dtsi" #include "mt7981.dtsi"
/ { / {
model = "GL.iNet GL-XE3000"; model = "GL.iNet GL-XE3000 (wan/lan reversed)";
compatible = "glinet,xe3000-emmc", "mediatek,mt7981"; compatible = "glinet,xe3000-emmc", "mediatek,mt7981";
chosen { chosen {
@ -20,31 +20,6 @@
regulator-always-on; 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 { gpio-keys {
compatible = "gpio-keys"; compatible = "gpio-keys";
@ -240,9 +215,8 @@
}; };
&hnat { &hnat {
mtketh-wan = "eth0"; mtketh-wan = "eth1";
mtketh-lan = "eth1"; mtketh-lan = "eth0";
mtketh-ppd = "eth1";
mtketh-max-gmac = <2>; mtketh-max-gmac = <2>;
status = "okay"; status = "okay";
}; };

View File

@ -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) ? gmac = ((skb_hnat_entry(skb) >> 1) % hnat_priv->gmac_num) ?
NR_GMAC2_PORT : NR_GMAC1_PORT; NR_GMAC2_PORT : NR_GMAC1_PORT;
else { 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; gmac = NR_GMAC1_PORT;
} }
} else if (IS_WAN(dev)) { } 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 */ /* Set act_dp = wan_dev */
entry.ipv4_hnapt.act_dp = dev->ifindex; entry.ipv4_hnapt.act_dp = dev->ifindex;
} else { } 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; gmac = (IS_GMAC1_MODE) ? NR_GMAC1_PORT : NR_GMAC2_PORT;
} }
} else if (IS_EXT(dev) && (FROM_GE_PPD(skb) || FROM_GE_LAN(skb) || } else if (IS_EXT(dev) && (FROM_GE_PPD(skb) || FROM_GE_LAN(skb) ||

View File

@ -66,7 +66,7 @@ mediatek_setup_interfaces()
glinet,x3000-emmc |\ glinet,x3000-emmc |\
*xe3000* |\ *xe3000* |\
*mt2500*) *mt2500*)
ucidef_set_interfaces_lan_wan "eth1" "eth0" ucidef_set_interfaces_lan_wan "eth0" "eth1"
;; ;;
*zr-3020*) *zr-3020*)
ucidef_set_interfaces_lan_wan "eth0" "eth1" ucidef_set_interfaces_lan_wan "eth0" "eth1"