Deleted Added
full compact
if_sf.c (111119) if_sf.c (112872)
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 111119 2003-02-19 05:47:46Z imp $
32 * $FreeBSD: head/sys/dev/sf/if_sf.c 112872 2003-03-31 17:29:43Z njl $
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 111119 2003-02-19 05:47:46Z imp $";
124 "$FreeBSD: head/sys/dev/sf/if_sf.c 112872 2003-03-31 17:29:43Z njl $";
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

--- 543 unchanged lines hidden (view full) ---

676 int i;
677 u_int32_t command;
678 struct sf_softc *sc;
679 struct ifnet *ifp;
680 int unit, rid, error = 0;
681
682 sc = device_get_softc(dev);
683 unit = device_get_unit(dev);
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

--- 543 unchanged lines hidden (view full) ---

676 int i;
677 u_int32_t command;
678 struct sf_softc *sc;
679 struct ifnet *ifp;
680 int unit, rid, error = 0;
681
682 sc = device_get_softc(dev);
683 unit = device_get_unit(dev);
684 bzero(sc, sizeof(struct sf_softc));
685
686 mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
687 MTX_DEF | MTX_RECURSE);
684
685 mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
686 MTX_DEF | MTX_RECURSE);
688 SF_LOCK(sc);
687
689 /*
690 * Handle power management nonsense.
691 */
692 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
693 u_int32_t iobase, membase, irq;
694
695 /* Save important PCI config data. */
696 iobase = pci_read_config(dev, SF_PCI_LOIO, 4);

--- 49 unchanged lines hidden (view full) ---

746
747 /* Allocate interrupt */
748 rid = 0;
749 sc->sf_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
750 RF_SHAREABLE | RF_ACTIVE);
751
752 if (sc->sf_irq == NULL) {
753 printf("sf%d: couldn't map interrupt\n", unit);
688 /*
689 * Handle power management nonsense.
690 */
691 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
692 u_int32_t iobase, membase, irq;
693
694 /* Save important PCI config data. */
695 iobase = pci_read_config(dev, SF_PCI_LOIO, 4);

--- 49 unchanged lines hidden (view full) ---

745
746 /* Allocate interrupt */
747 rid = 0;
748 sc->sf_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
749 RF_SHAREABLE | RF_ACTIVE);
750
751 if (sc->sf_irq == NULL) {
752 printf("sf%d: couldn't map interrupt\n", unit);
754 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
755 error = ENXIO;
756 goto fail;
757 }
758
753 error = ENXIO;
754 goto fail;
755 }
756
759 error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET,
760 sf_intr, sc, &sc->sf_intrhand);
761
762 if (error) {
763 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_res);
764 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
765 printf("sf%d: couldn't set up irq\n", unit);
766 goto fail;
767 }
768
769 callout_handle_init(&sc->sf_stat_ch);
770 /* Reset the adapter. */
771 sf_reset(sc);
772
773 /*
774 * Get station address from the EEPROM.
775 */
776 for (i = 0; i < ETHER_ADDR_LEN; i++)

--- 9 unchanged lines hidden (view full) ---

