diff options
-rw-r--r-- | sys/arch/mac68k/dev/if_mc.c | 57 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_mc_obio.c | 18 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_mcreg.h | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_mcvar.h | 10 |
4 files changed, 36 insertions, 55 deletions
diff --git a/sys/arch/mac68k/dev/if_mc.c b/sys/arch/mac68k/dev/if_mc.c index 504a9fd37c2..57495fe1644 100644 --- a/sys/arch/mac68k/dev/if_mc.c +++ b/sys/arch/mac68k/dev/if_mc.c @@ -1,8 +1,8 @@ -/* $OpenBSD: if_mc.c,v 1.8 2004/12/13 17:19:23 claudio Exp $ */ -/* $NetBSD: if_mc.c,v 1.4 1998/01/12 19:22:09 thorpej Exp $ */ +/* $OpenBSD: if_mc.c,v 1.9 2004/12/15 06:48:23 martin Exp $ */ +/* $NetBSD: if_mc.c,v 1.24 2004/10/30 18:08:34 thorpej Exp $ */ /*- - * Copyright (c) 1997 David Huang <khym@bga.com> + * Copyright (c) 1997 David Huang <khym@azeotrope.org> * All rights reserved. * * Portions of this code are based on code by Denton Gentry <denny1@home.com>, @@ -191,7 +191,6 @@ mcioctl(ifp, cmd, data) struct ifreq *ifr; int s = splnet(), err = 0; - int temp; switch (cmd) { @@ -250,9 +249,7 @@ mcioctl(ifp, cmd, data) * reset the interface to pick up any other changes * in flags */ - temp = ifp->if_flags & IFF_UP; mcreset(sc); - ifp->if_flags |= temp; mcstart(ifp); } break; @@ -269,9 +266,9 @@ mcioctl(ifp, cmd, data) * Multicast list has changed; set the hardware * filter accordingly. But remember UP flag! */ - temp = ifp->if_flags & IFF_UP; mcreset(sc); - ifp->if_flags |= temp; + if (ifp->if_flags & IFF_RUNNING) + mcreset(sc); err = 0; } break; @@ -418,7 +415,7 @@ mcstop(sc) DELAY(100); sc->sc_if.if_timer = 0; - sc->sc_if.if_flags &= ~(IFF_RUNNING | IFF_UP); + sc->sc_if.if_flags &= ~IFF_RUNNING; splx(s); return (0); @@ -434,12 +431,9 @@ mcwatchdog(ifp) struct ifnet *ifp; { struct mc_softc *sc = ifp->if_softc; - int temp; printf("mcwatchdog: resetting chip\n"); - temp = ifp->if_flags & IFF_UP; mcreset(sc); - ifp->if_flags |= temp; } /* @@ -465,7 +459,7 @@ maceput(sc, m) MFREE(m, n); } - if (totlen > NBPG) + if (totlen > PAGE_SIZE) panic("%s: maceput: packet overflow", sc->sc_dev.dv_xname); #if 0 @@ -505,7 +499,9 @@ struct mc_softc *sc = arg; } if (ir & CERR) { +#ifdef MCDEBUG printf("%s: collision error\n", sc->sc_dev.dv_xname); +#endif sc->sc_if.if_collisions++; } @@ -552,6 +548,7 @@ mc_tint(sc) else if (xmtfs & ONE) sc->sc_if.if_collisions++; else if (xmtfs & RTRY) { + printf("%s: excessive collisions\n", sc->sc_dev.dv_xname); sc->sc_if.if_collisions += 16; sc->sc_if.if_oerrors++; } @@ -631,14 +628,6 @@ mace_read(sc, pkt, len) return; } -#if NBPFILTER > 0 - /* - * Check if there's a bpf filter listening on this interface. - * If so, hand off the raw packet to enet. - */ - if (ifp->if_bpf) - bpf_tap(ifp->if_bpf, pkt, len); -#endif m = mace_get(sc, pkt, len); if (m == NULL) { ifp->if_ierrors++; @@ -647,6 +636,12 @@ mace_read(sc, pkt, len) ifp->if_ipackets++; +#if NBPFILTER > 0 + /* Pass the packet to any BPF listeners. */ + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m); +#endif + /* Pass the packet up. */ ether_input_mbuf(ifp, m); } @@ -716,9 +711,7 @@ mace_calcladrf(ac, af) { struct ifnet *ifp = &ac->ac_if; struct ether_multi *enm; - register u_char *cp, c; register u_int32_t crc; - register int i, len; struct ether_multistep step; /* @@ -730,7 +723,6 @@ mace_calcladrf(ac, af) */ *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0; - ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) { @@ -745,19 +737,8 @@ mace_calcladrf(ac, af) goto allmulti; } - cp = enm->enm_addrlo; - crc = 0xffffffff; - for (len = sizeof(enm->enm_addrlo); --len >= 0;) { - c = *cp++; - for (i = 8; --i >= 0;) { - if ((crc & 0x01) ^ (c & 0x01)) { - crc >>= 1; - crc ^= 0xedb88320; - } else - crc >>= 1; - c >>= 1; - } - } + crc = ether_crc32_le(enm->enm_addrlo, sizeof(enm->enm_addrlo)); + /* Just want the 6 most significant bits. */ crc >>= 26; @@ -781,7 +762,7 @@ u_char mc_get_enaddr(t, h, o, dst) bus_space_tag_t t; bus_space_handle_t h; - vm_offset_t o; + bus_size_t o; u_char *dst; { int i; diff --git a/sys/arch/mac68k/dev/if_mc_obio.c b/sys/arch/mac68k/dev/if_mc_obio.c index 9e475e172af..500bf2bd9d9 100644 --- a/sys/arch/mac68k/dev/if_mc_obio.c +++ b/sys/arch/mac68k/dev/if_mc_obio.c @@ -1,8 +1,8 @@ -/* $OpenBSD: if_mc_obio.c,v 1.4 2002/04/20 00:17:05 miod Exp $ */ -/* $NetBSD: if_mc_obio.c,v 1.4 1998/01/13 19:24:54 scottr Exp $ */ +/* $OpenBSD: if_mc_obio.c,v 1.5 2004/12/15 06:48:24 martin Exp $ */ +/* $NetBSD: if_mc_obio.c,v 1.13 2004/03/26 12:15:46 wiz Exp $ */ /*- - * Copyright (c) 1997 David Huang <khym@bga.com> + * Copyright (c) 1997 David Huang <khym@azeotrope.org> * All rights reserved. * * Portions of this code are based on code by Denton Gentry <denny1@home.com> @@ -138,9 +138,9 @@ mc_obio_attach(parent, self, aux) } /* allocate memory for transmit buffer and mark it non-cacheable */ - sc->sc_txbuf = malloc(NBPG, M_DEVBUF, M_WAITOK); + sc->sc_txbuf = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK); sc->sc_txbuf_phys = kvtop(sc->sc_txbuf); - physaccess (sc->sc_txbuf, (caddr_t)sc->sc_txbuf_phys, NBPG, + physaccess (sc->sc_txbuf, (caddr_t)sc->sc_txbuf_phys, PAGE_SIZE, PG_V | PG_RW | PG_CI); /* @@ -151,15 +151,15 @@ mc_obio_attach(parent, self, aux) * memory. If it's not, suggest reducing the number of buffers * to 2, which will fit in one 4K page. */ - sc->sc_rxbuf = malloc(MC_NPAGES * NBPG, M_DEVBUF, M_WAITOK); + sc->sc_rxbuf = malloc(MC_NPAGES * PAGE_SIZE, M_DEVBUF, M_WAITOK); sc->sc_rxbuf_phys = kvtop(sc->sc_rxbuf); for (i = 0; i < MC_NPAGES; i++) { int pa; - pa = kvtop(sc->sc_rxbuf + NBPG*i); - physaccess (sc->sc_rxbuf + NBPG*i, (caddr_t)pa, NBPG, + pa = kvtop(sc->sc_rxbuf + PAGE_SIZE*i); + physaccess (sc->sc_rxbuf + PAGE_SIZE*i, (caddr_t)pa, PAGE_SIZE, PG_V | PG_RW | PG_CI); - if (pa != sc->sc_rxbuf_phys + NBPG*i) + if (pa != sc->sc_rxbuf_phys + PAGE_SIZE*i) noncontig = 1; } diff --git a/sys/arch/mac68k/dev/if_mcreg.h b/sys/arch/mac68k/dev/if_mcreg.h index fc9b7c95f72..45d53bab652 100644 --- a/sys/arch/mac68k/dev/if_mcreg.h +++ b/sys/arch/mac68k/dev/if_mcreg.h @@ -1,8 +1,8 @@ -/* $OpenBSD: if_mcreg.h,v 1.1 1998/05/08 22:15:32 gene Exp $ */ -/* $NetBSD: if_mcreg.h,v 1.2 1997/11/07 13:31:18 briggs Exp $ */ +/* $OpenBSD: if_mcreg.h,v 1.2 2004/12/15 06:48:24 martin Exp $ */ +/* NetBSD: if_mcreg.h,v 1.3 2004/03/26 12:15:46 wiz Exp $ */ /*- - * Copyright (c) 1997 David Huang <khym@bga.com> + * Copyright (c) 1997 David Huang <khym@azeotrope.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/arch/mac68k/dev/if_mcvar.h b/sys/arch/mac68k/dev/if_mcvar.h index e4e80459ba8..876e233f43f 100644 --- a/sys/arch/mac68k/dev/if_mcvar.h +++ b/sys/arch/mac68k/dev/if_mcvar.h @@ -1,8 +1,8 @@ -/* $OpenBSD: if_mcvar.h,v 1.3 2002/04/20 00:17:05 miod Exp $ */ -/* $NetBSD: if_mcvar.h,v 1.3 1997/12/07 17:47:48 scottr Exp $ */ +/* $OpenBSD: if_mcvar.h,v 1.4 2004/12/15 06:48:24 martin Exp $ */ +/* $NetBSD: if_mcvar.h,v 1.8 2004/03/26 12:15:46 wiz Exp $ */ /*- - * Copyright (c) 1997 David Huang <khym@bga.com> + * Copyright (c) 1997 David Huang <khym@azeotrope.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ #error Must have at least two buffers for DMA! #endif -#define MC_NPAGES ((MC_RXDMABUFS * 0x800 + NBPG - 1) / NBPG) +#define MC_NPAGES ((MC_RXDMABUFS * 0x800 + PAGE_SIZE - 1) / PAGE_SIZE) struct mc_rxframe { u_int8_t rx_rcvcnt; @@ -82,4 +82,4 @@ int mcsetup(struct mc_softc *, u_int8_t *); void mcintr(void *arg); void mc_rint(struct mc_softc *sc); u_char mc_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, - vm_offset_t o, u_char *dst); + bus_size_t o, u_char *dst); |