All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized
@ 2011-08-26  9:24 Ingo van Lil
  2011-08-26 12:37 ` Sergei Shtylyov
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo van Lil @ 2011-08-26  9:24 UTC (permalink / raw)
  To: u-boot

Currently the ethernet MAC address is read from the 'ethaddr'
environment variable into the dev->enetaddr field each time the network
hardware is initialized, but it is written to the actual hardware only
once at board startup. When 'ethaddr' is set or changed after startup
the device can no longer receive packets because the hardware filter is
still programmed to the old MAC.

This patch moves the writing of the hardware address from eth_initialize
(board startup) to eth_init (just before actually using the network).
---
 net/eth.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 6082c90..2b43ae7 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -261,11 +261,6 @@ int eth_initialize(bd_t *bis)
 
 				memcpy(dev->enetaddr, env_enetaddr, 6);
 			}
-			if (dev->write_hwaddr &&
-				!eth_mac_skip(eth_number) &&
-				is_valid_ether_addr(dev->enetaddr)) {
-				dev->write_hwaddr(dev);
-			}
 
 			eth_number++;
 			dev = dev->next;
@@ -347,8 +342,14 @@ int eth_init(bd_t *bis)
 	do {
 		uchar env_enetaddr[6];
 
-		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr))
+		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr)) {
 			memcpy(dev->enetaddr, env_enetaddr, 6);
+			if (dev->write_hwaddr &&
+				!eth_mac_skip(eth_number) &&
+				is_valid_ether_addr(dev->enetaddr)) {
+				dev->write_hwaddr(dev);
+			}
+		}
 
 		++eth_number;
 		dev = dev->next;
-- 
1.7.6

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

* [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized
  2011-08-26  9:24 [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized Ingo van Lil
@ 2011-08-26 12:37 ` Sergei Shtylyov
  2011-08-26 12:43   ` Ingo van Lil
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2011-08-26 12:37 UTC (permalink / raw)
  To: u-boot

Hello.

On 26-08-2011 13:24, Ingo van Lil wrote:

> Currently the ethernet MAC address is read from the 'ethaddr'
> environment variable into the dev->enetaddr field each time the network
> hardware is initialized, but it is written to the actual hardware only
> once at board startup. When 'ethaddr' is set or changed after startup
> the device can no longer receive packets because the hardware filter is
> still programmed to the old MAC.

> This patch moves the writing of the hardware address from eth_initialize
> (board startup) to eth_init (just before actually using the network).

    You didn't sign off the patch...

WBR, Sergei

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

* [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized
  2011-08-26 12:37 ` Sergei Shtylyov
@ 2011-08-26 12:43   ` Ingo van Lil
  2011-08-26 19:20     ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo van Lil @ 2011-08-26 12:43 UTC (permalink / raw)
  To: u-boot

Currently the ethernet MAC address is read from the 'ethaddr'
environment variable into the dev->enetaddr field each time the network
hardware is initialized, but it is written to the actual hardware only
once at board startup. When 'ethaddr' is set or changed after startup
the device can no longer receive packets because the hardware filter is
still programmed to the old MAC.

This patch moves the writing of the hardware address from eth_initialize
(board startup) to eth_init (just before actually using the network).

Signed-off-by: Ingo van Lil <inguin@gmx.de>
---
 net/eth.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 6082c90..2b43ae7 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -261,11 +261,6 @@ int eth_initialize(bd_t *bis)
 
 				memcpy(dev->enetaddr, env_enetaddr, 6);
 			}
-			if (dev->write_hwaddr &&
-				!eth_mac_skip(eth_number) &&
-				is_valid_ether_addr(dev->enetaddr)) {
-				dev->write_hwaddr(dev);
-			}
 
 			eth_number++;
 			dev = dev->next;
@@ -347,8 +342,14 @@ int eth_init(bd_t *bis)
 	do {
 		uchar env_enetaddr[6];
 
-		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr))
+		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr)) {
 			memcpy(dev->enetaddr, env_enetaddr, 6);
+			if (dev->write_hwaddr &&
+				!eth_mac_skip(eth_number) &&
+				is_valid_ether_addr(dev->enetaddr)) {
+				dev->write_hwaddr(dev);
+			}
+		}
 
 		++eth_number;
 		dev = dev->next;
-- 
1.7.6

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

* [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized
  2011-08-26 12:43   ` Ingo van Lil
@ 2011-08-26 19:20     ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2011-08-26 19:20 UTC (permalink / raw)
  To: u-boot

On Friday, August 26, 2011 08:43:34 Ingo van Lil wrote:
> @@ -261,11 +261,6 @@ int eth_initialize(bd_t *bis)
> 
>  				memcpy(dev->enetaddr, env_enetaddr, 6);
>  			}
> -			if (dev->write_hwaddr &&
> -				!eth_mac_skip(eth_number) &&
> -				is_valid_ether_addr(dev->enetaddr)) {
> -				dev->write_hwaddr(dev);
> -			}

removing this breaks the original reason write_hwaddr was added in the first 
place: people want the MAC programmed into the hardware even if they dont use 
the network.

we should probably add an explicit comment above this block so people dont try 
and "fix it" in the future.

> @@ -347,8 +342,14 @@ int eth_init(bd_t *bis)
>  	do {
>  		uchar env_enetaddr[6];
> 
> -		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr))
> +		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr)) {
>  			memcpy(dev->enetaddr, env_enetaddr, 6);
> +			if (dev->write_hwaddr &&
> +				!eth_mac_skip(eth_number) &&
> +				is_valid_ether_addr(dev->enetaddr)) {
> +				dev->write_hwaddr(dev);
> +			}
> +		}

this changes the current API between the common layer and the drivers.  i'm 
not saying that's a bad thing, just that we need to:
 (1) update the documentation (see doc/README.{drivers.eth,enetaddr})
 (2) update the drivers which manually call their write_hwaddr() in their 
init() func to no longer do that
-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/20110826/227c79ac/attachment.pgp 

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

end of thread, other threads:[~2011-08-26 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26  9:24 [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized Ingo van Lil
2011-08-26 12:37 ` Sergei Shtylyov
2011-08-26 12:43   ` Ingo van Lil
2011-08-26 19:20     ` Mike Frysinger

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.