All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Bur <cyrilbur@gmail.com>
To: miltonm@us.ibm.com
Cc: OpenBMC Patches <openbmc-patches@stwcx.xyz>, openbmc@lists.ozlabs.org
Subject: Re: [PATCH u-boot 4/5] net: Implement random ethaddr fallback in eth.c
Date: Tue, 15 Mar 2016 11:21:33 +1100	[thread overview]
Message-ID: <20160315112133.02fb3d3e@camb691> (raw)
In-Reply-To: <1457721644-29871-5-git-send-email-openbmc-patches@stwcx.xyz>

On Fri, 11 Mar 2016 12:40:43 -0600
OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote:

> From: Joe Hershberger <joe.hershberger@ni.com>
> 
> Commit bef1014b31c5b33052bcaa865ba3618d73e906f0 upstream.
> 
> Backport changes CONFIG_NET_RANDOM_ETHADDR to CONFIG_RANDOM_MACADDR,
> net_random_ethaddr to eth_random_enetaddr, and is_zero_ethaddr to
> is_zero_ether_addr, and keeps existing function order.
> 

Should s/CONFIG_NET_RANDOM_ETHADDR/CONFIG_RANDOM_MACADDR/ have been done
everywhere? It would be best that the README files still reflect what the code
actually does no?

Cyril

> Upstream log:
> 
> Implement the random ethaddr fallback in eth.c so it is in a common
> place and not reimplemented in each board or driver that wants this
> behavior.
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Signed-off-by: Milton D. Miller II <miltonm@us.ibm.com>
> ---
>  README              |  3 ++-
>  doc/README.enetaddr |  2 ++
>  net/eth.c           | 13 ++++++++++++-
>  3 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/README b/README
> index bcfffc3..e06dc8a 100644
> --- a/README
> +++ b/README
> @@ -4764,7 +4764,8 @@ o If both the SROM and the environment contain a MAC address, and the
>    warning is printed.
>  
>  o If neither SROM nor the environment contain a MAC address, an error
> -  is raised.
> +  is raised. If CONFIG_NET_RANDOM_ETHADDR is defined, then in this case
> +  a random, locally-assigned MAC is used.
>  
>  If Ethernet drivers implement the 'write_hwaddr' function, valid MAC addresses
>  will be programmed into hardware as part of the initialization process.	 This
> diff --git a/doc/README.enetaddr b/doc/README.enetaddr
> index 1eaeaf9..611d5a4 100644
> --- a/doc/README.enetaddr
> +++ b/doc/README.enetaddr
> @@ -37,6 +37,8 @@ Correct flow of setting up the MAC address (summarized):
>     environment variable will be used unchanged.
>     If the environment variable is not set, it will be initialized from
>     eth_device->enetaddr, and a warning will be printed.
> +   If both are invalid and CONFIG_NET_RANDOM_ETHADDR is defined, a random,
> +   locally-assigned MAC is written to eth_device->enetaddr.
>  4. Program the address into hardware if the following conditions are met:
>  	a) The relevant driver has a 'write_addr' function
>  	b) The user hasn't set an 'ethmacskip' environment variable
> diff --git a/net/eth.c b/net/eth.c
> index 321d5b1..22d5adb 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -109,6 +109,7 @@ static int __def_eth_init(bd_t *bis)
>  {
>  	return -1;
>  }
> +
>  int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
>  int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
>  
> @@ -214,7 +215,17 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>  		eth_setenv_enetaddr_by_index(base_name, eth_number,
>  					     dev->enetaddr);
>  		printf("\nWarning: %s using MAC address from net device\n",
> -			dev->name);
> +		       dev->name);
> +	} else if (is_zero_ether_addr(dev->enetaddr)) {
> +#ifdef CONFIG_RANDOM_MACADDR
> +		eth_random_enetaddr(dev->enetaddr);
> +		printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",
> +		       dev->name, eth_number, dev->enetaddr);
> +#else
> +		printf("\nError: %s address not set.\n",
> +		       dev->name);
> +		return -EINVAL;
> +#endif
>  	}
>  
>  	if (dev->write_hwaddr &&

  reply	other threads:[~2016-03-15  0:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 18:40 [PATCH u-boot 0/5] Only call aspeednic_init when preparing to use network OpenBMC Patches
2016-03-11 18:40 ` [PATCH u-boot 1/5] net: aspeednic: Create aspeed_write_hwaddr from set_mac_address OpenBMC Patches
2016-03-15  0:12   ` Cyril Bur
2016-03-11 18:40 ` [PATCH u-boot 2/5] net: aspeednic: Do not start hardware in initialize OpenBMC Patches
2016-03-15  0:14   ` Cyril Bur
2016-03-11 18:40 ` [PATCH u-boot 3/5] net: aspeednic: Remove extra spaces before assignments OpenBMC Patches
2016-03-15  0:15   ` Cyril Bur
2016-03-11 18:40 ` [PATCH u-boot 4/5] net: Implement random ethaddr fallback in eth.c OpenBMC Patches
2016-03-15  0:21   ` Cyril Bur [this message]
2016-03-11 18:40 ` [PATCH u-boot 5/5] net: aspeednic: Do not fill in a random MAC address OpenBMC Patches
2016-03-15  0:11   ` Cyril Bur
2016-03-15 22:37     ` Milton Miller II

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=20160315112133.02fb3d3e@camb691 \
    --to=cyrilbur@gmail.com \
    --cc=miltonm@us.ibm.com \
    --cc=openbmc-patches@stwcx.xyz \
    --cc=openbmc@lists.ozlabs.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.