Skip to content

Commit

Permalink
mediatek:adjust to dsa and add support hnat for macvlan and wan bonding
Browse files Browse the repository at this point in the history
  • Loading branch information
padavanonly committed Sep 17, 2024
1 parent 8b0e4fc commit 81c7963
Show file tree
Hide file tree
Showing 40 changed files with 1,581 additions and 997 deletions.
2 changes: 1 addition & 1 deletion package/emortal/autocore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define Package/autocore/install/Default
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/

ifeq ($(filter ipq% mediatek%, $(TARGETID)),)
ifeq ($(filter ipq%, $(TARGETID)),)
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/

$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
Expand Down
2 changes: 1 addition & 1 deletion package/emortal/autocore/files/generic/cpuinfo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case "$DISTRIB_TARGET" in
"bcm53xx"/*)
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
"mediatek"/*|"mvebu"/*)
cpu_freq="$(mhz | awk -F 'cpu_MHz=' '{printf("%.fMHz",$2)}')" ;;
cpu_freq="" ;;
"mvebu/cortexa72")
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy2/cpuinfo_cur_freq")"
Expand Down
52 changes: 51 additions & 1 deletion package/emortal/autocore/files/generic/ethinfo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,57 @@ local jsonc = require "luci.jsonc"
local eth_info = {}
local ifname, stat
for ifname, stat in pairs(util.ubus("network.device", "status")) do
if ifname:match("^(eth%d+)$") == ifname then
if ifname:match("^(eth1)$") == ifname then
local status, speed, duplex

status = stat.carrier and "yes" or "no"

if not stat.carrier or not stat.speed or stat.speed:sub(1, 1) == "-" then
speed = "-"
else
speed = stat.speed:sub(1, -2) .. "Mb/s"
end

if speed == '-' then
duplex = "-"
elseif stat.speed:sub(-1) == "F" then
duplex = "Full"
else
duplex = "Half"
end

eth_info[#eth_info+1] = { name = ifname, status = status,
speed = speed, duplex = duplex }
end
end

for ifname, stat in pairs(util.ubus("network.device", "status")) do
if ifname:match("^(lan%d+)$") == ifname then
local status, speed, duplex

status = stat.carrier and "yes" or "no"

if not stat.carrier or not stat.speed or stat.speed:sub(1, 1) == "-" then
speed = "-"
else
speed = stat.speed:sub(1, -2) .. "Mb/s"
end

if speed == '-' then
duplex = "-"
elseif stat.speed:sub(-1) == "F" then
duplex = "Full"
else
duplex = "Half"
end

eth_info[#eth_info+1] = { name = ifname, status = status,
speed = speed, duplex = duplex }
end
end

for ifname, stat in pairs(util.ubus("network.device", "status")) do
if ifname:match("^(wan)$") == ifname then
local status, speed, duplex

status = stat.carrier and "yes" or "no"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ return view.extend({
o.depends('fastpath_mh_eth_hnat', '1');

o = s.option(form.Flag, 'fastpath_mh_eth_hnat_macvlan', _('Enable ethernet HNAT for MACVLAN WAN device'),
_('Enable hardware offloading for macvlan (sing wan only).'));
_('Enable hardware offloading for macvlan.'));
o.default = o.disabled;
o.rmempty = false;
o.depends('fastpath_mh_eth_hnat', '1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ msgid "Enable ethernet HNAT for MACVLAN WAN device"
msgstr "启用MACVLAN WAN 设备 HNAT"

#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:178
msgid "Enable hardware offloading for macvlan (sing wan only)."
msgstr "为MACVLAN 连接启用硬件加速(仅支持单WAN)。"
msgid "Enable hardware offloading for macvlan."
msgstr "为MACVLAN 连接启用硬件加速。"

#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:183
msgid "HNAT bind rate threshold (pps)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
led-running = &green_led;
led-upgrade = &green_led;
};



chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8 \
Expand Down Expand Up @@ -50,12 +52,6 @@
};
};

gsw: gsw@0 {
compatible = "mediatek,mt753x";
mediatek,ethsys = <&ethsys>;
#address-cells = <1>;
#size-cells = <0>;
};
};

&uart0 {
Expand All @@ -66,22 +62,23 @@
status = "okay";
};


&eth {
status = "okay";
status = "okay";

gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};

gmac1: mac@1 {
gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "2500base-x";
Expand All @@ -96,46 +93,58 @@
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
};
};

&gsw {
mediatek,mdio = <&mdio>;
mediatek,mdio_master_pinmux = <0>;
reset-gpios = <&pio 39 0>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
status = "okay";

port5: port@5 {
compatible = "mediatek,mt753x-port";
reg = <5>;
phy-mode = "sgmii";

fixed-link {
speed = <2500>;
full-duplex;
};
};

port6: port@6 {
compatible = "mediatek,mt753x-port";
mediatek,ssc-on;
reg = <6>;
phy-mode = "sgmii";

fixed-link {
speed = <2500>;
full-duplex;
switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 39 0>;

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
label = "lan1";
};

port@1 {
reg = <1>;
label = "lan2";
};

port@2 {
reg = <2>;
label = "lan3";
};

port@3 {
reg = <3>;
label = "wan";
};

port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
};
};

&hnat {
mtketh-wan = "eth1";
mtketh-lan = "eth0";
mtketh-lan = "lan";
mtketh-ppd = "eth1";
mtketh-max-gmac = <2>;
ext-devices = "wlan0","wlan1","rax0","ra0", "rai0","apclii0","apclix0", "apcli0";
status = "okay";
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@
};
};

gsw: gsw@0 {
compatible = "mediatek,mt753x";
mediatek,ethsys = <&ethsys>;
#address-cells = <1>;
#size-cells = <0>;
};


nmbm_spim_nand {
compatible = "generic,nmbm";
Expand Down Expand Up @@ -144,6 +139,7 @@

gmac1: mac@1 {
compatible = "mediatek,eth-mac";
label = "wan";
reg = <1>;
phy-mode = "gmii";
phy-handle = <&phy0>;
Expand All @@ -160,36 +156,53 @@
nvmem-cells = <&phy_calibration>;
nvmem-cell-names = "phy-cal-data";
};
};
};

&gsw {
mediatek,mdio = <&mdio>;
mediatek,portmap = "wllll";
mediatek,mdio_master_pinmux = <0>;
reset-gpios = <&pio 39 0>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
status = "okay";

port6: port@6 {
compatible = "mediatek,mt753x-port";
mediatek,ssc-on;
reg = <6>;
phy-mode = "sgmii";

fixed-link {
speed = <2500>;
full-duplex;
switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 39 0>;

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
label = "lan1";
};

port@1 {
reg = <1>;
label = "lan2";
};

port@2 {
reg = <2>;
label = "lan3";
};

port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
};
};

&hnat {
mtketh-wan = "eth1";
mtketh-lan = "eth0";
mtketh-max-gmac = <2>;
status = "okay";
mtketh-wan = "eth1";
mtketh-lan = "lan";
mtketh-max-gmac = <2>;
status = "okay";
};

&spi0 {
Expand Down
Loading

1 comment on commit 81c7963

@shminer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

切换到dsa后switch命令很多也不能用了 switch ingress-rate无法对端口限速了

Please sign in to comment.