[BPI-R2] Kernel Development

It’s strange that after booting the 5.3-rc kernel I have a very limited set of modules loaded. I cannot even run iptables or perform masquerading. I have tried manually to load the module “ modprobe ipt_MASQUERADE ” and the serial console freezes.

root@bpi-r2:~# iptables -nvL
iptables: Operation not supported.
root@bpi-r2:~# lsmod
Module                  Size  Used by
nf_conntrack          131072  0
nf_defrag_ipv6         20480  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
nfnetlink              16384  0
mtk_thermal            16384  0
spi_mt65xx             20480  0
nvmem_mtk_efuse        16384  0
pwm_mediatek           16384  0
mt6577_auxadc          16384  0
ip_tables              24576  0
x_tables               32768  1 ip_tables

Have you build more modules? Maybe upgrade to 5.3-rc5

I just ran importconfig and then build.sh after merging those branches into 5.3-rc

You have copied all modules to sdcard? You can look in /lib/modules which modules are available.

find /lib/modules/$(uname -r) -iname '*.ko'

But try also an upgrade to rc5…maybe rc1 has a bug which freezes console

After I tried to enable masquerading again I saw a backtrace message popping up in the console. I’m pasting it here:

[ 2466.807803] mt7530 mdio-bus:1f lan0: phylink_mac_config: mode=phy/gmii/1Gbps/Full adv=00,00000000,00000000 pause=0f link=1 an=0
[ 2466.823338] mt7530 mdio-bus:1f lan0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 2466.830878] br0: port 1(lan0) entered blocking state
[ 2466.835908] br0: port 1(lan0) entered forwarding state
[ 2466.841843] IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
[ 2466.871848] 8<--- cut here ---
[ 2466.874921] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 2466.883066] pgd = f245bbe7
[ 2466.885775] [00000000] *pgd=00000000
[ 2466.889362] Internal error: Oops: 80000005 [#1] SMP ARM
[ 2466.894586] Modules linked in: xt_MASQUERADE ip6table_nat ip6table_mangle iptable_nat nf_nat iptable_mangle ip6table_filter ip6_tables iptable_filter nf_conns
[ 2466.920001] CPU: 0 PID: 1065 Comm: kworker/0:2 Not tainted 5.3.0-rc1-bpi-r2 #2
[ 2466.927220] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 2466.932803] Workqueue: events switchdev_deferred_process_work
[ 2466.938551] PC is at 0x0
[ 2466.941085] LR is at dsa_switch_event+0x5d8/0x6c0
[ 2466.945787] pc : [<00000000>]    lr : [<c09f6398>]    psr: 200f0013
[ 2466.952050] sp : da91dcb0  ip : 00000000  fp : da91dcf4
[ 2466.957276] r10: 0000000c  r9 : d981b088  r8 : d6412850
[ 2466.962500] r7 : 00000006  r6 : d981b040  r5 : c1104c48  r4 : d981b04c
[ 2466.969028] r3 : 00000000  r2 : d6412850  r1 : 00000006  r0 : d981b040
[ 2466.975557] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[ 2466.982694] Control: 10c5387d  Table: 9741c06a  DAC: 00000051
[ 2466.988444] Process kworker/0:2 (pid: 1065, stack limit = 0xb6601ec8)
[ 2466.994886] Stack: (0xda91dcb0 to 0xda91e000)
[ 2466.999245] dca0:                                     0000001f 00000010 da91dce4 c1104c48
[ 2467.007429] dcc0: c06d4160 746d9f0c daffd000 ffffffff da91dd3c 00000005 00000000 00000000
[ 2467.015613] dce0: c09f52b4 c1104c48 da91dd1c da91dcf8 c014d504 c09f5dcc c1104c48 da91de38
[ 2467.023798] dd00: d9916800 00000000 c09f3bb4 c09f52b4 da91dd34 da91dd20 c014d664 c014d4bc
[ 2467.031982] dd20: 00000000 cb0a5035 da91dd64 da91dd38 c09f32c8 c014d648 7faf215d d6412850
[ 2467.040166] dd40: da91de73 00000000 00000006 746d9f0c da91ddb4 00000000 da91dd74 da91dd68
[ 2467.048350] dd60: c09f5310 c09f327c da91ddac da91dd78 c0b4bb48 c09f52c0 00000001 746d9f0c
[ 2467.056534] dd80: 00000390 ffffffff da91de38 00000006 00000000 00000000 00000000 db57d205
[ 2467.064718] dda0: da91ddbc da91ddb0 c0b4bb74 c0b4ba7c da91ddcc da91ddc0 c09f513c c0b4bb68
[ 2467.072902] ddc0: da91ddf4 da91ddd0 c014d504 c09f50f8 00000006 c11bc860 da91de38 ffffffff
[ 2467.081086] dde0: d6412850 00000000 da91de1c da91ddf8 c014d978 c014d4bc 00000000 746d9f0c
[ 2467.089269] de00: c1104c48 da91de73 00000000 d9916800 da91de34 da91de20 c014d9b8 c014d92c
[ 2467.097453] de20: 00000000 c01659c8 da91de64 da91de38 c0b4b7fc c014d99c d9916800 00000000
[ 2467.105637] de40: d6412850 da91de73 00000001 746d9f0c c1104c48 da91de73 da91de9c da91de68
[ 2467.113822] de60: c0b4b904 c0b4b7b4 00000000 c0b6ba9c 0014d504 746d9f0c d6412840 d6412850
[ 2467.122006] de80: d9916800 00000100 00000000 c11c5130 da91debc da91dea0 c0b4b99c c0b4b86c
[ 2467.130190] dea0: d6412840 c11bc858 c12332ac 00000100 da91dee4 da91dec0 c0b4b5ac c0b4b984
[ 2467.138374] dec0: 5f637aff c089b2f8 c11bc87c d55fe480 db57a100 db57d200 da91def4 da91dee8
[ 2467.146558] dee0: c0b4b6a0 c0b4b570 da91df34 da91def8 c0144e44 c0b4b690 daa1d780 da91c000
[ 2467.154742] df00: da91df1c 00000000 c0146eb4 d55fe480 db57a100 d55fe494 00000008 c1103d00
[ 2467.162926] df20: db57a118 da91c000 da91df74 da91df38 c01462dc c0144c98 da91c000 c0e57f04
[ 2467.171110] df40: c11c4979 db57a100 c014b53c d6286fc0 d6412f80 00000000 da91c000 d55fe480
[ 2467.179294] df60: d6286fdc dab43e74 da91dfac da91df78 c014ba34 c0146290 ffffe000 c0146284
[ 2467.187477] df80: da91dfac d6412f80 c014b8f8 00000000 00000000 00000000 00000000 00000000
[ 2467.195661] dfa0: 00000000 da91dfb0 c01010e8 c014b904 00000000 00000000 00000000 00000000
[ 2467.203844] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2467.212028] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[ 2467.220204] Backtrace: 
[ 2467.222661] [<c09f5dc0>] (dsa_switch_event) from [<c014d504>] (notifier_call_chain+0x54/0x94)
[ 2467.231194]  r10:c1104c48 r9:c09f52b4 r8:00000000 r7:00000000 r6:00000005 r5:da91dd3c
[ 2467.239025]  r4:ffffffff
[ 2467.241562] [<c014d4b0>] (notifier_call_chain) from [<c014d664>] (raw_notifier_call_chain+0x28/0x30)
[ 2467.250701]  r9:c09f52b4 r8:c09f3bb4 r7:00000000 r6:d9916800 r5:da91de38 r4:c1104c48
[ 2467.258451] [<c014d63c>] (raw_notifier_call_chain) from [<c09f32c8>] (dsa_port_mdb_add+0x58/0x84)
[ 2467.267332] [<c09f3270>] (dsa_port_mdb_add) from [<c09f5310>] (dsa_slave_port_obj_add+0x5c/0x78)
[ 2467.276120]  r4:00000000
[ 2467.278660] [<c09f52b4>] (dsa_slave_port_obj_add) from [<c0b4bb48>] (__switchdev_handle_port_obj_add+0xd8/0xec)
[ 2467.288758] [<c0b4ba70>] (__switchdev_handle_port_obj_add) from [<c0b4bb74>] (switchdev_handle_port_obj_add+0x18/0x24)
[ 2467.299460]  r10:db57d205 r9:00000000 r8:00000000 r7:00000000 r6:00000006 r5:da91de38
[ 2467.307291]  r4:ffffffff
[ 2467.309830] [<c0b4bb5c>] (switchdev_handle_port_obj_add) from [<c09f513c>] (dsa_slave_switchdev_blocking_event+0x50/0xb0)
[ 2467.320795] [<c09f50ec>] (dsa_slave_switchdev_blocking_event) from [<c014d504>] (notifier_call_chain+0x54/0x94)
[ 2467.330891] [<c014d4b0>] (notifier_call_chain) from [<c014d978>] (__blocking_notifier_call_chain+0x58/0x70)
[ 2467.340638]  r9:00000000 r8:d6412850 r7:ffffffff r6:da91de38 r5:c11bc860 r4:00000006
[ 2467.348389] [<c014d920>] (__blocking_notifier_call_chain) from [<c014d9b8>] (blocking_notifier_call_chain+0x28/0x30)
[ 2467.358916]  r7:d9916800 r6:00000000 r5:da91de73 r4:c1104c48
[ 2467.364581] [<c014d990>] (blocking_notifier_call_chain) from [<c0b4b7fc>] (switchdev_port_obj_notify+0x54/0xb8)
[ 2467.374678] [<c0b4b7a8>] (switchdev_port_obj_notify) from [<c0b4b904>] (switchdev_port_obj_add_now+0xa4/0x118)
[ 2467.384682]  r5:da91de73 r4:c1104c48
[ 2467.388262] [<c0b4b860>] (switchdev_port_obj_add_now) from [<c0b4b99c>] (switchdev_port_obj_add_deferred+0x24/0x70)
[ 2467.398706]  r9:c11c5130 r8:00000000 r7:00000100 r6:d9916800 r5:d6412850 r4:d6412840
[ 2467.406457] [<c0b4b978>] (switchdev_port_obj_add_deferred) from [<c0b4b5ac>] (switchdev_deferred_process+0x48/0x120)
[ 2467.416985]  r7:00000100 r6:c12332ac r5:c11bc858 r4:d6412840
[ 2467.422651] [<c0b4b564>] (switchdev_deferred_process) from [<c0b4b6a0>] (switchdev_deferred_process_work+0x1c/0x24)
[ 2467.433092]  r7:db57d200 r6:db57a100 r5:d55fe480 r4:c11bc87c
[ 2467.438757] [<c0b4b684>] (switchdev_deferred_process_work) from [<c0144e44>] (process_one_work+0x1b8/0x4b4)
[ 2467.448507] [<c0144c8c>] (process_one_work) from [<c01462dc>] (worker_thread+0x58/0x568)
[ 2467.456604]  r10:da91c000 r9:db57a118 r8:c1103d00 r7:00000008 r6:d55fe494 r5:db57a100
[ 2467.464435]  r4:d55fe480
[ 2467.466972] [<c0146284>] (worker_thread) from [<c014ba34>] (kthread+0x13c/0x16c)
[ 2467.474376]  r10:dab43e74 r9:d6286fdc r8:d55fe480 r7:da91c000 r6:00000000 r5:d6412f80
[ 2467.482207]  r4:d6286fc0
[ 2467.484744] [<c014b8f8>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[ 2467.491968] Exception stack(0xda91dfb0 to 0xda91dff8)
[ 2467.497021] dfa0:                                     00000000 00000000 00000000 00000000
[ 2467.505205] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2467.513387] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 2467.520004]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c014b8f8
[ 2467.527835]  r4:d6412f80
[ 2467.530369] Code: bad PC value
[ 2467.533719] ---[ end trace 70e4c4ee51ee3b9e ]---

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2466.889362] Internal error: Oops: 80000005 [#1] SMP ARM

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2466.988444] Process kworker/0:2 (pid: 1065, stack limit = 0xb6601ec8)

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2466.994886] Stack: (0xda91dcb0 to 0xda91e000)

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2466.999245] dca0:                                     0000001f 00000010 da91dce4 c1104c48

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.007429] dcc0: c06d4160 746d9f0c daffd000 ffffffff da91dd3c 00000005 00000000 00000000

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.015613] dce0: c09f52b4 c1104c48 da91dd1c da91dcf8 c014d504 c09f5dcc c1104c48 da91de38

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.023798] dd00: d9916800 00000000 c09f3bb4 c09f52b4 da91dd34 da91dd20 c014d664 c014d4bc

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.031982] dd20: 00000000 cb0a5035 da91dd64 da91dd38 c09f32c8 c014d648 7faf215d d6412850

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.040166] dd40: da91de73 00000000 00000006 746d9f0c da91ddb4 00000000 da91dd74 da91dd68

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.048350] dd60: c09f5310 c09f327c da91ddac da91dd78 c0b4bb48 c09f52c0 00000001 746d9f0c

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.056534] dd80: 00000390 ffffffff da91de38 00000006 00000000 00000000 00000000 db57d205

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.064718] dda0: da91ddbc da91ddb0 c0b4bb74 c0b4ba7c da91ddcc da91ddc0 c09f513c c0b4bb68

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.072902] ddc0: da91ddf4 da91ddd0 c014d504 c09f50f8 00000006 c11bc860 da91de38 ffffffff

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.081086] dde0: d6412850 00000000 da91de1c da91ddf8 c014d978 c014d4bc 00000000 746d9f0c

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.089269] de00: c1104c48 da91de73 00000000 d9916800 da91de34 da91de20 c014d9b8 c014d92c

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.097453] de20: 00000000 c01659c8 da91de64 da91de38 c0b4b7fc c014d99c d9916800 00000000

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.105637] de40: d6412850 da91de73 00000001 746d9f0c c1104c48 da91de73 da91de9c da91de68

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.113822] de60: c0b4b904 c0b4b7b4 00000000 c0b6ba9c 0014d504 746d9f0c d6412840 d6412850

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.122006] de80: d9916800 00000100 00000000 c11c5130 da91debc da91dea0 c0b4b99c c0b4b86c

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.130190] dea0: d6412840 c11bc858 c12332ac 00000100 da91dee4 da91dec0 c0b4b5ac c0b4b984

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.138374] dec0: 5f637aff c089b2f8 c11bc87c d55fe480 db57a100 db57d200 da91def4 da91dee8

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.146558] dee0: c0b4b6a0 c0b4b570 da91df34 da91def8 c0144e44 c0b4b690 daa1d780 da91c000

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.154742] df00: da91df1c 00000000 c0146eb4 d55fe480 db57a100 d55fe494 00000008 c1103d00

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.162926] df20: db57a118 da91c000 da91df74 da91df38 c01462dc c0144c98 da91c000 c0e57f04

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.171110] df40: c11c4979 db57a100 c014b53c d6286fc0 d6412f80 00000000 da91c000 d55fe480

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.179294] df60: d6286fdc dab43e74 da91dfac da91df78 c014ba34 c0146290 ffffe000 c0146284

