mirror of https://gitee.com/openkylin/linux.git
ath9k: Cleanup the beacon tasklet
Remove unused variables, use a helper function to choose the slot and reset beaconing status at one place. Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
2f8e82e8ab
commit
fb6e252f8d
|
@ -401,7 +401,6 @@ struct ath_beacon {
|
||||||
|
|
||||||
u32 beaconq;
|
u32 beaconq;
|
||||||
u32 bmisscnt;
|
u32 bmisscnt;
|
||||||
u32 ast_be_xmit;
|
|
||||||
u32 bc_tstamp;
|
u32 bc_tstamp;
|
||||||
struct ieee80211_vif *bslot[ATH_BCBUF];
|
struct ieee80211_vif *bslot[ATH_BCBUF];
|
||||||
int slottime;
|
int slottime;
|
||||||
|
@ -415,7 +414,7 @@ struct ath_beacon {
|
||||||
bool tx_last;
|
bool tx_last;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ath_beacon_tasklet(unsigned long data);
|
void ath9k_beacon_tasklet(unsigned long data);
|
||||||
bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
|
bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
|
||||||
void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
|
void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
|
||||||
u32 changed);
|
u32 changed);
|
||||||
|
|
|
@ -68,7 +68,7 @@ static void ath9k_beaconq_config(struct ath_softc *sc)
|
||||||
* up rate codes, and channel flags. Beacons are always sent out at the
|
* up rate codes, and channel flags. Beacons are always sent out at the
|
||||||
* lowest rate, and are not retried.
|
* lowest rate, and are not retried.
|
||||||
*/
|
*/
|
||||||
static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
|
static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
|
||||||
struct ath_buf *bf, int rateidx)
|
struct ath_buf *bf, int rateidx)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb = bf->bf_mpdu;
|
struct sk_buff *skb = bf->bf_mpdu;
|
||||||
|
@ -79,8 +79,6 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
|
||||||
u8 chainmask = ah->txchainmask;
|
u8 chainmask = ah->txchainmask;
|
||||||
u8 rate = 0;
|
u8 rate = 0;
|
||||||
|
|
||||||
ath9k_reset_beacon_status(sc);
|
|
||||||
|
|
||||||
sband = &sc->sbands[common->hw->conf.channel->band];
|
sband = &sc->sbands[common->hw->conf.channel->band];
|
||||||
rate = sband->bitrates[rateidx].hw_value;
|
rate = sband->bitrates[rateidx].hw_value;
|
||||||
if (vif->bss_conf.use_short_preamble)
|
if (vif->bss_conf.use_short_preamble)
|
||||||
|
@ -109,7 +107,7 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
|
||||||
ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
|
ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
static void ath9k_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct ath_softc *sc = hw->priv;
|
struct ath_softc *sc = hw->priv;
|
||||||
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
|
@ -126,7 +124,7 @@ static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_vif *vif)
|
struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
struct ath_softc *sc = hw->priv;
|
struct ath_softc *sc = hw->priv;
|
||||||
|
@ -136,15 +134,12 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct ath_txq *cabq = sc->beacon.cabq;
|
struct ath_txq *cabq = sc->beacon.cabq;
|
||||||
struct ieee80211_tx_info *info;
|
struct ieee80211_tx_info *info;
|
||||||
|
struct ieee80211_mgmt *mgmt_hdr;
|
||||||
int cabq_depth;
|
int cabq_depth;
|
||||||
|
|
||||||
if (avp->av_bcbuf == NULL)
|
if (avp->av_bcbuf == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ath9k_reset_beacon_status(sc);
|
|
||||||
|
|
||||||
/* Release the old beacon first */
|
|
||||||
|
|
||||||
bf = avp->av_bcbuf;
|
bf = avp->av_bcbuf;
|
||||||
skb = bf->bf_mpdu;
|
skb = bf->bf_mpdu;
|
||||||
if (skb) {
|
if (skb) {
|
||||||
|
@ -154,14 +149,14 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
||||||
bf->bf_buf_addr = 0;
|
bf->bf_buf_addr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a new beacon from mac80211 */
|
|
||||||
|
|
||||||
skb = ieee80211_beacon_get(hw, vif);
|
skb = ieee80211_beacon_get(hw, vif);
|
||||||
bf->bf_mpdu = skb;
|
|
||||||
if (skb == NULL)
|
if (skb == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp =
|
|
||||||
avp->tsf_adjust;
|
bf->bf_mpdu = skb;
|
||||||
|
|
||||||
|
mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
|
||||||
|
mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust;
|
||||||
|
|
||||||
info = IEEE80211_SKB_CB(skb);
|
info = IEEE80211_SKB_CB(skb);
|
||||||
if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
|
if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
|
||||||
|
@ -207,10 +202,10 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ath_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
|
ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
|
||||||
|
|
||||||
while (skb) {
|
while (skb) {
|
||||||
ath_tx_cabq(hw, skb);
|
ath9k_tx_cabq(hw, skb);
|
||||||
skb = ieee80211_get_buffered_bc(hw, vif);
|
skb = ieee80211_get_buffered_bc(hw, vif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +263,33 @@ void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
|
||||||
tasklet_enable(&sc->bcon_tasklet);
|
tasklet_enable(&sc->bcon_tasklet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ath9k_beacon_choose_slot(struct ath_softc *sc)
|
||||||
|
{
|
||||||
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
|
struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
|
||||||
|
u16 intval;
|
||||||
|
u32 tsftu;
|
||||||
|
u64 tsf;
|
||||||
|
int slot;
|
||||||
|
|
||||||
|
if (sc->sc_ah->opmode != NL80211_IFTYPE_AP) {
|
||||||
|
ath_dbg(common, BEACON, "slot 0, tsf: %llu\n",
|
||||||
|
ath9k_hw_gettsf64(sc->sc_ah));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
|
||||||
|
tsf = ath9k_hw_gettsf64(sc->sc_ah);
|
||||||
|
tsf += TU_TO_USEC(sc->sc_ah->config.sw_beacon_response_time);
|
||||||
|
tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
|
||||||
|
slot = (tsftu % (intval * ATH_BCBUF)) / intval;
|
||||||
|
|
||||||
|
ath_dbg(common, BEACON, "slot: %d tsf: %llu tsftu: %u\n",
|
||||||
|
slot, tsf, tsftu / ATH_BCBUF);
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
|
void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
|
@ -285,17 +307,15 @@ void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
|
||||||
(unsigned long long)tsfadjust, avp->av_bslot);
|
(unsigned long long)tsfadjust, avp->av_bslot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ath_beacon_tasklet(unsigned long data)
|
void ath9k_beacon_tasklet(unsigned long data)
|
||||||
{
|
{
|
||||||
struct ath_softc *sc = (struct ath_softc *)data;
|
struct ath_softc *sc = (struct ath_softc *)data;
|
||||||
struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
|
|
||||||
struct ath_hw *ah = sc->sc_ah;
|
struct ath_hw *ah = sc->sc_ah;
|
||||||
struct ath_common *common = ath9k_hw_common(ah);
|
struct ath_common *common = ath9k_hw_common(ah);
|
||||||
struct ath_buf *bf = NULL;
|
struct ath_buf *bf = NULL;
|
||||||
struct ieee80211_vif *vif;
|
struct ieee80211_vif *vif;
|
||||||
bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
|
bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
|
||||||
int slot;
|
int slot;
|
||||||
u32 bfaddr, bc = 0;
|
|
||||||
|
|
||||||
if (work_pending(&sc->hw_reset_work)) {
|
if (work_pending(&sc->hw_reset_work)) {
|
||||||
ath_dbg(common, RESET,
|
ath_dbg(common, RESET,
|
||||||
|
@ -331,49 +351,20 @@ void ath_beacon_tasklet(unsigned long data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
slot = ath9k_beacon_choose_slot(sc);
|
||||||
* Generate beacon frames. we are sending frames
|
|
||||||
* staggered so calculate the slot for this frame based
|
|
||||||
* on the tsf to safeguard against missing an swba.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if (ah->opmode == NL80211_IFTYPE_AP) {
|
|
||||||
u16 intval;
|
|
||||||
u32 tsftu;
|
|
||||||
u64 tsf;
|
|
||||||
|
|
||||||
intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
|
|
||||||
tsf = ath9k_hw_gettsf64(ah);
|
|
||||||
tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
|
|
||||||
tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
|
|
||||||
slot = (tsftu % (intval * ATH_BCBUF)) / intval;
|
|
||||||
vif = sc->beacon.bslot[slot];
|
vif = sc->beacon.bslot[slot];
|
||||||
|
|
||||||
ath_dbg(common, BEACON,
|
if (!vif || !vif->bss_conf.enable_beacon)
|
||||||
"slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
|
return;
|
||||||
slot, tsf, tsftu / ATH_BCBUF, intval, vif);
|
|
||||||
} else {
|
|
||||||
slot = 0;
|
|
||||||
vif = sc->beacon.bslot[slot];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bf = ath9k_beacon_generate(sc->hw, vif);
|
||||||
bfaddr = 0;
|
WARN_ON(!bf);
|
||||||
if (vif) {
|
|
||||||
bf = ath_beacon_generate(sc->hw, vif);
|
|
||||||
if (bf != NULL) {
|
|
||||||
bfaddr = bf->bf_daddr;
|
|
||||||
bc = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sc->beacon.bmisscnt != 0) {
|
if (sc->beacon.bmisscnt != 0) {
|
||||||
ath_dbg(common, BSTUCK,
|
ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
|
||||||
"resume beacon xmit after %u misses\n",
|
|
||||||
sc->beacon.bmisscnt);
|
sc->beacon.bmisscnt);
|
||||||
sc->beacon.bmisscnt = 0;
|
sc->beacon.bmisscnt = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle slot time change when a non-ERP station joins/leaves
|
* Handle slot time change when a non-ERP station joins/leaves
|
||||||
|
@ -392,21 +383,26 @@ void ath_beacon_tasklet(unsigned long data)
|
||||||
* set to ATH_BCBUF so this check is a noop.
|
* set to ATH_BCBUF so this check is a noop.
|
||||||
*/
|
*/
|
||||||
if (sc->beacon.updateslot == UPDATE) {
|
if (sc->beacon.updateslot == UPDATE) {
|
||||||
sc->beacon.updateslot = COMMIT; /* commit next beacon */
|
sc->beacon.updateslot = COMMIT;
|
||||||
sc->beacon.slotupdate = slot;
|
sc->beacon.slotupdate = slot;
|
||||||
} else if (sc->beacon.updateslot == COMMIT && sc->beacon.slotupdate == slot) {
|
} else if (sc->beacon.updateslot == COMMIT &&
|
||||||
|
sc->beacon.slotupdate == slot) {
|
||||||
ah->slottime = sc->beacon.slottime;
|
ah->slottime = sc->beacon.slottime;
|
||||||
ath9k_hw_init_global_settings(ah);
|
ath9k_hw_init_global_settings(ah);
|
||||||
sc->beacon.updateslot = OK;
|
sc->beacon.updateslot = OK;
|
||||||
}
|
}
|
||||||
if (bfaddr != 0) {
|
|
||||||
|
if (bf) {
|
||||||
|
ath9k_reset_beacon_status(sc);
|
||||||
|
|
||||||
|
ath_dbg(common, BEACON,
|
||||||
|
"Transmitting beacon for slot: %d\n", slot);
|
||||||
|
|
||||||
/* NB: cabq traffic should already be queued and primed */
|
/* NB: cabq traffic should already be queued and primed */
|
||||||
ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr);
|
ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr);
|
||||||
|
|
||||||
if (!edma)
|
if (!edma)
|
||||||
ath9k_hw_txstart(ah, sc->beacon.beaconq);
|
ath9k_hw_txstart(ah, sc->beacon.beaconq);
|
||||||
|
|
||||||
sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -559,7 +559,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
|
||||||
spin_lock_init(&sc->debug.samp_lock);
|
spin_lock_init(&sc->debug.samp_lock);
|
||||||
#endif
|
#endif
|
||||||
tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
|
tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
|
||||||
tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
|
tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
|
||||||
(unsigned long)sc);
|
(unsigned long)sc);
|
||||||
|
|
||||||
INIT_WORK(&sc->hw_reset_work, ath_reset_work);
|
INIT_WORK(&sc->hw_reset_work, ath_reset_work);
|
||||||
|
|
Loading…
Reference in New Issue