Technically speaking, it's the reverse. By looking at the device tree files (see below) It's eth0 that is connected to a switch. And if in this device the switch is not connected, then it's eth0 that becomes a ghost.
That said, here the kernel thinks this device has 2 ports because its device tree file defines them both. It does so in a roundabout way, but it does.
The dts of this device https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts is just changing some led addresses, and it is otherwise importing whole the gl-ar300m-nor device dts file, https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nor.dts which is again just renaming and importing the gl-ar300m file https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi that is importing the generic SoC's dts file which defines 2 ethernet ports and overrides some settings about them.
Yes device trees are very cool but can get confusing as they keep importing and overriding each other many times.
Since both jeff and star agree that it's eth1 the "right" one, and also your "the port connected to the switch is not used in this device" statement, I think the real solution here is disable eth0 in the dts and then if needed "rename" eth1 into eth0, again in the dts, so for the Linux kernel everything will be ok.
@jeff Try adding this at the end of the gl-ar300m-lite.dts
This should disable the unused eth0 port and leave only the eth1 port enabled.
I also add the property to not increment the mac address of eth1 as that's the primary interface and eth0 is not enabled (this is overriding properties set by the gl-ar300m.dtsi that has 2 ports, and the "primary" port is eth0)
ð0 {
status = "disabled";
};
ð1 {
mtd-mac-address-increment = <0>;
};
The "ð0" and "ð1" you see in the dts are labels (see device tree specification https://github.com/devicetree-org/devicetree-specification/blob/master/source/source-language.rst#labels ).
The actual full interface name and label declaration is in the generic ath79.dtsi which is imported by the SoC dtsi. https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/dts/ath79.dtsi#L66
eth1: eth@1a000000
, where defines that this interface will be called "eth1" in the rest of the dts files importing this one.
Theoretically the kernel should not care about labels and should just call "eth0" the first ethernet interface it sees (and here we should have only one enabled) but I can't guarantee that here.
Try the above and if you still get an eth1 interface (now without an eth0) you can try using aliases or changing the label so you rename the interface.
This is an example to give an alias as "eth0" to the full interface name of what is called "eth1" in the dts.
aliases {
eth0 = "eth@1a000000";
};
For the sake of completeness, this is the specification about aliases https://github.com/devicetree-org/devicetree-specification/blob/master/source/devicenodes.rst#aliases-node