UniFi 6 LR v2 ethernet not working

Just found this previous debate. So no, it's not RTL8211F but rather RTL8211FS.

So rather, please keep everything with SGMII and try this:

no luck - moved back to sgmii changes and built with demem enabled, when I run the command and take the interface down and back up nothing seems to change:

[  929.427544] mtk_soc_eth 1b100000.ethernet eth0: Link is Down
[  929.434879] br-lan: port 1(eth0) entered disabled state
[  933.058178] mtk_soc_eth 1b100000.ethernet eth0: PHY [mdio-bus:00] driver [RTL8211F Gigabit Ethernet] (irq=POLL)
[  933.071067] mtk_soc_eth 1b100000.ethernet eth0: configuring for phy/sgmii link mode
[  935.208543] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[  935.217189] br-lan: port 1(eth0) entered blocking state
[  935.222679] br-lan: port 1(eth0) entered forwarding state
[  973.688331] mtk_soc_eth 1b100000.ethernet eth0: Link is Down
[  973.696483] br-lan: port 1(eth0) entered disabled state
[  988.248545] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[  988.257296] br-lan: port 1(eth0) entered blocking state
[  988.262683] br-lan: port 1(eth0) entered forwarding state

https://pastebin.com/B5r5wTLn << new register dump with interface up

Try

devmem 0x1b128000 32 0x445060

(ie. set bit 12 which is SGMII_AN_ENABLE)

If that works you can achieve the same by setting

managed = 'in-band-status';

in device tree for &gmac0 and remove the phy from there. Then the link status, speed, duplex, ... will be polled from the PCS instead of the PHY.

hot dog, that does it - can connect to eth now. You're a wizard. going to make a build per your suggestion and test!

posting for posterity, but with this everything works(both wifi bands, ethernet port on my 2234k unit!) thanks again @daniel . Let me know if there's anything I can do to help get a v3 target going here - I'm not to familiar with the process here but can at the very least put this in a PR/add it to one if at all helpful)

unsure if CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON is necessary, but it didn't seem to hurt things?

diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
index 4bde061765..b6b154aded 100644
--- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
+++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
@@ -108,8 +108,10 @@
 +CONFIG_PHY_FIXED=y
 +CONFIG_PHYLIB_10G=y
 +CONFIG_PHY_AQUANTIA=y
++CONFIG_PHY_REALTEK=y
++CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
 +CONFIG_PHY_ADDR_ENABLE=y
-+CONFIG_PHY_ADDR=8
++CONFIG_PHY_ADDR=0
 +CONFIG_MEDIATEK_ETH=y
 +CONFIG_MTD=y
 +# CONFIG_MMC is not set
@@ -337,10 +339,10 @@
 +              #address-cells = <1>;
 +              #size-cells = <0>;
 +
-+              gphy: ethernet-phy@8 {
++              gphy: ethernet-phy@0 {
 +                      /* Marvell AQRate AQR112W - no driver */
-+                      compatible = "ethernet-phy-ieee802.3-c45";
-+                      reg = <0x8>;
++                      compatible = "ethernet-phy-ieee802.3-c22";
++                      reg = <0x0>;
 +              };
 +      };
 +};
diff --git a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi
index 4231cc1f79..7824b03569 100644
--- a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi
+++ b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr.dtsi
@@ -160,18 +160,18 @@
                compatible = "mediatek,eth-mac";
                reg = <0>;
 
-               phy-mode = "2500base-x";
+               phy-mode = "sgmii";
+               managed = "in-band-status";
                phy-handle = <&phy0>;
-               phy-connection-type = "2500base-x";
        };
 
        mdio: mdio-bus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               phy0: ethernet-phy@8 {
-                       compatible = "ethernet-phy-ieee802.3-c45";
-                       reg = <0x8>;
+               phy0: ethernet-phy@0 {
+                       compatible = "ethernet-phy-ieee802.3-c22";
+                       reg = <0x0>;
                };
        };
 };

Can you try if 100M/10M link speeds work as well and get indicated correctly? Would also be interesting to see ethtool eth0 output.

As you are touching uboot-mediatek as well, getting that to have working Ethernet as well would obviously be great. I assume the same change (setting phy-mode = "sgmii";) is needed there as well.

We could try one more alternative solution: Try to convince the PHY to not require in-band-status. I haven't found anything specific for the RTL8211 series, but on newer RealTek PHYs you could do this:

mdio mdio-bus mmd 0.30 0x7588 0x2
mdio mdio-bus mmd 0.30 0x7589 0x71D0
mdio mdio-bus mmd 0.30 0x7587 0x3
mdio mdio-bus mmd 0.30 0x7587 # (wait until BIT0 = 0)

not sure if this will work on the older PHYs though, there might be another secret trick...

I've added images for the v3 in my staging tree. Can you please use that to build and see if the if generated images work fine for you?

git clone https://git.openwrt.org/openwrt/staging/dangole.git openwrt-dangowrt
cd openwrt-dangowrt
make menuconfig 
# select UniFi 6 LR v3 or v3-ubootmod
make -j$(nproc)

The relevant commits are https://git.openwrt.org/?p=openwrt/staging/dangole.git;a=commit;h=92962bf13fa146da044af4f3f7df4443324f019a and https://git.openwrt.org/?p=openwrt/staging/dangole.git;a=commit;h=0b6a766b07dd4bb520f88ae100b61844c5204f59

1 Like

I'll definitely give this a shot when I get the chance! Thanks so much guys for the work to get this working :smile:

