* [PATCH net-next] net: enetc: Support ethernet aliases in dts.
@ 2025-02-25 21:44 Shenwei Wang
2025-02-26 14:57 ` Andrew Lunn
2025-02-26 15:47 ` Vladimir Oltean
0 siblings, 2 replies; 9+ messages in thread
From: Shenwei Wang @ 2025-02-25 21:44 UTC (permalink / raw)
To: Claudiu Manoil, Vladimir Oltean, Wei Fang, Clark Wang,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: imx, netdev, linux-imx, Shenwei Wang
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@nxp.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;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-25 21:44 [PATCH net-next] net: enetc: Support ethernet aliases in dts Shenwei Wang
@ 2025-02-26 14:57 ` Andrew Lunn
2025-02-26 15:07 ` Shenwei Wang
2025-02-26 15:47 ` Vladimir Oltean
1 sibling, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2025-02-26 14:57 UTC (permalink / raw)
To: Shenwei Wang
Cc: Claudiu Manoil, Vladimir Oltean, Wei Fang, Clark Wang,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, imx, netdev, linux-imx
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.
GregKH and others will tell you this is a user space problem. Ethernet
names have never been stable, user space has always had to deal with
this problem. Please use a udev rule, systemd naming, etc.
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 14:57 ` Andrew Lunn
@ 2025-02-26 15:07 ` Shenwei Wang
2025-02-26 15:10 ` Vladimir Oltean
0 siblings, 1 reply; 9+ messages in thread
From: Shenwei Wang @ 2025-02-26 15:07 UTC (permalink / raw)
To: Andrew Lunn
Cc: Claudiu Manoil, Vladimir Oltean, Wei Fang, Clark Wang,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, imx@lists.linux.dev, netdev@vger.kernel.org,
dl-linux-imx
> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Wednesday, February 26, 2025 8:58 AM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: Claudiu Manoil <claudiu.manoil@nxp.com>; Vladimir Oltean
> <vladimir.oltean@nxp.com>; Wei Fang <wei.fang@nxp.com>; Clark Wang
> <xiaoning.wang@nxp.com>; Andrew Lunn <andrew+netdev@lunn.ch>; David S.
> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>;
> imx@lists.linux.dev; netdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: [EXT] 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.
>
> GregKH and others will tell you this is a user space problem. Ethernet names have
> never been stable, user space has always had to deal with this problem. Please
> use a udev rule, systemd naming, etc.
Thanks Andrew.
Does it mean the ethernet aliases defined in the dts are no longer recommended or supported?
Thanks,
Shenwei
>
> Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 15:07 ` Shenwei Wang
@ 2025-02-26 15:10 ` Vladimir Oltean
0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2025-02-26 15:10 UTC (permalink / raw)
To: Shenwei Wang
Cc: Andrew Lunn, Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
imx@lists.linux.dev, netdev@vger.kernel.org, dl-linux-imx
On Wed, Feb 26, 2025 at 05:07:15PM +0200, Shenwei Wang wrote:
> > -----Original Message-----
> > From: Andrew Lunn <andrew@lunn.ch>
> > Sent: Wednesday, February 26, 2025 8:58 AM
> > To: Shenwei Wang <shenwei.wang@nxp.com>
> > Cc: Claudiu Manoil <claudiu.manoil@nxp.com>; Vladimir Oltean
> > <vladimir.oltean@nxp.com>; Wei Fang <wei.fang@nxp.com>; Clark Wang
> > <xiaoning.wang@nxp.com>; Andrew Lunn <andrew+netdev@lunn.ch>; David S.
> > Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> > Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>;
> > imx@lists.linux.dev; netdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> > Subject: [EXT] 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.
> >
> > GregKH and others will tell you this is a user space problem. Ethernet names have
> > never been stable, user space has always had to deal with this problem. Please
> > use a udev rule, systemd naming, etc.
>
> Thanks Andrew.
> Does it mean the ethernet aliases defined in the dts are no longer recommended or supported?
>
> Thanks,
> Shenwei
Aliases are recommended at least for U-Boot fixups of any kind (MAC
addresses, but not necessarily). You never want to perform a fixup based
on a hardcoded node path.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-25 21:44 [PATCH net-next] net: enetc: Support ethernet aliases in dts Shenwei Wang
2025-02-26 14:57 ` Andrew Lunn
@ 2025-02-26 15:47 ` Vladimir Oltean
2025-02-26 16:46 ` Shenwei Wang
1 sibling, 1 reply; 9+ messages in thread
From: Vladimir Oltean @ 2025-02-26 15:47 UTC (permalink / raw)
To: Shenwei Wang
Cc: Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, imx,
netdev, linux-imx
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@nxp.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 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 included -
the "label" device tree property is considered legacy.
Nacked-by: Vladimir Oltean <vladimir.oltean@nxp.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 15:47 ` Vladimir Oltean
@ 2025-02-26 16:46 ` Shenwei Wang
2025-02-26 17:10 ` Vladimir Oltean
0 siblings, 1 reply; 9+ messages in thread
From: Shenwei Wang @ 2025-02-26 16:46 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
imx@lists.linux.dev, netdev@vger.kernel.org, dl-linux-imx
> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Sent: Wednesday, February 26, 2025 9:48 AM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: Claudiu Manoil <claudiu.manoil@nxp.com>; Wei Fang <wei.fang@nxp.com>;
> Clark Wang <xiaoning.wang@nxp.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; imx@lists.linux.dev; netdev@vger.kernel.org; dl-
> linux-imx <linux-imx@nxp.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@nxp.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@nxp.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 16:46 ` Shenwei Wang
@ 2025-02-26 17:10 ` Vladimir Oltean
2025-02-26 17:43 ` Shenwei Wang
0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Oltean @ 2025-02-26 17:10 UTC (permalink / raw)
To: Shenwei Wang
Cc: Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
imx@lists.linux.dev, netdev@vger.kernel.org, dl-linux-imx
On Wed, Feb 26, 2025 at 06:46:54PM +0200, Shenwei Wang wrote:
> > 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.
Good luck adding of_alias_get_id() patches to (and others) PCIe NIC
drivers (with a real PCIe link layer, not Enhanced Allocation).
> > 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.
Yet, the rootfs seems to be the only place to keep net device names that
is sufficiently flexible to cover the variability in use cases. Maybe
you're used to your developer position where you can immediately modify
the device tree for a board, but one is supposed to be able to configure
U-Boot to provide a fixed device tree (its own) to Linux. This is for
example used for Arm SystemReady IR compliance with distributions, to my
knowledge.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 17:10 ` Vladimir Oltean
@ 2025-02-26 17:43 ` Shenwei Wang
2025-02-26 20:02 ` Vladimir Oltean
0 siblings, 1 reply; 9+ messages in thread
From: Shenwei Wang @ 2025-02-26 17:43 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
imx@lists.linux.dev, netdev@vger.kernel.org, dl-linux-imx
> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Sent: Wednesday, February 26, 2025 11:11 AM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: Claudiu Manoil <claudiu.manoil@nxp.com>; Wei Fang <wei.fang@nxp.com>;
> Clark Wang <xiaoning.wang@nxp.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; imx@lists.linux.dev; netdev@vger.kernel.org; dl-
> linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
>
> On Wed, Feb 26, 2025 at 06:46:54PM +0200, Shenwei Wang wrote:
> > > 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.
>
> Good luck adding of_alias_get_id() patches to (and others) PCIe NIC drivers (with
> a real PCIe link layer, not Enhanced Allocation).
>
> > > 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.
>
> Yet, the rootfs seems to be the only place to keep net device names that is
> sufficiently flexible to cover the variability in use cases. Maybe you're used to
> your developer position where you can immediately modify the device tree for a
> board, but one is supposed to be able to configure U-Boot to provide a fixed
> device tree (its own) to Linux. This is for example used for Arm SystemReady IR
> compliance with distributions, to my knowledge.
So my understanding here is that the primary purpose of Ethernet aliases in the
kernel DTS is simply to provide U-Boot with easier access to specific Ethernet nodes?
Thanks,
Shenwei
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next] net: enetc: Support ethernet aliases in dts.
2025-02-26 17:43 ` Shenwei Wang
@ 2025-02-26 20:02 ` Vladimir Oltean
0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2025-02-26 20:02 UTC (permalink / raw)
To: Shenwei Wang
Cc: Claudiu Manoil, Wei Fang, Clark Wang, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
imx@lists.linux.dev, netdev@vger.kernel.org, dl-linux-imx
On Wed, Feb 26, 2025 at 07:43:34PM +0200, Shenwei Wang wrote:
> So my understanding here is that the primary purpose of Ethernet aliases in the
> kernel DTS is simply to provide U-Boot with easier access to specific Ethernet nodes?
This is what my limited experience is telling me, yes.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-02-26 20:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 21:44 [PATCH net-next] net: enetc: Support ethernet aliases in dts Shenwei Wang
2025-02-26 14:57 ` Andrew Lunn
2025-02-26 15:07 ` Shenwei Wang
2025-02-26 15:10 ` Vladimir Oltean
2025-02-26 15:47 ` Vladimir Oltean
2025-02-26 16:46 ` Shenwei Wang
2025-02-26 17:10 ` Vladimir Oltean
2025-02-26 17:43 ` Shenwei Wang
2025-02-26 20:02 ` Vladimir Oltean
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox