devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Tim Harvey <tharvey@gateworks.com>
Cc: "Pali Rohár" <pali@kernel.org>,
	"Sean Anderson" <sean.anderson@seco.com>,
	"Michal Suchánek" <msuchanek@suse.de>,
	"Stephen Hemminger" <stephen@networkplumber.org>,
	netdev <netdev@vger.kernel.org>, u-boot <u-boot@lists.denx.de>,
	"Device Tree Mailing List" <devicetree@vger.kernel.org>
Subject: Re: ethernet<n> dt aliases implications in U-Boot and Linux
Date: Tue, 23 Aug 2022 14:21:33 -0500	[thread overview]
Message-ID: <CAL_JsqJMKTHHTh2LTbkycmm5SpORGNOibScE_attkOHU_sB3sw@mail.gmail.com> (raw)
In-Reply-To: <CAJ+vNU3bFNRiyhV_w_YWP+sjMTpU28PsX=BTkT7_Q=79=yR1gg@mail.gmail.com>

On Tue, Aug 9, 2022 at 4:39 PM Tim Harvey <tharvey@gateworks.com> wrote:
>
> On Tue, Aug 9, 2022 at 2:31 PM Pali Rohár <pali@kernel.org> wrote:
> >
> > On Tuesday 09 August 2022 16:48:23 Sean Anderson wrote:
> > > On 8/8/22 5:45 PM, Michal Suchánek wrote:
> > > > On Mon, Aug 08, 2022 at 02:38:35PM -0700, Stephen Hemminger wrote:
> > > >> On Mon, 8 Aug 2022 23:09:45 +0200
> > > >> Michal Suchánek <msuchanek@suse.de> wrote:
> > > >>
> > > >> > On Mon, Aug 08, 2022 at 03:57:55PM -0400, Sean Anderson wrote:
> > > >> > > Hi Tim,
> > > >> > >
> > > >> > > On 8/8/22 3:18 PM, Tim Harvey wrote:
> > > >> > > > Greetings,
> > > >> > > >
> > > >> > > > I'm trying to understand if there is any implication of 'ethernet<n>'
> > > >> > > > aliases in Linux such as:
> > > >> > > >         aliases {
> > > >> > > >                 ethernet0 = &eqos;
> > > >> > > >                 ethernet1 = &fec;
> > > >> > > >                 ethernet2 = &lan1;
> > > >> > > >                 ethernet3 = &lan2;
> > > >> > > >                 ethernet4 = &lan3;
> > > >> > > >                 ethernet5 = &lan4;
> > > >> > > >                 ethernet6 = &lan5;
> > > >> > > >         };
> > > >> > > >
> > > >> > > > I know U-Boot boards that use device-tree will use these aliases to
> > > >> > > > name the devices in U-Boot such that the device with alias 'ethernet0'
> > > >> > > > becomes eth0 and alias 'ethernet1' becomes eth1 but for Linux it
> > > >> > > > appears that the naming of network devices that are embedded (ie SoC)
> > > >> > > > vs enumerated (ie pci/usb) are always based on device registration
> > > >> > > > order which for static drivers depends on Makefile linking order and
> > > >> > > > has nothing to do with device-tree.
> > > >> > > >
> > > >> > > > Is there currently any way to control network device naming in Linux
> > > >> > > > other than udev?

Ah, the topic that will never die.

