MTK830 + RTL8221B-VB-CG 2.5G question

First of all thanks a lot for the work of openwrt.
I have a router with mt7986a + 2*rtl8221b, and tried the latest code.
Unfortunately both rtl8221b phys only work properly in sgmii mode:

[    1.387853] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc00d580000, irq 125
[    1.633766] mt7530 mdio-bus:1f lan4 (uninitialized): PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   12.479316] mt7530 mdio-bus:1f lan4: configuring for inband/sgmii link mode
[   12.524381] br-lan: port 5(lan4) entered blocking state
[   12.529608] br-lan: port 5(lan4) entered disabled state
[   12.537036] device lan4 entered promiscuous mode
[   12.593770] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:07] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   12.603950] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/sgmii link mode
[   39.604542] mt7530 mdio-bus:1f lan4: Link is Up - 1Gbps/Full - flow control rx/tx
[   39.612037] br-lan: port 5(lan4) entered blocking state
[   39.617258] br-lan: port 5(lan4) entered forwarding state
[   40.004206] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
[   40.012648] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

When I try phy-mode = "2500base-x" I get the following error abort mt7531 p5:

[   13.349572] mt7530 mdio-bus:1f lan4: configuring for inband/2500base-x link mode
[   13.357045] mt7530 mdio-bus:1f: mt753x_phylink_mac_config: unsupported 2500base-x port: 5

Eth1 is also not working, maybe we need to change the driver further?

@daniel very sorry to bother you, but today's commit completely broke rtl8221b:

[   13.034009] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:07] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   13.044205] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/sgmii link mode
[   22.147276] irq 82: nobody cared (try booting with the "irqpoll" option)
[   22.153974] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.64 #0
[   22.159963] Hardware name: MediaTek MT7986a RFB (DT)
[   22.164734] Call trace:
[   22.167165]  dump_backtrace+0x0/0x15c
[   22.170818]  show_stack+0x14/0x30
[   22.174117]  dump_stack_lvl+0x64/0x7c
[   22.177767]  dump_stack+0x14/0x2c
[   22.181067]  __report_bad_irq+0x48/0x128
[   22.184975]  note_interrupt+0x2e4/0x340
[   22.188795]  handle_irq_event+0xb8/0xe0
[   22.192617]  handle_level_irq+0xd4/0x1b4
[   22.196524]  generic_handle_domain_irq+0x28/0x3c
[   22.201125]  mtk_eint_irq_handler+0x230/0x28c
[   22.205468]  handle_domain_irq+0x5c/0x8c
[   22.209375]  gic_handle_irq+0x50/0x120
[   22.213109]  call_on_irq_stack+0x28/0x44
[   22.217015]  do_interrupt_handler+0x4c/0x54
[   22.221181]  el1_interrupt+0x2c/0x4c
[   22.224742]  el1h_64_irq_handler+0x14/0x20
[   22.228821]  el1h_64_irq+0x74/0x78
[   22.232206]  arch_cpu_idle+0x14/0x20
[   22.235767]  do_idle+0xc0/0x140
[   22.238897]  cpu_startup_entry+0x20/0x50
[   22.242804]  rest_init+0xc4/0xd0
[   22.246018]  arch_call_rest_init+0xc/0x14
[   22.250011]  start_kernel+0x5b4/0x5d4
[   22.253657]  __primary_switched+0xa0/0xa8
[   22.257651] handlers:
[   22.259908] [<0000000046802612>] irq_default_primary_handler threaded [<000000006a4a4199>] mt7530_irq_thread_fn
[   22.269979] Disabling IRQ #82

IRQ 82 is the external PHY interrupt (connect to mt7531 on the BPi-R3). Can you share

  • full dmesg output
  • cat /proc/interrupts

