Possible firmware issue on the BPI-R4 Pro switched-10Gbps port

I have a problem with the 10G LAN port of the BPI-R4 Pro 8X (lan-phy variant, i.e. the AS21010 RJ45 in front of MxL86252C port 13) and I would like to know if someone else see the same.

Frames received on this port are lost depending of the frame length modulo 16 (FCS included). Lengths of 10 and 14 mod 16 are fine. With 2 mod 16 it loses a bit, with 4, 5 and 6 mod 16 TCP collapses. It happens only when frames arrive back to back (UDP with gaps between packets is clean). No counter moves on the MxL (RMON of port 13, no FCS errors, no discards) or in the AS21010 debug counters.

The other end is a BPI-R4 with a SFP-10G-T module (BCM84891), 10GBASE-T, MTU 9000. Both run frank-w 7.3-main with some patches, AS21010 firmware 1.9.2 and MxL firmware 1.0.85. It is easy to reproduce from the R4 Pro with iperf3 in reverse mode, so the R4 sends:

iperf3 -c <R4> -R -M 1460
iperf3 -c <R4> -R -M 1452

The first one gives 1518 byte frames and ~3 Gbps with 3 retransmits. The second gives 1510 byte frames and ~310 Mbps with ~1000 retransmits in 8 s. With jumbo frames it is the same: MSS 8892 does 3-4 Gbps with 200 retransmits, MSS 8900 does 9.8 Gbps with 0-5. The other direction (R4 Pro sends) is clean at every size.

What I tried: the same cable and module on the WAN RJ45 of the R4 Pro (same AS21010 but connected directly to the SoC MAC) gives no loss at all. Port 13 in 10GBASE-R instead of USXGMII, so no rate adaptation in the AS21010, gives the same loss. So I think the problem is between the AS21010 and the port 13 receiver of the MxL, which are both firmware I can’t change.

Update: it is the AS21010, not the MxL.

