if_tl.c (105599) | if_tl.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_tl.c 105599 2002-10-21 02:54:50Z brooks $ | 32 * $FreeBSD: head/sys/pci/if_tl.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 35/* 36 * Texas Instruments ThunderLAN driver for FreeBSD 2.2.6 and 3.x. 37 * Supports many Compaq PCI NICs based on the ThunderLAN ethernet controller, 38 * the National Semiconductor DP83840A physical interface and the 39 * Microchip Technology 24Cxx series serial EEPROM. 40 * --- 179 unchanged lines hidden (view full) --- 220 221MODULE_DEPEND(tl, miibus, 1, 1, 1); 222 223/* "controller miibus0" required. See GENERIC if you get errors here. */ 224#include "miibus_if.h" 225 226#if !defined(lint) 227static const char rcsid[] = | 33 */ 34 35/* 36 * Texas Instruments ThunderLAN driver for FreeBSD 2.2.6 and 3.x. 37 * Supports many Compaq PCI NICs based on the ThunderLAN ethernet controller, 38 * the National Semiconductor DP83840A physical interface and the 39 * Microchip Technology 24Cxx series serial EEPROM. 40 * --- 179 unchanged lines hidden (view full) --- 220 221MODULE_DEPEND(tl, miibus, 1, 1, 1); 222 223/* "controller miibus0" required. See GENERIC if you get errors here. */ 224#include "miibus_if.h" 225 226#if !defined(lint) 227static const char rcsid[] = |
228 "$FreeBSD: head/sys/pci/if_tl.c 105599 2002-10-21 02:54:50Z brooks $"; | 228 "$FreeBSD: head/sys/pci/if_tl.c 106936 2002-11-14 23:49:09Z sam $"; |
229#endif 230 231/* 232 * Various supported device vendors/types and their names. 233 */ 234 235static struct tl_type tl_devs[] = { 236 { TI_VENDORID, TI_DEVICEID_THUNDERLAN, --- 1106 unchanged lines hidden (view full) --- 1343 ifm = &sc->ifmedia; 1344 ifm->ifm_media = ifm->ifm_cur->ifm_media; 1345 tl_ifmedia_upd(ifp); 1346 } 1347 1348 /* 1349 * Call MI attach routine. 1350 */ | 229#endif 230 231/* 232 * Various supported device vendors/types and their names. 233 */ 234 235static struct tl_type tl_devs[] = { 236 { TI_VENDORID, TI_DEVICEID_THUNDERLAN, --- 1106 unchanged lines hidden (view full) --- 1343 ifm = &sc->ifmedia; 1344 ifm->ifm_media = ifm->ifm_cur->ifm_media; 1345 tl_ifmedia_upd(ifp); 1346 } 1347 1348 /* 1349 * Call MI attach routine. 1350 */ |
1351 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 1351 ether_ifattach(ifp, sc->arpcom.ac_enaddr); |
1352 TL_UNLOCK(sc); 1353 return(0); 1354 1355fail: 1356 TL_UNLOCK(sc); 1357 mtx_destroy(&sc->tl_mtx); 1358 return(error); 1359} --- 5 unchanged lines hidden (view full) --- 1365 struct tl_softc *sc; 1366 struct ifnet *ifp; 1367 1368 sc = device_get_softc(dev); 1369 TL_LOCK(sc); 1370 ifp = &sc->arpcom.ac_if; 1371 1372 tl_stop(sc); | 1352 TL_UNLOCK(sc); 1353 return(0); 1354 1355fail: 1356 TL_UNLOCK(sc); 1357 mtx_destroy(&sc->tl_mtx); 1358 return(error); 1359} --- 5 unchanged lines hidden (view full) --- 1365 struct tl_softc *sc; 1366 struct ifnet *ifp; 1367 1368 sc = device_get_softc(dev); 1369 TL_LOCK(sc); 1370 ifp = &sc->arpcom.ac_if; 1371 1372 tl_stop(sc); |
1373 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 1373 ether_ifdetach(ifp); |
1374 1375 bus_generic_detach(dev); 1376 device_delete_child(dev, sc->tl_miibus); 1377 1378 contigfree(sc->tl_ldata, sizeof(struct tl_list_data), M_DEVBUF); 1379 if (sc->tl_bitrate) 1380 ifmedia_removeall(&sc->ifmedia); 1381 --- 156 unchanged lines hidden (view full) --- 1538 continue; 1539 } 1540 1541 sc->tl_cdata.tl_rx_tail->tl_ptr->tlist_fptr = 1542 vtophys(cur_rx->tl_ptr); 1543 sc->tl_cdata.tl_rx_tail->tl_next = cur_rx; 1544 sc->tl_cdata.tl_rx_tail = cur_rx; 1545 | 1374 1375 bus_generic_detach(dev); 1376 device_delete_child(dev, sc->tl_miibus); 1377 1378 contigfree(sc->tl_ldata, sizeof(struct tl_list_data), M_DEVBUF); 1379 if (sc->tl_bitrate) 1380 ifmedia_removeall(&sc->ifmedia); 1381 --- 156 unchanged lines hidden (view full) --- 1538 continue; 1539 } 1540 1541 sc->tl_cdata.tl_rx_tail->tl_ptr->tlist_fptr = 1542 vtophys(cur_rx->tl_ptr); 1543 sc->tl_cdata.tl_rx_tail->tl_next = cur_rx; 1544 sc->tl_cdata.tl_rx_tail = cur_rx; 1545 |
1546 eh = mtod(m, struct ether_header *); 1547 m->m_pkthdr.rcvif = ifp; 1548 | |
1549 /* 1550 * Note: when the ThunderLAN chip is in 'capture all 1551 * frames' mode, it will receive its own transmissions. 1552 * We drop don't need to process our own transmissions, 1553 * so we drop them here and continue. 1554 */ | 1546 /* 1547 * Note: when the ThunderLAN chip is in 'capture all 1548 * frames' mode, it will receive its own transmissions. 1549 * We drop don't need to process our own transmissions, 1550 * so we drop them here and continue. 1551 */ |
1552 eh = mtod(m, struct ether_header *); |
|
1555 /*if (ifp->if_flags & IFF_PROMISC && */ 1556 if (!bcmp(eh->ether_shost, sc->arpcom.ac_enaddr, 1557 ETHER_ADDR_LEN)) { 1558 m_freem(m); 1559 continue; 1560 } 1561 | 1553 /*if (ifp->if_flags & IFF_PROMISC && */ 1554 if (!bcmp(eh->ether_shost, sc->arpcom.ac_enaddr, 1555 ETHER_ADDR_LEN)) { 1556 m_freem(m); 1557 continue; 1558 } 1559 |
1562 /* Remove header from mbuf and pass it on. */ 1563 m->m_pkthdr.len = m->m_len = 1564 total_len - sizeof(struct ether_header); 1565 m->m_data += sizeof(struct ether_header); 1566 ether_input(ifp, eh, m); | 1560 m->m_pkthdr.rcvif = ifp; 1561 m->m_pkthdr.len = m->m_len = total_len; 1562 1563 (*ifp->if_input)(ifp, m); |
1567 } 1568 1569 return(r); 1570} 1571 1572/* 1573 * The RX-EOC condition hits when the ch_parm address hasn't been 1574 * initialized or the adapter reached a list with a forward pointer --- 435 unchanged lines hidden (view full) --- 2010 prev->tl_ptr->tlist_fptr = vtophys(cur_tx->tl_ptr); 2011 } 2012 prev = cur_tx; 2013 2014 /* 2015 * If there's a BPF listener, bounce a copy of this frame 2016 * to him. 2017 */ | 1564 } 1565 1566 return(r); 1567} 1568 1569/* 1570 * The RX-EOC condition hits when the ch_parm address hasn't been 1571 * initialized or the adapter reached a list with a forward pointer --- 435 unchanged lines hidden (view full) --- 2007 prev->tl_ptr->tlist_fptr = vtophys(cur_tx->tl_ptr); 2008 } 2009 prev = cur_tx; 2010 2011 /* 2012 * If there's a BPF listener, bounce a copy of this frame 2013 * to him. 2014 */ |
2018 if (ifp->if_bpf) 2019 bpf_mtap(ifp, cur_tx->tl_mbuf); | 2015 BPF_MTAP(ifp, cur_tx->tl_mbuf); |
2020 } 2021 2022 /* 2023 * If there are no packets queued, bail. 2024 */ 2025 if (cur_tx == NULL) { 2026 TL_UNLOCK(sc); 2027 return; --- 184 unchanged lines hidden (view full) --- 2212{ 2213 struct tl_softc *sc = ifp->if_softc; 2214 struct ifreq *ifr = (struct ifreq *) data; 2215 int s, error = 0; 2216 2217 s = splimp(); 2218 2219 switch(command) { | 2016 } 2017 2018 /* 2019 * If there are no packets queued, bail. 2020 */ 2021 if (cur_tx == NULL) { 2022 TL_UNLOCK(sc); 2023 return; --- 184 unchanged lines hidden (view full) --- 2208{ 2209 struct tl_softc *sc = ifp->if_softc; 2210 struct ifreq *ifr = (struct ifreq *) data; 2211 int s, error = 0; 2212 2213 s = splimp(); 2214 2215 switch(command) { |
2220 case SIOCSIFADDR: 2221 case SIOCGIFADDR: 2222 case SIOCSIFMTU: 2223 error = ether_ioctl(ifp, command, data); 2224 break; | |
2225 case SIOCSIFFLAGS: 2226 if (ifp->if_flags & IFF_UP) { 2227 if (ifp->if_flags & IFF_RUNNING && 2228 ifp->if_flags & IFF_PROMISC && 2229 !(sc->tl_if_flags & IFF_PROMISC)) { 2230 tl_dio_setbit(sc, TL_NETCMD, TL_CMD_CAF); 2231 tl_setmulti(sc); 2232 } else if (ifp->if_flags & IFF_RUNNING && --- 23 unchanged lines hidden (view full) --- 2256 else { 2257 struct mii_data *mii; 2258 mii = device_get_softc(sc->tl_miibus); 2259 error = ifmedia_ioctl(ifp, ifr, 2260 &mii->mii_media, command); 2261 } 2262 break; 2263 default: | 2216 case SIOCSIFFLAGS: 2217 if (ifp->if_flags & IFF_UP) { 2218 if (ifp->if_flags & IFF_RUNNING && 2219 ifp->if_flags & IFF_PROMISC && 2220 !(sc->tl_if_flags & IFF_PROMISC)) { 2221 tl_dio_setbit(sc, TL_NETCMD, TL_CMD_CAF); 2222 tl_setmulti(sc); 2223 } else if (ifp->if_flags & IFF_RUNNING && --- 23 unchanged lines hidden (view full) --- 2247 else { 2248 struct mii_data *mii; 2249 mii = device_get_softc(sc->tl_miibus); 2250 error = ifmedia_ioctl(ifp, ifr, 2251 &mii->mii_media, command); 2252 } 2253 break; 2254 default: |
2264 error = EINVAL; | 2255 error = ether_ioctl(ifp, command, data); |
2265 break; 2266 } 2267 2268 (void)splx(s); 2269 2270 return(error); 2271} 2272 --- 102 unchanged lines hidden --- | 2256 break; 2257 } 2258 2259 (void)splx(s); 2260 2261 return(error); 2262} 2263 --- 102 unchanged lines hidden --- |