mdio-tools icon indicating copy to clipboard operation
mdio-tools copied to clipboard

Device Auto Detection

Open wkz opened this issue 3 years ago • 0 comments

It would be great if mdio could auto detect commonly used devices and let the user access them with a simple alias.

Ideas:

  • Associate a simple numeric ID with each bus
  • Use sysfs to figure out PHY<->netdev associations
  • Use devlink to locate DSA switches
  • Probe buses to find devices

Create aliases based on:

  1. Associated netdev name, if available
  2. Object type combined with bus ID and address

Example usage:

root@box # mdio dev
DEV         TYPE     ADDR  BUS
mmd0-9      mmd       0x9  *et@30be0000!mdio!switch@4!mdio
mmd0-a      mmd       0xa  *et@30be0000!mdio!switch@4!mdio
eth3        mva       0x8  *et@30be0000!mdio!switch@4!mdio
eth4        mva       0x7  *et@30be0000!mdio!switch@4!mdio
mvls4-4     mvls      0x4  30be0000.ethernet-1
phy0-0      phy       0x0  *et@30be0000!mdio!switch@4!mdio
phy0-1      phy       0x1  *et@30be0000!mdio!switch@4!mdio
phy0-2      phy       0x2  *et@30be0000!mdio!switch@4!mdio
phy0-3      phy       0x3  *et@30be0000!mdio!switch@4!mdio
phy0-4      phy       0x4  *et@30be0000!mdio!switch@4!mdio
phy0-5      phy       0x5  *et@30be0000!mdio!switch@4!mdio
phy0-6      phy       0x6  *et@30be0000!mdio!switch@4!mdio

On such a system

  • mdio dev eth3 raw copper:1 would expand to:
    • mdio *et@30be0000!mdio!switch@4!mdio mva 8 raw copper:1
  • mdio dev mvls4-4 raw g1:0x1a would expand to:
    • mdio 30be0000.ethernet-1 mvls 4 raw g1:0x1a

etc.

wkz avatar Dec 05 '22 09:12 wkz