Support for RTL838x based managed switches

Hi there @svanheule; here's my GS1900-24HP v1:

root@gs1900-24hp:/tmp# fw_printenv
baudrate=115200
boardmodel=ZyXEL_GS1900_24HP
bootargs=console=ttyS0,115200 mem=64M quiet
bootcmd=cst fcTest; boota
bootdelay=0
bootpartition=0
ethact=rtl8380#0
ethaddr=04:BF:6D:22:F5:F8
ipaddr=10.0.7.2
netmask=255.255.255.0
serverip=10.0.7.1
stderr=serial
stdin=serial
stdout=serial

From my GS1900-24 v1:

root@OpenWrt:~# fw_printenv
baudrate=115200
boardmodel=ZyXEL_GS1900_24
bootargs=console=ttyS0,115200 mem=64M quiet
bootcmd=cst fcTest; boota
bootdelay=0
ethact=rtl8380#0
ethaddr=E4:18:6B:F7:73:85
ipaddr=192.168.1.1
netmask=255.255.255.0
serverip=192.168.1.111
stderr=serial
stdin=serial
stdout=serial

That's the exact patch I've been using since it was posted. Just run make menuconfig or similar after patching and enable "realtek-poe - Realtek PoE Switch Port daemon" under Network. I usually include it in the image, but building as a package should also work.

If you have no such menu entry then something went wrong with your patching.

1 Like

A make clean, inclusion as a default package to my board, and a full build of that board was enough to have the build generate that package.

I suspect the issue with realtek-poe segfaulting may be related to the difference in the PoE board on my GS1900-24HP v1 (in comparison to other PoE boards).

I don't have easy access to the board.

Here's realtek-poe -d:

