[BPI-R4] and SFP

Usually, when extended_cc equals zero (which your module has, one of the 4 bytes between vendor and product string), then https://elixir.bootlin.com/linux/v6.9.1/source/drivers/net/phy/sfp-bus.c#L124

sfp_may_have_phy() returns false and you’re not stuck in a waiting cycle.

So looks like you have a quirk that sets extendec_cc and makes phylink believe there is a phy to look for…

So removing the quirk would be the solution in this case…

Hi all,

I found this thread by looking information about BPI-R4. I want to upgrade my router from a PCEngine APU6 with AMD GX-412TC SOC to something more powerful and 10GbE. But the ISP is using 1GbE (1000Mbps) fiber connection. On Wiki Banana Pi BPI-R4 | BananaPi Docs says “The SFP serdes speed of BPI-R4 is fixed at 10Gbps, so only SFP that support this can be used!”. Here I see that some of you is trying to use 1000Mbps SFPs. My question is: what is the status of supporting lower speed SFPs in both ports? It is possible to connect SFP- 31W2A(SM-10)-DR for example? The other SFP I want to use a DAC to a local switch.

all right, thanks for the tip! would this work? I do not knnow what quirk I’m looking for, but as this dirty hacking isn’t meant to upstream anyway, I could as well turn phy detection off entirely for 2G5:

--- drivers/net/phy/sfp-bus.c   2024-05-02 16:32:50.000000000 +0200
+++ drivers/net/phy/sfp-bus.2.C 2024-05-25 08:28:21.322032789 +0200
@@ -125,8 +125,9 @@ bool sfp_may_have_phy(struct sfp_bus *bu
                case SFF8024_ECC_10GBASE_T_SFI:
                case SFF8024_ECC_10GBASE_T_SR:
                case SFF8024_ECC_5GBASE_T:
-               case SFF8024_ECC_2_5GBASE_T:
                        return true;
+               case SFF8024_ECC_2_5GBASE_T:
+                       return false;
                }
        }

I meant, there is some quirk that changes the extcc field, like so:

But then 2500.

Depending on the kernel you use.

So disable/edit that quirk.

I know you meant that. Unfortunately, grep mentions no ‘extended_cc’ in target/linux dir of openwrt (where all patches are stored) when running grep -R.

Openwrt is quite a lot of hacks, so as this problem seems sfp specific, I may as well turn off phy detection entirely for 2g5…

You either seem to lack kmod-phy-realtek package or the SFP doesn’t expose the PHY.

I’m using TP-LINK TL-SM410U, ONTi ONT-C2GE-R10 and some other TP-LINK and ONTi modules. I had the same problem with Openwrt going from kernel 6.1 to 6.6 on R3. Everything was working fine before, but after the update:

[   15.141286] sfp sfp-2: module                                   rev 1.0  sn 2208180027       dc 220818
[   15.150776] mt7530-mdio mdio-bus:1f sfp2: unsupported SFP module: no common interface modes
[   15.206232] sfp sfp-1: module TP-LINK          TL-SM410U        rev 2.0  sn 12260M4000737    dc 220621
[   15.208117] hwmon hwmon1: temp1_input not attached to any thermal zone
[   15.215705] mtk_soc_eth 15100000.ethernet eth1: unsupported SFP module: no common interface modes

Then I did a sfp-bus.c diff from kernel 6.9.1 and put the patch in target/linux/mediatek/patches-6.6

--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -151,10 +151,6 @@
        unsigned int br_min, br_nom, br_max;
        __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, };

