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
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.
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.
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.
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...
I have managed to compile OpenWrt 22.03 with your drivers for my DIR-878.
It works as expected, but I encountered one problem. I want to separate LAN 1 ports, so I create a new VLAN tagged to cpu and untagged to LAN 1, then I create a new interface for it. The new interface works, I got an IP address and internet connection from LAN 1, but the speed is very slow, around 1-2Mbps. If hnat is disabled using rmmod mtkhnat, I get full speed on LAN 1. Is it normal?
Sorry if this is a stupid question, I'm completely new to this, in fact it took me a week to successfully compile the firmware