Skip to content

ramips: add support for TP-Link Archer C5 v4#2174

Closed
dengqf6 wants to merge 4 commits intoopenwrt:masterfrom
dengqf6:c5v4
Closed

ramips: add support for TP-Link Archer C5 v4#2174
dengqf6 wants to merge 4 commits intoopenwrt:masterfrom
dengqf6:c5v4

Conversation

@dengqf6
Copy link
Copy Markdown

@dengqf6 dengqf6 commented Jun 28, 2019

TP-Link Archer C5 v4 is a dual band router with 5 GbE ports
Advertised as AC1200 for its 867Mbps (2×2) 5GHz band and 300 Mbps (2×2) 2.4GHz band.

Specs:

  • SoC: MediaTek MT7620A
  • Ethernet: 5 GbE ports (Realtek RTL8367S)
  • Wireless 2.4GHz: MediaTek MT7620A
  • Wireless 5GHz: MediaTek MT7612E
  • RAM: 64MiB
  • ROM: 8MiB (GD25Q64CSIG)
  • 1 USB 2.0 port
  • 2 Buttons (WPS and reset)
  • 8 LEDs

Flash instructions:
Currently one has to install OpenWrt only via the serial console

  1. Rename the factory.bin to to test.bin
  2. start a TFTP server from IP address 192.168.0.225 and serve the image named test.bin
  3. connect your device to the LAN port
  4. power up the router and press 4 on the console to stop the boot process.
  5. enter the following commands on the router console
tftp 0x80060000 test.bin
erase tplink 0x20000 0x7a0000
cp.b 0x80060000 0x20000 0x7a0000
reset

This PR includes the RTL8367S driver from mailing list
The TPLINK_HWID TPLINK_HWREV TPLINK_HWREVADD are dummy values. TP-Link seem s to use an RSA signed header for the stock firmware.

@dengqf6
Copy link
Copy Markdown
Author

dengqf6 commented Jun 28, 2019

@benwht

@981213
Copy link
Copy Markdown
Member

981213 commented Jun 28, 2019

Please don't patch the entire realtek switch SDK into openwrt tree. We only need to set up VLAN and there is nothing else useful.

@dengqf6
Copy link
Copy Markdown
Author

dengqf6 commented Jun 28, 2019

@981213
I know. That's why I mark this PR as "DO NOT MERGE". I'm seeking a better solution.

@981213
Copy link
Copy Markdown
Member

981213 commented Jun 28, 2019

Leaked datasheet here, which may be helpful :)
https://github.com/libc0607/Realtek_switch_hacking/blob/files/RTL8367S-CG_Datasheet.pdf

edit: BTW there are some other interesting documentations in this repo.

@981213
Copy link
Copy Markdown
Member

981213 commented Jun 28, 2019

This PR also adds RTL8367S driver for it. But I wonder if the driver for RTL8366S/RB can be reused

RTL8367S is configured using MDIO bus, and currently supported realtek switches are configured using their own SMI protocol. I don't know if the register arrangement are similar but you'll at least need to add a different register accessing method and probing mechanism.

@ynezz ynezz added the target/ramips pull request/issue for ramips target label Jun 28, 2019
@adschm
Copy link
Copy Markdown
Member

adschm commented Jul 10, 2019

There has been a reorganization in ramips target today. Please:

  • update your board.d subfiles since they have been re-sorted
  • update your Makefile (mt****/rt****.mk) changes so sorting of devices is correct
  • rename your DTS/DTSI files following the scheme soc_vendor_device.dts(i), e.g. mt7620a_tplink_archer-c50-v1.dts (and update includes there if necessary)
  • remove DTS := ... from Makefile
  • add MTK_SOC to Makefile (needs to match "soc" in DTS file name), e.g. MTK_SOC := mt7620a

Thank you!

Note that this in particular will require naming the device tplink_archer-c5-v4 / tplink,archer-c5-v4 in your case.

@CodeFetch
Copy link
Copy Markdown
Contributor

What a crappy driver for a crappy chip...

@CodeFetch
Copy link
Copy Markdown
Contributor

But I wonder if the driver for RTL8366S/RB can be reused

I don't expect that. There are some differences. It could work for your device, but that doesn't mean it works for others.

Does it work in the current state at all? I expect that it wouldn't compile.
If yes, first try to put all the code into a single file and remove all the parts that are unnecessary as 981213 suggested (QoS etc. and the Realtek-specific interfaces). So that you have a better overview of the implementation. If it still compiles and works as expected, try to add it to the existing RTL8367 module if possible.

@dengqf6 dengqf6 force-pushed the c5v4 branch 3 times, most recently from d13b3d2 to 5654a47 Compare August 16, 2019 14:43
@dengqf6 dengqf6 changed the title [RFC][DO NOT MERGE] ramips: add support for TP-Link Archer C5 v4 ramips: add support for TP-Link Archer C5 v4 Aug 16, 2019
@dengqf6
Copy link
Copy Markdown
Author

dengqf6 commented Aug 16, 2019

