diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-08-30 21:28:07 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-08-30 21:28:07 +0000 |
commit | 9345a3299225a38772ed10a03968e2051cd152ce (patch) | |
tree | dad8eae82801efb4119a2937ab467d96e1512eba /sys/dev | |
parent | 766e9c63455359ade1e08f073503f121ad73cb7d (diff) |
Try to read station address from the chip first, then try the EEPROM (if we
think it is there). On sparc64 try to read the local-mac-address property
from Open Firmware and as a last resort use the idprom property.
Hopefully fixes reading the station address on the Blade 1500.
ok deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_bge.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 6050e2724b8..4679bf9aaab 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.174 2006/08/29 17:44:16 kettenis Exp $ */ +/* $OpenBSD: if_bge.c,v 1.175 2006/08/30 21:28:06 kettenis Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -1779,33 +1779,40 @@ bge_attach(struct device *parent, struct device *self, void *aux) /* * Get station address from the EEPROM. */ - -#ifdef __sparc64__ - if (OF_getprop(PCITAG_NODE(pa->pa_tag), "local-mac-address", - sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) == ETHER_ADDR_LEN) + mac_addr = bge_readmem_ind(sc, 0x0c14); + if ((mac_addr >> 16) == 0x484b) { + sc->arpcom.ac_enaddr[0] = (u_char)(mac_addr >> 8); + sc->arpcom.ac_enaddr[1] = (u_char)mac_addr; + mac_addr = bge_readmem_ind(sc, 0x0c18); + sc->arpcom.ac_enaddr[2] = (u_char)(mac_addr >> 24); + sc->arpcom.ac_enaddr[3] = (u_char)(mac_addr >> 16); + sc->arpcom.ac_enaddr[4] = (u_char)(mac_addr >> 8); + sc->arpcom.ac_enaddr[5] = (u_char)mac_addr; gotenaddr = 1; -#endif + } + if (!gotenaddr && sc->bge_eeprom) { + if (bge_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, + BGE_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN) == 0) + gotenaddr = 1; + } +#ifdef __sparc64__ if (!gotenaddr) { - mac_addr = bge_readmem_ind(sc, 0x0c14); - if ((mac_addr >> 16) == 0x484b) { - sc->arpcom.ac_enaddr[0] = (u_char)(mac_addr >> 8); - sc->arpcom.ac_enaddr[1] = (u_char)mac_addr; - mac_addr = bge_readmem_ind(sc, 0x0c18); - sc->arpcom.ac_enaddr[2] = (u_char)(mac_addr >> 24); - sc->arpcom.ac_enaddr[3] = (u_char)(mac_addr >> 16); - sc->arpcom.ac_enaddr[4] = (u_char)(mac_addr >> 8); - sc->arpcom.ac_enaddr[5] = (u_char)mac_addr; + if (OF_getprop(PCITAG_NODE(pa->pa_tag), "local-mac-address", + sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) == ETHER_ADDR_LEN) gotenaddr = 1; - } } + if (!gotenaddr) { + extern void myetheraddr(u_char *); + + myetheraddr(sc->arpcom.ac_enaddr); + gotenaddr = 1; + } +#endif if (!gotenaddr) { - if (bge_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, - BGE_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) { - printf(": failed to read station address\n"); - goto fail_2; - } + printf(": failed to read station address\n"); + goto fail_2; } /* |