if_txp.c (148887) | if_txp.c (149678) |
---|---|
1/* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ 2 3/*- 4 * Copyright (c) 2001 5 * Jason L. Wright <jason@thought.net>, Theo de Raadt, and 6 * Aaron Campbell <aaron@monkey.org>. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> | 1/* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ 2 3/*- 4 * Copyright (c) 2001 5 * Jason L. Wright <jason@thought.net>, Theo de Raadt, and 6 * Aaron Campbell <aaron@monkey.org>. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"); | 38__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 149678 2005-08-31 18:09:54Z jhb $"); |
39 40/* 41 * Driver for 3c990 (Typhoon) Ethernet ASIC 42 */ 43 44#include <sys/cdefs.h> | 39 40/* 41 * Driver for 3c990 (Typhoon) Ethernet ASIC 42 */ 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"); | 45__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 149678 2005-08-31 18:09:54Z jhb $"); |
46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/sockio.h> 50#include <sys/mbuf.h> 51#include <sys/malloc.h> 52#include <sys/kernel.h> 53#include <sys/module.h> --- 33 unchanged lines hidden (view full) --- 87#define TXP_USEIOSPACE 88#define __STRICT_ALIGNMENT 89 90#include <dev/txp/if_txpreg.h> 91#include <dev/txp/3c990img.h> 92 93#ifndef lint 94static const char rcsid[] = | 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/sockio.h> 50#include <sys/mbuf.h> 51#include <sys/malloc.h> 52#include <sys/kernel.h> 53#include <sys/module.h> --- 33 unchanged lines hidden (view full) --- 87#define TXP_USEIOSPACE 88#define __STRICT_ALIGNMENT 89 90#include <dev/txp/if_txpreg.h> 91#include <dev/txp/3c990img.h> 92 93#ifndef lint 94static const char rcsid[] = |
95 "$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"; | 95 "$FreeBSD: head/sys/dev/txp/if_txp.c 149678 2005-08-31 18:09:54Z jhb $"; |
96#endif 97 98/* 99 * Various supported device vendors/types and their names. 100 */ 101static struct txp_type txp_devs[] = { 102 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_TX_95, 103 "3Com 3cR990-TX-95 Etherlink with 3XP Processor" }, --- 5 unchanged lines hidden (view full) --- 109 "3Com 3cR990-SRV-95 Etherlink Server with 3XP Processor" }, 110 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_SRV_97, 111 "3Com 3cR990-SRV-97 Etherlink Server with 3XP Processor" }, 112 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990B_SRV, 113 "3Com 3cR990B-SRV Etherlink Server with 3XP Processor" }, 114 { 0, 0, NULL } 115}; 116 | 96#endif 97 98/* 99 * Various supported device vendors/types and their names. 100 */ 101static struct txp_type txp_devs[] = { 102 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_TX_95, 103 "3Com 3cR990-TX-95 Etherlink with 3XP Processor" }, --- 5 unchanged lines hidden (view full) --- 109 "3Com 3cR990-SRV-95 Etherlink Server with 3XP Processor" }, 110 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_SRV_97, 111 "3Com 3cR990-SRV-97 Etherlink Server with 3XP Processor" }, 112 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990B_SRV, 113 "3Com 3cR990B-SRV Etherlink Server with 3XP Processor" }, 114 { 0, 0, NULL } 115}; 116 |
117static int txp_probe (device_t); 118static int txp_attach (device_t); 119static int txp_detach (device_t); 120static void txp_intr (void *); 121static void txp_tick (void *); 122static int txp_shutdown (device_t); 123static int txp_ioctl (struct ifnet *, u_long, caddr_t); 124static void txp_start (struct ifnet *); 125static void txp_stop (struct txp_softc *); 126static void txp_init (void *); 127static void txp_watchdog (struct ifnet *); | 117static int txp_probe(device_t); 118static int txp_attach(device_t); 119static int txp_detach(device_t); 120static void txp_intr(void *); 121static void txp_tick(void *); 122static int txp_shutdown(device_t); 123static int txp_ioctl(struct ifnet *, u_long, caddr_t); 124static void txp_start(struct ifnet *); 125static void txp_stop(struct txp_softc *); 126static void txp_init(void *); 127static void txp_watchdog(struct ifnet *); |
128 129static void txp_release_resources(struct txp_softc *); 130static int txp_chip_init(struct txp_softc *); 131static int txp_reset_adapter(struct txp_softc *); 132static int txp_download_fw(struct txp_softc *); 133static int txp_download_fw_wait(struct txp_softc *); | 128 129static void txp_release_resources(struct txp_softc *); 130static int txp_chip_init(struct txp_softc *); 131static int txp_reset_adapter(struct txp_softc *); 132static int txp_download_fw(struct txp_softc *); 133static int txp_download_fw_wait(struct txp_softc *); |
134static int txp_download_fw_section (struct txp_softc *, | 134static int txp_download_fw_section(struct txp_softc *, |
135 struct txp_fw_section_header *, int); 136static int txp_alloc_rings(struct txp_softc *); 137static int txp_rxring_fill(struct txp_softc *); 138static void txp_rxring_empty(struct txp_softc *); 139static void txp_set_filter(struct txp_softc *); 140 141static int txp_cmd_desc_numfree(struct txp_softc *); | 135 struct txp_fw_section_header *, int); 136static int txp_alloc_rings(struct txp_softc *); 137static int txp_rxring_fill(struct txp_softc *); 138static void txp_rxring_empty(struct txp_softc *); 139static void txp_set_filter(struct txp_softc *); 140 141static int txp_cmd_desc_numfree(struct txp_softc *); |
142static int txp_command (struct txp_softc *, u_int16_t, u_int16_t, u_int32_t, | 142static int txp_command(struct txp_softc *, u_int16_t, u_int16_t, u_int32_t, |
143 u_int32_t, u_int16_t *, u_int32_t *, u_int32_t *, int); | 143 u_int32_t, u_int16_t *, u_int32_t *, u_int32_t *, int); |
144static int txp_command2 (struct txp_softc *, u_int16_t, u_int16_t, | 144static int txp_command2(struct txp_softc *, u_int16_t, u_int16_t, |
145 u_int32_t, u_int32_t, struct txp_ext_desc *, u_int8_t, 146 struct txp_rsp_desc **, int); | 145 u_int32_t, u_int32_t, struct txp_ext_desc *, u_int8_t, 146 struct txp_rsp_desc **, int); |
147static int txp_response (struct txp_softc *, u_int32_t, u_int16_t, u_int16_t, | 147static int txp_response(struct txp_softc *, u_int32_t, u_int16_t, u_int16_t, |
148 struct txp_rsp_desc **); | 148 struct txp_rsp_desc **); |
149static void txp_rsp_fixup (struct txp_softc *, struct txp_rsp_desc *, | 149static void txp_rsp_fixup(struct txp_softc *, struct txp_rsp_desc *, |
150 struct txp_rsp_desc *); 151static void txp_capabilities(struct txp_softc *); 152 153static void txp_ifmedia_sts(struct ifnet *, struct ifmediareq *); 154static int txp_ifmedia_upd(struct ifnet *); 155#ifdef TXP_DEBUG 156static void txp_show_descriptor(void *); 157#endif --- 88 unchanged lines hidden (view full) --- 246 247 /* Allocate interrupt */ 248 rid = 0; 249 sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 250 RF_SHAREABLE | RF_ACTIVE); 251 252 if (sc->sc_irq == NULL) { 253 device_printf(dev, "couldn't map interrupt\n"); | 150 struct txp_rsp_desc *); 151static void txp_capabilities(struct txp_softc *); 152 153static void txp_ifmedia_sts(struct ifnet *, struct ifmediareq *); 154static int txp_ifmedia_upd(struct ifnet *); 155#ifdef TXP_DEBUG 156static void txp_show_descriptor(void *); 157#endif --- 88 unchanged lines hidden (view full) --- 246 247 /* Allocate interrupt */ 248 rid = 0; 249 sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 250 RF_SHAREABLE | RF_ACTIVE); 251 252 if (sc->sc_irq == NULL) { 253 device_printf(dev, "couldn't map interrupt\n"); |
254 txp_release_resources(sc); | |
255 error = ENXIO; 256 goto fail; 257 } 258 | 254 error = ENXIO; 255 goto fail; 256 } 257 |
259 error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET, 260 txp_intr, sc, &sc->sc_intrhand); 261 262 if (error) { 263 txp_release_resources(sc); 264 device_printf(dev, "couldn't set up irq\n"); 265 goto fail; 266 } 267 | |
268 if (txp_chip_init(sc)) { | 258 if (txp_chip_init(sc)) { |
269 txp_release_resources(sc); 270 /* XXX: set error to ??? */ | 259 error = ENXIO; |
271 goto fail; 272 } 273 274 sc->sc_fwbuf = contigmalloc(32768, M_DEVBUF, 275 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0); 276 error = txp_download_fw(sc); 277 contigfree(sc->sc_fwbuf, 32768, M_DEVBUF); 278 sc->sc_fwbuf = NULL; 279 | 260 goto fail; 261 } 262 263 sc->sc_fwbuf = contigmalloc(32768, M_DEVBUF, 264 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0); 265 error = txp_download_fw(sc); 266 contigfree(sc->sc_fwbuf, 32768, M_DEVBUF); 267 sc->sc_fwbuf = NULL; 268 |
280 if (error) { 281 txp_release_resources(sc); | 269 if (error) |
282 goto fail; | 270 goto fail; |
283 } | |
284 285 sc->sc_ldata = contigmalloc(sizeof(struct txp_ldata), M_DEVBUF, 286 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0); 287 bzero(sc->sc_ldata, sizeof(struct txp_ldata)); 288 289 if (txp_alloc_rings(sc)) { | 271 272 sc->sc_ldata = contigmalloc(sizeof(struct txp_ldata), M_DEVBUF, 273 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0); 274 bzero(sc->sc_ldata, sizeof(struct txp_ldata)); 275 276 if (txp_alloc_rings(sc)) { |
290 txp_release_resources(sc); 291 /* XXX: set error to ??? */ | 277 error = ENXIO; |
292 goto fail; 293 } 294 295 if (txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0, 296 NULL, NULL, NULL, 1)) { | 278 goto fail; 279 } 280 281 if (txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0, 282 NULL, NULL, NULL, 1)) { |
297 txp_release_resources(sc); 298 /* XXX: set error to ??? */ | 283 error = ENXIO; |
299 goto fail; 300 } 301 302 if (txp_command(sc, TXP_CMD_STATION_ADDRESS_READ, 0, 0, 0, 303 &p1, &p2, NULL, 1)) { | 284 goto fail; 285 } 286 287 if (txp_command(sc, TXP_CMD_STATION_ADDRESS_READ, 0, 0, 0, 288 &p1, &p2, NULL, 1)) { |
304 txp_release_resources(sc); 305 /* XXX: set error to ??? */ | 289 error = ENXIO; |
306 goto fail; 307 } 308 309 txp_set_filter(sc); 310 311 eaddr[0] = ((u_int8_t *)&p1)[1]; 312 eaddr[1] = ((u_int8_t *)&p1)[0]; 313 eaddr[2] = ((u_int8_t *)&p2)[3]; --- 14 unchanged lines hidden (view full) --- 328 329 sc->sc_xcvr = TXP_XCVR_AUTO; 330 txp_command(sc, TXP_CMD_XCVR_SELECT, TXP_XCVR_AUTO, 0, 0, 331 NULL, NULL, NULL, 0); 332 ifmedia_set(&sc->sc_ifmedia, IFM_ETHER|IFM_AUTO); 333 334 ifp = sc->sc_ifp = if_alloc(IFT_ETHER); 335 if (ifp == NULL) { | 290 goto fail; 291 } 292 293 txp_set_filter(sc); 294 295 eaddr[0] = ((u_int8_t *)&p1)[1]; 296 eaddr[1] = ((u_int8_t *)&p1)[0]; 297 eaddr[2] = ((u_int8_t *)&p2)[3]; --- 14 unchanged lines hidden (view full) --- 312 313 sc->sc_xcvr = TXP_XCVR_AUTO; 314 txp_command(sc, TXP_CMD_XCVR_SELECT, TXP_XCVR_AUTO, 0, 0, 315 NULL, NULL, NULL, 0); 316 ifmedia_set(&sc->sc_ifmedia, IFM_ETHER|IFM_AUTO); 317 318 ifp = sc->sc_ifp = if_alloc(IFT_ETHER); 319 if (ifp == NULL) { |
336 txp_release_resources(sc); | |
337 device_printf(dev, "couldn't set up irq\n"); 338 error = ENOSPC; 339 goto fail; 340 } 341 ifp->if_softc = sc; 342 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 343 ifp->if_mtu = ETHERMTU; 344 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | --- 7 unchanged lines hidden (view full) --- 352 ifp->if_hwassist = 0; 353 txp_capabilities(sc); 354 355 /* 356 * Attach us everywhere 357 */ 358 ether_ifattach(ifp, eaddr); 359 callout_handle_init(&sc->sc_tick); | 320 device_printf(dev, "couldn't set up irq\n"); 321 error = ENOSPC; 322 goto fail; 323 } 324 ifp->if_softc = sc; 325 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 326 ifp->if_mtu = ETHERMTU; 327 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | --- 7 unchanged lines hidden (view full) --- 335 ifp->if_hwassist = 0; 336 txp_capabilities(sc); 337 338 /* 339 * Attach us everywhere 340 */ 341 ether_ifattach(ifp, eaddr); 342 callout_handle_init(&sc->sc_tick); |
343 344 error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET, 345 txp_intr, sc, &sc->sc_intrhand); 346 347 if (error) { 348 ether_ifdetach(ifp); 349 device_printf(dev, "couldn't set up irq\n"); 350 goto fail; 351 } 352 |
|
360 return(0); 361 362fail: 363 txp_release_resources(sc); 364 mtx_destroy(&sc->sc_mtx); 365 return(error); 366} 367 --- 1519 unchanged lines hidden --- | 353 return(0); 354 355fail: 356 txp_release_resources(sc); 357 mtx_destroy(&sc->sc_mtx); 358 return(error); 359} 360 --- 1519 unchanged lines hidden --- |