public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] net: kirkwood: updates: used eth_setenv_enetaddr api
Date: Thu, 13 Aug 2009 01:17:25 -0400	[thread overview]
Message-ID: <200908130117.28652.vapier@gentoo.org> (raw)
In-Reply-To: <4A7C9EAF.4060507@gmail.com>

On Friday 07 August 2009 17:37:51 Ben Warren wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 22:17 Fri 07 Aug     , Prafulla Wadaskar wrote:
> >> eth_setenv_enetaddr is avaible by upper layer
> >> using this saves 204 bytes on total image size
> >>
> >> Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
> >> ---
> >>  drivers/net/kirkwood_egiga.c |   13 ++++++++-----
> >>  1 files changed, 8 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
> >> index 3d908f8..1a208f2 100644
> >> --- a/drivers/net/kirkwood_egiga.c
> >> +++ b/drivers/net/kirkwood_egiga.c
> >> @@ -606,7 +606,7 @@ int kirkwood_egiga_initialize(bd_t * bis)
> >>  	struct kwgbe_device *dkwgbe;
> >>  	struct eth_device *dev;
> >>  	int devnum;
> >> -	char *s, buf[NAMESIZE * 2];
> >> +	char *s;
> >>  	u8 used_ports[MAX_KWGBE_DEVS] = CONFIG_KIRKWOOD_EGIGA_PORTS;
> >>
> >>  	for (devnum = 0; devnum < MAX_KWGBE_DEVS; devnum++) {
> >> @@ -665,10 +665,13 @@ int kirkwood_egiga_initialize(bd_t * bis)
> >>
> >>  		while (!eth_getenv_enetaddr(s, dev->enetaddr)) {
> >>  			/* Generate Ramdom MAC addresses if not set */
> >> -			sprintf(buf, "00:50:43:%02x:%02x:%02x",
> >> -				get_random_hex(), get_random_hex(),
> >> -				get_random_hex());
> >> -			setenv(s, buf);
> >> +			dev->enetaddr[0] = 0x00;
> >> +			dev->enetaddr[1] = 0x50;
> >> +			dev->enetaddr[2] = 0x43;
> >> +			dev->enetaddr[3] = get_random_hex();
> >> +			dev->enetaddr[4] = get_random_hex();
> >> +			dev->enetaddr[5] = get_random_hex();
> >> +			eth_setenv_enetaddr(s, dev->enetaddr);
> >
> > it will be also good to use a private mac address
> > 			dev->enetaddr[0] = 0x02;
>
> Full ACK.  If you're generating something random, it MUST have the
> private bit.  Unless Marvell owns this block and is giving it away and
> is keeping track of all used numbers and ...

really we should add a new common eth function that generates a random local 
mac address ... and have each arch implement a random function.  you can see 
the one i use for Blackfin systems in asm-blackfin/net.h ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/f95b5a9e/attachment.pgp 

  reply	other threads:[~2009-08-13  5:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07 16:47 [U-Boot] [PATCH] net: kirkwood: updates: used eth_setenv_enetaddr api Prafulla Wadaskar
2009-08-07 21:07 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-07 21:37   ` Ben Warren
2009-08-13  5:17     ` Mike Frysinger [this message]
2009-08-15  8:35       ` Prafulla Wadaskar

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=200908130117.28652.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /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