Support for RTL838x based managed switches

There were many DSA changes introduced in 5.9, this is not unexpected. Can you point me to the compile errors?
In a few places in the code there were already comments giving hints what to do after 5.9, maybe have a look into the code.

Oh, I see... In order to proceed from the place that seems to be possible immediately, I was putting it off.

DSA error log
  CC      drivers/net/dsa/rtl83xx/common.o
  CC      drivers/mtd/mtdchar.o
  AR      drivers/i2c/algos/built-in.a
  CC      drivers/i2c/busses/i2c-gpio.o
  CC      drivers/net/dsa/rtl83xx/dsa.o
  CC      drivers/net/phy/sfp.o
  CC      drivers/net/phy/sfp-bus.o
  CC      drivers/net/phy/fixed_phy.o
  AR      drivers/i2c/busses/built-in.a
  AR      drivers/i2c/muxes/built-in.a
  CC      drivers/i2c/i2c-boardinfo.o
drivers/net/dsa/rtl83xx/common.c: In function 'rtl83xx_sw_probe':
drivers/net/dsa/rtl83xx/common.c:573:13: error: implicit declaration of function 'dsa_switch_alloc'; did you mean 'dsa_switch_find'? [-Werror=implicit-function-declaration]
  priv->ds = dsa_switch_alloc(dev, DSA_MAX_PORTS);
             ^~~~~~~~~~~~~~~~
             dsa_switch_find
drivers/net/dsa/rtl83xx/common.c:573:11: warning: assignment to 'struct dsa_switch *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  priv->ds = dsa_switch_alloc(dev, DSA_MAX_PORTS);
           ^
At top level:
drivers/net/dsa/rtl83xx/common.c:22:13: warning: 'dump_fdb' defined but not used [-Wunused-function]
 static void dump_fdb(struct rtl838x_switch_priv *priv)
             ^~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1274:22: error: initialization of 'enum dsa_tag_protocol (*)(struct dsa_switch *, int,  enum dsa_tag_protocol)' from incompatible pointer type 'enum dsa_tag_protocol (*)(struct dsa_switch *, int)' [-Werror=incompatible-pointer-types]
  .get_tag_protocol = rtl83xx_get_tag_protocol,
                      ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1274:22: note: (near initialization for 'rtl83xx_switch_ops.get_tag_protocol')
drivers/net/dsa/rtl83xx/dsa.c:1284:25: error: initialization of 'void (*)(struct dsa_switch *, int,  unsigned int,  phy_interface_t,  struct phy_device *, int,  int,  bool,  bool)' {aka 'void (*)(struct dsa_switch *, int,  unsigned int,  enum <anonymous>,  struct phy_device *, int,  int,  _Bool,  _Bool)'} from incompatible pointer type 'void (*)(struct dsa_switch *, int,  unsigned int,  phy_interface_t,  struct phy_device *)' {aka 'void (*)(struct dsa_switch *, int,  unsigned int,  enum <anonymous>,  struct phy_device *)'} [-Werror=incompatible-pointer-types]
  .phylink_mac_link_up = rtl83xx_phylink_mac_link_up,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1284:25: note: (near initialization for 'rtl83xx_switch_ops.phylink_mac_link_up')
drivers/net/dsa/rtl83xx/dsa.c:1302:25: error: initialization of 'int (*)(struct dsa_switch *, int,  bool,  struct switchdev_trans *)' {aka 'int (*)(struct dsa_switch *, int,  _Bool,  struct switchdev_trans *)'} from incompatible pointer type 'int (*)(struct dsa_switch *, int,  bool)' {aka 'int (*)(struct dsa_switch *, int,  _Bool)'} [-Werror=incompatible-pointer-types]
  .port_vlan_filtering = rtl83xx_vlan_filtering,
                         ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1302:25: note: (near initialization for 'rtl83xx_switch_ops.port_vlan_filtering')
drivers/net/dsa/rtl83xx/dsa.c:1316:22: error: initialization of 'enum dsa_tag_protocol (*)(struct dsa_switch *, int,  enum dsa_tag_protocol)' from incompatible pointer type 'enum dsa_tag_protocol (*)(struct dsa_switch *, int)' [-Werror=incompatible-pointer-types]
  .get_tag_protocol = rtl83xx_get_tag_protocol,
                      ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1316:22: note: (near initialization for 'rtl930x_switch_ops.get_tag_protocol')
drivers/net/dsa/rtl83xx/dsa.c:1326:25: error: initialization of 'void (*)(struct dsa_switch *, int,  unsigned int,  phy_interface_t,  struct phy_device *, int,  int,  bool,  bool)' {aka 'void (*)(struct dsa_switch *, int,  unsigned int,  enum <anonymous>,  struct phy_device *, int,  int,  _Bool,  _Bool)'} from incompatible pointer type 'void (*)(struct dsa_switch *, int,  unsigned int,  phy_interface_t,  struct phy_device *)' {aka 'void (*)(struct dsa_switch *, int,  unsigned int,  enum <anonymous>,  struct phy_device *)'} [-Werror=incompatible-pointer-types]
  .phylink_mac_link_up = rtl83xx_phylink_mac_link_up,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1326:25: note: (near initialization for 'rtl930x_switch_ops.phylink_mac_link_up')
drivers/net/dsa/rtl83xx/dsa.c:1341:25: error: initialization of 'int (*)(struct dsa_switch *, int,  bool,  struct switchdev_trans *)' {aka 'int (*)(struct dsa_switch *, int,  _Bool,  struct switchdev_trans *)'} from incompatible pointer type 'int (*)(struct dsa_switch *, int,  bool)' {aka 'int (*)(struct dsa_switch *, int,  _Bool)'} [-Werror=incompatible-pointer-types]
  .port_vlan_filtering = rtl83xx_vlan_filtering,
                         ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/rtl83xx/dsa.c:1341:25: note: (near initialization for 'rtl930x_switch_ops.port_vlan_filtering')
cc1: some warnings being treated as errors
make[9]: *** [scripts/Makefile.build:279: drivers/net/dsa/rtl83xx/common.o] Error 1
make[9]: *** Waiting for unfinished jobs....
  CC      drivers/i2c/i2c-core-base.o
  CC      drivers/mtd/mtd_blkdevs.o
  CC      drivers/mtd/mtdblock.o
  CC      drivers/net/phy/marvell.o
  CC      drivers/net/phy/realtek.o
cc1: some warnings being treated as errors
make[9]: *** [scripts/Makefile.build:279: drivers/net/dsa/rtl83xx/dsa.o] Error 1
make[8]: *** [scripts/Makefile.build:496: drivers/net/dsa/rtl83xx] Error 2
make[7]: *** [scripts/Makefile.build:496: drivers/net/dsa] Error 2
make[7]: *** Waiting for unfinished jobs....
  CC      drivers/net/phy/rtl83xx-phy.o
  CC      net/netfilter/core.o
  AR      net/ipv4/netfilter/built-in.a
  CC [M]  net/ipv4/netfilter/nf_defrag_ipv4.o
  AR      drivers/mtd/built-in.a
  CC      net/ipv4/route.o
  CC      net/ipv4/inetpeer.o
