Commit 405393cf authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k: Implement remain-on-channal support

Add remain on channel support in order to enable multi-channel
concurrency.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarRajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 78b21949
...@@ -338,6 +338,9 @@ enum ath_offchannel_state { ...@@ -338,6 +338,9 @@ enum ath_offchannel_state {
ATH_OFFCHANNEL_PROBE_SEND, ATH_OFFCHANNEL_PROBE_SEND,
ATH_OFFCHANNEL_PROBE_WAIT, ATH_OFFCHANNEL_PROBE_WAIT,
ATH_OFFCHANNEL_SUSPEND, ATH_OFFCHANNEL_SUSPEND,
ATH_OFFCHANNEL_ROC_START,
ATH_OFFCHANNEL_ROC_WAIT,
ATH_OFFCHANNEL_ROC_DONE,
}; };
struct ath_offchannel { struct ath_offchannel {
...@@ -347,6 +350,9 @@ struct ath_offchannel { ...@@ -347,6 +350,9 @@ struct ath_offchannel {
struct ieee80211_vif *scan_vif; struct ieee80211_vif *scan_vif;
int scan_idx; int scan_idx;
enum ath_offchannel_state state; enum ath_offchannel_state state;
struct ieee80211_channel *roc_chan;
struct ieee80211_vif *roc_vif;
int roc_duration;
}; };
void ath9k_fill_chanctx_ops(void); void ath9k_fill_chanctx_ops(void);
......
...@@ -751,6 +751,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) ...@@ -751,6 +751,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
hw->wiphy->n_iface_combinations = 1; hw->wiphy->n_iface_combinations = 1;
hw->wiphy->max_scan_ssids = 255; hw->wiphy->max_scan_ssids = 255;
hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
hw->wiphy->max_remain_on_channel_duration = 10000;
} }
} }
......
...@@ -2176,22 +2176,48 @@ ath_scan_next_channel(struct ath_softc *sc) ...@@ -2176,22 +2176,48 @@ ath_scan_next_channel(struct ath_softc *sc)
ath_chanctx_offchan_switch(sc, chan); ath_chanctx_offchan_switch(sc, chan);
} }
static void ath_offchannel_next(struct ath_softc *sc)
{
struct ieee80211_vif *vif;
if (sc->offchannel.scan_req) {
vif = sc->offchannel.scan_vif;
sc->offchannel.chan.txpower = vif->bss_conf.txpower;
ath_scan_next_channel(sc);
} else if (sc->offchannel.roc_vif) {
vif = sc->offchannel.roc_vif;
sc->offchannel.chan.txpower = vif->bss_conf.txpower;
sc->offchannel.state = ATH_OFFCHANNEL_ROC_START;
ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan);
} else {
ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc), NULL);
sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
if (sc->ps_idle)
ath_cancel_work(sc);
}
}
static void ath_roc_complete(struct ath_softc *sc, bool abort)
{
sc->offchannel.roc_vif = NULL;
sc->offchannel.roc_chan = NULL;
if (!abort)
ieee80211_remain_on_channel_expired(sc->hw);
ath_offchannel_next(sc);
ath9k_ps_restore(sc);
}
static void ath_scan_complete(struct ath_softc *sc, bool abort) static void ath_scan_complete(struct ath_softc *sc, bool abort)
{ {
struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_common *common = ath9k_hw_common(sc->sc_ah);
ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc), NULL);
sc->offchannel.scan_req = NULL; sc->offchannel.scan_req = NULL;
sc->offchannel.scan_vif = NULL; sc->offchannel.scan_vif = NULL;
sc->offchannel.state = ATH_OFFCHANNEL_IDLE; sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
ieee80211_scan_completed(sc->hw, abort); ieee80211_scan_completed(sc->hw, abort);
clear_bit(ATH_OP_SCANNING, &common->op_flags); clear_bit(ATH_OP_SCANNING, &common->op_flags);
ath_offchannel_next(sc);
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
if (!sc->ps_idle)
return;
ath_cancel_work(sc);
} }
static void ath_scan_send_probe(struct ath_softc *sc, static void ath_scan_send_probe(struct ath_softc *sc,
...@@ -2253,11 +2279,11 @@ static void ath_scan_channel_start(struct ath_softc *sc) ...@@ -2253,11 +2279,11 @@ static void ath_scan_channel_start(struct ath_softc *sc)
void ath_offchannel_channel_change(struct ath_softc *sc) void ath_offchannel_channel_change(struct ath_softc *sc)
{ {
if (!sc->offchannel.scan_req)
return;
switch (sc->offchannel.state) { switch (sc->offchannel.state) {
case ATH_OFFCHANNEL_PROBE_SEND: case ATH_OFFCHANNEL_PROBE_SEND:
if (!sc->offchannel.scan_req)
return;
if (sc->cur_chan->chandef.chan != if (sc->cur_chan->chandef.chan !=
sc->offchannel.chan.chandef.chan) sc->offchannel.chan.chandef.chan)
return; return;
...@@ -2265,8 +2291,23 @@ void ath_offchannel_channel_change(struct ath_softc *sc) ...@@ -2265,8 +2291,23 @@ void ath_offchannel_channel_change(struct ath_softc *sc)
ath_scan_channel_start(sc); ath_scan_channel_start(sc);
break; break;
case ATH_OFFCHANNEL_IDLE: case ATH_OFFCHANNEL_IDLE:
if (!sc->offchannel.scan_req)
return;
ath_scan_complete(sc, false); ath_scan_complete(sc, false);
break; break;
case ATH_OFFCHANNEL_ROC_START:
if (sc->cur_chan != &sc->offchannel.chan)
break;
sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT;
mod_timer(&sc->offchannel.timer, jiffies +
msecs_to_jiffies(sc->offchannel.roc_duration));
ieee80211_ready_on_channel(sc->hw);
break;
case ATH_OFFCHANNEL_ROC_DONE:
ath_roc_complete(sc, false);
break;
default: default:
break; break;
} }
...@@ -2277,11 +2318,11 @@ void ath_offchannel_timer(unsigned long data) ...@@ -2277,11 +2318,11 @@ void ath_offchannel_timer(unsigned long data)
struct ath_softc *sc = (struct ath_softc *)data; struct ath_softc *sc = (struct ath_softc *)data;
struct ath_chanctx *ctx = ath_chanctx_get_oper_chan(sc); struct ath_chanctx *ctx = ath_chanctx_get_oper_chan(sc);
if (!sc->offchannel.scan_req)
return;
switch (sc->offchannel.state) { switch (sc->offchannel.state) {
case ATH_OFFCHANNEL_PROBE_WAIT: case ATH_OFFCHANNEL_PROBE_WAIT:
if (!sc->offchannel.scan_req)
return;
if (ctx->active) { if (ctx->active) {
sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND; sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND;
ath_chanctx_switch(sc, ctx, NULL); ath_chanctx_switch(sc, ctx, NULL);
...@@ -2290,8 +2331,16 @@ void ath_offchannel_timer(unsigned long data) ...@@ -2290,8 +2331,16 @@ void ath_offchannel_timer(unsigned long data)
} }
/* fall through */ /* fall through */
case ATH_OFFCHANNEL_SUSPEND: case ATH_OFFCHANNEL_SUSPEND:
if (!sc->offchannel.scan_req)
return;
ath_scan_next_channel(sc); ath_scan_next_channel(sc);
break; break;
case ATH_OFFCHANNEL_ROC_START:
case ATH_OFFCHANNEL_ROC_WAIT:
sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
ath_chanctx_switch(sc, ctx, NULL);
break;
default: default:
break; break;
} }
...@@ -2316,9 +2365,9 @@ static int ath9k_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -2316,9 +2365,9 @@ static int ath9k_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
sc->offchannel.scan_vif = vif; sc->offchannel.scan_vif = vif;
sc->offchannel.scan_req = req; sc->offchannel.scan_req = req;
sc->offchannel.scan_idx = 0; sc->offchannel.scan_idx = 0;
sc->offchannel.chan.txpower = vif->bss_conf.txpower;
ath_scan_next_channel(sc); if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE)
ath_offchannel_next(sc);
out: out:
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
...@@ -2337,6 +2386,53 @@ static void ath9k_cancel_hw_scan(struct ieee80211_hw *hw, ...@@ -2337,6 +2386,53 @@ static void ath9k_cancel_hw_scan(struct ieee80211_hw *hw,
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
} }
static int ath9k_remain_on_channel(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_channel *chan, int duration,
enum ieee80211_roc_type type)
{
struct ath_softc *sc = hw->priv;
int ret = 0;
mutex_lock(&sc->mutex);
if (WARN_ON(sc->offchannel.roc_vif)) {
ret = -EBUSY;
goto out;
}
ath9k_ps_wakeup(sc);
sc->offchannel.roc_vif = vif;
sc->offchannel.roc_chan = chan;
sc->offchannel.roc_duration = duration;
if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE)
ath_offchannel_next(sc);
out:
mutex_unlock(&sc->mutex);
return ret;
}
static int ath9k_cancel_remain_on_channel(struct ieee80211_hw *hw)
{
struct ath_softc *sc = hw->priv;
mutex_lock(&sc->mutex);
del_timer_sync(&sc->offchannel.timer);
if (sc->offchannel.roc_vif) {
if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
ath_roc_complete(sc, true);
}
mutex_unlock(&sc->mutex);
return 0;
}
void ath9k_fill_chanctx_ops(void) void ath9k_fill_chanctx_ops(void)
{ {
if (!ath9k_use_chanctx) if (!ath9k_use_chanctx)
...@@ -2344,6 +2440,8 @@ void ath9k_fill_chanctx_ops(void) ...@@ -2344,6 +2440,8 @@ void ath9k_fill_chanctx_ops(void)
ath9k_ops.hw_scan = ath9k_hw_scan; ath9k_ops.hw_scan = ath9k_hw_scan;
ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
} }
struct ieee80211_ops ath9k_ops = { struct ieee80211_ops ath9k_ops = {
......
...@@ -2197,6 +2197,9 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -2197,6 +2197,9 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
if (vif) if (vif)
avp = (void *)vif->drv_priv; avp = (void *)vif->drv_priv;
if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN)
txctl->force_channel = true;
ret = ath_tx_prepare(hw, skb, txctl); ret = ath_tx_prepare(hw, skb, txctl);
if (ret) if (ret)
return ret; return ret;
...@@ -2234,7 +2237,8 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -2234,7 +2237,8 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
if (txctl->an && queue) if (txctl->an && queue)
tid = ath_get_skb_tid(sc, txctl->an, skb); tid = ath_get_skb_tid(sc, txctl->an, skb);
if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) { if (info->flags & (IEEE80211_TX_CTL_PS_RESPONSE |
IEEE80211_TX_CTL_TX_OFFCHAN)) {
ath_txq_unlock(sc, txq); ath_txq_unlock(sc, txq);
txq = sc->tx.uapsdq; txq = sc->tx.uapsdq;
ath_txq_lock(sc, txq); ath_txq_lock(sc, txq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment