Deleted Added
full compact
if_rl.c (162315) if_rl.c (164811)
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>
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/pci/if_rl.c 162315 2006-09-15 10:40:54Z glebius $");
34__FBSDID("$FreeBSD: head/sys/pci/if_rl.c 164811 2006-12-01 21:52:07Z ru $");
35
36/*
37 * RealTek 8129/8139 PCI NIC driver
38 *
39 * Supports several extremely cheap PCI 10/100 adapters based on
40 * the RealTek chipset. Datasheets can be obtained from
41 * www.realtek.com.tw.
42 *

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

210static void rl_setmulti(struct rl_softc *);
211static void rl_shutdown(device_t);
212static void rl_start(struct ifnet *);
213static void rl_start_locked(struct ifnet *);
214static void rl_stop(struct rl_softc *);
215static int rl_suspend(device_t);
216static void rl_tick(void *);
217static void rl_txeof(struct rl_softc *);
35
36/*
37 * RealTek 8129/8139 PCI NIC driver
38 *
39 * Supports several extremely cheap PCI 10/100 adapters based on
40 * the RealTek chipset. Datasheets can be obtained from
41 * www.realtek.com.tw.
42 *

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

210static void rl_setmulti(struct rl_softc *);
211static void rl_shutdown(device_t);
212static void rl_start(struct ifnet *);
213static void rl_start_locked(struct ifnet *);
214static void rl_stop(struct rl_softc *);
215static int rl_suspend(device_t);
216static void rl_tick(void *);
217static void rl_txeof(struct rl_softc *);
218static void rl_watchdog(struct ifnet *);
218static void rl_watchdog(struct rl_softc *);
219
220#ifdef RL_USEIOSPACE
221#define RL_RES SYS_RES_IOPORT
222#define RL_RID RL_PCI_LOIO
223#else
224#define RL_RES SYS_RES_MEMORY
225#define RL_RID RL_PCI_LOMEM
226#endif

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

950 }
951
952 ifp->if_softc = sc;
953 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
954 ifp->if_mtu = ETHERMTU;
955 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
956 ifp->if_ioctl = rl_ioctl;
957 ifp->if_start = rl_start;
219
220#ifdef RL_USEIOSPACE
221#define RL_RES SYS_RES_IOPORT
222#define RL_RID RL_PCI_LOIO
223#else
224#define RL_RES SYS_RES_MEMORY
225#define RL_RID RL_PCI_LOMEM
226#endif

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

950 }
951
952 ifp->if_softc = sc;
953 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
954 ifp->if_mtu = ETHERMTU;
955 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
956 ifp->if_ioctl = rl_ioctl;
957 ifp->if_start = rl_start;
958 ifp->if_watchdog = rl_watchdog;
959 ifp->if_init = rl_init;
960 ifp->if_capabilities = IFCAP_VLAN_MTU;
961 ifp->if_capenable = ifp->if_capabilities;
962#ifdef DEVICE_POLLING
963 ifp->if_capabilities |= IFCAP_POLLING;
964#endif
965 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
966 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;

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

1260 sc->rl_txthresh = oldthresh;
1261 return;
1262 }
1263 RL_INC(sc->rl_cdata.last_tx);
1264 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1265 } while (sc->rl_cdata.last_tx != sc->rl_cdata.cur_tx);
1266
1267 if (RL_LAST_TXMBUF(sc) == NULL)
958 ifp->if_init = rl_init;
959 ifp->if_capabilities = IFCAP_VLAN_MTU;
960 ifp->if_capenable = ifp->if_capabilities;
961#ifdef DEVICE_POLLING
962 ifp->if_capabilities |= IFCAP_POLLING;
963#endif
964 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
965 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;

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

1259 sc->rl_txthresh = oldthresh;
1260 return;
1261 }
1262 RL_INC(sc->rl_cdata.last_tx);
1263 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1264 } while (sc->rl_cdata.last_tx != sc->rl_cdata.cur_tx);
1265
1266 if (RL_LAST_TXMBUF(sc) == NULL)
1268 ifp->if_timer = 0;
1269 else if (ifp->if_timer == 0)
1270 ifp->if_timer = 5;
1267 sc->rl_watchdog_timer = 0;
1268 else if (sc->rl_watchdog_timer == 0)
1269 sc->rl_watchdog_timer = 5;
1271}
1272
1273static void
1274rl_tick(void *xsc)
1275{
1276 struct rl_softc *sc = xsc;
1277 struct mii_data *mii;
1278
1279 RL_LOCK_ASSERT(sc);
1280 mii = device_get_softc(sc->rl_miibus);
1281 mii_tick(mii);
1282
1270}
1271
1272static void
1273rl_tick(void *xsc)
1274{
1275 struct rl_softc *sc = xsc;
1276 struct mii_data *mii;
1277
1278 RL_LOCK_ASSERT(sc);
1279 mii = device_get_softc(sc->rl_miibus);
1280 mii_tick(mii);
1281
1282 rl_watchdog(sc);
1283
1283 callout_reset(&sc->rl_stat_callout, hz, rl_tick, sc);
1284}
1285
1286#ifdef DEVICE_POLLING
1287static void
1288rl_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
1289{
1290 struct rl_softc *sc = ifp->if_softc;

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

1461 BUS_DMASYNC_PREREAD);
1462 CSR_WRITE_4(sc, RL_CUR_TXSTAT(sc),
1463 RL_TXTHRESH(sc->rl_txthresh) |
1464 RL_CUR_TXMBUF(sc)->m_pkthdr.len);
1465
1466 RL_INC(sc->rl_cdata.cur_tx);
1467
1468 /* Set a timeout in case the chip goes out to lunch. */
1284 callout_reset(&sc->rl_stat_callout, hz, rl_tick, sc);
1285}
1286
1287#ifdef DEVICE_POLLING
1288static void
1289rl_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
1290{
1291 struct rl_softc *sc = ifp->if_softc;

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

1462 BUS_DMASYNC_PREREAD);
1463 CSR_WRITE_4(sc, RL_CUR_TXSTAT(sc),
1464 RL_TXTHRESH(sc->rl_txthresh) |
1465 RL_CUR_TXMBUF(sc)->m_pkthdr.len);
1466
1467 RL_INC(sc->rl_cdata.cur_tx);
1468
1469 /* Set a timeout in case the chip goes out to lunch. */
1469 ifp->if_timer = 5;
1470 sc->rl_watchdog_timer = 5;
1470 }
1471
1472 /*
1473 * We broke out of the loop because all our TX slots are
1474 * full. Mark the NIC as busy until it drains some of the
1475 * packets from the queue.
1476 */
1477 if (RL_CUR_TXMBUF(sc) != NULL)

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

