From owner-freebsd-sparc64@FreeBSD.ORG Thu Jan 8 01:41:17 2004 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5094C16A4CE for ; Thu, 8 Jan 2004 01:41:17 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1905443D1D for ; Thu, 8 Jan 2004 01:41:16 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 0FFF95C7F6; Thu, 8 Jan 2004 01:41:16 -0800 (PST) Date: Thu, 8 Jan 2004 10:41:16 +0100 From: Maxime Henrion To: sparc64@FreeBSD.org Message-ID: <20040108094116.GU2060@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="XMCwj5IQnwKtuyBG" Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: Need testers for patch to get MAC address of integrated dc(4) cards X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2004 09:41:17 -0000 --XMCwj5IQnwKtuyBG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, I've tweaked Marius' patch to properly get the MAC address of the integrated Davicom cards found in some sparc64 boxes from OpenFirmware without breaking the build of the dc(4) module. I'd like to get this tested as soon as possible because this patch should go into 5.2-RELEASE and we don't have much time left. Since I don't have the necessary hardware to test it myself, I need your help guys :-). For what it's worth, putting the code into an OF_getetheraddr2() function is a bit crude, but since Marius experienced difficulties merging it into OF_getetheraddr(), I chose to stay on the safe side. This can be revisited later. Thanks, Maxime --XMCwj5IQnwKtuyBG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dc.patch" Index: pci/if_dc.c =================================================================== RCS file: /space/ncvs/src/sys/pci/if_dc.c,v retrieving revision 1.137 diff -u -r1.137 if_dc.c --- pci/if_dc.c 6 Dec 2003 02:29:31 -0000 1.137 +++ pci/if_dc.c 7 Jan 2004 23:32:51 -0000 @@ -131,6 +131,11 @@ #include +#ifdef __sparc64__ +#include +#include +#endif + MODULE_DEPEND(dc, pci, 1, 1, 1); MODULE_DEPEND(dc, ether, 1, 1, 1); MODULE_DEPEND(dc, miibus, 1, 1, 1); @@ -2106,6 +2111,19 @@ dc_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 1); break; case DC_TYPE_DM9102: + dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0); +#ifdef __sparc64__ + /* + * If this is an onboard dc(4) the station address read from + * the EEPROM is all zero and we have to get it from the fcode. + */ + for (i = 0; i < ETHER_ADDR_LEN; i++) + if (eaddr[i] != 0x00) + break; + if (i >= ETHER_ADDR_LEN && OF_getetheraddr2(dev, eaddr) == -1) + OF_getetheraddr(dev, eaddr); +#endif + break; case DC_TYPE_21143: case DC_TYPE_ASIX: dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0); Index: sparc64/sparc64/ofw_machdep.c =================================================================== RCS file: /space/ncvs/src/sys/sparc64/sparc64/ofw_machdep.c,v retrieving revision 1.6 diff -u -r1.6 ofw_machdep.c --- sparc64/sparc64/ofw_machdep.c 26 Dec 2003 14:30:19 -0000 1.6 +++ sparc64/sparc64/ofw_machdep.c 7 Jan 2004 23:44:38 -0000 @@ -29,6 +29,8 @@ * Some OpenFirmware helper functions that are likely machine dependent. */ +#include "opt_ofw_pci.h" + #include #include @@ -56,6 +58,21 @@ if (node <= 0 || OF_getprop(node, "idprom", &idp, sizeof(idp)) == -1) panic("Could not determine the machine ethernet address"); bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN); +} + +int +OF_getetheraddr2(device_t dev, u_char *addr) +{ + phandle_t node; + +#ifdef OFW_NEWPCI + node = ofw_pci_get_node(dev); +#else + node = ofw_pci_node(dev); +#endif + if (node <= 0) + return (-1); + return (OF_getprop(node, "local-mac-address", addr, ETHER_ADDR_LEN)); } int --XMCwj5IQnwKtuyBG--