I switched port 13 to the SFP cage (lan-sfp overlay, i.e. #ov-pro-8x-lan-sfp instead of #ov-pro-8x-lan-phy in the boot config) and put in it a SFP-10G-T (BCM84891) from one of my R4s. Same cable and same tests as above, and now every frame length is clean. MSS 1340 (1398 byte frames, the worst case before) does 2.8 Gbps with 0 retransmits and MSS 8906 does 9.5 Gbps with 0, where before it was 1.5-1.9 Gbps with a few thousands retransmits.

So the MxL port 13 receiver is fine. The frames are lost in what the AS21010 sends to it. The AS21010 on the WAN port feeds the SoC MAC directly and loses nothing. My guess is that the MxL is more strict about the gap between frames than the SoC MAC, however I can’t confirm this from here.

The AS21010 runs firmware 1.9.2, which is also the version in the MediaTek feed. Does anyone know if Aeonsemi has a newer one? For now I keep the backhaul on the SFP cage, which means the 10G RJ45 LAN port is not used.

Same here, I can confirm this on my BPI-R4 Pro 8X (lan-phy variant, 10G RJ45 LAN port = lan6).

Setup: OpenWrt SNAPSHOT r37907-0108a88ab5. The image ships as21x1x_fw.bin (no version in the file name, and the boot messages are already gone from dmesg) and mxl862xxc_1030_1085_1085_0069_signed_xfi_upgrade_fca.bin, so presumably MxL firmware 1.0.85 like yours. Link partner is a workstation with a Realtek RTL8127 (r8169, firmware rtl8127a-1_0.0.5) over ~50 m of installed copper. iperf3 server is my firewall, connected to the R4 Pro via SFP+ (10G). Traffic direction: workstation → R4 Pro, i.e. frames received on the RJ45 port.

iperf3 -M was rejected on my Linux client, so I set the frame size with a host route (ip route add /32 dev mtu lock 1492) instead.

Link Frame size Bitrate Retransmits (8 s)
10G 1518 1.69 Gbit/s 260
10G 1510 807 Mbit/s 10165
2.5G 1518 2.32 Gbit/s 4
2.5G 1510 822 Mbit/s 15541

So the frame-length issue is not tied to 10GBASE-T, it also happens at 2.5G. At 2.5G, 1518-byte frames run at line rate, while at 10G even those are not fully clean. During these runs rx_crc_errors on lan6 did not move at all, so the loss is silent, like in your case.

I also see a second, different problem on the same port: phases with visible CRC errors. rx_crc_errors on lan6 slowly starts to rise hours after a clean link-up, up to ~15/min, and then even small single UDP packets (DNS queries) get dropped (up to ~30% loss). “ethtool -r lan6” stops it immediately, until the next phase. MxL862xx temperature stays flat at 54-60 °C the whole time. After the last renegotiation the link was clean with the R4 Pro as slave (the workstation reports master), so in my case this does not seem to match the master/slave theory from the other thread. I don’t know yet which role it had during a bad phase.

The same cable worked fine with an SFP+ 10GBASE-T module on my old BPI-R4, so I don’t think it is the cable.

I also forced the roles: with the workstation set to forced-slave (so the R4 Pro is master), the frame-length issue is still there. 10G, 1518-byte frames: 3.29 Gbit/s, 3055 retransmits; 1510-byte frames: 1.04 Gbit/s, 16853 retransmits. So for this issue the master/slave role does not seem to matter.

Has anyone seen these CRC phases too, or found a newer AS21010 firmware?

Thanks, Oli. The AS21010 talks to the MxL over the same host interface at 2.5G so it fits with the problem being on that side.

About master/slave. All my mod 16 tests were done with the R4 Pro forced to master, so the length loss is not the role issue. Your CRC phases also look different and have not seen those here. With the slave role the loss is there from the link-up on, on about half of the link-ups, and no counter moves at all. Rising rx_crc_errors hours later is probably something else.

Coming back to master/slave. If you want to see the role during a bad phase without patch:

phytool read lan6/0x18:7/33

bit 14 set (0x4xxx) is master, clear is slave.

Forcing it is not in frank-w’s 7.3-main and I don’t know about OpenWrt. The stock as21xxx driver maps ethtool master-slave only to the 1000BASE-T register, so “ethtool -s lan6 master-slave forced-master” does not change the 10G or 2.5G role. I carry two patches for it in my own build: one wires ethtool master/slave to the 10GBASE-T control register, the other adds a force_master attribute on the PHY so it can be set at boot before the first autoneg:

echo 1 > /sys/bus/mdio_bus/devices/mdio-bus:18/force_master

After that the driver puts master back before every autoneg and restarts once if the link still comes up slave. The phytool write from the other thread works too but it is only a one-shot. Your workstation must stay on auto, if both sides force master there is no link.

Update 2: I found the issue and I think I fixed it. It took disassembling the AS21010 firmware… but at least it’s a one byte change :smile:.

TL;DR: firmware 1.9.2 sets a MAC field of the AS21010 (VEND1 0x103c bits 8:3) to 3 at 2.5G and above, and with 3 the MxL drops the frames. At 1G and below it uses 8. The script changes the 3 into 8 (file offset 0x20d6e, 0x8d → 0xa1) and checks the image before it touches it.

python3 as21x1x-fw-fix.py patch as21x1x_fw.bin as21x1x_fw-fixed.bin

as21x1x-fw-fix.py (14.5 KB)

On my R4 Pro every frame length is clean now, so tunnels with odd MTUs work without MSS clamping and UDP/QUIC through them is fine too (MSS 1340 went from 0.35 to 2.8 Gbps). Previously, with the stock firmware, uploads from behind the R4 collapsed when something downloaded at the same time (MSS 1460 0.3-0.4 Gbps, jumbo frames ~3 Gbps). With the patched firmware this is 2.5 Gbps and 7-8.5 Gbps (with 6-7 Gbps going the other way at the same time).

This is still a blind fix though done with AI help. I don’t know what the field really is or why Aeonsemi picked 3 (maybe it suits another switch?), and a patched binary is not something every user should have to make. A proper 1.9.3 would be the right way, so if your R4 Pro uses the RJ45 LAN port it is probably worth telling Banana Pi or Aeonsemi that you see this too.

2 Likes

Good detective work. The 0x103c field changing 3→8 at the speed boundary looks like a MAC timing/IFG setting rather than a data-path bug; if so, 8 may just be above the MxL’s tolerance. I’d test intermediate values (4–7) and cold boots/autoneg cycles before calling it safe, and compare the WAN AS21010’s readback—it may also use 3 but feed a more tolerant SoC MAC. That would help separate a real fix from a lucky value.

Save your tokens man. No human randomly guesses a byte to flip in a 2MB binary. I tested all that. Better use would be to ask for a new firmware from BPI/Aeonsemi.

@meehien great find, and I can confirm it on firmware 1.9.1 as well (the one in linux-firmware, AS21010 at 10G, R4 Pro is master).

VEND1 0x103c reads 0xa01e here, so bits 8:3 are 3, same as on your 1.9.2. Instead of patching the binary I wrote the field at runtime with mdio-tools (read-modify-write, only bits 8:3 changed):

mdio mdio-bus mmd 0x18:30 raw 0x103c 0xa046

Side note for anyone reading C45 registers with mdio-tools on this board: every read returns the value of the previous read, so read twice and take the second value.

UDP, workstation → R4 Pro → firewall, 4 Gbit/s, 20 s per run:

Frame size field = 3 (stock) field = 8
1518 B 0 % loss 0.0002 % (12 of 6.8 M)
1510 B 1.4 % loss (96714 frames) 0 %
1514 B 0 % 0 %

The write only lasts until the next link-up; the firmware sets 3 again on every autoneg.

About the second problem I mentioned (the CRC phases): I caught one today with tcpdump, and it does not look like line noise. 6.5 h after link-up, lan6 starts receiving frames that the workstation never sent:

  • In 10 s the workstation (RTL8127, r8169) sent 172 frames; lan6 counted 18734 received, 18587 of them rmon Undersize.
  • Every one is the same 48-byte frame: DA 00:00:00:00:00:00, SA 00:00:01:01:01:01, then the pattern continues: 8 bytes each of 00, 01, 02, 03, 04, then 4 bytes of 05 (44 bytes), followed by fe 5a bf 47, which is the correct CRC32 of those 44 bytes.
  • They come in bursts of about 37 frames within 0.5 ms, every 10 to 45 ms, about 1850 frames/s. Only the RJ45 receive direction is affected.
  • While this runs, rx_dropped on lan6 climbs by hundreds of thousands per minute and throughput falls to 1 Gbit/s down and 130 Mbit/s up. Pause frames stay at 0, the MxL temperature is flat at about 60 °C, and “ethtool -r lan6” stops it at once.

A valid CRC over an incrementing 8-byte pattern looks like a built-in packet generator, and the AS21010 has a MAC of its own (your 0x103c field). Did you see anything like a test-frame generator in your disassembly, or a pattern like 00x8 01x8 02x8 …? The pcap with only these frames is attached.

The phase today happened with the stock value 3. I left the field at 8 now, so if the phases come back with 8 we know the two issues are separate.

Setup: OpenWrt main r38555-fb742de8e5, kernel 6.18.64, AS21010 firmware 1.9.1, MxL firmware 1.0.85, lan6 USXGMII in-band.

I am also reporting both findings to Christian Marangi (as21xxx maintainer, he submits the firmware to linux-firmware) so Aeonsemi hears about it from more than one user.

lan6-phantom-frames.pcap (21,1 KB)

Update on the phantom frames: a second phase today shows where they come from.

A small logger now checks VEND1 0x103c every 10 s and sets bits 8:3 from 3 to 8.

  • The phase began 12.5 h after the last retrain, with no link-down in between. The field had stayed at 8 all that time, so it does not trigger the phases.
  • From the minute the phantom frames started, the firmware wrote 3 into the field again on every check, for 4.5 h.

During the phase I set the field to 8, read it every 1.9 ms and recorded the phantom frames with tcpdump -tt:

Firmware resets the field (ms after write) Burst starts (ms)
2.0 – 4.1 3.2
11.7 – 13.8 13.2
3.9 – 6.0 5.4
47.2 – 49.1 48.2
1.9 – 3.9 2.2
34.4 – 36.3 36.7
52.8 – 54.7 53.2

At about 20 bursts/s a random burst lands in a 2 ms window about 4 % of the time; six of seven are inside, one 0.4 ms after.

So during a phase the firmware keeps re-running its host-side setup for the current speed (the code that writes 0x103c) without a link change, and every run sends a burst of the test frames to the MxL. A retrain ends it.

@meehien does the disassembly show what calls that routine apart from link-up? A periodic host-side check that gets stuck would fit.

Also sent to Christian Marangi.

@oli yes, it is a periodic check on the host side. In 1.9.2 the DPC (i.e. the firmware state machine for the host side) keeps five hang flags in its steady state: rx-fifo hang, tx-fifo hang, crc_err, mac_crc_low_rate and ldpc_err. The error ones are set when a counter keeps rising over several windows in a row. When any flag is set the firmware logs “fifo_hang”, waits a few ms (100 ms for the tx-fifo one) and than logs “reset_fifo” and calls same MAC set-up routine it uses at link-up. This is probably where your 3 comes from. For the error flags, firmware starts the packet generator twice with 20 frames each, so 40 frames. ~37 makes sense to me in this context. After that it clears the flags and starts monitoring again.

The state machine does not change state during any of this, so the copper side and the driver see nothing. If whatever trips the monitor is still there on the next pass it loops again and only a retrain resets the monitors. I ran the image with Claude in an emulator with each flag forced and with a flag held it does one reset every 10 ms (100 ms for tx-fifo).

Beyond this I don’t really know what happens in your case. A firmware log could solve this but it’s not available in the stock driver unfortunately.

Your workaround is somewhat incomplete also as mdio write is undone by every reset_fifo too, not just at link-up. In my patched version this is fixed, and the the value kept constant in the routine, as reset_fifo also writes 8.

Finally, I only looked at 1.9.2. The script above finds the code by what it does (not by address) so it may work on 1.9.1.

@meehien thanks, that matches 1.9.1 (the linux-firmware as21x1x_fw.bin).

In 1.9.1 the code after the reset_fifo log call has a loop that runs twice. Each pass calls a function with 20 as argument, and that function programs a register block at 0xea3c2xxx. After the second pass another function writes 0 into a field of that block, then all five flags are cleared. I have not decoded the frame pattern. But 2 × 20 fits the ~37 frames per burst, and in my timing test the bursts started within about 2 ms of the 0x103c reset. So the phantom frames are most likely the generator frames.

The firmware log can be read with the stock driver loaded. The firmware keeps it in a 40 KiB ring in RAM (0x346000…0x350000, write pointer at 0x201468). The text is XORed with 0x16, except 0x20 and 0x0a, which are stored as is, so a stored 0x20 is a space or a ‘6’. IPC RMEM32 (opcode 4) reads it with mdio-tools. Two things to watch: RMEM does not check the length, so never ask for more than 16 bytes, and follow each command with a NOOP so the IPC parity stays where the driver expects it.

On my link the ring covered 9 hours with 11 recoveries at 10 times; two came 82 ms apart, first on crc_err, then on ldpc_err. Each time matches a reset of 0x103c to 3 seen by my logger. All 11 were set off by crc_err and/or ldpc_err; rx-fifo, tx-fifo and mac-rx stayed 0. In between, Packet_Error_Mon shows bursts of ldpc errors on the copper side, e.g. “ldpc_cw : 10094, ldpc_err : 1299, 0”.

You are right about the workaround: the logger checks 0x103c once per second and only then sets 8 again, so frames of some sizes can still drop after each reset_fifo.

Since today the crc/ldpc check is off at runtime (CFG_PARAM direct, module 7, enable = 0; the hang monitor then skips both detectors). Phases have come hours to a day apart, so I will report after a few days whether one still comes.

Where did you get 1.9.2? linux-firmware ships 1.9.1.

I took 1.9.2 from sdk,linux-firmware is 1.9.1

1 Like

I know. I also posted about this, but have not really looked into that firmware, the same way I did 1.9.2. And I am not very tempted either…

And I took it from you :smile: