Need testers for patch to get MAC address of integrated dc(4)
cards
Marius Strobl
marius at alchemy.franken.de
Thu Jan 8 08:59:22 PST 2004
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.
-------------- next part --------------
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 <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/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 <sys/param.h>
#include <sys/systm.h>
@@ -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
More information about the freebsd-sparc64
mailing list