From patchwork Wed Jan 27 00:41:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Cieslakiewicz X-Patchwork-Id: 573789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DBADB140BD6 for ; Wed, 27 Jan 2016 11:54:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=wp.pl header.i=@wp.pl header.b=L7UZ6hVW; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 457EB28C70C; Wed, 27 Jan 2016 01:50:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RP_MATCHES_RCVD,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 90D5E28C707 for ; Wed, 27 Jan 2016 01:48:47 +0100 (CET) X-policyd-weight: using cached result; rate:hard: -5.5 Received: from mx3.wp.pl (mx3.wp.pl [212.77.101.10]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 27 Jan 2016 01:48:39 +0100 (CET) Received: (wp-smtpd smtp.wp.pl 12308 invoked from network); 27 Jan 2016 01:49:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1453855761; bh=B+VTKTe3MZVk+c3uX++1751D4px8zInFcgBUQvdk26c=; h=From:To:Cc:Subject; b=L7UZ6hVW6lBWPWsqoefqrkUrMql6NE4ARk0V3udlxXLAHcxRhYp/NFTuLISfIIixA nMFIMERDlcIvmAnUugJcLYzvw4kSV171j6MZxKKlOoO36+pKRJoOrHCbujH55mZ1Kk 9lVZjy0XpDCYB77lPI/CqyWg2TAtLe64GkF6qZUc= Received: from 89-71-116-5.dynamic.chello.pl (HELO kosmio) (michal.cieslakiewicz@[89.71.116.5]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 27 Jan 2016 01:49:21 +0100 Date: Wed, 27 Jan 2016 01:41:25 +0100 From: Michal To: Hartmut Knaack Message-ID: <20160127014125.4ec37e24@kosmio> In-Reply-To: <20160127010415.7bcf7198@kosmio> References: <56a01420c5aba5.36587961@wp.pl> <56A2C125.1090505@gmx.de> <20160127010415.7bcf7198@kosmio> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-slackware-linux-gnu) MIME-Version: 1.0 X-WP-MailID: bd9701e51bb7076f807175ec8119cf2f X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [cdOE] Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH 7/8] ath79: fix for random WLAN MAC for WNR2000v3 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" From: Michal Cieslakiewicz Fix for invalid/random WLAN MAC address in WNR2000v3. Permanent platform MAC is calculated and assigned during system startup. WLAN MAC follows wired Ethernet interface addresses. Signed-off-by: Michal Cieslakiewicz Acked-by: Hartmut Knaack --- .../ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c index 205c2e7..ee6b449 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c @@ -181,7 +181,7 @@ static struct gpio_keys_button wnr2000v3_gpio_keys[] __initdata = { } }; -static void __init wnr_common_setup(void) +static void __init wnr_common_setup(u8 *wmac_addr) { u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); @@ -200,12 +200,30 @@ static void __init wnr_common_setup(void) ath79_register_eth(1); ath79_register_m25p80(NULL); - ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL); + ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, wmac_addr); } static void __init wnr2000v3_setup(void) { - wnr_common_setup(); + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); + u8 wlan_mac_addr[6]; + u8 *eth0_mac_addr = (u8 *) (art + WNR2000V3_MAC0_OFFSET); + u8 *eth1_mac_addr = (u8 *) (art + WNR2000V3_MAC1_OFFSET); + + /* + * For WNR2000v3 ART flash area used for wlan MAC is usually empty (0xff) + * so ath9k driver uses random MAC instead each time module is loaded. + * To fix that, assign permanent wlan MAC equal to ethN's MAC plus 1, + * so network interfaces get sequential addresses. + */ + memcpy(wlan_mac_addr, eth0_mac_addr, sizeof(wlan_mac_addr)); + wlan_mac_addr[5] = (eth0_mac_addr[5] > eth1_mac_addr[5] ? + eth0_mac_addr[5] : eth1_mac_addr[5]) + 1; + + /* Avoid potential conflict in case: max(0xff,0x00)+1==0x00 */ + if (!wlan_mac_addr[5]) wlan_mac_addr[5] = 1; + + wnr_common_setup(wlan_mac_addr); ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio), wnr2000v3_leds_gpio); @@ -219,7 +237,7 @@ MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3 static void __init wnr612v2_setup(void) { - wnr_common_setup(); + wnr_common_setup(NULL); ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio), wnr612v2_leds_gpio); @@ -229,7 +247,7 @@ MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_set static void __init wnr1000v2_setup(void) { - wnr_common_setup(); + wnr_common_setup(NULL); ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio), wnr1000v2_leds_gpio); @@ -247,7 +265,7 @@ static void __init wpn824n_setup(void) AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN | AR724X_GPIO_FUNC_CLK_OBS3_EN); - wnr_common_setup(); + wnr_common_setup(NULL); ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio), wpn824n_leds_gpio);