Message from syslogd@bpi-r2 at Aug 24 21:03:59 ...
 kernel:[ 2467.187477] df80: da91dfac d6412f80 c014b8f8 000

It seems to be the mdb-issue from 5.3-rc1 - rc4+

To fix it make cherry-pick mentioned here:

Problem with NAT/ip_forward

it is strange that you get it, because i have added the fix some days ago to 5.3-rc

@cioby23 is it now working with rc6 and fixed build.sh?

Yes a did a new rebuild yesterday late night with rc6 and that crash does not appear anymore after connecting a cable to one of the LAN ports (br0). I saw DHCP is working fine and I received IP address on PC behind BPI-R2 but I stiil need to setup NAT. I’m using firewalld and later today I’ll try to setup masquerading and do some speed tests.

What is the default wan interface for 5.3-rc image ? I thought it was eth1 but I cannot see any eth1 interface available. I see the wan interface is bound to eth0.

Right now i’m using DHCP on wan interface I’m trying to setup pppoe on wan but it seems it does not work when using pppoeconf tool on Debian.

Below is the list of the interfaces

ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defau0
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP g0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::e475:9ff:fe46:d5d9/64 scope link 
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
4: wan@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.146/24 brd 192.168.1.255 scope global dynamic wan
       valid_lft 82744sec preferred_lft 82744sec
    inet6 fe80::e475:9ff:fe46:d5d9/64 scope link 
       valid_lft forever preferred_lft forever
