if_ti.c (113545) | if_ti.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 --- 63 unchanged lines hidden (view full) --- 72 * - Raymond Lee of Netgear, for providing a pair of Netgear 73 * GA620 Tigon 2 boards for testing 74 * - Ulf Zimmermann, for bringing the GA260 to my attention and 75 * convincing me to write this driver. 76 * - Andrew Gallatin for providing FreeBSD/Alpha support. 77 */ 78 79#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 --- 63 unchanged lines hidden (view full) --- 72 * - Raymond Lee of Netgear, for providing a pair of Netgear 73 * GA620 Tigon 2 boards for testing 74 * - Ulf Zimmermann, for bringing the GA260 to my attention and 75 * convincing me to write this driver. 76 * - Andrew Gallatin for providing FreeBSD/Alpha support. 77 */ 78 79#include <sys/cdefs.h> |
80__FBSDID("$FreeBSD: head/sys/dev/ti/if_ti.c 113545 2003-04-16 03:16:57Z mdodd $"); | 80__FBSDID("$FreeBSD: head/sys/dev/ti/if_ti.c 113609 2003-04-17 20:32:06Z njl $"); |
81 82#include "opt_ti.h" 83 84#include <sys/param.h> 85#include <sys/systm.h> 86#include <sys/sockio.h> 87#include <sys/mbuf.h> 88#include <sys/malloc.h> --- 2021 unchanged lines hidden (view full) --- 2110 } 2111#endif 2112 2113 sc = device_get_softc(dev); 2114 unit = device_get_unit(dev); 2115 2116 mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 2117 MTX_DEF | MTX_RECURSE); | 81 82#include "opt_ti.h" 83 84#include <sys/param.h> 85#include <sys/systm.h> 86#include <sys/sockio.h> 87#include <sys/mbuf.h> 88#include <sys/malloc.h> --- 2021 unchanged lines hidden (view full) --- 2110 } 2111#endif 2112 2113 sc = device_get_softc(dev); 2114 unit = device_get_unit(dev); 2115 2116 mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 2117 MTX_DEF | MTX_RECURSE); |
2118 ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts); |
|
2118 sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING; 2119 sc->arpcom.ac_if.if_capenable = sc->arpcom.ac_if.if_capabilities; 2120 2121 /* 2122 * Map control/status registers. 2123 */ 2124 pci_enable_busmaster(dev); 2125 --- 128 unchanged lines hidden (view full) --- 2254 ifp->if_output = ether_output; 2255 ifp->if_start = ti_start; 2256 ifp->if_watchdog = ti_watchdog; 2257 ifp->if_init = ti_init; 2258 ifp->if_mtu = ETHERMTU; 2259 ifp->if_snd.ifq_maxlen = TI_TX_RING_CNT - 1; 2260 2261 /* Set up ifmedia support. */ | 2119 sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING; 2120 sc->arpcom.ac_if.if_capenable = sc->arpcom.ac_if.if_capabilities; 2121 2122 /* 2123 * Map control/status registers. 2124 */ 2125 pci_enable_busmaster(dev); 2126 --- 128 unchanged lines hidden (view full) --- 2255 ifp->if_output = ether_output; 2256 ifp->if_start = ti_start; 2257 ifp->if_watchdog = ti_watchdog; 2258 ifp->if_init = ti_init; 2259 ifp->if_mtu = ETHERMTU; 2260 ifp->if_snd.ifq_maxlen = TI_TX_RING_CNT - 1; 2261 2262 /* Set up ifmedia support. */ |
2262 ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts); | |
2263 if (sc->ti_copper) { 2264 /* 2265 * Copper cards allow manual 10/100 mode selection, 2266 * but not manual 1000baseTX mode selection. Why? 2267 * Becuase currently there's no way to specify the 2268 * master/slave setting through the firmware interface, 2269 * so Alteon decided to just bag it and handle it 2270 * via autonegotiation. --- 34 unchanged lines hidden (view full) --- 2305 sc->dev = make_dev(&ti_cdevsw, sc->ti_unit, UID_ROOT, GID_OPERATOR, 2306 0600, "ti%d", sc->ti_unit); 2307 2308 /* 2309 * Call MI attach routine. 2310 */ 2311 ether_ifattach(ifp, sc->arpcom.ac_enaddr); 2312 | 2263 if (sc->ti_copper) { 2264 /* 2265 * Copper cards allow manual 10/100 mode selection, 2266 * but not manual 1000baseTX mode selection. Why? 2267 * Becuase currently there's no way to specify the 2268 * master/slave setting through the firmware interface, 2269 * so Alteon decided to just bag it and handle it 2270 * via autonegotiation. --- 34 unchanged lines hidden (view full) --- 2305 sc->dev = make_dev(&ti_cdevsw, sc->ti_unit, UID_ROOT, GID_OPERATOR, 2306 0600, "ti%d", sc->ti_unit); 2307 2308 /* 2309 * Call MI attach routine. 2310 */ 2311 ether_ifattach(ifp, sc->arpcom.ac_enaddr); 2312 |
2313 /* Hook interrupt last to avoid having to lock softc */ |
|
2313 error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET, 2314 ti_intr, sc, &sc->ti_intrhand); 2315 2316 if (error) { 2317 printf("ti%d: couldn't set up irq\n", unit); | 2314 error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET, 2315 ti_intr, sc, &sc->ti_intrhand); 2316 2317 if (error) { 2318 printf("ti%d: couldn't set up irq\n", unit); |
2319 ether_ifdetach(ifp); |
|
2318 goto fail; 2319 } 2320 2321fail: 2322 if (sc && error) 2323 ti_detach(dev); 2324 2325 return(error); --- 21 unchanged lines hidden (view full) --- 2347 return count; 2348 } 2349 /* now we know that there's a vnode in the cache. We hunt it 2350 down and kill it now, before unloading */ 2351 vgone(ti_vn); 2352 return(0); 2353} 2354 | 2320 goto fail; 2321 } 2322 2323fail: 2324 if (sc && error) 2325 ti_detach(dev); 2326 2327 return(error); --- 21 unchanged lines hidden (view full) --- 2349 return count; 2350 } 2351 /* now we know that there's a vnode in the cache. We hunt it 2352 down and kill it now, before unloading */ 2353 vgone(ti_vn); 2354 return(0); 2355} 2356 |
2355 | 2357/* 2358 * Shutdown hardware and free up resources. This can be called any 2359 * time after the mutex has been initialized. It is called in both 2360 * the error case in attach and the normal detach case so it needs 2361 * to be careful about only freeing resources that have actually been 2362 * allocated. 2363 */ |
2356static int 2357ti_detach(dev) 2358 device_t dev; 2359{ 2360 struct ti_softc *sc; 2361 struct ifnet *ifp; 2362 2363 if (ti_unref_special(dev)) 2364 return EBUSY; 2365 2366 sc = device_get_softc(dev); 2367 KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized")); 2368 TI_LOCK(sc); 2369 ifp = &sc->arpcom.ac_if; 2370 | 2364static int 2365ti_detach(dev) 2366 device_t dev; 2367{ 2368 struct ti_softc *sc; 2369 struct ifnet *ifp; 2370 2371 if (ti_unref_special(dev)) 2372 return EBUSY; 2373 2374 sc = device_get_softc(dev); 2375 KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized")); 2376 TI_LOCK(sc); 2377 ifp = &sc->arpcom.ac_if; 2378 |
2379 /* These should only be active if attach succeeded */ |
|
2371 if (device_is_alive(dev)) { | 2380 if (device_is_alive(dev)) { |
2372 if (bus_child_present(dev)) 2373 ti_stop(sc); | 2381 ti_stop(sc); |
2374 ether_ifdetach(ifp); 2375 bus_generic_detach(dev); | 2382 ether_ifdetach(ifp); 2383 bus_generic_detach(dev); |
2376 ifmedia_removeall(&sc->ifmedia); | |
2377 } | 2384 } |
2385 ifmedia_removeall(&sc->ifmedia); |
|
2378 2379 if (sc->ti_intrhand) 2380 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 2381 if (sc->ti_irq) 2382 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 2383 if (sc->ti_res) { 2384 bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, 2385 sc->ti_res); --- 1233 unchanged lines hidden --- | 2386 2387 if (sc->ti_intrhand) 2388 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 2389 if (sc->ti_irq) 2390 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 2391 if (sc->ti_res) { 2392 bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, 2393 sc->ti_res); --- 1233 unchanged lines hidden --- |