@Amadeus can you try out my experimental branch on your board? https://github.com/lynxis/openwrt/tree/whitebox

  • full dmesg output:
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.15.64 (build@server) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 11.3.0 r20448-ab31ffc425) 11.3.0, GNU ld (GNU Binutils) 2.37) #0 SMP Fri Sep 9 04:04:32 2022
[    0.000000] Machine model: MediaTek MT7986a RFB
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x0000000042ffffff]
[    0.000000]   node   0: [mem 0x0000000043000000-0x000000004302ffff]
[    0.000000]   node   0: [mem 0x0000000043030000-0x000000004fbfffff]
[    0.000000]   node   0: [mem 0x000000004fc00000-0x000000004fcfffff]
[    0.000000]   node   0: [mem 0x000000004fd00000-0x000000005fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.2
[    0.000000] percpu: Embedded 17 pages/cpu s29592 r8192 d31848 u69632
[    0.000000] pcpu-alloc: s29592 r8192 d31848 u69632 alloc=17*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129024
[    0.000000] Kernel command line: 
[    0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 493232K/524288K available (8256K kernel code, 882K rwdata, 2220K rodata, 448K init, 293K bss, 31056K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 640 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] GICv3: Distributor has no Range Selector support
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: 16 PPIs implemented
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x000000000c080000
[    0.000000] arch_timer: cp15 timer(s) running at 13.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2ff89eacb, max_idle_ns: 440795202429 ns
[    0.000000] sched_clock: 56 bits at 13MHz, resolution 76ns, wraps every 4398046511101ns
[    0.000098] Calibrating delay loop (skipped), value calculated using timer frequency.. 26.00 BogoMIPS (lpj=130000)
[    0.000106] pid_max: default: 32768 minimum: 301
[    0.000181] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.000189] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.001024] rcu: Hierarchical SRCU implementation.
[    0.001106] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
[    0.001273] smp: Bringing up secondary CPUs ...
[    0.001510] Detected VIPT I-cache on CPU1
[    0.001530] GICv3: CPU1: found redistributor 1 region 0:0x000000000c0a0000
[    0.001554] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.001810] Detected VIPT I-cache on CPU2
[    0.001822] GICv3: CPU2: found redistributor 2 region 0:0x000000000c0c0000
[    0.001833] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[    0.002055] Detected VIPT I-cache on CPU3
[    0.002065] GICv3: CPU3: found redistributor 3 region 0:0x000000000c0e0000
[    0.002074] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[    0.002100] smp: Brought up 1 node, 4 CPUs
[    0.002113] SMP: Total of 4 processors activated.
[    0.002116] CPU features: detected: 32-bit EL0 Support
[    0.002119] CPU features: detected: CRC32 instructions
[    0.002190] CPU: All CPU(s) started at EL2
[    0.002199] alternatives: patching kernel code
[    0.003775] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.003795] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.003899] pinctrl core: initialized pinctrl subsystem
[    0.004335] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.004525] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.004549] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.004568] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.004781] thermal_sys: Registered thermal governor 'fair_share'
[    0.004784] thermal_sys: Registered thermal governor 'bang_bang'
[    0.004788] thermal_sys: Registered thermal governor 'step_wise'
[    0.004791] thermal_sys: Registered thermal governor 'user_space'
[    0.004857] ASID allocator initialised with 65536 entries
[    0.005088] pstore: Registered ramoops as persistent store backend
[    0.005092] ramoops: using 0x10000@0x42ff0000, ecc: 0
[    0.011635] cryptd: max_cpu_qlen set to 1000
[    0.013208] SCSI subsystem initialized
[    0.013283] libata version 3.00 loaded.
[    0.013361] usbcore: registered new interface driver usbfs
[    0.013381] usbcore: registered new interface driver hub
[    0.013396] usbcore: registered new device driver usb
[    0.013929] clocksource: Switched to clocksource arch_sys_counter
[    0.014254] NET: Registered PF_INET protocol family
[    0.014331] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.014589] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.014601] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.014607] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.014629] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
[    0.014676] TCP: Hash tables configured (established 4096 bind 4096)
[    0.014730] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.014742] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.014825] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.014841] PCI: CLS 0 bytes, default 64
[    0.014944] Unpacking initramfs...
[    0.025697] workingset: timestamp_bits=46 max_order=17 bucket_order=0
[    0.027620] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.027632] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.052422] Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
[    0.052911] printk: console [ttyS0] disabled
[    0.073107] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 121, base_baud = 2500000) is a ST16650V2
[    0.721629] printk: console [ttyS0] enabled
[    0.746430] 11003000.serial: ttyS1 at MMIO 0x11003000 (irq = 122, base_baud = 1625000) is a ST16650V2
[    0.756304] mtk_rng 1020f000.trng: registered RNG driver
[    0.756358] hwrng: no data available
[    0.761978] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.772952] loop: module loaded
[    0.777285] spi-nand spi0.1: unknown raw ID 6400bfbf
[    0.782247] spi-nand: probe of spi0.1 failed with error -524
[    1.349841] Freeing initrd memory: 7184K
[    1.365119] mtk_soc_eth 15100000.ethernet: generated random MAC address 56:38:26:18:98:2d
[    1.373530] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc00d600000, irq 125
[    1.382679] mtk_soc_eth 15100000.ethernet: generated random MAC address 92:69:43:30:04:d0
[    1.391022] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc00d600000, irq 125
[    1.401013] i2c_dev: i2c /dev entries driver
[    1.405762] mtk-wdt 1001c000.watchdog: Watchdog enabled (timeout=31 sec, nowayout=0)
[    1.414073] NET: Registered PF_INET6 protocol family
[    1.419637] Segment Routing with IPv6
[    1.423306] In-situ OAM (IOAM) with IPv6
[    1.427252] NET: Registered PF_PACKET protocol family
[    1.432356] 8021q: 802.1Q VLAN Support v1.8
[    1.437612] pstore: Using crash dump compression: deflate
[    1.513954] mt7530 mdio-bus:1f: configuring for fixed/2500base-x link mode
[    1.521093] mt7530 mdio-bus:1f: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    1.530289] mt7530 mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7531 PHY] (irq=133)
[    1.550149] mt7530 mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7531 PHY] (irq=134)
[    1.569700] mt7530 mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7531 PHY] (irq=135)
[    1.589214] mt7530 mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7531 PHY] (irq=136)
[    1.633942] mt7530 mdio-bus:1f lan4 (uninitialized): PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[    1.644901] DSA: tree 0 setup
[    1.649071] xhci-mtk 11200000.usb: xHCI Host Controller
[    1.654309] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 1
[    1.664755] xhci-mtk 11200000.usb: hcc params 0x01403f99 hci version 0x110 quirks 0x0000000000210010
[    1.673896] xhci-mtk 11200000.usb: irq 124, io mem 0x11200000
[    1.679696] xhci-mtk 11200000.usb: xHCI Host Controller
[    1.684911] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 2
[    1.692287] xhci-mtk 11200000.usb: Host supports USB 3.2 Enhanced SuperSpeed
[    1.699597] hub 1-0:1.0: USB hub found
[    1.703349] hub 1-0:1.0: 2 ports detected
[    1.707581] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    1.715885] hub 2-0:1.0: USB hub found
[    1.719632] hub 2-0:1.0: 1 port detected
[    1.724731] Freeing unused kernel memory: 448K
[    1.823970] Run /init as init process
[    1.827618]   with arguments:
[    1.830569]     /init
[    1.832826]   with environment:
[    1.835957]     HOME=/
[    1.838301]     TERM=linux
[    2.004195] init: Console is alive
[    2.007669] init: - watchdog -
[    2.015250] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.027280] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.041264] init: - preinit -
[    2.075485] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[    2.084002] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    2.089210] mt7530 mdio-bus:1f lan1: configuring for phy/gmii link mode
[    2.103414] random: procd: uninitialized urandom read (4 bytes read)
[    4.132615] procd: - early -
[    4.135570] procd: - watchdog -
[    4.646142] procd: - watchdog -
[    4.649486] procd: - ubus -
[    4.654157] random: ubusd: uninitialized urandom read (4 bytes read)
[    4.701830] random: ubusd: uninitialized urandom read (4 bytes read)
[    4.708277] random: ubusd: uninitialized urandom read (4 bytes read)
[    4.715223] procd: - init -
[    4.796297] urngd: v1.0.2 started.
[    4.811440] kmodloader: loading kernel modules from /etc/modules.d/*
[    4.815062] random: crng init done
[    4.821175] random: 22 urandom warning(s) missed due to ratelimiting
[    4.843146] ntfs3: Max link count 4000
[    4.846992] ntfs3: Enabled Linux POSIX ACLs support
[    4.853464] crypto-safexcel 10320000.crypto: EIP97:230(0,1,4,4)-HIA:270(0,5,5),PE:150/433(alg:7fcdfc00)/0/0/0
[    4.867763] Loading modules backported from Linux version v5.15.58-0-g7d8048d4e064
[    4.875381] Backport generated by backports.git v5.15.58-1-0-g42a95ce7
[    4.895081] xt_time: kernel timezone is -0000
[    5.124180] sched: RT throttling activated
[    5.246341] mt7986-wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20220113162543a
[    5.246341] 
[    5.264997] mt7986-wmac 18000000.wmac: WM Firmware Version: ____000000, Build Time: 20220113162641
[    5.301606] mt7986-wmac 18000000.wmac: WA Firmware Version: DEV_000000, Build Time: 20220113163034
[    5.445369] mt7986-wmac 18000000.wmac: eeprom load fail, use default bin
[    9.246491] PPP generic driver version 2.4.2
[    9.251499] NET: Registered PF_PPPOX protocol family
[    9.257768] kmodloader: done loading kernel modules from /etc/modules.d/*
[   12.852676] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   12.861917] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[   12.870491] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[   12.875313] mt7530 mdio-bus:1f lan0: configuring for phy/gmii link mode
[   12.886800] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   12.893282] br-lan: port 1(lan0) entered blocking state
[   12.898569] br-lan: port 1(lan0) entered disabled state
[   12.906867] device lan0 entered promiscuous mode
[   12.911487] device eth0 entered promiscuous mode
[   12.928201] mt7530 mdio-bus:1f lan1: configuring for phy/gmii link mode
[   12.939947] br-lan: port 2(lan1) entered blocking state
[   12.945213] br-lan: port 2(lan1) entered disabled state
[   12.953488] device lan1 entered promiscuous mode
[   12.965071] mt7530 mdio-bus:1f lan2: configuring for phy/gmii link mode
[   12.972882] br-lan: port 3(lan2) entered blocking state
[   12.978177] br-lan: port 3(lan2) entered disabled state
[   12.987037] device lan2 entered promiscuous mode
[   12.998566] mt7530 mdio-bus:1f lan3: configuring for phy/gmii link mode
[   13.010587] br-lan: port 4(lan3) entered blocking state
[   13.015860] br-lan: port 4(lan3) entered disabled state
[   13.025401] device lan3 entered promiscuous mode
[   13.036502] mt7530 mdio-bus:1f lan4: configuring for inband/sgmii link mode
[   13.085611] br-lan: port 5(lan4) entered blocking state
[   13.090840] br-lan: port 5(lan4) entered disabled state
[   13.100220] device lan4 entered promiscuous mode
[   13.163995] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:07] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   13.174196] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/sgmii link mode
[   22.200220] irq 82: nobody cared (try booting with the "irqpoll" option)
[   22.206918] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.64 #0
[   22.212907] Hardware name: MediaTek MT7986a RFB (DT)
[   22.217679] Call trace:
[   22.220110]  dump_backtrace+0x0/0x15c
[   22.223764]  show_stack+0x14/0x30
[   22.227064]  dump_stack_lvl+0x64/0x7c
[   22.230714]  dump_stack+0x14/0x2c
[   22.234014]  __report_bad_irq+0x48/0x128
[   22.237921]  note_interrupt+0x2e4/0x340
[   22.241742]  handle_irq_event+0xb8/0xe0
[   22.245564]  handle_level_irq+0xd4/0x1b4
[   22.249470]  generic_handle_domain_irq+0x28/0x3c
[   22.254070]  mtk_eint_irq_handler+0x230/0x28c
[   22.258413]  handle_domain_irq+0x5c/0x8c
[   22.262319]  gic_handle_irq+0x50/0x120
[   22.266052]  call_on_irq_stack+0x28/0x44
[   22.269958]  do_interrupt_handler+0x4c/0x54
[   22.274125]  el1_interrupt+0x2c/0x4c
[   22.277685]  el1h_64_irq_handler+0x14/0x20
[   22.281765]  el1h_64_irq+0x74/0x78
[   22.285150]  arch_cpu_idle+0x14/0x20
[   22.288710]  do_idle+0xc0/0x140
[   22.291839]  cpu_startup_entry+0x24/0x50
[   22.295746]  rest_init+0xc4/0xd0
[   22.298959]  arch_call_rest_init+0xc/0x14
[   22.302952]  start_kernel+0x5b4/0x5d4
[   22.306598]  __primary_switched+0xa0/0xa8
[   22.310591] handlers:
[   22.312848] [<00000000d86558ec>] irq_default_primary_handler threaded [<00000000d8282601>] mt7530_irq_thread_fn
[   22.322918] Disabling IRQ #82
  • /proc/interrupts:
           CPU0       CPU1       CPU2       CPU3       
 11:        955       2038       1400       1100     GICv3  30 Level     arch_timer
 14:          0          0          0          0     GICv3 142 Level     wdt_bark
 25:          0          0          0          0   mt-eint   9 Edge      keys
 26:          0          0          0          0   mt-eint  10 Edge      keys
 82:     100001          0          0          0   mt-eint  66 Level     mt7530
 83:          0          0          0          0   mt-eint  67 Edge      keys
117:          0          0          0          0     GICv3 148 Level     10320000.crypto
118:          0          0          0          0     GICv3 149 Level     10320000.crypto
119:          0          0          0          0     GICv3 150 Level     10320000.crypto
120:          0          0          0          0     GICv3 151 Level     10320000.crypto
121:         83          0          0          0     GICv3 155 Level     ttyS0
123:          5          0          0          0     GICv3 172 Level     1100a000.spi
124:          0          0          0          0     GICv3 205 Level     xhci-hcd:usb1
126:         17          0          0          0     GICv3 229 Level     15100000.ethernet
127:          0          0          0          0     GICv3 230 Level     15100000.ethernet
129:       1246          0          0          0     GICv3 245 Level     mt7915e
133:          0          0          0          0    mt7530   0 Edge      mt7530-0:00
134:          0          0          0          0    mt7530   1 Edge      mt7530-0:01
135:          0          0          0          0    mt7530   2 Edge      mt7530-0:02
136:          0          0          0          0    mt7530   3 Edge      mt7530-0:03
IPI0:      1210       2071       1197       1068       Rescheduling interrupts
IPI1:      2419      98556       2127       1791       Function call interrupts
IPI2:         0          0          0          0       CPU stop interrupts
IPI3:         0          0          0          0       CPU stop (for crash dump) interrupts
IPI4:         0          0          0          0       Timer broadcast interrupts
IPI5:         1          0          0          0       IRQ work interrupts
IPI6:         0          0          0          0       CPU wake-up interrupts
Err:          0

If you did edit the MediaTek MT7986a RFB device tree, please also share your copy of the dts.

&eth {
	status = "okay";

	gmac0: mac@0 {
		compatible = "mediatek,eth-mac";
		reg = <0>;
		phy-mode = "2500base-x";

		fixed-link {
			speed = <2500>;
			full-duplex;
			pause;
		};
	};

	gmac1: mac@1 {
		compatible = "mediatek,eth-mac";
		reg = <1>;
		phy-mode = "sgmii";
		phy-handle = <&phy7>;
		managed = "in-band-status";
	};

	mdio: mdio-bus {
		#address-cells = <1>;
		#size-cells = <0>;
	};
};

&mdio {
	switch: switch@0 {
		compatible = "mediatek,mt7531";
		reg = <31>;
		reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
		interrupt-controller;
		#interrupt-cells = <1>;
		interrupt-parent = <&pio>;
		interrupts = <66 IRQ_TYPE_LEVEL_HIGH>;
	};

	phy5: ethernet-phy@5 {
		reg = <5>;
	};

	phy7: ethernet-phy@7 {
		reg = <7>;
	};
};

&switch {
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			label = "lan0";
		};

		port@1 {
			reg = <1>;
			label = "lan1";
		};

		port@2 {
			reg = <2>;
			label = "lan2";
		};

		port@3 {
			reg = <3>;
			label = "lan3";
		};

		port@5 {
			reg = <5>;
			label = "lan4";
			phy-mode = "sgmii";
			phy-handle = <&phy5>;
			managed = "in-band-status";
		};

		port@6 {
			reg = <6>;
			label = "cpu";
			ethernet = <&gmac0>;
			phy-mode = "2500base-x";

			fixed-link {
				speed = <2500>;
				full-duplex;
				pause;
			};
		};
	};
};

Thanks a lot for your patches, but after I changed phy-mode to "2500base-x" both rtl8221b (connect to mt7531 p5 adn eth1) still didn't work.

[   11.616406] device lan3 entered promiscuous mode
[   11.625746] mt7530 mdio-bus:1f lan4: configuring for inband/2500base-x link mode
[   11.633152] mt7530 mdio-bus:1f: mt753x_phylink_mac_config: unsupported 2500base-x port: 5
[   11.641754] br-lan: port 5(lan4) entered blocking state
[   11.647030] br-lan: port 5(lan4) entered disabled state
[   11.654481] device lan4 entered promiscuous mode
[   11.663824] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/2500base-x link mode

The support for in-band managed 1000Base-X and 2500Base-X on MT7531 is only present in openwrt.git master branch, not yet in @lynxis tree. Try picking commit https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=bd6783f4fb8f6171927e9067c0005a6d69fc13fe on top of it.

The other PHY which is directly connected to GMAC1 should already work though, right?

With the master branch and the patches from lynxis, now I don't get any error with phy-mode = "2500base-x", but when I plug and unplug the network cable connected to the rtl8221b phy, the system has no output.

[   15.828410] mt7530 mdio-bus:1f lan4: configuring for inband/2500base-x link mode
[   15.837186] mt7530 mdio-bus:1f lan4: Link is Up - 2.5Gbps/Full - flow control off
[   15.837267] br-lan: port 5(lan4) entered blocking state
[   15.849903] br-lan: port 5(lan4) entered disabled state
[   15.857352] device lan4 entered promiscuous mode
[   15.864266] br-lan: port 5(lan4) entered blocking state
[   15.869497] br-lan: port 5(lan4) entered forwarding state
[   15.880418] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/2500base-x link mode
[   16.643810] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   16.963850] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 2.5Gbps/Full - flow control off
[   16.972309] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

mdio responds fine:

root@OpenWrt:/# mdio mdio-bus
 DEV      PHY-ID  LINK
0x05  0x001cc849  down
0x06  0x00000000  down
0x07  0x001cc849  up

Remove the above (managed = "in-band-status";) from both 2.5G PHY sections if you want link status to come from the external PHY (rather than internal MT7986 SGMII SerDes PCS).

Thank you very much for your suggestion, now the eth1 port can work normally in 2.5g mode. Port lan4 (connected to mt7531 p5) log prints normally, but no network communication.

[   63.205036] mt7530 mdio-bus:1f lan4: Link is Up - 1Gbps/Full - flow control rx/tx
[   63.212535] br-lan: port 5(lan4) entered blocking state
[   63.217760] br-lan: port 5(lan4) entered forwarding state
[   63.223621] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready