From owner-svn-src-head@FreeBSD.ORG Wed Apr 7 15:29:14 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04516106566B; Wed, 7 Apr 2010 15:29:14 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E699F8FC0A; Wed, 7 Apr 2010 15:29:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o37FTDrI035634; Wed, 7 Apr 2010 15:29:13 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o37FTDi0035619; Wed, 7 Apr 2010 15:29:13 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <201004071529.o37FTDi0035619@svn.freebsd.org> From: Rui Paulo Date: Wed, 7 Apr 2010 15:29:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206358 - in head/sys: conf dev/bwi dev/bwn dev/iwn dev/ral dev/usb/wlan dev/wpi modules/wlan net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2010 15:29:14 -0000 Author: rpaulo Date: Wed Apr 7 15:29:13 2010 New Revision: 206358 URL: http://svn.freebsd.org/changeset/base/206358 Log: net80211 rate control framework (net80211 ratectl). This framework allows drivers to abstract the rate control algorithm and just feed the framework with the usable parameters. The rate control framework will now deal with passing the parameters to the selected algorithm. Right now we have AMRR (the default) and RSSADAPT but there's no way to select one with ifconfig, yet. The objective is to have more rate control algorithms in the net80211 stack so all drivers[0] can use it. Ideally, we'll have the well-known sample rate control algorithm in the net80211 at some point so all drivers can use it (not just ath). [0] all drivers that do rate control in software, that is. Reviewed by: bschmidt, thompsa, weyongo MFC after: 1 months Added: head/sys/net80211/ieee80211_ratectl.c (contents, props changed) head/sys/net80211/ieee80211_ratectl.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bwi/if_bwi.c head/sys/dev/bwi/if_bwivar.h head/sys/dev/bwn/if_bwn.c head/sys/dev/bwn/if_bwnvar.h head/sys/dev/iwn/if_iwn.c head/sys/dev/iwn/if_iwnvar.h head/sys/dev/ral/rt2560.c head/sys/dev/ral/rt2560var.h head/sys/dev/ral/rt2661.c head/sys/dev/ral/rt2661var.h head/sys/dev/usb/wlan/if_rum.c head/sys/dev/usb/wlan/if_rumvar.h head/sys/dev/usb/wlan/if_run.c head/sys/dev/usb/wlan/if_runvar.h head/sys/dev/usb/wlan/if_ural.c head/sys/dev/usb/wlan/if_uralvar.h head/sys/dev/usb/wlan/if_urtw.c head/sys/dev/usb/wlan/if_zyd.c head/sys/dev/usb/wlan/if_zydreg.h head/sys/dev/wpi/if_wpi.c head/sys/dev/wpi/if_wpivar.h head/sys/modules/wlan/Makefile head/sys/net80211/ieee80211.c head/sys/net80211/ieee80211_amrr.c head/sys/net80211/ieee80211_amrr.h head/sys/net80211/ieee80211_freebsd.h head/sys/net80211/ieee80211_node.c head/sys/net80211/ieee80211_node.h head/sys/net80211/ieee80211_rssadapt.c head/sys/net80211/ieee80211_rssadapt.h head/sys/net80211/ieee80211_var.h Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/conf/files Wed Apr 7 15:29:13 2010 (r206358) @@ -2380,6 +2380,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: head/sys/dev/bwi/if_bwi.c ============================================================================== --- head/sys/dev/bwi/if_bwi.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/bwi/if_bwi.c Wed Apr 7 15:29:13 2010 (r206358) @@ -64,8 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include @@ -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; @@ -621,10 +617,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); @@ -637,7 +630,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); } @@ -1831,7 +1824,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); @@ -1842,25 +1835,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) { @@ -3012,7 +2986,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) { @@ -3369,6 +3343,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__); @@ -3393,8 +3368,8 @@ _bwi_txeof(struct bwi_softc *sc, uint16_ bus_dmamap_unload(sc->sc_buf_dtag, tb->tb_dmap); ni = tb->tb_ni; + vap = ni->ni_vap; 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 *); @@ -3407,8 +3382,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: head/sys/dev/bwi/if_bwivar.h ============================================================================== --- head/sys/dev/bwi/if_bwivar.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/bwi/if_bwivar.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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: head/sys/dev/bwn/if_bwn.c ============================================================================== --- head/sys/dev/bwn/if_bwn.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/bwn/if_bwn.c Wed Apr 7 15:29:13 2010 (r206358) @@ -67,8 +67,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include @@ -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); } @@ -9678,7 +9633,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: head/sys/dev/bwn/if_bwnvar.h ============================================================================== --- head/sys/dev/bwn/if_bwnvar.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/bwn/if_bwnvar.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/iwn/if_iwn.c Wed Apr 7 15:29:13 2010 (r206358) @@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include +#include #include #include @@ -755,11 +755,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, ieee80211_media_change, ieee80211_media_status); @@ -772,7 +768,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); } @@ -1858,11 +1854,8 @@ iwn_node_alloc(struct ieee80211vap *vap, 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); } int @@ -2291,9 +2284,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")); @@ -2302,6 +2295,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) { /* @@ -2331,11 +2325,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); @@ -2851,7 +2845,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); @@ -6434,4 +6429,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: head/sys/dev/iwn/if_iwnvar.h ============================================================================== --- head/sys/dev/iwn/if_iwnvar.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/iwn/if_iwnvar.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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: head/sys/dev/ral/rt2560.c ============================================================================== --- head/sys/dev/ral/rt2560.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/ral/rt2560.c Wed Apr 7 15:29:13 2010 (r206358) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include @@ -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; @@ -1022,6 +1008,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) data->m = NULL; ieee80211_free_node(data->ni); data->ni = NULL; + ni = NULL; /* descriptor is no longer valid */ desc->flags &= ~htole32(RT2560_TX_VALID); @@ -1821,7 +1808,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: head/sys/dev/ral/rt2560var.h ============================================================================== --- head/sys/dev/ral/rt2560var.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/ral/rt2560var.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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: head/sys/dev/ral/rt2661.c ============================================================================== --- head/sys/dev/ral/rt2661.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/ral/rt2661.c Wed Apr 7 15:29:13 2010 (r206358) @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include @@ -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; @@ -921,13 +900,12 @@ rt2661_tx_intr(struct rt2661_softc *sc) data->m = NULL; ni = data->ni; data->ni = NULL; + vap = ni->ni_vap; /* if no frame has been sent, ignore */ if (ni == NULL) continue; - rn = RT2661_NODE(ni); - switch (RT2661_TX_RESULT(val)) { case RT2661_TX_SUCCESS: retrycnt = RT2661_TX_RETRYCNT(val); @@ -935,8 +913,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 +925,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 +1491,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: head/sys/dev/ral/rt2661var.h ============================================================================== --- head/sys/dev/ral/rt2661var.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/ral/rt2661var.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/usb/wlan/if_rum.c Wed Apr 7 15:29:13 2010 (r206358) @@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include @@ -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: head/sys/dev/usb/wlan/if_rumvar.h ============================================================================== --- head/sys/dev/usb/wlan/if_rumvar.h Wed Apr 7 15:19:52 2010 (r206357) +++ head/sys/dev/usb/wlan/if_rumvar.h Wed Apr 7 15:29:13 2010 (r206358) @@ -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; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***