All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] ethernet: ROM MAC address vs env variable MAC address
@ 2017-11-08 12:02 Prabhakar Kushwaha
  2017-11-09 10:14 ` Lukasz Majewski
  2017-11-13 19:49 ` Wolfgang Denk
  0 siblings, 2 replies; 4+ messages in thread
From: Prabhakar Kushwaha @ 2017-11-08 12:02 UTC (permalink / raw)
  To: u-boot

Hi All, 

I am seeing following type of code for MAC address write for a network device.

net/eth-uclass.c  eth_post_probe()   or net/eth_legacy.c eth_write_hwaddr()

	eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr);
	if (!is_zero_ethaddr(env_enetaddr)) {
		if (!is_zero_ethaddr(pdata->enetaddr) &&
		    memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
			printf("\nWarning: %s MAC addresses don't match:\n",
			       dev->name);
			printf("Address in ROM is          %pM\n",
			       pdata->enetaddr);
			printf("Address in environment is  %pM\n",
			       env_enetaddr);
		}

		/* Override the ROM MAC address */
		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);

Why ROM MAC address getting overwritten by environment env MAC address.  
MAC address is something unique and assigned to a particular device. So one should never change its MAC address.

Please suggest. 

Regards,
Prabhakar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] ethernet: ROM MAC address vs env variable MAC address
  2017-11-08 12:02 [U-Boot] ethernet: ROM MAC address vs env variable MAC address Prabhakar Kushwaha
@ 2017-11-09 10:14 ` Lukasz Majewski
  2017-11-13 19:49 ` Wolfgang Denk
  1 sibling, 0 replies; 4+ messages in thread
From: Lukasz Majewski @ 2017-11-09 10:14 UTC (permalink / raw)
  To: u-boot

Hi Prabhakar,

> Hi All, 
> 
> I am seeing following type of code for MAC address write for a
> network device.
> 
> net/eth-uclass.c  eth_post_probe()   or net/eth_legacy.c
> eth_write_hwaddr()
> 
> 	eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr);
> 	if (!is_zero_ethaddr(env_enetaddr)) {
> 		if (!is_zero_ethaddr(pdata->enetaddr) &&
> 		    memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
> 			printf("\nWarning: %s MAC addresses don't
> match:\n", dev->name);
> 			printf("Address in ROM is          %pM\n",
> 			       pdata->enetaddr);
> 			printf("Address in environment is  %pM\n",
> 			       env_enetaddr);
> 		}
> 
> 		/* Override the ROM MAC address */
> 		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
> 
> Why ROM MAC address getting overwritten by environment env MAC
> address. MAC address is something unique and assigned to a particular
> device. So one should never change its MAC address.
> 

It may happen that company which uses NXP processor wants to use their
own set of MAC addresses.

> Please suggest. 
> 
> Regards,
> Prabhakar
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171109/28cb3e2f/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] ethernet: ROM MAC address vs env variable MAC address
  2017-11-08 12:02 [U-Boot] ethernet: ROM MAC address vs env variable MAC address Prabhakar Kushwaha
  2017-11-09 10:14 ` Lukasz Majewski
@ 2017-11-13 19:49 ` Wolfgang Denk
  2017-11-14  9:31   ` Mike Looijmans
  1 sibling, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2017-11-13 19:49 UTC (permalink / raw)
  To: u-boot

Dear Prabhakar,

In message <HE1PR04MB12410876E4BA09FC9CD7800C97560@HE1PR04MB1241.eurprd04.prod.outlook.com> you wrote:
> 
> Why ROM MAC address getting overwritten by environment env MAC address.  

Because in U-Boot we give the user the freedom to do what he
needs/wants to do.  Usually the environment value gets initialized
from the value in the ROM, so there is no difference anyway. But if
the user wants a specific setting, he can change it.

> MAC address is something unique and assigned to a particular device. So one should never change its MAC address.

U-Boot follows good old UNIX style here:

"UNIX was not designed to stop you from doing stupid things,  because
that would also stop you from doing clever things."       - Doug Gwyn




Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If in any problem you find yourself doing an immense amount of  work,
the answer can be obtained by simple inspection.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] ethernet: ROM MAC address vs env variable MAC address
  2017-11-13 19:49 ` Wolfgang Denk
@ 2017-11-14  9:31   ` Mike Looijmans
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Looijmans @ 2017-11-14  9:31 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8-sig", Size: 1594 bytes --]

On 13-11-17 20:49, Wolfgang Denk wrote:
> Dear Prabhakar,
> 
> In message <HE1PR04MB12410876E4BA09FC9CD7800C97560@HE1PR04MB1241.eurprd04.prod.outlook.com> you wrote:
>>
>> Why ROM MAC address getting overwritten by environment env MAC address.
> 
> Because in U-Boot we give the user the freedom to do what he
> needs/wants to do.  Usually the environment value gets initialized
> from the value in the ROM, so there is no difference anyway. But if
> the user wants a specific setting, he can change it.
> 
>> MAC address is something unique and assigned to a particular device. So one should never change its MAC address.
> 
> U-Boot follows good old UNIX style here:
> 
> "UNIX was not designed to stop you from doing stupid things,  because
> that would also stop you from doing clever things."       - Doug Gwyn

Many board manufacturers "assign" this unique MAC address by printing it on a 
sticker and sticking that on the board somewhere. It's pretty darn hard to 
read a printed sticker in software, so we have to revert to solutions that 
actually work.

In the "clever things" department, protocols like IPv6 merrily broadcast your 
MAC address across gateways on the big bad internet, so if you value your 
privacy, you'll appreciate the possibility to change your MAC address at will.



Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans at topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-14  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 12:02 [U-Boot] ethernet: ROM MAC address vs env variable MAC address Prabhakar Kushwaha
2017-11-09 10:14 ` Lukasz Majewski
2017-11-13 19:49 ` Wolfgang Denk
2017-11-14  9:31   ` Mike Looijmans

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.