Date: Thu, 8 Jan 2004 10:41:16 +0100 From: Maxime Henrion <mux@freebsd.org> To: sparc64@FreeBSD.org Subject: Need testers for patch to get MAC address of integrated dc(4) cards Message-ID: <20040108094116.GU2060@elvis.mu.org>
next in thread | raw e-mail | index | archive | help
--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 <pci/if_dcreg.h> +#ifdef __sparc64__ +#include <dev/ofw/openfirm.h> +#include <machine/ofw_machdep.h> +#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 <sys/param.h> #include <sys/systm.h> @@ -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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040108094116.GU2060>