@981213 @CodeFetch
Adapted RTL8367S driver from mailing list. Tested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation is wrong here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation is wrong here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

better use dev_info()
and it's "checking chip_num..."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please add curly braces or remove newline after "else" and remove one level of indentation to make it more readable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove space after "(" and add space after if

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add space after if

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong indentation. use 3 spaces instead of 4 and tabs before values

@981213
Copy link
Copy Markdown
Member

981213 commented Aug 17, 2019

@CodeFetch Would you mind sending your review to the original patch on mailing list? @dengqf6 just picked those patches here.

@CodeFetch
Copy link
Copy Markdown
Contributor

@dengqf6 If you don't do the review process for these patches, please remove them from the PR and make clear that this is blocked.

@981213 Please add a blocked label.

@dengqf6 dengqf6 changed the title ramips: add support for TP-Link Archer C5 v4 [DO NOT MERGE] ramips: add support for TP-Link Archer C5 v4 Aug 18, 2019
@dengqf6 dengqf6 changed the title [DO NOT MERGE] ramips: add support for TP-Link Archer C5 v4 ramips: add support for TP-Link Archer C5 v4 Aug 26, 2019
@dengqf6
Copy link
Copy Markdown
Author

dengqf6 commented Aug 26, 2019

@CodeFetch As he did not reply to the mailing list, I fixed the code format myself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer putting the dev_info() before the if so this message will always be printed and remove the double-curly-braces and write

} else switch(...) {
(...)
}

instead. This is rare, but clean C-formatting as far as I know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By the way there is currently one level of indentation missing in the switch statement

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@dengqf6 dengqf6 force-pushed the c5v4 branch 2 times, most recently from a9e28e3 to 9036027 Compare August 27, 2019 12:44
@leonardcoutinho
Copy link
Copy Markdown

Can you try building my staging tree with this device and report back on how wifi performance changes?

I can't test with C5 v4 right now, but I will test your code with my Dir810l with has same slow speed with 2.4g(and same Soc).

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Sep 30, 2020

Could someone test this version in my staging tree for me?
https://git.openwrt.org/?p=openwrt/staging/981213.git;a=shortlog;h=refs/heads/tp-ac5-v4

I changed the rtl8367 driver to match chip_num only if dt compatible string is realtek,rtl8367c and fixed code style issues. But I don't have any device to test that.

edit: I've just fixed a dt property error in dts.

It works as before.

Can you try building my staging tree with this device and report back on how wifi performance changes?

I rebased @981213 branch over @dangowrt (check it here luizluca/openwrt@68b2f84). It still works but 2.5Ghz is still the same. First iperf3 runs is using 2.5Ghz to a wired target, the second one uses 5Ghz.

 $ iperf3 -c 192.168.3.20
Connecting to host 192.168.3.20, port 5201
[  5] local 192.168.3.99 port 43216 connected to 192.168.3.20 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  4.26 MBytes  35.6 Mbits/sec    0   1.40 MBytes
[  5]   1.00-2.00   sec  1.25 MBytes  10.5 Mbits/sec    0   2.54 MBytes
[  5]   2.00-3.00   sec  0.00 Bytes  0.00 bits/sec    0   3.23 MBytes
[  5]   3.00-4.00   sec  1.25 MBytes  10.5 Mbits/sec    0   3.24 MBytes
[  5]   4.00-5.00   sec  2.50 MBytes  21.0 Mbits/sec    0   3.24 MBytes
[  5]   5.00-6.00   sec  0.00 Bytes  0.00 bits/sec    0   3.24 MBytes
[  5]   6.00-7.00   sec  1.25 MBytes  10.5 Mbits/sec    0   3.24 MBytes
[  5]   7.00-8.00   sec  1.25 MBytes  10.5 Mbits/sec    0   3.24 MBytes
[  5]   8.00-9.00   sec  1.25 MBytes  10.5 Mbits/sec    0   3.24 MBytes
[  5]   9.00-10.00  sec  1.25 MBytes  10.5 Mbits/sec    0   3.24 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  14.3 MBytes  12.0 Mbits/sec    0             sender
[  5]   0.00-11.34  sec  12.9 MBytes  9.57 Mbits/sec                  receiver

iperf Done.
$ iperf3 -c 192.168.3.20
Connecting to host 192.168.3.20, port 5201
[  5] local 192.168.3.26 port 42698 connected to 192.168.3.20 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  15.6 MBytes   131 Mbits/sec  150    225 KBytes
[  5]   1.00-2.00   sec  12.3 MBytes   103 Mbits/sec   46    209 KBytes
[  5]   2.00-3.00   sec  16.0 MBytes   134 Mbits/sec   22    525 KBytes
[  5]   3.00-4.00   sec  16.0 MBytes   135 Mbits/sec  205    321 KBytes
[  5]   4.00-5.00   sec  16.1 MBytes   135 Mbits/sec  203    253 KBytes
[  5]   5.00-6.00   sec  21.1 MBytes   177 Mbits/sec    0    840 KBytes
[  5]   6.00-7.00   sec  21.2 MBytes   178 Mbits/sec  261    694 KBytes
[  5]   7.00-8.00   sec  20.0 MBytes   168 Mbits/sec  279    494 KBytes
[  5]   8.00-9.00   sec  21.2 MBytes   178 Mbits/sec  127    389 KBytes
[  5]   9.00-10.00  sec  20.0 MBytes   168 Mbits/sec    0    795 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   180 MBytes   151 Mbits/sec  1293             sender
[  5]   0.00-10.05  sec   177 MBytes   148 Mbits/sec                  receiver

iperf Done.

@hmh
Copy link
Copy Markdown
Contributor

hmh commented Oct 1, 2020

rtl8369 is the wired port switch, so maybe it is the wired performance (not wifi) that needs to be looked at ? Could you guys test it, please ?

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Oct 1, 2020

rtl8369 is the wired port switch, so maybe it is the wired performance (not wifi) that needs to be looked at ? Could you guys test it, please ?

It might have some wired limitations but the performance improves from 10 to more than 150 Mbps simply changing from 2.5Ghz to 5Ghz.

@leonardcoutinho
Copy link
Copy Markdown

rtl8369 is the wired port switch, so maybe it is the wired performance (not wifi) that needs to be looked at ? Could you guys test it, please ?

Last time I tested, I can reach 300mbit in wired internet using pppoe. Wired switch speed is not an problem I think.

@leonardcoutinho
Copy link
Copy Markdown

Can you try building my staging tree with this device and report back on how wifi performance changes?

I can't test with C5 v4 right now, but I will test your code with my Dir810l with has same slow speed with 2.4g(and same Soc).

I tested with 810l and have same speed as before. I will leave it conected to see if is more stable than before.

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Oct 1, 2020

Could someone test this version in my staging tree for me?
https://git.openwrt.org/?p=openwrt/staging/981213.git;a=shortlog;h=refs/heads/tp-ac5-v4

I changed the rtl8367 driver to match chip_num only if dt compatible string is realtek,rtl8367c and fixed code style issues. But I don't have any device to test that.

edit: I've just fixed a dt property error in dts.

@981213 , is your branch good enough for merge?

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Oct 20, 2020

Hello,

My installation (based on luizluca/openwrt@68b2f84) is crashing once each day or two. It might be more if it reboots by itself although there is no /sys/kernel/debug/crashlog (if it supports it).
It's a OOM error which brings wireless down (wired is still working). However, I'm using it with bare snapshot package selection (no luci) and it is working as an pure AP (no dhcp, no NAT). There is no reason for OOM and it might be a memory leak.

