Add support to get mac from device-tree using of_get_mac_address.
Signed-off-by: Clément Léger <[email protected]>
---
drivers/net/ethernet/mscc/ocelot_net.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
index eaeba60b1bba..d76def435b23 100644
--- a/drivers/net/ethernet/mscc/ocelot_net.c
+++ b/drivers/net/ethernet/mscc/ocelot_net.c
@@ -1704,7 +1704,10 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
NETIF_F_HW_TC;
dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
- eth_hw_addr_gen(dev, ocelot->base_mac, port);
+ err = of_get_mac_address(portnp, dev->dev_addr);
+ if (err)
+ eth_hw_addr_gen(dev, ocelot->base_mac, port);
+
ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr,
OCELOT_VLAN_UNAWARE_PVID, ENTRYTYPE_LOCKED);
--
2.33.0
On Wed, Nov 03, 2021 at 10:19:38AM +0100, Cl?ment L?ger wrote:
> Add support to get mac from device-tree using of_get_mac_address.
>
> Signed-off-by: Cl?ment L?ger <[email protected]>
> ---
Reviewed-by: Vladimir Oltean <[email protected]>
> drivers/net/ethernet/mscc/ocelot_net.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
> index eaeba60b1bba..d76def435b23 100644
> --- a/drivers/net/ethernet/mscc/ocelot_net.c
> +++ b/drivers/net/ethernet/mscc/ocelot_net.c
> @@ -1704,7 +1704,10 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
> NETIF_F_HW_TC;
> dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
>
> - eth_hw_addr_gen(dev, ocelot->base_mac, port);
> + err = of_get_mac_address(portnp, dev->dev_addr);
> + if (err)
> + eth_hw_addr_gen(dev, ocelot->base_mac, port);
> +
> ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr,
> OCELOT_VLAN_UNAWARE_PVID, ENTRYTYPE_LOCKED);
>
> --
> 2.33.0
>
On 03.11.21 11:19, Clément Léger wrote:
> Add support to get mac from device-tree using of_get_mac_address.
>
> Signed-off-by: Clément Léger <[email protected]>
> ---
> drivers/net/ethernet/mscc/ocelot_net.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
> index eaeba60b1bba..d76def435b23 100644
> --- a/drivers/net/ethernet/mscc/ocelot_net.c
> +++ b/drivers/net/ethernet/mscc/ocelot_net.c
> @@ -1704,7 +1704,10 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
> NETIF_F_HW_TC;
> dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
>
> - eth_hw_addr_gen(dev, ocelot->base_mac, port);
> + err = of_get_mac_address(portnp, dev->dev_addr);
of_get_ethdev_address() maybe, so that this gets routed through Jakub's fancy
new eth_hw_addr_set() infrastructure?
> + if (err)
> + eth_hw_addr_gen(dev, ocelot->base_mac, port);
> +
> ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr,
> OCELOT_VLAN_UNAWARE_PVID, ENTRYTYPE_LOCKED);
>
>
Le Mon, 15 Nov 2021 13:19:49 +0200,
Julian Wiedmann <[email protected]> a écrit :
> On 03.11.21 11:19, Clément Léger wrote:
> > Add support to get mac from device-tree using of_get_mac_address.
> >
> > Signed-off-by: Clément Léger <[email protected]>
> > ---
> > drivers/net/ethernet/mscc/ocelot_net.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
> > index eaeba60b1bba..d76def435b23 100644
> > --- a/drivers/net/ethernet/mscc/ocelot_net.c
> > +++ b/drivers/net/ethernet/mscc/ocelot_net.c
> > @@ -1704,7 +1704,10 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
> > NETIF_F_HW_TC;
> > dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
> >
> > - eth_hw_addr_gen(dev, ocelot->base_mac, port);
> > + err = of_get_mac_address(portnp, dev->dev_addr);
>
> of_get_ethdev_address() maybe, so that this gets routed through Jakub's fancy
> new eth_hw_addr_set() infrastructure?
Hi Julian,
Acked, I will use that.
>
> > + if (err)
> > + eth_hw_addr_gen(dev, ocelot->base_mac, port);
> > +
> > ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr,
> > OCELOT_VLAN_UNAWARE_PVID, ENTRYTYPE_LOCKED);
> >
> >
>
--
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com