> > > >> > >
> > > >> > > You can also use systemd-networkd et al. (but that is the same kind of mechanism)
> > > >> > >
> > > >> > > > Does Linux use the ethernet<n> aliases for anything at all?
> > > >> > >
> > > >> > > No :l
> > > >> >
> > > >> > Maybe it's a great opportunity for porting biosdevname to DT based
> > > >> > platforms ;-)
> > > >>
> > > >> Sorry, biosdevname was wrong way to do things.
> > > >> Did you look at the internals, it was dumpster diving as root into BIOS.
> > > >
> > > > When it's BIOS what defines the names then you have to read them from
> > > > the BIOS. Recently it was updated to use some sysfs file or whatver.
> > > > It's not like you would use any of that code with DT, anyway.
> > > >
> > > >> Systemd-networkd does things in much more supportable manner using existing
> > > >> sysfs API's.
> > > >
> > > > Which is a dumpster of systemd code, no thanks.
> > > >
> > > > I want my device naming independent of the init system, especially if
> > > > it's systemd.
> > >
> > > Well, there's always nameif...
> > >
> > > That said, I have made [1] for people using systemd-networkd.
> > >
> > > --Sean
> > >
> > > [1] https://github.com/systemd/systemd/pull/24265
> >
> > Hello!
> >
> > In some cases "label" DT property can be used also as interface name.
> > For example this property is already used by DSA kernel driver.
> >
> > I created very simple script which renames all interfaces in system to
> > their "label" DT property (if there is any defined).
> >
> > #!/bin/sh
> > for iface in `ls /sys/class/net/`; do
> >         for of_node in of_node device/of_node; do
> >                 if test -e /sys/class/net/$iface/$of_node/; then
> >                         label=`cat /sys/class/net/$iface/$of_node/label 2>/dev/null`
> >                         if test -n "$label" && test "$label" != "$iface"; then
> >                                 echo "Renaming net interface $iface to $label..."
> >                                 up=$((`cat /sys/class/net/$iface/flags 2>/dev/null || echo 1` & 0x1))
> >                                 if test "$up" != "0"; then
> >                                         ip link set dev $iface down
> >                                 fi
> >                                 ip link set dev $iface name "$label" && iface=$label
> >                                 if test "$up" != "0"; then
> >                                         ip link set dev $iface up
> >                                 fi
> >                         fi
> >                         break
> >                 fi
> >         done
> > done
> >
> > Maybe it would be better first to use "label" and then use ethernet alias?
>
> I've been wondering the same as well which made me wonder what the
> history of the 'aliases' node is and why its not used in most cases in
> Linux. I know for the SOC's I work with we've always defined aliases
> for ethernet<n>, gpio<n>, serial<n>, spi<n>, i2c<n>, mmc<n> etc. Where
> did this practice come from and why are we putting that in Linux dts
> files it if it's not used by Linux?

It's not 'Linux dts files', but dts files that happen to be hosted in
the Linux kernel. Many are sync'd to u-boot and other places.

While ethernetN is not used by the kernel, the rest are I think.
Personally, I'd do away with gpio, i2c and spi at least, but that ship
has sailed. Then we have some non-standard ones that crept in from
downstream I think (i.MX is the worst).

'label' is supposed to reflect the sticker on a user accessible
port/connector on device. As long as nothing is looking for particular
values of label, it's okay by me to use.

Rob

  parent reply	other threads:[~2022-08-23 20:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 19:18 ethernet<n> dt aliases implications in U-Boot and Linux Tim Harvey
2022-08-08 19:57 ` Sean Anderson
2022-08-08 21:09   ` Michal Suchánek
2022-08-08 21:38     ` Stephen Hemminger
2022-08-08 21:45       ` Michal Suchánek
2022-08-09 20:48         ` Sean Anderson
2022-08-09 21:31           ` Pali Rohár
2022-08-09 21:36             ` Sean Anderson
2022-08-09 21:42               ` Pali Rohár
2022-08-09 22:41                 ` Sean Anderson
2022-08-09 22:42                   ` Tim Harvey
2022-08-09 22:45                   ` Pali Rohár
2022-08-09 23:17                     ` Tim Harvey
2022-08-10  1:11                       ` Andrew Lunn
2022-08-10  7:16                         ` Michal Suchánek
2022-08-10 15:17                           ` Andrew Lunn
2022-08-10 15:35                             ` Michal Suchánek
2022-08-11 19:43                               ` Sean Anderson
2022-08-20  9:16                     ` Pali Rohár
2022-08-20 13:02                       ` Sean Anderson
2022-08-09 21:39             ` Tim Harvey
2022-08-09 21:45               ` Pali Rohár
2022-08-09 21:58               ` Stephen Hemminger
2022-08-10  9:56               ` Francesco Dolcini
2022-08-23 19:21               ` Rob Herring [this message]
2022-08-09 21:35           ` Tim Harvey
2022-08-09 21:41             ` Sean Anderson
2022-08-08 21:18   ` Tim Harvey
2022-08-08 21:18   ` Florian Fainelli
2022-08-08 21:28     ` Tim Harvey
2022-08-08 21:34       ` Florian Fainelli
2022-08-08 21:40         ` Tim Harvey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL_JsqJMKTHHTh2LTbkycmm5SpORGNOibScE_attkOHU_sB3sw@mail.gmail.com \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=msuchanek@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=sean.anderson@seco.com \
    --cc=stephen@networkplumber.org \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).