New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
udev: net_id: Use devicetree aliases when available #24265
Conversation
BTW, is this for RFE #17625? If so, please add |
What is enb2d3?? |
Thank you for the quick review.
I did not write this specifically for that issue, but it looks like this might close that (depending on whether there is an appropriate alias). I will add that tag.
OK (as it happened I quickly went through the history of this file and saw it used in d6eda67).
According to the sysfs ABI documentation, there can be multiple devicetrees, but it does not document the naming scheme used. The actual attachment is done by |
a34339e
to
57f39cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better now. One more round please.
57f39cf
to
5188095
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM. Only several coding style comments.
5188095
to
65b4f41
Compare
Devicetree firmware contains an "aliases" node, containing various aliases for devices described by the firmware. For ethernet devices, these are named "ethernet0", "ethernet1", etc. They provide a convenient means of numbering ethernet devices, especially on systems with no other stable number other than the address. In particular, U-Boot already uses these aliases to name its ethernet devices. Previously, there have been attempts (such as [1]) to add support for these aliases to Linux. However, these patches have been rejected because it is the maintainers' view that naming policy be left to userspace. Well, systemd is userspace, so here we are. In terms of implementation, apparently there can be multiple device trees at once. I have decided to dodge this problem for now, and just use /proc/device-tree. If it is desired to support multiple device trees later, then the scheme can be modified to include the device tree's index. For example, /sys/firmware/devicetree/base2/aliases/ethernet3 might be named enb2d3. For the moment we only support "ethernetX" aliases. Future patches might want to also handle "canX" and "wifiX". It is common on boards with only one ethernet device to use an alias of just "ethernet". In this case, the index is an implicit 0. In case the author of the firmware made a mistake, we check to ensure that aliases of "ethernet" and "ethernet0" do not both exist. [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/1399390594-1409-1-git-send-email-boris.brezillon@free-electrons.com/ Closes: systemd#17625
65b4f41
to
b99a1ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you.
Devicetree firmware contains an "aliases" node, containing various
aliases for devices described by the firmware. For ethernet devices,
these are named "ethernet0", "ethernet1", etc. They provide a convenient
means of numbering ethernet devices, especially on systems with no other
stable number other than the address. In particular, U-Boot already uses
these aliases to name its ethernet devices.
Previously, there have been attempts (such as [1]) to add support for
these aliases to Linux. However, these patches have been rejected
because it is the maintainers' view that naming policy be left to
userspace. Well, systemd is userspace, so here we are.
In terms of implementation, apparently there can be multiple device
trees at once. I have decided to dodge this problem for now, and just
use /proc/device-tree. If it is desired to support multiple device trees
later, then the scheme can be modified to something like enb2d3.
For the moment we only support "ethernetX" aliases. Future patches might
want to also handle "canX" and "wifiX".
It is common on boards with only one ethernet device to use an alias of
just "ethernet". In this case, the index is an implicit 0. In case the
author of the firmware made a mistake, we check to ensure that aliases
of "ethernet" and "ethernet0" do not both exist.
[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/1399390594-1409-1-git-send-email-boris.brezillon@free-electrons.com/
Signed-off-by: Sean Anderson sean.anderson@seco.com
Closes #17625.