diff options
author | 2008-04-04 11:05:04 +0000 | |
---|---|---|
committer | 2008-04-04 11:05:04 +0000 | |
commit | 7ced111b51a14da82839f8da5ddd22a2e8b1cd02 (patch) | |
tree | b8f28719a36b97f9a6fbc71dbb587407953c5d98 | |
parent | oops, some unrelated stuff crept into that commit - backout. (diff) | |
download | wireguard-openbsd-7ced111b51a14da82839f8da5ddd22a2e8b1cd02.tar.xz wireguard-openbsd-7ced111b51a14da82839f8da5ddd22a2e8b1cd02.zip |
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@
-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; |