5: lan0@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
9: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 s0
    link/ether f8:62:aa:50:16:10 brd ff:ff:ff:ff:ff:ff
10: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP grou0
    link/ether e6:75:09:46:d5:d9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.40.1/24 brd 192.168.40.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::e475:9ff:fe46:d5d9/64 scope link 
       valid_lft forever preferred_lft forever
20: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast s0
    link/none 
    inet 172.31.31.1/24 brd 172.31.31.255 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::1d25:8055:949:edd5/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever

eth1 is second gmac, which is only available if patches for second gmac are applied (4.19). i have not ported them because phylink-patches also using second gmac (renaming eth1 to wan) but with right setup.

so wan is connected to first gmac as it is displayed in “ip a” (wan@eth0)

have you set eth0 to up before configure wan to dhcp? you can try it manually by ip-tool and running “dhclient wan”

Right now my BPI-R2 wan port is connected behind other TP-link gigabit router and it receives DHCP on wan port from TP-link.

I want to get rid of the TP-link router and connect the PPPoE line directly into the BPI-R2 wan port.

This is the config I have in the interfaces file on Debian. Right now the PPP options are commented

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth1
iface eth1 inet manual
#auto dsl-provider
#iface dsl-provider inet ppp
#pre-up ip link set eth1 up
#provider dsl-provider

