Use ratecheck() to limit error messages on disconnect.

Break out some common functionality.
This commit is contained in:
augustss 2000-03-02 12:37:50 +00:00
parent e924f6f853
commit d6c4ac7ff2
7 changed files with 45 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_aue.c,v 1.25 2000/03/01 19:00:51 augustss Exp $ */
/* $NetBSD: if_aue.c,v 1.26 2000/03/02 12:37:50 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -174,8 +174,6 @@ static struct aue_type aue_devs[] = {
{ 0, 0 }
};
static struct timeval aue_errinterval = { 0, 2500000 }; /* 0.25 s*/
USB_DECLARE_DRIVER(aue);
static int aue_tx_list_init __P((struct aue_softc *));
@ -1167,10 +1165,10 @@ aue_rxeof(xfer, priv, status)
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return;
sc->aue_rx_errs++;
if (ratecheck(&sc->aue_rx_notice, &aue_errinterval)) {
if (usbd_ratecheck(&sc->aue_rx_notice)) {
printf("%s: %u usb errors on rx: %s\n",
USBDEVNAME(sc->aue_dev), sc->aue_rx_errs,
usbd_errstr(status));
USBDEVNAME(sc->aue_dev), sc->aue_rx_errs,
usbd_errstr(status));
sc->aue_rx_errs = 0;
}
if (status == USBD_STALLED)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_cue.c,v 1.9 2000/03/01 19:00:51 augustss Exp $ */
/* $NetBSD: if_cue.c,v 1.10 2000/03/02 12:37:50 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -886,8 +886,13 @@ cue_rxeof(xfer, priv, status)
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return;
printf("%s: usb error on rx: %s\n", USBDEVNAME(sc->cue_dev),
usbd_errstr(status));
sc->cue_rx_errs++;
if (usbd_ratecheck(&sc->cue_rx_notice)) {
printf("%s: %u usb errors on rx: %s\n",
USBDEVNAME(sc->cue_dev), sc->cue_rx_errs,
usbd_errstr(status));
sc->cue_rx_errs = 0;
}
if (status == USBD_STALLED)
usbd_clear_endpoint_stall(sc->cue_ep[CUE_ENDPT_RX]);
goto done;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_cuereg.h,v 1.4 2000/02/17 18:42:21 augustss Exp $ */
/* $NetBSD: if_cuereg.h,v 1.5 2000/03/02 12:37:50 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -196,4 +196,6 @@ struct cue_softc {
char cue_dying;
char cue_attached;
u_int cue_rx_errs;
struct timeval cue_rx_notice;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_kue.c,v 1.10 2000/03/01 19:00:51 augustss Exp $ */
/* $NetBSD: if_kue.c,v 1.11 2000/03/02 12:37:51 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -941,8 +941,13 @@ kue_rxeof(xfer, priv, status)
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return;
printf("%s: usb error on rx: %s\n", USBDEVNAME(sc->kue_dev),
usbd_errstr(status));
sc->kue_rx_errs++;
if (usbd_ratecheck(&sc->kue_rx_notice)) {
printf("%s: %u usb errors on rx: %s\n",
USBDEVNAME(sc->kue_dev), sc->kue_rx_errs,
usbd_errstr(status));
sc->kue_rx_errs = 0;
}
if (status == USBD_STALLED)
usbd_clear_endpoint_stall(sc->kue_ep[KUE_ENDPT_RX]);
goto done;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_kuereg.h,v 1.4 2000/02/17 18:42:22 augustss Exp $ */
/* $NetBSD: if_kuereg.h,v 1.5 2000/03/02 12:37:51 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -190,4 +190,6 @@ struct kue_softc {
char kue_dying;
char kue_attached;
u_int kue_rx_errs;
struct timeval kue_rx_notice;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdi.c,v 1.62 2000/02/08 18:46:03 augustss Exp $ */
/* $NetBSD: usbdi.c,v 1.63 2000/03/02 12:37:51 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@ -1103,6 +1103,21 @@ usbd_get_endpoint_descriptor(iface, address)
return (0);
}
/*
* usbd_ratecheck() can limit the number of error messages that occurs.
* When a device is unplugged it may take up to 0.25s for the hub driver
* to notice it. If the driver continuosly tries to do I/O operations
* this can generate a large number of messages.
*/
int
usbd_ratecheck(last)
struct timeval *last;
{
static struct timeval errinterval = { 0, 2500000 }; /* 0.25 s*/
return (ratecheck(last, &errinterval));
}
#if defined(__FreeBSD__)
int
usbd_driver_load(module_t mod, int what, void *arg)

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdi.h,v 1.40 2000/02/02 07:34:00 augustss Exp $ */
/* $NetBSD: usbdi.h,v 1.41 2000/03/02 12:37:51 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@ -185,6 +185,8 @@ usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
usbd_status usbd_reload_device_desc __P((usbd_device_handle));
int usbd_ratecheck __P((struct timeval *last));
/* NetBSD attachment information */
/* Attach data */