Deleted Added
full compact
if_sis.c (113564) if_sis.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

--- 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/pci/if_sis.c 113564 2003-04-16 15:19:55Z jhb $
32 * $FreeBSD: head/sys/pci/if_sis.c 113609 2003-04-17 20:32:06Z njl $
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * This driver also supports the NatSemi DP83815. Datasheets are
40 * available from http://www.national.com.

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

53 * Both chips offer the standard bit-bang MII interface as well as
54 * an enchanced PHY interface which simplifies accessing MII registers.
55 *
56 * The only downside to this chipset is that RX descriptors must be
57 * longword aligned.
58 */
59
60#include <sys/cdefs.h>
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * This driver also supports the NatSemi DP83815. Datasheets are
40 * available from http://www.national.com.

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

53 * Both chips offer the standard bit-bang MII interface as well as
54 * an enchanced PHY interface which simplifies accessing MII registers.
55 *
56 * The only downside to this chipset is that RX descriptors must be
57 * longword aligned.
58 */
59
60#include <sys/cdefs.h>
61__FBSDID("$FreeBSD: head/sys/pci/if_sis.c 113564 2003-04-16 15:19:55Z jhb $");
61__FBSDID("$FreeBSD: head/sys/pci/if_sis.c 113609 2003-04-17 20:32:06Z njl $");
62
63#include <sys/param.h>
64#include <sys/systm.h>
65#include <sys/sockio.h>
66#include <sys/mbuf.h>
67#include <sys/malloc.h>
68#include <sys/kernel.h>
69#include <sys/socket.h>

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

1382 ether_ifattach(ifp, eaddr);
1383
1384 /*
1385 * Tell the upper layer(s) we support long frames.
1386 */
1387 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1388 ifp->if_capabilities |= IFCAP_VLAN_MTU;
1389
62
63#include <sys/param.h>
64#include <sys/systm.h>
65#include <sys/sockio.h>
66#include <sys/mbuf.h>
67#include <sys/malloc.h>
68#include <sys/kernel.h>
69#include <sys/socket.h>

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

1382 ether_ifattach(ifp, eaddr);
1383
1384 /*
1385 * Tell the upper layer(s) we support long frames.
1386 */
1387 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1388 ifp->if_capabilities |= IFCAP_VLAN_MTU;
1389
1390 /* Hook interrupt last to avoid having to lock softc */
1390 error = bus_setup_intr(dev, sc->sis_irq, INTR_TYPE_NET,
1391 sis_intr, sc, &sc->sis_intrhand);
1392
1393 if (error) {
1394 printf("sis%d: couldn't set up irq\n", unit);
1391 error = bus_setup_intr(dev, sc->sis_irq, INTR_TYPE_NET,
1392 sis_intr, sc, &sc->sis_intrhand);
1393
1394 if (error) {
1395 printf("sis%d: couldn't set up irq\n", unit);
1396 ether_ifdetach(ifp);
1395 goto fail;
1396 }
1397
1398fail:
1399 if (error)
1400 sis_detach(dev);
1401
1402 return(error);
1403}
1404
1397 goto fail;
1398 }
1399
1400fail:
1401 if (error)
1402 sis_detach(dev);
1403
1404 return(error);
1405}
1406
1407/*
1408 * Shutdown hardware and free up resources. This can be called any
1409 * time after the mutex has been initialized. It is called in both
1410 * the error case in attach and the normal detach case so it needs
1411 * to be careful about only freeing resources that have actually been
1412 * allocated.
1413 */
1405static int
1406sis_detach(dev)
1407 device_t dev;
1408{
1409 struct sis_softc *sc;
1410 struct ifnet *ifp;
1411
1412 sc = device_get_softc(dev);
1413 KASSERT(mtx_initialized(&sc->sis_mtx), ("sis mutex not initialized"));
1414 SIS_LOCK(sc);
1415 ifp = &sc->arpcom.ac_if;
1416
1414static int
1415sis_detach(dev)
1416 device_t dev;
1417{
1418 struct sis_softc *sc;
1419 struct ifnet *ifp;
1420
1421 sc = device_get_softc(dev);
1422 KASSERT(mtx_initialized(&sc->sis_mtx), ("sis mutex not initialized"));
1423 SIS_LOCK(sc);
1424 ifp = &sc->arpcom.ac_if;
1425
1426 /* These should only be active if attach succeeded */
1417 if (device_is_alive(dev)) {
1427 if (device_is_alive(dev)) {
1418 if (bus_child_present(dev)) {
1419 sis_reset(sc);
1420 sis_stop(sc);
1421 }
1428 sis_reset(sc);
1429 sis_stop(sc);
1422 ether_ifdetach(ifp);
1430 ether_ifdetach(ifp);
1423 device_delete_child(dev, sc->sis_miibus);
1424 bus_generic_detach(dev);
1425 }
1431 }
1432 if (sc->sis_miibus)
1433 device_delete_child(dev, sc->sis_miibus);
1434 bus_generic_detach(dev);
1426
1427 if (sc->sis_intrhand)
1428 bus_teardown_intr(dev, sc->sis_irq, sc->sis_intrhand);
1429 if (sc->sis_irq)
1430 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sis_irq);
1431 if (sc->sis_res)
1432 bus_release_resource(dev, SIS_RES, SIS_RID, sc->sis_res);
1433

--- 955 unchanged lines hidden ---
1435
1436 if (sc->sis_intrhand)
1437 bus_teardown_intr(dev, sc->sis_irq, sc->sis_intrhand);
1438 if (sc->sis_irq)
1439 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sis_irq);
1440 if (sc->sis_res)
1441 bus_release_resource(dev, SIS_RES, SIS_RID, sc->sis_res);
1442

--- 955 unchanged lines hidden ---