Adds a new helper function of_get_ethdev_label() which sets initial name of
specified netdev interface based on DT "label" property. It is same what is
doing DSA function dsa_port_parse_of() for DSA ports.
This helper function can be useful for drivers to make consistency between
DSA and netdev interface names.
Signed-off-by: Pali Rohár <[email protected]>
---
include/linux/of_net.h | 6 ++++++
net/core/of_net.c | 15 +++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 0484b613ca64..532d88127b42 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -15,6 +15,7 @@ struct net_device;
extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
extern int of_get_mac_address(struct device_node *np, u8 *mac);
int of_get_ethdev_address(struct device_node *np, struct net_device *dev);
+int of_get_ethdev_label(struct device_node *np, struct net_device *dev);
extern struct net_device *of_find_net_device_by_node(struct device_node *np);
#else
static inline int of_get_phy_mode(struct device_node *np,
@@ -33,6 +34,11 @@ static inline int of_get_ethdev_address(struct device_node *np, struct net_devic
return -ENODEV;
}
+static inline int of_get_ethdev_label(struct device_node *np, struct net_device *dev)
+{
+ return -ENODEV;
+}
+
static inline struct net_device *of_find_net_device_by_node(struct device_node *np)
{
return NULL;
diff --git a/net/core/of_net.c b/net/core/of_net.c
index f1a9bf7578e7..18fc99c42461 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
@@ -168,3 +168,18 @@ int of_get_ethdev_address(struct device_node *np, struct net_device *dev)
return ret;
}
EXPORT_SYMBOL(of_get_ethdev_address);
+
+int of_get_ethdev_label(struct device_node *np, struct net_device *dev)
+{
+ const char *name = of_get_property(np, "label", NULL);
+
+ if (!name)
+ return -ENOENT;
+
+ if (strlen(name) >= sizeof(dev->name))
+ return -ENAMETOOLONG;
+
+ strcpy(dev->name, name);
+ return 0;
+}
+EXPORT_SYMBOL(of_get_ethdev_label);
--
2.20.1
Make consistency between DT based netdev and DSA interfaces in eth net
drivers by setting initial netdev name based on DT label. Exactly same
behavior is already implemented and used in DSA drivers.
This change just makes initial consistency between netdev eth devices and
DSA devices.
Signed-off-by: Pali Rohár <[email protected]>
---
drivers/net/ethernet/allwinner/sun4i-emac.c | 2 ++
drivers/net/ethernet/altera/altera_tse_main.c | 2 ++
drivers/net/ethernet/arc/emac_main.c | 2 ++
drivers/net/ethernet/atheros/ag71xx.c | 2 ++
drivers/net/ethernet/broadcom/bcm4908_enet.c | 1 +
drivers/net/ethernet/broadcom/bcmsysport.c | 3 +++
drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 ++
drivers/net/ethernet/broadcom/bgmac-platform.c | 2 ++
drivers/net/ethernet/cadence/macb_main.c | 2 ++
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 2 ++
drivers/net/ethernet/ethoc.c | 1 +
drivers/net/ethernet/ezchip/nps_enet.c | 2 ++
drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 ++
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 2 ++
drivers/net/ethernet/freescale/gianfar.c | 2 ++
drivers/net/ethernet/freescale/ucc_geth.c | 1 +
drivers/net/ethernet/hisilicon/hisi_femac.c | 2 ++
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 ++
drivers/net/ethernet/ibm/emac/core.c | 2 ++
drivers/net/ethernet/korina.c | 2 ++
drivers/net/ethernet/lantiq_xrx200.c | 2 ++
drivers/net/ethernet/litex/litex_liteeth.c | 2 ++
drivers/net/ethernet/marvell/mvneta.c | 2 ++
drivers/net/ethernet/marvell/pxa168_eth.c | 2 ++
drivers/net/ethernet/marvell/sky2.c | 2 ++
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++
drivers/net/ethernet/micrel/ks8851_common.c | 2 ++
drivers/net/ethernet/nxp/lpc_eth.c | 2 ++
drivers/net/ethernet/qualcomm/qca_spi.c | 2 ++
drivers/net/ethernet/qualcomm/qca_uart.c | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 2 ++
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c | 2 ++
drivers/net/ethernet/socionext/sni_ave.c | 2 ++
drivers/net/ethernet/ti/netcp_core.c | 2 ++
drivers/net/ethernet/xilinx/xilinx_emaclite.c | 2 ++
drivers/staging/octeon/ethernet.c | 2 ++
36 files changed, 69 insertions(+)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 800ee022388f..38f292f27512 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -851,6 +851,8 @@ static int emac_probe(struct platform_device *pdev)
goto out_release_sram;
}
+ of_get_ethdev_label(np, ndev);
+
/* Read MAC-address from DT */
ret = of_get_ethdev_address(np, ndev);
if (ret) {
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index d75d95a97dd9..d322918daaab 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -1523,6 +1523,8 @@ static int altera_tse_probe(struct platform_device *pdev)
*/
priv->rx_dma_buf_sz = ALTERA_RXDMABUFFER_SIZE;
+ of_get_ethdev_label(pdev->dev.of_node, ndev);
+
/* get default MAC address from device tree */
ret = of_get_ethdev_address(pdev->dev.of_node, ndev);
if (ret)
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index c642c3d3e600..554f6837382d 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -940,6 +940,8 @@ int arc_emac_probe(struct net_device *ndev, int interface)
goto out_clken;
}
+ of_get_ethdev_label(dev->of_node, ndev);
+
/* Get MAC address from device tree */
err = of_get_ethdev_address(dev->of_node, ndev);
if (err)
diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 88d2ab748399..94d9617a9ed1 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1966,6 +1966,8 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->ctrl = 0;
ag->stop_desc->next = (u32)ag->stop_desc_dma;
+ of_get_ethdev_label(np, ndev);
+
err = of_get_ethdev_address(np, ndev);
if (err) {
netif_err(ag, probe, ndev, "invalid MAC address, using random address\n");
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 7cc5213c575a..987298caa312 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -715,6 +715,7 @@ static int bcm4908_enet_probe(struct platform_device *pdev)
return err;
SET_NETDEV_DEV(netdev, &pdev->dev);
+ of_get_ethdev_label(dev->of_node, netdev);
err = of_get_ethdev_address(dev->of_node, netdev);
if (err)
eth_hw_addr_random(netdev);
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 40933bf5a710..45ad21fc8711 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2555,6 +2555,9 @@ static int bcm_sysport_probe(struct platform_device *pdev)
}
/* Initialize netdevice members */
+
+ of_get_ethdev_label(dn, dev);
+
ret = of_get_ethdev_address(dn, dev);
if (ret) {
dev_warn(&pdev->dev, "using random Ethernet MAC\n");
diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index e6f48786949c..d657e0fdd0aa 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -140,6 +140,8 @@ static int bgmac_probe(struct bcma_device *core)
bcma_set_drvdata(core, bgmac);
+ of_get_ethdev_label(bgmac->dev->of_node, bgmac->net_dev);
+
err = of_get_ethdev_address(bgmac->dev->of_node, bgmac->net_dev);
if (err == -EPROBE_DEFER)
return err;
diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c b/drivers/net/ethernet/broadcom/bgmac-platform.c
index c6412c523637..73fcb8bbbb3a 100644
--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
@@ -191,6 +191,8 @@ static int bgmac_probe(struct platform_device *pdev)
bgmac->dev = &pdev->dev;
bgmac->dma_dev = &pdev->dev;
+ of_get_ethdev_label(np, bgmac->net_dev);
+
ret = of_get_ethdev_address(np, bgmac->net_dev);
if (ret == -EPROBE_DEFER)
return ret;
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index ffce528aa00e..ac751a08c2d8 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4784,6 +4784,8 @@ static int macb_probe(struct platform_device *pdev)
if (bp->caps & MACB_CAPS_NEEDS_RSTONUBR)
bp->rx_intr_mask |= MACB_BIT(RXUBR);
+ of_get_ethdev_label(np, bp->dev);
+
err = of_get_ethdev_address(np, bp->dev);
if (err == -EPROBE_DEFER)
goto err_out_free_netdev;
diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index 4e39d712e121..0f0e45f27e8e 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -1501,6 +1501,8 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
netdev->min_mtu = 64 - OCTEON_MGMT_RX_HEADROOM;
netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM - VLAN_HLEN;
+ of_get_ethdev_label(pdev->dev.of_node, netdev);
+
result = of_get_ethdev_address(pdev->dev.of_node, netdev);
if (result)
eth_hw_addr_random(netdev);
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index b1c8ffea6ad2..46613aefb50c 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1147,6 +1147,7 @@ static int ethoc_probe(struct platform_device *pdev)
eth_hw_addr_set(netdev, pdata->hwaddr);
priv->phy_id = pdata->phy_id;
} else {
+ of_get_ethdev_label(pdev->dev.of_node, netdev);
of_get_ethdev_address(pdev->dev.of_node, netdev);
priv->phy_id = -1;
}
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index 323340826dab..310997c83bd3 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -600,6 +600,8 @@ static s32 nps_enet_probe(struct platform_device *pdev)
}
dev_dbg(dev, "Registers base address is 0x%p\n", priv->regs_base);
+ of_get_ethdev_label(dev->of_node, ndev);
+
/* set kernel MAC address to dev */
err = of_get_ethdev_address(dev->of_node, ndev);
if (err)
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index bbbde9f701c2..bf691a305806 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -885,6 +885,8 @@ static int mpc52xx_fec_probe(struct platform_device *op)
/* TX */
priv->t_irq = bcom_get_task_irq(priv->tx_dmatsk);
+ of_get_ethdev_label(np, ndev);
+
/*
* MAC address init:
*
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index bacf25318f87..aeb9f3fa1894 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -1005,6 +1005,8 @@ static int fs_enet_probe(struct platform_device *ofdev)
spin_lock_init(&fep->lock);
spin_lock_init(&fep->tx_lock);
+ of_get_ethdev_label(ofdev->dev.of_node, ndev);
+
of_get_ethdev_address(ofdev->dev.of_node, ndev);
ret = fep->ops->allocate_bd(ndev);
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index acab58fd3db3..fdb794355e9e 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -753,6 +753,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
if (stash_len || stash_idx)
priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
+ of_get_ethdev_label(np, dev);
+
err = of_get_ethdev_address(np, dev);
if (err) {
eth_hw_addr_random(dev);
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 823221c912ab..7496d6b4552d 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3731,6 +3731,7 @@ static int ucc_geth_probe(struct platform_device* ofdev)
goto err_free_netdev;
}
+ of_get_ethdev_label(np, dev);
of_get_ethdev_address(np, dev);
ugeth->ug_info = ug_info;
diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c
index a6c18b6527f9..060da9a0bbea 100644
--- a/drivers/net/ethernet/hisilicon/hisi_femac.c
+++ b/drivers/net/ethernet/hisilicon/hisi_femac.c
@@ -841,6 +841,8 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
(unsigned long)phy->phy_id,
phy_modes(phy->interface));
+ of_get_ethdev_label(node, ndev);
+
ret = of_get_ethdev_address(node, ndev);
if (ret) {
eth_hw_addr_random(ndev);
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index d7e62eca050f..27ecfbe7993f 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1219,6 +1219,8 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
goto out_phy_node;
}
+ of_get_ethdev_label(node, ndev);
+
ret = of_get_ethdev_address(node, ndev);
if (ret) {
eth_hw_addr_random(ndev);
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 6b3fc8823c54..bbeb8867aa4a 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2974,6 +2974,8 @@ static int emac_init_config(struct emac_instance *dev)
#endif
}
+ of_get_ethdev_label(np, dev->ndev);
+
/* Read MAC-address */
err = of_get_ethdev_address(np, dev->ndev);
if (err) {
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index df9a8eefa007..f06eb06489b4 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1296,6 +1296,8 @@ static int korina_probe(struct platform_device *pdev)
SET_NETDEV_DEV(dev, &pdev->dev);
lp = netdev_priv(dev);
+ of_get_ethdev_label(pdev->dev.of_node, dev);
+
if (mac_addr)
eth_hw_addr_set(dev, mac_addr);
else if (of_get_ethdev_address(pdev->dev.of_node, dev) < 0)
diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
index 0da09ea81980..ace9da9674d3 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -526,6 +526,8 @@ static int xrx200_probe(struct platform_device *pdev)
return PTR_ERR(priv->clk);
}
+ of_get_ethdev_label(np, net_dev);
+
err = of_get_ethdev_address(np, net_dev);
if (err)
eth_hw_addr_random(net_dev);
diff --git a/drivers/net/ethernet/litex/litex_liteeth.c b/drivers/net/ethernet/litex/litex_liteeth.c
index fdd99f0de424..5f3420564f6e 100644
--- a/drivers/net/ethernet/litex/litex_liteeth.c
+++ b/drivers/net/ethernet/litex/litex_liteeth.c
@@ -264,6 +264,8 @@ static int liteeth_probe(struct platform_device *pdev)
priv->tx_base = buf_base + priv->num_rx_slots * priv->slot_size;
priv->tx_slot = 0;
+ of_get_ethdev_label(pdev->dev.of_node, netdev);
+
err = of_get_ethdev_address(pdev->dev.of_node, netdev);
if (err)
eth_hw_addr_random(netdev);
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 5a7bdca22a63..383bbacc59f4 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5251,6 +5251,8 @@ static int mvneta_probe(struct platform_device *pdev)
goto err_free_ports;
}
+ of_get_ethdev_label(dn, dev);
+
err = of_get_ethdev_address(dn, dev);
if (!err) {
mac_from = "device tree";
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 1d607bc6b59e..fbd22ec463e8 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1433,6 +1433,8 @@ static int pxa168_eth_probe(struct platform_device *pdev)
INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task);
+ of_get_ethdev_label(pdev->dev.of_node, dev);
+
err = of_get_ethdev_address(pdev->dev.of_node, dev);
if (err) {
u8 addr[ETH_ALEN];
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 28b5b9341145..2f62b5b2432f 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4716,6 +4716,8 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
else
dev->max_mtu = ETH_JUMBO_MTU;
+ of_get_ethdev_label(hw->pdev->dev.of_node, dev);
+
/* try to get mac address in the following order:
* 1) from device tree data
* 2) from internal registers set by bootloader
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 75d67d1b5f6b..1cf1f41c3859 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2588,6 +2588,8 @@ static int __init mtk_init(struct net_device *dev)
struct mtk_eth *eth = mac->hw;
int ret;
+ of_get_ethdev_label(mac->of_node, dev);
+
ret = of_get_ethdev_address(mac->of_node, dev);
if (ret) {
/* If the mac address is invalid, use random mac address */
diff --git a/drivers/net/ethernet/micrel/ks8851_common.c b/drivers/net/ethernet/micrel/ks8851_common.c
index 691206f19ea7..d125cbdc473b 100644
--- a/drivers/net/ethernet/micrel/ks8851_common.c
+++ b/drivers/net/ethernet/micrel/ks8851_common.c
@@ -197,6 +197,8 @@ static void ks8851_init_mac(struct ks8851_net *ks, struct device_node *np)
struct net_device *dev = ks->netdev;
int ret;
+ of_get_ethdev_label(np, dev);
+
ret = of_get_ethdev_address(np, dev);
if (!ret) {
ks8851_write_mac_addr(dev);
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index bc39558fe82b..4b35e4540fe6 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1346,6 +1346,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
pldat->phy_node = of_parse_phandle(np, "phy-handle", 0);
+ of_get_ethdev_label(np, ndev);
+
/* Get MAC address from current HW setting (POR state is all zeros) */
__lpc_get_mac(pldat, addr);
eth_hw_addr_set(ndev, addr);
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 955cce644392..87a7f4b715c1 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -968,6 +968,8 @@ qca_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, qcaspi_devs);
+ of_get_ethdev_label(spi->dev.of_node, qca->net_dev);
+
ret = of_get_ethdev_address(spi->dev.of_node, qca->net_dev);
if (ret) {
eth_hw_addr_random(qca->net_dev);
diff --git a/drivers/net/ethernet/qualcomm/qca_uart.c b/drivers/net/ethernet/qualcomm/qca_uart.c
index 27c4f43176aa..a00d4739b28c 100644
--- a/drivers/net/ethernet/qualcomm/qca_uart.c
+++ b/drivers/net/ethernet/qualcomm/qca_uart.c
@@ -346,6 +346,7 @@ static int qca_uart_probe(struct serdev_device *serdev)
INIT_WORK(&qca->tx_work, qcauart_transmit);
of_property_read_u32(serdev->dev.of_node, "current-speed", &speed);
+ of_get_ethdev_label(serdev->dev.of_node, qca->net_dev);
ret = of_get_ethdev_address(serdev->dev.of_node, qca->net_dev);
if (ret) {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index b4c597f4040c..596a0cfcbe8a 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2741,6 +2741,8 @@ static int ravb_probe(struct platform_device *pdev)
/* Debug message level */
priv->msg_enable = RAVB_DEF_MSG_ENABLE;
+ of_get_ethdev_label(np, ndev);
+
/* Read and set MAC address */
ravb_read_mac_address(np, ndev);
if (!is_valid_ether_addr(ndev->dev_addr)) {
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
index 926532466691..cdc718c99386 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
@@ -117,6 +117,8 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
goto err_drv_remove;
}
+ of_get_ethdev_label(node, priv->dev);
+
/* Get MAC address if available (DT) */
of_get_ethdev_address(node, priv->dev);
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c
index 2c48f8b8ab71..cec095c652c7 100644
--- a/drivers/net/ethernet/socionext/sni_ave.c
+++ b/drivers/net/ethernet/socionext/sni_ave.c
@@ -1599,6 +1599,8 @@ static int ave_probe(struct platform_device *pdev)
ndev->max_mtu = AVE_MAX_ETHFRAME - (ETH_HLEN + ETH_FCS_LEN);
+ of_get_ethdev_label(np, ndev);
+
ret = of_get_ethdev_address(np, ndev);
if (ret) {
/* if the mac address is invalid, use random mac address */
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index b818e4579f6f..c274c383601c 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2002,6 +2002,8 @@ static int netcp_create_interface(struct netcp_device *netcp_device,
netcp->tx_resume_threshold = netcp->tx_pause_threshold;
netcp->node_interface = node_interface;
+ of_get_ethdev_label(node_interface, ndev);
+
ret = of_property_read_u32(node_interface, "efuse-mac", &efuse_mac);
if (efuse_mac) {
if (of_address_to_resource(node, NETCP_EFUSE_REG_INDEX, &res)) {
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 0815de581c7f..02379a5a7471 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1158,6 +1158,8 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
+ of_get_ethdev_label(ofdev->dev.of_node, ndev);
+
rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
if (rc) {
dev_warn(dev, "No MAC address found, using random\n");
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index f662739137b5..80f06fae365e 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -409,6 +409,8 @@ int cvm_oct_common_init(struct net_device *dev)
struct octeon_ethernet *priv = netdev_priv(dev);
int ret;
+ of_get_ethdev_label(priv->of_node, dev);
+
ret = of_get_ethdev_address(priv->of_node, dev);
if (ret)
eth_hw_addr_random(dev);
--
2.20.1
On Fri, Jan 07, 2022 at 05:12:21PM +0100, Pali Roh?r wrote:
> Adds a new helper function of_get_ethdev_label() which sets initial name of
> specified netdev interface based on DT "label" property. It is same what is
> doing DSA function dsa_port_parse_of() for DSA ports.
>
> This helper function can be useful for drivers to make consistency between
> DSA and netdev interface names.
>
> Signed-off-by: Pali Roh?r <[email protected]>
Doesn't this also need a patch to update the DT binding document
Documentation/devicetree/bindings/net/ethernet-controller.yaml ?
Also it needs a covering message for the series, and a well thought
out argument why this is required. Consistency with DSA probably
isn't a good enough reason.
From what I remember, there have been a number of network interface
naming proposals over the years, and as you can see, none of them have
been successful... but who knows what will happen this time.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
On Fri, Jan 07, 2022 at 04:29:31PM +0000, Russell King (Oracle) wrote:
> On Fri, Jan 07, 2022 at 05:12:21PM +0100, Pali Roh?r wrote:
> > Adds a new helper function of_get_ethdev_label() which sets initial name of
> > specified netdev interface based on DT "label" property. It is same what is
> > doing DSA function dsa_port_parse_of() for DSA ports.
> >
> > This helper function can be useful for drivers to make consistency between
> > DSA and netdev interface names.
> >
> > Signed-off-by: Pali Roh?r <[email protected]>
>
> Doesn't this also need a patch to update the DT binding document
> Documentation/devicetree/bindings/net/ethernet-controller.yaml ?
>
> Also it needs a covering message for the series, and a well thought
> out argument why this is required. Consistency with DSA probably
> isn't a good enough reason.
>
> >From what I remember, there have been a number of network interface
> naming proposals over the years, and as you can see, none of them have
> been successful... but who knows what will happen this time.
I agree with Russell here. I doubt this is going to be accepted.
DSA is special because DSA is very old, much older than DT, and maybe
older than udev. The old DSA platform drivers had a mechanism to
supply the interface name to the DSA core. When we added a DT binding
to DSA we kept that mechanism, since that mechanism had been used for
a long time.
Even if you could show there was a generic old mechanism, from before
the days of DT, that allowed interface names to be set from platform
drivers, i doubt it would be accepted because there is no continuity,
which DSA has.
Andrew
On Friday 07 January 2022 17:55:25 Andrew Lunn wrote:
> On Fri, Jan 07, 2022 at 04:29:31PM +0000, Russell King (Oracle) wrote:
> > On Fri, Jan 07, 2022 at 05:12:21PM +0100, Pali Rohár wrote:
> > > Adds a new helper function of_get_ethdev_label() which sets initial name of
> > > specified netdev interface based on DT "label" property. It is same what is
> > > doing DSA function dsa_port_parse_of() for DSA ports.
> > >
> > > This helper function can be useful for drivers to make consistency between
> > > DSA and netdev interface names.
> > >
> > > Signed-off-by: Pali Rohár <[email protected]>
> >
> > Doesn't this also need a patch to update the DT binding document
> > Documentation/devicetree/bindings/net/ethernet-controller.yaml ?
> >
> > Also it needs a covering message for the series, and a well thought
> > out argument why this is required. Consistency with DSA probably
> > isn't a good enough reason.
> >
> > >From what I remember, there have been a number of network interface
> > naming proposals over the years, and as you can see, none of them have
> > been successful... but who knows what will happen this time.
>
> I agree with Russell here. I doubt this is going to be accepted.
>
> DSA is special because DSA is very old, much older than DT, and maybe
> older than udev. The old DSA platform drivers had a mechanism to
> supply the interface name to the DSA core. When we added a DT binding
> to DSA we kept that mechanism, since that mechanism had been used for
> a long time.
>
> Even if you could show there was a generic old mechanism, from before
> the days of DT, that allowed interface names to be set from platform
> drivers, i doubt it would be accepted because there is no continuity,
> which DSA has.
Well, DT should universally describe HW board wiring. From HW point of
view, it is really does not matter if RJ45 port is connected to embedded
PHY on SoC itself or to the external PHY chip, or to the switch chip
with embedded PHY. And if board has mix of these options, also labels
(as printed on product box) should be in DTS described in the same way,
independently of which software solution / driver is used for particular
chip. It really should not matter for DTS if kernel is using for
particular HW part DSA driver or ethernet driver.
So there really should be some common way. And if the one which DSA is
using is the old mechanism, what is the new mechanism then?
On Thursday 13 January 2022 19:27:19 Pali Rohár wrote:
> On Friday 07 January 2022 17:55:25 Andrew Lunn wrote:
> > On Fri, Jan 07, 2022 at 04:29:31PM +0000, Russell King (Oracle) wrote:
> > > On Fri, Jan 07, 2022 at 05:12:21PM +0100, Pali Rohár wrote:
> > > > Adds a new helper function of_get_ethdev_label() which sets initial name of
> > > > specified netdev interface based on DT "label" property. It is same what is
> > > > doing DSA function dsa_port_parse_of() for DSA ports.
> > > >
> > > > This helper function can be useful for drivers to make consistency between
> > > > DSA and netdev interface names.
> > > >
> > > > Signed-off-by: Pali Rohár <[email protected]>
> > >
> > > Doesn't this also need a patch to update the DT binding document
> > > Documentation/devicetree/bindings/net/ethernet-controller.yaml ?
> > >
> > > Also it needs a covering message for the series, and a well thought
> > > out argument why this is required. Consistency with DSA probably
> > > isn't a good enough reason.
> > >
> > > >From what I remember, there have been a number of network interface
> > > naming proposals over the years, and as you can see, none of them have
> > > been successful... but who knows what will happen this time.
> >
> > I agree with Russell here. I doubt this is going to be accepted.
> >
> > DSA is special because DSA is very old, much older than DT, and maybe
> > older than udev. The old DSA platform drivers had a mechanism to
> > supply the interface name to the DSA core. When we added a DT binding
> > to DSA we kept that mechanism, since that mechanism had been used for
> > a long time.
> >
> > Even if you could show there was a generic old mechanism, from before
> > the days of DT, that allowed interface names to be set from platform
> > drivers, i doubt it would be accepted because there is no continuity,
> > which DSA has.
>
> Well, DT should universally describe HW board wiring. From HW point of
> view, it is really does not matter if RJ45 port is connected to embedded
> PHY on SoC itself or to the external PHY chip, or to the switch chip
> with embedded PHY. And if board has mix of these options, also labels
> (as printed on product box) should be in DTS described in the same way,
> independently of which software solution / driver is used for particular
> chip. It really should not matter for DTS if kernel is using for
> particular HW part DSA driver or ethernet driver.
>
> So there really should be some common way. And if the one which DSA is
> using is the old mechanism, what is the new mechanism then?
Hello! Any comments on this?