if_fatm.c (183504) | if_fatm.c (199559) |
---|---|
1/*- 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 * 27 * Author: Hartmut Brandt <harti@freebsd.org> 28 * 29 * Fore PCA200E driver for NATM 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 * 27 * Author: Hartmut Brandt <harti@freebsd.org> 28 * 29 * Fore PCA200E driver for NATM 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/fatm/if_fatm.c 183504 2008-09-30 18:52:43Z marius $"); | 33__FBSDID("$FreeBSD: head/sys/dev/fatm/if_fatm.c 199559 2009-11-19 22:06:40Z jhb $"); |
34 35#include "opt_inet.h" 36#include "opt_natm.h" 37 38#include <sys/types.h> 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 344 unchanged lines hidden (view full) --- 386 sc->stop_cnt = 0; 387 sc->heartbeat = h; 388} 389 390/* 391 * Ensure that the heart is still beating. 392 */ 393static void | 34 35#include "opt_inet.h" 36#include "opt_natm.h" 37 38#include <sys/types.h> 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 344 unchanged lines hidden (view full) --- 386 sc->stop_cnt = 0; 387 sc->heartbeat = h; 388} 389 390/* 391 * Ensure that the heart is still beating. 392 */ 393static void |
394fatm_watchdog(struct ifnet *ifp) | 394fatm_watchdog(void *arg) |
395{ | 395{ |
396 struct fatm_softc *sc = ifp->if_softc; | 396 struct fatm_softc *sc; |
397 | 397 |
398 FATM_LOCK(sc); 399 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 400 fatm_check_heartbeat(sc); 401 ifp->if_timer = 5; 402 } 403 FATM_UNLOCK(sc); | 398 sc = arg; 399 FATM_CHECKLOCK(sc); 400 fatm_check_heartbeat(sc); 401 callout_reset(&sc->watchdog_timer, hz * 5, fatm_watchdog, sc); |
404} 405 406/* 407 * Hard reset the i960 on the board. This is done by initializing registers, 408 * clearing interrupts and waiting for the selftest to finish. Not sure, 409 * whether all these barriers are actually needed. 410 * 411 * Assumes that we hold the lock. --- 57 unchanged lines hidden (view full) --- 469 470 FATM_CHECKLOCK(sc); 471 472 /* Stop the board */ 473 utopia_stop(&sc->utopia); 474 (void)fatm_reset(sc); 475 476 /* stop watchdog */ | 402} 403 404/* 405 * Hard reset the i960 on the board. This is done by initializing registers, 406 * clearing interrupts and waiting for the selftest to finish. Not sure, 407 * whether all these barriers are actually needed. 408 * 409 * Assumes that we hold the lock. --- 57 unchanged lines hidden (view full) --- 467 468 FATM_CHECKLOCK(sc); 469 470 /* Stop the board */ 471 utopia_stop(&sc->utopia); 472 (void)fatm_reset(sc); 473 474 /* stop watchdog */ |
477 sc->ifp->if_timer = 0; | 475 callout_stop(&sc->watchdog_timer); |
478 479 if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) { 480 sc->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 481 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 482 sc->utopia.carrier == UTP_CARR_OK); 483 484 /* 485 * Collect transmit mbufs, partial receive mbufs and --- 850 unchanged lines hidden (view full) --- 1336 /* 1337 * Now set flags, that we are ready 1338 */ 1339 sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; 1340 1341 /* 1342 * Start the watchdog timer 1343 */ | 476 477 if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) { 478 sc->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 479 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 480 sc->utopia.carrier == UTP_CARR_OK); 481 482 /* 483 * Collect transmit mbufs, partial receive mbufs and --- 850 unchanged lines hidden (view full) --- 1334 /* 1335 * Now set flags, that we are ready 1336 */ 1337 sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; 1338 1339 /* 1340 * Start the watchdog timer 1341 */ |
1344 sc->ifp->if_timer = 5; | 1342 callout_reset(&sc->watchdog_timer, hz * 5, fatm_watchdog, sc); |
1345 1346 /* start SUNI */ 1347 utopia_start(&sc->utopia); 1348 1349 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 1350 sc->utopia.carrier == UTP_CARR_OK); 1351 1352 /* start all channels */ --- 1185 unchanged lines hidden (view full) --- 2538 2539 if (device_is_alive(dev)) { 2540 FATM_LOCK(sc); 2541 fatm_stop(sc); 2542 utopia_detach(&sc->utopia); 2543 FATM_UNLOCK(sc); 2544 atm_ifdetach(sc->ifp); /* XXX race */ 2545 } | 1343 1344 /* start SUNI */ 1345 utopia_start(&sc->utopia); 1346 1347 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 1348 sc->utopia.carrier == UTP_CARR_OK); 1349 1350 /* start all channels */ --- 1185 unchanged lines hidden (view full) --- 2536 2537 if (device_is_alive(dev)) { 2538 FATM_LOCK(sc); 2539 fatm_stop(sc); 2540 utopia_detach(&sc->utopia); 2541 FATM_UNLOCK(sc); 2542 atm_ifdetach(sc->ifp); /* XXX race */ 2543 } |
2544 callout_drain(&sc->watchdog_timer); |
|
2546 2547 if (sc->ih != NULL) 2548 bus_teardown_intr(dev, sc->irqres, sc->ih); 2549 2550 while ((rb = LIST_FIRST(&sc->rbuf_used)) != NULL) { 2551 if_printf(sc->ifp, "rbuf %p still in use!\n", rb); 2552 bus_dmamap_unload(sc->rbuf_tag, rb->map); 2553 m_freem(rb->m); --- 225 unchanged lines hidden (view full) --- 2779 */ 2780 mtx_init(&sc->mtx, device_get_nameunit(dev), 2781 MTX_NETWORK_LOCK, MTX_DEF); 2782 2783 cv_init(&sc->cv_stat, "fatm_stat"); 2784 cv_init(&sc->cv_regs, "fatm_regs"); 2785 2786 sysctl_ctx_init(&sc->sysctl_ctx); | 2545 2546 if (sc->ih != NULL) 2547 bus_teardown_intr(dev, sc->irqres, sc->ih); 2548 2549 while ((rb = LIST_FIRST(&sc->rbuf_used)) != NULL) { 2550 if_printf(sc->ifp, "rbuf %p still in use!\n", rb); 2551 bus_dmamap_unload(sc->rbuf_tag, rb->map); 2552 m_freem(rb->m); --- 225 unchanged lines hidden (view full) --- 2778 */ 2779 mtx_init(&sc->mtx, device_get_nameunit(dev), 2780 MTX_NETWORK_LOCK, MTX_DEF); 2781 2782 cv_init(&sc->cv_stat, "fatm_stat"); 2783 cv_init(&sc->cv_regs, "fatm_regs"); 2784 2785 sysctl_ctx_init(&sc->sysctl_ctx); |
2786 callout_init_mtx(&sc->watchdog_timer, &sc->mtx, 0); |
|
2787 2788 /* 2789 * Make the sysctl tree 2790 */ 2791 if ((sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, 2792 SYSCTL_STATIC_CHILDREN(_hw_atm), OID_AUTO, 2793 device_get_nameunit(dev), CTLFLAG_RD, 0, "")) == NULL) 2794 goto fail; --- 24 unchanged lines hidden (view full) --- 2819 /* 2820 * Network subsystem stuff 2821 */ 2822 ifp->if_softc = sc; 2823 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 2824 ifp->if_flags = IFF_SIMPLEX; 2825 ifp->if_ioctl = fatm_ioctl; 2826 ifp->if_start = fatm_start; | 2787 2788 /* 2789 * Make the sysctl tree 2790 */ 2791 if ((sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, 2792 SYSCTL_STATIC_CHILDREN(_hw_atm), OID_AUTO, 2793 device_get_nameunit(dev), CTLFLAG_RD, 0, "")) == NULL) 2794 goto fail; --- 24 unchanged lines hidden (view full) --- 2819 /* 2820 * Network subsystem stuff 2821 */ 2822 ifp->if_softc = sc; 2823 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 2824 ifp->if_flags = IFF_SIMPLEX; 2825 ifp->if_ioctl = fatm_ioctl; 2826 ifp->if_start = fatm_start; |
2827 ifp->if_watchdog = fatm_watchdog; | |
2828 ifp->if_init = fatm_init; 2829 ifp->if_linkmib = &IFP2IFATM(sc->ifp)->mib; 2830 ifp->if_linkmiblen = sizeof(IFP2IFATM(sc->ifp)->mib); 2831 2832 /* 2833 * Enable memory and bustmaster 2834 */ 2835 cfg = pci_read_config(dev, PCIR_COMMAND, 2); --- 264 unchanged lines hidden --- | 2827 ifp->if_init = fatm_init; 2828 ifp->if_linkmib = &IFP2IFATM(sc->ifp)->mib; 2829 ifp->if_linkmiblen = sizeof(IFP2IFATM(sc->ifp)->mib); 2830 2831 /* 2832 * Enable memory and bustmaster 2833 */ 2834 cfg = pci_read_config(dev, PCIR_COMMAND, 2); --- 264 unchanged lines hidden --- |