How does portmap and portdisable work on device-tree?

For example:

&esw {
	mediatek,portmap = <0x2f>;
	mediatek,portdisable = <0x2a>;
};

I'm porting new device to OpenWrt and it boots fine. Everything is working except wan port and openwrt thinks lan2 is the wan port.

Can anyone help me to understand logic of the portmap and portdisable ?

This is not to necrobump an old post from two years ago, but to give others the answer who would stumble upon this post, in search for the subject matter.

I came upon this myself while doing my own device ports, and here is the description for those two lines in the device tree. The portmap and portdisable values are the hexadecimal equivalent of the binary representation of the switch ports from 0 to 5.

This means that taking the hexadecimal 0x3f for example, this is 111111 in binary, which corresponds to switch ports 5 to 0 for every bit from left to right. So mediatek,portmap = <0x3f> results in a switch port mapping of all available ports into one vlan. On the other hand mediatek,portdisable = <0x3c> results in the disabling of ports 5 to 2, because 0x3c is 111100 in binary.

-ianp

2 Likes