Change switch port position

I have a Unielec U4019 and, on OpenWrt, it seems the WAN port is mislabelled on the outside of the device. The swich port labelled WAN is actually LAN1. The LAN4 port is functioning as the WAN port. I want to reverse this so the labels match up, just swap the position of the WAN port over to LAN 1. I have been making some changes to the switch configuration below but have been getting nowhere.

I just want to swap the functionality of the two ports

This is the default in 02_network.sh

	unielec,u4019-32m)
		ucidef_set_interfaces_lan_wan "eth0" "eth1"
		ucidef_add_switch "switch0" \
			"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
;;

If it is indeed just swapping those two parts, then the correct line should be:

ucidef_add_switch "switch0" \
			"0u@eth0" "5:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "0u@eth1" "4:wan"

But are you sure that LAN1, LAN2, LAN3 are correct as well or are they swapped too?
Ideally try each port one by one by plugging a cable, then check the swconfig dev switch0 show output to see which external port corresponds to which internal swconfig port.

1 Like

Thanks, I didn't know you could do that

Can you please break down the syntax of this switch config?

"0u@eth0" "5:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "0u@eth1" "4:wan"

"0u@eth0" => swconfig port 0 is connected to netdev eth0, prefer untagged config
"5:lan:1" => swconfig port 5 is a lan port, but externally labelled as port 1
"1:lan:2" => swconfig port 1 is a lan port, but externally labelled as port 2
"2:lan:3" => swconfig port 2 is a lan port, but externally labelled as port 3
"3:lan:4" => swconfig port 3 is a lan port, but externally labelled as port 4
"0u@eth1" => swconfig port 0 is connected to netdev eth1, prefer untagged config "4:wan" => swconfig port 4 is a wan port

It doesn't actually make much sense that port 0 is assigned to both eth0 and eth1, I just blindly modified the existing example you quoted, maybe it is wrong to begin with.

@jow
IPQ40xx's essedma driver has its own implementation of VLAN, the "eth1" is actually "eth0.2".
That's why the swconfig of this target looks weird.
You can't change the WAN port without changing the dts or driver.

2 Likes

Thanks for the explanation @LGA1150

Does that mean changing this section in the .dtsi from this

		ethphy0: ethernet-phy@0 {
			reg = <0>;
		};

		ethphy1: ethernet-phy@1 {
			reg = <1>;
		};

		ethphy2: ethernet-phy@2 {
			reg = <2>;
		};

		ethphy3: ethernet-phy@3 {
			reg = <3>;
		};

		ethphy4: ethernet-phy@4 {
			reg = <4>;
		};

to this

		ethphy4: ethernet-phy@0 {
			reg = <0>;
		};

		ethphy3: ethernet-phy@1 {
			reg = <1>;
		};

		ethphy2: ethernet-phy@2 {
			reg = <2>;
		};

		ethphy1: ethernet-phy@3 {
			reg = <3>;
		};

		ethphy0: ethernet-phy@4 {
			reg = <4>;
		};

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.