[   32.796625] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-2: link becomes ready
[43418.371616] odhcpd invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
[43418.381358] CPU: 0 PID: 1055 Comm: odhcpd Not tainted 5.4.68 #0
[43418.387546] Stack : 805b0000 8054e788 00000000 00000000 8054d958 83763c04 83d5db5c 80581ce3
[43418.396120]         804fbb8c 0000041f 806e33bc 805aa034 000000dc 00000001 83763bb8 afd02e63
[43418.404658]         00000000 00000000 80710000 00000000 00000030 000000e8 342e3520 2038362e
[43418.413203]         00000000 00000870 00000000 0005d1ae 80000000 83763d44 83e75860 00000000
[43418.421820]         00000000 805aa034 000000dc 00100cca 00000002 80288558 00000000 806e0000
[43418.430438]         ...
[43418.432957] Call Trace:
[43418.435489] [<80009d60>] show_stack+0x30/0x100
[43418.440051] [<800d0cc8>] dump_header+0x60/0x1f4
[43418.444686] [<800d1764>] oom_kill_process+0x178/0x180
[43418.449853] [<800d1f18>] out_of_memory+0x220/0x348
[43418.454768] [<80110dcc>] __alloc_pages_nodemask+0x960/0xcb8
[43418.460466] [<800cbf9c>] pagecache_get_page+0x148/0x3f8
[43418.465905] [<800ccea0>] filemap_fault+0x514/0x9a0
[43418.470836] [<800f7880>] __do_fault+0x3c/0x154
[43418.475387] [<800fc5c4>] handle_mm_fault+0x7c0/0xd00
[43418.480537] [<800107d4>] do_page_fault+0x114/0x52c
[43418.485465] [<800161bc>] tlb_do_page_fault_0+0x10c/0x114
[43418.490895] Mem-Info:
[43418.493236] active_anon:319 inactive_anon:4 isolated_anon:0
[43418.493236]  active_file:92 inactive_file:128 isolated_file:0
[43418.493236]  unevictable:0 dirty:0 writeback:0 unstable:0
[43418.493236]  slab_reclaimable:180 slab_unreclaimable:1959
[43418.493236]  mapped:10 shmem:18 pagetables:58 bounce:0
[43418.493236]  free:2848 free_pcp:15 free_cma:0
[43418.525506] Node 0 active_anon:1276kB inactive_anon:16kB active_file:368kB inactive_file:512kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:40kB dirty:0kB writeback:0kB shmem:72kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
[43418.548049] Normal free:11392kB min:12288kB low:14336kB high:16384kB active_anon:1276kB inactive_anon:16kB active_file:368kB inactive_file:512kB unevictable:0kB writepending:0kB present:65536kB managed:58788kB mlocked:0kB kernel_stack:312kB pagetables:232kB bounce:0kB free_pcp:60kB local_pcp:60kB free_cma:0kB
[43418.576071] lowmem_reserve[]: 0 0
[43418.579485] Normal: 166*4kB (UME) 65*8kB (UME) 96*16kB (UME) 31*32kB (UM) 16*64kB (ME) 12*128kB (M) 4*256kB (ME) 2*512kB (ME) 3*1024kB (ME) 0*2048kB 0*4096kB = 11392kB
[43418.594867] 238 total pagecache pages
[43418.598632] 0 pages in swap cache
[43418.602019] Swap cache stats: add 0, delete 0, find 0/0
[43418.607351] Free swap  = 0kB
[43418.610282] Total swap = 0kB
[43418.613224] 16384 pages RAM
[43418.616075] 0 pages HighMem/MovableOnly
[43418.619990] 1687 pages reserved
[43418.623196] Tasks state (memory values in pages):
[43418.628059] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[43418.636948] [    567]     0   567      314       19    20480        0             0 ubusd
[43418.645323] [    568]     0   568      235        9    16384        0             0 askfirst
[43418.653941] [    805]     0   805      316       33    20480        0             0 logd
[43418.662205] [    806]     0   806      350       22    16384        0             0 logread
[43418.670834] [    870]   453   870      349       24    20480        0             0 dnsmasq
[43418.679523] [    911]     0   911      287       12    12288        0             0 dropbear
[43418.688393] [    978]     0   978      877       53    20480        0             0 hostapd
[43418.697088] [    979]     0   979      852       26    16384        0             0 wpa_supplicant
[43418.706261] [   1021]     0  1021      446       41    16384        0             0 netifd
[43418.714702] [   1055]     0  1055      370       30    20480        0             0 odhcpd
[43418.723144] [   1294]     0  1294      267       14    16384        0             0 odhcp6c
[43418.731754] [   1310]     0  1310      313       12    12288        0             0 ntpd
[43418.740126] [   4166]     0  4166      113        1     4096        0             0 dhcpv6.script
[43418.749220] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),global_oom,task_memcg=/,task=hostapd,pid=978,uid=0
[43418.759831] Out of memory: Killed process 978 (hostapd) total-vm:3508kB, anon-rss:184kB, file-rss:28kB, shmem-rss:0kB, UID:0 pgtables:20kB oom_score_adj:0
[43418.776683] oom_reaper: reaped process 978 (hostapd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
[43419.400851] br-guest: port 2(wlan0-2) entered disabled state
[43419.672391] br-guest: port 2(wlan0-2) entered disabled state
[43419.954189] device wlan0-2 left promiscuous mode
[43419.958997] br-guest: port 2(wlan0-2) entered disabled state
[43420.055264] br-lan: port 3(wlan0-1) entered disabled state
[43420.474661] device wlan0-1 left promiscuous mode
[43420.479463] br-lan: port 3(wlan0-1) entered disabled state
[43420.658005] br-lan: port 2(wlan0) entered disabled state
[43455.021528] br-lan: port 2(wlan0) entered disabled state
[43455.436564] device wlan0 left promiscuous mode
[43455.441188] br-lan: port 2(wlan0) entered disabled state
[43498.380813] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration start
[43498.389619] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration end
[43500.702867] ieee80211 phy0: rt2800_loft_iq_calibration: Info - LOFT Calibration Done!
[43500.714837] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[43500.736136] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 0, (gain= 3, phase=3e)
[43500.746373] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[43500.767666] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 1, (gain= 0, phase=3b)
[43500.777016] ieee80211 phy0: rt2800_loft_iq_calibration: Info - TX IQ Calibration Done!
[43500.819309] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=0, Ph_rx=-7
[43500.837295] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=-2, Ph_rx=5
[43500.864111] br-lan: port 2(wlan0) entered blocking state
[43500.869599] br-lan: port 2(wlan0) entered disabled state
[43500.875440] device wlan0 entered promiscuous mode
[43501.216333] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[43501.223118] br-lan: port 2(wlan0) entered blocking state
[43501.228597] br-lan: port 2(wlan0) entered forwarding state
[43503.671980] br-lan: port 3(wlan0-1) entered blocking state
[43503.677680] br-lan: port 3(wlan0-1) entered disabled state
[43503.683719] device wlan0-1 entered promiscuous mode
[43503.771724] br-lan: port 3(wlan0-1) entered blocking state
[43503.777384] br-lan: port 3(wlan0-1) entered forwarding state
[43503.788484] br-lan: port 3(wlan0-1) entered disabled state
[43506.546007] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-1: link becomes ready
[43506.553006] br-lan: port 3(wlan0-1) entered blocking state
[43506.558661] br-lan: port 3(wlan0-1) entered forwarding state
[43511.748420] br-guest: port 2(wlan0-2) entered blocking state
[43511.754304] br-guest: port 2(wlan0-2) entered disabled state
[43511.760577] device wlan0-2 entered promiscuous mode
[43511.864295] br-guest: port 2(wlan0-2) entered blocking state
[43511.870133] br-guest: port 2(wlan0-2) entered forwarding state
[43511.879644] br-guest: port 2(wlan0-2) entered disabled state
[43511.888381] hostapd invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=0, oom_score_adj=0
[43511.898211] CPU: 0 PID: 4183 Comm: hostapd Not tainted 5.4.68 #0
[43511.904362] Stack : 805b0000 8054e788 00000000 00000000 8054d958 83975974 83e4eedc 80581ce3
[43511.913036]         804fbb8c 00001057 806e33bc 805aa034 0000034d 00000001 83975928 3a68be79
[43511.921655]         00000000 00000000 80710000 00000000 00000030 00000146 2e352064 38362e34
[43511.930214]         00000000 00000874 00000000 000db4a3 80000000 83975ab4 83e4ebe0 00000000
[43511.938752]         00000000 805aa034 0000034d 00040cc0 00000003 80288558 00000000 806e0000
[43511.947288]         ...
[43511.949780] Call Trace:
[43511.952307] [<80009d60>] show_stack+0x30/0x100
[43511.956869] [<800d0cc8>] dump_header+0x60/0x1f4
[43511.961572] [<800d1764>] oom_kill_process+0x178/0x180
[43511.966845] [<800d1f18>] out_of_memory+0x220/0x348
[43511.971787] [<80110dcc>] __alloc_pages_nodemask+0x960/0xcb8
[43511.977488] [<8011d3b4>] new_slab+0x2d8/0xcd4
[43511.981946] [<8011df4c>] ___slab_alloc.isra.97.constprop.102+0x19c/0x35c
[43511.988796] [<8011e12c>] __slab_alloc.isra.98.constprop.101+0x20/0x44
[43511.995388] [<8011ebcc>] __kmalloc+0x1fc/0x2a8
[43511.999957] [<8036587c>] genl_rcv_msg+0x47c/0x4cc
[43512.004859] [<80363bd0>] netlink_rcv_skb+0xac/0x158
[43512.009876] [<803643b0>] genl_rcv+0x30/0x48
[43512.014159] [<803632e4>] netlink_unicast+0x1b0/0x284
[43512.019239] [<803636a0>] netlink_sendmsg+0x2e8/0x3d0
[43512.024395] [<802f6a88>] ____sys_sendmsg+0xc0/0x264
[43512.029410] [<802f7398>] ___sys_sendmsg+0x7c/0xcc
[43512.034225] [<802f84c0>] __sys_sendmsg+0x4c/0x94
[43512.038950] [<8000e9cc>] syscall_common+0x34/0x58
[43512.043761] Mem-Info:
[43512.046095] active_anon:438 inactive_anon:4 isolated_anon:0
[43512.046095]  active_file:449 inactive_file:396 isolated_file:0
[43512.046095]  unevictable:0 dirty:0 writeback:0 unstable:0
[43512.046095]  slab_reclaimable:183 slab_unreclaimable:2001
[43512.046095]  mapped:318 shmem:18 pagetables:67 bounce:0
[43512.046095]  free:2100 free_pcp:0 free_cma:0
[43512.078513] Node 0 active_anon:1752kB inactive_anon:16kB active_file:1796kB inactive_file:1584kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:1272kB dirty:0kB writeback:0kB shmem:72kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
[43512.101346] Normal free:8400kB min:12288kB low:14336kB high:16384kB active_anon:1752kB inactive_anon:16kB active_file:1796kB inactive_file:1584kB unevictable:0kB writepending:0kB present:65536kB managed:58788kB mlocked:0kB kernel_stack:360kB pagetables:268kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[43512.129261] lowmem_reserve[]: 0 0
[43512.132674] Normal: 110*4kB (UME) 41*8kB (UM) 43*16kB (UM) 35*32kB (UM) 7*64kB (M) 2*128kB (M) 4*256kB (UM) 2*512kB (UM) 3*1024kB (UM) 0*2048kB 0*4096kB = 8400kB
[43512.147445] 863 total pagecache pages
[43512.151185] 0 pages in swap cache
[43512.154561] Swap cache stats: add 0, delete 0, find 0/0
[43512.159893] Free swap  = 0kB
[43512.162870] Total swap = 0kB
[43512.165816] 16384 pages RAM
[43512.168668] 0 pages HighMem/MovableOnly
[43512.172651] 1687 pages reserved
[43512.175877] Tasks state (memory values in pages):
[43512.180678] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[43512.189488] [    567]     0   567      314      126    20480        0             0 ubusd
[43512.197841] [    568]     0   568      235        9    16384        0             0 askfirst
[43512.206459] [    805]     0   805      316       85    20480        0             0 logd
[43512.214821] [    806]     0   806      350       22    16384        0             0 logread
[43512.223377] [    870]   453   870      349       24    20480        0             0 dnsmasq
[43512.231968] [    911]     0   911      287       12    12288        0             0 dropbear
[43512.240605] [    979]     0   979      852       25    16384        0             0 wpa_supplicant
[43512.249755] [   1021]     0  1021      446      156    16384        0             0 netifd
[43512.258196] [   1055]     0  1055      370      157    20480        0             0 odhcpd
[43512.266686] [   1294]     0  1294      267       21    16384        0             0 odhcp6c
[43512.275230] [   1310]     0  1310      313       12    12288        0             0 ntpd
[43512.283498] [   4183]     0  4183      877      279    24576        0             0 hostapd
[43512.292028] [   4217]     0  4217      407      109    20480        0             0 sh
[43512.300115] [   4349]     0  4349      348       20    20480        0             0 ubus
[43512.308374] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),global_oom,task_memcg=/,task=hostapd,pid=4183,uid=0
[43512.319144] Out of memory: Killed process 4183 (hostapd) total-vm:3508kB, anon-rss:156kB, file-rss:960kB, shmem-rss:0kB, UID:0 pgtables:24kB oom_score_adj:0
[43512.350143] oom_reaper: reaped process 4183 (hostapd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
[43513.700467] br-lan: port 3(wlan0-1) entered disabled state
[43514.403862] br-guest: port 2(wlan0-2) entered disabled state
[43514.412019] device wlan0-2 left promiscuous mode
[43514.416790] br-guest: port 2(wlan0-2) entered disabled state
[43514.428173] br-lan: port 3(wlan0-1) entered disabled state
[43514.696925] device wlan0-1 left promiscuous mode
[43514.701718] br-lan: port 3(wlan0-1) entered disabled state
[43514.786406] br-lan: port 2(wlan0) entered disabled state

Free tells me it has lots of used memory:

              total        used        free      shared  buff/cache   available
Mem:          58788       46156        9020          72        3612           0
Swap:             0           0           0

With only 14 userland processes (plus two shells started after the crash).

# cat /proc/*/status | grep VmRSS | awk '{ S+=$2} END { print S}'
12020

/proc/meminfo 
MemTotal:          58788 kB
MemFree:            9332 kB
MemAvailable:          0 kB
Buffers:            1252 kB
Cached:             2212 kB
SwapCached:            0 kB
Active:             3100 kB
Inactive:           1756 kB
Active(anon):       1448 kB
Inactive(anon):       16 kB
Active(file):       1652 kB
Inactive(file):     1740 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          1404 kB
Mapped:             1828 kB
Shmem:                72 kB
KReclaimable:        728 kB
Slab:               7872 kB
SReclaimable:        728 kB
SUnreclaim:         7144 kB
KernelStack:         344 kB
PageTables:          304 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       29392 kB
Committed_AS:       5596 kB
VmallocTotal:    1048372 kB
VmallocUsed:         596 kB
VmallocChunk:          0 kB
Percpu:               32 kB

I guess it is all in kernel space.

My build is more than 20 days old. Is there any known fix in master? Or could it be a side effect from using @981213 branch over @dangowrt?

edit: after the reboot, it is much cleaner:

              total        used        free      shared  buff/cache   available
Mem:          58788       16876       32080          76        9832       25516
Swap:             0           0           0

/proc/meminfo 
MemTotal:          58788 kB
MemFree:           31988 kB
MemAvailable:      25424 kB
Buffers:            2564 kB
Cached:             7268 kB
SwapCached:            0 kB
Active:             6956 kB
Inactive:           4224 kB
Active(anon):       1408 kB
Inactive(anon):       16 kB
Active(file):       5548 kB
Inactive(file):     4208 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          1356 kB
Mapped:             2956 kB
Shmem:                76 kB
KReclaimable:       1688 kB
Slab:               9580 kB
SReclaimable:       1688 kB
SUnreclaim:         7892 kB
KernelStack:         376 kB
PageTables:          276 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       29392 kB
Committed_AS:       5372 kB
VmallocTotal:    1048372 kB
VmallocUsed:         572 kB
VmallocChunk:          0 kB
Percpu:               64 kB

# cat /proc/*/status | grep VmRSS | awk '{ S+=$2} END { print S}'
19816

Userland is even using more memory than before.

@luizluca
Copy link
Copy Markdown
Contributor

Maybe it is now fixed: 08a42ef

I rebased it just now. Let's see how things go.

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Nov 4, 2020

Maybe it is now fixed: 08a42ef

I rebased it just now. Let's see how things go.

I don't know if that was 08a42ef but r14808+3-499924adf0 is working as expected (including the bad 2.5GHz performance). After 5 days, no significant change in memory usage:

              total        used        free      shared  buff/cache   available
Mem:          58784       17868       30620          72       10296       24388
Swap:             0           0           0

Anyway, the memory issue was not specific to this device.

2.5GHz will not be fixed in anytime soon and other already merged devices are also affected. Wouldn't it be better to merge as it is (PR or with @981213 fixes)? There are build being kept outside OpenWrt for this device. We could have that effort inside OpenWrt.

@hmh
Copy link
Copy Markdown
Contributor

hmh commented Nov 4, 2020

@luizluca: for the record, which devices also share the badly-supported 2.5GHz radio and were already merged?

I also agree this should not get in the way of this PR.

@leonardcoutinho
Copy link
Copy Markdown

I agree too, this is general mt7620a driver problem, not C5 V4 only.

@luizluca
Copy link
Copy Markdown
Contributor

luizluca commented Nov 5, 2020

@luizluca: for the record, which devices also share the badly-supported 2.5GHz radio and were already merged?

I'm just saying what has being commented in this PR. I guess all these are affected as they share the same SoC:
https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/image/mt7620.mk

@leonardcoutinho
Copy link
Copy Markdown

I try latest openwrt build in my D-link 810l to test wifi performance before flash my archer c5 v4, and wifi is much better than before, now it reach 100mbit in wifi 2.4ghz in both down and up speed. I will test it a few days more to see how it perform and see stability of kernel, then flash archer c5 later. Maybe c5 can't perform like 810l because some radio differences, but at least is not problem of mt7620 anymore.

@musashino205
Copy link
Copy Markdown
Contributor

Could someone test this version in my staging tree for me?
https://git.openwrt.org/?p=openwrt/staging/981213.git;a=shortlog;h=refs/heads/tp-ac5-v4

@981213 I tested on my WN-AC733GR3 (ramips/mt7620, RTL8367RB, RGMII on extif1), works without any issues.

@dengqf6
Copy link
Copy Markdown
Author

dengqf6 commented Feb 27, 2021

Because I no longer have this router, I'm closing this pull request.
Anyone who have one, feel free to continue my work.

@dengqf6 dengqf6 closed this Feb 27, 2021
@luizluca
Copy link
Copy Markdown
Contributor

I wonder why this was not merged. It won't break existing devices, it won't brick on install and it provides decent wired and 5GHz performance. The poor 2Ghz is not ideal but other devices are in master missing features while all features are implemented for this device. I tested it multiple times until everything just worked.

Thanks @dengqf6 for your work.

@luizluca
Copy link
Copy Markdown
Contributor

I'll try to take from here. It looks like af5a17d added support for rtl8367s.
If it works, it might simplify this PR.

@adschm
Copy link
Copy Markdown
Member

adschm commented Feb 27, 2021

I'll try to take from here. It looks like af5a17d added support for rtl8367s.

That's mediatek target, not ramips.

The only way to get anywhere with this PR is through @981213 ...

@luizluca
Copy link
Copy Markdown
Contributor

That's mediatek target, not ramips.

Isn't mediatek target simply the new ramips?

target/linux/ramips/mt7620
target/linux/ramips/mt7621
target/linux/mediatek/mt7622
target/linux/mediatek/mt7623
target/linux/mediatek/mt7629

The only way to get anywhere with this PR is through @981213 ...

If the get rid of the switch patches, the PR will only be a normal DTS/leds/makefile port. It would be much easier to get merged.

@luizluca
Copy link
Copy Markdown
Contributor

It looks like that same driver added by @blogic was already being used in 19.07.x port published in OpenWrt wiki (https://github.com/benwht/openwrt/commit/b57307fa1e498e9b82fe53cdcf58e6005a73baef.patch).

It should work.

@adschm
Copy link
Copy Markdown
Member

adschm commented Feb 28, 2021

If the get rid of the switch patches, the PR will only be a normal DTS/leds/makefile port. It would be much easier to get merged.

And who do you think will review porting the mediatek driver to ramips?

@981213
Copy link
Copy Markdown
Member

981213 commented Feb 28, 2021

That's mediatek target, not ramips.

Isn't mediatek target simply the new ramips?

It's not. ramips are for mediatek mips and former ralink socs. the mediatek target is for the new arm socs.

The only way to get anywhere with this PR is through @981213 ...

If the get rid of the switch patches, the PR will only be a normal DTS/leds/makefile port. It would be much easier to get merged.

That switch driver is still a bit scary for me to touch :(
If you want to continue working on it, would you mind to rebase my tree and throw the patches onto the mail list? I'd prefer getting more eyes on the switch driver before merging it.

@luizluca
Copy link
Copy Markdown
Contributor

That's mediatek target, not ramips.

Isn't mediatek target simply the new ramips?

It's not. ramips are for mediatek mips and former ralink socs. the mediatek target is for the new arm socs.

Thanks. Anyway, it looks like the same driver added for mediatek target is already in use for everyone that is currently using @benwht port for 19.07 (and even 18.06). If true, I could say it is in use for years.

That switch driver is still a bit scary for me to touch :(

It looks like rtl8367c or rtl8367s (I'm confused with cross-referencing between these two) is also needed for mediatek target mt7622. @blogic took a quick path and added a completely new driver specific for mediatek target and configured it as builtin. This PR was based on changes to rtl8367b driver (target/linux/generic) to also support rtl8367c. It looks like one option should go.

For a device perceptive, it should not matter which one is in use if they work as expected, specially when compiled as a module. I don't know which one costs less to maintain in OpenWrt tree but OpenWrt is already "paying" it for mediatek target. The resulting ipk for the standalone driver is 10x bigger, probably because it might not depend on other modules.

If you want to continue working on it, would you mind to rebase my tree and throw the patches onto the mail list? I'd prefer getting more eyes on the switch driver before merging it.

I don't feel comfortable to post a patch from someone else to mail list when I'm not sure that exactly it does. I'm a hobby kernel developer and I never touched switch drivers (yet). Eventually someone will suggest a change and I will not have the background to discuss it. The two options for rtl8367c support can be discussed between the big guys in a dedicated thread or PR.

This PR does work and it would cost nothing if accepted. However, it didn't get merged after 20 months. I'll try an alternative reusing the existing driver, probably migrating it from target/linux/mediatek to target/linux/generic and nobody needs to touch a single switch driver. I hope this clears the path for C5v4 to get merged.

This PR rebased just worked as expected.
My first try with the new driver failed, not loading switch0 (mt7620). Maybe I just messed with the DTS file while including the mt7620a_tplink_archer.dtsi file or it conflicted with existing modules. Here is dmesg difference:

--- this PR rebased
+++ using new rtl8367c driver
====
@@ -25,10 +25,10 @@
 ] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
 ] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
 ] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
-] Writing ErrCtl register=00000800
-] Readback ErrCtl register=00000800
+] Writing ErrCtl register=0000080c
+] Readback ErrCtl register=0000080c
 ] mem auto-init: stack:off, heap alloc:off, heap free:off