drivers/net/phy/rtl83xx-phy.c:97:13: warning: 'rtl8380_sds_rst' defined but not used [-Wunused-function]
 static void rtl8380_sds_rst(int mac)
             ^~~~~~~~~~~~~~~
  CC      drivers/i2c/i2c-core-smbus.o
  AR      net/ethtool/built-in.a
  CC      net/unix/af_unix.o
  CC      net/unix/garbage.o
  CC [M]  net/ipv4/netfilter/nf_log_ipv4.o
  AR      drivers/net/phy/built-in.a
make[6]: *** [scripts/Makefile.build:496: drivers/net] Error 2
make[6]: *** Waiting for unfinished jobs....
  CC      net/unix/sysctl_net_unix.o
  CC      drivers/i2c/i2c-core-of.o
  CC      net/netfilter/nf_log.o
  CC      net/unix/scm.o
  AR      drivers/i2c/built-in.a
make[5]: *** [Makefile:1821: drivers] Error 2
make[5]: *** Waiting for unfinished jobs....
Ethernet error log
  CC      drivers/net/ethernet/rtl838x_eth.o
  CC      net/ipv4/syncookies.o
  AR      drivers/i3c/built-in.a
  AR      drivers/media/i2c/built-in.a
  AR      drivers/media/tuners/built-in.a
  AR      drivers/media/rc/keymaps/built-in.a
  AR      drivers/media/rc/built-in.a
drivers/net/ethernet/rtl838x_eth.c:1848:20: error: initialization of 'void (*)(struct net_device *, unsigned int)' from incompatible pointer type 'void (*)(struct net_device *)' [-Werror=incompatible-pointer-types]
  .ndo_tx_timeout = rtl838x_eth_tx_timeout,
                    ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1848:20: note: (near initialization for 'rtl838x_eth_netdev_ops.ndo_tx_timeout')
drivers/net/ethernet/rtl838x_eth.c:1859:20: error: initialization of 'void (*)(struct net_device *, unsigned int)' from incompatible pointer type 'void (*)(struct net_device *)' [-Werror=incompatible-pointer-types]
  .ndo_tx_timeout = rtl838x_eth_tx_timeout,
                    ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1859:20: note: (near initialization for 'rtl839x_eth_netdev_ops.ndo_tx_timeout')
drivers/net/ethernet/rtl838x_eth.c:1870:20: error: initialization of 'void (*)(struct net_device *, unsigned int)' from incompatible pointer type 'void (*)(struct net_device *)' [-Werror=incompatible-pointer-types]
  .ndo_tx_timeout = rtl838x_eth_tx_timeout,
                    ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1870:20: note: (near initialization for 'rtl930x_eth_netdev_ops.ndo_tx_timeout')
drivers/net/ethernet/rtl838x_eth.c:1881:20: error: initialization of 'void (*)(struct net_device *, unsigned int)' from incompatible pointer type 'void (*)(struct net_device *)' [-Werror=incompatible-pointer-types]
  .ndo_tx_timeout = rtl838x_eth_tx_timeout,
                    ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1881:20: note: (near initialization for 'rtl931x_eth_netdev_ops.ndo_tx_timeout')
drivers/net/ethernet/rtl838x_eth.c:1886:3: error: 'const struct phylink_mac_ops' has no member named 'mac_link_state'; did you mean 'mac_link_down'?
  .mac_link_state = rtl838x_mac_pcs_get_state,
   ^~~~~~~~~~~~~~
   mac_link_down
drivers/net/ethernet/rtl838x_eth.c:1886:20: error: initialization of 'void (*)(struct phylink_config *, struct phylink_link_state *)' from incompatible pointer type 'int (*)(struct phylink_config *, struct phylink_link_state *)' [-Werror=incompatible-pointer-types]
  .mac_link_state = rtl838x_mac_pcs_get_state,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1886:20: note: (near initialization for 'rtl838x_phylink_ops.mac_pcs_get_state')
drivers/net/ethernet/rtl838x_eth.c:1890:17: error: initialization of 'void (*)(struct phylink_config *, struct phy_device *, unsigned int,  phy_interface_t,  int,  int,  bool,  bool)' {aka 'void (*)(struct phylink_config *, struct phy_device *, unsigned int,  enum <anonymous>,  int,  int,  _Bool,  _Bool)'} from incompatible pointer type 'void (*)(struct phylink_config *, unsigned int,  phy_interface_t,  struct phy_device *)' {aka 'void (*)(struct phylink_config *, unsigned int,  enum <anonymous>,  struct phy_device *)'} [-Werror=incompatible-pointer-types]
  .mac_link_up = rtl838x_mac_link_up,
                 ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/rtl838x_eth.c:1890:17: note: (near initialization for 'rtl838x_phylink_ops.mac_link_up')
drivers/net/ethernet/rtl838x_eth.c: In function 'rtl838x_eth_probe':
drivers/net/ethernet/rtl838x_eth.c:2067:13: error: too few arguments to function 'of_get_phy_mode'
  phy_mode = of_get_phy_mode(dn);
             ^~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/rtl838x_eth.c:15:
./include/linux/of_net.h:15:12: note: declared here
 extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
            ^~~~~~~~~~~~~~~
  AR      drivers/media/common/b2c2/built-in.a
  AR      drivers/media/platform/ti-vpe/built-in.a
cc1: some warnings being treated as errors
make[8]: *** [scripts/Makefile.build:279: drivers/net/ethernet/rtl838x_eth.o] Error 1
make[7]: *** [scripts/Makefile.build:496: drivers/net/ethernet] Error 2
make[6]: *** [scripts/Makefile.build:496: drivers/net] Error 2
make[6]: *** Waiting for unfinished jobs....

The phy driver many not have a problem.

At first sight, this does not look too bad.
The easiest is the rtl838x_eth_tx_timeout function. Just add ", unsigned int txqueue" in the definition of the function in rtl838x_eth.c. Then there is dsa_switch_alloc() which went away. In common.c just apply the same recipe that is provided in https://lore.kernel.org/lkml/20191020031941.3805884-17-vivien.didelot@gmail.com/
For the tag protocol, just add like for the tx_timout function an additional argument in the argument list and ignore it in the function: ", enum dsa_tag_protocol mprot"
Let's see where this gets you and I will look at the other errors.

1 Like

I tried to backport the upstreamed SPI driver and succeeded.

