BPI R3 mtk_soc_eth driver shows no link-state, but SFP module does have a link-up

Trying to get my BPI R3 up and running again as an ONT.
However, newer 23.05 snapshot releases UF-SM-1G-S module doesn't detect a link anymore using autoneg.

Error with autoneg on while it's connected properly to ISP:

ethtool eth1
Settings for eth1:
        Supported ports: [ FIBRE ]
        Supported link modes:   1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseX/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: no

Autoneg did work before on BPI R3 on same ISP connection, where ER-X-SFP wouldn't and needed to be forced. But forcing speed/duplex using ethtool on BPI R3 doesn't seem to do anything.

If autoneg is turned off, the 'Link detected' changes to yes, but speed and duplex remain unknown and it doesn't work still.

Also, now ethtool doesn't seem to accept multiple config settings in one cmd line anymore, which used to work just fine:

 ethtool -s eth1 speed 1000 autoneg off duplex full
Cannot set new settings: Invalid argument
  not setting speed
  not setting duplex
  not setting autoneg

dmesg output:

[    9.785323] sfp sfp-1: Host maximum power 1.0W
[    9.790478] sfp sfp-2: Host maximum power 1.0W
[    9.859441] urngd: v1.0.2 started.
[   10.119803] sfp sfp-1: module UBNT             UF-SM-1G-S       rev      sn FT16101506897    dc 161019
[   10.129276] sfp sfp-1: Host does not support 2.0W modules, module left in power mode 1
[   10.137190] mtk_soc_eth 15100000.ethernet eth1: switched to inband/1000base-x link mode
[   32.609229] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/1000base-x link mode

Any help is much appreciated.

I don't know why this was working before but there are a series of patches coming in:
Could this be related: https://patchwork.kernel.org/project/linux-mediatek/list/?series=777712 ?

Don't think it's related.
It seems something with ethtool unable to set fixed speed / duplex mode.
Now just tested again with 23.05.0-rc1 and it also doesn't work. Same issue.

Gona go back further to figure out where it stopped working...

This ethtool command works in older OpenWRT releases... but not in 23.05 rc's


root@OpenWrt:/# ethtool -s eth1 speed 1000 duplex full autoneg off
[  616.887726] sfp sfp1: Unable to ascertain link mode
[  616.892607] mtk_soc_eth 15100000.ethernet eth1: selection of interface failed, advertisement 0000000,00000000,00006400
Cannot set new settings: Invalid argument
  not setting speed
  not setting duplex
  not setting autoneg

Cmd line issue seems to be due to now ethtool functionality split across two packages:

ethtool
ethtool-full

Using ethtool-full does seem to accept at least cmd line:
ethtool -s eth1 speed 1000 duplex full autoneg off

Unfortunately, unable to get the SFP module to set to fixed speed/duplex...

ethtool -s eth1 autoneg off speed 1000 duplex full
root@OpenWRT:~# ethtool eth1
Settings for eth1:
        Supported ports: [ FIBRE ]
        Supported link modes:   1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseX/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: Unknown!
        Duplex: Unknown! (255)
        Auto-negotiation: off
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes

Speed/Duplex remain 'unknown', and a link-state is not established.
For my ISP, autoneg doesn't work - with at least the Ubiquiti SFP modules.

Here's same output of release 21.02.3 with ethtool 5.10 on an Ubiquiti ER-X-SFP with the same UF-SM-1G-S SFP module using same cmd line to ethtool:

 ethtool eth5
Settings for eth5:
        Supported ports: [ TP MII ]
        Supported link modes:   100baseT/Half 100baseT/Full
                                1000baseT/Full
                                1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 7
        Transceiver: external
        Auto-negotiation: off
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

And here it does work.

Found older snapshot release with following driver:

root@OpenWrt:~# ethtool -i eth1
driver: mtk_soc_eth
version: 5.15.77
firmware-version:
expansion-rom-version:
bus-info: 15100000.ethernet
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

Using ethtool, am able to set speed / duplex fixed.
Unfortunately, older build doesn't support vlan q-tagging, hence useless for me.

And 23.05.0-rc3 has a newer driver which expresses the issue:

ethtool -i eth1
driver: mtk_soc_eth
version: 5.15.127
firmware-version:
expansion-rom-version:
bus-info: 15100000.ethernet
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

Thinking issue lies here in this piece of the code flow:

Here's some more debugging info below, and I think some other person encountered the same issue here: SFP on Banana Pi BPI-R3 not receiving traffic with Openwrt Snapshot (23.1.2023)

Ethtool reports 'no link' - while there's a link-state according to SFP module

ethtool eth1
Settings for eth1:
        Supported ports: [ FIBRE ]
        Supported link modes:   1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseX/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: Unknown!
        Duplex: Unknown! (255)
        Auto-negotiation: on
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: no

See here, link is up:


