treewide: Provide label MAC address#2159
Conversation
|
@neoraider This could be interesting for Gluon, too. |
|
Thank you for taking care of this, LGTM. |
|
I added commits for the few non-ath79 devices I can tell the sticker address. I also have data on the FritzBox 4040 (ipq40xx): However, unfortunately I'm not able to identify the corresponding ethernet nodes in the DTS/DTSI files for this one. |
|
Hm... As far as I understood the MAC addresses should always be equal to the stock firmware (Stock LAN MAC = OpenWrt LAN MAC etc.). For adding new devices to Gluon it was important that the primary MAC is correct. You can find the definitions here. What is missing for these devices? Edit:
Can't you retrieve them from the switch configs? |
|
@CodeFetch If you say that the referenced script identifies these "primary" MAC addresses correctly based on the if-conditions, I will just translate those into DTS. |
|
They should. It's part of the checklist for adding device support in Gluon.
|
|
Okay, thanks. |
|
@CodeFetch |
|
x86, brcm2708, ar71xx-mikrotik (ar71xx-generic) tl-wdr3600, tl-wdr4300, tl-wr902ac-v1 (ar71xx-generic) a40, a60, archer-c7-v4, archer-c7-v5, carambola2, koala, mr600, mr600v2, mr900, mr900v2, mr1750, mr1750v2, om2p, om2pv2, om2pv4, om2p-hs, om2p-hsv2, om2p-hsv3, om2p-hsv4, om2p-lc, om5p, om5p-an, om5p-ac, om5p-acv2, unifi-outdoor-plus, unifiac-lite, unifiac-pro (ar71xx-generic) archer-c5, archer-c58-v1, archer-c59-v1, archer-c60-v1, archer-c7 Yes, everything else /sys/class/ieee80211/phy0/macaddress except it does not have a phy0. In that case it's eth0... |
|
Okay, I've now added everything from GLUON EXCEPT
Note that only those devices from ar71xx could be transferred that are already included in ath79 (roughly 50 to 70 per cent). Edit: Obviously anything from GLUON, not from OpenWrt |
|
Question: |
|
In Gluon, we default to the phy0 address for devices without an explicit setting, as this is the most common choice by hardware vendors - it is the address visible as BSSID after all (and that's the only address many users will ever see, if at all). |
Indeed, that's true, and I've exploited that myself :-) However, while this is helpful when sorting out a set of devices, it's irrelevant when you have a single device's DTS alias: I will have to write , e.g., either ð0 or &wifi0 . What I'm looking for is a technical reason, like a bigger likelihood of ethernet or wireless to be initialized correctly or a higher probability of one type to fail in general. |
|
@blogic Since you are listed as maintainer for ipq40xx, maybe you can help me on this one: For example, for the FritzBox 4040 I know: So which node would I refer to in the following statement instead of ð0 (and why?): aliases { |
|
oh boy. Well, the Device-Tree is governed by a different project and different people. so while it's not a problem to specify something cool, it's usually a process to convince the dt folks to make it part of their standard. Do you think you can pitch your idea over at the device-tree project as well? Thanks. |
Well, what I do here is just setting a single alias. This is very much comparable to the led-boot, led-failsafe, etc., only with much less additional code involved. Despite that, I doubt that the functionality established here is of any interest OUTSIDE of the OpenWrt environment. The idea to label a machine consisting of several netif devices with a single MAC address sounds very specific to me. It is very helpful here, but I suspect it won't matter for other projects. |
|
In theory, a device tree describes a piece of hardware - independently of the used operating system. I'd argue that a MAC address that is printed on a sticker is a property of the hardware and deserves to be part of the device tree, even if it is not that useful outside of OpenWrt. |
This is what they say about "aliases" in context of a spi "port": "If those ports are physically organised and labelled the same, then In the latter cases we're altering the hardware description to suit an If you look at your router, the LEDs all have either a label or some sort of
Look: For once, just give it a honest try before making it sound like it that this is just a silly idea, It's not. You've managed to convince several other devs to respond. Hence it should be possible to get upstream to think about how these stickers should be handled. Contrary to popular opinion the devicetree folks are not monsters, they just sometimes make it difficult, but it's part of the process.
There are a lot of devices-tree sources all over the arch/*/boot/dts directories, so why wouldn't it apply to upstream as well? |
|
I've sent an e-mail to devicetree-spec, most probably it is waiting for moderation now. I will post a link when it made it to the archive. |
|
Yes. |
|
One guy from devicetree-spec raised the (in my eyes justified) question whether primary-mac-address is a really good name. Edit: To clarify this: So far, primary-mac-address is the best option I could think of, and that's also in line with the initial feedback on the devicetree-spec list. However, being the best from a relative perspective, it is not precisely great. |
|
label-mac-address? |
|
Rebase. |
baec1c2 to
311f9a1
Compare
|
Rebased and added PISEN TS-D084, TL-MR3420v2. |
|
Rebased and added GL-AR750. |
|
Rebased due to addition of WDR3500 and also added 3500 here. |
|
Added Archer D50 v1. |
|
Would someone please merge this? |
Yes, sorry for the delay, please rebase. |
Just a FYI there's a proper tag Co-developed-by: for such purposes:
|
To refer to the MAC address on a device's label, one can specify the alias label-mac-device in the DTS which should point to the bearer of the corresponding MAC address. With the function get_mac_label, the user can retrieve then retrieve this address and use it as a value that uniquely identifies his device. This is severely helpful for several downstream functionalities, e.g. define MAC addresses of custom netifs or change the SSID to be easily recognizable. Signed-off-by: Adrian Schmutzler <[email protected]>
For many devices, MAC addresses cannot be retrieved via the device tree alias. To still provide the label MAC address for those, this implements a second mechanism that will put the address into uci config. Note that this stores the actual MAC address, whereas in DTS we reference the bearing device. This is based on the work of Rosy Song <[email protected]> Signed-off-by: Adrian Schmutzler <[email protected]>
This patch adds the label MAC address for several devices in ath79. Some devices require setting the MAC address in 02_network: For the following devices, the netif device can be linked in device tree, but the MAC address cannot be read: - alfa-network,ap121f - avm,fritz300e - ubnt-xm devices For the following devices, label MAC address is tied to lan or wan, so no node to link to exists in device tree: - adtran,bsap1800-v2 - adtran,bsap1840 - dlink,dir-842-c1/-c2/-c3 - engenius,ecb1750 - iodata,etg3-r - iodata,wn-ac1167dgr - iodata,wn-ac1600dgr - iodata,wn-ac1600dgr2 - iodata,wn-ag300dgr - nec,wg800hp - nec,wg1200cr - trendnet,tew-823dru Signed-off-by: Adrian Schmutzler <[email protected]>
This patch adds the label MAC address for some devices in mpc85xx. Signed-off-by: Adrian Schmutzler <[email protected]>
This patch adds the label MAC address for several devices in ipq806x. Signed-off-by: Adrian Schmutzler <[email protected]>
|
Thanks! Pulled into my staging tree at https://git.openwrt.org/openwrt/staging/ynezz.git |
|
@mweinelt I think I will to calculate based on the lan_mac in that particular case. |
|
1 Ethernet port |
|
@mweinelt Thanks, that's consistent with what's been reported based on the urlader key value store: |
Problem description:
Despite that most of the netifs have different MAC addresses, each device typically has one specific MAC address which is printed on a sticker somewhere.
This specific address may act as an identifier for the device which is apparent to the user, and thus is used e.g. for MAC adresses or IP addresses of routers in Freifunk firmware.
Other possible uses might be a router-specific SSID instead of "OpenWrt" as suggested in this PR: #1370
Solution concept:
One can introduce an alias to the device DTS files which references the node bearing the MAC address of interest:
By adding a small function
"get_mac_primary""get_mac_label" to /lib/functions/system.sh, this can then be used to retrieve the "label" MAC address where required.This is not limited to ethernet devices, but can also be WiFi etc.
Notes:
CURRENT STATE:
ToDo: Need help for ipq40xx (=> identification of ethernet nodes)Question: Is there a preference ethernet over WiFi or vice-versa if ambiguousToDo: Squash ath79 into one commitDevices with open pull-request and reported address:
D-Link DIR-842 C1 #2276 label_mac=$lan_macD-Link DIR-842 C2 #2259 label_mac=$lan_macCOMFAST CF-E313AC #1942
label-mac-device = ð1;CPExxx @ ar9344 #2252label-mac-device = &wmac;GL-AR750 https://patchwork.ozlabs.org/patch/1135461/label-mac-device = ð0;ALFA Network AP121F #2199label_mac=$(cat /sys/class/ieee80211/phy0/mac-address)TP-Link Archer D7(b) v1 #2079
label-mac-device = &wmac;Devices where label-mac-device is already set:
Archer C60 v1/v2
TP-Link TL-WR940N v3/v4
TP-Link TL-WR941N v6