提交 73fa2f26 编写于 作者: F Felix Fietkau 提交者: John W. Linville

ath9k: Add multi-channel scheduling support

Signed-off-by: NFelix Fietkau <nbd@openwrt.org>
Signed-off-by: NRajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 6036c284
......@@ -350,6 +350,10 @@ enum ath_chanctx_event {
ATH_CHANCTX_EVENT_BEACON_SENT,
ATH_CHANCTX_EVENT_TSF_TIMER,
ATH_CHANCTX_EVENT_BEACON_RECEIVED,
ATH_CHANCTX_EVENT_ASSOC,
ATH_CHANCTX_EVENT_SWITCH,
ATH_CHANCTX_EVENT_UNASSIGN,
ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL,
};
enum ath_chanctx_state {
......@@ -362,6 +366,7 @@ enum ath_chanctx_state {
struct ath_chanctx_sched {
bool beacon_pending;
bool offchannel_pending;
enum ath_chanctx_state state;
u32 next_tbtt;
......
......@@ -180,10 +180,13 @@ void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
n_active++;
}
if (n_active > 1)
set_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags);
else
if (n_active <= 1) {
clear_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags);
return;
}
if (test_and_set_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags))
return;
ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL);
}
static bool
......@@ -282,6 +285,7 @@ static void ath_chanctx_set_next(struct ath_softc *sc, bool force)
ath_chanctx_send_ps_frame(sc, false);
ath_offchannel_channel_change(sc);
ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_SWITCH);
}
void ath_chanctx_work(struct work_struct *work)
......@@ -357,8 +361,17 @@ void ath9k_chanctx_force_active(struct ieee80211_hw *hw,
void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx,
struct cfg80211_chan_def *chandef)
{
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
spin_lock_bh(&sc->chan_lock);
if (test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags) &&
(sc->cur_chan != ctx) && (ctx == &sc->offchannel.chan)) {
sc->sched.offchannel_pending = true;
spin_unlock_bh(&sc->chan_lock);
return;
}
sc->next_chan = ctx;
if (chandef)
ctx->chandef = *chandef;
......@@ -462,6 +475,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
struct ath_hw *ah = sc->sc_ah;
struct ath_common *common = ath9k_hw_common(ah);
struct ath_vif *avp = NULL;
struct ath_chanctx *ctx;
u32 tsf_time;
bool noa_changed = false;
......@@ -475,6 +489,25 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
if (avp->offchannel_duration)
avp->offchannel_duration = 0;
if (avp->chanctx != sc->cur_chan)
break;
if (sc->sched.offchannel_pending) {
sc->sched.offchannel_pending = false;
sc->next_chan = &sc->offchannel.chan;
sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
}
ctx = ath_chanctx_get_next(sc, sc->cur_chan);
if (ctx->active && sc->sched.state == ATH_CHANCTX_STATE_IDLE) {
sc->next_chan = ctx;
sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
}
/* if the timer missed its window, use the next interval */
if (sc->sched.state == ATH_CHANCTX_STATE_WAIT_FOR_TIMER)
sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON)
break;
......@@ -518,11 +551,65 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
ieee80211_queue_work(sc->hw, &sc->chanctx_work);
break;
case ATH_CHANCTX_EVENT_BEACON_RECEIVED:
if (!test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags))
if (!test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags) ||
sc->cur_chan == &sc->offchannel.chan)
break;
ath_chanctx_adjust_tbtt_delta(sc);
break;
case ATH_CHANCTX_EVENT_ASSOC:
if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE ||
avp->chanctx != sc->cur_chan)
break;
sc->sched.state = ATH_CHANCTX_STATE_IDLE;
/* fall through */
case ATH_CHANCTX_EVENT_SWITCH:
if (!test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags) ||
sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE ||
sc->cur_chan->switch_after_beacon ||
sc->cur_chan == &sc->offchannel.chan)
break;
/* If this is a station chanctx, stay active for a half
* beacon period (minus channel switch time)
*/
sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan);
sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER;
tsf_time = ath9k_hw_gettsf32(sc->sc_ah);
tsf_time +=
TU_TO_USEC(sc->cur_chan->beacon.beacon_interval) / 2;
tsf_time -= sc->sched.channel_switch_time;
sc->sched.switch_start_time = tsf_time;
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer,
tsf_time, 1000000);
break;
case ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL:
if (sc->cur_chan == &sc->offchannel.chan ||
sc->cur_chan->switch_after_beacon)
break;
sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan);
ieee80211_queue_work(sc->hw, &sc->chanctx_work);
break;
case ATH_CHANCTX_EVENT_UNASSIGN:
if (sc->cur_chan->assigned) {
if (sc->next_chan && !sc->next_chan->assigned &&
sc->next_chan != &sc->offchannel.chan)
sc->sched.state = ATH_CHANCTX_STATE_IDLE;
break;
}
ctx = ath_chanctx_get_next(sc, sc->cur_chan);
sc->sched.state = ATH_CHANCTX_STATE_IDLE;
if (!ctx->assigned)
break;
sc->next_chan = ctx;
ieee80211_queue_work(sc->hw, &sc->chanctx_work);
break;
}
spin_unlock_bh(&sc->chan_lock);
......
......@@ -1747,6 +1747,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
bss_conf->bssid, bss_conf->assoc);
ath9k_calculate_summary_state(sc, avp->chanctx);
if (bss_conf->assoc)
ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_ASSOC);
}
if (changed & BSS_CHANGED_IBSS) {
......@@ -2492,6 +2494,7 @@ static void ath9k_remove_chanctx(struct ieee80211_hw *hw,
mutex_lock(&sc->mutex);
ctx->assigned = false;
ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN);
mutex_unlock(&sc->mutex);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册