786 sc->sf_unit = unit;
787
788 /* Allocate the descriptor queues. */
789 sc->sf_ldata = contigmalloc(sizeof(struct sf_list_data), M_DEVBUF,
790 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
791
792 if (sc->sf_ldata == NULL) {
793 printf("sf%d: no memory for list buffers!\n", unit);
757 callout_handle_init(&sc->sf_stat_ch);
758 /* Reset the adapter. */
759 sf_reset(sc);
760
761 /*
762 * Get station address from the EEPROM.
763 */
764 for (i = 0; i < ETHER_ADDR_LEN; i++)

--- 9 unchanged lines hidden (view full) ---

774 sc->sf_unit = unit;
775
776 /* Allocate the descriptor queues. */
777 sc->sf_ldata = contigmalloc(sizeof(struct sf_list_data), M_DEVBUF,
778 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
779
780 if (sc->sf_ldata == NULL) {
781 printf("sf%d: no memory for list buffers!\n", unit);
794 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
795 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
796 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
797 error = ENXIO;
798 goto fail;
799 }
800
801 bzero(sc->sf_ldata, sizeof(struct sf_list_data));
802
803 /* Do MII setup. */
804 if (mii_phy_probe(dev, &sc->sf_miibus,
805 sf_ifmedia_upd, sf_ifmedia_sts)) {
806 printf("sf%d: MII without any phy!\n", sc->sf_unit);
782 error = ENXIO;
783 goto fail;
784 }
785
786 bzero(sc->sf_ldata, sizeof(struct sf_list_data));
787
788 /* Do MII setup. */
789 if (mii_phy_probe(dev, &sc->sf_miibus,
790 sf_ifmedia_upd, sf_ifmedia_sts)) {
791 printf("sf%d: MII without any phy!\n", sc->sf_unit);
807 contigfree(sc->sf_ldata,sizeof(struct sf_list_data),M_DEVBUF);
808 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
809 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
810 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
811 error = ENXIO;
812 goto fail;
813 }
814
815 ifp = &sc->arpcom.ac_if;
816 ifp->if_softc = sc;
817 ifp->if_unit = unit;
818 ifp->if_name = "sf";

--- 6 unchanged lines hidden (view full) ---

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 */
832 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
792 error = ENXIO;
793 goto fail;
794 }
795
796 ifp = &sc->arpcom.ac_if;
797 ifp->if_softc = sc;
798 ifp->if_unit = unit;
799 ifp->if_name = "sf";

--- 6 unchanged lines hidden (view full) ---

806 ifp->if_init = sf_init;
807 ifp->if_baudrate = 10000000;
808 ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1;
809
810 /*
811 * Call MI attach routine.
812 */
813 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
833 SF_UNLOCK(sc);
834 return(0);
835
814
815 error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET,
816 sf_intr, sc, &sc->sf_intrhand);
817
818 if (error) {
819 printf("sf%d: couldn't set up irq\n", unit);
820 goto fail;
821 }
822
836fail:
823fail:
837 SF_UNLOCK(sc);
838 mtx_destroy(&sc->sf_mtx);
824 if (error)
825 sf_detach(dev);
826
839 return(error);
840}
841
842static int
843sf_detach(dev)
844 device_t dev;
845{
846 struct sf_softc *sc;
847 struct ifnet *ifp;
848
849 sc = device_get_softc(dev);
827 return(error);
828}
829
830static int
831sf_detach(dev)
832 device_t dev;
833{
834 struct sf_softc *sc;
835 struct ifnet *ifp;
836
837 sc = device_get_softc(dev);
838 KASSERT(mtx_initialized(&sc->sf_mtx), "sf mutex not initialized");
850 SF_LOCK(sc);
851 ifp = &sc->arpcom.ac_if;
852
839 SF_LOCK(sc);
840 ifp = &sc->arpcom.ac_if;
841
853 ether_ifdetach(ifp);
854 sf_stop(sc);
842 if (device_is_alive(dev)) {
843 if (bus_child_present(dev))
844 sf_stop(sc);
845 ether_ifdetach(ifp);
846 device_delete_child(dev, sc->sf_miibus);
847 bus_generic_detach(dev);
848 }
855
849
856 bus_generic_detach(dev);
857 device_delete_child(dev, sc->sf_miibus);
850 if (sc->sf_intrhand)
851 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
852 if (sc->sf_irq)
853 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
854 if (sc->sf_res)
855 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
858
856
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);
857 if (sc->sf_ldata)
858 contigfree(sc->sf_ldata, sizeof(struct sf_list_data), M_DEVBUF);
862
859
863 contigfree(sc->sf_ldata, sizeof(struct sf_list_data), M_DEVBUF);
864
865 SF_UNLOCK(sc);
866 mtx_destroy(&sc->sf_mtx);
867
868 return(0);
869}
870
871static int
872sf_init_rx_ring(sc)

--- 686 unchanged lines hidden ---
860 SF_UNLOCK(sc);
861 mtx_destroy(&sc->sf_mtx);
862
863 return(0);
864}
865
866static int
867sf_init_rx_ring(sc)

--- 686 unchanged lines hidden ---