if_run.c (205042) | if_run.c (206358) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/wlan/if_run.c 205042 2010-03-11 22:05:12Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/wlan/if_run.c 206358 2010-04-07 15:29:13Z rpaulo $ */ |
2 3/*- 4 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr> 5 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 6 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21#include <sys/cdefs.h> | 2 3/*- 4 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr> 5 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 6 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_run.c 205042 2010-03-11 22:05:12Z thompsa $"); | 22__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_run.c 206358 2010-04-07 15:29:13Z rpaulo $"); |
23 24/*- 25 * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver. 26 * http://www.ralinktech.com/ 27 */ 28 29#include <sys/param.h> 30#include <sys/sockio.h> --- 29 unchanged lines hidden (view full) --- 60#include <netinet/in_systm.h> 61#include <netinet/in_var.h> 62#include <netinet/if_ether.h> 63#include <netinet/ip.h> 64 65#include <net80211/ieee80211_var.h> 66#include <net80211/ieee80211_regdomain.h> 67#include <net80211/ieee80211_radiotap.h> | 23 24/*- 25 * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver. 26 * http://www.ralinktech.com/ 27 */ 28 29#include <sys/param.h> 30#include <sys/sockio.h> --- 29 unchanged lines hidden (view full) --- 60#include <netinet/in_systm.h> 61#include <netinet/in_var.h> 62#include <netinet/if_ether.h> 63#include <netinet/ip.h> 64 65#include <net80211/ieee80211_var.h> 66#include <net80211/ieee80211_regdomain.h> 67#include <net80211/ieee80211_radiotap.h> |
68#include <net80211/ieee80211_amrr.h> | 68#include <net80211/ieee80211_ratectl.h> |
69 70#include <dev/usb/usb.h> 71#include <dev/usb/usbdi.h> 72#include "usbdevs.h" 73 74#define USB_DEBUG_VAR run_debug 75#include <dev/usb/usb_debug.h> 76 --- 208 unchanged lines hidden (view full) --- 285 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3070) }, 286 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3072_1) }, 287 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3072_2) }, 288 { USB_VP(USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RT2870_1) }, 289 { USB_VP(USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RT2870_2) }, 290}; 291 292MODULE_DEPEND(run, wlan, 1, 1, 1); | 69 70#include <dev/usb/usb.h> 71#include <dev/usb/usbdi.h> 72#include "usbdevs.h" 73 74#define USB_DEBUG_VAR run_debug 75#include <dev/usb/usb_debug.h> 76 --- 208 unchanged lines hidden (view full) --- 285 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3070) }, 286 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3072_1) }, 287 { USB_VP(USB_VENDOR_ZINWELL, USB_PRODUCT_ZINWELL_RT3072_2) }, 288 { USB_VP(USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RT2870_1) }, 289 { USB_VP(USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RT2870_2) }, 290}; 291 292MODULE_DEPEND(run, wlan, 1, 1, 1); |
293MODULE_DEPEND(run, wlan_amrr, 1, 1, 1); | |
294MODULE_DEPEND(run, usb, 1, 1, 1); 295MODULE_DEPEND(run, firmware, 1, 1, 1); 296 297static device_probe_t run_match; 298static device_attach_t run_attach; 299static device_detach_t run_detach; 300 301static usb_callback_t run_bulk_rx_callback; --- 43 unchanged lines hidden (view full) --- 345static int run_wme_update(struct ieee80211com *); 346static void run_wme_update_cb(void *, int); 347static void run_key_update_begin(struct ieee80211vap *); 348static void run_key_update_end(struct ieee80211vap *); 349static int run_key_set(struct ieee80211vap *, const struct ieee80211_key *, 350 const uint8_t mac[IEEE80211_ADDR_LEN]); 351static int run_key_delete(struct ieee80211vap *, 352 const struct ieee80211_key *); | 293MODULE_DEPEND(run, usb, 1, 1, 1); 294MODULE_DEPEND(run, firmware, 1, 1, 1); 295 296static device_probe_t run_match; 297static device_attach_t run_attach; 298static device_detach_t run_detach; 299 300static usb_callback_t run_bulk_rx_callback; --- 43 unchanged lines hidden (view full) --- 344static int run_wme_update(struct ieee80211com *); 345static void run_wme_update_cb(void *, int); 346static void run_key_update_begin(struct ieee80211vap *); 347static void run_key_update_end(struct ieee80211vap *); 348static int run_key_set(struct ieee80211vap *, const struct ieee80211_key *, 349 const uint8_t mac[IEEE80211_ADDR_LEN]); 350static int run_key_delete(struct ieee80211vap *, 351 const struct ieee80211_key *); |
353static void run_amrr_start(struct run_softc *, struct ieee80211_node *); 354static void run_amrr_to(void *); 355static void run_amrr_cb(void *, int); | 352static void run_ratectl_start(struct run_softc *, struct ieee80211_node *); 353static void run_ratectl_to(void *); 354static void run_ratectl_cb(void *, int); |
356static void run_iter_func(void *, struct ieee80211_node *); 357static void run_newassoc(struct ieee80211_node *, int); 358static void run_rx_frame(struct run_softc *, struct mbuf *, uint32_t); 359static void run_tx_free(struct run_endpoint_queue *pq, 360 struct run_tx_data *, int); 361static void run_set_tx_desc(struct run_softc *, struct run_tx_data *, 362 uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); 363static int run_tx(struct run_softc *, struct mbuf *, --- 385 unchanged lines hidden (view full) --- 749 vap->iv_key_delete = run_key_delete; 750 vap->iv_key_set = run_key_set; 751 vap->iv_update_beacon = run_update_beacon; 752 753 /* override state transition machine */ 754 rvp->newstate = vap->iv_newstate; 755 vap->iv_newstate = run_newstate; 756 | 355static void run_iter_func(void *, struct ieee80211_node *); 356static void run_newassoc(struct ieee80211_node *, int); 357static void run_rx_frame(struct run_softc *, struct mbuf *, uint32_t); 358static void run_tx_free(struct run_endpoint_queue *pq, 359 struct run_tx_data *, int); 360static void run_set_tx_desc(struct run_softc *, struct run_tx_data *, 361 uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); 362static int run_tx(struct run_softc *, struct mbuf *, --- 385 unchanged lines hidden (view full) --- 748 vap->iv_key_delete = run_key_delete; 749 vap->iv_key_set = run_key_set; 750 vap->iv_update_beacon = run_update_beacon; 751 752 /* override state transition machine */ 753 rvp->newstate = vap->iv_newstate; 754 vap->iv_newstate = run_newstate; 755 |
757 TASK_INIT(&rvp->amrr_task, 0, run_amrr_cb, rvp); | 756 TASK_INIT(&rvp->ratectl_task, 0, run_ratectl_cb, rvp); |
758 TASK_INIT(&sc->wme_task, 0, run_wme_update_cb, ic); 759 TASK_INIT(&sc->usb_timeout_task, 0, run_usb_timeout_cb, sc); | 757 TASK_INIT(&sc->wme_task, 0, run_wme_update_cb, ic); 758 TASK_INIT(&sc->usb_timeout_task, 0, run_usb_timeout_cb, sc); |
760 callout_init((struct callout *)&rvp->amrr_ch, 1); 761 ieee80211_amrr_init(&rvp->amrr, vap, 762 IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, 763 IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, 764 1000 /* 1 sec */); | 759 callout_init((struct callout *)&rvp->ratectl_ch, 1); 760 ieee80211_ratectl_init(vap); 761 ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); |
765 766 /* complete setup */ 767 ieee80211_vap_attach(vap, run_media_change, ieee80211_media_status); 768 ic->ic_opmode = opmode; 769 return vap; 770} 771 772static void --- 8 unchanged lines hidden (view full) --- 781 return; 782 783 ic = vap->iv_ic; 784 ifp = ic->ic_ifp; 785 786 sc = ifp->if_softc; 787 788 RUN_LOCK(sc); | 762 763 /* complete setup */ 764 ieee80211_vap_attach(vap, run_media_change, ieee80211_media_status); 765 ic->ic_opmode = opmode; 766 return vap; 767} 768 769static void --- 8 unchanged lines hidden (view full) --- 778 return; 779 780 ic = vap->iv_ic; 781 ifp = ic->ic_ifp; 782 783 sc = ifp->if_softc; 784 785 RUN_LOCK(sc); |
789 sc->sc_rvp->amrr_run = RUN_AMRR_OFF; | 786 sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; |
790 RUN_UNLOCK(sc); 791 792 /* drain them all */ | 787 RUN_UNLOCK(sc); 788 789 /* drain them all */ |
793 usb_callout_drain(&sc->sc_rvp->amrr_ch); 794 ieee80211_draintask(ic, &sc->sc_rvp->amrr_task); | 790 usb_callout_drain(&sc->sc_rvp->ratectl_ch); 791 ieee80211_draintask(ic, &sc->sc_rvp->ratectl_task); |
795 ieee80211_draintask(ic, &sc->wme_task); 796 ieee80211_draintask(ic, &sc->usb_timeout_task); 797 | 792 ieee80211_draintask(ic, &sc->wme_task); 793 ieee80211_draintask(ic, &sc->usb_timeout_task); 794 |
798 ieee80211_amrr_cleanup(&rvp->amrr); | 795 ieee80211_ratectl_deinit(vap); |
799 ieee80211_vap_detach(vap); 800 free(rvp, M_80211_VAP); 801 sc->sc_rvp = NULL; 802} 803 804static void 805run_setup_tx_list(struct run_softc *sc, struct run_endpoint_queue *pq) 806{ --- 820 unchanged lines hidden (view full) --- 1627 ostate = vap->iv_state; 1628 DPRINTF("%s -> %s\n", 1629 ieee80211_state_name[ostate], 1630 ieee80211_state_name[nstate]); 1631 1632 IEEE80211_UNLOCK(ic); 1633 RUN_LOCK(sc); 1634 | 796 ieee80211_vap_detach(vap); 797 free(rvp, M_80211_VAP); 798 sc->sc_rvp = NULL; 799} 800 801static void 802run_setup_tx_list(struct run_softc *sc, struct run_endpoint_queue *pq) 803{ --- 820 unchanged lines hidden (view full) --- 1624 ostate = vap->iv_state; 1625 DPRINTF("%s -> %s\n", 1626 ieee80211_state_name[ostate], 1627 ieee80211_state_name[nstate]); 1628 1629 IEEE80211_UNLOCK(ic); 1630 RUN_LOCK(sc); 1631 |
1635 sc->sc_rvp->amrr_run = RUN_AMRR_OFF; 1636 usb_callout_stop(&rvp->amrr_ch); | 1632 sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; 1633 usb_callout_stop(&rvp->ratectl_ch); |
1637 1638 if (ostate == IEEE80211_S_RUN) { 1639 /* turn link LED off */ 1640 run_set_leds(sc, RT2860_LED_RADIO); 1641 } 1642 1643 switch (nstate) { 1644 case IEEE80211_S_INIT: --- 31 unchanged lines hidden (view full) --- 1676 1677 if (vap->iv_opmode != IEEE80211_M_MONITOR) { 1678 run_enable_tsf_sync(sc); 1679 } /* else tsf */ 1680 1681 /* enable automatic rate adaptation */ 1682 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; 1683 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) | 1634 1635 if (ostate == IEEE80211_S_RUN) { 1636 /* turn link LED off */ 1637 run_set_leds(sc, RT2860_LED_RADIO); 1638 } 1639 1640 switch (nstate) { 1641 case IEEE80211_S_INIT: --- 31 unchanged lines hidden (view full) --- 1673 1674 if (vap->iv_opmode != IEEE80211_M_MONITOR) { 1675 run_enable_tsf_sync(sc); 1676 } /* else tsf */ 1677 1678 /* enable automatic rate adaptation */ 1679 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; 1680 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) |
1684 run_amrr_start(sc, ni); | 1681 run_ratectl_start(sc, ni); |
1685 1686 /* turn link LED on */ 1687 run_set_leds(sc, RT2860_LED_RADIO | 1688 (IEEE80211_IS_CHAN_2GHZ(vap->iv_bss->ni_chan) ? 1689 RT2860_LED_LINK_2GHZ : RT2860_LED_LINK_5GHZ)); 1690 1691 break; 1692 default: --- 263 unchanged lines hidden (view full) --- 1956 IEEE80211_LOCK(ic); 1957 if(nislocked) 1958 IEEE80211_NODE_LOCK(nt); 1959 1960 return (error? 0 : 1); 1961} 1962 1963static void | 1682 1683 /* turn link LED on */ 1684 run_set_leds(sc, RT2860_LED_RADIO | 1685 (IEEE80211_IS_CHAN_2GHZ(vap->iv_bss->ni_chan) ? 1686 RT2860_LED_LINK_2GHZ : RT2860_LED_LINK_5GHZ)); 1687 1688 break; 1689 default: --- 263 unchanged lines hidden (view full) --- 1953 IEEE80211_LOCK(ic); 1954 if(nislocked) 1955 IEEE80211_NODE_LOCK(nt); 1956 1957 return (error? 0 : 1); 1958} 1959 1960static void |
1964run_amrr_start(struct run_softc *sc, struct ieee80211_node *ni) | 1961run_ratectl_start(struct run_softc *sc, struct ieee80211_node *ni) |
1965{ 1966 struct ieee80211vap *vap = ni->ni_vap; 1967 struct run_vap *rvp = RUN_VAP(vap); 1968 uint32_t sta[3]; | 1962{ 1963 struct ieee80211vap *vap = ni->ni_vap; 1964 struct run_vap *rvp = RUN_VAP(vap); 1965 uint32_t sta[3]; |
1966#if 0 |
|
1969 uint8_t wcid; | 1967 uint8_t wcid; |
1968#endif |
|
1970 1971 RUN_LOCK_ASSERT(sc, MA_OWNED); 1972 1973 /* read statistic counters (clear on read) and update AMRR state */ 1974 run_read_region_1(sc, RT2860_TX_STA_CNT0, 1975 (uint8_t *)sta, sizeof sta); 1976 | 1969 1970 RUN_LOCK_ASSERT(sc, MA_OWNED); 1971 1972 /* read statistic counters (clear on read) and update AMRR state */ 1973 run_read_region_1(sc, RT2860_TX_STA_CNT0, 1974 (uint8_t *)sta, sizeof sta); 1975 |
1976#if 0 |
|
1977 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); 1978 ieee80211_amrr_node_init(&rvp->amrr, &rvp->amn[wcid], ni); | 1977 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); 1978 ieee80211_amrr_node_init(&rvp->amrr, &rvp->amn[wcid], ni); |
1979#endif 1980 ieee80211_ratectl_node_init(ni); |
|
1979 1980 /* start at lowest available bit-rate, AMRR will raise */ 1981 ni->ni_txrate = 2; 1982 1983 /* start calibration timer */ | 1981 1982 /* start at lowest available bit-rate, AMRR will raise */ 1983 ni->ni_txrate = 2; 1984 1985 /* start calibration timer */ |
1984 rvp->amrr_run = RUN_AMRR_ON; 1985 usb_callout_reset(&rvp->amrr_ch, hz, run_amrr_to, rvp); | 1986 rvp->ratectl_run = RUN_RATECTL_ON; 1987 usb_callout_reset(&rvp->ratectl_ch, hz, run_ratectl_to, rvp); |
1986} 1987 1988static void | 1988} 1989 1990static void |
1989run_amrr_to(void *arg) | 1991run_ratectl_to(void *arg) |
1990{ 1991 struct run_vap *rvp = arg; 1992 1993 /* do it in a process context, so it can go sleep */ | 1992{ 1993 struct run_vap *rvp = arg; 1994 1995 /* do it in a process context, so it can go sleep */ |
1994 ieee80211_runtask(rvp->vap.iv_ic, &rvp->amrr_task); | 1996 ieee80211_runtask(rvp->vap.iv_ic, &rvp->ratectl_task); |
1995 /* next timeout will be rescheduled in the callback task */ 1996} 1997 1998/* ARGSUSED */ 1999static void | 1997 /* next timeout will be rescheduled in the callback task */ 1998} 1999 2000/* ARGSUSED */ 2001static void |
2000run_amrr_cb(void *arg, int pending) | 2002run_ratectl_cb(void *arg, int pending) |
2001{ 2002 struct run_vap *rvp = arg; 2003 struct ieee80211vap *vap = &rvp->vap; 2004 struct ieee80211com *ic = vap->iv_ic; 2005 struct run_softc *sc = ic->ic_ifp->if_softc; 2006 2007 if (ic->ic_opmode == IEEE80211_M_STA) 2008 run_iter_func(rvp, vap->iv_bss); --- 6 unchanged lines hidden (view full) --- 2015 * (when h/w is sending beacons). 2016 */ 2017 RUN_LOCK(sc); 2018 run_reset_livelock(sc); 2019 RUN_UNLOCK(sc); 2020 ieee80211_iterate_nodes(&ic->ic_sta, run_iter_func, rvp); 2021 } 2022 | 2003{ 2004 struct run_vap *rvp = arg; 2005 struct ieee80211vap *vap = &rvp->vap; 2006 struct ieee80211com *ic = vap->iv_ic; 2007 struct run_softc *sc = ic->ic_ifp->if_softc; 2008 2009 if (ic->ic_opmode == IEEE80211_M_STA) 2010 run_iter_func(rvp, vap->iv_bss); --- 6 unchanged lines hidden (view full) --- 2017 * (when h/w is sending beacons). 2018 */ 2019 RUN_LOCK(sc); 2020 run_reset_livelock(sc); 2021 RUN_UNLOCK(sc); 2022 ieee80211_iterate_nodes(&ic->ic_sta, run_iter_func, rvp); 2023 } 2024 |
2023 if(rvp->amrr_run == RUN_AMRR_ON) 2024 usb_callout_reset(&rvp->amrr_ch, hz, run_amrr_to, rvp); | 2025 if(rvp->ratectl_run == RUN_RATECTL_ON) 2026 usb_callout_reset(&rvp->ratectl_ch, hz, run_ratectl_to, rvp); |
2025} 2026 2027 2028static void 2029run_iter_func(void *arg, struct ieee80211_node *ni) 2030{ 2031 struct run_vap *rvp = arg; 2032 struct ieee80211com *ic = rvp->vap.iv_ic; 2033 struct ifnet *ifp = ic->ic_ifp; 2034 struct run_softc *sc = ifp->if_softc; 2035 struct ieee80211_node_table *nt = &ic->ic_sta; | 2027} 2028 2029 2030static void 2031run_iter_func(void *arg, struct ieee80211_node *ni) 2032{ 2033 struct run_vap *rvp = arg; 2034 struct ieee80211com *ic = rvp->vap.iv_ic; 2035 struct ifnet *ifp = ic->ic_ifp; 2036 struct run_softc *sc = ifp->if_softc; 2037 struct ieee80211_node_table *nt = &ic->ic_sta; |
2036 struct ieee80211_amrr_node *amn = &rvp->amn[0]; /* make compiler happy */ | |
2037 uint32_t sta[3], stat; 2038 int error; 2039 uint8_t wcid, mcs, pid; | 2038 uint32_t sta[3], stat; 2039 int error; 2040 uint8_t wcid, mcs, pid; |
2041 struct ieee80211vap *vap = ni->ni_vap; 2042 int txcnt = 0, success = 0, retrycnt = 0; |
|
2040 2041 if(ic->ic_opmode != IEEE80211_M_STA) 2042 IEEE80211_NODE_ITERATE_UNLOCK(nt); 2043 2044 RUN_LOCK(sc); 2045 2046 if(ic->ic_opmode != IEEE80211_M_STA){ 2047 /* drain Tx status FIFO (maxsize = 16) */ 2048 run_read(sc, RT2860_TX_STAT_FIFO, &stat); 2049 while (stat & RT2860_TXQ_VLD) { 2050 DPRINTFN(4, "tx stat 0x%08x\n", stat); 2051 2052 wcid = (stat >> RT2860_TXQ_WCID_SHIFT) & 0xff; 2053 2054 /* if no ACK was requested, no feedback is available */ 2055 if (!(stat & RT2860_TXQ_ACKREQ) || wcid == 0xff) 2056 continue; 2057 2058 /* update per-STA AMRR stats */ | 2043 2044 if(ic->ic_opmode != IEEE80211_M_STA) 2045 IEEE80211_NODE_ITERATE_UNLOCK(nt); 2046 2047 RUN_LOCK(sc); 2048 2049 if(ic->ic_opmode != IEEE80211_M_STA){ 2050 /* drain Tx status FIFO (maxsize = 16) */ 2051 run_read(sc, RT2860_TX_STAT_FIFO, &stat); 2052 while (stat & RT2860_TXQ_VLD) { 2053 DPRINTFN(4, "tx stat 0x%08x\n", stat); 2054 2055 wcid = (stat >> RT2860_TXQ_WCID_SHIFT) & 0xff; 2056 2057 /* if no ACK was requested, no feedback is available */ 2058 if (!(stat & RT2860_TXQ_ACKREQ) || wcid == 0xff) 2059 continue; 2060 2061 /* update per-STA AMRR stats */ |
2059 amn = &rvp->amn[wcid]; 2060 amn->amn_txcnt++; | |
2061 if (stat & RT2860_TXQ_OK) { | 2062 if (stat & RT2860_TXQ_OK) { |
2062 amn->amn_success++; | |
2063 /* 2064 * Check if there were retries, ie if the Tx 2065 * success rate is different from the requested 2066 * rate. Note that it works only because we do 2067 * not allow rate fallback from OFDM to CCK. 2068 */ 2069 mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f; 2070 pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf; 2071 if (mcs + 1 != pid) | 2063 /* 2064 * Check if there were retries, ie if the Tx 2065 * success rate is different from the requested 2066 * rate. Note that it works only because we do 2067 * not allow rate fallback from OFDM to CCK. 2068 */ 2069 mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f; 2070 pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf; 2071 if (mcs + 1 != pid) |
2072 amn->amn_retrycnt++; | 2072 retrycnt = 1; 2073 ieee80211_ratectl_tx_complete(vap, ni, 2074 IEEE80211_RATECTL_TX_SUCCESS, 2075 &retrycnt, NULL); |
2073 } else { | 2076 } else { |
2074 amn->amn_retrycnt++; | 2077 retrycnt = 1; 2078 ieee80211_ratectl_tx_complete(vap, ni, 2079 IEEE80211_RATECTL_TX_SUCCESS, 2080 &retrycnt, NULL); |
2075 ifp->if_oerrors++; 2076 } 2077 run_read_region_1(sc, RT2860_TX_STAT_FIFO, 2078 (uint8_t *)&stat, sizeof stat); 2079 } | 2081 ifp->if_oerrors++; 2082 } 2083 run_read_region_1(sc, RT2860_TX_STAT_FIFO, 2084 (uint8_t *)&stat, sizeof stat); 2085 } |
2080 DPRINTFN(3, "retrycnt=%d txcnt=%d success=%d\n", 2081 amn->amn_retrycnt, amn->amn_txcnt, amn->amn_success); | |
2082 } else { 2083 /* read statistic counters (clear on read) and update AMRR state */ 2084 error = run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta, 2085 sizeof sta); 2086 if (error != 0) 2087 goto skip; 2088 2089 DPRINTFN(3, "retrycnt=%d txcnt=%d failcnt=%d\n", 2090 le32toh(sta[1]) >> 16, le32toh(sta[1]) & 0xffff, 2091 le32toh(sta[0]) & 0xffff); 2092 | 2086 } else { 2087 /* read statistic counters (clear on read) and update AMRR state */ 2088 error = run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta, 2089 sizeof sta); 2090 if (error != 0) 2091 goto skip; 2092 2093 DPRINTFN(3, "retrycnt=%d txcnt=%d failcnt=%d\n", 2094 le32toh(sta[1]) >> 16, le32toh(sta[1]) & 0xffff, 2095 le32toh(sta[0]) & 0xffff); 2096 |
2097#if 0 |
|
2093 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); 2094 amn = &rvp->amn[wcid]; | 2098 wcid = RUN_AID2WCID(ni == NULL ? 0 : ni->ni_associd); 2099 amn = &rvp->amn[wcid]; |
2100#endif |
|
2095 2096 /* count failed TX as errors */ 2097 ifp->if_oerrors += le32toh(sta[0]) & 0xffff; 2098 | 2101 2102 /* count failed TX as errors */ 2103 ifp->if_oerrors += le32toh(sta[0]) & 0xffff; 2104 |
2099 amn->amn_retrycnt = | 2105 retrycnt = |
2100 (le32toh(sta[0]) & 0xffff) + /* failed TX count */ 2101 (le32toh(sta[1]) >> 16); /* TX retransmission count */ 2102 | 2106 (le32toh(sta[0]) & 0xffff) + /* failed TX count */ 2107 (le32toh(sta[1]) >> 16); /* TX retransmission count */ 2108 |
2103 amn->amn_txcnt = 2104 amn->amn_retrycnt + | 2109 txcnt = 2110 retrycnt + |
2105 (le32toh(sta[1]) & 0xffff); /* successful TX count */ 2106 | 2111 (le32toh(sta[1]) & 0xffff); /* successful TX count */ 2112 |
2107 amn->amn_success = | 2113 success = |
2108 (le32toh(sta[1]) >> 16) + 2109 (le32toh(sta[1]) & 0xffff); | 2114 (le32toh(sta[1]) >> 16) + 2115 (le32toh(sta[1]) & 0xffff); |
2116 ieee80211_ratectl_tx_update(vap, ni, &txcnt, &success, 2117 &retrycnt); |
|
2110 } 2111 | 2118 } 2119 |
2112 ieee80211_amrr_choose(ni, amn); | 2120 ieee80211_ratectl_rate(ni, NULL, 0); |
2113 2114skip:; 2115 RUN_UNLOCK(sc); 2116 2117 if(ic->ic_opmode != IEEE80211_M_STA) 2118 IEEE80211_NODE_ITERATE_LOCK(nt); 2119} 2120 --- 2321 unchanged lines hidden (view full) --- 4442 struct ieee80211com *ic = ifp->if_l2com; 4443 uint32_t tmp; 4444 int i; 4445 int ntries; 4446 4447 RUN_LOCK_ASSERT(sc, MA_OWNED); 4448 4449 if(sc->sc_rvp != NULL){ | 2121 2122skip:; 2123 RUN_UNLOCK(sc); 2124 2125 if(ic->ic_opmode != IEEE80211_M_STA) 2126 IEEE80211_NODE_ITERATE_LOCK(nt); 2127} 2128 --- 2321 unchanged lines hidden (view full) --- 4450 struct ieee80211com *ic = ifp->if_l2com; 4451 uint32_t tmp; 4452 int i; 4453 int ntries; 4454 4455 RUN_LOCK_ASSERT(sc, MA_OWNED); 4456 4457 if(sc->sc_rvp != NULL){ |
4450 sc->sc_rvp->amrr_run = RUN_AMRR_OFF; | 4458 sc->sc_rvp->ratectl_run = RUN_RATECTL_OFF; |
4451 if (ic->ic_flags & IEEE80211_F_SCAN) 4452 ieee80211_cancel_scan(&sc->sc_rvp->vap); 4453 } 4454 4455 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 4456 run_set_leds(sc, 0); /* turn all LEDs off */ 4457 4458 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); --- 69 unchanged lines hidden --- | 4459 if (ic->ic_flags & IEEE80211_F_SCAN) 4460 ieee80211_cancel_scan(&sc->sc_rvp->vap); 4461 } 4462 4463 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 4464 run_set_leds(sc, 0); /* turn all LEDs off */ 4465 4466 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); --- 69 unchanged lines hidden --- |