@@ -51,8 +51,12 @@
 ]   IO 0x0000000010160000..0x000000001016ffff
 ] rt2880_gpio 10000600.gpio: registering 24 gpios
 ] rt2880_gpio 10000600.gpio: registering 24 irq handlers
+] rt2880_gpio 10000638.gpio: registering 16 gpios
+] rt2880_gpio 10000638.gpio: registering 16 irq handlers
 ] rt2880_gpio 10000660.gpio: registering 32 gpios
 ] rt2880_gpio 10000660.gpio: registering 32 irq handlers
+] rt2880_gpio 10000688.gpio: registering 1 gpios
+] rt2880_gpio 10000688.gpio: registering 1 irq handlers
 ] PCI host bridge to bus 0000:00
@@ -107,28 +111,24 @@
 ] libphy: Fixed MDIO Bus: probed
-] gsw: setting port4 to ephy mode
-] libphy: mdio: probed
-] mtk_soc_eth 10100000.ethernet: using fixed link parameters
-] mtk_soc_eth 10100000.ethernet: loaded mt7620 driver
-] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
+] Error: Driver 'mtk_soc_eth' is already registered, aborting...
 ] rt2880_wdt 10000120.watchdog: Initialized
 ] NET: Registered protocol family 10
@@ -149,11 +149,6 @@
 ] hub 1-0:1.0: 1 port detected