Would be great to know if we can use the phy interrupt signal and reset signals. With the interrupt we could get rid of polling link state from either PCS or PHY and only read the link status when notified about a change by an interrupt (the realtek.c driver supports that already). Asserting the reset should probably be done by the bootloader (and hence relevant for the ubootmod variant mostly).

Hmm, I have very little experience with compiling openwrt so it's entirely possible that I've done something wrong here, but that build is failing for me on mt76:

make -f ./scripts/Makefile.modpost
  sed 's/\.ko$/\.o/' /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/modules.order | scripts/mod/modpost   -E -o /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/Module.symvers -e -i Module.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/ath10k-ct.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/button-hotplug.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/cryptodev-linux.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/gpio-button-hotplug.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/mac80211.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/nat46.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/rtl8812au-ct.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/trelay.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/ubnt-ledbar.symvers -i /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/symvers/ubootenv-nvram.symvers   -T -
ERROR: modpost: "mt792xu_rr" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792x_reset" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792x_get_mac80211_ops" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792x_update_channel" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_dma_init" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_init_reset" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_wr" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_disconnect" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_wfsys_reset" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
ERROR: modpost: "mt792xu_mcu_power_on" [/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/mt7921/mt7921u.ko] undefined!
WARNING: modpost: suppressed 57 unresolved symbol warnings because there were too many)
make[5]: *** [scripts/Makefile.modpost:133: /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/Module.symvers] Error 1
make[5]: *** Deleting file '/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/Module.symvers'
make[4]: *** [Makefile:1827: modules] Error 2
make[4]: Leaving directory '/home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.15.128'
make[3]: *** [Makefile:547: /home/<username>/dev/openwrt-dangowrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt76-2023-07-26-b14c2351/.built] Error 2
make[3]: Leaving directory '/home/<username>/dev/openwrt-dangowrt/package/kernel/mt76'
time: package/kernel/mt76/compile#53.53#7.19#61.06
    ERROR: package/kernel/mt76 failed to build.
make[2]: *** [package/Makefile:120: package/kernel/mt76/compile] Error 1
make[2]: Leaving directory '/home/<username>/dev/openwrt-dangowrt'
make[1]: *** [package/Makefile:114: /home/<username>/dev/openwrt-dangowrt/staging_dir/target-aarch64_cortex-a53_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/<username>/dev/openwrt-dangowrt'
make: *** [/home/<username>/dev/openwrt-dangowrt/include/toplevel.mk:232: world] Error 2

EDIT: for reference this was using the config from here https://downloads.openwrt.org/releases/23.05.0-rc3/targets/mediatek/mt7622/config.buildinfo, just changing the target profile to the new unifi 6 lr v3 option using make menuconfig.

confirming that this branch works for me! Flashed it over the old image through luci if that matters, let me know if a full reset back to stock is necessary instead. going to try and wrangle a 100mbps switch to see if it works as expected.

I think just doing:

make menuconfig
make -j8

from the repo root is all that's necessary, at least that's what I've been doing usually.

here's the before(1gbps) and after(100mbps) ethool output for a 1g and 100mbps switch, seems ok to me:

root@OpenWrt:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                             100baseT/Half 100baseT/Full 
                                             1000baseT/Full 
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes


---- now plugged into 100m ---
root@OpenWrt:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                             100baseT/Half 100baseT/Full 
        Link partner advertised pause frame use: Symmetric
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
1 Like

Please post a full bootlog as well, just to confirm that the PHY is still probed.

Ah yeah I see that does build. I assumed starting from the "official" config would be a reasonable starting point, but I guess because this is not the same version I was pulling that from, there's probably something a little incompatible about those settings or something. Trying out the image in a bit.

dmesg log, with connection to 100mbps:

root@UBNTL6R:~# dmesg  |grep mtk_so
[    1.220164] mtk_soc_eth 1b100000.ethernet eth0: mediatek frame engine at 0xffffffc009340000, irq 134
[    9.046646] mtk_soc_eth 1b100000.ethernet eth0: PHY [mdio-bus:00] driver [RTL8211F Gigabit Ethernet] (irq=POLL)
[    9.059916] mtk_soc_eth 1b100000.ethernet eth0: configuring for inband/sgmii link mode
[   11.206954] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   27.721647] mtk_soc_eth 1b100000.ethernet eth0: Link is Down
[   27.779344] mtk_soc_eth 1b100000.ethernet eth0: PHY [mdio-bus:00] driver [RTL8211F Gigabit Ethernet] (irq=POLL)
[   27.792102] mtk_soc_eth 1b100000.ethernet eth0: configuring for inband/sgmii link mode
[   29.926904] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

no errors, and eth works as expected!

Things seem to be working for me too. I did a quick test of setting my switch to force 100BaseT full duplex, and it ended up getting only half duplex (ethtool shows link partner only advertising half duplex), though I suspect this could be something going wrong with the switch because my desktop has the exact same behavior when connected to the switch in the same fashion.

mt7622 snapshot build #106 includes the changes adding images for the v3 (== with RTL8211FS PHY) variant.
Hence images for the UniFi 6 LR v3 are now available for download at https://downloads.openwrt.org/snapshots/targets/mediatek/mt7622/

Someone who got the device, please confirm that this new image has working Ethernet and also otherwise works fine.

2 Likes

Awesome @daniel, many thanks!
Any chance this gets "back-ported" to 23.05?

Yes, once tested and confirmed working and not breaking anything else I intend to backport to for-Linux-5.15 part of all the recent mediatek changes to the openwrt-23.05 branch.