Debugging phy/driver (rtl8261n/rtl8261be)

I have a ZyXEL XGS1250-12 v2, which runs pretty smoothly with OpenWRT, except that the three 2.5/5/10 GbE ports are not working. The chips providing those ports are rtl8261be. I succeeded in building an image that includes the rtl8261n driver, which seemed to be the best choice to achieve anything.
During boot, the rtl8261n driver automatically initializes the interfaces, the port indicator LED shows the right color depending on the link speed, and it starts blinking together with the other ports.
However, even though there is some traffic reported in the GUI, the connection doesn't work (DHCP or static).
ethtool shows very similar information compared to the working interfaces and dmesg shows some failures that I think are not related to this problem.

The output of ethtool:

root@SW1:~# ethtool lan9
Settings for lan9:
	Supported ports: [ TP MII ]
	Supported link modes:   100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	                        10000baseT/Full 
	                        2500baseT/Full 
	                        5000baseT/Full 
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	                        10000baseT/Full 
	                        2500baseT/Full 
	                        5000baseT/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: 24
	Transceiver: external
	Auto-negotiation: on
	MDI-X: Unknown
	Supports Wake-on: d
	Wake-on: d
	Link detected: yes

some interesting dmesg lines:

[    2.291612] Realtek RTL8261N mdio-bus:18: rtkphy_config_init:69 [RTL8261N/RTL826XB] phy_id: 0x1CCAF3 PHYAD:24
[    3.712274] rtl83xx-switch switch@1b000000 lan9 (uninitialized): PHY [mdio-bus:18] driver [Realtek RTL8261N] (irq=POLL)
[    3.725867] Realtek RTL8261N mdio-bus:19: rtkphy_config_init:69 [RTL8261N/RTL826XB] phy_id: 0x1CCAF3 PHYAD:25
[    5.148424] rtl83xx-switch switch@1b000000 lan10 (uninitialized): PHY [mdio-bus:19] driver [Realtek RTL8261N] (irq=POLL)
[    5.161912] Realtek RTL8261N mdio-bus:1a: rtkphy_config_init:69 [RTL8261N/RTL826XB] phy_id: 0x1CCAF3 PHYAD:26
[    6.586067] rtl83xx-switch switch@1b000000 lan11 (uninitialized): PHY [mdio-bus:1a] driver [Realtek RTL8261N] (irq=POLL)

...

[    6.649653] rtl83xx_fib_event_work_do: FIB4 default rule failed
[    6.656339] rtl83xx_fib_event_work_do: FIB4 default rule failed

...

[   12.666685] rtl83xx_fib_event: FIB_RULE ADD/DEL for IPv6 not supported
[   12.674040] rtl83xx_fib_event: FIB_RULE ADD/DEL for IPv6 not supported

There are multiple of those FIB related lines. However, I'm now wondering what choices I have to debug the interfaces. Can someone with some experience give me a hint where to start or tell me if this is a dead end? I really would like to get this device to work and also contribute something to OpenWRT.

Did you manage to get it working wit OpenWrt? The XGS1250-12 that are for sale now are mostly v.2 I believe.

Yes, I managed to get the 10GbE ports up and running with the help of BrainSlayer. The RTL8261N driver can also be used for the RTL8261BE chipset, some changes are necessary. The smi addresses in the device tree file have to be adjusted, the driver has to be compiled statically (I was not able to compile it as a kernel module) and finally I had to use the modified driver from BrainSlayer. He works on the dd-wrt project and has modified it so that the chipset is initialized correctly.

Here are the individual steps with which I had success. (It's not a clean solution, you would have to create a new target for version 2. Also, the inclusion of the driver is probably not in the right file):

git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c
	modified:   target/linux/generic/files/drivers/net/phy/rtl8261n/phy_rtl826xb_patch.c
	modified:   target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_osal.c
	modified:   target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c
	modified:   target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts
	modified:   target/linux/realtek/rtl930x/config-6.6
git diff target/linux/realtek/rtl930x/config-6.6
diff --git a/target/linux/realtek/rtl930x/config-6.6 b/target/linux/realtek/rtl930x/config-6.6
index c01fa172f4..25b7592951 100644
--- a/target/linux/realtek/rtl930x/config-6.6
+++ b/target/linux/realtek/rtl930x/config-6.6
@@ -234,3 +234,4 @@ CONFIG_USE_OF=y
 CONFIG_WATCHDOG_CORE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_ZLIB_INFLATE=y
+CONFIG_RTL8261N_PHY=y
git diff target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts
diff --git a/target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts b/target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts
index aa48511372..14c96bc406 100644
--- a/target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts
+++ b/target/linux/realtek/dts/rtl9302_zyxel_xgs1250-12.dts
@@ -278,7 +278,7 @@
                phy24: ethernet-phy@24 {
                        reg = <24>;
                        compatible = "ethernet-phy-ieee802.3-c45";
-                       rtl9300,smi-address = <1 8>;
+                       rtl9300,smi-address = <1 0>;
                        sds = < 6 >;
                        // Disabled because we do not know how to bring up again
                        // reset-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
@@ -288,7 +288,7 @@
                phy25: ethernet-phy@25 {
                        reg = <25>;
                        compatible = "ethernet-phy-ieee802.3-c45";
-                       rtl9300,smi-address = <2 8>;
+                       rtl9300,smi-address = <2 1>;
                        sds = < 7 >;
                        // Disabled because we do not know how to bring up again
                        // reset-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
@@ -298,7 +298,7 @@
                phy26: ethernet-phy@26 {
                        reg = <26>;
                        compatible = "ethernet-phy-ieee802.3-c45";
-                       rtl9300,smi-address = <3 8>;
+                       rtl9300,smi-address = <3 2>;
                        sds = < 8 >;
                        // Disabled because we do not know how to bring up again
                        // reset-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;

I then replaced the RTL8261N driver with the one from the dd-wrt mirror:

1 Like

Thank you for the information. Did you also build by merging the pull request in the link you provided (PR for kernel 6.12)? Or did you just use the main OpenWrt branch and inserted BrainSlayer's modified drivers along with the modified devide tree file?

I got it running, finally. Thanks! How do you manage your switch, through the /etc/config/network file or through luci? I tried installing the luci package but no switch menu appeared.

No, I have compiled the main branch with kernel version 6.6 together with the drivers. I think now it would also be possible to compile it with kernel 6.12, because the pull request was merged into the main branch and brainslayer also made a customization for 6.12.

1 Like

I have made the configuration in luci. I have only used OpenWRT on routers, so I don't know the switch menu, but as far as I can see, basically everything can be configured via network > interfaces. Perhaps this menu only appears if there is a configuration for it or it is specified via menuconfig.

1 Like

To add to this, the menu is named "Bridge VLAN filtering" and is located in the Interfaces section and under the switch0 bridge. I got it working without any issues, thanks.

1 Like