PERFORCE change 137127 for review
Sam Leffler
sam at FreeBSD.org
Fri Mar 7 23:03:23 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=137127
Change 137127 by sam at sam_ebb on 2008/03/07 23:02:50
o convert debug msgs to use net80211 debug flag
o purge callout; track time and update in tx complete routine
Affected files ...
.. //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.c#8 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.h#4 edit
.. //depot/projects/vap/sys/modules/ath_rate_amrr/Makefile#5 edit
Differences ...
==== //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.c#8 (text+ko) ====
@@ -46,6 +46,7 @@
* Mathieu Lacage, Hossein Manshaei, Thierry Turletti
*/
#include "opt_inet.h"
+#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -65,7 +66,6 @@
#include <net/if.h>
#include <net/if_media.h>
#include <net/if_arp.h>
-#include <net/ethernet.h> /* XXX for ether_sprintf */
#include <net80211/ieee80211_var.h>
@@ -80,21 +80,10 @@
#include <dev/ath/ath_rate/amrr/amrr.h>
#include <contrib/dev/ath/ah_desc.h>
-#define AMRR_DEBUG
-#ifdef AMRR_DEBUG
-#define DPRINTF(sc, _fmt, ...) do { \
- if (sc->sc_debug & 0x10) \
- printf(_fmt, __VA_ARGS__); \
-} while (0)
-#else
-#define DPRINTF(sc, _fmt, ...)
-#endif
-
static int ath_rateinterval = 1000; /* rate ctl interval (ms) */
static int ath_rate_max_success_threshold = 10;
static int ath_rate_min_success_threshold = 1;
-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 *);
@@ -104,7 +93,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
@@ -166,6 +154,11 @@
amn->amn_tx_try3_cnt++;
amn->amn_tx_failure_cnt++;
}
+ if (amn->amn_interval != 0 &&
+ ticks - amn->amn_ticks > amn->amn_interval) {
+ ath_rate_ctl(sc, &an->an_node);
+ amn->amn_ticks = ticks;
+ }
}
void
@@ -176,7 +169,7 @@
}
static void
-node_reset (struct amrr_node *amn)
+node_reset(struct amrr_node *amn)
{
amn->amn_tx_try0_cnt = 0;
amn->amn_tx_try1_cnt = 0;
@@ -200,13 +193,14 @@
{
struct ath_node *an = ATH_NODE(ni);
struct amrr_node *amn = ATH_NODE_AMRR(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),
+ 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);
@@ -268,7 +262,12 @@
amn->amn_tx_rate3 = amn->amn_tx_rate3sp = 0;
}
}
- node_reset (amn);
+ node_reset(amn);
+
+ amn->amn_interval = ath_rateinterval;
+ if (vap->iv_opmode == IEEE80211_M_STA)
+ amn->amn_interval /= 2;
+ amn->amn_interval = (amn->amn_interval * hz) / 1000;
}
/*
@@ -338,14 +337,10 @@
{
struct ieee80211com *ic = vap->iv_ic;
struct ath_softc *sc = ic->ic_ifp->if_softc;
- struct amrr_softc *asc = (struct amrr_softc *) sc->sc_rc;
- const struct ieee80211_txparam *tp;
struct ieee80211_node *ni;
- if (state == IEEE80211_S_INIT) {
- callout_stop(&asc->timer);
+ if (state == IEEE80211_S_INIT)
return;
- }
if (vap->iv_opmode == IEEE80211_M_STA) {
/*
* Reset local xmit state; this is really only
@@ -367,20 +362,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(&asc->timer, (interval * hz) / 1000,
- ath_ratectl, vap);
- }
}
/*
@@ -402,12 +383,10 @@
rix = amn->amn_rix;
- DPRINTF (sc, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
- amn->amn_tx_try0_cnt,
- amn->amn_tx_try1_cnt,
- amn->amn_tx_try2_cnt,
- amn->amn_tx_try3_cnt,
- amn->amn_success_threshold);
+ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
+ "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d",
+ amn->amn_tx_try0_cnt, amn->amn_tx_try1_cnt, amn->amn_tx_try2_cnt,
+ amn->amn_tx_try3_cnt, amn->amn_success_threshold);
if (is_success (amn) && is_enough (amn)) {
amn->amn_success++;
if (amn->amn_success == amn->amn_success_threshold &&
@@ -415,7 +394,8 @@
amn->amn_recovery = 1;
amn->amn_success = 0;
rix++;
- DPRINTF (sc, "increase rate to %d\n", rix);
+ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
+ "increase rate to %d", rix);
} else {
amn->amn_recovery = 0;
}
@@ -427,11 +407,17 @@
amn->amn_success_threshold *= 2;
amn->amn_success_threshold = min (amn->amn_success_threshold,
(u_int)ath_rate_max_success_threshold);
- DPRINTF (sc, "decrease rate recovery thr: %d\n", amn->amn_success_threshold);
+ IEEE80211_NOTE(ni->ni_vap,
+ IEEE80211_MSG_RATECTL, ni,
+ "decrease rate recovery thr: %d",
+ amn->amn_success_threshold);
} else {
/* simple failure. */
amn->amn_success_threshold = ath_rate_min_success_threshold;
- DPRINTF (sc, "decrease rate normal thr: %d\n", amn->amn_success_threshold);
+ IEEE80211_NOTE(ni->ni_vap,
+ IEEE80211_MSG_RATECTL, ni,
+ "decrease rate normal thr: %d",
+ amn->amn_success_threshold);
}
amn->amn_recovery = 0;
rix--;
@@ -454,30 +440,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 amrr_softc *asc = (struct amrr_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(&asc->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);
@@ -504,7 +466,6 @@
if (asc == NULL)
return NULL;
asc->arc.arc_space = sizeof(struct amrr_node);
- callout_init(&asc->timer, CALLOUT_MPSAFE);
ath_rate_sysctlattach(sc);
return &asc->arc;
@@ -515,7 +476,6 @@
{
struct amrr_softc *asc = (struct amrr_softc *) arc;
- callout_drain(&asc->timer);
free(asc, M_DEVBUF);
}
==== //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.h#4 (text+ko) ====
@@ -43,12 +43,13 @@
/* per-device state */
struct amrr_softc {
struct ath_ratectrl arc; /* base state */
- struct callout timer; /* periodic timer */
};
/* per-node state */
struct amrr_node {
int amn_rix; /* current rate index */
+ int amn_ticks; /* time of last update */
+ int amn_interval; /* update interval (ticks) */
/* AMRR statistics for this node */
u_int amn_tx_try0_cnt;
u_int amn_tx_try1_cnt;
==== //depot/projects/vap/sys/modules/ath_rate_amrr/Makefile#5 (text+ko) ====
@@ -40,7 +40,7 @@
KMOD= ath_rate
SRCS= amrr.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>
More information about the p4-projects
mailing list