Date: Fri, 7 Mar 2008 23:03:22 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 137128 for review Message-ID: <200803072303.m27N3Mhl005043@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=137128 Change 137128 by sam@sam_ebb on 2008/03/07 23:03:22 o convert debug msgs to use net80211 flag o purge callout; track time and update in tx complete Affected files ... .. //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.c#11 edit .. //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.h#7 edit .. //depot/projects/vap/sys/modules/ath_rate_onoe/Makefile#5 edit Differences ... ==== //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.c#11 (text+ko) ==== @@ -34,6 +34,7 @@ * Atsushi Onoe's rate control algorithm. */ #include "opt_inet.h" +#include "opt_wlan.h" #include <sys/param.h> #include <sys/systm.h> @@ -68,19 +69,6 @@ #include <dev/ath/ath_rate/onoe/onoe.h> #include <contrib/dev/ath/ah_desc.h> -#define ONOE_DEBUG -#ifdef ONOE_DEBUG -enum { - ATH_DEBUG_RATE = 0x00000010, /* rate control */ -}; -#define DPRINTF(sc, _fmt, ...) do { \ - if (sc->sc_debug & ATH_DEBUG_RATE) \ - printf(_fmt, __VA_ARGS__); \ -} while (0) -#else -#define DPRINTF(sc, _fmt, ...) -#endif - /* * Default parameters for the rate control algorithm. These are * all tunable with sysctls. The rate controller runs periodically @@ -104,7 +92,6 @@ static int ath_rate_raise = 10; /* add credit threshold */ static int ath_rate_raise_threshold = 10; /* rate ctl raise threshold */ -static void ath_ratectl(void *); static void ath_rate_update(struct ath_softc *, struct ieee80211_node *, int rate); static void ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *); @@ -114,7 +101,6 @@ ath_rate_node_init(struct ath_softc *sc, struct ath_node *an) { /* NB: assumed to be zero'd by caller */ - ath_rate_update(sc, &an->an_node, 0); } void @@ -163,6 +149,10 @@ on->on_tx_err++; on->on_tx_retr += ts->ts_shortretry + ts->ts_longretry; + if (on->on_interval != 0 && ticks - on->on_ticks > on->on_interval) { + ath_rate_ctl(sc, &an->an_node); + on->on_ticks = ticks; + } } void @@ -177,14 +167,15 @@ { struct ath_node *an = ATH_NODE(ni); struct onoe_node *on = ATH_NODE_ONOE(an); + struct ieee80211vap *vap = ni->ni_vap; const HAL_RATE_TABLE *rt = sc->sc_currates; u_int8_t rix; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); - DPRINTF(sc, "%s: set xmit rate for %s to %dM\n", - __func__, ether_sprintf(ni->ni_macaddr), - ni->ni_rates.rs_nrates > 0 ? + IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni, + "%s: set xmit rate to %dM", __func__, + ni->ni_rates.rs_nrates > 0 ? (ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0); /* @@ -246,6 +237,11 @@ } done: on->on_tx_ok = on->on_tx_err = on->on_tx_retr = on->on_tx_upper = 0; + + on->on_interval = ath_rateinterval; + if (vap->iv_opmode == IEEE80211_M_STA) + on->on_interval /= 2; + on->on_interval = (on->on_interval * hz) / 1000; } /* @@ -315,14 +311,10 @@ { struct ieee80211com *ic = vap->iv_ic; struct ath_softc *sc = ic->ic_ifp->if_softc; - struct onoe_softc *osc = (struct onoe_softc *) sc->sc_rc; - const struct ieee80211_txparam *tp; struct ieee80211_node *ni; - if (state == IEEE80211_S_INIT) { - callout_stop(&osc->timer); + if (state == IEEE80211_S_INIT) return; - } if (vap->iv_opmode == IEEE80211_M_STA) { /* * Reset local xmit state; this is really only @@ -344,20 +336,6 @@ ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_cb, sc); ath_rate_update(sc, vap->iv_bss, 0); } - tp = ATH_NODE(vap->iv_bss)->an_tp; - if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE && - state == IEEE80211_S_RUN) { - int interval; - /* - * Start the background rate control thread if we - * are not configured to use a fixed xmit rate. - */ - interval = ath_rateinterval; - if (vap->iv_opmode == IEEE80211_M_STA) - interval /= 2; - callout_reset(&osc->timer, (interval * hz) / 1000, - ath_ratectl, vap); - } } /* @@ -390,10 +368,9 @@ on->on_tx_retr < (on->on_tx_ok * ath_rate_raise) / 100) dir = 1; - DPRINTF(sc, "%s: ok %d err %d retr %d upper %d dir %d\n", - ether_sprintf(ni->ni_macaddr), - on->on_tx_ok, on->on_tx_err, on->on_tx_retr, - on->on_tx_upper, dir); + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "ok %d err %d retr %d upper %d dir %d", + on->on_tx_ok, on->on_tx_err, on->on_tx_retr, on->on_tx_upper, dir); nrate = on->on_rix; switch (dir) { @@ -421,8 +398,8 @@ } if (nrate != on->on_rix) { - DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n", - __func__, + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: %dM -> %dM (%d ok, %d err, %d retr)", __func__, ni->ni_txrate / 2, (rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2, on->on_tx_ok, on->on_tx_err, on->on_tx_retr); @@ -432,30 +409,6 @@ } static void -ath_ratectl(void *arg) -{ - struct ieee80211vap *vap = arg; - struct ieee80211com *ic = vap->iv_ic; - struct ifnet *ifp = ic->ic_ifp; - struct ath_softc *sc = ifp->if_softc; - struct onoe_softc *osc = (struct onoe_softc *) sc->sc_rc; - int interval; - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - sc->sc_stats.ast_rate_calls++; - - if (vap->iv_opmode == IEEE80211_M_STA) - ath_rate_ctl(sc, vap->iv_bss); /* NB: no reference */ - else - ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_ctl, sc); - } - interval = ath_rateinterval; - if (vap->iv_opmode == IEEE80211_M_STA) - interval /= 2; - callout_reset(&osc->timer, (interval * hz) / 1000, ath_ratectl, arg); -} - -static void ath_rate_sysctlattach(struct ath_softc *sc) { struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); @@ -482,7 +435,6 @@ if (osc == NULL) return NULL; osc->arc.arc_space = sizeof(struct onoe_node); - callout_init(&osc->timer, CALLOUT_MPSAFE); ath_rate_sysctlattach(sc); return &osc->arc; @@ -493,7 +445,6 @@ { struct onoe_softc *osc = (struct onoe_softc *) arc; - callout_drain(&osc->timer); free(osc, M_DEVBUF); } ==== //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.h#7 (text+ko) ==== @@ -38,12 +38,14 @@ /* per-device state */ struct onoe_softc { struct ath_ratectrl arc; /* base state */ - struct callout timer; /* periodic timer */ }; /* per-node state */ struct onoe_node { int on_rix; /* current rate index */ + int on_ticks; /* time of last update */ + int on_interval; /* update interval (ticks) */ + u_int on_tx_ok; /* tx ok pkt */ u_int on_tx_err; /* tx !ok pkt */ u_int on_tx_retr; /* tx retry count */ ==== //depot/projects/vap/sys/modules/ath_rate_onoe/Makefile#5 (text+ko) ==== @@ -40,7 +40,7 @@ KMOD= ath_rate SRCS= onoe.c -SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ah.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ah.h opt_wlan.h HAL= ${.CURDIR}/../../contrib/dev/ath CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${HAL} @@ -56,7 +56,13 @@ ATH_MODULE_ARCH=${MACHINE_ARCH} .endif +.if !defined(KERNBUILDDIR) opt_ah.h: ${HAL}/public/${ATH_MODULE_ARCH}-elf.opt_ah.h cp ${HAL}/public/${ATH_MODULE_ARCH}-elf.opt_ah.h ${.TARGET} +opt_wlan.h: + echo "#define IEEE80211_DEBUG 1" > opt_wlan.h +# echo > opt_wlan.h +.endif + .include <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803072303.m27N3Mhl005043>