All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo van Lil <inguin@gmx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized
Date: Fri, 26 Aug 2011 14:43:34 +0200	[thread overview]
Message-ID: <1314362614-27958-1-git-send-email-inguin@gmx.de> (raw)
In-Reply-To: <4E579387.1090707@mvista.com>

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

  reply	other threads:[~2011-08-26 12:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-08-26 19:20     ` Mike Frysinger

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=1314362614-27958-1-git-send-email-inguin@gmx.de \
    --to=inguin@gmx.de \
    --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 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.