root@gs1900-24hp:~# realtek-poe -d
TX -> 0x20 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x18
RX -> 0x20 0x01 0x02 0x18 0x00 0xe1 0x11 0x11 0x00 0x01 0x01 0x40
TX -> 0x18 0x02 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x14
RX -> 0x18 0x02 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x15
TX -> 0x18 0x03 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0xff 0xff 0x17
RX -> 0x18 0x03 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x14
TX -> 0x06 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x02
RX -> 0x06 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x02
TX -> 0x18 0x05 0x00 0x02 0x8a 0x00 0x3c 0xff 0xff 0xff 0xff 0xe1
RX -> 0x18 0x05 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x16
TX -> 0x1a 0x06 0x00 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1b
RX -> 0x1a 0x06 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x19
TX -> 0x1c 0x07 0x00 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1f
RX -> 0x1c 0x07 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1c
TX -> 0x15 0x08 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
RX -> 0x15 0x08 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x16
TX -> 0x13 0x09 0x00 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
RX -> 0x13 0x09 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x15
TX -> 0x11 0x0a 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x15
RX -> 0xfe 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xf4
TX -> 0x10 0x0b 0x00 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
RX -> 0x10 0x0b 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x14
TX -> 0x00 0x0c 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x06
RX -> 0x00 0x0c 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x05
TX -> 0x00 0x0d 0x01 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x07
RX -> 0x00 0x0a 0x01 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x07
TX -> 0x00 0x0e 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x09
RX -> 0x00 0x0e 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x09
TX -> 0x00 0x0f 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0b
RX -> 0x00 0x0f 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0b
TX -> 0x00 0x10 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0d
RX -> 0x00 0x10 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0a
TX -> 0x00 0x11 0x05 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0f
RX -> 0x00 0x11 0x05 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0f
TX -> 0x00 0x12 0x06 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x11
RX -> 0x00 0x12 0x06 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x11
TX -> 0x00 0x13 0x07 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x13
RX -> 0x00 0x13 0x07 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x13
TX -> 0x23 0x14 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x2e
RX -> 0x23 0x14 0x00 0x00 0x00 0x00 0x07 0x02 0xff 0xff 0xff 0x3d
TX -> 0x2a 0x15 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x37
RX -> 0x2a 0x15 0x00 0x11 0xc0 0x10 0x10 0x10 0x10 0x10 0x10 0x70
TX -> 0x26 0x16 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x34
RX -> 0x26 0x16 0x00 0x03 0x01 0x4d 0x02 0x00 0xff 0xff 0xff 0x8c
TX -> 0x30 0x17 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3f
RX -> 0x30 0x17 0x00 0x00 0x00 0x00 0x00 0x00 0xce 0x00 0x00 0x15
TX -> 0x26 0x18 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x37
RX -> 0x26 0x18 0x01 0x03 0x01 0x4d 0x00 0x01 0xff 0xff 0xff 0x8e
TX -> 0x30 0x19 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x42
RX -> 0x30 0x19 0x01 0x00 0x00 0x00 0x00 0x00 0xcd 0x00 0x00 0x17
TX -> 0x26 0x1a 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3a
RX -> 0x26 0x1a 0x02 0x03 0x01 0x4d 0x00 0x02 0xff 0xff 0xff 0x92
TX -> 0x30 0x1b 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x45
RX -> 0x30 0x1b 0x02 0x00 0x00 0x00 0x00 0x00 0xcd 0x00 0x00 0x1a
TX -> 0x26 0x1c 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3d
RX -> 0x26 0x1c 0x03 0x03 0x01 0x4d 0x00 0x03 0xff 0xff 0xff 0x96
TX -> 0x30 0x1d 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x48
RX -> 0x30 0x1d 0x03 0x00 0x00 0x00 0x00 0x00 0xce 0x00 0x00 0x1e
TX -> 0x26 0x1e 0x04 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x40
RX -> 0x26 0x1e 0x04 0x03 0x01 0x4d 0x00 0x04 0xff 0xff 0xff 0x9a
TX -> 0x30 0x1f 0x04 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4b
RX -> 0x30 0x1f 0x04 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x1f
TX -> 0x26 0x20 0x05 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x43
RX -> 0x26 0x20 0x05 0x03 0x01 0x4d 0x00 0x05 0xff 0xff 0xff 0x9e
TX -> 0x30 0x21 0x05 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4e
RX -> 0x30 0x21 0x05 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x22
TX -> 0x26 0x22 0x06 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x46
RX -> 0x26 0x22 0x06 0x03 0x01 0x4d 0x00 0x06 0xff 0xff 0xff 0xa2
TX -> 0x30 0x23 0x06 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x51
RX -> 0x30 0x23 0x06 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x25
TX -> 0x26 0x24 0x07 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x49
RX -> 0x26 0x24 0x07 0x03 0x01 0x4d 0x00 0x07 0xff 0xff 0xff 0xa6
TX -> 0x30 0x25 0x07 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x54
RX -> 0x30 0x25 0x07 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x28
TX -> 0x26 0x26 0x08 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4c
RX -> 0x26 0x26 0x08 0x00 0x00 0x4d 0x00 0x08 0xff 0xff 0xff 0xa6

And of ubus call poe info which more clearly demonstrates bugginess:

{
	"firmware": "v17.1",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 65.000000,
	"consumption": 0.000000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		{
			"priority": 0,
			"mode": "",
			"status": "",
			"consumption": 8760293210493327441055989213691904.000000
		},
		{
			"priority": 215,
			"mode": "",
			"status": "unknown"
		}
	}
}

Weird. The name and priority come directly from the config, so I can't see how that's messed up. What does your config file look like?

uh-oh. Hope you don't have to pay for that :slight_smile:

If it would help any, on my GS1900-8HP v1 (latest master, PoE PD on lan1, config here) yields this:

root@OpenWrt:~# realtek-poe -d
Failed to add object: Invalid argument
TX -> 0x20 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x18

Hi @imaginator, I'm having exactly the same problem. I just flashed my DGS-1210-28 and with the vanilla config, it successfully works with IPv6. ARP seems to not be forwarded, so there is basically no IPv4 possible.

I'm running OpenWrt 21.02.2 r16495-bf0c965af0 / Linux 5.4.179

