Considering some problems with openwrt flow offload now, I try to use the hwnat driver of mtk sdk. Compared with flow offload, it is more stable and supports wifi offload. This is the sdk driver source code published by mtk https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/
Based on the above source code, I modified the hwnat driver that can run stably under linux 5.10. It supports offload of ipv4, ipv6 and wifi. For some reason I'm using the switch driver instead of the dsa driver. The steps to use this driver are as follows
Replace ramips folder of your openwrt source directory with the folder corresponding to the link
This folder is only adapted to wr1200js, newifi d1, and k2p now. If you are on other models, you should refer to these two commits to modify the source code to adapt to your router.
Run rm .config. In theory, after re-make menuconfig, kmod-ramips_hnat will be automatically added to .config. Flash the compiled firmware, when you see the following log, it means hwnat is running successfully. To avoid conflicts, you should disable flow offload.
For the second step, the wan of 7621 has two cases. If your wan is port4, it should be
mediatek,portmap = "llllw";
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6u@eth0" "5u@eth1"
And if your wan is port0, it should be
mediatek,portmap = "wllll";
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6u@eth0" "5u@eth1"
You can see whether your wan is port0 or port4 from the switch0 node in the original dts
But there are some mt7621 routers that only support one gmac, such as newifi3 d2, so the above steps are not suitable for these routers. I don't have time to adapt this kind of router, I hope people with energy can study it.
Can use on coolwolfsnow lede?
Any openwrt could use this driver if the kernel version is 5.10. But I haven't test firewall4.
Really appreciate your guidance
I'm curious how hard it would be to port this to DSA and kernel 5.15.x. Exciting that you have it up and running with 5.10 and the older switch code. Anything that helps out these little chipsets is a good thing. Thanks for digging into it. Hopefully people can pile on and get this into a usable PR.
In theory 5.15 can be used directly. As for dsa, mtk sdk lacks related patches, and I have the need to use switch myself, so I have no motivation to test dsa.
It may sound ridiculous, but I want to ask can I disable the kernel driver in runtime to avoid using HWNAT? As we need monitoring bandwith sometimes but with HWNAT enabled, it won't work corretly...
solution found: using
rmmod mtkhnat or
modprobe mtkhnat to toggle mtkhwnat
i adapted it for my netgear r 6260, it's working, but is normal that no switch config in luci is present?
Anyone got this working on Redmi AX6000?
that's very easy i do not have that device, but check if kernel 5.10 or 5.4 is right
also that is not mt7621 chipset
swconfig package is needed