From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 03:48:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C5A0106564A; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CBDA8FC12; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p323mFFB069367; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p323mFeb069365; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020348.p323mFeb069365@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 03:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220260 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 03:48:15 -0000 Author: adrian Date: Sat Apr 2 03:48:15 2011 New Revision: 220260 URL: http://svn.freebsd.org/changeset/base/220260 Log: A handful of the openwrt devices use a MAC address that's at a hard-coded offset in the flash. Some devices (eg the TPLink WR-1043ND) don't have a flash environment partition which can be queried for the current board settings. This particular workaround allows for image creators to use a hint to set the base MAC address. For example: hint.arge.0.eeprommac=0x1f01fc00 Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Sat Apr 2 00:27:22 2011 (r220259) +++ head/sys/mips/atheros/if_arge.c Sat Apr 2 03:48:15 2011 (r220260) @@ -227,11 +227,32 @@ arge_attach(device_t dev) uint32_t reg, rnd; int is_base_mac_empty, i, phys_total; uint32_t hint; + long eeprom_mac_addr = 0; sc = device_get_softc(dev); sc->arge_dev = dev; sc->arge_mac_unit = device_get_unit(dev); + /* + * Some units (eg the TP-Link WR-1043ND) do not have a convenient + * EEPROM location to read the ethernet MAC address from. + * OpenWRT simply snaffles it from a fixed location. + * + * Since multiple units seem to use this feature, include + * a method of setting the MAC address based on an flash location + * in CPU address space. + */ + if (sc->arge_mac_unit == 0 && + resource_long_value(device_get_name(dev), device_get_unit(dev), + "eeprommac", &eeprom_mac_addr) == 0) { + int i; + const char *mac = (const char *) MIPS_PHYS_TO_KSEG1(eeprom_mac_addr); + device_printf(dev, "Overriding MAC from EEPROM\n"); + for (i = 0; i < 6; i++) { + ar711_base_mac[i] = mac[i]; + } + } + KASSERT(((sc->arge_mac_unit == 0) || (sc->arge_mac_unit == 1)), ("if_arge: Only MAC0 and MAC1 supported"));