From: Stephen Hemminger <stephen@networkplumber.org>
To: Harini Katakam <harinik@xilinx.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicolas Ferre <nicolas.ferre@atmel.com>,
David Miller <davem@davemloft.net>,
Michal Simek <michal.simek@xilinx.com>,
Harini Katakam <harini.katakam@xilinx.com>,
Harini Katakam <harinikatakamlinux@gmail.com>
Subject: Re: Request for suggestion on net device re-naming/re-ordering based on DT alias
Date: Wed, 27 Feb 2019 10:40:28 -0800 [thread overview]
Message-ID: <20190227104028.707a75e2@shemminger-XPS-13-9360> (raw)
In-Reply-To: <CAFcVEC+8P25MKWhizUUEuamikaZYUOjpppV=59=W3POTEfQqXw@mail.gmail.com>
On Wed, 27 Feb 2019 17:24:03 +0530
Harini Katakam <harinik@xilinx.com> wrote:
> Hi,
>
> We've had some users requesting control over net device name order
> when multiple ethernet devices are present on a system. I've tried a
> few solutions to this and looked it up on forums. But I apologize if
> I have missed something.
>
> I know that the current system allocates eth<n> as per probe order
> but that is obviously not stably controlled by user (tried DT
> re-ordering and defer probe). One solution is to use DT alias names
> to write to (net_device)->name as follows:
> Devicetree:
> aliases {
> ethernet0 = &mac1;
> ethernet1 = &mac0;
> };
> Driver probe:
> + /* Read ethernet DT alias id and assign to right device name*/
> + id = of_alias_get_id(np, "ethernet");
> + if (id < 0) {
> + dev_warn(&pdev->dev, "failed to get alias id (%u)\n", id);
> + return id;
> + }
> + snprintf(dev->name, sizeof(dev->name), "eth%d", id);
> +
>
> These three drivers seem to have something similar for mdio/phy bus IDs:
> drivers/net/ethernet/broadcom/genet/bcmmii.c:409: id =
> of_alias_get_id(dn, "eth");
> drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c:43: plat->bus_id =
> of_alias_get_id(np, "ethernet");
> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:404:
> plat->bus_id = of_alias_get_id(np, "ethernet");
>
> Drawback: This approach will break if alias is not provided for one
> of the interfaces on board. Not to mention, there could be systems
> with multiple ethernet makes (for ex. Cadence macb and Xilinx axienet)
> If one of the drivers does not have an alias read mechanism, it is
> possible to have clashing ID assignments. Is there any way this
> solution can be changed to be stable/acceptable?
>
> One other alternative I've tried is netdev kernel bootargs but this
> device name was not being picked by the kernel:
> https://www.kernel.org/doc/html/v4.19/admin-guide/kernel-parameters.html
> netdev= <mac1’s interrupt id>, <mac1’s base address>, eth0
> netdev=<mac0’s interrupt id>, <mac0’s base address>, eth1
>
> Could you please suggest any alternatives?
> Thanks!
>
> Regards,
> Harini
Device naming is a hard problem, and there is no perfect solution.
Device tree should be providing hints to userspace policy for naming, not
trying to do it in the kernel.
See: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
next prev parent reply other threads:[~2019-02-27 18:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 11:54 Request for suggestion on net device re-naming/re-ordering based on DT alias Harini Katakam
2019-02-27 18:40 ` Stephen Hemminger [this message]
2019-02-27 18:45 ` Florian Fainelli
2019-02-27 21:42 ` Stephen Hemminger
2019-02-28 5:43 ` Harini Katakam
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=20190227104028.707a75e2@shemminger-XPS-13-9360 \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=harini.katakam@xilinx.com \
--cc=harinik@xilinx.com \
--cc=harinikatakamlinux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
/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