[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DB8PR04MB698558D9D5AB177E65D32B66ECE20@DB8PR04MB6985.eurprd04.prod.outlook.com>
Date: Thu, 5 Mar 2020 15:03:48 +0000
From: Madalin Bucur <madalin.bucur@....com>
To: Sascha Hauer <s.hauer@...gutronix.de>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH v2] fsl/fman: Use random MAC address when none is given
> -----Original Message-----
> From: Sascha Hauer <s.hauer@...gutronix.de>
> Sent: Thursday, March 5, 2020 4:48 PM
> To: Madalin Bucur <madalin.bucur@....com>
> Cc: netdev@...r.kernel.org
> Subject: Re: [PATCH v2] fsl/fman: Use random MAC address when none is
> given
>
> On Thu, Mar 05, 2020 at 01:38:01PM +0000, Madalin Bucur wrote:
> > > -----Original Message-----
> > > From: Sascha Hauer <s.hauer@...gutronix.de>
> > > Sent: Thursday, March 5, 2020 2:34 PM
> > > To: netdev@...r.kernel.org
> > > Cc: Madalin Bucur <madalin.bucur@....com>; Sascha Hauer
> > > <s.hauer@...gutronix.de>
> > > Subject: [PATCH v2] fsl/fman: Use random MAC address when none is
> given
> > >
> > > There's no need to fail probing when no MAC address is given in the
> > > device tree, just use a random MAC address.
> > >
> > > Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> > > ---
> > >
> > > Changes since v1:
> > > - Remove printing of permanent MAC address
> > >
> > > drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 11 +++++++++--
> > > drivers/net/ethernet/freescale/fman/fman_memac.c | 4 ----
> > > drivers/net/ethernet/freescale/fman/mac.c | 10 ++--------
> > > 3 files changed, 11 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > index fd93d542f497..fc117eab788d 100644
> > > --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > @@ -233,8 +233,15 @@ static int dpaa_netdev_init(struct net_device
> > > *net_dev,
> > > net_dev->features |= net_dev->hw_features;
> > > net_dev->vlan_features = net_dev->features;
> > >
> > > - memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len);
> > > - memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
> > > + if (is_valid_ether_addr(mac_addr)) {
> > > + dev_info(dev, "FMan MAC address: %pM\n", mac_addr);
> > > + memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len);
> > > + memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
> > > + } else {
> > > + eth_hw_addr_random(net_dev);
> > > + dev_info(dev, "Using random MAC address: %pM\n",
> > > + net_dev->dev_addr);
> > > + }
> >
> > To make the HW MAC aware of the new random address you set in the
> dpaa_eth,
> > you also need to call mac_dev->change_addr() after
> eth_hw_addr_random(), like
> > it's done in dpaa_set_mac_address():
> >
> > err = mac_dev->change_addr(mac_dev->fman_mac,
> > (enet_addr_t *)net_dev->dev_addr);
> >
> > This will write the new MAC address in the MAC HW registers.
>
> Ok, I see.
>
> So when I call mac_dev->change_addr() here in dpaa_netdev_init() it
> means I can remove all the code setting the MAC address in hardware
> before this point, right?
It's not an issue if you just write it here for the random address and leave
the previous functionality in place. Do you have a board to validate your
changes?
> Sascha
>
> --
> Pengutronix e.K. |
> |
> Steuerwalder Str. 21 |
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.peng
> utronix.de%2F&data=02%7C01%7Cmadalin.bucur%40nxp.com%7C4b875830989945
> 006ae908d7c11439bc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637190164
> 922597543&sdata=48VF83dAoB1m5B3I0jQIf0KwhO9au4gJVIieGqt1G8c%3D&re
> served=0 |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
> |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
> |
Powered by blists - more mailing lists