Bringing support for realtek-poe to mainline OpenWrt

For anyone interested the upcoming Embedded Open Source Summit will have a talk Adding Support for Power Over Ethernet (PoE or IEEE Clause 33) to Linux Network Stack on 2nd day of the summit (Wednesday, April 17 • 11:55am - 12:35pm PDT).

4 Likes

Hey @RaylynnKnight thanks for you work! Is there a proof of concept available for any existing OpenWrt PoE device?

Sorry, I have been distracted by other work and have not kept up with the work being done in mainline. I'm not aware of any proof of concept for any existing OpenWrt devices. It appears that the Microchip PD692x0 and the TI TPS23881 PoE controllers are targeted by the current patches.

It seems that the Linux kernel mainline patches for PoE are targeting the PoE controllers themselves, not the generic intermediate microcontroller used on Realtek switches.
If that impression is correct, the abstraction level of those patches might not be a good fit.

1 Like

Yes, that's correct. There are, however, devices that do not use a control MCU (some TP-Links).

Can someone please let me know which option is currently recommended from a user perspective?

I basically would like to switch certain PoE ports on and off in order to reset attached PoE-devices. I am happy if it is a CLI, ubus call or similar - something i can call from the shell or script.

So far it seems as if poemgr and realtek-poe made their way into the packages.

Do i need those packages in order to control powering the ports when using OpenWRT 23.05.4 for a ZyXEL GS1900-10HP?

Just the latter, the former does not work for the Broadcom PSE AFAIK that the supported RTL838x PoE switches come with.

Ok, thanks, it seems to work:

wget -O /tmp/poe.ipk https://downloads.openwrt.org/releases/23.05.4/packages/mips_4kec/packages/realtek-poe_39c93d39-2_mips_4kec.ipk
opkg install /tmp/poe.ipk

And then i can the configured ports from /etc/config/poe:

root@Zyxel8HP:~# ubus call poe info
{
	"firmware": "v22.4",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 170.000000,
	"consumption": 1.400000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		}
	}
}

I configured lan4, where a poe device is attached in /etc/config/poe:

config global
	option budget	'170'

config port
	option enable	'1'
	option id	'1'
	option name	'lan1'
	option poe_plus	'1'
	option priority	'2'

config port
	option enable '1'
	option id '4'
	option name 'lan4'
	option poe_plus '1'
	option priority '3'

and now i can see it is indeed giving me a figure that looks kind of ok for the power state and power consumption:

root@Zyxel8HP:~# ubus call poe info
{
	"firmware": "v22.4",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 170.000000,
	"consumption": 2.600000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan4": {
			"priority": 3,
			"mode": "PoE+",
			"status": "Delivering power",
			"consumption": 2.600000
		}
	}
}

The question for me is, which ubus call allows me to switch the lan4 power off and back on, whilst keeping other ports functional?

ubus call poe manage "{ 'port': '$PORT', 'enable': false }"
3 Likes

@Borromini & @stragies:

Thank you, that works as intended :grinning: :+1:. This does indeed power-cycle the device attached to port 'lan4' then:

ubus call poe manage "{ 'port': 'lan4', 'enable': false }" && \
sleep 10 && \
ubus call poe manage "{ 'port': 'lan4', 'enable': true }"

Edit #1:
In case someone else stumbles across this, these are the functions ubus can call from realtek-poe:

root@Zyxel8HP:~# ubus -v list poe
'poe' @324788d8
	"info":{}
	"reload":{}
	"sendframe":{"frame":"String"}
	"manage":{"port":"String","enable":"Boolean"}
4 Likes

I installed realtek-poe onto 23.05.3 on a GS1900-24HPv1 and it works fine, but the only issue is the logs fill up with loads of these . does not seem to affect anything at all, just spammy. is there a way to silence these? or should i be concerned?