1688 error = ether_ioctl(ifp, command, data);
1689 break;
1690 }
1691
1692 return (error);
1693}
1694
1695static void
1471 }
1472
1473 /*
1474 * We broke out of the loop because all our TX slots are
1475 * full. Mark the NIC as busy until it drains some of the
1476 * packets from the queue.
1477 */
1478 if (RL_CUR_TXMBUF(sc) != NULL)

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

1689 error = ether_ioctl(ifp, command, data);
1690 break;
1691 }
1692
1693 return (error);
1694}
1695
1696static void
1696rl_watchdog(struct ifnet *ifp)
1697rl_watchdog(struct rl_softc *sc)
1697{
1698{
1698 struct rl_softc *sc = ifp->if_softc;
1699
1699
1700 RL_LOCK(sc);
1700 RL_LOCK_ASSERT(sc);
1701
1701
1702 if_printf(ifp, "watchdog timeout\n");
1703 ifp->if_oerrors++;
1702 if (sc->rl_watchdog_timer == 0 || --sc->rl_watchdog_timer >0)
1703 return;
1704
1704
1705 device_printf(sc->rl_dev, "watchdog timeout\n");
1706 sc->rl_ifp->if_oerrors++;
1707
1705 rl_txeof(sc);
1706 rl_rxeof(sc);
1707 rl_init_locked(sc);
1708 rl_txeof(sc);
1709 rl_rxeof(sc);
1710 rl_init_locked(sc);
1708
1709 RL_UNLOCK(sc);
1710}
1711
1712/*
1713 * Stop the adapter and free any mbufs allocated to the
1714 * RX and TX lists.
1715 */
1716static void
1717rl_stop(struct rl_softc *sc)
1718{
1719 register int i;
1720 struct ifnet *ifp = sc->rl_ifp;
1721
1722 RL_LOCK_ASSERT(sc);
1723
1711}
1712
1713/*
1714 * Stop the adapter and free any mbufs allocated to the
1715 * RX and TX lists.
1716 */
1717static void
1718rl_stop(struct rl_softc *sc)
1719{
1720 register int i;
1721 struct ifnet *ifp = sc->rl_ifp;
1722
1723 RL_LOCK_ASSERT(sc);
1724
1724 ifp->if_timer = 0;
1725 sc->rl_watchdog_timer = 0;
1725 callout_stop(&sc->rl_stat_callout);
1726 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1727
1728 CSR_WRITE_1(sc, RL_COMMAND, 0x00);
1729 CSR_WRITE_2(sc, RL_IMR, 0x0000);
1730 bus_dmamap_unload(sc->rl_tag, sc->rl_cdata.rl_rx_dmamap);
1731
1732 /*

--- 78 unchanged lines hidden ---
1726 callout_stop(&sc->rl_stat_callout);
1727 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1728
1729 CSR_WRITE_1(sc, RL_COMMAND, 0x00);
1730 CSR_WRITE_2(sc, RL_IMR, 0x0000);
1731 bus_dmamap_unload(sc->rl_tag, sc->rl_cdata.rl_rx_dmamap);
1732
1733 /*

--- 78 unchanged lines hidden ---