-] rtl8367b rtl8367s: switch phy addr=29
-] rtl8367b rtl8367s: using MDIO bus 'mdio'
-] rtl8367b rtl8367s: RTL8367C chip found
-] rtl8367b rtl8367s: checking chip_num=0x6367 ver=0xa0...
-] libphy: rtl8367s: probed
 ] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
@@ -166,22 +161,12 @@
 ] random: jshn: uninitialized urandom read (4 bytes read)
-] rtl8367b rtl8367s: checking chip_num=0x6367 ver=0xa0...
-] mtk_soc_eth 10100000.ethernet eth0: port 5 link up (1000Mbps/Full duplex)
-] 8021q: adding VLAN 0 to HW filter on device eth0
 ] urandom_read: 4 callbacks suppressed
 ] ...
 ] random: procd: uninitialized urandom read (4 bytes read)
-] mtk_soc_eth 10100000.ethernet eth0: port 5 link down
+] urandom-seed: Seeding with /etc/urandom.seed
 ] procd: - early -
@@ -210,73 +195,57 @@
 ] random: crng init done
-] rtl8367b rtl8367s: checking chip_num=0x6367 ver=0xa0...
-] mtk_soc_eth 10100000.ethernet eth0: port 5 link up (1000Mbps/Full duplex)

Tomorrow I'll try to isolate the cause.

@luizluca
Copy link
Copy Markdown
Contributor

It looks like it is a conflict when I have kmod-switch-rtl8366-smi loaded. Without that, the driver does load. The new driver also changed the CPU port from 7 to 5. With some more DTS changes I got a running config.

I created a new PR based on that approach.

@namiltd
Copy link
Copy Markdown
Contributor

namiltd commented Jan 16, 2024

New wersions:
-version compatible with release 23.05: #14314
-version compatible with main branch: #14418

@luizluca
Copy link
Copy Markdown
Contributor

See #14418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs reviewer target/ramips pull request/issue for ramips target

Projects

None yet

Development

Successfully merging this pull request may close these issues.