Aug  2 16:32:02 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:32:02 10.10.10.2 realtek-poe: 	CMD:    30 4b 04 ff ff ff ff ff ff ff ff 77
Aug  2 16:32:02 10.10.10.2 realtek-poe: 	reply:  ff c2 30 4b 04 00 00 00 00 00 c0 00
Aug  2 16:32:08 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:32:08 10.10.10.2 realtek-poe: 	CMD:    26 e7 00 ff ff ff ff ff ff ff ff 05
Aug  2 16:32:08 10.10.10.2 realtek-poe: 	reply:  ff a7 26 e7 00 00 00 4d 00 00 ff ff
Aug  2 16:33:07 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:33:07 10.10.10.2 realtek-poe: 	CMD:    30 3b 0c ff ff ff ff ff ff ff ff 6f
Aug  2 16:33:07 10.10.10.2 realtek-poe: 	reply:  ff c8 30 3b 0c 00 00 00 00 00 c2 00
Aug  2 16:33:11 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:33:11 10.10.10.2 realtek-poe: 	CMD:    30 b5 12 ff ff ff ff ff ff ff ff ef
Aug  2 16:33:11 10.10.10.2 realtek-poe: 	reply:  ff 4e 30 b5 12 00 00 00 00 00 bc 00
Aug  2 16:33:43 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:33:43 10.10.10.2 realtek-poe: 	CMD:    30 2d 16 ff ff ff ff ff ff ff ff 6b
Aug  2 16:33:43 10.10.10.2 realtek-poe: 	reply:  ff ce 30 2d 16 00 00 00 00 00 c0 00
Aug  2 16:34:07 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:34:07 10.10.10.2 realtek-poe: 	CMD:    30 b7 11 ff ff ff ff ff ff ff ff f0
Aug  2 16:34:07 10.10.10.2 realtek-poe: 	reply:  ff 4e 30 b7 11 00 00 00 00 00 bb 00
Aug  2 16:34:41 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:34:41 10.10.10.2 realtek-poe: 	CMD:    30 48 06 ff ff ff ff ff ff ff ff 76
Aug  2 16:34:41 10.10.10.2 realtek-poe: 	reply:  ff c3 30 48 06 00 00 00 00 00 c0 00
Aug  2 16:34:49 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:34:49 10.10.10.2 realtek-poe: 	CMD:    30 38 10 ff ff ff ff ff ff ff ff 70
Aug  2 16:34:49 10.10.10.2 realtek-poe: 	reply:  ff cd 30 38 10 00 00 00 00 00 bc 00
Aug  2 16:34:59 10.10.10.2 realtek-poe: MCU rejected command: not-ready
Aug  2 16:34:59 10.10.10.2 realtek-poe: 	CMD:    30 3f 0a ff ff ff ff ff ff ff ff 71
Aug  2 16:34:59 10.10.10.2 realtek-poe: 	reply:  ff c8 30 3f 0a 00 00 00 00 00 c0 00
# ubus call poe info
{
	"firmware": "v17.1",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 170.000000,
	"consumption": 11.700000,

That looks like a couple of extra bytes in the Rx buffer, that throws the packet parsing off. It's been on my TODO, just very hard to reproduce and test a fix. It doesn't indicate any failure.

1 Like

Hello,

I'm running two Zyxel GS1900-10HP with identical /etc/config/poe files.

cpuinfo router A:

Click to reveal cpuinfo router A
root@Switch-Keller:~# cat /proc/cpuinfo 
system type		: RTL8380
machine			: ZyXEL GS1900-10HP Switch
processor		: 0
cpu model		: MIPS 4KEc V7.0
BogoMIPS		: 498.89
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 2, address/irw mask: [0x0fff, 0x0fff]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16
Options implemented	: tlb 4kex 4k_cache 32fpr prefetch mcheck ejtag llsc dc_aliases perf_cntr_intr_bit mm_full
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

cpuinfo router B:

Click to reveal cpuinfo router B
root@Switch-Garage:~# cat /proc/cpuinfo 
system type		: RTL8380
machine			: ZyXEL GS1900-10HP Switch
processor		: 0
cpu model		: MIPS 4KEc V7.0
BogoMIPS		: 498.89
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 2, address/irw mask: [0x0fff, 0x0fff]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16
Options implemented	: tlb 4kex 4k_cache 32fpr prefetch mcheck ejtag llsc dc_aliases perf_cntr_intr_bit mm_full
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

They appear to be the same version as far as I can tell.

The config looks like this. diff says they are identical, so I'm only posting one version:

Click to reveal poe config
root@Switch-Garage:~# cat /etc/config/poe 
config global
	option budget '77'

config port
	option enable '1'
	option id '1'
	option name 'lan1'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '2'
	option name 'lan2'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '3'
	option name 'lan3'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '4'
	option name 'lan4'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '5'
	option name 'lan5'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '6'
	option name 'lan6'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '7'
	option name 'lan7'
	option poe_plus '1'
	option priority '2'

config port
	option enable '1'
	option id '8'
	option name 'lan8'
	option poe_plus '1'
	option priority '2'

However the response from ubus call poe info is different. Why is one not showing any firmware? Any hints what I could do to fix this?

Router B (not working)

root@Switch-Garage:~# ubus call poe info
{
	"firmware": "v0.0",
	"budget": 77.000000,
	"consumption": 0.000000,
	"ports": {
		"lan1": {
			"priority": 2,
			"status": "unknown"
		},
		"lan2": {
			"priority": 2,
			"status": "unknown"
		},
		"lan3": {
			"priority": 2,
			"status": "unknown"
		},
		"lan4": {
			"priority": 2,
			"status": "unknown"
		},
		"lan5": {
			"priority": 2,
			"status": "unknown"
		},
		"lan6": {
			"priority": 2,
			"status": "unknown"
		},
		"lan7": {
			"priority": 2,
			"status": "unknown"
		},
		"lan8": {
			"priority": 2,
			"status": "unknown"
		}
	}
}

Router A (working):

root@Switch-Keller:~# ubus call poe info
{
	"firmware": "v22.4",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 77.000000,
	"consumption": 3.300000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan2": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan3": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan4": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Delivering power",
			"consumption": 3.300000
		},
		"lan5": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan6": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan7": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		},
		"lan8": {
			"priority": 2,
			"mode": "PoE+",
			"status": "Searching"
		}
	}
}

