diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2008-04-04 11:05:05 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2008-04-04 11:05:05 +0000 |
commit | ba1ede989d2677d60da0c08a506dad2605e58e1e (patch) | |
tree | 35ddbcbccf06a40373f4c44c632c69621564929b /sys/dev | |
parent | 43c9fd6d7f4e345d5c80728e22f057fc9c73fbff (diff) |
tht is cool cos it generates interrupts when the link state change.
however, tht is uncool cos it generates these interrupts spuriously (up to
8000 times a second).
this rate limits the reading of the link state off the hardware to 100
times a second. less bus_space reads is a good thing.
tested by and ok thib@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_tht.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 16f54402881..9a84a5c2795 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.112 2008/02/02 20:34:42 brad Exp $ */ +/* $OpenBSD: if_tht.c,v 1.113 2008/04/04 11:05:04 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -37,6 +37,7 @@ #include <sys/proc.h> #include <sys/queue.h> #include <sys/rwlock.h> +#include <sys/time.h> #include <machine/bus.h> @@ -482,6 +483,7 @@ struct tht_softc { struct arpcom sc_ac; struct ifmedia sc_media; + struct timeval sc_mediacheck; u_int16_t sc_lladdr[3]; @@ -1761,9 +1763,13 @@ tht_fw_tick(void *arg) void tht_link_state(struct tht_softc *sc) { + static const struct timeval interval = { 0, 10000 }; struct ifnet *ifp = &sc->sc_ac.ac_if; int link_state = LINK_STATE_DOWN; + if (!ratecheck(&sc->sc_mediacheck, &interval)) + return; + if (tht_read(sc, THT_REG_MAC_LNK_STAT) & THT_REG_MAC_LNK_STAT_LINK) link_state = LINK_STATE_UP; |