diff options
-rw-r--r-- | sys/dev/ce/if_ce.c | 70 | ||||
-rw-r--r-- | sys/dev/cp/if_cp.c | 69 | ||||
-rw-r--r-- | sys/dev/ctau/if_ct.c | 70 | ||||
-rw-r--r-- | sys/dev/cx/if_cx.c | 64 |
4 files changed, 100 insertions, 173 deletions
diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c index 2118c3d..f04fd09 100644 --- a/sys/dev/ce/if_ce.c +++ b/sys/dev/ce/if_ce.c @@ -171,11 +171,11 @@ typedef struct _drv_t { node_p node; struct ifqueue queue; struct ifqueue hi_queue; - short timeout; - struct callout timeout_handle; #else struct ifnet *ifp; #endif + short timeout; + struct callout timeout_handle; #if __FreeBSD_version >= 500000 struct cdev *devt; #else /* __FreeBSD_version < 500000 */ @@ -211,13 +211,13 @@ static void ce_up (drv_t *d); static void ce_start (drv_t *d); static void ce_down (drv_t *d); static void ce_watchdog (drv_t *d); +static void ce_watchdog_timer (void *arg); #ifdef NETGRAPH extern struct ng_type typestruct; #else static void ce_ifstart (struct ifnet *ifp); static void ce_tlf (struct sppp *sp); static void ce_tls (struct sppp *sp); -static void ce_ifwatchdog (struct ifnet *ifp); static int ce_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data); static void ce_initialize (void *softc); #endif @@ -677,6 +677,7 @@ static int ce_attach (device_t dev) continue; d = c->sys; + callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #ifdef NETGRAPH if (ng_make_node_common (&typestruct, &d->node) != 0) { printf ("%s: cannot make common node\n", d->name); @@ -685,7 +686,6 @@ static int ce_attach (device_t dev) } #if __FreeBSD_version >= 500000 NG_NODE_SET_PRIVATE (d->node, d); - callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #else d->node->private = d; #endif @@ -731,7 +731,6 @@ static int ce_attach (device_t dev) d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; d->ifp->if_ioctl = ce_sioctl; d->ifp->if_start = ce_ifstart; - d->ifp->if_watchdog = ce_ifwatchdog; d->ifp->if_init = ce_initialize; d->rqueue.ifq_maxlen = IFQ_MAXLEN; #if __FreeBSD_version >= 500000 @@ -806,6 +805,7 @@ static int ce_detach (device_t dev) if (! d || ! d->chan) continue; + callout_stop (&d->timeout_handle); #ifndef NETGRAPH /* Detach from the packet filter list of interfaces. */ bpfdetach (d->ifp); @@ -855,13 +855,12 @@ static int ce_detach (device_t dev) TAU32_DestructiveHalt (b->ddk.pControllerObject, 0); bus_release_resource (dev, SYS_RES_MEMORY, PCIR_BAR(0), bd->ce_res); - s = splimp (); - CE_LOCK (bd); for (c = b->chan; c < b->chan + NCHAN; ++c) { drv_t *d = (drv_t*) c->sys; if (! d || ! d->chan) continue; + callout_drain (&d->timeout_handle); channel [b->num * NCHAN + c->num] = 0; /* Deallocate buffers. */ ce_bus_dma_mem_free (&d->dmamem); @@ -869,8 +868,6 @@ static int ce_detach (device_t dev) adapter [b->num] = 0; ce_bus_dma_mem_free (&bd->dmamem); free (b, M_DEVBUF); - CE_UNLOCK (bd); - splx (s); #if __FreeBSD_version >= 504000 mtx_destroy (&bd->ce_mtx); #endif @@ -888,13 +885,6 @@ static void ce_ifstart (struct ifnet *ifp) CE_UNLOCK (bd); } -static void ce_ifwatchdog (struct ifnet *ifp) -{ - drv_t *d = ifp->if_softc; - - ce_watchdog (d); -} - static void ce_tlf (struct sppp *sp) { drv_t *d = SP2IFP(sp)->if_softc; @@ -989,6 +979,7 @@ static void ce_down (drv_t *d) ce_set_rts (d->chan, 0); d->running = 0; + callout_stop (&d->timeout_handle); } /* @@ -1055,11 +1046,7 @@ static void ce_send (drv_t *d) } m_freem (m); /* Set up transmit timeout, if the transmit ring is not empty.*/ -#ifdef NETGRAPH d->timeout = 10; -#else - d->ifp->if_timer = 10; -#endif } #ifndef NETGRAPH #if __FreeBSD_version >= 600034 @@ -1082,6 +1069,7 @@ static void ce_start (drv_t *d) if (! d->chan->rts) ce_set_rts (d->chan, 1); ce_send (d); + callout_reset (&d->timeout_handle, hz, ce_watchdog_timer, d); } } @@ -1092,11 +1080,8 @@ static void ce_start (drv_t *d) */ static void ce_watchdog (drv_t *d) { - bdrv_t *bd = d->board->sys; CE_DEBUG (d, ("device timeout\n")); if (d->running) { - int s = splimp (); - CE_LOCK (bd); ce_set_dtr (d->chan, 0); ce_set_rts (d->chan, 0); /* ce_stop_chan (d->chan);*/ @@ -1104,25 +1089,35 @@ static void ce_watchdog (drv_t *d) ce_set_dtr (d->chan, 1); ce_set_rts (d->chan, 1); ce_start (d); - CE_UNLOCK (bd); - splx (s); } } +static void ce_watchdog_timer (void *arg) +{ + drv_t *d = arg; + bdrv_t *bd = d->board->sys; + + CE_LOCK(bd); + if (d->timeout == 1) + ce_watchdog (d); + if (d->timeout) + d->timeout--; + callout_reset (&d->timeout_handle, hz, ce_watchdog_timer, d); + CE_UNLOCK(bd); +} + static void ce_transmit (ce_chan_t *c, void *attachment, int len) { drv_t *d = c->sys; -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_opackets; #if __FreeBSD_version >= 600034 d->ifp->if_flags &= ~IFF_DRV_OACTIVE; #else d->ifp->if_flags &= ~IFF_OACTIVE; #endif - d->ifp->if_timer = 0; #endif ce_start (d); } @@ -1195,16 +1190,14 @@ static void ce_error (ce_chan_t *c, int data) break; case CE_UNDERRUN: CE_DEBUG (d, ("underrun error\n")); -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_oerrors; #if __FreeBSD_version >= 600034 d->ifp->if_flags &= ~IFF_DRV_OACTIVE; #else d->ifp->if_flags &= ~IFF_OACTIVE; #endif - d->ifp->if_timer = 0; #endif ce_start (d); break; @@ -2507,19 +2500,6 @@ static int ng_ce_rmnode (node_p node) return 0; } -static void ng_ce_watchdog (void *arg) -{ - drv_t *d = arg; - - if (d) { - if (d->timeout == 1) - ce_watchdog (d); - if (d->timeout) - d->timeout--; - callout_reset (&d->timeout_handle, hz, ng_ce_watchdog, d); - } -} - static int ng_ce_connect (hook_p hook) { #if __FreeBSD_version >= 500000 @@ -2530,7 +2510,7 @@ static int ng_ce_connect (hook_p hook) if (d) { CE_DEBUG (d, ("Connect\n")); - callout_reset (&d->timeout_handle, hz, ng_ce_watchdog, d); + callout_reset (&d->timeout_handle, hz, ce_watchdog_timer, d); } return 0; diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c index 75e3297..f6eeed5 100644 --- a/sys/dev/cp/if_cp.c +++ b/sys/dev/cp/if_cp.c @@ -117,12 +117,12 @@ typedef struct _drv_t { node_p node; struct ifqueue queue; struct ifqueue hi_queue; - short timeout; - struct callout timeout_handle; #else struct ifqueue queue; struct ifnet *ifp; #endif + short timeout; + struct callout timeout_handle; struct cdev *devt; } drv_t; @@ -151,13 +151,13 @@ static void cp_up (drv_t *d); static void cp_start (drv_t *d); static void cp_down (drv_t *d); static void cp_watchdog (drv_t *d); +static void cp_watchdog_timer (void *arg); #ifdef NETGRAPH extern struct ng_type typestruct; #else static void cp_ifstart (struct ifnet *ifp); static void cp_tlf (struct sppp *sp); static void cp_tls (struct sppp *sp); -static void cp_ifwatchdog (struct ifnet *ifp); static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data); static void cp_initialize (void *softc); #endif @@ -490,6 +490,7 @@ static int cp_attach (device_t dev) d->board = b; d->chan = c; c->sys = d; + callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #ifdef NETGRAPH if (ng_make_node_common (&typestruct, &d->node) != 0) { printf ("%s: cannot make common node\n", d->name); @@ -508,7 +509,6 @@ static int cp_attach (device_t dev) d->hi_queue.ifq_maxlen = IFQ_MAXLEN; mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF); mtx_init (&d->hi_queue.ifq_mtx, "cp_queue_hi", NULL, MTX_DEF); - callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #else /*NETGRAPH*/ d->ifp = if_alloc(IFT_PPP); if (d->ifp == NULL) { @@ -521,7 +521,6 @@ static int cp_attach (device_t dev) d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; d->ifp->if_ioctl = cp_sioctl; d->ifp->if_start = cp_ifstart; - d->ifp->if_watchdog = cp_ifwatchdog; d->ifp->if_init = cp_initialize; d->queue.ifq_maxlen = NRBUF; mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF); @@ -603,6 +602,7 @@ static int cp_detach (device_t dev) if (! d || ! d->chan->type) continue; + callout_stop (&d->timeout_handle); #ifndef NETGRAPH /* Detach from the packet filter list of interfaces. */ bpfdetach (d->ifp); @@ -639,12 +639,12 @@ static int cp_detach (device_t dev) callout_drain (&led_timo[b->num]); splx (s); - s = splimp (); for (c = b->chan; c < b->chan + NCHAN; ++c) { drv_t *d = (drv_t*) c->sys; if (! d || ! d->chan->type) continue; + callout_drain (&d->timeout_handle); channel [b->num*NCHAN + c->num] = 0; /* Deallocate buffers. */ cp_bus_dma_mem_free (&d->dmamem); @@ -652,7 +652,6 @@ static int cp_detach (device_t dev) adapter [b->num] = 0; cp_bus_dma_mem_free (&bd->dmamem); free (b, M_DEVBUF); - splx (s); mtx_destroy (&bd->cp_mtx); return 0; } @@ -668,13 +667,6 @@ static void cp_ifstart (struct ifnet *ifp) CP_UNLOCK (bd); } -static void cp_ifwatchdog (struct ifnet *ifp) -{ - drv_t *d = ifp->if_softc; - - cp_watchdog (d); -} - static void cp_tlf (struct sppp *sp) { drv_t *d = SP2IFP(sp)->if_softc; @@ -766,6 +758,7 @@ static void cp_down (drv_t *d) cp_set_rts (d->chan, 0); d->running = 0; + callout_stop (&d->timeout_handle); } /* @@ -827,11 +820,7 @@ static void cp_send (drv_t *d) } m_freem (m); /* Set up transmit timeout, if the transmit ring is not empty.*/ -#ifdef NETGRAPH d->timeout = 10; -#else - d->ifp->if_timer = 10; -#endif } #ifndef NETGRAPH d->ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -850,6 +839,7 @@ static void cp_start (drv_t *d) if (! d->chan->rts) cp_set_rts (d->chan, 1); cp_send (d); + callout_reset (&d->timeout_handle, hz, cp_watchdog_timer, d); } } @@ -860,12 +850,8 @@ static void cp_start (drv_t *d) */ static void cp_watchdog (drv_t *d) { - bdrv_t *bd = d->board->sys; CP_DEBUG (d, ("device timeout\n")); if (d->running) { - int s = splimp (); - - CP_LOCK (bd); cp_stop_chan (d->chan); cp_stop_e1 (d->chan); cp_start_e1 (d->chan); @@ -873,21 +859,31 @@ static void cp_watchdog (drv_t *d) cp_set_dtr (d->chan, 1); cp_set_rts (d->chan, 1); cp_start (d); - CP_UNLOCK (bd); - splx (s); } } +static void cp_watchdog_timer (void *arg) +{ + drv_t *d = arg; + bdrv_t *bd = d->board->sys; + + CP_LOCK (bd); + if (d->timeout == 1) + cp_watchdog (d); + if (d->timeout) + d->timeout--; + callout_reset (&d->timeout_handle, hz, cp_watchdog_timer, d); + CP_UNLOCK (bd); +} + static void cp_transmit (cp_chan_t *c, void *attachment, int len) { drv_t *d = c->sys; -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_opackets; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; #endif cp_start (d); } @@ -958,12 +954,10 @@ static void cp_error (cp_chan_t *c, int data) break; case CP_UNDERRUN: CP_DEBUG (d, ("underrun error\n")); -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_oerrors; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; #endif cp_start (d); break; @@ -2198,26 +2192,13 @@ static int ng_cp_rmnode (node_p node) return 0; } -static void ng_cp_watchdog (void *arg) -{ - drv_t *d = arg; - - if (d) { - if (d->timeout == 1) - cp_watchdog (d); - if (d->timeout) - d->timeout--; - callout_reset (&d->timeout_handle, hz, ng_cp_watchdog, d); - } -} - static int ng_cp_connect (hook_p hook) { drv_t *d = NG_NODE_PRIVATE (NG_HOOK_NODE (hook)); if (d) { CP_DEBUG (d, ("Connect\n")); - callout_reset (&d->timeout_handle, hz, ng_cp_watchdog, d); + callout_reset (&d->timeout_handle, hz, cp_watchdog_timer, d); } return 0; diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c index de3408b..125dfa5 100644 --- a/sys/dev/ctau/if_ct.c +++ b/sys/dev/ctau/if_ct.c @@ -118,12 +118,12 @@ typedef struct _drv_t { node_p node; struct ifqueue queue; struct ifqueue hi_queue; - short timeout; - struct callout timeout_handle; #else struct ifqueue queue; struct ifnet *ifp; #endif + short timeout; + struct callout timeout_handle; struct cdev *devt; } drv_t; @@ -155,13 +155,13 @@ static void ct_up (drv_t *d); static void ct_start (drv_t *d); static void ct_down (drv_t *d); static void ct_watchdog (drv_t *d); +static void ct_watchdog_timer (void *arg); #ifdef NETGRAPH extern struct ng_type typestruct; #else static void ct_ifstart (struct ifnet *ifp); static void ct_tlf (struct sppp *sp); static void ct_tls (struct sppp *sp); -static void ct_ifwatchdog (struct ifnet *ifp); static int ct_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data); static void ct_initialize (void *softc); #endif @@ -701,6 +701,7 @@ static int ct_attach (device_t dev) c->sys = d; channel [b->num*NCHAN + c->num] = d; sprintf (d->name, "ct%d.%d", b->num, c->num); + callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #ifdef NETGRAPH if (ng_make_node_common (&typestruct, &d->node) != 0) { @@ -724,8 +725,7 @@ static int ct_attach (device_t dev) d->queue.ifq_maxlen = IFQ_MAXLEN; d->hi_queue.ifq_maxlen = IFQ_MAXLEN; mtx_init (&d->queue.ifq_mtx, "ct_queue", NULL, MTX_DEF); - mtx_init (&d->hi_queue.ifq_mtx, "ct_queue_hi", NULL, MTX_DEF); - callout_init (&d->timeout_handle, CALLOUT_MPSAFE); + mtx_init (&d->hi_queue.ifq_mtx, "ct_queue_hi", NULL, MTX_DEF); #else /*NETGRAPH*/ d->ifp = if_alloc(IFT_PPP); if (d->ifp == NULL) { @@ -742,7 +742,6 @@ static int ct_attach (device_t dev) d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; d->ifp->if_ioctl = ct_sioctl; d->ifp->if_start = ct_ifstart; - d->ifp->if_watchdog = ct_ifwatchdog; d->ifp->if_init = ct_initialize; d->queue.ifq_maxlen = NBUF; mtx_init (&d->queue.ifq_mtx, "ct_queue", NULL, MTX_DEF); @@ -816,6 +815,7 @@ static int ct_detach (device_t dev) if (!d || !d->chan->type) continue; + callout_stop (&d->timeout_handle); #ifdef NETGRAPH if (d->node) { ng_rmnode_self (d->node); @@ -845,12 +845,12 @@ static int ct_detach (device_t dev) callout_drain (&led_timo[b->num]); splx (s); - s = splimp (); for (c = b->chan; c < b->chan + NCHAN; ++c) { drv_t *d = (drv_t*) c->sys; if (!d || !d->chan->type) continue; + callout_drain(&d->timeout_handle); /* Deallocate buffers. */ ct_bus_dma_mem_free (&d->dmamem); @@ -858,7 +858,6 @@ static int ct_detach (device_t dev) bd->board = 0; adapter [b->num] = 0; free (b, M_DEVBUF); - splx (s); mtx_destroy (&bd->ct_mtx); @@ -876,13 +875,6 @@ static void ct_ifstart (struct ifnet *ifp) CT_UNLOCK (bd); } -static void ct_ifwatchdog (struct ifnet *ifp) -{ - drv_t *d = ifp->if_softc; - - ct_watchdog (d); -} - static void ct_tlf (struct sppp *sp) { drv_t *d = SP2IFP(sp)->if_softc; @@ -970,6 +962,7 @@ static void ct_down (drv_t *d) ct_set_dtr (d->chan, 0); ct_set_rts (d->chan, 0); d->running = 0; + callout_stop (&d->timeout_handle); splx (s); } @@ -1033,11 +1026,7 @@ static void ct_send (drv_t *d) /* Set up transmit timeout, if the transmit ring is not empty. * Transmit timeout is 10 seconds. */ -#ifdef NETGRAPH d->timeout = 10; -#else - d->ifp->if_timer = 10; -#endif } #ifndef NETGRAPH d->ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -1058,6 +1047,7 @@ static void ct_start (drv_t *d) if (! d->chan->rts) ct_set_rts (d->chan, 1); ct_send (d); + callout_reset (&d->timeout_handle, hz, ct_watchdog_timer, d); } splx (s); @@ -1070,11 +1060,7 @@ static void ct_start (drv_t *d) */ static void ct_watchdog (drv_t *d) { - bdrv_t *bd = d->bd; - int s; - s = splimp (); - CT_LOCK (bd); CT_DEBUG (d, ("device timeout\n")); if (d->running) { ct_setup_chan (d->chan); @@ -1083,8 +1069,20 @@ static void ct_watchdog (drv_t *d) ct_set_rts (d->chan, 1); ct_start (d); } +} + +static void ct_watchdog_timer (void *arg) +{ + drv_t *d = arg; + bdrv_t *bd = d->bd; + + CT_LOCK (bd); + if (d->timeout == 1) + ct_watchdog (d); + if (d->timeout) + d->timeout--; + callout_reset (&d->timeout_handle, hz, ct_watchdog_timer, d); CT_UNLOCK (bd); - splx (s); } /* @@ -1096,12 +1094,10 @@ static void ct_transmit (ct_chan_t *c, void *attachment, int len) if (!d) return; -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_opackets; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; #endif ct_start (d); } @@ -1181,12 +1177,10 @@ static void ct_error (ct_chan_t *c, int data) break; case CT_UNDERRUN: CT_DEBUG (d, ("underrun error\n")); -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_oerrors; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; #endif ct_start (d); break; @@ -2142,20 +2136,6 @@ static int ng_ct_rmnode (node_p node) return 0; } -static void ng_ct_watchdog (void *arg) -{ - drv_t *d = arg; - - if (!d) - return; - - if (d->timeout == 1) - ct_watchdog (d); - if (d->timeout) - d->timeout--; - callout_reset (&d->timeout_handle, hz, ng_ct_watchdog, d); -} - static int ng_ct_connect (hook_p hook) { drv_t *d = NG_NODE_PRIVATE (NG_HOOK_NODE (hook)); @@ -2163,7 +2143,7 @@ static int ng_ct_connect (hook_p hook) if (!d) return 0; - callout_reset (&d->timeout_handle, hz, ng_ct_watchdog, d); + callout_reset (&d->timeout_handle, hz, ct_watchdog_timer, d); return 0; } diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c index c0d354a..4e9750e 100644 --- a/sys/dev/cx/if_cx.c +++ b/sys/dev/cx/if_cx.c @@ -143,12 +143,12 @@ typedef struct _drv_t { node_p node; struct ifqueue lo_queue; struct ifqueue hi_queue; - short timeout; - struct callout timeout_handle; #else struct ifqueue queue; struct ifnet *ifp; #endif + short timeout; + struct callout timeout_handle; struct cdev *devt; async_q aqueue; #define CX_READ 1 @@ -197,6 +197,7 @@ static void cx_softintr (void *); static void *cx_fast_ih; static void cx_down (drv_t *d); static void cx_watchdog (drv_t *d); +static void cx_watchdog_timer (void *arg); static void cx_carrier (void *arg); #ifdef NETGRAPH @@ -205,7 +206,6 @@ extern struct ng_type typestruct; static void cx_ifstart (struct ifnet *ifp); static void cx_tlf (struct sppp *sp); static void cx_tls (struct sppp *sp); -static void cx_ifwatchdog (struct ifnet *ifp); static int cx_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data); static void cx_initialize (void *softc); #endif @@ -811,6 +811,7 @@ static int cx_attach (device_t dev) case T_UNIV_RS232: case T_UNIV_RS449: case T_UNIV_V35: + callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #ifdef NETGRAPH if (ng_make_node_common (&typestruct, &d->node) != 0) { printf ("%s: cannot make common node\n", d->name); @@ -834,7 +835,6 @@ static int cx_attach (device_t dev) d->hi_queue.ifq_maxlen = IFQ_MAXLEN; mtx_init (&d->lo_queue.ifq_mtx, "cx_queue_lo", NULL, MTX_DEF); mtx_init (&d->hi_queue.ifq_mtx, "cx_queue_hi", NULL, MTX_DEF); - callout_init (&d->timeout_handle, CALLOUT_MPSAFE); #else /*NETGRAPH*/ d->ifp = if_alloc(IFT_PPP); if (d->ifp == NULL) { @@ -851,7 +851,6 @@ static int cx_attach (device_t dev) d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; d->ifp->if_ioctl = cx_sioctl; d->ifp->if_start = cx_ifstart; - d->ifp->if_watchdog = cx_ifwatchdog; d->ifp->if_init = cx_initialize; d->queue.ifq_maxlen = 2; mtx_init (&d->queue.ifq_mtx, "cx_queue", NULL, MTX_DEF); @@ -959,6 +958,7 @@ static int cx_detach (device_t dev) d->tty = NULL; } + callout_stop (&d->timeout_handle); #ifdef NETGRAPH if (d->node) { ng_rmnode_self (d->node); @@ -992,6 +992,7 @@ static int cx_detach (device_t dev) continue; callout_drain (&d->dcd_timeout_handle); + callout_drain (&d->timeout_handle); } splx (s); @@ -1026,13 +1027,6 @@ static void cx_ifstart (struct ifnet *ifp) CX_UNLOCK (bd); } -static void cx_ifwatchdog (struct ifnet *ifp) -{ - drv_t *d = ifp->if_softc; - - cx_watchdog (d); -} - static void cx_tlf (struct sppp *sp) { drv_t *d = SP2IFP(sp)->if_softc; @@ -1129,6 +1123,7 @@ static void cx_down (drv_t *d) cx_set_dtr (d->chan, 0); cx_set_rts (d->chan, 0); d->running = 0; + callout_stop (&d->timeout_handle); splx (s); } @@ -1191,11 +1186,7 @@ static void cx_send (drv_t *d) m_freem (m); /* Set up transmit timeout, 10 seconds. */ -#ifdef NETGRAPH d->timeout = 10; -#else - d->ifp->if_timer = 10; -#endif } #ifndef NETGRAPH d->ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -1215,6 +1206,7 @@ static void cx_start (drv_t *d) if (! d->chan->rts) cx_set_rts (d->chan, 1); cx_send (d); + callout_reset (&d->timeout_handle, hz, cx_watchdog_timer, d); } splx (s); } @@ -1226,10 +1218,7 @@ static void cx_start (drv_t *d) */ static void cx_watchdog (drv_t *d) { - bdrv_t *bd = d->board->sys; - int s = splhigh (); - CX_LOCK (bd); CX_DEBUG (d, ("device timeout\n")); if (d->running) { cx_setup_chan (d->chan); @@ -1238,8 +1227,20 @@ static void cx_watchdog (drv_t *d) cx_set_rts (d->chan, 1); cx_start (d); } +} + +static void cx_watchdog_timer (void *arg) +{ + drv_t *d = arg; + bdrv_t *bd = d->board->sys; + + CX_LOCK (bd); + if (d->timeout == 1) + cx_watchdog (d); + if (d->timeout) + d->timeout--; + callout_reset (&d->timeout_handle, hz, cx_watchdog_timer, d); CX_UNLOCK (bd); - splx (s); } /* @@ -1262,12 +1263,10 @@ static void cx_transmit (cx_chan_t *c, void *attachment, int len) } return; } -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_opackets; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; #endif cx_start (d); } @@ -1421,14 +1420,12 @@ static void cx_error (cx_chan_t *c, int data) case CX_UNDERRUN: CX_DEBUG (d, ("underrun error\n")); if (c->mode != M_ASYNC) { -#ifdef NETGRAPH d->timeout = 0; -#else +#ifndef NETGRAPH ++d->ifp->if_oerrors; d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - d->ifp->if_timer = 0; - cx_start (d); #endif + cx_start (d); } break; case CX_BREAK: @@ -2477,22 +2474,11 @@ static int ng_cx_rmnode (node_p node) return 0; } -static void ng_cx_watchdog (void *arg) -{ - drv_t *d = arg; - - if (d->timeout == 1) - cx_watchdog (d); - if (d->timeout) - d->timeout--; - callout_reset (&d->timeout_handle, hz, ng_cx_watchdog, d); -} - static int ng_cx_connect (hook_p hook) { drv_t *d = NG_NODE_PRIVATE (NG_HOOK_NODE (hook)); - callout_reset (&d->timeout_handle, hz, ng_cx_watchdog, d); + callout_reset (&d->timeout_handle, hz, cx_watchdog_timer, d); return 0; } |