However, I noticed, when I reassign some ports (1-9) to VLAN 100, everything works and the switch can be used at least as a switch.

The second thing I noticed: When I connect a port of each VLAN (1 and 100) of the switch to my home network (with DHCP, etc.) there seem to be some loop created, because lights start flickering fast and Wireshark displays lots of ICMP Neighbor Advertisements.

A few posts above I read about VLAN1 being enabled on all ports, but that seems to has been fixed in #4323.

Is there anything I can do to help debugging this?

Config where switching between 1-9 works:

root@OpenWrt:~# cat /etc/config/network
config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd9f:ebb2:1abf::/48'

config device 'switch'
	option name 'switch'
	option type 'bridge'
	option macaddr 'bc:22:28:7a:21:40'
	list ports 'lan1'
	list ports 'lan10'
	list ports 'lan11'
	list ports 'lan12'
	list ports 'lan13'
	list ports 'lan14'
	list ports 'lan15'
	list ports 'lan16'
	list ports 'lan17'
	list ports 'lan18'
	list ports 'lan19'
	list ports 'lan2'
	list ports 'lan20'
	list ports 'lan21'
	list ports 'lan22'
	list ports 'lan23'
	list ports 'lan24'
	list ports 'lan25'
	list ports 'lan26'
	list ports 'lan27'
	list ports 'lan28'
	list ports 'lan3'
	list ports 'lan4'
	list ports 'lan5'
	list ports 'lan6'
	list ports 'lan7'
	list ports 'lan8'
	list ports 'lan9'
#	option ipv6 '0'
#	option sendredirects '0'
#	option multicast '0'

config bridge-vlan 'wan_vlan'
	option device 'switch'
	option vlan '1'
#	list ports 'lan3'
#	list ports 'lan4'
#	list ports 'lan6'
#	list ports 'lan7'
#	list ports 'lan8'
#	list ports 'lan9'
	list ports 'lan10'
	list ports 'lan11'
	list ports 'lan12'
	list ports 'lan13'
	list ports 'lan14'
	list ports 'lan15'
	list ports 'lan16'
	list ports 'lan17'
	list ports 'lan18'
	list ports 'lan19'
	list ports 'lan20'
	list ports 'lan21'
	list ports 'lan22'
	list ports 'lan23'
	list ports 'lan24'
	list ports 'lan25'
	list ports 'lan26'
	list ports 'lan27'
	list ports 'lan28'

config device
	option name 'switch.1'
	option macaddr 'bc:22:23:7a:21:40'

config bridge-vlan 'lan_vlan'
	option device 'switch'
	option vlan '100'
	list ports 'lan1:t'
	list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'
        list ports 'lan6'
        list ports 'lan7'
        list ports 'lan8'
        list ports 'lan9'

config device
	option name 'switch.100'
	option macaddr 'be:22:28:7a:21:40'

config interface 'lan'
	option device 'switch.100'
	option proto 'dhcp'
#	option delegate '0'

Hi, using today's snapshot, the described issue with VLAN is solved. Seems I had a misconception which commits have landed in the last release.
However, I would like to suggest some modification to the device page of https://openwrt.org/toh/hwdata/d-link/d-link_dgs-1210-28. I was living under the assumption, that the device support has already 'production quality'. Sorry.

Have you tried the snapshot, @imaginator ?

Rather than suggesting modifications, why not make the modifications yourself? That's what a wiki is for!

Hi @RaylynnKnight,

unfortunately, I cannot change the commit message, linked as "Supported Since Commit" on this ToH page, which is in my opinion misleading:

To install, upload the sysupgrade image to the OEM webpage or sysupgrade
from the system running from initramfs image.

It has been developed and tested on device with F1 revision.

It is simply not true. The OEM web interface does not accept the current release or snapshot. Installation via serial console + tftp is necessary.
For the dgs-1210-28 it seems that the same information regarding installation are true as for the dgs-1210-16

What do you think of simply linking the wiki page of dgs-1210-16 for the time being and later move the information to a more generic page for the dgs-1210 series?

