if_sf.c (105221) | if_sf.c (106936) |
---|---|
1/* 2 * Copyright (c) 1997, 1998, 1999 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, 1999 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/sf/if_sf.c 105221 2002-10-16 09:14:59Z phk $ | 32 * $FreeBSD: head/sys/dev/sf/if_sf.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 35/* 36 * Adaptec AIC-6915 "Starfire" PCI fast ethernet driver for FreeBSD. 37 * Programming manual is available from: 38 * ftp.adaptec.com:/pub/BBS/userguides/aic6915_pg.pdf. 39 * 40 * Written by Bill Paul <wpaul@ctr.columbia.edu> --- 75 unchanged lines hidden (view full) --- 116#define SF_USEIOSPACE 117 118#include <pci/if_sfreg.h> 119 120MODULE_DEPEND(sf, miibus, 1, 1, 1); 121 122#ifndef lint 123static const char rcsid[] = | 33 */ 34 35/* 36 * Adaptec AIC-6915 "Starfire" PCI fast ethernet driver for FreeBSD. 37 * Programming manual is available from: 38 * ftp.adaptec.com:/pub/BBS/userguides/aic6915_pg.pdf. 39 * 40 * Written by Bill Paul <wpaul@ctr.columbia.edu> --- 75 unchanged lines hidden (view full) --- 116#define SF_USEIOSPACE 117 118#include <pci/if_sfreg.h> 119 120MODULE_DEPEND(sf, miibus, 1, 1, 1); 121 122#ifndef lint 123static const char rcsid[] = |
124 "$FreeBSD: head/sys/dev/sf/if_sf.c 105221 2002-10-16 09:14:59Z phk $"; | 124 "$FreeBSD: head/sys/dev/sf/if_sf.c 106936 2002-11-14 23:49:09Z sam $"; |
125#endif 126 127static struct sf_type sf_devs[] = { 128 { AD_VENDORID, AD_DEVICEID_STARFIRE, 129 "Adaptec AIC-6915 10/100BaseTX" }, 130 { 0, 0, NULL } 131}; 132 --- 403 unchanged lines hidden (view full) --- 536 struct sf_softc *sc = ifp->if_softc; 537 struct ifreq *ifr = (struct ifreq *) data; 538 struct mii_data *mii; 539 int error = 0; 540 541 SF_LOCK(sc); 542 543 switch(command) { | 125#endif 126 127static struct sf_type sf_devs[] = { 128 { AD_VENDORID, AD_DEVICEID_STARFIRE, 129 "Adaptec AIC-6915 10/100BaseTX" }, 130 { 0, 0, NULL } 131}; 132 --- 403 unchanged lines hidden (view full) --- 536 struct sf_softc *sc = ifp->if_softc; 537 struct ifreq *ifr = (struct ifreq *) data; 538 struct mii_data *mii; 539 int error = 0; 540 541 SF_LOCK(sc); 542 543 switch(command) { |
544 case SIOCSIFADDR: 545 case SIOCGIFADDR: 546 case SIOCSIFMTU: 547 error = ether_ioctl(ifp, command, data); 548 break; | |
549 case SIOCSIFFLAGS: 550 if (ifp->if_flags & IFF_UP) { 551 if (ifp->if_flags & IFF_RUNNING && 552 ifp->if_flags & IFF_PROMISC && 553 !(sc->sf_if_flags & IFF_PROMISC)) { 554 SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC); 555 } else if (ifp->if_flags & IFF_RUNNING && 556 !(ifp->if_flags & IFF_PROMISC) && --- 14 unchanged lines hidden (view full) --- 571 error = 0; 572 break; 573 case SIOCGIFMEDIA: 574 case SIOCSIFMEDIA: 575 mii = device_get_softc(sc->sf_miibus); 576 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 577 break; 578 default: | 544 case SIOCSIFFLAGS: 545 if (ifp->if_flags & IFF_UP) { 546 if (ifp->if_flags & IFF_RUNNING && 547 ifp->if_flags & IFF_PROMISC && 548 !(sc->sf_if_flags & IFF_PROMISC)) { 549 SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC); 550 } else if (ifp->if_flags & IFF_RUNNING && 551 !(ifp->if_flags & IFF_PROMISC) && --- 14 unchanged lines hidden (view full) --- 566 error = 0; 567 break; 568 case SIOCGIFMEDIA: 569 case SIOCSIFMEDIA: 570 mii = device_get_softc(sc->sf_miibus); 571 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 572 break; 573 default: |
579 error = EINVAL; | 574 error = ether_ioctl(ifp, command, data); |
580 break; 581 } 582 583 SF_UNLOCK(sc); 584 585 return(error); 586} 587 --- 241 unchanged lines hidden (view full) --- 829 ifp->if_watchdog = sf_watchdog; 830 ifp->if_init = sf_init; 831 ifp->if_baudrate = 10000000; 832 ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; 833 834 /* 835 * Call MI attach routine. 836 */ | 575 break; 576 } 577 578 SF_UNLOCK(sc); 579 580 return(error); 581} 582 --- 241 unchanged lines hidden (view full) --- 824 ifp->if_watchdog = sf_watchdog; 825 ifp->if_init = sf_init; 826 ifp->if_baudrate = 10000000; 827 ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; 828 829 /* 830 * Call MI attach routine. 831 */ |
837 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 832 ether_ifattach(ifp, sc->arpcom.ac_enaddr); |
838 SF_UNLOCK(sc); 839 return(0); 840 841fail: 842 SF_UNLOCK(sc); 843 mtx_destroy(&sc->sf_mtx); 844 return(error); 845} --- 4 unchanged lines hidden (view full) --- 850{ 851 struct sf_softc *sc; 852 struct ifnet *ifp; 853 854 sc = device_get_softc(dev); 855 SF_LOCK(sc); 856 ifp = &sc->arpcom.ac_if; 857 | 833 SF_UNLOCK(sc); 834 return(0); 835 836fail: 837 SF_UNLOCK(sc); 838 mtx_destroy(&sc->sf_mtx); 839 return(error); 840} --- 4 unchanged lines hidden (view full) --- 845{ 846 struct sf_softc *sc; 847 struct ifnet *ifp; 848 849 sc = device_get_softc(dev); 850 SF_LOCK(sc); 851 ifp = &sc->arpcom.ac_if; 852 |
858 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 853 ether_ifdetach(ifp); |
859 sf_stop(sc); 860 861 bus_generic_detach(dev); 862 device_delete_child(dev, sc->sf_miibus); 863 864 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand); 865 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq); 866 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res); --- 105 unchanged lines hidden (view full) --- 972 * completely unuseable on the Alpha. Our only recourse is to copy received 973 * packets into properly aligned buffers before handing them off. 974 */ 975 976static void 977sf_rxeof(sc) 978 struct sf_softc *sc; 979{ | 854 sf_stop(sc); 855 856 bus_generic_detach(dev); 857 device_delete_child(dev, sc->sf_miibus); 858 859 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand); 860 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq); 861 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res); --- 105 unchanged lines hidden (view full) --- 967 * completely unuseable on the Alpha. Our only recourse is to copy received 968 * packets into properly aligned buffers before handing them off. 969 */ 970 971static void 972sf_rxeof(sc) 973 struct sf_softc *sc; 974{ |
980 struct ether_header *eh; | |
981 struct mbuf *m; 982 struct ifnet *ifp; 983 struct sf_rx_bufdesc_type0 *desc; 984 struct sf_rx_cmpdesc_type3 *cur_rx; 985 u_int32_t rxcons, rxprod; 986 int cmpprodidx, cmpconsidx, bufprodidx; 987 988 ifp = &sc->arpcom.ac_if; --- 23 unchanged lines hidden (view full) --- 1012 ifp, NULL); 1013 sf_newbuf(sc, desc, m); 1014 if (m0 == NULL) { 1015 ifp->if_ierrors++; 1016 continue; 1017 } 1018 m = m0; 1019 | 975 struct mbuf *m; 976 struct ifnet *ifp; 977 struct sf_rx_bufdesc_type0 *desc; 978 struct sf_rx_cmpdesc_type3 *cur_rx; 979 u_int32_t rxcons, rxprod; 980 int cmpprodidx, cmpconsidx, bufprodidx; 981 982 ifp = &sc->arpcom.ac_if; --- 23 unchanged lines hidden (view full) --- 1006 ifp, NULL); 1007 sf_newbuf(sc, desc, m); 1008 if (m0 == NULL) { 1009 ifp->if_ierrors++; 1010 continue; 1011 } 1012 m = m0; 1013 |
1020 eh = mtod(m, struct ether_header *); | |
1021 ifp->if_ipackets++; | 1014 ifp->if_ipackets++; |
1022 1023 /* Remove header from mbuf and pass it on. */ 1024 m_adj(m, sizeof(struct ether_header)); 1025 ether_input(ifp, eh, m); | 1015 (*ifp->if_input)(ifp, m); |
1026 } 1027 1028 csr_write_4(sc, SF_CQ_CONSIDX, 1029 (rxcons & ~SF_CQ_CONSIDX_RXQ1) | cmpconsidx); 1030 csr_write_4(sc, SF_RXDQ_PTR_Q1, 1031 (rxprod & ~SF_RXDQ_PRODIDX) | bufprodidx); 1032 1033 return; --- 365 unchanged lines hidden (view full) --- 1399 cur_tx = NULL; 1400 break; 1401 } 1402 1403 /* 1404 * If there's a BPF listener, bounce a copy of this frame 1405 * to him. 1406 */ | 1016 } 1017 1018 csr_write_4(sc, SF_CQ_CONSIDX, 1019 (rxcons & ~SF_CQ_CONSIDX_RXQ1) | cmpconsidx); 1020 csr_write_4(sc, SF_RXDQ_PTR_Q1, 1021 (rxprod & ~SF_RXDQ_PRODIDX) | bufprodidx); 1022 1023 return; --- 365 unchanged lines hidden (view full) --- 1389 cur_tx = NULL; 1390 break; 1391 } 1392 1393 /* 1394 * If there's a BPF listener, bounce a copy of this frame 1395 * to him. 1396 */ |
1407 if (ifp->if_bpf) 1408 bpf_mtap(ifp, m_head); | 1397 BPF_MTAP(ifp, m_head); |
1409 1410 SF_INC(i, SF_TX_DLIST_CNT); 1411 sc->sf_tx_cnt++; 1412 /* 1413 * Don't get the TX DMA queue get too full. 1414 */ 1415 if (sc->sf_tx_cnt > 64) 1416 break; --- 153 unchanged lines hidden --- | 1398 1399 SF_INC(i, SF_TX_DLIST_CNT); 1400 sc->sf_tx_cnt++; 1401 /* 1402 * Don't get the TX DMA queue get too full. 1403 */ 1404 if (sc->sf_tx_cnt > 64) 1405 break; --- 153 unchanged lines hidden --- |