From owner-freebsd-sparc64@FreeBSD.ORG Thu Jan 8 08:59:22 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 3324C16A4CE; Thu, 8 Jan 2004 08:59:22 -0800 (PST) Received: from newtrinity.zeist.de (newtrinity.zeist.de [217.24.217.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC25543D78; Thu, 8 Jan 2004 08:58:40 -0800 (PST) (envelope-from marius@newtrinity.zeist.de) Received: from newtrinity.zeist.de (localhost [127.0.0.1]) i08Gwe9J098097; Thu, 8 Jan 2004 17:58:40 +0100 (CET) (envelope-from marius@newtrinity.zeist.de) Received: (from marius@localhost) by newtrinity.zeist.de (8.12.10/8.12.10/Submit) id i08GwZ4o098096; Thu, 8 Jan 2004 17:58:35 +0100 (CET) (envelope-from marius) Date: Thu, 8 Jan 2004 17:58:35 +0100 From: Marius Strobl To: Maxime Henrion Message-ID: <20040108175835.A95298@newtrinity.zeist.de> References: <20040108094116.GU2060@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ZfOjI3PrQbgiZnxM" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20040108094116.GU2060@elvis.mu.org>; from mux@freebsd.org on Thu, Jan 08, 2004 at 10:41:16AM +0100 X-AntiVirus: checked by AntiVir Milter 1.0.6; AVE 6.23.0.2; VDF 6.23.0.26 cc: sparc64@freebsd.org Subject: Re: 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 16:59:22 -0000 --ZfOjI3PrQbgiZnxM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 08, 2004 at 10:41:16AM +0100, Maxime Henrion wrote: > 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. > Please use the attached version instead, it has two changes over Maxime's version: - Fix compilation by adding a prototype for OF_getetheraddr2(). - Add a debugging printf for an issue I had with my version of OF_getetheraddr() to really make sure it works as expected. The patch is compile tested but otherwise not (yet) tested on my side. I probably won't be able to really test it in time for getting it into 5.2-RELEASE, so if you own a Netra X1 or a Sunfire V100 please give it a try an reply with all the dcX lines you get in /var/run/dmesg.boot. Thanks. --ZfOjI3PrQbgiZnxM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dc.patch2" Index: pci/if_dc.c =================================================================== RCS file: /usr/data/bsd/cvs/fbsd/src/sys/pci/if_dc.c,v retrieving revision 1.138 diff -u -r1.138 if_dc.c --- pci/if_dc.c 8 Jan 2004 06:22:15 -0000 1.138 +++ pci/if_dc.c 8 Jan 2004 14:22:26 -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/include/ofw_machdep.h =================================================================== RCS file: /usr/data/bsd/cvs/fbsd/src/sys/sparc64/include/ofw_machdep.h,v retrieving revision 1.3 diff -u -r1.3 ofw_machdep.h --- sparc64/include/ofw_machdep.h 2 Sep 2003 20:32:12 -0000 1.3 +++ sparc64/include/ofw_machdep.h 8 Jan 2004 16:27:28 -0000 @@ -32,6 +32,7 @@ int OF_decode_addr(phandle_t, int *, bus_addr_t *); void OF_getetheraddr(device_t, u_char *); +int OF_getetheraddr2(device_t, u_char *); void cpu_shutdown(void *); void openfirmware_exit(void *); Index: sparc64/sparc64/ofw_machdep.c =================================================================== RCS file: /usr/data/bsd/cvs/fbsd/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 8 Jan 2004 14:49:18 -0000 @@ -29,6 +29,8 @@ * Some OpenFirmware helper functions that are likely machine dependent. */ +#include "opt_ofw_pci.h" + #include #include @@ -56,6 +58,23 @@ 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) { + device_printf(dev, "OF_getetheraddr2: invalid node.\n"); + return (-1); + } + return (OF_getprop(node, "local-mac-address", addr, ETHER_ADDR_LEN)); } int --ZfOjI3PrQbgiZnxM--