From patchwork Fri Aug 26 09:24:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ingo van Lil X-Patchwork-Id: 111732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C43E9B6F83 for ; Fri, 26 Aug 2011 19:31:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 47ACE28081; Fri, 26 Aug 2011 11:31:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14uzAkFU5sNk; Fri, 26 Aug 2011 11:31:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 88A3628082; Fri, 26 Aug 2011 11:31:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10EC428082 for ; Fri, 26 Aug 2011 11:31:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dU3AxrsgFZtU for ; Fri, 26 Aug 2011 11:31:18 +0200 (CEST) X-Greylist: delayed 399 seconds by postgrey-1.27 at theia; Fri, 26 Aug 2011 11:31:16 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.23]) by theia.denx.de (Postfix) with SMTP id C42A928081 for ; Fri, 26 Aug 2011 11:31:15 +0200 (CEST) Received: (qmail invoked by alias); 26 Aug 2011 09:24:34 -0000 Received: from 50.250.80.212.static.versanetonline.de (EHLO zaphod.peppercon.de) [212.80.250.50] by mail.gmx.net (mp041) with SMTP; 26 Aug 2011 11:24:34 +0200 X-Authenticated: #3035711 X-Provags-ID: V01U2FsdGVkX1/9m/Qc2bf9L1QUHTYTZkFdmNiUVtVaLZb1CIhAn4 +FTCrP5g97sMPU From: Ingo van Lil To: u-boot@lists.denx.de Date: Fri, 26 Aug 2011 11:24:27 +0200 Message-Id: <1314350667-13314-1-git-send-email-inguin@gmx.de> X-Mailer: git-send-email 1.7.6 X-Y-GMX-Trusted: 0 Cc: Ingo van Lil Subject: [U-Boot] [PATCH] Write MAC address whenever ethernet subsystem is initialized X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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;