Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/isa/if_iy.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/isa/if_iy.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.79 retrieving revision 1.79.4.5 diff -u -p -r1.79 -r1.79.4.5 --- src/sys/dev/isa/if_iy.c 2008/04/08 20:08:50 1.79 +++ src/sys/dev/isa/if_iy.c 2010/08/11 22:53:36 1.79.4.5 @@ -1,4 +1,4 @@ -/* $NetBSD: if_iy.c,v 1.79 2008/04/08 20:08:50 cegger Exp $ */ +/* $NetBSD: if_iy.c,v 1.79.4.5 2010/08/11 22:53:36 yamt Exp $ */ /* #define IYDEBUG */ /* #define IYMEMDEBUG */ @@ -17,13 +17,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -46,10 +39,9 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.79 2008/04/08 20:08:50 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.79.4.5 2010/08/11 22:53:36 yamt Exp $"); #include "opt_inet.h" -#include "bpfilter.h" #include "rnd.h" #include @@ -73,10 +65,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1. #include -#if NBPFILTER > 0 #include #include -#endif #ifdef INET #include @@ -177,8 +167,8 @@ int in_iftint = 0; int iy_mediachange(struct ifnet *); void iy_mediastatus(struct ifnet *, struct ifmediareq *); -int iyprobe(struct device *, struct cfdata *, void *); -void iyattach(struct device *, struct device *, void *); +int iyprobe(device_t, cfdata_t, void *); +void iyattach(device_t, device_t, void *); static u_int16_t eepromread(bus_space_tag_t, bus_space_handle_t, int); @@ -192,8 +182,7 @@ static u_int8_t eepro_irqmap[] = EEPP_IN static u_int8_t eepro_revirqmap[] = EEPP_RINTMAP; int -iyprobe(struct device *parent, struct cfdata *match, - void *aux) +iyprobe(device_t parent, cfdata_t match, void *aux) { struct isa_attach_args *ia = aux; u_int16_t eaddr[8]; @@ -292,7 +281,7 @@ out: } void -iyattach(struct device *parent, struct device *self, void *aux) +iyattach(device_t parent, device_t self, void *aux) { struct iy_softc *sc = (void *)self; struct isa_attach_args *ia = aux; @@ -388,8 +377,7 @@ iyattach(struct device *parent, struct d } void -iystop(sc) -struct iy_softc *sc; +iystop(struct iy_softc *sc) { bus_space_tag_t iot; bus_space_handle_t ioh; @@ -419,19 +407,20 @@ struct iy_softc *sc; bus_space_write_2(iot, ioh, HOST_ADDR_REG, p); v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG)); - bitmask_snprintf(v, "\020\006Ab\010Dn", sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), "\020\006Ab\010Dn", v); printf("0x%04x: %s ", p, sbuf); v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG)); - bitmask_snprintf(v, "\020\6MAX_COL\7HRT_BEAT\010TX_DEF\011UND_RUN\012JERR\013LST_CRS\014LTCOL\016TX_OK\020COLL", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\6MAX_COL\7HRT_BEAT\010TX_DEF\011UND_RUN" + "\012JERR\013LST_CRS\014LTCOL\016TX_OK\020COLL", v); printf("0x%s", sbuf); p = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG)); printf(" 0x%04x", p); v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG)); - bitmask_snprintf(v, "\020\020Ch", sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), "\020\020Ch", v); printf(" 0x%s\n", sbuf); } while (v & 0x8000); @@ -442,8 +431,7 @@ struct iy_softc *sc; } void -iyreset(sc) -struct iy_softc *sc; +iyreset(struct iy_softc *sc) { int s; s = splnet(); @@ -453,8 +441,7 @@ struct iy_softc *sc; } void -iyinit(sc) -struct iy_softc *sc; +iyinit(struct iy_softc *sc) { int i; unsigned temp; @@ -495,8 +482,10 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(temp, "\020\1PRMSC\2NOBRDST\3SEECRC\4LENGTH\5NOSaIns\6MultiIA", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\1PRMSC\2NOBRDST\3SEECRC\4LENGTH\5NOSaIns\6MultiIA", + temp); + printf("%s: RECV_MODES set to %s\n", device_xname(&sc->sc_dev), sbuf); } #endif @@ -513,8 +502,9 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(temp, "\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC", + temp); printf("%s: media select was 0x%s ", device_xname(&sc->sc_dev), sbuf); } #endif @@ -552,8 +542,9 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(temp, "\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC", + temp); printf("changed to 0x%s\n", sbuf); } #endif @@ -569,13 +560,14 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(temp, "\020\4bad_irq\010flash/boot present", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\4bad_irq\010flash/boot present", temp); + printf("%s: int no was %s\n", device_xname(&sc->sc_dev), sbuf); temp = bus_space_read_1(iot, ioh, INT_NO_REG); - bitmask_snprintf(temp, "\020\4bad_irq\010flash/boot present", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\4bad_irq\010flash/boot present", temp); printf("%s: int no now %s\n", device_xname(&sc->sc_dev), sbuf); } #endif @@ -590,8 +582,9 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(temp, "\020\2WORD_WIDTH\010INT_ENABLE", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), "\020\2WORD_WIDTH\010INT_ENABLE", + temp); + printf("%s: HW access is %s\n", device_xname(&sc->sc_dev), sbuf); } #endif @@ -602,8 +595,8 @@ struct iy_softc *sc; char sbuf[128]; temp = bus_space_read_1(iot, ioh, REG1); - bitmask_snprintf(temp, "\020\2WORD_WIDTH\010INT_ENABLE", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), "\020\2WORD_WIDTH\010INT_ENABLE", + temp); printf("%s: HW access is %s\n", device_xname(&sc->sc_dev), sbuf); } #endif @@ -634,8 +627,7 @@ struct iy_softc *sc; } void -iystart(ifp) -struct ifnet *ifp; +iystart(struct ifnet *ifp) { struct iy_softc *sc; @@ -694,10 +686,7 @@ struct ifnet *ifp; continue; } -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m0); -#endif + bpf_mtap(ifp, m0); avail = sc->tx_start - sc->tx_end; if (avail <= 0) @@ -867,10 +856,7 @@ struct ifnet *ifp; static inline void -eepromwritebit(iot, ioh, what) - bus_space_tag_t iot; - bus_space_handle_t ioh; - int what; +eepromwritebit(bus_space_tag_t iot, bus_space_handle_t ioh, int what) { bus_space_write_1(iot, ioh, EEPROM_REG, what); delay(1); @@ -881,9 +867,7 @@ eepromwritebit(iot, ioh, what) } static inline int -eepromreadbit(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; +eepromreadbit(bus_space_tag_t iot, bus_space_handle_t ioh) { int b; @@ -897,10 +881,7 @@ eepromreadbit(iot, ioh) } static u_int16_t -eepromread(iot, ioh, offset) - bus_space_tag_t iot; - bus_space_handle_t ioh; - int offset; +eepromread(bus_space_tag_t iot, bus_space_handle_t ioh, int offset) { volatile int i; volatile int j; @@ -941,8 +922,7 @@ eepromread(iot, ioh, offset) * an interrupt after a transmit has been started on it. */ void -iywatchdog(ifp) - struct ifnet *ifp; +iywatchdog(struct ifnet *ifp) { struct iy_softc *sc = ifp->if_softc; @@ -955,8 +935,7 @@ iywatchdog(ifp) * What to do upon receipt of an interrupt. */ int -iyintr(arg) - void *arg; +iyintr(void *arg) { struct iy_softc *sc; struct ifnet *ifp; @@ -976,13 +955,13 @@ iyintr(arg) if (status & ALL_INTS) { char sbuf[128]; - bitmask_snprintf(status, "\020\1RX_STP\2RX\3TX\4EXEC", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), "\020\1RX_STP\2RX\3TX\4EXEC", + status); printf("%s: got interrupt %s", device_xname(&sc->sc_dev), sbuf); if (status & EXEC_INT) { - bitmask_snprintf(bus_space_read_1(iot, ioh, 0), - "\020\6ABORT", sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\6ABORT", bus_space_read_1(iot, ioh, 0)); printf(" event %s\n", sbuf); } else printf("\n"); @@ -1011,11 +990,7 @@ iyintr(arg) } void -iyget(sc, iot, ioh, rxlen) - struct iy_softc *sc; - bus_space_tag_t iot; - bus_space_handle_t ioh; - int rxlen; +iyget(struct iy_softc *sc, bus_space_tag_t iot, bus_space_handle_t ioh, int rxlen) { struct mbuf *m, *top, **mp; struct ifnet *ifp; @@ -1079,10 +1054,7 @@ iyget(sc, iot, ioh, rxlen) ++ifp->if_ipackets; -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, top); -#endif + bpf_mtap(ifp, top); (*ifp->if_input)(ifp, top); return; @@ -1092,8 +1064,7 @@ dropped: } void -iy_intr_rx(sc) -struct iy_softc *sc; +iy_intr_rx(struct iy_softc *sc) { bus_space_tag_t iot; bus_space_handle_t ioh; @@ -1119,8 +1090,10 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(rxstatus, "\020\1RCLD\2IA_MCH\010SHORT\011OVRN\013ALGERR\014CRCERR\015LENERR\016RCVOK\020TYP", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\1RCLD\2IA_MCH\010SHORT\011OVRN\013ALGERR" + "\014CRCERR\015LENERR\016RCVOK\020TYP", rxstatus); + printf("%s: pck at 0x%04x stat %s next 0x%x len 0x%x\n", device_xname(&sc->sc_dev), rxadrs, sbuf, rxnext, rxlen); } @@ -1140,8 +1113,7 @@ struct iy_softc *sc; } void -iy_intr_tx(sc) -struct iy_softc *sc; +iy_intr_tx(struct iy_softc *sc) { bus_space_tag_t iot; bus_space_handle_t ioh; @@ -1170,8 +1142,11 @@ struct iy_softc *sc; { char sbuf[128]; - bitmask_snprintf(txstat2, "\020\6MAX_COL\7HRT_BEAT\010TX_DEF\011UND_RUN\012JERR\013LST_CRS\014LTCOL\016TX_OK\020COLL", - sbuf, sizeof(sbuf)); + snprintb(sbuf, sizeof(sbuf), + "\020\6MAX_COL\7HRT_BEAT\010TX_DEF" + "\011UND_RUN\012JERR\013LST_CRS" + "\014LTCOL\016TX_OK\020COLL", txstat2); + printf("txstat 0x%x stat2 0x%s next 0x%x len 0x%x\n", txstatus, sbuf, txnext, txlen); } @@ -1193,10 +1168,7 @@ struct iy_softc *sc; } int -iyioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +iyioctl(struct ifnet *ifp, u_long cmd, void *data) { struct iy_softc *sc; struct ifaddr *ifa; @@ -1216,46 +1188,50 @@ iyioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + iyinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - iyinit(sc); arp_ifinit(ifp, ifa); break; #endif default: - iyinit(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; sc->promisc = ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ iystop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ iyinit(sc); - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ iystop(sc); iyinit(sc); + break; } #ifdef IYDEBUGX if (ifp->if_flags & IFF_DEBUG) @@ -1286,15 +1262,14 @@ iyioctl(ifp, cmd, data) error = ifmedia_ioctl(ifp, ifr, &sc->iy_ifmedia, cmd); break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); return error; } int -iy_mediachange(ifp) - struct ifnet *ifp; +iy_mediachange(struct ifnet *ifp) { struct iy_softc *sc = ifp->if_softc; @@ -1314,9 +1289,7 @@ iy_mediachange(ifp) } void -iy_mediastatus(ifp, ifmr) - struct ifnet *ifp; - struct ifmediareq *ifmr; +iy_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) { struct iy_softc *sc = ifp->if_softc; @@ -1326,8 +1299,7 @@ iy_mediastatus(ifp, ifmr) static void -iy_mc_setup(sc) - struct iy_softc *sc; +iy_mc_setup(struct iy_softc *sc) { struct ether_multi *enm; struct ether_multistep step; @@ -1415,8 +1387,7 @@ iy_mc_setup(sc) } static void -iy_mc_reset(sc) - struct iy_softc *sc; +iy_mc_reset(struct iy_softc *sc) { struct ether_multi *enm; struct ether_multistep step; @@ -1481,8 +1452,7 @@ setupmulti: #ifdef IYDEBUGX void -print_rbd(rbd) - volatile struct ie_recv_buf_desc *rbd; +print_rbd(volatile struct ie_recv_buf_desc *rbd) { printf("RBD at %08lx:\nactual %04x, next %04x, buffer %08x\n" "length %04x, mbz %04x\n", (u_long)rbd, rbd->ie_rbd_actual, @@ -1492,8 +1462,7 @@ print_rbd(rbd) #endif void -iyprobemem(sc) - struct iy_softc *sc; +iyprobemem(struct iy_softc *sc) { bus_space_tag_t iot; bus_space_handle_t ioh; @@ -1571,11 +1540,7 @@ iyprobemem(sc) } static int -eepromreadall(iot, ioh, wordp, maxi) - bus_space_tag_t iot; - bus_space_handle_t ioh; - u_int16_t *wordp; - int maxi; +eepromreadall(bus_space_tag_t iot, bus_space_handle_t ioh, u_int16_t *wordp, int maxi) { int i; u_int16_t checksum, tmp;