-       phylink_set(modes, Autoneg);
-       phylink_set(modes, Pause);
-       phylink_set(modes, Asym_Pause);
-
        /* Decode the bitrate information to MBd */
        br_min = br_nom = br_max = 0;
        if (id->base.br_nominal) {
@@ -328,7 +324,7 @@
         * modules use 2500Mbaud rather than 3100 or 3200Mbaud for
         * 2500BASE-X, so we allow some slack here.
         */
-       if (bitmap_empty(modes, __ETHTOOL_LINK_MODE_MASK_NBITS) && br_nom) {
+       if (linkmode_empty(modes) && br_nom) {
                if (br_min <= 1300 && br_max >= 1200) {
                        phylink_set(modes, 1000baseX_Full);
                        __set_bit(PHY_INTERFACE_MODE_1000BASEX, interfaces);
@@ -339,6 +335,10 @@
                }
        }

+       phylink_set(modes, Autoneg);
+       phylink_set(modes, Pause);
+       phylink_set(modes, Asym_Pause);
+
        if (bus->sfp_quirk && bus->sfp_quirk->modes)
                bus->sfp_quirk->modes(id, modes, interfaces);

And It seems to be working fine again

[   15.391245] sfp sfp-2: module                                   rev 1.0  sn 2208180027       dc 220818
[   15.442338] sfp sfp-1: module TP-LINK          TL-SM410U        rev 2.0  sn 12260M4000737    dc 220621
[   15.452578] hwmon hwmon1: temp1_input not attached to any thermal zone
[   15.643208] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221012174743a

Sorry if it is a noob-question…

I am using trunk OpenWrt (version 6.6.30) and have a GPON-ONU-34-20BI module. The module is detected at boot and link is also detected.

[   58.082859] sfp sfp2: module FS               GPON-ONU-34-20BI rev 01   sn G2410075131      dc 240301 
Settings for eth1:
	Supported ports: [ FIBRE ]
	Supported link modes:   2500baseX/Full 
	                        1000baseX/Full 
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  2500baseX/Full 
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 2500Mb/s
	Duplex: Full
	Port: FIBRE
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: off
	Current message level: 0x000000ff (255)
			       drv probe link timer ifdown ifup rx_err tx_err
	Link detected: yes

However the speed is 2500Mb and I have to change it to 1000Mb (ethtool speed) does not work so I have to log into the module. The IP address according to HackGPON is 192.168.1.10, but I cannot connect to it. Am I missing something…?

Ok, found the solution… that works.

Now I am trying to set the speed to 1000.

fw_setenv sgmii_mode 4

After reading the sgmii mode, link_status (onu lanpsg 0) is still unchanged (5). Or do I need to unlock the bootloader?

Hello @wvdakker

I have the same sfp receiver, and my R4 détective it in dmesg.

However the link is not detected in ethtool since I haven’t Connect the fiber in it since I have to configure the ont before.

But I’m not able to connect to 192.168.1.10 how did you do it please ?

Hi, Be sure your bpi has ip 192.168.1.1

then

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-dss [email protected]

And you are in. (note: after filling in your password) https://hack-gpon.org/ont-fs-com-gpon-onu-stick-with-mac/

I noticed you have to have a link before you can log in.

My BPI has the ip 192.168.1.1

I have connect the ONT on sfp lan and it is detected

Thu May 30 09:49:46 2024 kern.info kernel: [  105.202018] sfp sfp2: module FS               GPON-ONU-34-20BI rev 01   sn G2410318799      dc 240327
Thu May 30 09:49:46 2024 kern.info kernel: [  105.211440] mtk_soc_eth 15100000.ethernet eth1: switched to inband/2500base-x link mode

With ethtool I can see it has negotiated the speed

root@OpenWrt:~# ethtool eth1
Settings for eth1:
	Supported ports: [ FIBRE ]
	Supported link modes:   2500baseX/Full 
	                        1000baseX/Full 
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  2500baseX/Full 
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 2500Mb/s
	Duplex: Full
	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

But I cannot ping nor ssh from the BPI or a device connected on LAN.

I have to connect the fiber even if I haven’t configure anything on ONT if I understand ?

Most ont need link up to access their webinterface/internal ip

I noticed I only can ping/ssh the sfp if there is a link. If I remove the link I cannot access the sfp. Inserting, then I can.

There is somewhere on this forum a discussion to modify the source so you can also access it without a link. I think it was in the BPIR3-SFP forum.

You use an devicetree-overlay to change the los-gpio so that you can simulate a link-up without having fibre connected.

it looks like @dangowrt did a nice job with openwrt’s commits for the past few days … the sfp module works without any hacks and right from the start. Thank you @dangowrt !

1 Like

Yes I confirm that after the fiber is in the ONT the link is detected and that works perfectly. My R4 is now my router instead of the ISP one, thank you !

Ok found my problem. The ISP doesnt use GPON but AON. Therefor the TX didnt match and not came up. Switching to FS fiber module SFP-GE-BX (be sure to install the right one) works out of the box and the link came up directly.

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
	Link partner advertised link modes:  1000baseX/Full 
	Link partner advertised pause frame use: No
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: FIBRE
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
	Current message level: 0x000000ff (255)
			       drv probe link timer ifdown ifup rx_err tx_err
	Link detected: yes

This module can be added to the ones which work with the bpi-r4 SFP filber module

sfp sfp2: module FS               GPON-ONU-34-20BI rev 01   sn G2410075131      dc 240301 

This one?

No that is the older one I used.

This one works for my ISP:

sfp sfp1: module FS               SFP-GE-BX        rev A0   sn F2130219083      dc 220922