User @applesin posted a lua-implementation for the V2 of the the device

2 Likes

Thank you! I'm still experiencing issues, but I'll continue there.

I'm trying to install realtek-poe on a Zyxel GS1900-8HP running latest OpenWrt 24.10 stable build, using the package "realtek-poe_0~ea32075a-r1_mips_4kec.ipk" from here: https://downloads.openwrt.org/releases/packages-24.10/mips_4kec/packages/

When I try to install it I get the following error:

Unknown package 'realtek-poe'.
Collected errors:
 * pkg_hash_check_unresolved: cannot find dependency libubox20240329 for realtek-poe
 * pkg_hash_check_unresolved: cannot find dependency libubus20250102 for realtek-poe
 * pkg_hash_check_unresolved: cannot find dependency libuci20250120 for realtek-poe
 * pkg_hash_fetch_best_installation_candidate: Packages for realtek-poe found, but incompatible with the architectures configured
 * opkg_install_cmd: Cannot install package realtek-poe.

Googling this has not led me to a solution unfortunately. Any help appreciated!

This is my hardware:

Hostname	OpenWrt
Model	ZyXEL GS1900-8HP v1 Switch
Architecture	RTL8380
Target Platform	realtek/rtl838x
Firmware Version	OpenWrt 23.05.5 r24106-10cc5fcd00 / LuCI openwrt-23.05 branch git-24.264.56413-c7a3562
Kernel Version	5.15.167

When I run opkg update I get:

Downloading https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/routing/Packages.gz
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/routing/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/telephony/Packages.gz
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/telephony/Packages.gz

Collected errors:
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/targets/realtek/rtl838x/packages/Packages.gz, wget returned 5.
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/base/Packages.gz, wget returned 5.
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/luci/Packages.gz, wget returned 5.
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/packages/Packages.gz, wget returned 5.
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/routing/Packages.gz, wget returned 5.
 * opkg_download: Failed to download https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/telephony/Packages.gz, wget returned 5.

Pinging openwrt.org from the switch itself (under Network > Diagnostics) is fine.

Using

wget https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/telephony/Packages.gz

produces

Downloading 'https://downloads.openwrt.org/releases/23.05.5/packages/mips_4kec/telephony/Packages.gz'
Connecting to 151.101.2.132:443
Writing to 'Packages.gz'
Packages.gz          100% |*******************************| 72529   0:00:00 ETA
Download completed (72529 bytes)

So I could manually download all these missing packages, but do I need to unzip them somewhere specific before trying to install realtek-poe again? How do I do that?

I'm an absolute idiot. I was trying to install realtek-poe for 24.10 onto a 23.05.5 system. Used the right version realtek-poe and all is fine.

1 Like

FYI buildbot has decided to not build realtek-poe for realtek rtl839x switches (mips-24kc).