Many devices containing switches have a cable test function available in the UI of the stock firmware, that leverages VCT functions available in e.g. the AR9331, QCA8337, and other chips.
I tried searching for tool, that I could use on Openwrt to (automatically?) measure cable lengths for all devices/individual_ports, but wasn't successful. Or is this built in, and some SNMP MIB makes this info available, if enabled somewhere?
Does somebody know a way? Or could I cobble (easily?) something together using some command-line MDIO-Write/Read tool?
You may be interested in this link. Ethtool has cable-test options. This requires support from the PHY driver
Yes, ethtool has these options
--cable-test-tdr, but I haven't found a device yet, where it works. I usually get something like:
netlink error: PHY driver does not support cable testing
netlink error: Operation not supported
Digging a bit, it seems to be implemented for (some? DSA?) Marvell drivers, and in the rpi4 (https://github.com/torvalds/linux/blob/master/drivers/net/phy/bcm-phy-lib.c) since commit https://github.com/torvalds/linux/commit/11ecf8c55b91806e4dc6a1b9fe7cbf68cdc9b006
Testing on Openwrt complains about missing netlink support in ethtool, which doesn't seem to be an explicit option in the build system, but may be included in
ethtool-full. I'll try that later today.