[    1.598013] spi-nor spi0.0: mx25l25635e (32768 Kbytes)
[    1.603896] 8 fixed-partitions partitions found on MTD device spi0.0
[    1.611111] Creating 8 MTD partitions on "spi0.0":
[    1.616620] 0x000000000000-0x000000080000 : "u-boot"
[    1.628049] 0x000000080000-0x0000000c0000 : "u-boot-env"
[    1.636707] 0x0000000c0000-0x000000100000 : "u-boot-env2"
[    1.650101] 0x000000100000-0x000000e80000 : "firmware"
[    1.681183] 0x000000e80000-0x000001000000 : "kernel2"
[    1.689342] 0x000001000000-0x000001040000 : "sysinfo"
[    1.702177] 0x000001040000-0x000001c40000 : "rootfs2"
[    1.710408] 0x000001c40000-0x000002000000 : "jffs2"
/proc/mtd, hexdump
root@OpenWrt:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00010000 "u-boot"
mtd1: 00040000 00010000 "u-boot-env"
mtd2: 00040000 00010000 "u-boot-env2"
mtd3: 00d80000 00010000 "firmware"
mtd4: 00180000 00010000 "kernel2"
mtd5: 00040000 00010000 "sysinfo"
mtd6: 00c00000 00010000 "rootfs2"
mtd7: 003c0000 00010000 "jffs2"
root@OpenWrt:/# hexdump -n 128 -C /dev/mtdblock0
00000000  10 00 00 ff 00 00 00 00  10 00 00 fd 00 00 00 00  |................|
00000010  10 00 01 01 00 00 00 00  10 00 00 ff 00 00 00 00  |................|
00000020  10 00 00 fd 00 00 00 00  10 00 00 fb 00 00 00 00  |................|
00000030  10 00 00 f9 00 00 00 00  10 00 00 f7 00 00 00 00  |................|
00000040  10 00 00 f5 00 00 00 00  10 00 00 f3 00 00 00 00  |................|
00000050  10 00 00 f1 00 00 00 00  10 00 00 ef 00 00 00 00  |................|
00000060  10 00 00 ed 00 00 00 00  10 00 00 eb 00 00 00 00  |................|
00000070  10 00 00 e9 00 00 00 00  10 00 00 e7 00 00 00 00  |................|
00000080
root@OpenWrt:/# hexdump -n 128 -C /dev/mtdblock1
00000000  19 99 24 fe 62 61 75 64  72 61 74 65 3d 31 31 35  |..$.baudrate=115|
00000010  32 30 30 00 62 6f 61 72  64 6d 6f 64 65 6c 3d 52  |200.boardmodel=R|
00000020  54 4c 38 33 38 32 4d 5f  49 4e 54 50 48 59 5f 38  |TL8382M_INTPHY_8|
00000030  32 31 38 42 5f 38 32 31  34 46 43 5f 44 45 4d 4f  |218B_8214FC_DEMO|
00000040  00 62 6f 6f 74 63 6d 64  3d 62 6f 6f 74 61 00 62  |.bootcmd=boota.b|
00000050  6f 6f 74 64 65 6c 61 79  3d 31 00 64 69 61 67 6d  |ootdelay=1.diagm|
00000060  6f 64 65 3d 34 00 65 74  68 61 63 74 3d 72 74 6c  |ode=4.ethact=rtl|
00000070  38 33 38 30 23 30 00 65  74 68 61 64 64 72 3d 42  |8380#0.ethaddr=B|
00000080
3 Likes

Great!
The rest of the compilation errors are also easy: mac_link_state simply got renamed to mac_pcs_get_state
so we also need to do that. And finally in rtl838x_eth.c lines 2067:

    phy_mode = PHY_INTERFACE_MODE_NA;
err = of_get_phy_mode(dn, &phy_mode);
if (err < 0) {
	dev_err(&pdev->dev, "incorrect phy-mode\n");
	err = -EINVAL;
	goto err_free;
}
2 Likes

Thank you! I'll try to fix the errors :slight_smile:

BTW, the upstreamed GPIO driver (gpio-realtek-otto) probably doesn't support the pin range 32-159, so additional driver(s) may be needed to use the range.

I believe this is the Realtek RTL8231 driver that has been taken out of the initial driver and that is now developed separately by @svanheule . I believe he wanted to get it ready for submission to mainline last week. Maybe we can get his latest version directly into OpenWRT?

3 Likes

I succeded to change the GPIO 47 (system status LED, bit 15 in LED_GLB_CTRL) to GPIO 24 (SoC GPIO: 0) with the following bindings in 5.10:

  • rtl838x.dtsi

      /* LED_GLB_CTRL */
      pinmux_led: pinmux@bb00a000 {
      	compatible = "pinctrl-single";
      	reg = <0xbb00a000 0x4>;
    
      	pinctrl-single,bit-per-mux;
      	pinctrl-single,register-width = <32>;
      	pinctrl-single,function-mask = <0x1>;
      	#pinctrl-cells = <2>;
    
      	/* enable GPIO 0 */
      	pinmux_disable_sys_led: disable_sys_led {
      		pinctrl-single,bits = <0x0 0x0 0x8000>;
      	};
      };
    
  • device dts

      leds {
      	pinctrl-names = "default";
      	pinctrl-0 = <&pinmux_disable_sys_led>;
      	compatible = "gpio-leds";
    
      	led_sys_loop: sys_loop {
      		label = "red:sys_loop";
      		gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
      	};
      };
    
2 Likes

This is exactly how I've been muxing that GPIO control :slight_smile:

Like @anon13997276 mentioned, I've been working on a new RTL8231 driver. I was busy with work this week, but should have some more time for the driver in the coming days.

3 Likes

Hi alfa,
I finally came around to add some debugging code which might help to understand you problem. Could you try running https://github.com/bkobl/openwrt/tree/pie on your device and post the output of

root@DLink:/# cat /sys/kernel/debug/rtl838x/drop_counters 
ALE_TX_GOOD_PKTS: 113
MAC_RX_DROP: 0
ACL_FWD_DROP: 0
HW_ATTACK_PREVENTION_DROP: 0
RMA_DROP: 0
VLAN_IGR_FLTR_DROP: 0
INNER_OUTER_CFI_EQUAL_1_DROP: 0
PORT_MOVE_DROP: 0
NEW_SA_DROP: 0
MAC_LIMIT_SYS_DROP: 0
MAC_LIMIT_VLAN_DROP: 0
MAC_LIMIT_PORT_DROP: 0
SWITCH_MAC_DROP: 0
ROUTING_EXCEPTION_DROP: 0
DA_LKMISS_DROP: 0
RSPAN_DROP: 0
ACL_LKMISS_DROP: 0
ACL_DROP: 224
INBW_DROP: 0
IGR_METER_DROP: 0
ACCEPT_FRAME_TYPE_DROP: 0
STP_IGR_DROP: 0
INVALID_SA_DROP: 0
SA_BLOCKING_DROP: 0
DA_BLOCKING_DROP: 0
L2_INVALID_DPM_DROP: 0
MCST_INVALID_DPM_DROP: 0
RX_FLOW_CONTROL_DROP: 0
STORM_SPPRS_DROP: 0
LALS_DROP: 0
VLAN_EGR_FILTER_DROP: 0
STP_EGR_DROP: 0
SRC_PORT_FILTER_DROP: 0
PORT_ISOLATION_DROP: 0
ACL_FLTR_DROP: 0
MIRROR_FLTR_DROP: 0
TX_MAX_DROP: 0
LINK_DOWN_DROP: 869
FLOW_CONTROL_DROP: 0
BRIDGE .1d discards: 0

