[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<AS8PR04MB91761FDBD0170D8773395E9289C22@AS8PR04MB9176.eurprd04.prod.outlook.com>
Date: Wed, 26 Feb 2025 16:46:54 +0000
From: Shenwei Wang <shenwei.wang@....com>
To: Vladimir Oltean <vladimir.oltean@....com>
CC: Claudiu Manoil <claudiu.manoil@....com>, Wei Fang <wei.fang@....com>,
Clark Wang <xiaoning.wang@....com>, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>, dl-linux-imx <linux-imx@....com>
Subject: RE: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@....com>
> Sent: Wednesday, February 26, 2025 9:48 AM
> To: Shenwei Wang <shenwei.wang@....com>
> Cc: Claudiu Manoil <claudiu.manoil@....com>; Wei Fang <wei.fang@....com>;
> Clark Wang <xiaoning.wang@....com>; Andrew Lunn
> <andrew+netdev@...n.ch>; David S. Miller <davem@...emloft.net>; Eric
> Dumazet <edumazet@...gle.com>; Jakub Kicinski <kuba@...nel.org>; Paolo
> Abeni <pabeni@...hat.com>; imx@...ts.linux.dev; netdev@...r.kernel.org; dl-
> linux-imx <linux-imx@....com>
> Subject: Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
>
> On Tue, Feb 25, 2025 at 03:44:58PM -0600, Shenwei Wang wrote:
> > Retrieve the "ethernet" alias ID from the DTS and assign it as the
> > interface name (e.g., "eth0", "eth1"). This ensures predictable naming
> > aligned with the DTS's configuration.
> >
> > If no alias is defined, fall back to the kernel's default enumeration
> > to maintain backward compatibility.
> >
> > Signed-off-by: Shenwei Wang <shenwei.wang@....com>
> > ---
> > drivers/net/ethernet/freescale/enetc/enetc4_pf.c | 14 ++++++++++++--
> > 1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > index fc41078c4f5d..5ec8dc59e809 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > @@ -622,10 +622,20 @@ static int enetc4_pf_netdev_create(struct enetc_si
> *si)
> > struct device *dev = &si->pdev->dev;
> > struct enetc_ndev_priv *priv;
> > struct net_device *ndev;
> > + char ifname[IFNAMSIZ];
> > int err;
> >
> > - ndev = alloc_etherdev_mqs(sizeof(struct enetc_ndev_priv),
> > - si->num_tx_rings, si->num_rx_rings);
> > + err = of_alias_get_id(dev->of_node, "ethernet");
> > + if (err >= 0) {
> > + snprintf(ifname, IFNAMSIZ, "eth%d", err);
> > + ndev = alloc_netdev_mqs(sizeof(struct enetc_ndev_priv),
> > + ifname, NET_NAME_PREDICTABLE,
> ether_setup,
> > + si->num_tx_rings, si->num_rx_rings);
> > + } else {
> > + ndev = alloc_etherdev_mqs(sizeof(struct enetc_ndev_priv),
> > + si->num_tx_rings, si->num_rx_rings);
> > + }
> > +
> > if (!ndev)
> > return -ENOMEM;
> >
>
> Shenwei, you don't want the kernel to attempt to be very smart about the initial
> netdev naming. You will inevitably run into the situation where "eth%d" is already
> the name chosen for the kernel for a different net_device without a predictable
> name (e.g. e1000e PCIe card) which has been allocated already. Then you'll want
The driver just provides an option to configure predictable interface naming. IMO, all
those kind of naming conflicts should be managed by the DTS itself.
> to fix that somehow, and the stream of patches will never stop, because the
> kernel will never be able to fulfill all requirements. Look at the udev naming rules
> for dpaa2 and enetc on Layerscape and build something like that. DSA switch
Even with the udev/systemd solution, you may still need to resolve the naming
conflict sometimes among multiple cards.
Thanks,
Shenwei
> included - the "label" device tree property is considered legacy.
>
> Nacked-by: Vladimir Oltean <vladimir.oltean@....com>
Powered by blists - more mailing lists