cat /sys/kernel/debug/sfp-1/state
Module state: present
Module probe attempts: 0 0
Device state: up
Main state: link_up
Fault recovery remaining retries: 5
PHY probe remaining retries: 12
moddef0: 1
rx_los: 0
tx_fault: 0
tx_disable: 0

There's light going in both directions:

ethtool -m eth1
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x07 (LC)
        Transceiver codes                         : 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00
        Transceiver type                          : Ethernet: BASE-BX10
        Encoding                                  : 0x01 (8B/10B)
        BR, Nominal                               : 1300MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 3km
        Length (SMF)                              : 3000m
        Length (50um)                             : 0m
        Length (62.5um)                           : 0m
        Length (Copper)                           : 0m
        Length (OM3)                              : 0m
        Laser wavelength                          : 1310nm
        Vendor name                               : UBNT
        Vendor OUI                                : 00:00:00
        Vendor PN                                 : UF-SM-1G-S
        Vendor rev                                :
        Option values                             : 0x20 0x0a
        Option                                    : RX_LOS implemented
        Option                                    : TX_FAULT implemented
        Option                                    : Power level 3 requirement
        BR margin, max                            : 0%
        BR margin, min                            : 0%
        Vendor SN                                 : FT16101506897
        Date code                                 : 161019
        Optical diagnostics support               : Yes
        Laser bias current                        : 21.230 mA
        **Laser output power                        : 0.1986 mW / -7.02 dBm**
        **Receiver signal average optical power     : 0.1933 mW / -7.14 dBm**
        Module temperature                        : 36.17 degrees C / 97.10 degrees F
        Module voltage                            : 3.2502 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : Off
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : Off
        Laser rx power high warning               : Off
        Laser rx power low warning                : Off
        Laser bias current high alarm threshold   : 100.000 mA
        Laser bias current low alarm threshold    : 0.000 mA
        Laser bias current high warning threshold : 90.000 mA
        Laser bias current low warning threshold  : 0.100 mA
        Laser output power high alarm threshold   : 0.6310 mW / -2.00 dBm
        Laser output power low alarm threshold    : 0.1000 mW / -10.00 dBm
        Laser output power high warning threshold : 0.5012 mW / -3.00 dBm
        Laser output power low warning threshold  : 0.1259 mW / -9.00 dBm
        Module temperature high alarm threshold   : 90.00 degrees C / 194.00 degrees F
        Module temperature low alarm threshold    : -45.00 degrees C / -49.00 degrees F
        Module temperature high warning threshold : 85.00 degrees C / 185.00 degrees F
        Module temperature low warning threshold  : -40.00 degrees C / -40.00 degrees F
        Module voltage high alarm threshold       : 3.8000 V
        Module voltage low alarm threshold        : 2.7000 V
        Module voltage high warning threshold     : 3.7000 V
        Module voltage low warning threshold      : 2.8000 V
        Laser rx power high alarm threshold       : 1.0000 mW / 0.00 dBm
        Laser rx power low alarm threshold        : 0.0040 mW / -23.98 dBm
        Laser rx power high warning threshold     : 0.7943 mW / -1.00 dBm
        Laser rx power low warning threshold      : 0.0050 mW / -23.01 dBm

But, no packets are being exchanged...

ethtool -S eth1
NIC statistics:
     tx_bytes: 0
     tx_packets: 0
     tx_skip: 0
     tx_collisions: 0
     rx_bytes: 0
     rx_packets: 0
     rx_overflow: 0
     rx_fcs_errors: 0
     rx_short_errors: 0
     rx_long_errors: 0
     rx_checksum_errors: 0
     rx_flow_control_packets: 0
     rx_xdp_redirect: 0
     rx_xdp_pass: 0
     rx_xdp_drop: 0
     rx_xdp_tx: 0
     rx_xdp_tx_errors: 0
     tx_xdp_xmit: 0
     tx_xdp_xmit_errors: 0
     rx_pp_alloc_fast: 20015
     rx_pp_alloc_slow: 19
     rx_pp_alloc_slow_ho: 0
     rx_pp_alloc_empty: 19
     rx_pp_alloc_refill: 664
     rx_pp_alloc_waive: 0
     rx_pp_recycle_cached: 0
     rx_pp_recycle_cache_full: 0
     rx_pp_recycle_ring: 19545
     rx_pp_recycle_ring_full: 0
     rx_pp_recycle_released_ref: 641

Hi,

for me, it works since snapshot from of 10.Apr. Currently I'm running 23.05.0-rc2 without any problems related to sfp module.

Are you using autoneg on the SFP interface? - In my case, that doesn't work for my ISP. Have to fix it to 1000/full which currently isn't possible in latest driver afaik.
I have a matching pair of Ubiquiti ONU's, and those work fine using autoneg. It's just with my ISP it doesn't.

Driver last update was pre-23.05.0-rc1 even.

And in earlier snapshots it did work for me to set speed/duplex to fixed.

Seriously?
image

yes, I use autoneg.

Solution, changed to kernel 6.1 - where autoneg off speed 1000 duplex full works out of box.