if_wb.c (105221) | if_wb.c (106936) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * | 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * $FreeBSD: head/sys/pci/if_wb.c 105221 2002-10-16 09:14:59Z phk $ | 32 * $FreeBSD: head/sys/pci/if_wb.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = | 33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = |
131 "$FreeBSD: head/sys/pci/if_wb.c 105221 2002-10-16 09:14:59Z phk $"; | 131 "$FreeBSD: head/sys/pci/if_wb.c 106936 2002-11-14 23:49:09Z sam $"; |
132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 833 unchanged lines hidden (view full) --- 973 free(sc->wb_ldata_ptr, M_DEVBUF); 974 error = ENXIO; 975 goto fail; 976 } 977 978 /* 979 * Call MI attach routine. 980 */ | 132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 833 unchanged lines hidden (view full) --- 973 free(sc->wb_ldata_ptr, M_DEVBUF); 974 error = ENXIO; 975 goto fail; 976 } 977 978 /* 979 * Call MI attach routine. 980 */ |
981 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 981 ether_ifattach(ifp, eaddr); |
982 WB_UNLOCK(sc); 983 return(0); 984 985fail: 986 if (error) 987 device_delete_child(dev, sc->wb_miibus); 988 WB_UNLOCK(sc); 989 mtx_destroy(&sc->wb_mtx); --- 8 unchanged lines hidden (view full) --- 998 struct wb_softc *sc; 999 struct ifnet *ifp; 1000 1001 sc = device_get_softc(dev); 1002 WB_LOCK(sc); 1003 ifp = &sc->arpcom.ac_if; 1004 1005 wb_stop(sc); | 982 WB_UNLOCK(sc); 983 return(0); 984 985fail: 986 if (error) 987 device_delete_child(dev, sc->wb_miibus); 988 WB_UNLOCK(sc); 989 mtx_destroy(&sc->wb_mtx); --- 8 unchanged lines hidden (view full) --- 998 struct wb_softc *sc; 999 struct ifnet *ifp; 1000 1001 sc = device_get_softc(dev); 1002 WB_LOCK(sc); 1003 ifp = &sc->arpcom.ac_if; 1004 1005 wb_stop(sc); |
1006 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 1006 ether_ifdetach(ifp); |
1007 1008 /* Delete any miibus and phy devices attached to this interface */ 1009 bus_generic_detach(dev); 1010 device_delete_child(dev, sc->wb_miibus); 1011 1012 bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand); 1013 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->wb_irq); 1014 bus_release_resource(dev, WB_RES, WB_RID, sc->wb_res); --- 123 unchanged lines hidden (view full) --- 1138/* 1139 * A frame has been uploaded: pass the resulting mbuf chain up to 1140 * the higher level protocols. 1141 */ 1142static void 1143wb_rxeof(sc) 1144 struct wb_softc *sc; 1145{ | 1007 1008 /* Delete any miibus and phy devices attached to this interface */ 1009 bus_generic_detach(dev); 1010 device_delete_child(dev, sc->wb_miibus); 1011 1012 bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand); 1013 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->wb_irq); 1014 bus_release_resource(dev, WB_RES, WB_RID, sc->wb_res); --- 123 unchanged lines hidden (view full) --- 1138/* 1139 * A frame has been uploaded: pass the resulting mbuf chain up to 1140 * the higher level protocols. 1141 */ 1142static void 1143wb_rxeof(sc) 1144 struct wb_softc *sc; 1145{ |
1146 struct ether_header *eh; | |
1147 struct mbuf *m = NULL; 1148 struct ifnet *ifp; 1149 struct wb_chain_onefrag *cur_rx; 1150 int total_len = 0; 1151 u_int32_t rxstat; 1152 1153 ifp = &sc->arpcom.ac_if; 1154 --- 44 unchanged lines hidden (view full) --- 1199 wb_newbuf(sc, cur_rx, m); 1200 if (m0 == NULL) { 1201 ifp->if_ierrors++; 1202 break; 1203 } 1204 m = m0; 1205 1206 ifp->if_ipackets++; | 1146 struct mbuf *m = NULL; 1147 struct ifnet *ifp; 1148 struct wb_chain_onefrag *cur_rx; 1149 int total_len = 0; 1150 u_int32_t rxstat; 1151 1152 ifp = &sc->arpcom.ac_if; 1153 --- 44 unchanged lines hidden (view full) --- 1198 wb_newbuf(sc, cur_rx, m); 1199 if (m0 == NULL) { 1200 ifp->if_ierrors++; 1201 break; 1202 } 1203 m = m0; 1204 1205 ifp->if_ipackets++; |
1207 eh = mtod(m, struct ether_header *); 1208 1209 /* Remove header from mbuf and pass it on. */ 1210 m_adj(m, sizeof(struct ether_header)); 1211 ether_input(ifp, eh, m); | 1206 (*ifp->if_input)(ifp, m); |
1212 } 1213} 1214 1215static void 1216wb_rxeoc(sc) 1217 struct wb_softc *sc; 1218{ 1219 wb_rxeof(sc); --- 336 unchanged lines hidden (view full) --- 1556 1557 if (cur_tx != start_tx) 1558 WB_TXOWN(cur_tx) = WB_TXSTAT_OWN; 1559 1560 /* 1561 * If there's a BPF listener, bounce a copy of this frame 1562 * to him. 1563 */ | 1207 } 1208} 1209 1210static void 1211wb_rxeoc(sc) 1212 struct wb_softc *sc; 1213{ 1214 wb_rxeof(sc); --- 336 unchanged lines hidden (view full) --- 1551 1552 if (cur_tx != start_tx) 1553 WB_TXOWN(cur_tx) = WB_TXSTAT_OWN; 1554 1555 /* 1556 * If there's a BPF listener, bounce a copy of this frame 1557 * to him. 1558 */ |
1564 if (ifp->if_bpf) 1565 bpf_mtap(ifp, cur_tx->wb_mbuf); | 1559 BPF_MTAP(ifp, cur_tx->wb_mbuf); |
1566 } 1567 1568 /* 1569 * If there are no packets queued, bail. 1570 */ 1571 if (cur_tx == NULL) { 1572 WB_UNLOCK(sc); 1573 return; --- 206 unchanged lines hidden (view full) --- 1780 struct wb_softc *sc = ifp->if_softc; 1781 struct mii_data *mii; 1782 struct ifreq *ifr = (struct ifreq *) data; 1783 int error = 0; 1784 1785 WB_LOCK(sc); 1786 1787 switch(command) { | 1560 } 1561 1562 /* 1563 * If there are no packets queued, bail. 1564 */ 1565 if (cur_tx == NULL) { 1566 WB_UNLOCK(sc); 1567 return; --- 206 unchanged lines hidden (view full) --- 1774 struct wb_softc *sc = ifp->if_softc; 1775 struct mii_data *mii; 1776 struct ifreq *ifr = (struct ifreq *) data; 1777 int error = 0; 1778 1779 WB_LOCK(sc); 1780 1781 switch(command) { |
1788 case SIOCSIFADDR: 1789 case SIOCGIFADDR: 1790 case SIOCSIFMTU: 1791 error = ether_ioctl(ifp, command, data); 1792 break; | |
1793 case SIOCSIFFLAGS: 1794 if (ifp->if_flags & IFF_UP) { 1795 wb_init(sc); 1796 } else { 1797 if (ifp->if_flags & IFF_RUNNING) 1798 wb_stop(sc); 1799 } 1800 error = 0; --- 4 unchanged lines hidden (view full) --- 1805 error = 0; 1806 break; 1807 case SIOCGIFMEDIA: 1808 case SIOCSIFMEDIA: 1809 mii = device_get_softc(sc->wb_miibus); 1810 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1811 break; 1812 default: | 1782 case SIOCSIFFLAGS: 1783 if (ifp->if_flags & IFF_UP) { 1784 wb_init(sc); 1785 } else { 1786 if (ifp->if_flags & IFF_RUNNING) 1787 wb_stop(sc); 1788 } 1789 error = 0; --- 4 unchanged lines hidden (view full) --- 1794 error = 0; 1795 break; 1796 case SIOCGIFMEDIA: 1797 case SIOCSIFMEDIA: 1798 mii = device_get_softc(sc->wb_miibus); 1799 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1800 break; 1801 default: |
1813 error = EINVAL; | 1802 error = ether_ioctl(ifp, command, data); |
1814 break; 1815 } 1816 1817 WB_UNLOCK(sc); 1818 1819 return(error); 1820} 1821 --- 95 unchanged lines hidden --- | 1803 break; 1804 } 1805 1806 WB_UNLOCK(sc); 1807 1808 return(error); 1809} 1810 --- 95 unchanged lines hidden --- |