How can I reliably map between `radioA` and `phyB`?

Is there a way to reliably map radioA IDs from wireless UCI config to phyB IDs? I don't really want to assume that radio0 is phy0 and radio1 is phy1 unless this is guaranteed to be correct.

Is there a way to reliably map radioA IDs from wireless UCI config to phyB IDs? I don't really want to assume that radio0 is phy0 and radio1 is phy1 unless this is guaranteed to be correct.

look at the /etc/config/wireless radioA config and see what /sys/* phy it's
configured to use.

David Lang

I don't seam to see any things relating to sys or phy in the UCI config.

I don't seam to see any things relating to sys or phy in the UCI config.

these are running various versions of LEDE and OpenWRT

on my Turris, I have:

in radio0
option path 'platform/soc/soc:pcie-controller/pci0000:00/0000:00:02.0/0000:02:00.0'

in radio1
option path 'platform/soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0'

root@sun:/sys# uci show wireless.radio1.path
wireless.radio1.path='platform/soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0'

on my wrt1900acs I have

radio0
option path 'soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0'
radio1
option path 'soc/soc:pcie-controller/pci0000:00/0000:00:02.0/0000:02:00.0'

on my WNDR3800 I have

radio0
option path 'pci0000:00/0000:00:11.0'
radio1
option path 'pci0000:00/0000:00:12.0'

on the Turris

root@sun:/sys# find . -name phy[01]
./devices/platform/soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0/ieee80211/phy1
./devices/platform/soc/soc:pcie-controller/pci0000:00/0000:00:02.0/0000:02:00.0/ieee80211/phy0
./class/ieee80211/phy0
./class/ieee80211/phy1
./kernel/debug/ieee80211/phy1
./kernel/debug/ieee80211/phy0

on the wrt1900acs

root@moon:/sys# find . -name phy[01]
./devices/platform/soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0/ieee80211/phy0
./devices/platform/soc/soc:pcie-controller/pci0000:00/0000:00:02.0/0000:02:00.0/ieee80211/phy1
./class/ieee80211/phy1
./class/ieee80211/phy0
./kernel/debug/ieee80211/phy1
./kernel/debug/ieee80211/phy0

on the wndr3800 I have

root@mars:/sys# find . -name phy[01]
./devices/pci0000:00/0000:00:11.0/ieee80211/phy0
./devices/pci0000:00/0000:00:12.0/ieee80211/phy1
./class/ieee80211/phy0
./class/ieee80211/phy1
./kernel/debug/ieee80211/phy1
./kernel/debug/ieee80211/phy0

My /etc/config/wireless starts with these lines:

config wifi-device  radio0
    option type     mac80211
    option phy      phy0
    option channel  auto

If I type uci show wireless in the CLI, I see these lines listed:

wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.phy='phy0'
wireless.radio0.channel='auto'

This lets you manually tie devices to phys. The UCI entry only shows up if the /etc/config/wireless file explicitly sets the mapping.

The other option is to find the mapping from the ifname to the phy. E.g. If you want to know what wlan0 is connected to:

# cat /sys/class/net/wlan0/phy80211/name
phy0

This might be what I need - I'll take a look into this. Thanks.

Will the final option allow you to match radios with phys?

Yes, but it's somewhat complicated and a bit fragile. From uci show wireless you should see these lines:

wireless.@wifi-iface[0].device='radio0'
wireless.@wifi-iface[0].network='wlan'

So if you look up wlan in the network file, it should have something like this

config interface 'wlan'
   option proto 'dhcp'
   option ifname 'wlan0'

and then listing uci show network.wlan should show you:

network.wlan=interface
network.wlan.proto='dhcp'
network.wlan.ifname='wlan0'

So you have to follow the trail from radio0 to network wlan to ifname wlan0 and then use that to look up the phy. This is fragile in that it requires the config to be explicitly captured in the config files. The problem is that it appears that radio0 is not really a concept outside of the config scripts, so the rest of the system does not recognize it.
If you can do without radio, and only deal with ifname (like wlan0) and phy, life will be simpler.