if_rl.c (106157) | if_rl.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_rl.c 106157 2002-10-29 19:02:19Z imp $ | 32 * $FreeBSD: head/sys/pci/if_rl.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 35/* 36 * RealTek 8129/8139 PCI NIC driver 37 * 38 * Supports several extremely cheap PCI 10/100 adapters based on 39 * the RealTek chipset. Datasheets can be obtained from 40 * www.realtek.com.tw. --- 85 unchanged lines hidden (view full) --- 126 * uniprocessor systems though. 127 */ 128#define RL_USEIOSPACE 129 130#include <pci/if_rlreg.h> 131 132#ifndef lint 133static const char rcsid[] = | 33 */ 34 35/* 36 * RealTek 8129/8139 PCI NIC driver 37 * 38 * Supports several extremely cheap PCI 10/100 adapters based on 39 * the RealTek chipset. Datasheets can be obtained from 40 * www.realtek.com.tw. --- 85 unchanged lines hidden (view full) --- 126 * uniprocessor systems though. 127 */ 128#define RL_USEIOSPACE 129 130#include <pci/if_rlreg.h> 131 132#ifndef lint 133static const char rcsid[] = |
134 "$FreeBSD: head/sys/pci/if_rl.c 106157 2002-10-29 19:02:19Z imp $"; | 134 "$FreeBSD: head/sys/pci/if_rl.c 106936 2002-11-14 23:49:09Z sam $"; |
135#endif 136 137/* 138 * Various supported device vendors/types and their names. 139 */ 140static struct rl_type rl_devs[] = { 141 { RT_VENDORID, RT_DEVICEID_8129, 142 "RealTek 8129 10/100BaseTX" }, --- 924 unchanged lines hidden (view full) --- 1067 ifp->if_watchdog = rl_watchdog; 1068 ifp->if_init = rl_init; 1069 ifp->if_baudrate = 10000000; 1070 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; 1071 1072 /* 1073 * Call MI attach routine. 1074 */ | 135#endif 136 137/* 138 * Various supported device vendors/types and their names. 139 */ 140static struct rl_type rl_devs[] = { 141 { RT_VENDORID, RT_DEVICEID_8129, 142 "RealTek 8129 10/100BaseTX" }, --- 924 unchanged lines hidden (view full) --- 1067 ifp->if_watchdog = rl_watchdog; 1068 ifp->if_init = rl_init; 1069 ifp->if_baudrate = 10000000; 1070 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; 1071 1072 /* 1073 * Call MI attach routine. 1074 */ |
1075 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 1075 ether_ifattach(ifp, eaddr); |
1076 1077 error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET, 1078 rl_intr, sc, &sc->rl_intrhand); 1079 1080 if (error) { 1081 printf("rl%d: couldn't set up irq\n", unit); 1082 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1083 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); --- 16 unchanged lines hidden (view full) --- 1100{ 1101 struct rl_softc *sc; 1102 struct ifnet *ifp; 1103 1104 sc = device_get_softc(dev); 1105 RL_LOCK(sc); 1106 ifp = &sc->arpcom.ac_if; 1107 | 1076 1077 error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET, 1078 rl_intr, sc, &sc->rl_intrhand); 1079 1080 if (error) { 1081 printf("rl%d: couldn't set up irq\n", unit); 1082 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1083 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); --- 16 unchanged lines hidden (view full) --- 1100{ 1101 struct rl_softc *sc; 1102 struct ifnet *ifp; 1103 1104 sc = device_get_softc(dev); 1105 RL_LOCK(sc); 1106 ifp = &sc->arpcom.ac_if; 1107 |
1108 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 1108 ether_ifdetach(ifp); |
1109 rl_stop(sc); 1110 1111 bus_generic_detach(dev); 1112 device_delete_child(dev, sc->rl_miibus); 1113 1114 bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand); 1115 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1116 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); --- 53 unchanged lines hidden (view full) --- 1170 * Note: to make the Alpha happy, the frame payload needs to be aligned 1171 * on a 32-bit boundary. To achieve this, we pass RL_ETHER_ALIGN (2 bytes) 1172 * as the offset argument to m_devget(). 1173 */ 1174static void 1175rl_rxeof(sc) 1176 struct rl_softc *sc; 1177{ | 1109 rl_stop(sc); 1110 1111 bus_generic_detach(dev); 1112 device_delete_child(dev, sc->rl_miibus); 1113 1114 bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand); 1115 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1116 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); --- 53 unchanged lines hidden (view full) --- 1170 * Note: to make the Alpha happy, the frame payload needs to be aligned 1171 * on a 32-bit boundary. To achieve this, we pass RL_ETHER_ALIGN (2 bytes) 1172 * as the offset argument to m_devget(). 1173 */ 1174static void 1175rl_rxeof(sc) 1176 struct rl_softc *sc; 1177{ |
1178 struct ether_header *eh; | |
1179 struct mbuf *m; 1180 struct ifnet *ifp; 1181 int total_len = 0; 1182 u_int32_t rxstat; 1183 caddr_t rxbufpos; 1184 int wrap = 0; 1185 u_int16_t cur_rx; 1186 u_int16_t limit; --- 93 unchanged lines hidden (view full) --- 1280 * Round up to 32-bit boundary. 1281 */ 1282 cur_rx = (cur_rx + 3) & ~3; 1283 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16); 1284 1285 if (m == NULL) 1286 continue; 1287 | 1178 struct mbuf *m; 1179 struct ifnet *ifp; 1180 int total_len = 0; 1181 u_int32_t rxstat; 1182 caddr_t rxbufpos; 1183 int wrap = 0; 1184 u_int16_t cur_rx; 1185 u_int16_t limit; --- 93 unchanged lines hidden (view full) --- 1279 * Round up to 32-bit boundary. 1280 */ 1281 cur_rx = (cur_rx + 3) & ~3; 1282 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16); 1283 1284 if (m == NULL) 1285 continue; 1286 |
1288 eh = mtod(m, struct ether_header *); | |
1289 ifp->if_ipackets++; | 1287 ifp->if_ipackets++; |
1290 1291 /* Remove header from mbuf and pass it on. */ 1292 m_adj(m, sizeof(struct ether_header)); 1293 ether_input(ifp, eh, m); | 1288 (*ifp->if_input)(ifp, m); |
1294 } 1295 1296 return; 1297} 1298 1299/* 1300 * A frame was downloaded to the chip. It's safe for us to clean up 1301 * the list buffers. --- 257 unchanged lines hidden (view full) --- 1559 ifp->if_flags |= IFF_OACTIVE; 1560 break; 1561 } 1562 1563 /* 1564 * If there's a BPF listener, bounce a copy of this frame 1565 * to him. 1566 */ | 1289 } 1290 1291 return; 1292} 1293 1294/* 1295 * A frame was downloaded to the chip. It's safe for us to clean up 1296 * the list buffers. --- 257 unchanged lines hidden (view full) --- 1554 ifp->if_flags |= IFF_OACTIVE; 1555 break; 1556 } 1557 1558 /* 1559 * If there's a BPF listener, bounce a copy of this frame 1560 * to him. 1561 */ |
1567 if (ifp->if_bpf) 1568 bpf_mtap(ifp, RL_CUR_TXMBUF(sc)); | 1562 BPF_MTAP(ifp, RL_CUR_TXMBUF(sc)); |
1569 1570 /* 1571 * Transmit the frame. 1572 */ 1573 bus_dmamap_create(sc->rl_tag, 0, &RL_CUR_DMAMAP(sc)); 1574 bus_dmamap_load(sc->rl_tag, RL_CUR_DMAMAP(sc), 1575 mtod(RL_CUR_TXMBUF(sc), void *), 1576 RL_CUR_TXMBUF(sc)->m_pkthdr.len, rl_dma_map_txbuf, sc, 0); --- 177 unchanged lines hidden (view full) --- 1754 struct rl_softc *sc = ifp->if_softc; 1755 struct ifreq *ifr = (struct ifreq *) data; 1756 struct mii_data *mii; 1757 int error = 0; 1758 1759 RL_LOCK(sc); 1760 1761 switch(command) { | 1563 1564 /* 1565 * Transmit the frame. 1566 */ 1567 bus_dmamap_create(sc->rl_tag, 0, &RL_CUR_DMAMAP(sc)); 1568 bus_dmamap_load(sc->rl_tag, RL_CUR_DMAMAP(sc), 1569 mtod(RL_CUR_TXMBUF(sc), void *), 1570 RL_CUR_TXMBUF(sc)->m_pkthdr.len, rl_dma_map_txbuf, sc, 0); --- 177 unchanged lines hidden (view full) --- 1748 struct rl_softc *sc = ifp->if_softc; 1749 struct ifreq *ifr = (struct ifreq *) data; 1750 struct mii_data *mii; 1751 int error = 0; 1752 1753 RL_LOCK(sc); 1754 1755 switch(command) { |
1762 case SIOCSIFADDR: 1763 case SIOCGIFADDR: 1764 case SIOCSIFMTU: 1765 error = ether_ioctl(ifp, command, data); 1766 break; | |
1767 case SIOCSIFFLAGS: 1768 if (ifp->if_flags & IFF_UP) { 1769 rl_init(sc); 1770 } else { 1771 if (ifp->if_flags & IFF_RUNNING) 1772 rl_stop(sc); 1773 } 1774 error = 0; --- 4 unchanged lines hidden (view full) --- 1779 error = 0; 1780 break; 1781 case SIOCGIFMEDIA: 1782 case SIOCSIFMEDIA: 1783 mii = device_get_softc(sc->rl_miibus); 1784 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1785 break; 1786 default: | 1756 case SIOCSIFFLAGS: 1757 if (ifp->if_flags & IFF_UP) { 1758 rl_init(sc); 1759 } else { 1760 if (ifp->if_flags & IFF_RUNNING) 1761 rl_stop(sc); 1762 } 1763 error = 0; --- 4 unchanged lines hidden (view full) --- 1768 error = 0; 1769 break; 1770 case SIOCGIFMEDIA: 1771 case SIOCSIFMEDIA: 1772 mii = device_get_softc(sc->rl_miibus); 1773 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1774 break; 1775 default: |
1787 error = EINVAL; | 1776 error = ether_ioctl(ifp, command, data); |
1788 break; 1789 } 1790 1791 RL_UNLOCK(sc); 1792 1793 return(error); 1794} 1795 --- 144 unchanged lines hidden --- | 1777 break; 1778 } 1779 1780 RL_UNLOCK(sc); 1781 1782 return(error); 1783} 1784 --- 144 unchanged lines hidden --- |