Btw: I'm running the switch on snapshot and deployed the switch in a production environment. Apart from small limitations regarding VLAN, it runs absolutely great since the installation four days ago.
Thank you all for the great work!

1 Like

Does installation from OEM work if you flash the initramfs image through the OEM web UI, then boot from the initramfs image, and run sysupgrade after that?

I tried sysupgrade and initramfs from both release and snapshot, but none of them is accepted.

The commit message is misleading and I believe the misleading part occurred because of copy/paste from another commit.

Boot initramfs image from U-Boot

  1. Press Escape key during Hit Esc key to stop autoboot prompt
  2. Press CTRL+C keys to get into real U-Boot prompt
  3. Init network with rtk network on command
  4. Load image with tftpboot 0x8f000000 openwrt-rtl838x-generic-d-link_dgs-1210-28-initramfs->kernel.bin command
  5. Boot the image with bootm command

To install, upload the sysupgrade image to the OEM webpage or sysupgrade
from the system running from initramfs image.

Note that the first line of the instructions is "Boot initramfs image from U-Boot". I think the last sentence was copy/pasted and not edited to remove the OEM webpage which as far as I know has never worked on the D-Link switches.

3 Likes

Has anybody tried using the SFPs yet? My SFP was not displayed using ethtool.

The SFPs are combo ports on this switch, aren't they? What does ethtool lanXX show for one of them? Can you select the FIBRE port instead of TP or MII or whatever it defaults to?

Something like

ethtool -s lanXX port fibre

Discalimer: I have no idea if any of the required phy support is actually there....

I think there is only one PHY (RTL8214FC) that supports these combo ports and this is supported. However we do not provide the necessary I2C access in order to read out the EEPROMS. I also do not know what exactly the limitations are in the kernel support if I2C is not available. I have the impression that things just seem to work, though.

The issue with I2C is due to the fact that on the RTL83xx platforms I2C is bit-banged and the Clock-line is shared between the SFP ports. The linux i2c-gpio driver does not support this. Otherwise it would be quite simple to set this up in the .dts after figuring out the GPIOs either through the "show tech-support" command or by probing the lines in the SFP modules.

1 Like

Haven’t tried it my self yet but as far as I can remember this subject about SFP has been up in this tread earlier.
If I recall right they are not hot pluggable so you need to connect the module and power on the switch. But you can connect the fiber or cable during operational drift. But not change the SFP module.

1 Like

I tested both SFP ports on the NETGEAR GS310T with both Fiber and Copper modules before sending the pull request. Have been side-tracked with other work, but will be resuming adding support for devices I have soon.

2 Likes

Hi @bmork and thanks for the suggestion. I was successfully able to set the configuration on the interface. Unfortunately it seems the configuration only applies to the TP port (see below). I could not test if it works, since my GPON SFP only provides auto negotiation when plugged into the fibre uplink. And currently I have no access to the uplink.

root@sw-doris:~# ethtool -s lan28 port fibre speed 1000 duplex full autoneg off
root@sw-doris:~# ethtool lan28
Settings for lan28:
	Supported ports: [ TP MII FIBRE ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  1000baseT/Full
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 27
	Transceiver: external
	Auto-negotiation: off
	MDI-X: Unknown
	Supports Wake-on: d
	Wake-on: d
	Link detected: no

I tried setting up the correct IP address anyway, but I get no connection.

I don't know if this was meant only in the D-Link DGS-1210-28 specific context?

But this is certainly not true for the realtek target as such. There can of course be device specific exceptions, as the SFP slot implementations vary. I have no first hand experience with any devices with shared i2c clocks or multiplexing phys.

But what I can say is that the SFP slots on the ZyXEL GS1900-10HP are fully functional. This includes hot plug, eeprom access (including DOM), as well as auto-neg, fixed speed (10/100/1000) and duplex for copper SFPs. Which means that the OpenWrt feature set is more complete than the OEM feature set.

2 Likes

Do you have any idea why changing from TP to Fibre doesn't work? Am I doing something wrong?