auto br0
iface br0 inet static
    address 192.168.40.1
    netmask 255.255.255.0
    bridge_ports lan0 lan1 lan2 lan3 wlan0
    bridge_fd 5
    bridge_stp no

so your dhcp works (currently with your old router),right?

I have also pppoe running on wan,but with 2 vlan (but before i had 1 directly on wan). I suggest using a lts-kernel and setup well configured (whitelisting) iptables before using r2 directly on public internet!

if you have no second gmac you need to drop eth1 block (it will cause a hang on “raise network interfaces”) and change dsl-provider interface (also in /etc/ppp/peers) to wan instead of ethx

Yes DHCP works on old router. RIght now it a kind of double NAT setup.

TP-link WAN (public IP from PPPoE) —> Lan port on TP connected to WAN port on BPI-R2 —>Lan port on BPI-R2 connected to local PC.

I will remove eth1 interface config and update the dsl-provider file with the correct wan interface.

I have managed to setup the PPPoE connection on BPI-R2 router and it connected successfully (kernel 5.3-rc)

After running some speedtests I saw the maximum I can get on the BPI-R2 box is around 170Mbps download compared with the old TP-link router which can reach around 450Mbps (using DD-WRT).

I think the BPI-R2 limitations comes from missing HNAT support. The TPlink device has some hardware NAT implemented using SFE (shortcut forwarding engine)

