Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/wlan/if_run.c
Context not available. | |||||
const struct ieee80211_bpf_params *); | const struct ieee80211_bpf_params *); | ||||
static int run_raw_xmit(struct ieee80211_node *, struct mbuf *, | static int run_raw_xmit(struct ieee80211_node *, struct mbuf *, | ||||
const struct ieee80211_bpf_params *); | const struct ieee80211_bpf_params *); | ||||
static void run_start(struct ifnet *); | static int run_transmit(struct ieee80211com *, struct mbuf *); | ||||
static int run_ioctl(struct ifnet *, u_long, caddr_t); | static void run_start(struct run_softc *); | ||||
static void run_parent(struct ieee80211com *); | |||||
static void run_iq_calib(struct run_softc *, u_int); | static void run_iq_calib(struct run_softc *, u_int); | ||||
static void run_set_agc(struct run_softc *, uint8_t); | static void run_set_agc(struct run_softc *, uint8_t); | ||||
static void run_select_chan_group(struct run_softc *, int); | static void run_select_chan_group(struct run_softc *, int); | ||||
Context not available. | |||||
static void run_rt5390_rf_setup(struct run_softc *); | static void run_rt5390_rf_setup(struct run_softc *); | ||||
static int run_txrx_enable(struct run_softc *); | static int run_txrx_enable(struct run_softc *); | ||||
static void run_adjust_freq_offset(struct run_softc *); | static void run_adjust_freq_offset(struct run_softc *); | ||||
static void run_init(void *); | |||||
static void run_init_locked(struct run_softc *); | static void run_init_locked(struct run_softc *); | ||||
static void run_stop(void *); | static void run_stop(void *); | ||||
static void run_delay(struct run_softc *, u_int); | static void run_delay(struct run_softc *, u_int); | ||||
Context not available. | |||||
{ | { | ||||
struct run_softc *sc = device_get_softc(self); | struct run_softc *sc = device_get_softc(self); | ||||
struct usb_attach_arg *uaa = device_get_ivars(self); | struct usb_attach_arg *uaa = device_get_ivars(self); | ||||
struct ieee80211com *ic; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ifnet *ifp; | |||||
uint32_t ver; | uint32_t ver; | ||||
int ntries, error; | int ntries, error; | ||||
uint8_t iface_index, bands; | uint8_t iface_index, bands; | ||||
Context not available. | |||||
mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), | mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), | ||||
MTX_NETWORK_LOCK, MTX_DEF); | MTX_NETWORK_LOCK, MTX_DEF); | ||||
mbufq_init(&sc->sc_snd, ifqmaxlen); | |||||
iface_index = RT2860_IFACE_INDEX; | iface_index = RT2860_IFACE_INDEX; | ||||
Context not available. | |||||
device_printf(sc->sc_dev, | device_printf(sc->sc_dev, | ||||
"MAC/BBP RT%04X (rev 0x%04X), RF %s (MIMO %dT%dR), address %s\n", | "MAC/BBP RT%04X (rev 0x%04X), RF %s (MIMO %dT%dR), address %s\n", | ||||
sc->mac_ver, sc->mac_rev, run_get_rf(sc->rf_rev), | sc->mac_ver, sc->mac_rev, run_get_rf(sc->rf_rev), | ||||
sc->ntxchains, sc->nrxchains, ether_sprintf(sc->sc_bssid)); | sc->ntxchains, sc->nrxchains, ether_sprintf(ic->ic_macaddr)); | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); | |||||
if (ifp == NULL) { | |||||
device_printf(sc->sc_dev, "can not if_alloc()\n"); | |||||
goto detach; | |||||
} | |||||
ic = ifp->if_l2com; | |||||
ifp->if_softc = sc; | |||||
if_initname(ifp, "run", device_get_unit(sc->sc_dev)); | |||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; | |||||
ifp->if_init = run_init; | |||||
ifp->if_ioctl = run_ioctl; | |||||
ifp->if_start = run_start; | |||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); | |||||
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; | |||||
IFQ_SET_READY(&ifp->if_snd); | |||||
ic->ic_ifp = ifp; | |||||
ic->ic_softc = sc; | ic->ic_softc = sc; | ||||
ic->ic_name = device_get_nameunit(self); | ic->ic_name = device_get_nameunit(self); | ||||
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ | ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ | ||||
Context not available. | |||||
setbit(&bands, IEEE80211_MODE_11A); | setbit(&bands, IEEE80211_MODE_11A); | ||||
ieee80211_init_channels(ic, NULL, &bands); | ieee80211_init_channels(ic, NULL, &bands); | ||||
ieee80211_ifattach(ic, sc->sc_bssid); | ieee80211_ifattach(ic); | ||||
ic->ic_scan_start = run_scan_start; | ic->ic_scan_start = run_scan_start; | ||||
ic->ic_scan_end = run_scan_end; | ic->ic_scan_end = run_scan_end; | ||||
Context not available. | |||||
ic->ic_wme.wme_update = run_wme_update; | ic->ic_wme.wme_update = run_wme_update; | ||||
ic->ic_raw_xmit = run_raw_xmit; | ic->ic_raw_xmit = run_raw_xmit; | ||||
ic->ic_update_promisc = run_update_promisc; | ic->ic_update_promisc = run_update_promisc; | ||||
ic->ic_vap_create = run_vap_create; | ic->ic_vap_create = run_vap_create; | ||||
ic->ic_vap_delete = run_vap_delete; | ic->ic_vap_delete = run_vap_delete; | ||||
ic->ic_transmit = run_transmit; | |||||
ic->ic_parent = run_parent; | |||||
ieee80211_radiotap_attach(ic, | ieee80211_radiotap_attach(ic, | ||||
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), | &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), | ||||
Context not available. | |||||
run_detach(device_t self) | run_detach(device_t self) | ||||
{ | { | ||||
struct run_softc *sc = device_get_softc(self); | struct run_softc *sc = device_get_softc(self); | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic; | |||||
int i; | int i; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
Context not available. | |||||
run_unsetup_tx_list(sc, &sc->sc_epq[i]); | run_unsetup_tx_list(sc, &sc->sc_epq[i]); | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
if (ifp) { | if (sc->sc_ic.ic_softc == sc) { | ||||
ic = ifp->if_l2com; | |||||
/* drain tasks */ | /* drain tasks */ | ||||
usb_callout_drain(&sc->ratectl_ch); | usb_callout_drain(&sc->ratectl_ch); | ||||
ieee80211_draintask(ic, &sc->cmdq_task); | ieee80211_draintask(ic, &sc->cmdq_task); | ||||
ieee80211_draintask(ic, &sc->ratectl_task); | ieee80211_draintask(ic, &sc->ratectl_task); | ||||
ieee80211_ifdetach(ic); | ieee80211_ifdetach(ic); | ||||
if_free(ifp); | |||||
} | } | ||||
mbufq_drain(&sc->sc_snd); | |||||
mtx_destroy(&sc->sc_mtx); | mtx_destroy(&sc->sc_mtx); | ||||
return (0); | return (0); | ||||
Context not available. | |||||
const uint8_t bssid[IEEE80211_ADDR_LEN], | const uint8_t bssid[IEEE80211_ADDR_LEN], | ||||
const uint8_t mac[IEEE80211_ADDR_LEN]) | const uint8_t mac[IEEE80211_ADDR_LEN]) | ||||
{ | { | ||||
struct ifnet *ifp = ic->ic_ifp; | struct run_softc *sc = ic->ic_softc; | ||||
struct run_softc *sc = ifp->if_softc; | |||||
struct run_vap *rvp; | struct run_vap *rvp; | ||||
struct ieee80211vap *vap; | struct ieee80211vap *vap; | ||||
int i; | int i; | ||||
if (sc->rvp_cnt >= RUN_VAP_MAX) { | if (sc->rvp_cnt >= RUN_VAP_MAX) { | ||||
if_printf(ifp, "number of VAPs maxed out\n"); | device_printf(sc->sc_dev, "number of VAPs maxed out\n"); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
if (vap == NULL) { | if (vap == NULL) { | ||||
if_printf(ifp, "wds only supported in ap mode\n"); | device_printf(sc->sc_dev, | ||||
"wds only supported in ap mode\n"); | |||||
return (NULL); | return (NULL); | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
if_printf(ifp, "unknown opmode %d\n", opmode); | device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
rvp = (struct run_vap *) malloc(sizeof(struct run_vap), | rvp = malloc(sizeof(struct run_vap), M_80211_VAP, M_WAITOK | M_ZERO); | ||||
M_80211_VAP, M_NOWAIT | M_ZERO); | |||||
if (rvp == NULL) | |||||
return (NULL); | |||||
vap = &rvp->vap; | vap = &rvp->vap; | ||||
if (ieee80211_vap_setup(ic, vap, name, unit, | if (ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, | ||||
opmode, flags, bssid, mac) != 0) { | bssid) != 0) { | ||||
/* out of memory */ | /* out of memory */ | ||||
free(rvp, M_80211_VAP); | free(rvp, M_80211_VAP); | ||||
return (NULL); | return (NULL); | ||||
Context not available. | |||||
ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); | ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */); | ||||
/* complete setup */ | /* complete setup */ | ||||
ieee80211_vap_attach(vap, run_media_change, ieee80211_media_status); | ieee80211_vap_attach(vap, run_media_change, ieee80211_media_status, | ||||
mac); | |||||
/* make sure id is always unique */ | /* make sure id is always unique */ | ||||
for (i = 0; i < RUN_VAP_MAX; i++) { | for (i = 0; i < RUN_VAP_MAX; i++) { | ||||
Context not available. | |||||
run_vap_delete(struct ieee80211vap *vap) | run_vap_delete(struct ieee80211vap *vap) | ||||
{ | { | ||||
struct run_vap *rvp = RUN_VAP(vap); | struct run_vap *rvp = RUN_VAP(vap); | ||||
struct ifnet *ifp; | |||||
struct ieee80211com *ic; | struct ieee80211com *ic; | ||||
struct run_softc *sc; | struct run_softc *sc; | ||||
uint8_t rvp_id; | uint8_t rvp_id; | ||||
Context not available. | |||||
return; | return; | ||||
ic = vap->iv_ic; | ic = vap->iv_ic; | ||||
ifp = ic->ic_ifp; | sc = ic->ic_softc; | ||||
sc = ifp->if_softc; | |||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
m_freem(rvp->beacon_mbuf); | m_freem(rvp->beacon_mbuf); | ||||
Context not available. | |||||
static int | static int | ||||
run_read_eeprom(struct run_softc *sc) | run_read_eeprom(struct run_softc *sc) | ||||
{ | { | ||||
struct ieee80211com *ic = &sc->sc_ic; | |||||
int8_t delta_2ghz, delta_5ghz; | int8_t delta_2ghz, delta_5ghz; | ||||
uint32_t tmp; | uint32_t tmp; | ||||
uint16_t val; | uint16_t val; | ||||
Context not available. | |||||
/* read MAC address */ | /* read MAC address */ | ||||
run_srom_read(sc, RT2860_EEPROM_MAC01, &val); | run_srom_read(sc, RT2860_EEPROM_MAC01, &val); | ||||
sc->sc_bssid[0] = val & 0xff; | ic->ic_macaddr[0] = val & 0xff; | ||||
sc->sc_bssid[1] = val >> 8; | ic->ic_macaddr[1] = val >> 8; | ||||
run_srom_read(sc, RT2860_EEPROM_MAC23, &val); | run_srom_read(sc, RT2860_EEPROM_MAC23, &val); | ||||
sc->sc_bssid[2] = val & 0xff; | ic->ic_macaddr[2] = val & 0xff; | ||||
sc->sc_bssid[3] = val >> 8; | ic->ic_macaddr[3] = val >> 8; | ||||
run_srom_read(sc, RT2860_EEPROM_MAC45, &val); | run_srom_read(sc, RT2860_EEPROM_MAC45, &val); | ||||
sc->sc_bssid[4] = val & 0xff; | ic->ic_macaddr[4] = val & 0xff; | ||||
sc->sc_bssid[5] = val >> 8; | ic->ic_macaddr[5] = val >> 8; | ||||
if (sc->mac_ver < 0x3593) { | if (sc->mac_ver < 0x3593) { | ||||
/* read vender BBP settings */ | /* read vender BBP settings */ | ||||
Context not available. | |||||
struct ieee80211vap *vap = ifp->if_softc; | struct ieee80211vap *vap = ifp->if_softc; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
const struct ieee80211_txparam *tp; | const struct ieee80211_txparam *tp; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint8_t rate, ridx; | uint8_t rate, ridx; | ||||
int error; | int error; | ||||
Context not available. | |||||
#if 0 | #if 0 | ||||
if ((ifp->if_flags & IFF_UP) && | if ((ifp->if_flags & IFF_UP) && | ||||
(ifp->if_drv_flags & IFF_DRV_RUNNING)){ | (ifp->if_drv_flags & RUN_RUNNING)){ | ||||
run_init_locked(sc); | run_init_locked(sc); | ||||
} | } | ||||
#endif | #endif | ||||
Context not available. | |||||
{ | { | ||||
const struct ieee80211_txparam *tp; | const struct ieee80211_txparam *tp; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct run_vap *rvp = RUN_VAP(vap); | struct run_vap *rvp = RUN_VAP(vap); | ||||
enum ieee80211_state ostate; | enum ieee80211_state ostate; | ||||
uint32_t sta[3]; | uint32_t sta[3]; | ||||
Context not available. | |||||
run_set_txpreamble(sc); | run_set_txpreamble(sc); | ||||
run_set_basicrates(sc); | run_set_basicrates(sc); | ||||
ni = ieee80211_ref_node(vap->iv_bss); | ni = ieee80211_ref_node(vap->iv_bss); | ||||
IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid); | IEEE80211_ADDR_COPY(ic->ic_macaddr, ni->ni_bssid); | ||||
run_set_bssid(sc, ni->ni_bssid); | run_set_bssid(sc, ni->ni_bssid); | ||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
run_enable_tsf_sync(sc); | run_enable_tsf_sync(sc); | ||||
Context not available. | |||||
run_wme_update_cb(void *arg) | run_wme_update_cb(void *arg) | ||||
{ | { | ||||
struct ieee80211com *ic = arg; | struct ieee80211com *ic = arg; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct ieee80211_wme_state *wmesp = &ic->ic_wme; | struct ieee80211_wme_state *wmesp = &ic->ic_wme; | ||||
int aci, error = 0; | int aci, error = 0; | ||||
Context not available. | |||||
static int | static int | ||||
run_wme_update(struct ieee80211com *ic) | run_wme_update(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
/* sometime called wothout lock */ | /* sometime called wothout lock */ | ||||
if (mtx_owned(&ic->ic_comlock.mtx)) { | if (mtx_owned(&ic->ic_comlock.mtx)) { | ||||
Context not available. | |||||
struct ieee80211vap *vap = cmdq->arg1; | struct ieee80211vap *vap = cmdq->arg1; | ||||
struct ieee80211_key *k = cmdq->k; | struct ieee80211_key *k = cmdq->k; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct ieee80211_node *ni; | struct ieee80211_node *ni; | ||||
uint32_t attr; | uint32_t attr; | ||||
uint16_t base, associd; | uint16_t base, associd; | ||||
Context not available. | |||||
const uint8_t mac[IEEE80211_ADDR_LEN]) | const uint8_t mac[IEEE80211_ADDR_LEN]) | ||||
{ | { | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint32_t i; | uint32_t i; | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
Context not available. | |||||
run_key_delete(struct ieee80211vap *vap, struct ieee80211_key *k) | run_key_delete(struct ieee80211vap *vap, struct ieee80211_key *k) | ||||
{ | { | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct ieee80211_key *k0; | struct ieee80211_key *k0; | ||||
uint32_t i; | uint32_t i; | ||||
Context not available. | |||||
struct run_softc *sc = arg; | struct run_softc *sc = arg; | ||||
/* do it in a process context, so it can go sleep */ | /* do it in a process context, so it can go sleep */ | ||||
ieee80211_runtask(sc->sc_ifp->if_l2com, &sc->ratectl_task); | ieee80211_runtask(&sc->sc_ic, &sc->ratectl_task); | ||||
/* next timeout will be rescheduled in the callback task */ | /* next timeout will be rescheduled in the callback task */ | ||||
} | } | ||||
Context not available. | |||||
run_ratectl_cb(void *arg, int pending) | run_ratectl_cb(void *arg, int pending) | ||||
{ | { | ||||
struct run_softc *sc = arg; | struct run_softc *sc = arg; | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
if (vap == NULL) | if (vap == NULL) | ||||
Context not available. | |||||
run_drain_fifo(void *arg) | run_drain_fifo(void *arg) | ||||
{ | { | ||||
struct run_softc *sc = arg; | struct run_softc *sc = arg; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
uint32_t stat; | uint32_t stat; | ||||
uint16_t (*wstat)[3]; | uint16_t (*wstat)[3]; | ||||
uint8_t wcid, mcs, pid; | uint8_t wcid, mcs, pid; | ||||
Context not available. | |||||
if (stat & RT2860_TXQ_OK) | if (stat & RT2860_TXQ_OK) | ||||
(*wstat)[RUN_SUCCESS]++; | (*wstat)[RUN_SUCCESS]++; | ||||
else | else | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | counter_u64_add(sc->sc_ic.ic_oerrors, 1); | ||||
/* | /* | ||||
* Check if there were retries, ie if the Tx success rate is | * Check if there were retries, ie if the Tx success rate is | ||||
* different from the requested rate. Note that it works only | * different from the requested rate. Note that it works only | ||||
Context not available. | |||||
{ | { | ||||
struct run_softc *sc = arg; | struct run_softc *sc = arg; | ||||
struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
struct ieee80211com *ic = ni->ni_ic; | |||||
struct ifnet *ifp = ic->ic_ifp; | |||||
struct run_node *rn = (void *)ni; | struct run_node *rn = (void *)ni; | ||||
union run_stats sta[2]; | union run_stats sta[2]; | ||||
uint16_t (*wstat)[3]; | uint16_t (*wstat)[3]; | ||||
Context not available. | |||||
goto fail; | goto fail; | ||||
/* count failed TX as errors */ | /* count failed TX as errors */ | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, le16toh(sta[0].error.fail)); | if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, | ||||
le16toh(sta[0].error.fail)); | |||||
retrycnt = le16toh(sta[1].tx.retry); | retrycnt = le16toh(sta[1].tx.retry); | ||||
success = le16toh(sta[1].tx.success); | success = le16toh(sta[1].tx.success); | ||||
Context not available. | |||||
{ | { | ||||
struct run_cmdq *cmdq = arg; | struct run_cmdq *cmdq = arg; | ||||
struct ieee80211_node *ni = cmdq->arg1; | struct ieee80211_node *ni = cmdq->arg1; | ||||
struct run_softc *sc = ni->ni_vap->iv_ic->ic_ifp->if_softc; | struct run_softc *sc = ni->ni_vap->iv_ic->ic_softc; | ||||
uint8_t wcid = cmdq->wcid; | uint8_t wcid = cmdq->wcid; | ||||
RUN_LOCK_ASSERT(sc, MA_OWNED); | RUN_LOCK_ASSERT(sc, MA_OWNED); | ||||
Context not available. | |||||
struct ieee80211_rateset *rs = &ni->ni_rates; | struct ieee80211_rateset *rs = &ni->ni_rates; | ||||
struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint8_t rate; | uint8_t rate; | ||||
uint8_t ridx; | uint8_t ridx; | ||||
uint8_t wcid; | uint8_t wcid; | ||||
Context not available. | |||||
static void | static void | ||||
run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen) | run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen) | ||||
{ | { | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
struct ieee80211_node *ni; | struct ieee80211_node *ni; | ||||
struct rt2870_rxd *rxd; | struct rt2870_rxd *rxd; | ||||
Context not available. | |||||
rxwisize += sizeof(uint32_t); | rxwisize += sizeof(uint32_t); | ||||
if (__predict_false(len > dmalen)) { | if (__predict_false(len > dmalen)) { | ||||
m_freem(m); | m_freem(m); | ||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("bad RXWI length %u > %u\n", len, dmalen); | DPRINTF("bad RXWI length %u > %u\n", len, dmalen); | ||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { | if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { | ||||
m_freem(m); | m_freem(m); | ||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("%s error.\n", (flags & RT2860_RX_CRCERR)?"CRC":"ICV"); | DPRINTF("%s error.\n", (flags & RT2860_RX_CRCERR)?"CRC":"ICV"); | ||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
ieee80211_notify_michael_failure(ni->ni_vap, wh, | ieee80211_notify_michael_failure(ni->ni_vap, wh, | ||||
rxwi->keyidx); | rxwi->keyidx); | ||||
m_freem(m); | m_freem(m); | ||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
DPRINTF("MIC error. Someone is lying.\n"); | DPRINTF("MIC error. Someone is lying.\n"); | ||||
return; | return; | ||||
} | } | ||||
Context not available. | |||||
rssi = rxwi->rssi[ant]; | rssi = rxwi->rssi[ant]; | ||||
nf = run_rssi2dbm(sc, rssi, ant); | nf = run_rssi2dbm(sc, rssi, ant); | ||||
m->m_pkthdr.rcvif = ifp; | |||||
m->m_pkthdr.len = m->m_len = len; | m->m_pkthdr.len = m->m_len = len; | ||||
if (ni != NULL) { | if (ni != NULL) { | ||||
Context not available. | |||||
run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) | run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) | ||||
{ | { | ||||
struct run_softc *sc = usbd_xfer_softc(xfer); | struct run_softc *sc = usbd_xfer_softc(xfer); | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct mbuf *m = NULL; | struct mbuf *m = NULL; | ||||
struct mbuf *m0; | struct mbuf *m0; | ||||
uint32_t dmalen; | uint32_t dmalen; | ||||
Context not available. | |||||
} | } | ||||
if (sc->rx_m == NULL) { | if (sc->rx_m == NULL) { | ||||
DPRINTF("could not allocate mbuf - idle with stall\n"); | DPRINTF("could not allocate mbuf - idle with stall\n"); | ||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
usbd_xfer_set_stall(xfer); | usbd_xfer_set_stall(xfer); | ||||
usbd_xfer_set_frames(xfer, 0); | usbd_xfer_set_frames(xfer, 0); | ||||
} else { | } else { | ||||
Context not available. | |||||
if (error != USB_ERR_CANCELLED) { | if (error != USB_ERR_CANCELLED) { | ||||
/* try to clear stall first */ | /* try to clear stall first */ | ||||
usbd_xfer_set_stall(xfer); | usbd_xfer_set_stall(xfer); | ||||
if (error == USB_ERR_TIMEOUT) | if (error == USB_ERR_TIMEOUT) | ||||
device_printf(sc->sc_dev, "device timeout\n"); | device_printf(sc->sc_dev, "device timeout\n"); | ||||
counter_u64_add(ic->ic_ierrors, 1); | |||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | |||||
goto tr_setup; | goto tr_setup; | ||||
} | } | ||||
if (sc->rx_m != NULL) { | if (sc->rx_m != NULL) { | ||||
Context not available. | |||||
m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); | ||||
if (__predict_false(m0 == NULL)) { | if (__predict_false(m0 == NULL)) { | ||||
DPRINTF("could not allocate mbuf\n"); | DPRINTF("could not allocate mbuf\n"); | ||||
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); | counter_u64_add(ic->ic_ierrors, 1); | ||||
break; | break; | ||||
} | } | ||||
m_copydata(m, 4 /* skip 32-bit DMA-len header */, | m_copydata(m, 4 /* skip 32-bit DMA-len header */, | ||||
Context not available. | |||||
run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index) | run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index) | ||||
{ | { | ||||
struct run_softc *sc = usbd_xfer_softc(xfer); | struct run_softc *sc = usbd_xfer_softc(xfer); | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
struct run_tx_data *data; | struct run_tx_data *data; | ||||
struct ieee80211vap *vap = NULL; | struct ieee80211vap *vap = NULL; | ||||
struct usb_page_cache *pc; | struct usb_page_cache *pc; | ||||
Context not available. | |||||
"bytes @ index %d\n", actlen, index); | "bytes @ index %d\n", actlen, index); | ||||
data = usbd_xfer_get_priv(xfer); | data = usbd_xfer_get_priv(xfer); | ||||
run_tx_free(pq, data, 0); | run_tx_free(pq, data, 0); | ||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; | |||||
usbd_xfer_set_priv(xfer, NULL); | usbd_xfer_set_priv(xfer, NULL); | ||||
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); | |||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
case USB_ST_SETUP: | case USB_ST_SETUP: | ||||
tr_setup: | tr_setup: | ||||
Context not available. | |||||
size + 3 + 8) > RUN_MAX_TXSZ) { | size + 3 + 8) > RUN_MAX_TXSZ) { | ||||
DPRINTF("data overflow, %u bytes\n", | DPRINTF("data overflow, %u bytes\n", | ||||
m->m_pkthdr.len); | m->m_pkthdr.len); | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | |||||
run_tx_free(pq, data, 1); | run_tx_free(pq, data, 1); | ||||
goto tr_setup; | goto tr_setup; | ||||
} | } | ||||
Context not available. | |||||
usbd_xfer_set_frame_len(xfer, 0, size); | usbd_xfer_set_frame_len(xfer, 0, size); | ||||
usbd_xfer_set_priv(xfer, data); | usbd_xfer_set_priv(xfer, data); | ||||
usbd_transfer_submit(xfer); | usbd_transfer_submit(xfer); | ||||
run_start(sc); | |||||
RUN_UNLOCK(sc); | |||||
run_start(ifp); | |||||
RUN_LOCK(sc); | |||||
break; | break; | ||||
default: | default: | ||||
Context not available. | |||||
data = usbd_xfer_get_priv(xfer); | data = usbd_xfer_get_priv(xfer); | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | |||||
if (data != NULL) { | if (data != NULL) { | ||||
if(data->ni != NULL) | if(data->ni != NULL) | ||||
vap = data->ni->ni_vap; | vap = data->ni->ni_vap; | ||||
Context not available. | |||||
run_tx_free(pq, data, error); | run_tx_free(pq, data, error); | ||||
usbd_xfer_set_priv(xfer, NULL); | usbd_xfer_set_priv(xfer, NULL); | ||||
} | } | ||||
if (vap == NULL) | if (vap == NULL) | ||||
vap = TAILQ_FIRST(&ic->ic_vaps); | vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
Context not available. | |||||
run_set_tx_desc(struct run_softc *sc, struct run_tx_data *data) | run_set_tx_desc(struct run_softc *sc, struct run_tx_data *data) | ||||
{ | { | ||||
struct mbuf *m = data->m; | struct mbuf *m = data->m; | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211vap *vap = data->ni->ni_vap; | struct ieee80211vap *vap = data->ni->ni_vap; | ||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
struct rt2870_txd *txd; | struct rt2870_txd *txd; | ||||
Context not available. | |||||
static int | static int | ||||
run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) | run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
struct ieee80211_channel *chan; | struct ieee80211_channel *chan; | ||||
Context not available. | |||||
static int | static int | ||||
run_tx_mgt(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) | run_tx_mgt(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) | ||||
{ | { | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
struct run_node *rn = (void *)ni; | struct run_node *rn = (void *)ni; | ||||
struct run_tx_data *data; | struct run_tx_data *data; | ||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
Context not available. | |||||
USETW(wh->i_dur, dur); | USETW(wh->i_dur, dur); | ||||
} | } | ||||
if (sc->sc_epq[0].tx_nfree == 0) { | if (sc->sc_epq[0].tx_nfree == 0) | ||||
/* let caller free mbuf */ | /* let caller free mbuf */ | ||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE; | |||||
return (EIO); | return (EIO); | ||||
} | |||||
data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); | data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); | ||||
STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); | STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); | ||||
sc->sc_epq[0].tx_nfree--; | sc->sc_epq[0].tx_nfree--; | ||||
Context not available. | |||||
wflags = RT2860_TX_FRAG; | wflags = RT2860_TX_FRAG; | ||||
/* check that there are free slots before allocating the mbuf */ | /* check that there are free slots before allocating the mbuf */ | ||||
if (sc->sc_epq[0].tx_nfree == 0) { | if (sc->sc_epq[0].tx_nfree == 0) | ||||
/* let caller free mbuf */ | /* let caller free mbuf */ | ||||
sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE; | |||||
return (ENOBUFS); | return (ENOBUFS); | ||||
} | |||||
if (prot == IEEE80211_PROT_RTSCTS) { | if (prot == IEEE80211_PROT_RTSCTS) { | ||||
/* NB: CTS is the same size as an ACK */ | /* NB: CTS is the same size as an ACK */ | ||||
Context not available. | |||||
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); | mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); | ||||
} | } | ||||
if (mprot == NULL) { | if (mprot == NULL) { | ||||
if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); | if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); | ||||
DPRINTF("could not allocate mbuf\n"); | DPRINTF("could not allocate mbuf\n"); | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
} | } | ||||
Context not available. | |||||
if (sc->sc_epq[0].tx_nfree == 0) { | if (sc->sc_epq[0].tx_nfree == 0) { | ||||
/* let caller free mbuf */ | /* let caller free mbuf */ | ||||
sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE; | |||||
DPRINTF("sending raw frame, but tx ring is full\n"); | DPRINTF("sending raw frame, but tx ring is full\n"); | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
Context not available. | |||||
run_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, | run_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, | ||||
const struct ieee80211_bpf_params *params) | const struct ieee80211_bpf_params *params) | ||||
{ | { | ||||
struct ifnet *ifp = ni->ni_ic->ic_ifp; | struct run_softc *sc = ni->ni_ic->ic_softc; | ||||
struct run_softc *sc = ifp->if_softc; | |||||
int error = 0; | int error = 0; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
/* prevent management frames from being sent if we're not ready */ | /* prevent management frames from being sent if we're not ready */ | ||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { | if (!(sc->sc_flags & RUN_RUNNING)) { | ||||
error = ENETDOWN; | error = ENETDOWN; | ||||
goto done; | goto done; | ||||
} | } | ||||
Context not available. | |||||
if (params == NULL) { | if (params == NULL) { | ||||
/* tx mgt packet */ | /* tx mgt packet */ | ||||
if ((error = run_tx_mgt(sc, m, ni)) != 0) { | if ((error = run_tx_mgt(sc, m, ni)) != 0) { | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | |||||
DPRINTF("mgt tx failed\n"); | DPRINTF("mgt tx failed\n"); | ||||
goto done; | goto done; | ||||
} | } | ||||
Context not available. | |||||
} else { | } else { | ||||
/* tx raw packet with param */ | /* tx raw packet with param */ | ||||
if ((error = run_tx_param(sc, m, ni, params)) != 0) { | if ((error = run_tx_param(sc, m, ni, params)) != 0) { | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | |||||
DPRINTF("tx with param failed\n"); | DPRINTF("tx with param failed\n"); | ||||
goto done; | goto done; | ||||
} | } | ||||
} | } | ||||
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); | |||||
done: | done: | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
Context not available. | |||||
return (error); | return (error); | ||||
} | } | ||||
static int | |||||
run_transmit(struct ieee80211com *ic, struct mbuf *m) | |||||
{ | |||||
struct run_softc *sc = ic->ic_softc; | |||||
int error; | |||||
RUN_LOCK(sc); | |||||
if ((sc->sc_flags & RUN_RUNNING) == 0) { | |||||
RUN_UNLOCK(sc); | |||||
return (ENXIO); | |||||
} | |||||
error = mbufq_enqueue(&sc->sc_snd, m); | |||||
if (error) { | |||||
RUN_UNLOCK(sc); | |||||
return (error); | |||||
} | |||||
run_start(sc); | |||||
RUN_UNLOCK(sc); | |||||
return (0); | |||||
} | |||||
static void | static void | ||||
run_start(struct ifnet *ifp) | run_start(struct run_softc *sc) | ||||
{ | { | ||||
struct run_softc *sc = ifp->if_softc; | |||||
struct ieee80211_node *ni; | struct ieee80211_node *ni; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
RUN_LOCK(sc); | RUN_LOCK_ASSERT(sc, MA_OWNED); | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | if ((sc->sc_flags & RUN_RUNNING) == 0) | ||||
RUN_UNLOCK(sc); | |||||
return; | return; | ||||
} | |||||
for (;;) { | while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { | ||||
/* send data frames */ | |||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m); | |||||
if (m == NULL) | |||||
break; | |||||
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; | ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; | ||||
if (run_tx(sc, m, ni) != 0) { | if (run_tx(sc, m, ni) != 0) { | ||||
IFQ_DRV_PREPEND(&ifp->if_snd, m); | mbufq_prepend(&sc->sc_snd, m); | ||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE; | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
RUN_UNLOCK(sc); | |||||
} | } | ||||
static int | static void | ||||
run_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) | run_parent(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | |||||
struct ifreq *ifr = (struct ifreq *) data; | |||||
int startall = 0; | int startall = 0; | ||||
int error; | |||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
error = sc->sc_detached ? ENXIO : 0; | if (sc->sc_detached) { | ||||
RUN_UNLOCK(sc); | |||||
if (error) | |||||
return (error); | |||||
switch (cmd) { | |||||
case SIOCSIFFLAGS: | |||||
RUN_LOCK(sc); | |||||
if (ifp->if_flags & IFF_UP) { | |||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)){ | |||||
startall = 1; | |||||
run_init_locked(sc); | |||||
} else | |||||
run_update_promisc_locked(sc); | |||||
} else { | |||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING && | |||||
(ic->ic_nrunning == 0 || sc->rvp_cnt <= 1)) { | |||||
run_stop(sc); | |||||
} | |||||
} | |||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
if (startall) | return; | ||||
ieee80211_start_all(ic); | |||||
break; | |||||
case SIOCGIFMEDIA: | |||||
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd); | |||||
break; | |||||
case SIOCGIFADDR: | |||||
error = ether_ioctl(ifp, cmd, data); | |||||
break; | |||||
default: | |||||
error = EINVAL; | |||||
break; | |||||
} | } | ||||
return (error); | if (ic->ic_nrunning > 0) { | ||||
if (!(sc->sc_flags & RUN_RUNNING)) { | |||||
startall = 1; | |||||
run_init_locked(sc); | |||||
} else | |||||
run_update_promisc_locked(sc); | |||||
} else if ((sc->sc_flags & RUN_RUNNING) && sc->rvp_cnt <= 1) | |||||
run_stop(sc); | |||||
RUN_UNLOCK(sc); | |||||
if (startall) | |||||
ieee80211_start_all(ic); | |||||
} | } | ||||
static void | static void | ||||
Context not available. | |||||
static int | static int | ||||
run_set_chan(struct run_softc *sc, struct ieee80211_channel *c) | run_set_chan(struct run_softc *sc, struct ieee80211_channel *c) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
u_int chan, group; | u_int chan, group; | ||||
chan = ieee80211_chan2ieee(ic, c); | chan = ieee80211_chan2ieee(ic, c); | ||||
Context not available. | |||||
static void | static void | ||||
run_set_channel(struct ieee80211com *ic) | run_set_channel(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
run_set_chan(sc, ic->ic_curchan); | run_set_chan(sc, ic->ic_curchan); | ||||
Context not available. | |||||
static void | static void | ||||
run_scan_start(struct ieee80211com *ic) | run_scan_start(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint32_t tmp; | uint32_t tmp; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
Context not available. | |||||
run_write(sc, RT2860_BCN_TIME_CFG, | run_write(sc, RT2860_BCN_TIME_CFG, | ||||
tmp & ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | | tmp & ~(RT2860_BCN_TX_EN | RT2860_TSF_TIMER_EN | | ||||
RT2860_TBTT_TIMER_EN)); | RT2860_TBTT_TIMER_EN)); | ||||
run_set_bssid(sc, sc->sc_ifp->if_broadcastaddr); | run_set_bssid(sc, ieee80211broadcastaddr); | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
Context not available. | |||||
static void | static void | ||||
run_scan_end(struct ieee80211com *ic) | run_scan_end(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
run_enable_tsf_sync(sc); | run_enable_tsf_sync(sc); | ||||
/* XXX keep local copy */ | /* XXX keep local copy */ | ||||
run_set_bssid(sc, sc->sc_bssid); | run_set_bssid(sc, ic->ic_macaddr); | ||||
RUN_UNLOCK(sc); | RUN_UNLOCK(sc); | ||||
Context not available. | |||||
run_update_beacon(struct ieee80211vap *vap, int item) | run_update_beacon(struct ieee80211vap *vap, int item) | ||||
{ | { | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct run_vap *rvp = RUN_VAP(vap); | struct run_vap *rvp = RUN_VAP(vap); | ||||
int mcast = 0; | int mcast = 0; | ||||
uint32_t i; | uint32_t i; | ||||
Context not available. | |||||
struct ieee80211vap *vap = arg; | struct ieee80211vap *vap = arg; | ||||
struct run_vap *rvp = RUN_VAP(vap); | struct run_vap *rvp = RUN_VAP(vap); | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct rt2860_txwi txwi; | struct rt2860_txwi txwi; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
uint16_t txwisize; | uint16_t txwisize; | ||||
Context not available. | |||||
static void | static void | ||||
run_updateprot(struct ieee80211com *ic) | run_updateprot(struct ieee80211com *ic) | ||||
{ | { | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint32_t i; | uint32_t i; | ||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
Context not available. | |||||
run_updateprot_cb(void *arg) | run_updateprot_cb(void *arg) | ||||
{ | { | ||||
struct ieee80211com *ic = arg; | struct ieee80211com *ic = arg; | ||||
struct run_softc *sc = ic->ic_ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
uint32_t tmp; | uint32_t tmp; | ||||
tmp = RT2860_RTSTH_EN | RT2860_PROT_NAV_SHORT | RT2860_TXOP_ALLOW_ALL; | tmp = RT2860_RTSTH_EN | RT2860_PROT_NAV_SHORT | RT2860_TXOP_ALLOW_ALL; | ||||
Context not available. | |||||
run_usb_timeout_cb(void *arg) | run_usb_timeout_cb(void *arg) | ||||
{ | { | ||||
struct ieee80211vap *vap = arg; | struct ieee80211vap *vap = arg; | ||||
struct run_softc *sc = vap->iv_ic->ic_ifp->if_softc; | struct run_softc *sc = vap->iv_ic->ic_softc; | ||||
RUN_LOCK_ASSERT(sc, MA_OWNED); | RUN_LOCK_ASSERT(sc, MA_OWNED); | ||||
Context not available. | |||||
run_read(sc, RT2860_RX_FILTR_CFG, &tmp); | run_read(sc, RT2860_RX_FILTR_CFG, &tmp); | ||||
tmp |= RT2860_DROP_UC_NOME; | tmp |= RT2860_DROP_UC_NOME; | ||||
if (sc->sc_ifp->if_flags & IFF_PROMISC) | if (sc->sc_ic.ic_promisc > 0) | ||||
tmp &= ~RT2860_DROP_UC_NOME; | tmp &= ~RT2860_DROP_UC_NOME; | ||||
run_write(sc, RT2860_RX_FILTR_CFG, tmp); | run_write(sc, RT2860_RX_FILTR_CFG, tmp); | ||||
DPRINTF("%s promiscuous mode\n", (sc->sc_ifp->if_flags & IFF_PROMISC) ? | DPRINTF("%s promiscuous mode\n", (sc->sc_ic.ic_promisc > 0) ? | ||||
"entering" : "leaving"); | "entering" : "leaving"); | ||||
} | } | ||||
Context not available. | |||||
{ | { | ||||
struct run_softc *sc = ic->ic_softc; | struct run_softc *sc = ic->ic_softc; | ||||
if ((ic->ic_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) | if ((sc->sc_flags & RUN_RUNNING) == 0) | ||||
return; | return; | ||||
RUN_LOCK(sc); | RUN_LOCK(sc); | ||||
Context not available. | |||||
static void | static void | ||||
run_enable_tsf_sync(struct run_softc *sc) | run_enable_tsf_sync(struct run_softc *sc) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
uint32_t tmp; | uint32_t tmp; | ||||
Context not available. | |||||
static void | static void | ||||
run_set_txpreamble(struct run_softc *sc) | run_set_txpreamble(struct run_softc *sc) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
uint32_t tmp; | uint32_t tmp; | ||||
run_read(sc, RT2860_AUTO_RSP_CFG, &tmp); | run_read(sc, RT2860_AUTO_RSP_CFG, &tmp); | ||||
Context not available. | |||||
static void | static void | ||||
run_set_basicrates(struct run_softc *sc) | run_set_basicrates(struct run_softc *sc) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
/* set basic rates mask */ | /* set basic rates mask */ | ||||
if (ic->ic_curmode == IEEE80211_MODE_11B) | if (ic->ic_curmode == IEEE80211_MODE_11B) | ||||
Context not available. | |||||
i = RUN_CMDQ_GET(&sc->cmdq_store); | i = RUN_CMDQ_GET(&sc->cmdq_store); | ||||
DPRINTF("cmdq_store=%d\n", i); | DPRINTF("cmdq_store=%d\n", i); | ||||
sc->cmdq[i].func = run_updateslot_cb; | sc->cmdq[i].func = run_updateslot_cb; | ||||
sc->cmdq[i].arg0 = ic->ic_ifp; | sc->cmdq[i].arg0 = ic; | ||||
ieee80211_runtask(ic, &sc->cmdq_task); | ieee80211_runtask(ic, &sc->cmdq_task); | ||||
return; | return; | ||||
Context not available. | |||||
static void | static void | ||||
run_updateslot_cb(void *arg) | run_updateslot_cb(void *arg) | ||||
{ | { | ||||
struct ifnet *ifp = arg; | struct ieee80211com *ic = arg; | ||||
struct run_softc *sc = ifp->if_softc; | struct run_softc *sc = ic->ic_softc; | ||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
uint32_t tmp; | uint32_t tmp; | ||||
run_read(sc, RT2860_BKOFF_SLOT_CFG, &tmp); | run_read(sc, RT2860_BKOFF_SLOT_CFG, &tmp); | ||||
Context not available. | |||||
static void | static void | ||||
run_update_mcast(struct ieee80211com *ic) | run_update_mcast(struct ieee80211com *ic) | ||||
{ | { | ||||
/* h/w filter supports getting everything or nothing */ | |||||
ic->ic_ifp->if_flags |= IFF_ALLMULTI; | |||||
} | } | ||||
static int8_t | static int8_t | ||||
run_rssi2dbm(struct run_softc *sc, uint8_t rssi, uint8_t rxchain) | run_rssi2dbm(struct run_softc *sc, uint8_t rssi, uint8_t rxchain) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211_channel *c = ic->ic_curchan; | struct ieee80211_channel *c = ic->ic_curchan; | ||||
int delta; | int delta; | ||||
Context not available. | |||||
static int | static int | ||||
run_txrx_enable(struct run_softc *sc) | run_txrx_enable(struct run_softc *sc) | ||||
{ | { | ||||
struct ieee80211com *ic = sc->sc_ifp->if_l2com; | struct ieee80211com *ic = &sc->sc_ic; | ||||
uint32_t tmp; | uint32_t tmp; | ||||
int error, ntries; | int error, ntries; | ||||
Context not available. | |||||
static void | static void | ||||
run_init_locked(struct run_softc *sc) | run_init_locked(struct run_softc *sc) | ||||
{ | { | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211com *ic = ifp->if_l2com; | struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
uint32_t tmp; | uint32_t tmp; | ||||
uint8_t bbp1, bbp3; | uint8_t bbp1, bbp3; | ||||
int i; | int i; | ||||
Context not available. | |||||
for (i = 0; i != RUN_EP_QUEUES; i++) | for (i = 0; i != RUN_EP_QUEUES; i++) | ||||
run_setup_tx_list(sc, &sc->sc_epq[i]); | run_setup_tx_list(sc, &sc->sc_epq[i]); | ||||
run_set_macaddr(sc, IF_LLADDR(ifp)); | run_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); | ||||
for (ntries = 0; ntries < 100; ntries++) { | for (ntries = 0; ntries < 100; ntries++) { | ||||
if (run_read(sc, RT2860_WPDMA_GLO_CFG, &tmp) != 0) | if (run_read(sc, RT2860_WPDMA_GLO_CFG, &tmp) != 0) | ||||
Context not available. | |||||
/* turn radio LED on */ | /* turn radio LED on */ | ||||
run_set_leds(sc, RT2860_LED_RADIO); | run_set_leds(sc, RT2860_LED_RADIO); | ||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; | sc->sc_flags |= RUN_RUNNING; | ||||
ifp->if_drv_flags |= IFF_DRV_RUNNING; | |||||
sc->cmdq_run = RUN_CMDQ_GO; | sc->cmdq_run = RUN_CMDQ_GO; | ||||
for (i = 0; i != RUN_N_XFER; i++) | for (i = 0; i != RUN_N_XFER; i++) | ||||
Context not available. | |||||
} | } | ||||
static void | static void | ||||
run_init(void *arg) | |||||
{ | |||||
struct run_softc *sc = arg; | |||||
struct ifnet *ifp = sc->sc_ifp; | |||||
struct ieee80211com *ic = ifp->if_l2com; | |||||
RUN_LOCK(sc); | |||||
run_init_locked(sc); | |||||
RUN_UNLOCK(sc); | |||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) | |||||
ieee80211_start_all(ic); | |||||
} | |||||
static void | |||||
run_stop(void *arg) | run_stop(void *arg) | ||||
{ | { | ||||
struct run_softc *sc = (struct run_softc *)arg; | struct run_softc *sc = (struct run_softc *)arg; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
uint32_t tmp; | uint32_t tmp; | ||||
int i; | int i; | ||||
int ntries; | int ntries; | ||||
Context not available. | |||||
RUN_LOCK_ASSERT(sc, MA_OWNED); | RUN_LOCK_ASSERT(sc, MA_OWNED); | ||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) | if (sc->sc_flags & RUN_RUNNING) | ||||
run_set_leds(sc, 0); /* turn all LEDs off */ | run_set_leds(sc, 0); /* turn all LEDs off */ | ||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); | sc->sc_flags &= ~RUN_RUNNING; | ||||
sc->ratectl_run = RUN_RATECTL_OFF; | sc->ratectl_run = RUN_RATECTL_OFF; | ||||
sc->cmdq_run = sc->cmdq_key_set; | sc->cmdq_run = sc->cmdq_key_set; | ||||
Context not available. |