Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/wlan/if_ural.c
Show First 20 Lines • Show All 1,248 Lines • ▼ Show 20 Lines | ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) | ||||
wh = mtod(m0, struct ieee80211_frame *); | wh = mtod(m0, struct ieee80211_frame *); | ||||
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)]; | tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)]; | ||||
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) | if (IEEE80211_IS_MULTICAST(wh->i_addr1)) | ||||
rate = tp->mcastrate; | rate = tp->mcastrate; | ||||
else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) | else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) | ||||
rate = tp->ucastrate; | rate = tp->ucastrate; | ||||
else | else { | ||||
(void) ieee80211_ratectl_rate(ni, NULL, 0); | |||||
rate = ni->ni_txrate; | rate = ni->ni_txrate; | ||||
} | |||||
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { | if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { | ||||
k = ieee80211_crypto_encap(ni, m0); | k = ieee80211_crypto_encap(ni, m0); | ||||
if (k == NULL) { | if (k == NULL) { | ||||
m_freem(m0); | m_freem(m0); | ||||
return ENOBUFS; | return ENOBUFS; | ||||
} | } | ||||
/* packet header may have moved, reset our local pointer */ | /* packet header may have moved, reset our local pointer */ | ||||
▲ Show 20 Lines • Show All 936 Lines • ▼ Show 20 Lines | ural_ratectl_timeout(void *arg) | ||||
ieee80211_runtask(ic, &uvp->ratectl_task); | ieee80211_runtask(ic, &uvp->ratectl_task); | ||||
} | } | ||||
static void | static void | ||||
ural_ratectl_task(void *arg, int pending) | ural_ratectl_task(void *arg, int pending) | ||||
{ | { | ||||
struct ural_vap *uvp = arg; | struct ural_vap *uvp = arg; | ||||
struct ieee80211vap *vap = &uvp->vap; | struct ieee80211vap *vap = &uvp->vap; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ural_softc *sc = vap->iv_ic->ic_softc; | ||||
struct ural_softc *sc = ic->ic_softc; | struct ieee80211_ratectl_tx_stats *txs = &sc->sc_txs; | ||||
struct ieee80211_node *ni; | int fail; | ||||
int ok, fail; | |||||
int sum, retrycnt; | |||||
ni = ieee80211_ref_node(vap->iv_bss); | |||||
RAL_LOCK(sc); | RAL_LOCK(sc); | ||||
/* read and clear statistic registers (STA_CSR0 to STA_CSR10) */ | /* read and clear statistic registers (STA_CSR0 to STA_CSR10) */ | ||||
ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof(sc->sta)); | ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof(sc->sta)); | ||||
ok = sc->sta[7] + /* TX ok w/o retry */ | txs->flags = IEEE80211_RATECTL_TX_STATS_RETRIES; | ||||
txs->nsuccess = sc->sta[7] + /* TX ok w/o retry */ | |||||
sc->sta[8]; /* TX ok w/ retry */ | sc->sta[8]; /* TX ok w/ retry */ | ||||
fail = sc->sta[9]; /* TX retry-fail count */ | fail = sc->sta[9]; /* TX retry-fail count */ | ||||
sum = ok+fail; | txs->nframes = txs->nsuccess + fail; | ||||
retrycnt = sc->sta[8] + fail; | /* XXX fail * maxretry */ | ||||
txs->nretries = sc->sta[8] + fail; | |||||
ieee80211_ratectl_tx_update(vap, ni, &sum, &ok, &retrycnt); | ieee80211_ratectl_tx_update(vap, txs); | ||||
(void) ieee80211_ratectl_rate(ni, NULL, 0); | |||||
/* count TX retry-fail as Tx errors */ | /* count TX retry-fail as Tx errors */ | ||||
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, fail); | if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, fail); | ||||
usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); | usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); | ||||
RAL_UNLOCK(sc); | RAL_UNLOCK(sc); | ||||
ieee80211_free_node(ni); | |||||
} | } | ||||
static int | static int | ||||
ural_pause(struct ural_softc *sc, int timeout) | ural_pause(struct ural_softc *sc, int timeout) | ||||
{ | { | ||||
usb_pause_mtx(&sc->sc_mtx, timeout); | usb_pause_mtx(&sc->sc_mtx, timeout); | ||||
return (0); | return (0); | ||||
} | } |