From owner-svn-src-all@FreeBSD.ORG Sun Mar 16 02:41:47 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AB6C6383; Sun, 16 Mar 2014 02:41:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7FEC41B3; Sun, 16 Mar 2014 02:41:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2G2flI3017756; Sun, 16 Mar 2014 02:41:47 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2G2flQb017755; Sun, 16 Mar 2014 02:41:47 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201403160241.s2G2flQb017755@svn.freebsd.org> From: Adrian Chadd Date: Sun, 16 Mar 2014 02:41:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263224 - head/sys/mips/atheros X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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: Sun, 16 Mar 2014 02:41:47 -0000 Author: adrian Date: Sun Mar 16 02:41:47 2014 New Revision: 263224 URL: http://svnweb.freebsd.org/changeset/base/263224 Log: Handle the case where both arge0 and arge1 MAC addresses are available via 'eeprommac'. The existing driver would just make arge units past 0 take the primary MAC and increment it by the unit number, without correct address wrapping. That has to be fixed at a later date. Tested: * Atheros DB120 reference obard Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Sun Mar 16 02:34:33 2014 (r263223) +++ head/sys/mips/atheros/if_arge.c Sun Mar 16 02:41:47 2014 (r263224) @@ -555,6 +555,7 @@ arge_attach(device_t dev) long eeprom_mac_addr = 0; int miicfg = 0; int readascii = 0; + int local_mac = 0; sc = device_get_softc(dev); sc->arge_dev = dev; @@ -576,6 +577,7 @@ arge_attach(device_t dev) */ if (resource_long_value(device_get_name(dev), device_get_unit(dev), "eeprommac", &eeprom_mac_addr) == 0) { + local_mac = 1; int i; const char *mac = (const char *) MIPS_PHYS_TO_KSEG1(eeprom_mac_addr); @@ -729,7 +731,22 @@ arge_attach(device_t dev) sc->arge_eaddr[4] = (rnd >> 16) & 0xff; sc->arge_eaddr[5] = (rnd >> 8) & 0xff; } - if (sc->arge_mac_unit != 0) + + /* + * This is a little hairy and stupid. + * + * For some older boards, the arge1 mac isn't pulled from anywhere. + * It's just assumed the MAC is the base MAC + 1. + * + * For other boards, there's multiple MAC addresses stored in EEPROM. + * + * So, if we did read the eeprommac for this particular interface, + * let's use the address as given. Otherwise, just add the MAC unit + * counter to it. + * + * XXX TODO: we really should handle MAC byte wraparound! + */ + if (local_mac == 0 && sc->arge_mac_unit != 0) sc->arge_eaddr[5] += sc->arge_mac_unit; if (arge_dma_alloc(sc) != 0) {