diff options
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/wlan/if_rum.c | 76 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_rumvar.h | 11 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_run.c | 88 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_runvar.h | 12 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_ural.c | 75 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_uralvar.h | 11 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_urtw.c | 1 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_zyd.c | 50 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_zydreg.h | 7 |
9 files changed, 121 insertions, 210 deletions
diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index 0cd394d..5b3441b 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -140,7 +140,6 @@ static const struct usb_device_id rum_devs[] = { }; MODULE_DEPEND(rum, wlan, 1, 1, 1); -MODULE_DEPEND(rum, wlan_amrr, 1, 1, 1); MODULE_DEPEND(rum, usb, 1, 1, 1); static device_probe_t rum_match; @@ -212,17 +211,14 @@ static int rum_prepare_beacon(struct rum_softc *, struct ieee80211vap *); static int rum_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); -static struct ieee80211_node *rum_node_alloc(struct ieee80211vap *, - const uint8_t mac[IEEE80211_ADDR_LEN]); -static void rum_newassoc(struct ieee80211_node *, int); static void rum_scan_start(struct ieee80211com *); static void rum_scan_end(struct ieee80211com *); static void rum_set_channel(struct ieee80211com *); static int rum_get_rssi(struct rum_softc *, uint8_t); -static void rum_amrr_start(struct rum_softc *, +static void rum_ratectl_start(struct rum_softc *, struct ieee80211_node *); -static void rum_amrr_timeout(void *); -static void rum_amrr_task(void *, int); +static void rum_ratectl_timeout(void *); +static void rum_ratectl_task(void *, int); static int rum_pause(struct rum_softc *, int); static const struct { @@ -511,9 +507,7 @@ rum_attach(device_t self) ieee80211_ifattach(ic, sc->sc_bssid); ic->ic_update_promisc = rum_update_promisc; - ic->ic_newassoc = rum_newassoc; ic->ic_raw_xmit = rum_raw_xmit; - ic->ic_node_alloc = rum_node_alloc; ic->ic_scan_start = rum_scan_start; ic->ic_scan_end = rum_scan_end; ic->ic_set_channel = rum_set_channel; @@ -608,13 +602,10 @@ rum_vap_create(struct ieee80211com *ic, rvp->newstate = vap->iv_newstate; vap->iv_newstate = rum_newstate; - usb_callout_init_mtx(&rvp->amrr_ch, &sc->sc_mtx, 0); - TASK_INIT(&rvp->amrr_task, 0, rum_amrr_task, rvp); - ieee80211_amrr_init(&rvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 1000 /* 1 sec */); - + usb_callout_init_mtx(&rvp->ratectl_ch, &sc->sc_mtx, 0); + TASK_INIT(&rvp->ratectl_task, 0, rum_ratectl_task, rvp); + ieee80211_ratectl_init(vap); + ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); ic->ic_opmode = opmode; @@ -627,9 +618,9 @@ rum_vap_delete(struct ieee80211vap *vap) struct rum_vap *rvp = RUM_VAP(vap); struct ieee80211com *ic = vap->iv_ic; - usb_callout_drain(&rvp->amrr_ch); - ieee80211_draintask(ic, &rvp->amrr_task); - ieee80211_amrr_cleanup(&rvp->amrr); + usb_callout_drain(&rvp->ratectl_ch); + ieee80211_draintask(ic, &rvp->ratectl_task); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(rvp, M_80211_VAP); } @@ -716,7 +707,7 @@ rum_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) IEEE80211_UNLOCK(ic); RUM_LOCK(sc); - usb_callout_stop(&rvp->amrr_ch); + usb_callout_stop(&rvp->ratectl_ch); switch (nstate) { case IEEE80211_S_INIT: @@ -751,7 +742,7 @@ rum_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) /* enable automatic rate adaptation */ tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) - rum_amrr_start(sc, ni); + rum_ratectl_start(sc, ni); break; default: break; @@ -2194,7 +2185,7 @@ bad: } static void -rum_amrr_start(struct rum_softc *sc, struct ieee80211_node *ni) +rum_ratectl_start(struct rum_softc *sc, struct ieee80211_node *ni) { struct ieee80211vap *vap = ni->ni_vap; struct rum_vap *rvp = RUM_VAP(vap); @@ -2202,23 +2193,23 @@ rum_amrr_start(struct rum_softc *sc, struct ieee80211_node *ni) /* clear statistic registers (STA_CSR0 to STA_CSR5) */ rum_read_multi(sc, RT2573_STA_CSR0, sc->sta, sizeof sc->sta); - ieee80211_amrr_node_init(&rvp->amrr, &RUM_NODE(ni)->amn, ni); + ieee80211_ratectl_node_init(ni); - usb_callout_reset(&rvp->amrr_ch, hz, rum_amrr_timeout, rvp); + usb_callout_reset(&rvp->ratectl_ch, hz, rum_ratectl_timeout, rvp); } static void -rum_amrr_timeout(void *arg) +rum_ratectl_timeout(void *arg) { struct rum_vap *rvp = arg; struct ieee80211vap *vap = &rvp->vap; struct ieee80211com *ic = vap->iv_ic; - ieee80211_runtask(ic, &rvp->amrr_task); + ieee80211_runtask(ic, &rvp->ratectl_task); } static void -rum_amrr_task(void *arg, int pending) +rum_ratectl_task(void *arg, int pending) { struct rum_vap *rvp = arg; struct ieee80211vap *vap = &rvp->vap; @@ -2227,6 +2218,7 @@ rum_amrr_task(void *arg, int pending) struct rum_softc *sc = ifp->if_softc; struct ieee80211_node *ni = vap->iv_bss; int ok, fail; + int sum, retrycnt; RUM_LOCK(sc); /* read and clear statistic registers (STA_CSR0 to STA_CSR10) */ @@ -2235,36 +2227,18 @@ rum_amrr_task(void *arg, int pending) ok = (le32toh(sc->sta[4]) >> 16) + /* TX ok w/o retry */ (le32toh(sc->sta[5]) & 0xffff); /* TX ok w/ retry */ fail = (le32toh(sc->sta[5]) >> 16); /* TX retry-fail count */ + sum = ok+fail; + retrycnt = (le32toh(sc->sta[5]) & 0xffff) + fail; - ieee80211_amrr_tx_update(&RUM_NODE(ni)->amn, - ok+fail, ok, (le32toh(sc->sta[5]) & 0xffff) + fail); - (void) ieee80211_amrr_choose(ni, &RUM_NODE(ni)->amn); + ieee80211_ratectl_tx_update(vap, ni, &sum, &ok, &retrycnt); + (void) ieee80211_ratectl_rate(ni, NULL, 0); ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */ - usb_callout_reset(&rvp->amrr_ch, hz, rum_amrr_timeout, rvp); + usb_callout_reset(&rvp->ratectl_ch, hz, rum_ratectl_timeout, rvp); RUM_UNLOCK(sc); } -/* ARGUSED */ -static struct ieee80211_node * -rum_node_alloc(struct ieee80211vap *vap __unused, - const uint8_t mac[IEEE80211_ADDR_LEN] __unused) -{ - struct rum_node *rn; - - rn = malloc(sizeof(struct rum_node), M_80211_NODE, M_NOWAIT | M_ZERO); - return rn != NULL ? &rn->ni : NULL; -} - -static void -rum_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&RUM_VAP(vap)->amrr, &RUM_NODE(ni)->amn, ni); -} - static void rum_scan_start(struct ieee80211com *ic) { diff --git a/sys/dev/usb/wlan/if_rumvar.h b/sys/dev/usb/wlan/if_rumvar.h index 82bb117..f46634c 100644 --- a/sys/dev/usb/wlan/if_rumvar.h +++ b/sys/dev/usb/wlan/if_rumvar.h @@ -67,18 +67,11 @@ struct rum_tx_data { }; typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead; -struct rum_node { - struct ieee80211_node ni; - struct ieee80211_amrr_node amn; -}; -#define RUM_NODE(ni) ((struct rum_node *)(ni)) - struct rum_vap { struct ieee80211vap vap; struct ieee80211_beacon_offsets bo; - struct ieee80211_amrr amrr; - struct usb_callout amrr_ch; - struct task amrr_task; + struct usb_callout ratectl_ch; + struct task ratectl_task; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index 65f48e4..e69cb06 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -290,7 +290,6 @@ static const struct usb_device_id run_devs[] = { }; MODULE_DEPEND(run, wlan, 1, 1, 1); -MODULE_DEPEND(run, wlan_amrr, 1, 1, 1); MODULE_DEPEND(run, usb, 1, 1, 1); MODULE_DEPEND(run, firmware, 1, 1, 1); @@ -350,9 +349,9 @@ static int run_key_set(struct ieee80211vap *, const struct ieee80211_key *, const uint8_t mac[IEEE80211_ADDR_LEN]); static int run_key_delete(struct ieee80211vap *, const struct ieee80211_key *); -static void run_amrr_start(struct run_softc *, struct ieee80211_node *); -static void run_amrr_to(void *); -static void run_amrr_cb(void *, int); +static void run_ratectl_start(struct run_softc *, struct ieee80211_node *); +static void run_ratectl_to(void *); +static void run_ratectl_cb(void *, int); static void run_iter_func(void *, struct ieee80211_node *); static void run_newassoc(struct ieee80211_node *, int); static void run_rx_frame(struct run_softc *, struct mbuf *, uint32_t); @@ -754,14 +753,12 @@ run_vap_create(struct ieee80211com *ic, rvp->newstate = vap->iv_newstate; vap->iv_newstate = run_newstate; - TASK_INIT(&rvp->amrr_task, 0, run_amrr_cb, rvp); + TASK_INIT(&rvp->ratectl_task, 0, run_ratectl_cb, rvp); TASK_INIT(&sc->wme_task, 0, run_wme_update_cb, ic); TASK_INIT(&sc->usb_timeout_task, 0, run_usb_timeout_cb, sc); - callout_init((struct callout *)&rvp->amrr_ch, 1); - ieee80211_amrr_init(&rvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 1000 /* 1 sec */); + callout_init((struct callout *)&rvp->ratectl_ch, 1); + ieee80211_ratectl_init(vap); + ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); /* complete setup */ ieee80211_vap_attach(vap, run_media_change, ieee80211_media_status); @@ -786,16 +783,16 @@ run_vap_delete(struct ieee80211vap *vap) sc = ifp->if_softc; RUN_LOCK(sc); - sc->sc_rvp->amrr_run = RUN_AMRR_OFF; + sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; RUN_UNLOCK(sc); /* drain them all */ - usb_callout_drain(&sc->sc_rvp->amrr_ch); - ieee80211_draintask(ic, &sc->sc_rvp->amrr_task); + usb_callout_drain(&sc->sc_rvp->ratectl_ch); + ieee80211_draintask(ic, &sc->sc_rvp->ratectl_task); ieee80211_draintask(ic, &sc->wme_task); ieee80211_draintask(ic, &sc->usb_timeout_task); - ieee80211_amrr_cleanup(&rvp->amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(rvp, M_80211_VAP); sc->sc_rvp = NULL; @@ -1632,8 +1629,8 @@ run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) IEEE80211_UNLOCK(ic); RUN_LOCK(sc); - sc->sc_rvp->amrr_run = RUN_AMRR_OFF; - usb_callout_stop(&rvp->amrr_ch); + sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; + usb_callout_stop(&rvp->ratectl_ch); if (ostate == IEEE80211_S_RUN) { /* turn link LED off */ @@ -1681,7 +1678,7 @@ run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) /* enable automatic rate adaptation */ tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) - run_amrr_start(sc, ni); + run_ratectl_start(sc, ni); /* turn link LED on */ run_set_leds(sc, RT2860_LED_RADIO | @@ -1961,12 +1958,14 @@ fail: } static void -run_amrr_start(struct run_softc *sc, struct ieee80211_node *ni) +run_ratectl_start(struct run_softc *sc, struct ieee80211_node *ni) { struct ieee80211vap *vap = ni->ni_vap; struct run_vap *rvp = RUN_VAP(vap); uint32_t sta[3]; +#if 0 uint8_t wcid; +#endif RUN_LOCK_ASSERT(sc, MA_OWNED); @@ -1974,30 +1973,33 @@ run_amrr_start(struct run_softc *sc, struct ieee80211_node *ni) run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta, sizeof sta); +#if 0 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); ieee80211_amrr_node_init(&rvp->amrr, &rvp->amn[wcid], ni); +#endif + ieee80211_ratectl_node_init(ni); /* start at lowest available bit-rate, AMRR will raise */ ni->ni_txrate = 2; /* start calibration timer */ - rvp->amrr_run = RUN_AMRR_ON; - usb_callout_reset(&rvp->amrr_ch, hz, run_amrr_to, rvp); + rvp->ratectl_run = RUN_RATECTL_ON; + usb_callout_reset(&rvp->ratectl_ch, hz, run_ratectl_to, rvp); } static void -run_amrr_to(void *arg) +run_ratectl_to(void *arg) { struct run_vap *rvp = arg; /* do it in a process context, so it can go sleep */ - ieee80211_runtask(rvp->vap.iv_ic, &rvp->amrr_task); + ieee80211_runtask(rvp->vap.iv_ic, &rvp->ratectl_task); /* next timeout will be rescheduled in the callback task */ } /* ARGSUSED */ static void -run_amrr_cb(void *arg, int pending) +run_ratectl_cb(void *arg, int pending) { struct run_vap *rvp = arg; struct ieee80211vap *vap = &rvp->vap; @@ -2020,8 +2022,8 @@ run_amrr_cb(void *arg, int pending) ieee80211_iterate_nodes(&ic->ic_sta, run_iter_func, rvp); } - if(rvp->amrr_run == RUN_AMRR_ON) - usb_callout_reset(&rvp->amrr_ch, hz, run_amrr_to, rvp); + if(rvp->ratectl_run == RUN_RATECTL_ON) + usb_callout_reset(&rvp->ratectl_ch, hz, run_ratectl_to, rvp); } @@ -2033,10 +2035,11 @@ run_iter_func(void *arg, struct ieee80211_node *ni) struct ifnet *ifp = ic->ic_ifp; struct run_softc *sc = ifp->if_softc; struct ieee80211_node_table *nt = &ic->ic_sta; - struct ieee80211_amrr_node *amn = &rvp->amn[0]; /* make compiler happy */ uint32_t sta[3], stat; int error; uint8_t wcid, mcs, pid; + struct ieee80211vap *vap = ni->ni_vap; + int txcnt = 0, success = 0, retrycnt = 0; if(ic->ic_opmode != IEEE80211_M_STA) IEEE80211_NODE_ITERATE_UNLOCK(nt); @@ -2056,10 +2059,7 @@ run_iter_func(void *arg, struct ieee80211_node *ni) continue; /* update per-STA AMRR stats */ - amn = &rvp->amn[wcid]; - amn->amn_txcnt++; if (stat & RT2860_TXQ_OK) { - amn->amn_success++; /* * Check if there were retries, ie if the Tx * success rate is different from the requested @@ -2069,16 +2069,20 @@ run_iter_func(void *arg, struct ieee80211_node *ni) mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f; pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf; if (mcs + 1 != pid) - amn->amn_retrycnt++; + retrycnt = 1; + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); } else { - amn->amn_retrycnt++; + retrycnt = 1; + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); ifp->if_oerrors++; } run_read_region_1(sc, RT2860_TX_STAT_FIFO, (uint8_t *)&stat, sizeof stat); } - DPRINTFN(3, "retrycnt=%d txcnt=%d success=%d\n", - amn->amn_retrycnt, amn->amn_txcnt, amn->amn_success); } else { /* read statistic counters (clear on read) and update AMRR state */ error = run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta, @@ -2090,26 +2094,30 @@ run_iter_func(void *arg, struct ieee80211_node *ni) le32toh(sta[1]) >> 16, le32toh(sta[1]) & 0xffff, le32toh(sta[0]) & 0xffff); +#if 0 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); amn = &rvp->amn[wcid]; +#endif /* count failed TX as errors */ ifp->if_oerrors += le32toh(sta[0]) & 0xffff; - amn->amn_retrycnt = + retrycnt = (le32toh(sta[0]) & 0xffff) + /* failed TX count */ (le32toh(sta[1]) >> 16); /* TX retransmission count */ - amn->amn_txcnt = - amn->amn_retrycnt + + txcnt = + retrycnt + (le32toh(sta[1]) & 0xffff); /* successful TX count */ - amn->amn_success = + success = (le32toh(sta[1]) >> 16) + (le32toh(sta[1]) & 0xffff); + ieee80211_ratectl_tx_update(vap, ni, &txcnt, &success, + &retrycnt); } - ieee80211_amrr_choose(ni, amn); + ieee80211_ratectl_rate(ni, NULL, 0); skip:; RUN_UNLOCK(sc); @@ -4447,7 +4455,7 @@ run_stop(void *arg) RUN_LOCK_ASSERT(sc, MA_OWNED); if(sc->sc_rvp != NULL){ - sc->sc_rvp->amrr_run = RUN_AMRR_OFF; + sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; if (ic->ic_flags & IEEE80211_F_SCAN) ieee80211_cancel_scan(&sc->sc_rvp->vap); } diff --git a/sys/dev/usb/wlan/if_runvar.h b/sys/dev/usb/wlan/if_runvar.h index 87b15bc..a7f8f1f 100644 --- a/sys/dev/usb/wlan/if_runvar.h +++ b/sys/dev/usb/wlan/if_runvar.h @@ -107,13 +107,11 @@ struct run_node { struct run_vap { struct ieee80211vap vap; struct ieee80211_beacon_offsets bo; - struct ieee80211_amrr amrr; - struct ieee80211_amrr_node amn[RT2870_WCID_MAX + 1]; - struct usb_callout amrr_ch; - struct task amrr_task; - uint8_t amrr_run; -#define RUN_AMRR_ON 1 -#define RUN_AMRR_OFF 0 + struct usb_callout ratectl_ch; + struct task ratectl_task; + uint8_t ratectl_run; +#define RUN_RATECTL_ON 1 +#define RUN_RATECTL_OFF 0 int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 25fb86f..fc907bc 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -162,9 +162,6 @@ static void ural_write_multi(struct ural_softc *, uint16_t, void *, static void ural_bbp_write(struct ural_softc *, uint8_t, uint8_t); static uint8_t ural_bbp_read(struct ural_softc *, uint8_t); static void ural_rf_write(struct ural_softc *, uint8_t, uint32_t); -static struct ieee80211_node *ural_node_alloc(struct ieee80211vap *, - const uint8_t mac[IEEE80211_ADDR_LEN]); -static void ural_newassoc(struct ieee80211_node *, int); static void ural_scan_start(struct ieee80211com *); static void ural_scan_end(struct ieee80211com *); static void ural_set_channel(struct ieee80211com *); @@ -191,10 +188,10 @@ static void ural_init(void *); static void ural_stop(struct ural_softc *); static int ural_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); -static void ural_amrr_start(struct ural_softc *, +static void ural_ratectl_start(struct ural_softc *, struct ieee80211_node *); -static void ural_amrr_timeout(void *); -static void ural_amrr_task(void *, int); +static void ural_ratectl_timeout(void *); +static void ural_ratectl_task(void *, int); static int ural_pause(struct ural_softc *sc, int timeout); /* @@ -403,7 +400,6 @@ static devclass_t ural_devclass; DRIVER_MODULE(ural, uhub, ural_driver, ural_devclass, NULL, 0); MODULE_DEPEND(ural, usb, 1, 1, 1); MODULE_DEPEND(ural, wlan, 1, 1, 1); -MODULE_DEPEND(ural, wlan_amrr, 1, 1, 1); static int ural_match(device_t self) @@ -500,9 +496,7 @@ ural_attach(device_t self) ieee80211_ifattach(ic, sc->sc_bssid); ic->ic_update_promisc = ural_update_promisc; - ic->ic_newassoc = ural_newassoc; ic->ic_raw_xmit = ural_raw_xmit; - ic->ic_node_alloc = ural_node_alloc; ic->ic_scan_start = ural_scan_start; ic->ic_scan_end = ural_scan_end; ic->ic_set_channel = ural_set_channel; @@ -597,12 +591,10 @@ ural_vap_create(struct ieee80211com *ic, uvp->newstate = vap->iv_newstate; vap->iv_newstate = ural_newstate; - usb_callout_init_mtx(&uvp->amrr_ch, &sc->sc_mtx, 0); - TASK_INIT(&uvp->amrr_task, 0, ural_amrr_task, uvp); - ieee80211_amrr_init(&uvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 1000 /* 1 sec */); + usb_callout_init_mtx(&uvp->ratectl_ch, &sc->sc_mtx, 0); + TASK_INIT(&uvp->ratectl_task, 0, ural_ratectl_task, uvp); + ieee80211_ratectl_init(vap); + ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); @@ -616,9 +608,9 @@ ural_vap_delete(struct ieee80211vap *vap) struct ural_vap *uvp = URAL_VAP(vap); struct ieee80211com *ic = vap->iv_ic; - usb_callout_drain(&uvp->amrr_ch); - ieee80211_draintask(ic, &uvp->amrr_task); - ieee80211_amrr_cleanup(&uvp->amrr); + usb_callout_drain(&uvp->ratectl_ch); + ieee80211_draintask(ic, &uvp->ratectl_task); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(uvp, M_80211_VAP); } @@ -703,7 +695,7 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) IEEE80211_UNLOCK(ic); RAL_LOCK(sc); - usb_callout_stop(&uvp->amrr_ch); + usb_callout_stop(&uvp->ratectl_ch); switch (nstate) { case IEEE80211_S_INIT: @@ -759,7 +751,7 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) /* XXX should use ic_bsschan but not valid until after newstate call below */ tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) - ural_amrr_start(sc, ni); + ural_ratectl_start(sc, ni); break; @@ -1584,25 +1576,6 @@ ural_rf_write(struct ural_softc *sc, uint8_t reg, uint32_t val) DPRINTFN(15, "RF R[%u] <- 0x%05x\n", reg & 0x3, val & 0xfffff); } -/* ARGUSED */ -static struct ieee80211_node * -ural_node_alloc(struct ieee80211vap *vap __unused, - const uint8_t mac[IEEE80211_ADDR_LEN] __unused) -{ - struct ural_node *un; - - un = malloc(sizeof(struct ural_node), M_80211_NODE, M_NOWAIT | M_ZERO); - return un != NULL ? &un->ni : NULL; -} - -static void -ural_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&URAL_VAP(vap)->amrr, &URAL_NODE(ni)->amn, ni); -} - static void ural_scan_start(struct ieee80211com *ic) { @@ -2231,7 +2204,7 @@ bad: } static void -ural_amrr_start(struct ural_softc *sc, struct ieee80211_node *ni) +ural_ratectl_start(struct ural_softc *sc, struct ieee80211_node *ni) { struct ieee80211vap *vap = ni->ni_vap; struct ural_vap *uvp = URAL_VAP(vap); @@ -2239,23 +2212,23 @@ ural_amrr_start(struct ural_softc *sc, struct ieee80211_node *ni) /* clear statistic registers (STA_CSR0 to STA_CSR10) */ ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof sc->sta); - ieee80211_amrr_node_init(&uvp->amrr, &URAL_NODE(ni)->amn, ni); + ieee80211_ratectl_node_init(ni); - usb_callout_reset(&uvp->amrr_ch, hz, ural_amrr_timeout, uvp); + usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); } static void -ural_amrr_timeout(void *arg) +ural_ratectl_timeout(void *arg) { struct ural_vap *uvp = arg; struct ieee80211vap *vap = &uvp->vap; struct ieee80211com *ic = vap->iv_ic; - ieee80211_runtask(ic, &uvp->amrr_task); + ieee80211_runtask(ic, &uvp->ratectl_task); } static void -ural_amrr_task(void *arg, int pending) +ural_ratectl_task(void *arg, int pending) { struct ural_vap *uvp = arg; struct ieee80211vap *vap = &uvp->vap; @@ -2264,6 +2237,7 @@ ural_amrr_task(void *arg, int pending) struct ural_softc *sc = ifp->if_softc; struct ieee80211_node *ni = vap->iv_bss; int ok, fail; + int sum, retrycnt; RAL_LOCK(sc); /* read and clear statistic registers (STA_CSR0 to STA_CSR10) */ @@ -2272,14 +2246,15 @@ ural_amrr_task(void *arg, int pending) ok = sc->sta[7] + /* TX ok w/o retry */ sc->sta[8]; /* TX ok w/ retry */ fail = sc->sta[9]; /* TX retry-fail count */ + sum = ok+fail; + retrycnt = sc->sta[8] + fail; - ieee80211_amrr_tx_update(&URAL_NODE(ni)->amn, - ok+fail, ok, sc->sta[8] + fail); - (void) ieee80211_amrr_choose(ni, &URAL_NODE(ni)->amn); + ieee80211_ratectl_tx_update(vap, ni, &sum, &ok, &retrycnt); + (void) ieee80211_ratectl_rate(ni, NULL, 0); ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */ - usb_callout_reset(&uvp->amrr_ch, hz, ural_amrr_timeout, uvp); + usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); RAL_UNLOCK(sc); } diff --git a/sys/dev/usb/wlan/if_uralvar.h b/sys/dev/usb/wlan/if_uralvar.h index 5d9c582..46dbfbd 100644 --- a/sys/dev/usb/wlan/if_uralvar.h +++ b/sys/dev/usb/wlan/if_uralvar.h @@ -71,18 +71,11 @@ struct ural_tx_data { }; typedef STAILQ_HEAD(, ural_tx_data) ural_txdhead; -struct ural_node { - struct ieee80211_node ni; - struct ieee80211_amrr_node amn; -}; -#define URAL_NODE(ni) ((struct ural_node *)(ni)) - struct ural_vap { struct ieee80211vap vap; struct ieee80211_beacon_offsets bo; - struct ieee80211_amrr amrr; - struct usb_callout amrr_ch; - struct task amrr_task; + struct usb_callout ratectl_ch; + struct task ratectl_task; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 6604268..2b20a62 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/wlan/if_urtwvar.h> SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); +#define URTW_DEBUG #ifdef URTW_DEBUG int urtw_debug = 0; SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RW, &urtw_debug, 0, diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index 724bfaa..ee143d6 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -125,8 +125,6 @@ static void zyd_vap_delete(struct ieee80211vap *); static void zyd_tx_free(struct zyd_tx_data *, int); static void zyd_setup_tx_list(struct zyd_softc *); static void zyd_unsetup_tx_list(struct zyd_softc *); -static struct ieee80211_node *zyd_node_alloc(struct ieee80211vap *, - const uint8_t mac[IEEE80211_ADDR_LEN]); static int zyd_newstate(struct ieee80211vap *, enum ieee80211_state, int); static int zyd_cmd(struct zyd_softc *, uint16_t, const void *, int, void *, int, int); @@ -163,7 +161,6 @@ static void zyd_init_locked(struct zyd_softc *); static void zyd_init(void *); static void zyd_stop(struct zyd_softc *); static int zyd_loadfirmware(struct zyd_softc *); -static void zyd_newassoc(struct ieee80211_node *, int); static void zyd_scan_start(struct ieee80211com *); static void zyd_scan_end(struct ieee80211com *); static void zyd_set_channel(struct ieee80211com *); @@ -408,9 +405,7 @@ zyd_attach(device_t dev) ieee80211_init_channels(ic, NULL, &bands); ieee80211_ifattach(ic, sc->sc_bssid); - ic->ic_newassoc = zyd_newassoc; ic->ic_raw_xmit = zyd_raw_xmit; - ic->ic_node_alloc = zyd_node_alloc; ic->ic_scan_start = zyd_scan_start; ic->ic_scan_end = zyd_scan_end; ic->ic_set_channel = zyd_set_channel; @@ -483,10 +478,8 @@ zyd_vap_create(struct ieee80211com *ic, zvp->newstate = vap->iv_newstate; vap->iv_newstate = zyd_newstate; - ieee80211_amrr_init(&zvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 1000 /* 1 sec */); + ieee80211_ratectl_init(vap); + ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, @@ -500,7 +493,7 @@ zyd_vap_delete(struct ieee80211vap *vap) { struct zyd_vap *zvp = ZYD_VAP(vap); - ieee80211_amrr_cleanup(&zvp->amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(zvp, M_80211_VAP); } @@ -518,8 +511,8 @@ zyd_tx_free(struct zyd_tx_data *data, int txerr) data->m = NULL; if (txerr == 0) - ieee80211_amrr_tx_complete(&ZYD_NODE(data->ni)->amn, - IEEE80211_AMRR_SUCCESS, 0); + ieee80211_ratectl_tx_complete(data->ni->ni_vap, + data->ni, IEEE80211_RATECTL_TX_SUCCESS, NULL, NULL); ieee80211_free_node(data->ni); data->ni = NULL; } @@ -572,17 +565,6 @@ zyd_unsetup_tx_list(struct zyd_softc *sc) } } -/* ARGUSED */ -static struct ieee80211_node * -zyd_node_alloc(struct ieee80211vap *vap __unused, - const uint8_t mac[IEEE80211_ADDR_LEN] __unused) -{ - struct zyd_node *zn; - - zn = malloc(sizeof(struct zyd_node), M_80211_NODE, M_NOWAIT | M_ZERO); - return (zn != NULL) ? (&zn->ni) : (NULL); -} - static int zyd_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { @@ -669,9 +651,12 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error) */ ni = ieee80211_find_txnode(vap, retry->macaddr); if (ni != NULL) { - ieee80211_amrr_tx_complete(&ZYD_NODE(ni)->amn, - IEEE80211_AMRR_FAILURE, - (int)(le16toh(retry->count) & 0xff)); + int retrycnt = + (int)(le16toh(retry->count) & 0xff); + + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_FAILURE, + &retrycnt, NULL); ieee80211_free_node(ni); } if (le16toh(retry->count) & 0x100) @@ -2498,7 +2483,7 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = tp->ucastrate; else { - (void) ieee80211_amrr_choose(ni, &ZYD_NODE(ni)->amn); + (void) ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; } } @@ -2910,14 +2895,6 @@ zyd_loadfirmware(struct zyd_softc *sc) } static void -zyd_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&ZYD_VAP(vap)->amrr, &ZYD_NODE(ni)->amn, ni); -} - -static void zyd_scan_start(struct ieee80211com *ic) { struct ifnet *ifp = ic->ic_ifp; @@ -2970,4 +2947,3 @@ static devclass_t zyd_devclass; DRIVER_MODULE(zyd, uhub, zyd_driver, zyd_devclass, NULL, 0); MODULE_DEPEND(zyd, usb, 1, 1, 1); MODULE_DEPEND(zyd, wlan, 1, 1, 1); -MODULE_DEPEND(zyd, wlan_amrr, 1, 1, 1); diff --git a/sys/dev/usb/wlan/if_zydreg.h b/sys/dev/usb/wlan/if_zydreg.h index 57a5e87..dd11632 100644 --- a/sys/dev/usb/wlan/if_zydreg.h +++ b/sys/dev/usb/wlan/if_zydreg.h @@ -1177,12 +1177,6 @@ struct zyd_rx_data { int rssi; }; -struct zyd_node { - struct ieee80211_node ni; /* must be the first */ - struct ieee80211_amrr_node amn; -}; -#define ZYD_NODE(ni) ((struct zyd_node *)(ni)) - struct zyd_rx_radiotap_header { struct ieee80211_radiotap_header wr_ihdr; uint8_t wr_flags; @@ -1243,7 +1237,6 @@ struct zyd_vap { struct ieee80211vap vap; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); - struct ieee80211_amrr amrr; }; #define ZYD_VAP(vap) ((struct zyd_vap *)(vap)) |