if_run.c (345636) | if_run.c (345752) |
---|---|
1/*- 2 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr> 3 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 4 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org> 5 * Copyright (c) 2013-2014 Kevin Lo 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr> 3 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 4 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org> 5 * Copyright (c) 2013-2014 Kevin Lo 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#include <sys/cdefs.h> |
21__FBSDID("$FreeBSD: stable/11/sys/dev/usb/wlan/if_run.c 345636 2019-03-28 09:50:25Z avos $"); | 21__FBSDID("$FreeBSD: stable/11/sys/dev/usb/wlan/if_run.c 345752 2019-03-31 11:31:01Z avos $"); |
22 23/*- 24 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver. 25 * http://www.ralinktech.com/ 26 */ 27 28#include <sys/param.h> 29#include <sys/sockio.h> --- 396 unchanged lines hidden (view full) --- 426static void run_update_beacon(struct ieee80211vap *, int); 427static void run_update_beacon_cb(void *); 428static void run_updateprot(struct ieee80211com *); 429static void run_updateprot_cb(void *); 430static void run_usb_timeout_cb(void *); 431static void run_reset_livelock(struct run_softc *); 432static void run_enable_tsf_sync(struct run_softc *); 433static void run_enable_tsf(struct run_softc *); | 22 23/*- 24 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver. 25 * http://www.ralinktech.com/ 26 */ 27 28#include <sys/param.h> 29#include <sys/sockio.h> --- 396 unchanged lines hidden (view full) --- 426static void run_update_beacon(struct ieee80211vap *, int); 427static void run_update_beacon_cb(void *); 428static void run_updateprot(struct ieee80211com *); 429static void run_updateprot_cb(void *); 430static void run_usb_timeout_cb(void *); 431static void run_reset_livelock(struct run_softc *); 432static void run_enable_tsf_sync(struct run_softc *); 433static void run_enable_tsf(struct run_softc *); |
434static void run_disable_tsf(struct run_softc *); |
|
434static void run_get_tsf(struct run_softc *, uint64_t *); 435static void run_enable_mrr(struct run_softc *); 436static void run_set_txpreamble(struct run_softc *); 437static void run_set_basicrates(struct run_softc *); 438static void run_set_leds(struct run_softc *, uint16_t); 439static void run_set_bssid(struct run_softc *, const uint8_t *); 440static void run_set_macaddr(struct run_softc *, const uint8_t *); 441static void run_updateslot(struct ieee80211com *); --- 1595 unchanged lines hidden (view full) --- 2037run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 2038{ 2039 const struct ieee80211_txparam *tp; 2040 struct ieee80211com *ic = vap->iv_ic; 2041 struct run_softc *sc = ic->ic_softc; 2042 struct run_vap *rvp = RUN_VAP(vap); 2043 enum ieee80211_state ostate; 2044 uint32_t sta[3]; | 435static void run_get_tsf(struct run_softc *, uint64_t *); 436static void run_enable_mrr(struct run_softc *); 437static void run_set_txpreamble(struct run_softc *); 438static void run_set_basicrates(struct run_softc *); 439static void run_set_leds(struct run_softc *, uint16_t); 440static void run_set_bssid(struct run_softc *, const uint8_t *); 441static void run_set_macaddr(struct run_softc *, const uint8_t *); 442static void run_updateslot(struct ieee80211com *); --- 1595 unchanged lines hidden (view full) --- 2038run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 2039{ 2040 const struct ieee80211_txparam *tp; 2041 struct ieee80211com *ic = vap->iv_ic; 2042 struct run_softc *sc = ic->ic_softc; 2043 struct run_vap *rvp = RUN_VAP(vap); 2044 enum ieee80211_state ostate; 2045 uint32_t sta[3]; |
2045 uint32_t tmp; | |
2046 uint8_t ratectl; 2047 uint8_t restart_ratectl = 0; 2048 uint8_t bid = 1 << rvp->rvp_id; 2049 2050 ostate = vap->iv_state; 2051 DPRINTF("%s -> %s\n", 2052 ieee80211_state_name[ostate], 2053 ieee80211_state_name[nstate]); --- 16 unchanged lines hidden (view full) --- 2070 2071 if (ostate != IEEE80211_S_RUN) 2072 break; 2073 2074 ratectl &= ~bid; 2075 sc->runbmap &= ~bid; 2076 2077 /* abort TSF synchronization if there is no vap running */ | 2046 uint8_t ratectl; 2047 uint8_t restart_ratectl = 0; 2048 uint8_t bid = 1 << rvp->rvp_id; 2049 2050 ostate = vap->iv_state; 2051 DPRINTF("%s -> %s\n", 2052 ieee80211_state_name[ostate], 2053 ieee80211_state_name[nstate]); --- 16 unchanged lines hidden (view full) --- 2070 2071 if (ostate != IEEE80211_S_RUN) 2072 break; 2073 2074 ratectl &= ~bid; 2075 sc->runbmap &= ~bid; 2076 2077 /* abort TSF synchronization if there is no vap running */ |
2078 if (--sc->running == 0) { 2079 run_read(sc, RT2860_BCN_TIME_CFG, &tmp); 2080 run_write(sc, RT2860_BCN_TIME_CFG, 2081 tmp & ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | 2082 RT2860_TBTT_TIMER_EN)); 2083 } | 2078 if (--sc->running == 0) 2079 run_disable_tsf(sc); |
2084 break; 2085 2086 case IEEE80211_S_RUN: 2087 if (!(sc->runbmap & bid)) { 2088 if(sc->running++) 2089 restart_ratectl = 1; 2090 sc->runbmap |= bid; 2091 } --- 2719 unchanged lines hidden (view full) --- 4811 run_chan_5ghz, nitems(run_chan_5ghz), bands, 0); 4812 } 4813} 4814 4815static void 4816run_scan_start(struct ieee80211com *ic) 4817{ 4818 struct run_softc *sc = ic->ic_softc; | 2080 break; 2081 2082 case IEEE80211_S_RUN: 2083 if (!(sc->runbmap & bid)) { 2084 if(sc->running++) 2085 restart_ratectl = 1; 2086 sc->runbmap |= bid; 2087 } --- 2719 unchanged lines hidden (view full) --- 4807 run_chan_5ghz, nitems(run_chan_5ghz), bands, 0); 4808 } 4809} 4810 4811static void 4812run_scan_start(struct ieee80211com *ic) 4813{ 4814 struct run_softc *sc = ic->ic_softc; |
4819 uint32_t tmp; | |
4820 4821 RUN_LOCK(sc); 4822 4823 /* abort TSF synchronization */ | 4815 4816 RUN_LOCK(sc); 4817 4818 /* abort TSF synchronization */ |
4824 run_read(sc, RT2860_BCN_TIME_CFG, &tmp); 4825 run_write(sc, RT2860_BCN_TIME_CFG, 4826 tmp & ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | 4827 RT2860_TBTT_TIMER_EN)); | 4819 run_disable_tsf(sc); |
4828 run_set_bssid(sc, ieee80211broadcastaddr); 4829 4830 RUN_UNLOCK(sc); 4831 4832 return; 4833} 4834 4835static void --- 266 unchanged lines hidden (view full) --- 5102 if (run_read(sc, RT2860_BCN_TIME_CFG, &tmp) == 0) { 5103 tmp &= ~(RT2860_BCN_TX_EN | RT2860_TBTT_TIMER_EN); 5104 tmp |= RT2860_TSF_TIMER_EN; 5105 run_write(sc, RT2860_BCN_TIME_CFG, tmp); 5106 } 5107} 5108 5109static void | 4820 run_set_bssid(sc, ieee80211broadcastaddr); 4821 4822 RUN_UNLOCK(sc); 4823 4824 return; 4825} 4826 4827static void --- 266 unchanged lines hidden (view full) --- 5094 if (run_read(sc, RT2860_BCN_TIME_CFG, &tmp) == 0) { 5095 tmp &= ~(RT2860_BCN_TX_EN | RT2860_TBTT_TIMER_EN); 5096 tmp |= RT2860_TSF_TIMER_EN; 5097 run_write(sc, RT2860_BCN_TIME_CFG, tmp); 5098 } 5099} 5100 5101static void |
5102run_disable_tsf(struct run_softc *sc) 5103{ 5104 uint32_t tmp; 5105 5106 if (run_read(sc, RT2860_BCN_TIME_CFG, &tmp) == 0) { 5107 tmp &= ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | 5108 RT2860_TBTT_TIMER_EN); 5109 run_write(sc, RT2860_BCN_TIME_CFG, tmp); 5110 } 5111} 5112 5113static void |
|
5110run_get_tsf(struct run_softc *sc, uint64_t *buf) 5111{ 5112 run_read_region_1(sc, RT2860_TSF_TIMER_DW0, (uint8_t *)buf, 5113 sizeof(*buf)); 5114} 5115 5116static void 5117run_enable_mrr(struct run_softc *sc) --- 934 unchanged lines hidden (view full) --- 6052 run_delay(sc, 10); 6053 6054 if (run_bbp_init(sc) != 0) { 6055 device_printf(sc->sc_dev, "could not initialize BBP\n"); 6056 goto fail; 6057 } 6058 6059 /* abort TSF synchronization */ | 5114run_get_tsf(struct run_softc *sc, uint64_t *buf) 5115{ 5116 run_read_region_1(sc, RT2860_TSF_TIMER_DW0, (uint8_t *)buf, 5117 sizeof(*buf)); 5118} 5119 5120static void 5121run_enable_mrr(struct run_softc *sc) --- 934 unchanged lines hidden (view full) --- 6056 run_delay(sc, 10); 6057 6058 if (run_bbp_init(sc) != 0) { 6059 device_printf(sc->sc_dev, "could not initialize BBP\n"); 6060 goto fail; 6061 } 6062 6063 /* abort TSF synchronization */ |
6060 run_read(sc, RT2860_BCN_TIME_CFG, &tmp); 6061 tmp &= ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | 6062 RT2860_TBTT_TIMER_EN); 6063 run_write(sc, RT2860_BCN_TIME_CFG, tmp); | 6064 run_disable_tsf(sc); |
6064 6065 /* clear RX WCID search table */ 6066 run_set_region_4(sc, RT2860_WCID_ENTRY(0), 0, 512); 6067 /* clear WCID attribute table */ 6068 run_set_region_4(sc, RT2860_WCID_ATTR(0), 0, 8 * 32); 6069 6070 /* hostapd sets a key before init. So, don't clear it. */ 6071 if (sc->cmdq_key_set != RUN_CMDQ_GO) { --- 197 unchanged lines hidden --- | 6065 6066 /* clear RX WCID search table */ 6067 run_set_region_4(sc, RT2860_WCID_ENTRY(0), 0, 512); 6068 /* clear WCID attribute table */ 6069 run_set_region_4(sc, RT2860_WCID_ATTR(0), 0, 8 * 32); 6070 6071 /* hostapd sets a key before init. So, don't clear it. */ 6072 if (sc->cmdq_key_set != RUN_CMDQ_GO) { --- 197 unchanged lines hidden --- |