if_vr.c (105221) | if_vr.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/dev/vr/if_vr.c 105221 2002-10-16 09:14:59Z phk $ | 32 * $FreeBSD: head/sys/dev/vr/if_vr.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 35/* 36 * VIA Rhine fast ethernet PCI NIC driver 37 * 38 * Supports various network adapters based on the VIA Rhine 39 * and Rhine II PCI controllers, including the D-Link DFE530TX. 40 * Datasheets are available at http://www.via.com.tw. --- 55 unchanged lines hidden (view full) --- 96 97MODULE_DEPEND(vr, miibus, 1, 1, 1); 98 99/* "controller miibus0" required. See GENERIC if you get errors here. */ 100#include "miibus_if.h" 101 102#ifndef lint 103static const char rcsid[] = | 33 */ 34 35/* 36 * VIA Rhine fast ethernet PCI NIC driver 37 * 38 * Supports various network adapters based on the VIA Rhine 39 * and Rhine II PCI controllers, including the D-Link DFE530TX. 40 * Datasheets are available at http://www.via.com.tw. --- 55 unchanged lines hidden (view full) --- 96 97MODULE_DEPEND(vr, miibus, 1, 1, 1); 98 99/* "controller miibus0" required. See GENERIC if you get errors here. */ 100#include "miibus_if.h" 101 102#ifndef lint 103static const char rcsid[] = |
104 "$FreeBSD: head/sys/dev/vr/if_vr.c 105221 2002-10-16 09:14:59Z phk $"; | 104 "$FreeBSD: head/sys/dev/vr/if_vr.c 106936 2002-11-14 23:49:09Z sam $"; |
105#endif 106 107/* 108 * Various supported device vendors/types and their names. 109 */ 110static struct vr_type vr_devs[] = { 111 { VIA_VENDORID, VIA_DEVICEID_RHINE, 112 "VIA VT3043 Rhine I 10/100BaseTX" }, --- 697 unchanged lines hidden (view full) --- 810 goto fail; 811 } 812 813 callout_handle_init(&sc->vr_stat_ch); 814 815 /* 816 * Call MI attach routine. 817 */ | 105#endif 106 107/* 108 * Various supported device vendors/types and their names. 109 */ 110static struct vr_type vr_devs[] = { 111 { VIA_VENDORID, VIA_DEVICEID_RHINE, 112 "VIA VT3043 Rhine I 10/100BaseTX" }, --- 697 unchanged lines hidden (view full) --- 810 goto fail; 811 } 812 813 callout_handle_init(&sc->vr_stat_ch); 814 815 /* 816 * Call MI attach routine. 817 */ |
818 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 818 ether_ifattach(ifp, eaddr); |
819 VR_UNLOCK(sc); 820 return(0); 821 822fail: 823 VR_UNLOCK(sc); 824 mtx_destroy(&sc->vr_mtx); 825 826 return(error); --- 6 unchanged lines hidden (view full) --- 833 struct vr_softc *sc; 834 struct ifnet *ifp; 835 836 sc = device_get_softc(dev); 837 VR_LOCK(sc); 838 ifp = &sc->arpcom.ac_if; 839 840 vr_stop(sc); | 819 VR_UNLOCK(sc); 820 return(0); 821 822fail: 823 VR_UNLOCK(sc); 824 mtx_destroy(&sc->vr_mtx); 825 826 return(error); --- 6 unchanged lines hidden (view full) --- 833 struct vr_softc *sc; 834 struct ifnet *ifp; 835 836 sc = device_get_softc(dev); 837 VR_LOCK(sc); 838 ifp = &sc->arpcom.ac_if; 839 840 vr_stop(sc); |
841 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 841 ether_ifdetach(ifp); |
842 843 bus_generic_detach(dev); 844 device_delete_child(dev, sc->vr_miibus); 845 846 bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand); 847 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq); 848 bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res); 849 --- 119 unchanged lines hidden (view full) --- 969/* 970 * A frame has been uploaded: pass the resulting mbuf chain up to 971 * the higher level protocols. 972 */ 973static void 974vr_rxeof(sc) 975 struct vr_softc *sc; 976{ | 842 843 bus_generic_detach(dev); 844 device_delete_child(dev, sc->vr_miibus); 845 846 bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand); 847 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq); 848 bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res); 849 --- 119 unchanged lines hidden (view full) --- 969/* 970 * A frame has been uploaded: pass the resulting mbuf chain up to 971 * the higher level protocols. 972 */ 973static void 974vr_rxeof(sc) 975 struct vr_softc *sc; 976{ |
977 struct ether_header *eh; | |
978 struct mbuf *m; 979 struct ifnet *ifp; 980 struct vr_chain_onefrag *cur_rx; 981 int total_len = 0; 982 u_int32_t rxstat; 983 984 ifp = &sc->arpcom.ac_if; 985 --- 61 unchanged lines hidden (view full) --- 1047 vr_newbuf(sc, cur_rx, m); 1048 if (m0 == NULL) { 1049 ifp->if_ierrors++; 1050 continue; 1051 } 1052 m = m0; 1053 1054 ifp->if_ipackets++; | 977 struct mbuf *m; 978 struct ifnet *ifp; 979 struct vr_chain_onefrag *cur_rx; 980 int total_len = 0; 981 u_int32_t rxstat; 982 983 ifp = &sc->arpcom.ac_if; 984 --- 61 unchanged lines hidden (view full) --- 1046 vr_newbuf(sc, cur_rx, m); 1047 if (m0 == NULL) { 1048 ifp->if_ierrors++; 1049 continue; 1050 } 1051 m = m0; 1052 1053 ifp->if_ipackets++; |
1055 eh = mtod(m, struct ether_header *); 1056 1057 /* Remove header from mbuf and pass it on. */ 1058 m_adj(m, sizeof(struct ether_header)); 1059 ether_input(ifp, eh, m); | 1054 (*ifp->if_input)(ifp, m); |
1060 } 1061 1062 return; 1063} 1064 1065static void 1066vr_rxeoc(sc) 1067 struct vr_softc *sc; --- 317 unchanged lines hidden (view full) --- 1385 1386 if (cur_tx != start_tx) 1387 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; 1388 1389 /* 1390 * If there's a BPF listener, bounce a copy of this frame 1391 * to him. 1392 */ | 1055 } 1056 1057 return; 1058} 1059 1060static void 1061vr_rxeoc(sc) 1062 struct vr_softc *sc; --- 317 unchanged lines hidden (view full) --- 1380 1381 if (cur_tx != start_tx) 1382 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; 1383 1384 /* 1385 * If there's a BPF listener, bounce a copy of this frame 1386 * to him. 1387 */ |
1393 if (ifp->if_bpf) 1394 bpf_mtap(ifp, cur_tx->vr_mbuf); | 1388 BPF_MTAP(ifp, cur_tx->vr_mbuf); |
1395 1396 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; 1397 VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO); 1398 } 1399 1400 /* 1401 * If there are no frames queued, bail. 1402 */ --- 168 unchanged lines hidden (view full) --- 1571 struct vr_softc *sc = ifp->if_softc; 1572 struct ifreq *ifr = (struct ifreq *) data; 1573 struct mii_data *mii; 1574 int error = 0; 1575 1576 VR_LOCK(sc); 1577 1578 switch(command) { | 1389 1390 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; 1391 VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO); 1392 } 1393 1394 /* 1395 * If there are no frames queued, bail. 1396 */ --- 168 unchanged lines hidden (view full) --- 1565 struct vr_softc *sc = ifp->if_softc; 1566 struct ifreq *ifr = (struct ifreq *) data; 1567 struct mii_data *mii; 1568 int error = 0; 1569 1570 VR_LOCK(sc); 1571 1572 switch(command) { |
1579 case SIOCSIFADDR: 1580 case SIOCGIFADDR: 1581 case SIOCSIFMTU: 1582 error = ether_ioctl(ifp, command, data); 1583 break; | |
1584 case SIOCSIFFLAGS: 1585 if (ifp->if_flags & IFF_UP) { 1586 vr_init(sc); 1587 } else { 1588 if (ifp->if_flags & IFF_RUNNING) 1589 vr_stop(sc); 1590 } 1591 error = 0; --- 4 unchanged lines hidden (view full) --- 1596 error = 0; 1597 break; 1598 case SIOCGIFMEDIA: 1599 case SIOCSIFMEDIA: 1600 mii = device_get_softc(sc->vr_miibus); 1601 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1602 break; 1603 default: | 1573 case SIOCSIFFLAGS: 1574 if (ifp->if_flags & IFF_UP) { 1575 vr_init(sc); 1576 } else { 1577 if (ifp->if_flags & IFF_RUNNING) 1578 vr_stop(sc); 1579 } 1580 error = 0; --- 4 unchanged lines hidden (view full) --- 1585 error = 0; 1586 break; 1587 case SIOCGIFMEDIA: 1588 case SIOCSIFMEDIA: 1589 mii = device_get_softc(sc->vr_miibus); 1590 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1591 break; 1592 default: |
1604 error = EINVAL; | 1593 error = ether_ioctl(ifp, command, data); |
1605 break; 1606 } 1607 1608 VR_UNLOCK(sc); 1609 1610 return(error); 1611} 1612 --- 95 unchanged lines hidden --- | 1594 break; 1595 } 1596 1597 VR_UNLOCK(sc); 1598 1599 return(error); 1600} 1601 --- 95 unchanged lines hidden --- |