Deleted Added
sdiff udiff text old ( 199414 ) new ( 199560 )
full compact
1/*-
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/wb/if_wb.c 199560 2009-11-19 22:14:23Z jhb $");
35
36/*
37 * Winbond fast ethernet PCI NIC driver
38 *
39 * Supports various cheap network adapters based on the Winbond W89C840F
40 * fast ethernet controller chip. This includes adapters manufactured by
41 * Winbond itself and some made by Linksys.
42 *

--- 110 unchanged lines hidden (view full) ---

153static void wb_intr(void *);
154static void wb_tick(void *);
155static void wb_start(struct ifnet *);
156static void wb_start_locked(struct ifnet *);
157static int wb_ioctl(struct ifnet *, u_long, caddr_t);
158static void wb_init(void *);
159static void wb_init_locked(struct wb_softc *);
160static void wb_stop(struct wb_softc *);
161static void wb_watchdog(struct wb_softc *);
162static int wb_shutdown(device_t);
163static int wb_ifmedia_upd(struct ifnet *);
164static void wb_ifmedia_sts(struct ifnet *, struct ifmediareq *);
165
166static void wb_eeprom_putbyte(struct wb_softc *, int);
167static void wb_eeprom_getword(struct wb_softc *, int, u_int16_t *);
168static void wb_read_eeprom(struct wb_softc *, caddr_t, int, int, int);
169static void wb_mii_sync(struct wb_softc *);

--- 674 unchanged lines hidden (view full) ---

844 goto fail;
845 }
846 ifp->if_softc = sc;
847 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
848 ifp->if_mtu = ETHERMTU;
849 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
850 ifp->if_ioctl = wb_ioctl;
851 ifp->if_start = wb_start;
852 ifp->if_init = wb_init;
853 ifp->if_snd.ifq_maxlen = WB_TX_LIST_CNT - 1;
854
855 /*
856 * Do MII setup.
857 */
858 if (mii_phy_probe(dev, &sc->wb_miibus,
859 wb_ifmedia_upd, wb_ifmedia_sts)) {

--- 41 unchanged lines hidden (view full) ---

901 KASSERT(mtx_initialized(&sc->wb_mtx), ("wb mutex not initialized"));
902 ifp = sc->wb_ifp;
903
904 /*
905 * Delete any miibus and phy devices attached to this interface.
906 * This should only be done if attach succeeded.
907 */
908 if (device_is_attached(dev)) {
909 ether_ifdetach(ifp);
910 WB_LOCK(sc);
911 wb_stop(sc);
912 WB_UNLOCK(sc);
913 callout_drain(&sc->wb_stat_callout);
914 }
915 if (sc->wb_miibus)
916 device_delete_child(dev, sc->wb_miibus);
917 bus_generic_detach(dev);
918
919 if (sc->wb_intrhand)
920 bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand);
921 if (sc->wb_irq)

--- 229 unchanged lines hidden (view full) ---

1151 struct wb_softc *sc;
1152{
1153 struct wb_chain *cur_tx;
1154 struct ifnet *ifp;
1155
1156 ifp = sc->wb_ifp;
1157
1158 /* Clear the timeout timer. */
1159 sc->wb_timer = 0;
1160
1161 if (sc->wb_cdata.wb_tx_head == NULL)
1162 return;
1163
1164 /*
1165 * Go through our tx list and free mbufs for those
1166 * frames that have been transmitted.
1167 */

--- 38 unchanged lines hidden (view full) ---

1206static void
1207wb_txeoc(sc)
1208 struct wb_softc *sc;
1209{
1210 struct ifnet *ifp;
1211
1212 ifp = sc->wb_ifp;
1213
1214 sc->wb_timer = 0;
1215
1216 if (sc->wb_cdata.wb_tx_head == NULL) {
1217 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1218 sc->wb_cdata.wb_tx_tail = NULL;
1219 } else {
1220 if (WB_TXOWN(sc->wb_cdata.wb_tx_head) == WB_UNSENT) {
1221 WB_TXOWN(sc->wb_cdata.wb_tx_head) = WB_TXSTAT_OWN;
1222 sc->wb_timer = 5;
1223 CSR_WRITE_4(sc, WB_TXSTART, 0xFFFFFFFF);
1224 }
1225 }
1226
1227 return;
1228}
1229
1230static void

--- 92 unchanged lines hidden (view full) ---

1323 struct mii_data *mii;
1324
1325 sc = xsc;
1326 WB_LOCK_ASSERT(sc);
1327 mii = device_get_softc(sc->wb_miibus);
1328
1329 mii_tick(mii);
1330
1331 if (sc->wb_timer > 0 && --sc->wb_timer == 0)
1332 wb_watchdog(sc);
1333 callout_reset(&sc->wb_stat_callout, hz, wb_tick, sc);
1334
1335 return;
1336}
1337
1338/*
1339 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
1340 * pointers to the fragment pointers.

--- 184 unchanged lines hidden (view full) ---

1525 * frames.
1526 */
1527 WB_TXOWN(start_tx) = WB_UNSENT;
1528 }
1529
1530 /*
1531 * Set a timeout in case the chip goes out to lunch.
1532 */
1533 sc->wb_timer = 5;
1534
1535 return;
1536}
1537
1538static void
1539wb_init(xsc)
1540 void *xsc;
1541{

--- 202 unchanged lines hidden (view full) ---

1744 error = ether_ioctl(ifp, command, data);
1745 break;
1746 }
1747
1748 return(error);
1749}
1750
1751static void
1752wb_watchdog(sc)
1753 struct wb_softc *sc;
1754{
1755 struct ifnet *ifp;
1756
1757 WB_LOCK_ASSERT(sc);
1758 ifp = sc->wb_ifp;
1759 ifp->if_oerrors++;
1760 if_printf(ifp, "watchdog timeout\n");
1761#ifdef foo
1762 if (!(wb_phy_readreg(sc, PHY_BMSR) & PHY_BMSR_LINKSTAT))
1763 if_printf(ifp, "no carrier - transceiver cable problem?\n");
1764#endif
1765 wb_stop(sc);
1766 wb_reset(sc);
1767 wb_init_locked(sc);
1768
1769 if (ifp->if_snd.ifq_head != NULL)
1770 wb_start_locked(ifp);
1771
1772 return;
1773}
1774
1775/*
1776 * Stop the adapter and free any mbufs allocated to the
1777 * RX and TX lists.
1778 */
1779static void
1780wb_stop(sc)
1781 struct wb_softc *sc;
1782{
1783 register int i;
1784 struct ifnet *ifp;
1785
1786 WB_LOCK_ASSERT(sc);
1787 ifp = sc->wb_ifp;
1788 sc->wb_timer = 0;
1789
1790 callout_stop(&sc->wb_stat_callout);
1791
1792 WB_CLRBIT(sc, WB_NETCFG, (WB_NETCFG_RX_ON|WB_NETCFG_TX_ON));
1793 CSR_WRITE_4(sc, WB_IMR, 0x00000000);
1794 CSR_WRITE_4(sc, WB_TXADDR, 0x00000000);
1795 CSR_WRITE_4(sc, WB_RXADDR, 0x00000000);
1796

--- 48 unchanged lines hidden ---