diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2001-09-23 22:41:26 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2001-09-23 22:41:26 +0000 |
commit | 77e3c5a4e03093b0aa5c232a36e895e42223d3bc (patch) | |
tree | b1502315a2aa682b3603507048fa1ec57ee58b26 /sys/dev | |
parent | 288b3e872c00d49b8bb4cde7c343a820c79cdf75 (diff) |
Read the MAC address correctly from 630EA1-based sis(4) devices. Should fix
problems people have been reporting of this nature with the SiS network
devices found on some motherboards; fixes pr#2085. Patch by peter@, jason@ ok
Also, some space vs tab fixes while we're here.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_sis.c | 54 | ||||
-rw-r--r-- | sys/dev/pci/if_sisreg.h | 3 |
2 files changed, 41 insertions, 16 deletions
diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c index 9b97dd70938..16e38b2746d 100644 --- a/sys/dev/pci/if_sis.c +++ b/sys/dev/pci/if_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sis.c,v 1.17 2001/08/25 10:13:29 art Exp $ */ +/* $OpenBSD: if_sis.c,v 1.18 2001/09/23 22:41:25 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -89,7 +89,7 @@ #include <net/bpf.h> #endif -#include <vm/vm.h> /* for vtophys */ +#include <vm/vm.h> /* for vtophys */ #include <sys/device.h> @@ -131,6 +131,7 @@ void sis_eeprom_getword __P((struct sis_softc *, int, u_int16_t *)); #ifdef __i386__ void sis_read_cmos __P((struct sis_softc *, struct pci_attach_args *, caddr_t, int, int)); #endif +void sis_read_630ea1_enaddr __P((struct sis_softc *, struct pci_attach_args *)); void sis_read_eeprom __P((struct sis_softc *, caddr_t, int, int, int)); int sis_miibus_readreg __P((struct device *, int, int)); @@ -337,6 +338,27 @@ void sis_read_cmos(sc, pa, dest, off, cnt) } #endif +void sis_read_630ea1_enaddr(sc, pa) + struct sis_softc *sc; + struct pci_attach_args *pa; +{ + u_int16_t *enaddr = (u_int16_t *) &sc->arpcom.ac_enaddr; + + SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RELOAD); + SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_RELOAD); + + SIS_CLRBIT(sc, SIS_RXFILT_CTL, SIS_RXFILTCTL_ENABLE); + + CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0); + enaddr[0] = CSR_READ_4(sc, SIS_RXFILT_DATA) & 0xffff; + CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR1); + enaddr[1] = CSR_READ_4(sc, SIS_RXFILT_DATA) & 0xffff; + CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2); + enaddr[2] = CSR_READ_4(sc, SIS_RXFILT_DATA) & 0xffff; + + SIS_SETBIT(sc, SIS_RXFILT_CTL, SIS_RXFILTCTL_ENABLE); +} + int sis_miibus_readreg(self, phy, reg) struct device *self; int phy, reg; @@ -466,10 +488,10 @@ u_int32_t sis_crc(sc, addr) void sis_setmulti_ns(sc) struct sis_softc *sc; { - struct ifnet *ifp; - struct arpcom *ac = &sc->arpcom; - struct ether_multi *enm; - struct ether_multistep step; + struct ifnet *ifp; + struct arpcom *ac = &sc->arpcom; + struct ether_multi *enm; + struct ether_multistep step; u_int32_t h = 0, i, filtsave; int bit, index; @@ -496,8 +518,8 @@ void sis_setmulti_ns(sc) CSR_WRITE_4(sc, SIS_RXFILT_DATA, 0); } - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { + ETHER_FIRST_MULTI(step, ac, enm); + while (enm != NULL) { h = sis_crc(sc, enm->enm_addrlo); index = h >> 3; bit = h & 0x1F; @@ -580,7 +602,7 @@ void sis_reset(sc) CSR_WRITE_4(sc, NS_CLKRUN, 0); } - return; + return; } /* @@ -792,19 +814,21 @@ void sis_attach(parent, self, aux) command = pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG) & 0x000000ff; if (command == SIS_REV_630S || - command == SIS_REV_630E || - command == SIS_REV_630EA1) - sis_read_cmos(sc, pa, (caddr_t)&sc->arpcom.ac_enaddr, + command == SIS_REV_630E) + sis_read_cmos(sc, pa, (caddr_t)&sc->arpcom.ac_enaddr, 0x9, 6); else #endif + if (command == SIS_REV_630EA1) + sis_read_630ea1_enaddr(sc, pa); + else sis_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, SIS_EE_NODEADDR, 3, 0); break; } printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); - + sc->sis_ldata_ptr = malloc(sizeof(struct sis_list_data) + 8, M_DEVBUF, M_NOWAIT); if (sc->sis_ldata_ptr == NULL) { @@ -974,8 +998,8 @@ int sis_newbuf(sc, c, m) void sis_rxeof(sc) struct sis_softc *sc; { - struct mbuf *m; - struct ifnet *ifp; + struct mbuf *m; + struct ifnet *ifp; struct sis_desc *cur_rx; int i, total_len = 0; u_int32_t rxstat; diff --git a/sys/dev/pci/if_sisreg.h b/sys/dev/pci/if_sisreg.h index ff13f207de4..0f2f0310d32 100644 --- a/sys/dev/pci/if_sisreg.h +++ b/sys/dev/pci/if_sisreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sisreg.h,v 1.6 2001/03/14 15:17:31 aaron Exp $ */ +/* $OpenBSD: if_sisreg.h,v 1.7 2001/09/23 22:41:25 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -106,6 +106,7 @@ #define SIS_CSR_RX_RESET 0x00000020 #define SIS_CSR_SOFTINTR 0x00000080 #define SIS_CSR_RESET 0x00000100 +#define SIS_CSR_RELOAD 0x00000400 #define SIS_CFG_BIGENDIAN 0x00000001 #define SIS_CFG_PERR_DETECT 0x00000008 |