Date: Tue, 11 May 2010 11:08:16 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r207912 - in stable/8/sys: conf dev/bwi dev/bwn dev/iwn dev/ral dev/usb/wlan dev/wpi modules/wlan net80211 Message-ID: <201005111108.o4BB8GFd062635@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Tue May 11 11:08:15 2010 New Revision: 207912 URL: http://svn.freebsd.org/changeset/base/207912 Log: MFC r206367, r206358, r206370, r206371, r206372, r206398, r206415, r206416, r206417, r206418, r206418: net80211 ratectl framework. Added: stable/8/sys/net80211/ieee80211_ratectl.c - copied unchanged from r206358, head/sys/net80211/ieee80211_ratectl.c stable/8/sys/net80211/ieee80211_ratectl.h - copied, changed from r206358, head/sys/net80211/ieee80211_ratectl.h Modified: stable/8/sys/conf/files stable/8/sys/dev/bwi/if_bwi.c stable/8/sys/dev/bwi/if_bwivar.h stable/8/sys/dev/bwn/if_bwn.c stable/8/sys/dev/bwn/if_bwnvar.h stable/8/sys/dev/iwn/if_iwn.c stable/8/sys/dev/iwn/if_iwnvar.h stable/8/sys/dev/ral/rt2560.c stable/8/sys/dev/ral/rt2560var.h stable/8/sys/dev/ral/rt2661.c stable/8/sys/dev/ral/rt2661var.h stable/8/sys/dev/usb/wlan/if_rum.c stable/8/sys/dev/usb/wlan/if_rumvar.h stable/8/sys/dev/usb/wlan/if_run.c stable/8/sys/dev/usb/wlan/if_runvar.h stable/8/sys/dev/usb/wlan/if_ural.c stable/8/sys/dev/usb/wlan/if_uralvar.h stable/8/sys/dev/usb/wlan/if_urtw.c stable/8/sys/dev/usb/wlan/if_zyd.c stable/8/sys/dev/usb/wlan/if_zydreg.h stable/8/sys/dev/wpi/if_wpi.c stable/8/sys/dev/wpi/if_wpivar.h stable/8/sys/modules/wlan/Makefile stable/8/sys/net80211/ieee80211.c stable/8/sys/net80211/ieee80211_amrr.c stable/8/sys/net80211/ieee80211_amrr.h stable/8/sys/net80211/ieee80211_freebsd.h stable/8/sys/net80211/ieee80211_node.c stable/8/sys/net80211/ieee80211_node.h stable/8/sys/net80211/ieee80211_rssadapt.c stable/8/sys/net80211/ieee80211_rssadapt.h stable/8/sys/net80211/ieee80211_var.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/conf/files Tue May 11 11:08:15 2010 (r207912) @@ -2370,6 +2370,7 @@ net80211/ieee80211_phy.c optional wlan net80211/ieee80211_power.c optional wlan net80211/ieee80211_proto.c optional wlan net80211/ieee80211_radiotap.c optional wlan +net80211/ieee80211_ratectl.c optional wlan net80211/ieee80211_regdomain.c optional wlan net80211/ieee80211_rssadapt.c optional wlan wlan_rssadapt net80211/ieee80211_scan.c optional wlan Modified: stable/8/sys/dev/bwi/if_bwi.c ============================================================================== --- stable/8/sys/dev/bwi/if_bwi.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/bwi/if_bwi.c Tue May 11 11:08:15 2010 (r207912) @@ -64,8 +64,8 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> -#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_phy.h> +#include <net80211/ieee80211_ratectl.h> #include <net/bpf.h> @@ -112,9 +112,6 @@ static void bwi_set_channel(struct ieee8 static void bwi_scan_end(struct ieee80211com *); static int bwi_newstate(struct ieee80211vap *, enum ieee80211_state, int); static void bwi_updateslot(struct ifnet *); -static struct ieee80211_node *bwi_node_alloc(struct ieee80211vap *, - const uint8_t [IEEE80211_ADDR_LEN]); -static void bwi_newassoc(struct ieee80211_node *, int); static int bwi_media_change(struct ifnet *); static void bwi_calibrate(void *); @@ -525,7 +522,6 @@ bwi_attach(struct bwi_softc *sc) ic->ic_vap_delete = bwi_vap_delete; ic->ic_raw_xmit = bwi_raw_xmit; ic->ic_updateslot = bwi_updateslot; - ic->ic_node_alloc = bwi_node_alloc; ic->ic_scan_start = bwi_scan_start; ic->ic_scan_end = bwi_scan_end; ic->ic_set_channel = bwi_set_channel; @@ -620,10 +616,7 @@ bwi_vap_create(struct ieee80211com *ic, #if 0 vap->iv_update_beacon = bwi_beacon_update; #endif - ieee80211_amrr_init(&bvp->bv_amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /*ms*/); + ieee80211_ratectl_init(vap); /* complete setup */ ieee80211_vap_attach(vap, bwi_media_change, ieee80211_media_status); @@ -636,7 +629,7 @@ bwi_vap_delete(struct ieee80211vap *vap) { struct bwi_vap *bvp = BWI_VAP(vap); - ieee80211_amrr_cleanup(&bvp->bv_amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(bvp, M_80211_VAP); } @@ -1826,7 +1819,7 @@ bwi_newstate(struct ieee80211vap *vap, e #endif if (vap->iv_opmode == IEEE80211_M_STA) { /* fake a join to init the tx rate */ - bwi_newassoc(ni, 1); + ic->ic_newassoc(ni, 1); } callout_reset(&sc->sc_calib_ch, hz, bwi_calibrate, sc); @@ -1837,25 +1830,6 @@ back: return error; } -/* ARGUSED */ -static struct ieee80211_node * -bwi_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) -{ - struct bwi_node *bn; - - bn = malloc(sizeof(struct bwi_node), M_80211_NODE, M_NOWAIT | M_ZERO); - return bn != NULL ? &bn->ni : NULL; -} - -static void -bwi_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&BWI_VAP(vap)->bv_amrr, - &BWI_NODE(ni)->amn, ni); -} - static int bwi_media_change(struct ifnet *ifp) { @@ -3007,7 +2981,7 @@ bwi_encap(struct bwi_softc *sc, int idx, } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = rate_fb = tp->ucastrate; } else { - rix = ieee80211_amrr_choose(ni, &BWI_NODE(ni)->amn); + rix = ieee80211_ratectl_rate(ni, NULL, pkt_len); rate = ni->ni_txrate; if (rix > 0) { @@ -3364,6 +3338,7 @@ _bwi_txeof(struct bwi_softc *sc, uint16_ struct bwi_txbuf *tb; int ring_idx, buf_idx; struct ieee80211_node *ni; + struct ieee80211vap *vap; if (tx_id == 0) { if_printf(ifp, "%s: zero tx id\n", __func__); @@ -3389,9 +3364,9 @@ _bwi_txeof(struct bwi_softc *sc, uint16_ ni = tb->tb_ni; if (tb->tb_ni != NULL) { - struct bwi_node *bn = (struct bwi_node *) tb->tb_ni; const struct bwi_txbuf_hdr *hdr = mtod(tb->tb_mbuf, const struct bwi_txbuf_hdr *); + vap = ni->ni_vap; /* NB: update rate control only for unicast frames */ if (hdr->txh_mac_ctrl & htole32(BWI_TXH_MAC_C_ACK)) { @@ -3402,8 +3377,9 @@ _bwi_txeof(struct bwi_softc *sc, uint16_ * well so to avoid over-aggressive downshifting we * treat any number of retries as "1". */ - ieee80211_amrr_tx_complete(&bn->amn, acked, - data_txcnt > 1); + ieee80211_ratectl_tx_complete(vap, ni, + (data_txcnt > 1) ? IEEE80211_RATECTL_TX_SUCCESS : + IEEE80211_RATECTL_TX_FAILURE, &acked, NULL); } /* Modified: stable/8/sys/dev/bwi/if_bwivar.h ============================================================================== --- stable/8/sys/dev/bwi/if_bwivar.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/bwi/if_bwivar.h Tue May 11 11:08:15 2010 (r207912) @@ -533,15 +533,8 @@ struct bwi_rx_radiotap_hdr { /* TODO: sq */ }; -struct bwi_node { - struct ieee80211_node ni; /* must be the first */ - struct ieee80211_amrr_node amn; -}; -#define BWI_NODE(ni) ((struct bwi_node *)(ni)) - struct bwi_vap { struct ieee80211vap bv_vap; - struct ieee80211_amrr bv_amrr; int (*bv_newstate)(struct ieee80211vap *, enum ieee80211_state, int); }; Modified: stable/8/sys/dev/bwn/if_bwn.c ============================================================================== --- stable/8/sys/dev/bwn/if_bwn.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/bwn/if_bwn.c Tue May 11 11:08:15 2010 (r207912) @@ -67,8 +67,8 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> -#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_phy.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/bwn/if_bwnreg.h> #include <dev/bwn/if_bwnvar.h> @@ -180,18 +180,14 @@ static void bwn_addchannels(struct ieee8 const struct bwn_channelinfo *, int); static int bwn_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); -static void bwn_newassoc(struct ieee80211_node *, int); static void bwn_updateslot(struct ifnet *); static void bwn_update_promisc(struct ifnet *); static void bwn_wme_init(struct bwn_mac *); static int bwn_wme_update(struct ieee80211com *); -static struct ieee80211_node *bwn_node_alloc(struct ieee80211vap *, - const uint8_t [IEEE80211_ADDR_LEN]); static void bwn_wme_clear(struct bwn_softc *); static void bwn_wme_load(struct bwn_mac *); static void bwn_wme_loadparams(struct bwn_mac *, const struct wmeParams *, uint16_t); -static void bwn_node_cleanup(struct ieee80211_node *); static void bwn_scan_start(struct ieee80211com *); static void bwn_scan_end(struct ieee80211com *); static void bwn_set_channel(struct ieee80211com *); @@ -1088,15 +1084,10 @@ bwn_attach_post(struct bwn_softc *sc) /* override default methods */ ic->ic_raw_xmit = bwn_raw_xmit; - ic->ic_newassoc = bwn_newassoc; ic->ic_updateslot = bwn_updateslot; ic->ic_update_promisc = bwn_update_promisc; ic->ic_wme.wme_update = bwn_wme_update; - ic->ic_node_alloc = bwn_node_alloc; - sc->sc_node_cleanup = ic->ic_node_cleanup; - ic->ic_node_cleanup = bwn_node_cleanup; - ic->ic_scan_start = bwn_scan_start; ic->ic_scan_end = bwn_scan_end; ic->ic_set_channel = bwn_set_channel; @@ -2772,20 +2763,6 @@ bwn_raw_xmit(struct ieee80211_node *ni, } /* - * Setup driver-specific state for a newly associated node. - * Note that we're called also on a re-associate, the isnew - * param tells us if this is the first time or not. - */ -static void -bwn_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&BWN_VAP(vap)->bv_amrr, - &BWN_NODE(ni)->bn_amn, ni); -} - -/* * Callback from the 802.11 layer to update the slot time * based on the current setting. We use it to notify the * firmware of ERP changes and the f/w takes care of things @@ -2857,32 +2834,6 @@ bwn_wme_update(struct ieee80211com *ic) return (0); } -static struct ieee80211_node * -bwn_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) -{ - struct ieee80211com *ic = vap->iv_ic; - struct bwn_softc *sc = ic->ic_ifp->if_softc; - const size_t space = sizeof(struct bwn_node); - struct bwn_node *bn; - - bn = malloc(space, M_80211_NODE, M_NOWAIT|M_ZERO); - if (bn == NULL) { - /* XXX stat+msg */ - return (NULL); - } - DPRINTF(sc, BWN_DEBUG_NODE, "%s: bn %p\n", __func__, bn); - return (&bn->bn_node); -} - -static void -bwn_node_cleanup(struct ieee80211_node *ni) -{ - struct ieee80211com *ic = ni->ni_ic; - struct bwn_softc *sc = ic->ic_ifp->if_softc; - - sc->sc_node_cleanup(ni); -} - static void bwn_scan_start(struct ieee80211com *ic) { @@ -3018,10 +2969,7 @@ bwn_vap_create(struct ieee80211com *ic, /* override max aid so sta's cannot assoc when we're out of sta id's */ vap->iv_max_aid = BWN_STAID_MAX; - ieee80211_amrr_init(&bvp->bv_amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /*ms*/); + ieee80211_ratectl_init(vap); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, @@ -3034,7 +2982,7 @@ bwn_vap_delete(struct ieee80211vap *vap) { struct bwn_vap *bvp = BWN_VAP(vap); - ieee80211_amrr_cleanup(&bvp->bv_amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(bvp, M_80211_VAP); } @@ -9040,12 +8988,12 @@ bwn_handle_txeof(struct bwn_mac *mac, co struct bwn_dma_ring *dr; struct bwn_dmadesc_generic *desc; struct bwn_dmadesc_meta *meta; - struct bwn_node *bn; struct bwn_pio_txqueue *tq; struct bwn_pio_txpkt *tp = NULL; struct bwn_softc *sc = mac->mac_sc; struct bwn_stats *stats = &mac->mac_stats; struct ieee80211_node *ni; + struct ieee80211vap *vap; int slot; BWN_ASSERT_LOCKED(mac->mac_sc); @@ -9074,9 +9022,12 @@ bwn_handle_txeof(struct bwn_mac *mac, co dr->getdesc(dr, slot, &desc, &meta); if (meta->mt_islast) { ni = meta->mt_ni; - bn = (struct bwn_node *)ni; - ieee80211_amrr_tx_complete(&bn->bn_amn, - status->ack, 0); + vap = ni->ni_vap; + ieee80211_ratectl_tx_complete(vap, ni, + status->ack ? + IEEE80211_RATECTL_TX_SUCCESS : + IEEE80211_RATECTL_TX_FAILURE, + NULL, 0); break; } slot = bwn_dma_nextslot(dr, slot); @@ -9092,8 +9043,12 @@ bwn_handle_txeof(struct bwn_mac *mac, co return; } ni = tp->tp_ni; - bn = (struct bwn_node *)ni; - ieee80211_amrr_tx_complete(&bn->bn_amn, status->ack, 0); + vap = ni->ni_vap; + ieee80211_ratectl_tx_complete(vap, ni, + status->ack ? + IEEE80211_RATECTL_TX_SUCCESS : + IEEE80211_RATECTL_TX_FAILURE, + NULL, 0); } bwn_pio_handle_txeof(mac, status); } @@ -9680,7 +9635,7 @@ bwn_set_txhdr(struct bwn_mac *mac, struc else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = rate_fb = tp->ucastrate; else { - rix = ieee80211_amrr_choose(ni, &BWN_NODE(ni)->bn_amn); + rix = ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; if (rix > 0) Modified: stable/8/sys/dev/bwn/if_bwnvar.h ============================================================================== --- stable/8/sys/dev/bwn/if_bwnvar.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/bwn/if_bwnvar.h Tue May 11 11:08:15 2010 (r207912) @@ -883,18 +883,11 @@ struct bwn_mac { TAILQ_ENTRY(bwn_mac) mac_list; }; -struct bwn_node { - struct ieee80211_node bn_node; /* must be the first */ - struct ieee80211_amrr_node bn_amn; -}; -#define BWN_NODE(ni) ((struct bwn_node *)(ni)) - /* * Driver-specific vap state. */ struct bwn_vap { struct ieee80211vap bv_vap; /* base class */ - struct ieee80211_amrr bv_amrr; int (*bv_newstate)(struct ieee80211vap *, enum ieee80211_state, int); }; Modified: stable/8/sys/dev/iwn/if_iwn.c ============================================================================== --- stable/8/sys/dev/iwn/if_iwn.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/iwn/if_iwn.c Tue May 11 11:08:15 2010 (r207912) @@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$"); #include <netinet/ip.h> #include <net80211/ieee80211_var.h> -#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> +#include <net80211/ieee80211_ratectl.h> #include <dev/iwn/if_iwnreg.h> #include <dev/iwn/if_iwnvar.h> @@ -785,11 +785,7 @@ iwn_vap_create(struct ieee80211com *ic, ivp->iv_newstate = vap->iv_newstate; vap->iv_newstate = iwn_newstate; - ieee80211_amrr_init(&ivp->iv_amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /* ms */); - + ieee80211_ratectl_init(vap); /* Complete setup. */ ieee80211_vap_attach(vap, iwn_media_change, ieee80211_media_status); ic->ic_opmode = opmode; @@ -801,7 +797,7 @@ iwn_vap_delete(struct ieee80211vap *vap) { struct iwn_vap *ivp = IWN_VAP(vap); - ieee80211_amrr_cleanup(&ivp->iv_amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(ivp, M_80211_VAP); } @@ -1897,11 +1893,8 @@ iwn_node_alloc(struct ieee80211vap *vap, static void iwn_newassoc(struct ieee80211_node *ni, int isnew) { - struct ieee80211vap *vap = ni->ni_vap; - struct iwn_node *wn = (void *)ni; - - ieee80211_amrr_node_init(&IWN_VAP(vap)->iv_amrr, - &wn->amn, ni); + /* XXX move */ + ieee80211_ratectl_node_init(ni); } static int @@ -2333,9 +2326,9 @@ iwn_tx_done(struct iwn_softc *sc, struct struct ifnet *ifp = sc->sc_ifp; struct iwn_tx_ring *ring = &sc->txq[desc->qid & 0xf]; struct iwn_tx_data *data = &ring->data[desc->idx]; - struct iwn_node *wn = (void *)data->ni; struct mbuf *m; struct ieee80211_node *ni; + struct ieee80211vap *vap; KASSERT(data->ni != NULL, ("no node")); @@ -2344,6 +2337,7 @@ iwn_tx_done(struct iwn_softc *sc, struct bus_dmamap_unload(ring->data_dmat, data->map); m = data->m, data->m = NULL; ni = data->ni, data->ni = NULL; + vap = ni->ni_vap; if (m->m_flags & M_TXCB) { /* @@ -2373,11 +2367,11 @@ iwn_tx_done(struct iwn_softc *sc, struct */ if (status & 0x80) { ifp->if_oerrors++; - ieee80211_amrr_tx_complete(&wn->amn, - IEEE80211_AMRR_FAILURE, ackfailcnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); } else { - ieee80211_amrr_tx_complete(&wn->amn, - IEEE80211_AMRR_SUCCESS, ackfailcnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); } m_freem(m); ieee80211_free_node(ni); @@ -2897,7 +2891,8 @@ iwn_tx_data(struct iwn_softc *sc, struct else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = tp->ucastrate; else { - (void) ieee80211_amrr_choose(ni, &wn->amn); + /* XXX pass pktlen */ + (void) ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; } ridx = iwn_plcp_signal(rate); @@ -6480,4 +6475,3 @@ DRIVER_MODULE(iwn, pci, iwn_driver, iwn_ MODULE_DEPEND(iwn, pci, 1, 1, 1); MODULE_DEPEND(iwn, firmware, 1, 1, 1); MODULE_DEPEND(iwn, wlan, 1, 1, 1); -MODULE_DEPEND(iwn, wlan_amrr, 1, 1, 1); Modified: stable/8/sys/dev/iwn/if_iwnvar.h ============================================================================== --- stable/8/sys/dev/iwn/if_iwnvar.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/iwn/if_iwnvar.h Tue May 11 11:08:15 2010 (r207912) @@ -99,7 +99,6 @@ struct iwn_rx_ring { struct iwn_node { struct ieee80211_node ni; /* must be the first */ - struct ieee80211_amrr_node amn; uint16_t disable_tid; uint8_t id; uint8_t ridx[IEEE80211_RATE_MAXSIZE]; @@ -193,8 +192,6 @@ struct iwn_hal { struct iwn_vap { struct ieee80211vap iv_vap; - struct ieee80211_amrr iv_amrr; - struct callout iv_amrr_to; uint8_t iv_ridx; int (*iv_newstate)(struct ieee80211vap *, Modified: stable/8/sys/dev/ral/rt2560.c ============================================================================== --- stable/8/sys/dev/ral/rt2560.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/ral/rt2560.c Tue May 11 11:08:15 2010 (r207912) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -103,8 +103,6 @@ static void rt2560_reset_rx_ring(struct struct rt2560_rx_ring *); static void rt2560_free_rx_ring(struct rt2560_softc *, struct rt2560_rx_ring *); -static struct ieee80211_node *rt2560_node_alloc(struct ieee80211vap *, - const uint8_t [IEEE80211_ADDR_LEN]); static void rt2560_newassoc(struct ieee80211_node *, int); static int rt2560_newstate(struct ieee80211vap *, enum ieee80211_state, int); @@ -307,7 +305,6 @@ rt2560_attach(device_t dev, int id) ic->ic_raw_xmit = rt2560_raw_xmit; ic->ic_updateslot = rt2560_update_slot; ic->ic_update_promisc = rt2560_update_promisc; - ic->ic_node_alloc = rt2560_node_alloc; ic->ic_scan_start = rt2560_scan_start; ic->ic_scan_end = rt2560_scan_end; ic->ic_set_channel = rt2560_set_channel; @@ -430,11 +427,7 @@ rt2560_vap_create(struct ieee80211com *i vap->iv_newstate = rt2560_newstate; vap->iv_update_beacon = rt2560_beacon_update; - ieee80211_amrr_init(&rvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /* ms */); - + ieee80211_ratectl_init(vap); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); if (TAILQ_FIRST(&ic->ic_vaps) == vap) @@ -447,7 +440,7 @@ rt2560_vap_delete(struct ieee80211vap *v { struct rt2560_vap *rvp = RT2560_VAP(vap); - ieee80211_amrr_cleanup(&rvp->amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(rvp, M_80211_VAP); } @@ -764,25 +757,11 @@ rt2560_free_rx_ring(struct rt2560_softc bus_dma_tag_destroy(ring->data_dmat); } -static struct ieee80211_node * -rt2560_node_alloc(struct ieee80211vap *vap, - const uint8_t mac[IEEE80211_ADDR_LEN]) -{ - struct rt2560_node *rn; - - rn = malloc(sizeof (struct rt2560_node), M_80211_NODE, - M_NOWAIT | M_ZERO); - - return (rn != NULL) ? &rn->ni : NULL; -} - static void rt2560_newassoc(struct ieee80211_node *ni, int isnew) { - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&RT2560_VAP(vap)->amrr, - &RT2560_NODE(ni)->amrr, ni); + /* XXX move */ + ieee80211_ratectl_node_init(ni); } static int @@ -955,10 +934,11 @@ rt2560_tx_intr(struct rt2560_softc *sc) struct ifnet *ifp = sc->sc_ifp; struct rt2560_tx_desc *desc; struct rt2560_tx_data *data; - struct rt2560_node *rn; struct mbuf *m; uint32_t flags; int retrycnt; + struct ieee80211vap *vap; + struct ieee80211_node *ni; bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map, BUS_DMASYNC_POSTREAD); @@ -973,15 +953,19 @@ rt2560_tx_intr(struct rt2560_softc *sc) !(flags & RT2560_TX_VALID)) break; - rn = (struct rt2560_node *)data->ni; m = data->m; + ni = data->ni; + vap = ni->ni_vap; switch (flags & RT2560_TX_RESULT_MASK) { case RT2560_TX_SUCCESS: + retrycnt = 0; + DPRINTFN(sc, 10, "%s\n", "data frame sent successfully"); if (data->rix != IEEE80211_FIXED_RATE_NONE) - ieee80211_amrr_tx_complete(&rn->amrr, - IEEE80211_AMRR_SUCCESS, 0); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); ifp->if_opackets++; break; @@ -991,8 +975,9 @@ rt2560_tx_intr(struct rt2560_softc *sc) DPRINTFN(sc, 9, "data frame sent after %u retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) - ieee80211_amrr_tx_complete(&rn->amrr, - IEEE80211_AMRR_SUCCESS, retrycnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); ifp->if_opackets++; break; @@ -1002,8 +987,9 @@ rt2560_tx_intr(struct rt2560_softc *sc) DPRINTFN(sc, 9, "data frame failed after %d retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) - ieee80211_amrr_tx_complete(&rn->amrr, - IEEE80211_AMRR_FAILURE, retrycnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_FAILURE, + &retrycnt, NULL); ifp->if_oerrors++; break; @@ -1821,7 +1807,7 @@ rt2560_tx_data(struct rt2560_softc *sc, } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = tp->ucastrate; } else { - (void) ieee80211_amrr_choose(ni, &RT2560_NODE(ni)->amrr); + (void) ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; } Modified: stable/8/sys/dev/ral/rt2560var.h ============================================================================== --- stable/8/sys/dev/ral/rt2560var.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/ral/rt2560var.h Tue May 11 11:08:15 2010 (r207912) @@ -95,16 +95,9 @@ struct rt2560_rx_ring { int cur_decrypt; }; -struct rt2560_node { - struct ieee80211_node ni; - struct ieee80211_amrr_node amrr; -}; -#define RT2560_NODE(ni) ((struct rt2560_node *)(ni)) - struct rt2560_vap { struct ieee80211vap ral_vap; struct ieee80211_beacon_offsets ral_bo; - struct ieee80211_amrr amrr; int (*ral_newstate)(struct ieee80211vap *, enum ieee80211_state, int); Modified: stable/8/sys/dev/ral/rt2661.c ============================================================================== --- stable/8/sys/dev/ral/rt2661.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/ral/rt2661.c Tue May 11 11:08:15 2010 (r207912) @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> -#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_ratectl.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -100,8 +100,6 @@ static void rt2661_reset_rx_ring(struct struct rt2661_rx_ring *); static void rt2661_free_rx_ring(struct rt2661_softc *, struct rt2661_rx_ring *); -static struct ieee80211_node *rt2661_node_alloc(struct ieee80211vap *, - const uint8_t [IEEE80211_ADDR_LEN]); static void rt2661_newassoc(struct ieee80211_node *, int); static int rt2661_newstate(struct ieee80211vap *, enum ieee80211_state, int); @@ -307,7 +305,6 @@ rt2661_attach(device_t dev, int id) ieee80211_ifattach(ic, macaddr); ic->ic_newassoc = rt2661_newassoc; - ic->ic_node_alloc = rt2661_node_alloc; #if 0 ic->ic_wme.wme_update = rt2661_wme_update; #endif @@ -428,11 +425,7 @@ rt2661_vap_create(struct ieee80211com *i vap->iv_update_beacon = rt2661_beacon_update; #endif - ieee80211_amrr_init(&rvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /* ms */); - + ieee80211_ratectl_init(vap); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); if (TAILQ_FIRST(&ic->ic_vaps) == vap) @@ -445,7 +438,7 @@ rt2661_vap_delete(struct ieee80211vap *v { struct rt2661_vap *rvp = RT2661_VAP(vap); - ieee80211_amrr_cleanup(&rvp->amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(rvp, M_80211_VAP); } @@ -771,25 +764,11 @@ rt2661_free_rx_ring(struct rt2661_softc bus_dma_tag_destroy(ring->data_dmat); } -static struct ieee80211_node * -rt2661_node_alloc(struct ieee80211vap *vap, - const uint8_t mac[IEEE80211_ADDR_LEN]) -{ - struct rt2661_node *rn; - - rn = malloc(sizeof (struct rt2661_node), M_80211_NODE, - M_NOWAIT | M_ZERO); - - return (rn != NULL) ? &rn->ni : NULL; -} - static void rt2661_newassoc(struct ieee80211_node *ni, int isnew) { - struct ieee80211vap *vap = ni->ni_vap; - - ieee80211_amrr_node_init(&RT2661_VAP(vap)->amrr, - &RT2661_NODE(ni)->amrr, ni); + /* XXX move */ + ieee80211_ratectl_node_init(ni); } static int @@ -899,9 +878,9 @@ rt2661_tx_intr(struct rt2661_softc *sc) struct ifnet *ifp = sc->sc_ifp; struct rt2661_tx_ring *txq; struct rt2661_tx_data *data; - struct rt2661_node *rn; uint32_t val; int qid, retrycnt; + struct ieee80211vap *vap; for (;;) { struct ieee80211_node *ni; @@ -925,8 +904,8 @@ rt2661_tx_intr(struct rt2661_softc *sc) /* if no frame has been sent, ignore */ if (ni == NULL) continue; - - rn = RT2661_NODE(ni); + else + vap = ni->ni_vap; switch (RT2661_TX_RESULT(val)) { case RT2661_TX_SUCCESS: @@ -935,8 +914,9 @@ rt2661_tx_intr(struct rt2661_softc *sc) DPRINTFN(sc, 10, "data frame sent successfully after " "%d retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) - ieee80211_amrr_tx_complete(&rn->amrr, - IEEE80211_AMRR_SUCCESS, retrycnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); ifp->if_opackets++; break; @@ -946,8 +926,9 @@ rt2661_tx_intr(struct rt2661_softc *sc) DPRINTFN(sc, 9, "%s\n", "sending data frame failed (too much retries)"); if (data->rix != IEEE80211_FIXED_RATE_NONE) - ieee80211_amrr_tx_complete(&rn->amrr, - IEEE80211_AMRR_FAILURE, retrycnt); + ieee80211_ratectl_tx_complete(vap, ni, + IEEE80211_RATECTL_TX_FAILURE, + &retrycnt, NULL); ifp->if_oerrors++; break; @@ -1511,7 +1492,7 @@ rt2661_tx_data(struct rt2661_softc *sc, } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = tp->ucastrate; } else { - (void) ieee80211_amrr_choose(ni, &RT2661_NODE(ni)->amrr); + (void) ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; } rate &= IEEE80211_RATE_VAL; Modified: stable/8/sys/dev/ral/rt2661var.h ============================================================================== --- stable/8/sys/dev/ral/rt2661var.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/ral/rt2661var.h Tue May 11 11:08:15 2010 (r207912) @@ -88,15 +88,8 @@ struct rt2661_rx_ring { int next; }; -struct rt2661_node { - struct ieee80211_node ni; - struct ieee80211_amrr_node amrr; -}; -#define RT2661_NODE(ni) ((struct rt2661_node *)(ni)) - struct rt2661_vap { struct ieee80211vap ral_vap; - struct ieee80211_amrr amrr; int (*ral_newstate)(struct ieee80211vap *, enum ieee80211_state, int); Modified: stable/8/sys/dev/usb/wlan/if_rum.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_rum.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/usb/wlan/if_rum.c Tue May 11 11:08:15 2010 (r207912) @@ -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_de }; 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 ru 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, e 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, e /* 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, str /* 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) { Modified: stable/8/sys/dev/usb/wlan/if_rumvar.h ============================================================================== --- stable/8/sys/dev/usb/wlan/if_rumvar.h Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/usb/wlan/if_rumvar.h Tue May 11 11:08:15 2010 (r207912) @@ -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); Modified: stable/8/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_run.c Tue May 11 09:26:46 2010 (r207911) +++ stable/8/sys/dev/usb/wlan/if_run.c Tue May 11 11:08:15 2010 (r207912) @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005111108.o4BB8GFd062635>