after say a minute after you have gotten a command prompt on the device? On my D-Link DGS-1210-10P I see similar issues as on your device. My suspicion is that the reason packets are not bridged has to do with them being dropped under LINK_DOWN_DROP as in my case, whatever this then means. You should not see the ACL_DROP category, though. This is me (successfully, yay!) testing the new Packet Inspection Engine code (which I now have to connect to netfilter) in this branch.

1 Like

Hi, I fixed the compile errors of network-related drivers, but the kernel panics at
priv->ports[pn].dp = dsa_to_port(priv->ds, pn);
in rtl83xx_mdio_probe, drivers/net/dsa/rtl83xx/common.c.

pr_info("get DSA port, port number: %u\n", pn);
priv->ports[pn].dp = dsa_to_port(priv->ds, pn);
pr_info("done\n");
bootlog
[   11.180674] get DSA port, port number: 0
[   11.185179] CPU 0 Unable to handle kernel paging request at virtual address 0000001c, epc == 8070dc3c, ra == 8070dc2c
[   11.197112] Oops[#1]:
[   11.199669] CPU: 0 PID: 51 Comm: kworker/0:1 Not tainted 5.10.33 #0
[   11.206700] Workqueue: events deferred_probe_work_func
[   11.212442] $ 0   : 00000000 00000001 00000000 00000000
[   11.218293] $ 4   : 8220cd80 0000001c 81501b8c 81501b80
[   11.224145] $ 8   : ffffefff 806d59fc 00000000 00000000
[   11.229998] $12   : 00000000 40000000 00000000 0002c1c2
[   11.235849] $16   : 8173a080 80e37754 81483e10 80e02078
[   11.241701] $20   : 806f52f8 80610000 81483e00 8060c338
[   11.247554] $24   : 00000018 802ec6fc                  
[   11.253406] $28   : 81500000 81501d28 80610000 8070dc2c
[   11.259258] Hi    : 00000000
[   11.262472] Lo    : 00057fa8
[   11.265699] epc   : 8070dc3c rtl83xx_sw_probe+0x544/0xc08
[   11.271729] ra    : 8070dc2c rtl83xx_sw_probe+0x534/0xc08
[   11.277749] Status: 1010ff03 KERNEL EXL IE 
[   11.282431] Cause : 10800008 (ExcCode 02)
[   11.286900] BadVA : 0000001c
[   11.290115] PrId  : 00019070 (MIPS 4KEc)
[   11.294484] Modules linked in:
[   11.297907] Process kworker/0:1 (pid: 51, threadinfo=(ptrval), task=(ptrval), tls=00000000)
[   11.307218] Stack : 82068688 00000000 00000000 00000000 00000000 806ea6a0 805f3204 80610000
[   11.316580]         8066fbb0 00000000 81483e10 806ea6a0 80e30000 00000000 80e30000 806ea6a0
[   11.325935]         00000001 80670000 8066fbb0 80300a04 81483e10 00000000 80e30000 00000000
[   11.335290]         80e30000 81483e10 00000000 802fe3ac 806ea6a0 81501e08 806ea6a0 802fecbc
[   11.344653]         80630000 0000000f 00000000 81501e08 802fec48 00000001 806e521c 806e0000
[   11.354016]         ...
[   11.356754] Call Trace:
[   11.359494] [<8070dc3c>] rtl83xx_sw_probe+0x544/0xc08
[   11.365165] [<80300a04>] platform_drv_probe+0x40/0x94
[   11.370817] [<802fe3ac>] really_probe+0x124/0x520
[   11.376088] [<802fc0b4>] bus_for_each_drv+0x70/0xb0
[   11.381544] [<802fe21c>] __device_attach+0x114/0x178
[   11.387106] [<802fd0e4>] bus_probe_device+0x9c/0xb8
[   11.392570] [<802fd77c>] deferred_probe_work_func+0xbc/0x114
[   11.398907] [<8003d324>] process_one_work+0x220/0x484
[   11.404562] [<8003d8a4>] worker_thread+0x31c/0x5c8
[   11.409937] [<80042b30>] kthread+0x13c/0x144
[   11.414722] [<80001eb8>] ret_from_kernel_thread+0x14/0x1c
[   11.420760] 
[   11.422427] Code: 8fa30024  8c820008  2445001c <8c42001c> 2442fefc  24460104  10c5000a  00000000  8c460018 
[   11.433363] 
[   11.435202] ---[ end trace 3658ac454d5dd534 ]---
[   11.440375] Kernel panic - not syncing: Fatal exception
[   11.446219] Rebooting in 1 seconds..

The current dsa_to_port returns dsa_port from the port list in dsa_switch_tree, but the tree is built when the DSA switch is registered (dsa_register_switch -> dsa_switch_probe). So, priv->ds->dst is null in rtl83xx_mdio_probe.

I think that priv->ports[pn].dp is not yet used in rtl83xx_mdio_probe, it is merely convenient to set this pointer up already in this loop.
My suggestion is to remove that line and instead do in rtl83xx_sw_probe

	if (err) {
		/* Probing fails the 1st time because of missing ethernet driver
		 * initialization. Use this to disable traffic in case the bootloader left if on
		 */
		return err;
	}
	err = dsa_register_switch(priv->ds);
	if (err) {
		dev_err(dev, "Error registering switch: %d\n", err);
		return err;
	}

	for (i = 0; i <= priv->cpu_port; i++)
		priv->ports[i].dp = dsa_to_port(priv->ds, i);

	/* Enable link and media change interrupts. Are the SERDES masks needed? */

Not tested, at your own risk :wink:

2 Likes

Great! I succeeded to boot the device and the switches are working now :+1:

bootlog
BSH-GSXXN# bootm
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   MIPS OpenWrt Linux-5.10.33
   Created:      2021-05-07   8:01:12 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    5777677 Bytes = 5.5 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.10.33 (musashino205@TAIHA.NET) (mips-openwrt-linux-musl-gcc (OpenWrt GCC 8.4.0 r16639-b656199f91) 8.4.0, GNU ld (GNU Binutils) 2.34) #0 Fri May 7 08:01:12 2021
[    0.000000] RTL838X model is 83826800
[    0.000000] SoC Type: RTL8382
[    0.000000] Kernel command line: 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019070 (MIPS 4KEc)
[    0.000000] MIPS: machine is I-O DATA BSH-G24MB
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.
[    0.000000] Primary data cache 16kB, 2-way, VIPT, cache aliases, linesize 16 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 115204K/131072K available (5318K kernel code, 593K rwdata, 1216K rodata, 7200K init, 203K bss, 15868K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x3c4/0x5b4 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 500MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041786 ns
[    0.000020] sched_clock: 32 bits at 250MHz, resolution 4ns, wraps every 8589934590ns
[    0.008672] Calibrating delay loop... 498.89 BogoMIPS (lpj=2494464)
[    0.075533] pid_max: default: 32768 minimum: 301
[    0.081062] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.089113] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.109900] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.120828] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.128517] pinctrl core: initialized pinctrl subsystem
[    0.135700] NET: Registered protocol family 16
[    0.272873] clocksource: Switched to clocksource MIPS
[    0.281725] NET: Registered protocol family 2
[    0.288083] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.297523] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.306074] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.313919] TCP: Hash tables configured (established 1024 bind 1024)
[    0.321451] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.328799] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.337084] NET: Registered protocol family 1
[    0.719514] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.734934] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.741317] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.756413] pinctrl-single bb001000.pinmux: 32 pins, size 4
[    0.763363] pinctrl-single bb00a000.pinmux: 32 pins, size 4
[    0.872677] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.881959] printk: console [ttyS0] disabled
[    0.886872] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    0.896670] printk: console [ttyS0] enabled
[    0.896670] printk: console [ttyS0] enabled
[    0.905995] printk: bootconsole [early0] disabled
[    0.905995] printk: bootconsole [early0] disabled
[    1.575190] brd: module loaded
[    1.587310] spi-nor spi0.0: mx25l12805d (16384 Kbytes)
[    1.593292] 7 fixed-partitions partitions found on MTD device spi0.0
[    1.600398] Creating 7 MTD partitions on "spi0.0":
[    1.605903] 0x000000000000-0x000000080000 : "u-boot"
[    1.617271] 0x000000080000-0x000000090000 : "u-boot-env"
[    1.625873] 0x000000090000-0x0000000a0000 : "u-boot-env2"
[    1.639250] 0x0000000a0000-0x0000001a0000 : "jffs2_cfg"
[    1.647731] 0x0000001a0000-0x0000002a0000 : "jffs2_log"
[    1.660975] 0x0000002a0000-0x000000950000 : "firmware"
[    1.669654] 2 uimage-fw partitions found on MTD device firmware
[    1.676438] Creating 2 MTD partitions on "firmware":
[    1.682013] 0x000000000000-0x0000002d0000 : "kernel"
[    1.694888] 0x0000002d0000-0x0000006b0000 : "rootfs"
[    1.702742] mtd: device 7 (rootfs) set to be root filesystem
[    1.711807] 1 squashfs-split partitions found on MTD device rootfs
[    1.718864] 0x000000590000-0x0000006b0000 : "rootfs_data"
[    1.727395] 0x000000950000-0x000001000000 : "runtime2"
[    1.751908] libphy: Fixed MDIO Bus: probed
[    1.762491] Probing RTL838X eth device pdev: 81483c00, dev: 81483c10
[    1.785413] Found SoC ID: 8382: RTL8382, family 8380
[    1.790978] rtl8380_init_mac
[    1.794333] Using MAC 00003476c5d9f0a8
[    1.800008] libphy: rtl838x-eth-mdio: probed
[    1.905420] Phy on MAC 0: 1cc981
[    1.919280] Realtek RTL8218B (external) mdio-bus:00: Detected external RTL8218B
[    1.927554] Firmware loaded. Size 1168, magic: 83808380
[    2.582852] random: fast init done
[    3.509176] Realtek RTL8218B (internal) mdio-bus:08: Detected internal RTL8218B
[    3.517468] Firmware loaded. Size 1184, magic: 83808380
[    6.235402] rtl8218d_phy_probe: id: 16
[    6.266929] rtl8218d_phy_probe: id: 17
[    6.298339] rtl8218d_phy_probe: id: 18
[    6.329369] rtl8218d_phy_probe: id: 19
[    6.360789] rtl8218d_phy_probe: id: 20
[    6.392128] rtl8218d_phy_probe: id: 21
[    6.423480] rtl8218d_phy_probe: id: 22
[    6.454839] rtl8218d_phy_probe: id: 23
[    6.464180] NET: Registered protocol family 10
[    6.486346] Segment Routing with IPv6
[    6.490652] NET: Registered protocol family 17
[    6.497023] 8021q: 802.1Q VLAN Support v1.8
[    6.529127] Phy on MAC 0: 1cc981
[    6.543041] Realtek RTL8218B (external) rtl838x slave mii-0:00: Detected external RTL8218B
[    6.552299] Firmware loaded. Size 1168, magic: 83808380
[    8.121248] Realtek RTL8218B (internal) rtl838x slave mii-0:08: Detected internal RTL8218B
[    8.130603] Firmware loaded. Size 1184, magic: 83808380
[   10.842110] rtl8218d_phy_probe: id: 16
[   10.873090] rtl8218d_phy_probe: id: 17
[   10.903927] rtl8218d_phy_probe: id: 18
[   10.934758] rtl8218d_phy_probe: id: 19
[   10.965580] rtl8218d_phy_probe: id: 20
[   10.996444] rtl8218d_phy_probe: id: 21
[   11.027470] rtl8218d_phy_probe: id: 22
[   11.058285] rtl8218d_phy_probe: id: 23
[   11.165319] libphy: rtl838x slave mii: probed
[   11.196361] In rtl83xx_vlan_setup
[   11.200110] UNKNOWN_MC_PMASK: 000000000fffffff
[   11.205179] VLAN profile 0: L2 learning: 1, UNKN L2MC FLD PMSK 511,          UNKN IPMC FLD PMSK 511, UNKN IPv6MC FLD PMSK: 511
[   13.303327] rtl83xx-switch switch@bb000000 lan1 (uninitialized): PHY [mdio-bus:00] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.330861] rtl83xx-switch switch@bb000000 lan2 (uninitialized): PHY [mdio-bus:01] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.346413] rtl83xx-switch switch@bb000000 lan3 (uninitialized): PHY [mdio-bus:02] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.362211] rtl83xx-switch switch@bb000000 lan4 (uninitialized): PHY [mdio-bus:03] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.377890] rtl83xx-switch switch@bb000000 lan5 (uninitialized): PHY [mdio-bus:04] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.393562] rtl83xx-switch switch@bb000000 lan6 (uninitialized): PHY [mdio-bus:05] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.409359] rtl83xx-switch switch@bb000000 lan7 (uninitialized): PHY [mdio-bus:06] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.425329] rtl83xx-switch switch@bb000000 lan8 (uninitialized): PHY [mdio-bus:07] driver [Realtek RTL8218B (external)] (irq=POLL)
[   13.441029] rtl83xx-switch switch@bb000000 lan9 (uninitialized): PHY [mdio-bus:08] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.456585] rtl83xx-switch switch@bb000000 lan10 (uninitialized): PHY [mdio-bus:09] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.472404] rtl83xx-switch switch@bb000000 lan11 (uninitialized): PHY [mdio-bus:0a] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.488054] rtl83xx-switch switch@bb000000 lan12 (uninitialized): PHY [mdio-bus:0b] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.503729] rtl83xx-switch switch@bb000000 lan13 (uninitialized): PHY [mdio-bus:0c] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.519533] rtl83xx-switch switch@bb000000 lan14 (uninitialized): PHY [mdio-bus:0d] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.535508] rtl83xx-switch switch@bb000000 lan15 (uninitialized): PHY [mdio-bus:0e] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.551206] rtl83xx-switch switch@bb000000 lan16 (uninitialized): PHY [mdio-bus:0f] driver [Realtek RTL8218B (internal)] (irq=POLL)
[   13.567283] rtl83xx-switch switch@bb000000 lan17 (uninitialized): PHY [mdio-bus:10] driver [REALTEK RTL8218D] (irq=POLL)
[   13.582132] rtl83xx-switch switch@bb000000 lan18 (uninitialized): PHY [mdio-bus:11] driver [REALTEK RTL8218D] (irq=POLL)
[   13.597185] rtl83xx-switch switch@bb000000 lan19 (uninitialized): PHY [mdio-bus:12] driver [REALTEK RTL8218D] (irq=POLL)
[   13.611785] rtl83xx-switch switch@bb000000 lan20 (uninitialized): PHY [mdio-bus:13] driver [REALTEK RTL8218D] (irq=POLL)
[   13.626641] rtl83xx-switch switch@bb000000 lan21 (uninitialized): PHY [mdio-bus:14] driver [REALTEK RTL8218D] (irq=POLL)
[   13.641259] rtl83xx-switch switch@bb000000 lan22 (uninitialized): PHY [mdio-bus:15] driver [REALTEK RTL8218D] (irq=POLL)
[   13.655864] rtl83xx-switch switch@bb000000 lan23 (uninitialized): PHY [mdio-bus:16] driver [REALTEK RTL8218D] (irq=POLL)
[   13.670712] rtl83xx-switch switch@bb000000 lan24 (uninitialized): PHY [mdio-bus:17] driver [REALTEK RTL8218D] (irq=POLL)
[   13.685145] rtl83xx-switch switch@bb000000: configuring for fixed/internal link mode
[   13.694679] DSA: tree 0 setup
[   13.698092] LINK state irq: 20
[   13.701569] In rtl83xx_setup_qos
[   13.705283] Setting up RTL838X QoS
[   13.709098] RTL838X_PRI_SEL_TBL_CTRL(i): 00033112
[   13.714418] Current Intprio2queue setting: 00000000
[   13.719871] QM_PKT2CPU_INTPRI_MAP: 00fac688
[   13.724645] rtl838x_dbgfs_init called
[   13.870875] Freeing unused kernel memory: 7200K
[   13.876056] This architecture does not have kernel memory protection.
[   13.883356] Run /init as init process
[   13.887460]   with arguments:
[   13.890774]     /init
[   13.893394]   with environment:
[   13.896917]     HOME=/
[   13.899547]     TERM=linux
[   13.902762] rtl83xx-switch switch@bb000000: Link is Up - 1Gbps/Full - flow control off
[   14.927659] init: Console is alive
[   14.957391] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[   14.970356] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[   14.993526] init: - preinit -
[   15.386903] random: jshn: uninitialized urandom read (4 bytes read)
[   15.510504] random: jshn: uninitialized urandom read (4 bytes read)
[   16.918879] random: jshn: uninitialized urandom read (4 bytes read)
[   16.998214] random: jshn: uninitialized urandom read (4 bytes read)
[   17.183145] random: jshn: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   21.629739] procd: - early -
[   24.117358] procd: - ubus -
[   24.139215] urandom_read: 1 callbacks suppressed
[   24.139230] random: ubusd: uninitialized urandom read (4 bytes read)
[   24.174280] random: ubusd: uninitialized urandom read (4 bytes read)
[   24.182429] random: ubusd: uninitialized urandom read (4 bytes read)
[   24.199066] procd: - init -
Please press Enter to activate this console.
[   25.221218] kmodloader: loading kernel modules from /etc/modules.d/*
[   25.409518] xt_time: kernel timezone is -0000
[   25.496017] kmodloader: done loading kernel modules from /etc/modules.d/*
[   25.548708] urngd: v1.0.2 started.
[   25.702361] random: crng init done
[   25.706323] random: 1 urandom warning(s) missed due to ratelimiting
[   62.433648] Using MAC 00003476c5d9f0a8
[   62.452021] RESETTING 8380, CPU_PORT 28
[   62.656359] rtl838x-eth bb00a300.ethernet eth0: configuring for fixed/internal link mode
[   62.665426] In rtl838x_mac_config, mode 1
[   62.673095] In rtl838x_mac_config, mode 1
[   62.677656] rtl838x-eth bb00a300.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   62.733021] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   63.268400] device eth0 entered promiscuous mode
[   63.273743] rtl83xx-switch switch@bb000000 lan1: configuring for phy/qsgmii link mode
[   63.283233] 8021q: adding VLAN 0 to HW filter on device lan1
[   63.380792] switch: port 1(lan1) entered blocking state
[   63.386799] switch: port 1(lan1) entered disabled state
[   63.393716] device lan1 entered promiscuous mode
[   63.643125] device switch entered promiscuous mode
[   63.931052] rtl83xx-switch switch@bb000000 lan10: configuring for phy/internal link mode
[   63.940651] 8021q: adding VLAN 0 to HW filter on device lan10
[   64.133726] switch: port 2(lan10) entered blocking state
[   64.139694] switch: port 2(lan10) entered disabled state
[   64.233100] device lan10 entered promiscuous mode
[   64.366333] rtl83xx-switch switch@bb000000 lan11: configuring for phy/internal link mode
[   64.376133] 8021q: adding VLAN 0 to HW filter on device lan11
[   64.463671] switch: port 3(lan11) entered blocking state
[   64.469642] switch: port 3(lan11) entered disabled state
[   64.553095] device lan11 entered promiscuous mode
[   64.675631] rtl83xx-switch switch@bb000000 lan12: configuring for phy/internal link mode
[   64.685508] 8021q: adding VLAN 0 to HW filter on device lan12
[   64.794050] switch: port 4(lan12) entered blocking state
[   64.800019] switch: port 4(lan12) entered disabled state
[   64.857605] device lan12 entered promiscuous mode
[   64.954431] rtl83xx-switch switch@bb000000 lan13: configuring for phy/internal link mode
[   64.964070] 8021q: adding VLAN 0 to HW filter on device lan13
[   65.063748] switch: port 5(lan13) entered blocking state
[   65.069719] switch: port 5(lan13) entered disabled state
[   65.143085] device lan13 entered promiscuous mode
[   65.215604] rtl83xx-switch switch@bb000000 lan14: configuring for phy/internal link mode
[   65.225514] 8021q: adding VLAN 0 to HW filter on device lan14
[   65.324605] switch: port 6(lan14) entered blocking state
[   65.330571] switch: port 6(lan14) entered disabled state
[   65.337374] device lan14 entered promiscuous mode
[   65.453515] rtl83xx-switch switch@bb000000 lan15: configuring for phy/internal link mode
[   65.463227] 8021q: adding VLAN 0 to HW filter on device lan15
[   65.543927] switch: port 7(lan15) entered blocking state
[   65.549894] switch: port 7(lan15) entered disabled state
[   65.556703] device lan15 entered promiscuous mode
[   65.683740] rtl83xx-switch switch@bb000000 lan16: configuring for phy/internal link mode
[   65.693568] 8021q: adding VLAN 0 to HW filter on device lan16
[   65.728871] RTL8380 Link change: status: 1, ports 8000
[   65.753661] switch: port 8(lan16) entered blocking state
[   65.759624] switch: port 8(lan16) entered disabled state
[   65.766414] device lan16 entered promiscuous mode
[   65.872440] rtl83xx-switch switch@bb000000 lan17: configuring for phy/qsgmii link mode
[   65.882132] 8021q: adding VLAN 0 to HW filter on device lan17
[   65.943657] switch: port 9(lan17) entered blocking state
[   65.949625] switch: port 9(lan17) entered disabled state
[   65.956443] device lan17 entered promiscuous mode
[   66.027368] rtl83xx-switch switch@bb000000 lan18: configuring for phy/qsgmii link mode
[   66.036797] 8021q: adding VLAN 0 to HW filter on device lan18
[   66.103832] switch: port 10(lan18) entered blocking state
[   66.109891] switch: port 10(lan18) entered disabled state
[   66.116814] device lan18 entered promiscuous mode
[   66.223466] rtl83xx-switch switch@bb000000 lan19: configuring for phy/qsgmii link mode
[   66.232737] 8021q: adding VLAN 0 to HW filter on device lan19
[   66.293857] switch: port 11(lan19) entered blocking state
[   66.299918] switch: port 11(lan19) entered disabled state
[   66.306822] device lan19 entered promiscuous mode
[   66.364968] rtl83xx-switch switch@bb000000 lan2: configuring for phy/qsgmii link mode
[   66.374621] 8021q: adding VLAN 0 to HW filter on device lan2
[   66.443759] switch: port 12(lan2) entered blocking state
[   66.449726] switch: port 12(lan2) entered disabled state
[   66.456563] device lan2 entered promiscuous mode
[   66.523471] rtl83xx-switch switch@bb000000 lan20: configuring for phy/qsgmii link mode
[   66.532983] 8021q: adding VLAN 0 to HW filter on device lan20
[   66.593746] switch: port 13(lan20) entered blocking state
[   66.599805] switch: port 13(lan20) entered disabled state
[   66.606703] device lan20 entered promiscuous mode
[   66.676474] rtl83xx-switch switch@bb000000 lan21: configuring for phy/qsgmii link mode
[   66.685979] 8021q: adding VLAN 0 to HW filter on device lan21
[   66.752733] switch: port 14(lan21) entered blocking state
[   66.758911] switch: port 14(lan21) entered disabled state
[   66.765836] device lan21 entered promiscuous mode
[   66.841344] rtl83xx-switch switch@bb000000 lan22: configuring for phy/qsgmii link mode
[   66.850912] 8021q: adding VLAN 0 to HW filter on device lan22
[   66.918001] switch: port 15(lan22) entered blocking state
[   66.924197] switch: port 15(lan22) entered disabled state
[   66.930994] device lan22 entered promiscuous mode
[   67.003583] rtl83xx-switch switch@bb000000 lan23: configuring for phy/qsgmii link mode
[   67.013229] 8021q: adding VLAN 0 to HW filter on device lan23
[   67.083271] switch: port 16(lan23) entered blocking state
[   67.089330] switch: port 16(lan23) entered disabled state
[   67.096250] device lan23 entered promiscuous mode
[   67.168035] rtl83xx-switch switch@bb000000 lan24: configuring for phy/qsgmii link mode
[   67.177762] 8021q: adding VLAN 0 to HW filter on device lan24
[   67.242234] switch: port 17(lan24) entered blocking state
[   67.248418] switch: port 17(lan24) entered disabled state
[   67.255354] device lan24 entered promiscuous mode
[   67.351258] rtl83xx-switch switch@bb000000 lan3: configuring for phy/qsgmii link mode
[   67.360771] 8021q: adding VLAN 0 to HW filter on device lan3
[   67.443681] switch: port 18(lan3) entered blocking state
[   67.449647] switch: port 18(lan3) entered disabled state
[   67.456441] device lan3 entered promiscuous mode
[   67.526908] rtl83xx-switch switch@bb000000 lan4: configuring for phy/qsgmii link mode
[   67.536588] 8021q: adding VLAN 0 to HW filter on device lan4
[   67.603753] switch: port 19(lan4) entered blocking state
[   67.609725] switch: port 19(lan4) entered disabled state
[   67.616554] device lan4 entered promiscuous mode
[   67.683555] rtl83xx-switch switch@bb000000 lan5: configuring for phy/qsgmii link mode
[   67.692781] 8021q: adding VLAN 0 to HW filter on device lan5
[   67.757734] switch: port 20(lan5) entered blocking state
[   67.763817] switch: port 20(lan5) entered disabled state
[   67.770534] device lan5 entered promiscuous mode
[   67.843457] rtl83xx-switch switch@bb000000 lan6: configuring for phy/qsgmii link mode
[   67.853043] 8021q: adding VLAN 0 to HW filter on device lan6
[   67.914039] switch: port 21(lan6) entered blocking state
[   67.920007] switch: port 21(lan6) entered disabled state
[   67.926845] device lan6 entered promiscuous mode
[   67.974803] rtl83xx-switch switch@bb000000 lan7: configuring for phy/qsgmii link mode
[   67.984441] 8021q: adding VLAN 0 to HW filter on device lan7
[   68.029576] switch: port 22(lan7) entered blocking state
[   68.035683] switch: port 22(lan7) entered disabled state
[   68.042413] device lan7 entered promiscuous mode
[   68.069033] rtl83xx-switch switch@bb000000 lan8: configuring for phy/qsgmii link mode
[   68.078708] 8021q: adding VLAN 0 to HW filter on device lan8
[   68.122253] switch: port 23(lan8) entered blocking state
[   68.128333] switch: port 23(lan8) entered disabled state
[   68.135152] device lan8 entered promiscuous mode
[   68.161914] rtl83xx-switch switch@bb000000 lan9: configuring for phy/internal link mode
[   68.171470] 8021q: adding VLAN 0 to HW filter on device lan9
[   68.205508] switch: port 24(lan9) entered blocking state
[   68.211477] switch: port 24(lan9) entered disabled state
[   68.218320] device lan9 entered promiscuous mode
[   68.990143] RTL8380 Link change: status: 1, ports 8000
[   69.095189] rtl83xx-switch switch@bb000000 lan16: Link is Up - 1Gbps/Full - flow control off
[   69.153115] switch: port 8(lan16) entered blocking state
[   69.159090] switch: port 8(lan16) entered forwarding state
[   69.193914] IPv6: ADDRCONF(NETDEV_CHANGE): switch: link becomes ready
[   69.230361] IPv6: ADDRCONF(NETDEV_CHANGE): switch.1: link becomes ready
[   69.238522] IPv6: ADDRCONF(NETDEV_CHANGE): switch.100: link becomes ready



BusyBox v1.33.0 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r16602+100-62a0a8607f
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/# ubus call system board
{
        "initramfs": true,
        "kernel": "5.10.33",
        "hostname": "OpenWrt",
        "system": "RTL8382",
        "model": "I-O DATA BSH-G24MB",
        "board_name": "iodata,bsh-g24mb",
        "release": {
                "distribution": "OpenWrt",
                "version": "SNAPSHOT",
                "revision": "r16602+100-62a0a8607f",
                "target": "realtek/generic",
                "description": "OpenWrt SNAPSHOT r16602+100-62a0a8607f"
        }
}
root@OpenWrt:/# ls -alh /sys/class/net/
drwxr-xr-x    2 root     root           0 Jan  1  1970 .
drwxr-xr-x   17 root     root           0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root           0 Jan  1  1970 eth0 -> ../../devices/platform/bb00a300.ethernet/net/eth0
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan1 -> ../../devices/platform/switch@bb000000/net/lan1
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan10 -> ../../devices/platform/switch@bb000000/net/lan10
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan11 -> ../../devices/platform/switch@bb000000/net/lan11
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan12 -> ../../devices/platform/switch@bb000000/net/lan12
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan13 -> ../../devices/platform/switch@bb000000/net/lan13
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan14 -> ../../devices/platform/switch@bb000000/net/lan14
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan15 -> ../../devices/platform/switch@bb000000/net/lan15
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan16 -> ../../devices/platform/switch@bb000000/net/lan16
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan17 -> ../../devices/platform/switch@bb000000/net/lan17
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan18 -> ../../devices/platform/switch@bb000000/net/lan18
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan19 -> ../../devices/platform/switch@bb000000/net/lan19
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan2 -> ../../devices/platform/switch@bb000000/net/lan2
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan20 -> ../../devices/platform/switch@bb000000/net/lan20
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan21 -> ../../devices/platform/switch@bb000000/net/lan21
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan22 -> ../../devices/platform/switch@bb000000/net/lan22
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan23 -> ../../devices/platform/switch@bb000000/net/lan23
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan24 -> ../../devices/platform/switch@bb000000/net/lan24
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan3 -> ../../devices/platform/switch@bb000000/net/lan3
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan4 -> ../../devices/platform/switch@bb000000/net/lan4
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan5 -> ../../devices/platform/switch@bb000000/net/lan5
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan6 -> ../../devices/platform/switch@bb000000/net/lan6
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan7 -> ../../devices/platform/switch@bb000000/net/lan7
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan8 -> ../../devices/platform/switch@bb000000/net/lan8
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lan9 -> ../../devices/platform/switch@bb000000/net/lan9
lrwxrwxrwx    1 root     root           0 Jan  1  1970 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx    1 root     root           0 May  7 08:01 switch -> ../../devices/virtual/net/switch
lrwxrwxrwx    1 root     root           0 May  7 08:01 switch.1 -> ../../devices/virtual/net/switch.1
lrwxrwxrwx    1 root     root           0 May  7 08:01 switch.100 -> ../../devices/virtual/net/switch.100
root@OpenWrt:/# [  176.488987] RTL8380 Link change: status: 1, ports 4
[  176.593109] rtl83xx-switch switch@bb000000 lan3: Link is Up - 1Gbps/Full - flow control off
[  176.602541] switch: port 18(lan3) entered blocking state
[  176.608631] switch: port 18(lan3) entered forwarding state

EDIT:
there are several connection issues:

  • VLAN 100 on "lan1" port cannot be connected (no rx packet on the PC)
  • the PC cannot access to the device on VLAN 1 either SSH or ping
    • allowed input on the firewall

but the device can access to the internet.

my repo: https://github.com/musashino-build/openwrt/tree/tgtbump/rtk_5.10

/etc/config/network
root@OpenWrt:/# cat /etc/config/network 

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd68:4671:9e18::/48'

config device 'switch'
        option name 'switch'
        option type 'bridge'
        option macaddr '34:76:c5:d9:f0:a8'

config bridge-vlan 'wan_vlan'
        option device 'switch'
        option vlan '1'
        option ports ' lan1 lan10 lan11 lan12 lan13 lan14 lan15 lan16 lan17 lan18 lan19 lan2 lan20 lan21 lan22 lan23 lan24 lan3 lan4 lan5 lan6 lan7 lan8 lan9'

config interface 'wan'
        option ifname 'switch.1'
        option proto 'dhcp'

config device 'wan_switch_1_dev'
        option name 'switch.1'
        option macaddr '34:76:c5:d9:f0:a8'

config interface 'wan6'
        option ifname 'switch.1'
        option proto 'dhcpv6'

config bridge-vlan 'lan_vlan'
        option device 'switch'
        option vlan '100'
        option ports 'lan1:t'

config interface 'lan'
        option ifname 'switch.100'
        option proto 'static'
        option ipaddr '192.168.12.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config device 'lan_switch_100_dev'
        option name 'switch.100'
        option macaddr '36:76:c5:d9:f0:a8'
/etc/config/firewall (partial)
config zone
        option name             wan
        list   network          'wan'
        list   network          'wan6'
        option input            ACCEPT
        option output           ACCEPT
        option forward          REJECT
        option masq             1
        option mtu_fix          1
3 Likes

@musashino If you're building on recent master this might be related maybe, concerning the VLAN issues:

https://lists.openwrt.org/pipermail/openwrt-devel/2021-May/034999.html

1 Like

Thank you! Yes, my repo is based on recent master, I'll check it :slight_smile:

1 Like

There should be a patch going into master very soon for the VLAN issue.
Sorry for the mess...

3 Likes

In the meantime would we be able to test by just reverting that particular commit?

You can test the actual fix:

https://lists.openwrt.org/pipermail/openwrt-devel/2021-May/035020.html

Hi, I applied the same fix with the patch on ML to 5.10 and it solves the second issue.

However, the first issue (of VLAN 100) is still there...

bridge vlan
root@OpenWrt:/# bridge vlan
port              vlan-id  
lan1              1 PVID Egress Untagged
                  100
lan2              1 PVID Egress Untagged
lan3              1 PVID Egress Untagged
lan4              1 PVID Egress Untagged
lan5              1 PVID Egress Untagged
lan6              1 PVID Egress Untagged
lan7              1 PVID Egress Untagged
lan8              1 PVID Egress Untagged
lan9              1 PVID Egress Untagged
lan10             1 PVID Egress Untagged
lan11             1 PVID Egress Untagged
lan12             1 PVID Egress Untagged
lan13             1 PVID Egress Untagged
lan14             1 PVID Egress Untagged
lan15             1 PVID Egress Untagged
lan16             1 PVID Egress Untagged
lan17             1 PVID Egress Untagged
lan18             1 PVID Egress Untagged
lan19             1 PVID Egress Untagged
lan20             1 PVID Egress Untagged
lan21             1 PVID Egress Untagged
lan22             1 PVID Egress Untagged
lan23             1 PVID Egress Untagged
lan24             1 PVID Egress Untagged
switch            1
                  100

I may have misunderstood something about GPIO in realtek target...
The reset button on ALLNET ALL-SG8208M and D-Link DGS-1210-10P can be used in current master (5.4)?