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/ic/elink3.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/ic/elink3.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.126 retrieving revision 1.127 diff -u -p -r1.126 -r1.127 --- src/sys/dev/ic/elink3.c 2008/04/28 20:23:49 1.126 +++ src/sys/dev/ic/elink3.c 2008/08/27 05:33:47 1.127 @@ -1,4 +1,4 @@ -/* $NetBSD: elink3.c,v 1.126 2008/04/28 20:23:49 martin Exp $ */ +/* $NetBSD: elink3.c,v 1.127 2008/08/27 05:33:47 christos Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.126 2008/04/28 20:23:49 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.127 2008/08/27 05:33:47 christos Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -206,9 +206,9 @@ int ep_media_change(struct ifnet *ifp); void ep_media_status(struct ifnet *ifp, struct ifmediareq *req); /* MII callbacks */ -int ep_mii_readreg(struct device *, int, int); -void ep_mii_writereg(struct device *, int, int, int); -void ep_statchg(struct device *); +int ep_mii_readreg(device_t, int, int); +void ep_mii_writereg(device_t, int, int, int); +void ep_statchg(device_t); void ep_tick(void *); @@ -222,8 +222,8 @@ static inline int ep_w1_reg(struct ep_so /* * MII bit-bang glue. */ -u_int32_t ep_mii_bitbang_read(struct device *); -void ep_mii_bitbang_write(struct device *, u_int32_t); +u_int32_t ep_mii_bitbang_read(device_t); +void ep_mii_bitbang_write(device_t, u_int32_t); const struct mii_bitbang_ops ep_mii_bitbang_ops = { ep_mii_bitbang_read, @@ -242,9 +242,7 @@ const struct mii_bitbang_ops ep_mii_bitb * Window 1 registers offset! */ static inline int -ep_w1_reg(sc, reg) - struct ep_softc *sc; - int reg; +ep_w1_reg(struct ep_softc *sc, int reg) { switch (sc->ep_chipset) { @@ -270,9 +268,7 @@ ep_w1_reg(sc, reg) * but older hardware doesn't implement it and we must delay. */ static inline void -ep_finish_reset(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; +ep_finish_reset(bus_space_tag_t iot, bus_space_handle_t ioh) { int i; @@ -289,9 +285,7 @@ ep_finish_reset(iot, ioh) * Used for global reset, TX_RESET, RX_RESET. */ static inline void -ep_reset_cmd(sc, cmd, arg) - struct ep_softc *sc; - u_int cmd, arg; +ep_reset_cmd(struct ep_softc *sc, u_int cmd, u_int arg) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -302,9 +296,7 @@ ep_reset_cmd(sc, cmd, arg) static inline void -ep_discard_rxtop(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; +ep_discard_rxtop(bus_space_tag_t iot, bus_space_handle_t ioh) { int i; @@ -330,10 +322,7 @@ ep_discard_rxtop(iot, ioh) * Back-end attach and configure. */ int -epconfig(sc, chipset, enaddr) - struct ep_softc *sc; - u_short chipset; - u_int8_t *enaddr; +epconfig(struct ep_softc *sc, u_short chipset, u_int8_t *enaddr) { struct ifnet *ifp = &sc->sc_ethercom.ec_if; bus_space_tag_t iot = sc->sc_iot; @@ -393,7 +382,7 @@ epconfig(sc, chipset, enaddr) break; default: - aprint_error_dev(&sc->sc_dev, + aprint_error_dev(sc->sc_dev, "wrote 0x%x to TX_AVAIL_THRESH, read back 0x%x. " "Interface disabled\n", ELINK_LARGEWIN_PROBE, (int) i); @@ -408,7 +397,7 @@ epconfig(sc, chipset, enaddr) bus_space_write_2(iot, ioh, ELINK_COMMAND, SET_TX_AVAIL_THRESH | (1600 >> sc->ep_pktlenshift)); - strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); + strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); ifp->if_softc = sc; ifp->if_start = epstart; ifp->if_ioctl = epioctl; @@ -440,7 +429,7 @@ epconfig(sc, chipset, enaddr) * Display some additional information, if pertinent. */ if (sc->ep_flags & ELINK_FLAGS_USEFIFOBUFFER) - aprint_normal_dev(&sc->sc_dev, "RoadRunner FIFO buffer enabled\n"); + aprint_normal_dev(sc->sc_dev, "RoadRunner FIFO buffer enabled\n"); /* * Initialize our media structures and MII info. We'll @@ -478,7 +467,7 @@ epconfig(sc, chipset, enaddr) * we don't, just treat the Boomerang like the Vortex. */ if (sc->ep_flags & ELINK_FLAGS_MII) { - mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, + mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0); if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { ifmedia_add(&sc->sc_mii.mii_media, @@ -505,7 +494,7 @@ epconfig(sc, chipset, enaddr) GO_WINDOW(1); /* Window 1 is operating window */ #if NRND > 0 - rnd_attach_source(&sc->rnd_source, device_xname(&sc->sc_dev), + rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev), RND_TYPE_NET, 0); #endif @@ -528,8 +517,7 @@ epconfig(sc, chipset, enaddr) * internal-configuration register. */ void -ep_internalconfig(sc) - struct ep_softc *sc; +ep_internalconfig(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -556,7 +544,7 @@ ep_internalconfig(sc) ram_split = (config1 & CONFIG_RAMSPLIT) >> CONFIG_RAMSPLIT_SHIFT; - aprint_normal_dev(&sc->sc_dev, "address %s, %dKB %s-wide FIFO, %s Rx:Tx split\n", + aprint_normal_dev(sc->sc_dev, "address %s, %dKB %s-wide FIFO, %s Rx:Tx split\n", ether_sprintf(CLLADDR(sc->sc_ethercom.ec_if.if_sadl)), 8 << ram_size, (ram_width) ? "word" : "byte", @@ -573,8 +561,7 @@ ep_internalconfig(sc) * default active medium; punt to ifconfig instead. */ void -ep_509_probemedia(sc) - struct ep_softc *sc; +ep_509_probemedia(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -587,7 +574,7 @@ ep_509_probemedia(sc) GO_WINDOW(0); ep_w0_config = bus_space_read_2(iot, ioh, ELINK_W0_CONFIG_CTRL); - aprint_normal_dev(&sc->sc_dev, ""); + aprint_normal_dev(sc->sc_dev, ""); /* Sanity check that there are any media! */ if ((ep_w0_config & ELINK_W0_CC_MEDIAMASK) == 0) { @@ -638,8 +625,7 @@ ep_509_probemedia(sc) * Use media and card-version info in window 3 instead. */ void -ep_vortex_probemedia(sc) - struct ep_softc *sc; +ep_vortex_probemedia(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -659,7 +645,7 @@ ep_vortex_probemedia(sc) default_media = (config1 & CONFIG_MEDIAMASK) >> CONFIG_MEDIAMASK_SHIFT; - aprint_normal_dev(&sc->sc_dev, ""); + aprint_normal_dev(sc->sc_dev, ""); /* Sanity check that there are any media! */ if ((reset_options & ELINK_PCI_MEDIAMASK) == 0) { @@ -710,8 +696,7 @@ ep_vortex_probemedia(sc) * One second timer, used to tick the MII. */ void -ep_tick(arg) - void *arg; +ep_tick(void *arg) { struct ep_softc *sc = arg; int s; @@ -721,7 +706,7 @@ ep_tick(arg) panic("ep_tick"); #endif - if (!device_is_active(&sc->sc_dev)) + if (!device_is_active(sc->sc_dev)) return; s = splnet(); @@ -738,8 +723,7 @@ ep_tick(arg) * interrupts. ?! */ int -epinit(ifp) - struct ifnet *ifp; +epinit(struct ifnet *ifp) { struct ep_softc *sc = ifp->if_softc; bus_space_tag_t iot = sc->sc_iot; @@ -867,8 +851,7 @@ epinit(ifp) * Enable reception of all multicasts and filter in software. */ void -epsetfilter(sc) - struct ep_softc *sc; +epsetfilter(struct ep_softc *sc) { struct ifnet *ifp = &sc->sc_ethercom.ec_if; @@ -880,8 +863,7 @@ epsetfilter(sc) } int -ep_media_change(ifp) - struct ifnet *ifp; +ep_media_change(struct ifnet *ifp) { struct ep_softc *sc = ifp->if_softc; @@ -895,8 +877,7 @@ ep_media_change(ifp) * Reset and enable the MII on the RoadRunner. */ void -ep_roadrunner_mii_enable(sc) - struct ep_softc *sc; +ep_roadrunner_mii_enable(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -919,8 +900,7 @@ ep_roadrunner_mii_enable(sc) * Set the card to use the specified media. */ void -epsetmedia(sc) - struct ep_softc *sc; +epsetmedia(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1005,7 +985,7 @@ epsetmedia(sc) break; case IFM_NONE: - printf("%s: interface disabled\n", device_xname(&sc->sc_dev)); + printf("%s: interface disabled\n", device_xname(sc->sc_dev)); return; default: @@ -1065,9 +1045,7 @@ epsetmedia(sc) * (if_media callback, may be called before interface is brought up). */ void -ep_media_status(ifp, req) - struct ifnet *ifp; - struct ifmediareq *req; +ep_media_status(struct ifnet *ifp, struct ifmediareq *req) { struct ep_softc *sc = ifp->if_softc; bus_space_tag_t iot = sc->sc_iot; @@ -1117,8 +1095,7 @@ ep_media_status(ifp, req) * Always called as splnet(). */ void -epstart(ifp) - struct ifnet *ifp; +epstart(struct ifnet *ifp) { struct ep_softc *sc = ifp->if_softc; bus_space_tag_t iot = sc->sc_iot; @@ -1286,7 +1263,7 @@ readcheck: if (epstatus(sc)) { if (ifp->if_flags & IFF_DEBUG) printf("%s: adapter reset\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); epreset(sc); } } @@ -1303,8 +1280,7 @@ readcheck: * on the cable (once in a blue moon). */ static int -epstatus(sc) - struct ep_softc *sc; +epstatus(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1319,26 +1295,26 @@ epstatus(sc) if (fifost & FIFOS_RX_UNDERRUN) { if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) - printf("%s: RX underrun\n", device_xname(&sc->sc_dev)); + printf("%s: RX underrun\n", device_xname(sc->sc_dev)); epreset(sc); return 0; } if (fifost & FIFOS_RX_STATUS_OVERRUN) { if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) - printf("%s: RX Status overrun\n", device_xname(&sc->sc_dev)); + printf("%s: RX Status overrun\n", device_xname(sc->sc_dev)); return 1; } if (fifost & FIFOS_RX_OVERRUN) { if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) - printf("%s: RX overrun\n", device_xname(&sc->sc_dev)); + printf("%s: RX overrun\n", device_xname(sc->sc_dev)); return 1; } if (fifost & FIFOS_TX_OVERRUN) { if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) - printf("%s: TX overrun\n", device_xname(&sc->sc_dev)); + printf("%s: TX overrun\n", device_xname(sc->sc_dev)); epreset(sc); return 0; } @@ -1348,8 +1324,7 @@ epstatus(sc) static void -eptxstat(sc) - struct ep_softc *sc; +eptxstat(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1368,13 +1343,13 @@ eptxstat(sc) ++sc->sc_ethercom.ec_if.if_oerrors; if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) printf("%s: jabber (%x)\n", - device_xname(&sc->sc_dev), i); + device_xname(sc->sc_dev), i); epreset(sc); } else if (i & TXS_UNDERRUN) { ++sc->sc_ethercom.ec_if.if_oerrors; if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG) printf("%s: fifo underrun (%x) @%d\n", - device_xname(&sc->sc_dev), i, + device_xname(sc->sc_dev), i, sc->tx_start_thresh); if (sc->tx_succ_ok < 100) sc->tx_start_thresh = min(ETHER_MAX_LEN, @@ -1391,8 +1366,7 @@ eptxstat(sc) } int -epintr(arg) - void *arg; +epintr(void *arg) { struct ep_softc *sc = arg; bus_space_tag_t iot = sc->sc_iot; @@ -1401,7 +1375,7 @@ epintr(arg) u_int16_t status; int ret = 0; - if (sc->enabled == 0 || !device_is_active(&sc->sc_dev)) + if (sc->enabled == 0 || !device_is_active(sc->sc_dev)) return (0); @@ -1448,7 +1422,7 @@ epintr(arg) } if (status & CARD_FAILURE) { printf("%s: adapter failure (%x)\n", - device_xname(&sc->sc_dev), status); + device_xname(sc->sc_dev), status); #if 1 epinit(ifp); #else @@ -1472,8 +1446,7 @@ epintr(arg) } void -epread(sc) - struct ep_softc *sc; +epread(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1504,7 +1477,7 @@ again: s = "dribble bits"; if (s) - printf("%s: %s\n", device_xname(&sc->sc_dev), s); + printf("%s: %s\n", device_xname(sc->sc_dev), s); } if (len & ERR_INCOMPLETE) @@ -1560,7 +1533,7 @@ again: if (len & ERR_INCOMPLETE) { if (ifp->if_flags & IFF_DEBUG) printf("%s: adapter reset\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); epreset(sc); return; } @@ -1575,9 +1548,7 @@ abort: } struct mbuf * -epget(sc, totlen) - struct ep_softc *sc; - int totlen; +epget(struct ep_softc *sc, int totlen) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1714,10 +1685,7 @@ epget(sc, totlen) } int -epioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +epioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ep_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; @@ -1759,8 +1727,7 @@ epioctl(ifp, cmd, data) } void -epreset(sc) - struct ep_softc *sc; +epreset(struct ep_softc *sc) { int s; @@ -1770,21 +1737,18 @@ epreset(sc) } void -epwatchdog(ifp) - struct ifnet *ifp; +epwatchdog(struct ifnet *ifp) { struct ep_softc *sc = ifp->if_softc; - log(LOG_ERR, "%s: device timeout\n", device_xname(&sc->sc_dev)); + log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev)); ++sc->sc_ethercom.ec_if.if_oerrors; epreset(sc); } void -epstop(ifp, disable) - struct ifnet *ifp; - int disable; +epstop(struct ifnet *ifp, int disable) { struct ep_softc *sc = ifp->if_softc; bus_space_tag_t iot = sc->sc_iot; @@ -1835,8 +1799,7 @@ epstop(ifp, disable) * Before reboots, reset card completely. */ static void -epshutdown(arg) - void *arg; +epshutdown(void *arg) { struct ep_softc *sc = arg; int s = splnet(); @@ -1867,10 +1830,7 @@ epshutdown(arg) * NOTE: the caller must provide an i/o handle for ELINK_ID_PORT! */ u_int16_t -epreadeeprom(iot, ioh, offset) - bus_space_tag_t iot; - bus_space_handle_t ioh; - int offset; +epreadeeprom(bus_space_tag_t iot, bus_space_handle_t ioh, int offset) { u_int16_t data = 0; int i; @@ -1883,8 +1843,7 @@ epreadeeprom(iot, ioh, offset) } static int -epbusyeeprom(sc) - struct ep_softc *sc; +epbusyeeprom(struct ep_softc *sc) { bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; @@ -1915,22 +1874,20 @@ epbusyeeprom(sc) } if (i == 0) { aprint_normal("\n"); - aprint_error_dev(&sc->sc_dev, "eeprom failed to come ready\n"); + aprint_error_dev(sc->sc_dev, "eeprom failed to come ready\n"); return (1); } if (sc->ep_chipset != ELINK_CHIPSET_CORKSCREW && (j & EEPROM_TST_MODE) != 0) { /* XXX PnP mode? */ - printf("\n%s: erase pencil mark!\n", device_xname(&sc->sc_dev)); + printf("\n%s: erase pencil mark!\n", device_xname(sc->sc_dev)); return (1); } return (0); } u_int16_t -ep_read_eeprom(sc, offset) - struct ep_softc *sc; - u_int16_t offset; +ep_read_eeprom(struct ep_softc *sc, u_int16_t offset) { bus_size_t eecmd, eedata; u_int16_t readcmd; @@ -1964,8 +1921,7 @@ ep_read_eeprom(sc, offset) } void -epmbuffill(v) - void *v; +epmbuffill(void *v) { struct ep_softc *sc = v; struct mbuf *m; @@ -1990,13 +1946,12 @@ epmbuffill(v) } void -epmbufempty(sc) - struct ep_softc *sc; +epmbufempty(struct ep_softc *sc) { int s, i; s = splnet(); - for (i = 0; imb[i]) { m_freem(sc->mb[i]); sc->mb[i] = NULL; @@ -2008,13 +1963,12 @@ epmbufempty(sc) } int -epenable(sc) - struct ep_softc *sc; +epenable(struct ep_softc *sc) { if (sc->enabled == 0 && sc->enable != NULL) { if ((*sc->enable)(sc) != 0) { - aprint_error_dev(&sc->sc_dev, "device enable failed\n"); + aprint_error_dev(sc->sc_dev, "device enable failed\n"); return (EIO); } } @@ -2024,8 +1978,7 @@ epenable(sc) } void -epdisable(sc) - struct ep_softc *sc; +epdisable(struct ep_softc *sc) { if (sc->enabled != 0 && sc->disable != NULL) { @@ -2040,11 +1993,9 @@ epdisable(sc) * Handle device activation/deactivation requests. */ int -ep_activate(self, act) - struct device *self; - enum devact act; +ep_activate(device_t self, enum devact act) { - struct ep_softc *sc = (struct ep_softc *)self; + struct ep_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_ethercom.ec_if; int error = 0, s; @@ -2071,9 +2022,9 @@ ep_activate(self, act) * Detach a elink3 interface. */ int -ep_detach(struct device *self, int flags) +ep_detach(device_t self, int flags) { - struct ep_softc *sc = (struct ep_softc *)self; + struct ep_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_ethercom.ec_if; /* Succeed now if there's no work to do. */ @@ -2105,10 +2056,9 @@ ep_detach(struct device *self, int flags } u_int32_t -ep_mii_bitbang_read(self) - struct device *self; +ep_mii_bitbang_read(device_t self) { - struct ep_softc *sc = (void *) self; + struct ep_softc *sc = device_private(self); /* We're already in Window 4. */ return (bus_space_read_2(sc->sc_iot, sc->sc_ioh, @@ -2116,11 +2066,9 @@ ep_mii_bitbang_read(self) } void -ep_mii_bitbang_write(self, val) - struct device *self; - u_int32_t val; +ep_mii_bitbang_write(device_t self, u_int32_t val) { - struct ep_softc *sc = (void *) self; + struct ep_softc *sc = device_private(self); /* We're already in Window 4. */ bus_space_write_2(sc->sc_iot, sc->sc_ioh, @@ -2128,11 +2076,9 @@ ep_mii_bitbang_write(self, val) } int -ep_mii_readreg(self, phy, reg) - struct device *self; - int phy, reg; +ep_mii_readreg(device_t self, int phy, int reg) { - struct ep_softc *sc = (void *) self; + struct ep_softc *sc = device_private(self); int val; GO_WINDOW(4); @@ -2145,11 +2091,9 @@ ep_mii_readreg(self, phy, reg) } void -ep_mii_writereg(self, phy, reg, val) - struct device *self; - int phy, reg, val; +ep_mii_writereg(device_t self, int phy, int reg, int val) { - struct ep_softc *sc = (void *) self; + struct ep_softc *sc = device_private(self); GO_WINDOW(4); @@ -2159,10 +2103,9 @@ ep_mii_writereg(self, phy, reg, val) } void -ep_statchg(self) - struct device *self; +ep_statchg(device_t self) { - struct ep_softc *sc = (struct ep_softc *)self; + struct ep_softc *sc = device_private(self); bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; int mctl;