I have an 500Mbps (download) / 250Mbps (upload) connection.

Can you try same with phylink?

This 5.3-rc kernel has phylink branch merged into it

UPDATE: run similar speed test on kernel 4.14.140 and I saw some improvements compared to 5.3-rc + phylink.

I did the tests initially without HNAT enabled and then loaded the mtkhnat module but no difference was observed. Results were very similar.

For current hnat implementation there are some limitations…it does only work for traffic between wan+lan (nat on wan,lan on lan-ports). Most use-cases like nat on pppx or briged lan-ports are skipping hnat.

HNAT support for anything else except standard IPoE might be tricky/unsupported as it requires HW switching/forwarding engine to be either flexible enough so it is possible to configure it to deal with encapsulating protocol implementation (i.e. how to extract IP frames from PPP encapsulated into ethernet frames, how to create encapsulated PPPoE frames for outgres, e.t.c.) or HW engine should have support built in for some specific protocols. I’m not so sure about R2’s HW NAT actual capabilities but implementation code I’ve seen for it (both older one for 4.14 and recent one that was backported to 4.14 by OpenWRT team) are not “smart” enough to support PPPoE. Thus do not expect your internet throughput with R2 to match one you get with other device which has properly working vendor-shipped HW NAT driver with PPPoE support - like one you’ve get in your TP-link device.

R64 seems to support PPTP HNAT, https://github.com/BPI-SINOVOIP/BPI-R64-BSP/blob/master/proprietary_driver/net/nat/hw_nat/pptp_l2tp_fdb.c Maybe it’s also compatible with R2

you mean 4.14 is faster than 5.3-phylink also without hnat? 4.14 contains some network-tweaks from openwrt/lede, maybe these improve network-speed…

the main problem i saw in my network-tests: i can only transmit ~1Gbit/s (940Mbit/s) summarized when multiple clients connected, also with second gmac, maybe traffic also causes collisions (have not much clients for testing this)…tested with 2 simultanous iperf3-sessions on r2 going to 2 different clients. phylink has better performance than mainline-driver, but also only reaches ~1Gbit/s where at least using second gmac (lan+wan) or trgmii-mode (lan+lan) should bring additional speed

here are the Patches for 4.14 i had also applied to 4.14-branch (but imho squashed together while merging second gmac):

at least DQL,RDMA and RPS are not ported to 4.19 due to instability there. some if them i had tried to port here: https://github.com/frank-w/BPI-R2-4.14/commits/4.19-gmac...these are merged to 4.19-main: https://github.com/frank-w/BPI-R2-4.14/commits/4.19-main?after=11c8a1bd2f229b114fff29ec7839422567651f39+69&author=frank-w

found an old commit which also includes porting of RPS: https://github.com/frank-w/BPI-R2-4.14/commit/57f5c8eccbf7e0b070986e7bc0db1e821d542b49