if_xl.c (113545) | if_xl.c (113609) |
---|---|
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 --- 87 unchanged lines hidden (view full) --- 96 * support the PCI "boomerang" chips even though they work with the 97 * "vortex" driver in order to obtain better performance. 98 * 99 * This driver is in the /sys/pci directory because it only supports 100 * PCI-based NICs. 101 */ 102 103#include <sys/cdefs.h> | 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 --- 87 unchanged lines hidden (view full) --- 96 * support the PCI "boomerang" chips even though they work with the 97 * "vortex" driver in order to obtain better performance. 98 * 99 * This driver is in the /sys/pci directory because it only supports 100 * PCI-based NICs. 101 */ 102 103#include <sys/cdefs.h> |
104__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 113545 2003-04-16 03:16:57Z mdodd $"); | 104__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 113609 2003-04-17 20:32:06Z njl $"); |
105 106#include <sys/param.h> 107#include <sys/systm.h> 108#include <sys/sockio.h> 109#include <sys/endian.h> 110#include <sys/mbuf.h> 111#include <sys/kernel.h> 112#include <sys/socket.h> --- 1190 unchanged lines hidden (view full) --- 1303 int media = IFM_ETHER|IFM_100_TX|IFM_FDX; 1304 int unit, error = 0, rid, res; 1305 1306 sc = device_get_softc(dev); 1307 unit = device_get_unit(dev); 1308 1309 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 1310 MTX_DEF | MTX_RECURSE); | 105 106#include <sys/param.h> 107#include <sys/systm.h> 108#include <sys/sockio.h> 109#include <sys/endian.h> 110#include <sys/mbuf.h> 111#include <sys/kernel.h> 112#include <sys/socket.h> --- 1190 unchanged lines hidden (view full) --- 1303 int media = IFM_ETHER|IFM_100_TX|IFM_FDX; 1304 int unit, error = 0, rid, res; 1305 1306 sc = device_get_softc(dev); 1307 unit = device_get_unit(dev); 1308 1309 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 1310 MTX_DEF | MTX_RECURSE); |
1311 ifmedia_init(&sc->ifmedia, 0, xl_ifmedia_upd, xl_ifmedia_sts); |
|
1311 1312 sc->xl_flags = 0; 1313 if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_555) 1314 sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_PHYOK; 1315 if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_556 || 1316 pci_get_device(dev) == TC_DEVICEID_HURRICANE_556B) 1317 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | 1318 XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET | --- 301 unchanged lines hidden (view full) --- 1620 * type to something sane. 1621 */ 1622 if (sc->xl_xcvr == XL_XCVR_AUTO) 1623 xl_choose_xcvr(sc, bootverbose); 1624 1625 /* 1626 * Do ifmedia setup. 1627 */ | 1312 1313 sc->xl_flags = 0; 1314 if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_555) 1315 sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_PHYOK; 1316 if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_556 || 1317 pci_get_device(dev) == TC_DEVICEID_HURRICANE_556B) 1318 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | 1319 XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET | --- 301 unchanged lines hidden (view full) --- 1621 * type to something sane. 1622 */ 1623 if (sc->xl_xcvr == XL_XCVR_AUTO) 1624 xl_choose_xcvr(sc, bootverbose); 1625 1626 /* 1627 * Do ifmedia setup. 1628 */ |
1628 1629 ifmedia_init(&sc->ifmedia, 0, xl_ifmedia_upd, xl_ifmedia_sts); 1630 | |
1631 if (sc->xl_media & XL_MEDIAOPT_BT) { 1632 if (bootverbose) 1633 printf("xl%d: found 10baseT\n", sc->xl_unit); 1634 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL); 1635 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL); 1636 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX) 1637 ifmedia_add(&sc->ifmedia, 1638 IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL); --- 82 unchanged lines hidden (view full) --- 1721 CSR_WRITE_2(sc, XL_W0_MFG_ID, XL_NO_XCVR_PWR_MAGICBITS); 1722 } 1723 1724 /* 1725 * Call MI attach routine. 1726 */ 1727 ether_ifattach(ifp, eaddr); 1728 | 1629 if (sc->xl_media & XL_MEDIAOPT_BT) { 1630 if (bootverbose) 1631 printf("xl%d: found 10baseT\n", sc->xl_unit); 1632 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL); 1633 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL); 1634 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX) 1635 ifmedia_add(&sc->ifmedia, 1636 IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL); --- 82 unchanged lines hidden (view full) --- 1719 CSR_WRITE_2(sc, XL_W0_MFG_ID, XL_NO_XCVR_PWR_MAGICBITS); 1720 } 1721 1722 /* 1723 * Call MI attach routine. 1724 */ 1725 ether_ifattach(ifp, eaddr); 1726 |
1727 /* Hook interrupt last to avoid having to lock softc */ |
|
1729 error = bus_setup_intr(dev, sc->xl_irq, INTR_TYPE_NET, 1730 xl_intr, sc, &sc->xl_intrhand); 1731 if (error) { 1732 printf("xl%d: couldn't set up irq\n", unit); | 1728 error = bus_setup_intr(dev, sc->xl_irq, INTR_TYPE_NET, 1729 xl_intr, sc, &sc->xl_intrhand); 1730 if (error) { 1731 printf("xl%d: couldn't set up irq\n", unit); |
1732 ether_ifdetach(ifp); |
|
1733 goto fail; 1734 } 1735 1736fail: 1737 if (error) 1738 xl_detach(dev); 1739 1740 return(error); 1741} 1742 | 1733 goto fail; 1734 } 1735 1736fail: 1737 if (error) 1738 xl_detach(dev); 1739 1740 return(error); 1741} 1742 |
1743/* 1744 * Shutdown hardware and free up resources. This can be called any 1745 * time after the mutex has been initialized. It is called in both 1746 * the error case in attach and the normal detach case so it needs 1747 * to be careful about only freeing resources that have actually been 1748 * allocated. 1749 */ |
|
1743static int 1744xl_detach(dev) 1745 device_t dev; 1746{ 1747 struct xl_softc *sc; 1748 struct ifnet *ifp; 1749 int rid, res; 1750 --- 5 unchanged lines hidden (view full) --- 1756 if (sc->xl_flags & XL_FLAG_USE_MMIO) { 1757 rid = XL_PCI_LOMEM; 1758 res = SYS_RES_MEMORY; 1759 } else { 1760 rid = XL_PCI_LOIO; 1761 res = SYS_RES_IOPORT; 1762 } 1763 | 1750static int 1751xl_detach(dev) 1752 device_t dev; 1753{ 1754 struct xl_softc *sc; 1755 struct ifnet *ifp; 1756 int rid, res; 1757 --- 5 unchanged lines hidden (view full) --- 1763 if (sc->xl_flags & XL_FLAG_USE_MMIO) { 1764 rid = XL_PCI_LOMEM; 1765 res = SYS_RES_MEMORY; 1766 } else { 1767 rid = XL_PCI_LOIO; 1768 res = SYS_RES_IOPORT; 1769 } 1770 |
1771 /* These should only be active if attach succeeded */ |
|
1764 if (device_is_alive(dev)) { | 1772 if (device_is_alive(dev)) { |
1765 if (bus_child_present(dev)) { 1766 xl_reset(sc); 1767 xl_stop(sc); 1768 } | 1773 xl_reset(sc); 1774 xl_stop(sc); |
1769 ether_ifdetach(ifp); | 1775 ether_ifdetach(ifp); |
1770 device_delete_child(dev, sc->xl_miibus); 1771 bus_generic_detach(dev); 1772 ifmedia_removeall(&sc->ifmedia); | |
1773 } | 1776 } |
1777 if (sc->xl_miibus) 1778 device_delete_child(dev, sc->xl_miibus); 1779 bus_generic_detach(dev); 1780 ifmedia_removeall(&sc->ifmedia); |
|
1774 1775 if (sc->xl_intrhand) 1776 bus_teardown_intr(dev, sc->xl_irq, sc->xl_intrhand); 1777 if (sc->xl_irq) 1778 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->xl_irq); 1779 if (sc->xl_fres != NULL) 1780 bus_release_resource(dev, SYS_RES_MEMORY, 1781 XL_PCI_FUNCMEM, sc->xl_fres); --- 1485 unchanged lines hidden --- | 1781 1782 if (sc->xl_intrhand) 1783 bus_teardown_intr(dev, sc->xl_irq, sc->xl_intrhand); 1784 if (sc->xl_irq) 1785 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->xl_irq); 1786 if (sc->xl_fres != NULL) 1787 bus_release_resource(dev, SYS_RES_MEMORY, 1788 XL_PCI_FUNCMEM, sc->xl_fres); --- 1485 unchanged lines hidden --- |