From: Scott Branden <scott.branden@broadcom.com>
To: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Cc: phil@raspberrypi.org, jonathan@raspberrypi.org,
matthias.bgg@kernel.org, linux-rpi-kernel@lists.infradead.org,
wahrenst@gmx.net, nsaenzjulienne@suse.de,
Doug Berger <opendmb@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"open list:BROADCOM GENET ETHERNET DRIVER"
<bcm-kernel-feedback-list@broadcom.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v2] net: bcmgenet: Generate a random MAC if none is valid
Date: Tue, 15 Oct 2019 15:32:28 -0700 [thread overview]
Message-ID: <dda8587a-0734-d294-5b50-0f5f35c27918@broadcom.com> (raw)
In-Reply-To: <20191014212000.27712-1-f.fainelli@gmail.com>
Hi Florian,
On 2019-10-14 2:20 p.m., Florian Fainelli wrote:
> Instead of having a hard failure and stopping the driver's probe
> routine, generate a random Ethernet MAC address to keep going.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Changes in v2:
>
> - provide a message that a random MAC is used, the same message that
> bcmsysport.c uses
>
> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 12cb77ef1081..dd4e4f1dd384 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -3461,16 +3461,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
> goto err;
> }
>
> - if (dn) {
> + if (dn)
> macaddr = of_get_mac_address(dn);
> - if (IS_ERR(macaddr)) {
> - dev_err(&pdev->dev, "can't find MAC address\n");
> - err = -EINVAL;
> - goto err;
> - }
> - } else {
> + else
> macaddr = pd->mac_address;
> - }
>
> priv->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(priv->base)) {
> @@ -3482,7 +3476,12 @@ static int bcmgenet_probe(struct platform_device *pdev)
>
> SET_NETDEV_DEV(dev, &pdev->dev);
> dev_set_drvdata(&pdev->dev, dev);
> - ether_addr_copy(dev->dev_addr, macaddr);
> + if (IS_ERR_OR_NULL(macaddr) || !is_valid_ether_addr(macaddr)) {
> + dev_warn(&pdev->dev, "using random Ethernet MAC\n");
I would still consider this warrants a dev_err as you should not be
using the device with a random MAC address assigned to it. But I'll
leave it to the "experts" to decide on the print level here.
> + eth_hw_addr_random(dev);
> + } else {
> + ether_addr_copy(dev->dev_addr, macaddr);
> + }
> dev->watchdog_timeo = 2 * HZ;
> dev->ethtool_ops = &bcmgenet_ethtool_ops;
> dev->netdev_ops = &bcmgenet_netdev_ops;
next prev parent reply other threads:[~2019-10-15 22:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 21:20 [PATCH net-next v2] net: bcmgenet: Generate a random MAC if none is valid Florian Fainelli
2019-10-15 0:52 ` Doug Berger
2019-10-15 22:32 ` Scott Branden [this message]
2019-10-15 22:39 ` Jakub Kicinski
2019-10-16 0:04 ` David Miller
2019-10-16 3:34 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dda8587a-0734-d294-5b50-0f5f35c27918@broadcom.com \
--to=scott.branden@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jonathan@raspberrypi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=matthias.bgg@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nsaenzjulienne@suse.de \
--cc=opendmb@gmail.com \
--cc=phil@raspberrypi.org \
--cc=wahrenst@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).