ath9k patches
cover ath9k patches
From: Sujith Manoharan <[email protected]>
MCC fixes for -next.
Sujith Manoharan (9):
ath9k: Add a function to check for an active GO
ath9k: Check for active GO in mgd_prepare_tx()
ath9k: Use a helper function for offchannel NoA
ath9k: Use a helper function to set NoA
ath9k: Use a helper function for bmiss
ath9k: Fix RoC expiration
ath9k: Send oneshot NoA
ath9k: Fix HW scan abort
ath9k: Improve flush() in mcc mode
drivers/net/wireless/ath/ath9k/ath9k.h | 6 +- drivers/net/wireless/ath/ath9k/channel.c | 253 +++++++++++++++++++++---------- drivers/net/wireless/ath/ath9k/main.c | 87 +++++++++-- 3 files changed, 256 insertions(+), 90 deletions(-)
Signature · 1 line
2.1.2
PATCH 1/9 ath9k: Add a function to check for an active GO
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/channel.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -0
@@ -469,6 +469,7 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force);void ath_offchannel_next (struct ath_softc *sc);void ath_scan_complete (struct ath_softc *sc,bool abort);void ath_roc_complete (struct ath_softc *sc,bool abort); +struct ath_chanctx *ath_is_go_chanctx_present (struct ath_softc *sc);#else
drivers/net/wireless/ath/ath9k/channel.c +30 -0
@@ -146,6 +146,36 @@ void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx,#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT +/*************/ +/* Utilities */ +/*************/ + +struct ath_chanctx *ath_is_go_chanctx_present (struct ath_softc *sc) +{ +struct ath_chanctx *ctx; +struct ath_vif *avp; +struct ieee80211_vif *vif; + +spin_lock_bh (&sc->chan_lock); + +ath_for_each_chanctx (sc, ctx) { +if (!ctx->active) +continue ; + +list_for_each_entry (avp, &ctx->vifs, list) { + vif = avp->vif; + +if (ieee80211_vif_type_p2p (vif) ==NL80211_IFTYPE_P2P_GO ) { +spin_unlock_bh (&sc->chan_lock); +return ctx; + } + } + } + +spin_unlock_bh (&sc->chan_lock); +return NULL ; +} +/**********************************************************/ /* Functions to handle the channel context state machine. */ /**********************************************************/
Signature · 1 line
2.1.2
PATCH 2/9 ath9k: Check for active GO in mgd_prepare_tx()
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
If a GO interface is active when we receive amgd_prepare_tx() call, then we need to send
out a new NoA before switching to a new context.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 2 ++ drivers/net/wireless/ath/ath9k/channel.c | 14 ++++++++++ drivers/net/wireless/ath/ath9k/main.c | 45 +++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +2 -0
@@ -385,6 +385,7 @@ struct ath_chanctx_sched {bool wait_switch;bool force_noa_update;bool extend_absence; +bool mgd_prepare_tx;enum ath_chanctx_state state;u8 beacon_miss;
@@ -977,6 +978,7 @@ struct ath_softc {struct ath_chanctx_sched sched;struct ath_offchannel offchannel;struct ath_chanctx *next_chan; +struct completion go_beacon;#endif unsigned long driver_data;
drivers/net/wireless/ath/ath9k/channel.c +14 -0
@@ -421,6 +421,9 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, "Move chanctx state from WAIT_FOR_TIMER to WAIT_FOR_BEACON\n"); } +if (sc->sched.mgd_prepare_tx) + sc->sched.state =ATH_CHANCTX_STATE_WAIT_FOR_BEACON ; +/* * When a context becomes inactive, for example, * disassociation of a station context, the NoA
@@ -547,6 +550,15 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, } sc->sched.beacon_pending = false; + +if (sc->sched.mgd_prepare_tx) { + sc->sched.mgd_prepare_tx = false; +complete (&sc->go_beacon); +ath_dbg (common,CHAN_CTX , +"Beacon sent, complete go_beacon\n" ); +break ; + } +if (sc->sched.state !=ATH_CHANCTX_STATE_WAIT_FOR_BEACON )break ;
@@ -1263,6 +1275,8 @@ void ath9k_init_channel_context(struct ath_softc *sc) (unsigned long)sc);setup_timer (&sc->sched.timer, ath_chanctx_timer, (unsigned long )sc); + +init_completion (&sc->go_beacon); }void ath9k_deinit_channel_context (struct ath_softc *sc)
drivers/net/wireless/ath/ath9k/main.c +38 -7
64 lines not on this page · raw message
Signature · 1 line
2.1.2
PATCH 3/9 ath9k: Use a helper function for offchannel NoA
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/channel.c | 45 +++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +27 -18
@@ -366,6 +366,32 @@ static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time) "Setup chanctx timer with timeout: %d ms\n", jiffies_to_msecs(tsf_time)); } +static void ath_chanctx_offchannel_noa (struct ath_softc *sc, +struct ath_chanctx *ctx, +struct ath_vif *avp, +u32 tsf_time) +{ +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + + avp->noa_index++; + avp->offchannel_start = tsf_time; + avp->offchannel_duration = sc->sched.offchannel_duration; + +ath_dbg (common,CHAN_CTX , +"offchannel noa_duration: %d, noa_start: %d, noa_index: %d\n" , + avp->offchannel_duration, + avp->offchannel_start, + avp->noa_index); + +/* +* When multiple contexts are active, the NoA +* has to be recalculated and advertised after +* an offchannel operation. +*/ +if (ctx->active && avp->noa_duration) + avp->noa_duration =0 ; +} +void ath_chanctx_event (struct ath_softc *sc,struct ieee80211_vif *vif,enum ath_chanctx_event ev) {
@@ -461,24 +487,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,* values and increment the index. */ if (sc->next_chan == &sc->offchannel.chan) { - avp->noa_index++; - avp->offchannel_start = tsf_time; - avp->offchannel_duration = sc->sched.offchannel_duration; - -ath_dbg (common,CHAN_CTX , -"offchannel noa_duration: %d, noa_start: %d, noa_index: %d\n" , - avp->offchannel_duration, - avp->offchannel_start, - avp->noa_index); - -/* -* When multiple contexts are active, the NoA -* has to be recalculated and advertised after -* an offchannel operation. -*/ -if (ctx->active && avp->noa_duration) - avp->noa_duration =0 ; - +ath_chanctx_offchannel_noa (sc, ctx, avp, tsf_time);break ; }
Signature · 1 line
2.1.2
PATCH 4/9 ath9k: Use a helper function to set NoA
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/channel.c | 61 +++++++++++++++++++------------- 1 file changed, 36 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +36 -25
@@ -392,6 +392,39 @@ static void ath_chanctx_offchannel_noa(struct ath_softc *sc, avp->noa_duration =0 ; } +static void ath_chanctx_set_periodic_noa (struct ath_softc *sc, +struct ath_vif *avp, +struct ath_beacon_config *cur_conf, +u32 tsf_time, +u32 beacon_int) +{ +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + + avp->noa_index++; + avp->noa_start = tsf_time; + +if (sc->sched.extend_absence) + avp->noa_duration = (3 * beacon_int /2 ) + + sc->sched.channel_switch_time; +else + avp->noa_duration = +TU_TO_USEC (cur_conf->beacon_interval) /2 + + sc->sched.channel_switch_time; + +if (test_bit (ATH_OP_SCANNING , &common->op_flags) || + sc->sched.extend_absence) + avp->periodic_noa = false; +else + avp->periodic_noa = true; + +ath_dbg (common,CHAN_CTX , +"noa_duration: %d, noa_start: %d, noa_index: %d, periodic: %d\n" , + avp->noa_duration, + avp->noa_start, + avp->noa_index, + avp->periodic_noa); +} +void ath_chanctx_event (struct ath_softc *sc,struct ieee80211_vif *vif,enum ath_chanctx_event ev) {
@@ -521,31 +554,9 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,* announcement. */ if (ctx->active && - (!avp->noa_duration || sc->sched.force_noa_update)) { - avp->noa_index++; - avp->noa_start = tsf_time; - -if (sc->sched.extend_absence) - avp->noa_duration = (3 * beacon_int /2 ) + - sc->sched.channel_switch_time; -else - avp->noa_duration = -TU_TO_USEC (cur_conf->beacon_interval) /2 + - sc->sched.channel_switch_time; - -if (test_bit (ATH_OP_SCANNING , &common->op_flags) || - sc->sched.extend_absence) - avp->periodic_noa = false; -else - avp->periodic_noa = true; - -ath_dbg (common,CHAN_CTX , -"noa_duration: %d, noa_start: %d, noa_index: %d, periodic: %d\n" , - avp->noa_duration, - avp->noa_start, - avp->noa_index, - avp->periodic_noa); - } + (!avp->noa_duration || sc->sched.force_noa_update)) +ath_chanctx_set_periodic_noa (sc, avp, cur_conf, + tsf_time, beacon_int);if (ctx->active && sc->sched.force_noa_update) sc->sched.force_noa_update = false;
Signature · 1 line
2.1.2
PATCH 5/9 ath9k: Use a helper function for bmiss
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/channel.c | 45 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +26 -19
@@ -366,6 +366,31 @@ static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time) "Setup chanctx timer with timeout: %d ms\n", jiffies_to_msecs(tsf_time)); } +static void ath_chanctx_handle_bmiss (struct ath_softc *sc, +struct ath_chanctx *ctx, +struct ath_vif *avp) +{ +/* +* Clear the extend_absence flag if it had been +* set during the previous beacon transmission, +* since we need to revert to the normal NoA +* schedule. +*/ +if (ctx->active && sc->sched.extend_absence) { + avp->noa_duration =0 ; + sc->sched.extend_absence = false; + } + +/* If at least two consecutive beacons were missed on the STA +* chanctx, stay on the STA channel for one extra beacon period, +* to resync the timer properly. +*/ +if (ctx->active && sc->sched.beacon_miss >=2 ) { + avp->noa_duration =0 ; + sc->sched.extend_absence = true; + } +} + static void ath_chanctx_offchannel_noa(struct ath_softc *sc, struct ath_chanctx *ctx, struct ath_vif *avp,
@@ -524,25 +549,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,break ; } -/* -* Clear the extend_absence flag if it had been -* set during the previous beacon transmission, -* since we need to revert to the normal NoA -* schedule. -*/ -if (ctx->active && sc->sched.extend_absence) { - avp->noa_duration =0 ; - sc->sched.extend_absence = false; - } - -/* If at least two consecutive beacons were missed on the STA -* chanctx, stay on the STA channel for one extra beacon period, -* to resync the timer properly. -*/ -if (ctx->active && sc->sched.beacon_miss >=2 ) { - avp->noa_duration =0 ; - sc->sched.extend_absence = true; - } +ath_chanctx_handle_bmiss (sc, ctx, avp);/* Prevent wrap-around issues */ if (avp->noa_duration && tsf_time - avp->noa_start >BIT (30 ))
Signature · 1 line
2.1.2
PATCH 6/9 ath9k: Fix RoC expiration
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
mac80211 has to be notified when a RoC period expires in the driver. In MCC mode, since the offchannel/RoC timer is set with the requested duration, ieee80211_remain_on_channel_expired() needs to be called when the timer expires.
But, currently it is done after we move back to the operating channel. This is incorrect - fix this by calling ieee80211_remain_on_channel_expired() when the RoC timer expires and in ath_roc_complete() when the RoC request is aborted.
--- drivers/net/wireless/ath/ath9k/channel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +2 -1
@@ -894,7 +894,7 @@ void ath_roc_complete(struct ath_softc *sc, bool abort) sc->offchannel.roc_vif =NULL ; sc->offchannel.roc_chan =NULL ; -if (!abort) +if (abort)ieee80211_remain_on_channel_expired (sc->hw);ath_offchannel_next (sc);ath9k_ps_restore (sc);
@@ -1028,6 +1028,7 @@ static void ath_offchannel_timer(unsigned long data)case ATH_OFFCHANNEL_ROC_WAIT : ctx =ath_chanctx_get_oper_chan (sc, false); sc->offchannel.state =ATH_OFFCHANNEL_ROC_DONE ; +ieee80211_remain_on_channel_expired (sc->hw);ath_chanctx_switch (sc, ctx,NULL );break ;default :
Signature · 1 line
2.1.2
PATCH 7/9 ath9k: Send oneshot NoA
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
This patch makes sure that a GO interface
sends out a new NoA schedule with 200ms duration
when mgd_prepare_tx() is called.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/channel.c | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -0
@@ -620,6 +620,7 @@ struct ath_vif {u32 noa_start;u32 noa_duration;bool periodic_noa; +bool oneshot_noa; };struct ath9k_vif_iter_data {
drivers/net/wireless/ath/ath9k/channel.c +41 -0
59 lines not on this page · raw message
Signature · 1 line
2.1.2
PATCH 8/9 ath9k: Fix HW scan abort
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Instead of using ATH_CHANCTX_EVENT_ASSIGN to abort a HW scan when a new interface becomes active, use the mgd_prepare_tx() callback. This allows us to make sure that the GO's channel becomes operational by using flush_work().
--- drivers/net/wireless/ath/ath9k/channel.c | 16 ---------------- drivers/net/wireless/ath/ath9k/main.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +0 -16
@@ -743,22 +743,6 @@ 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_ASSIGN : -/* -* When adding a new channel context, check if a scan -* is in progress and abort it since the addition of -* a new channel context is usually followed by VIF -* assignment, in which case we have to start multi-channel -* operation. -*/ -if (test_bit (ATH_OP_SCANNING , &common->op_flags)) { -ath_dbg (common,CHAN_CTX , -"Aborting HW scan to add new context\n" ); - -spin_unlock_bh (&sc->chan_lock); -del_timer_sync (&sc->offchannel.timer); -ath_scan_complete (sc, true); -spin_lock_bh (&sc->chan_lock); - }break ;case ATH_CHANCTX_EVENT_CHANGE :break ;
drivers/net/wireless/ath/ath9k/main.c +13 -1
@@ -2365,7 +2365,6 @@ static int ath9k_add_chanctx(struct ieee80211_hw *hw, conf->def.chan->center_freq);ath_chanctx_set_channel (sc, ctx, &conf->def); -ath_chanctx_event (sc,NULL ,ATH_CHANCTX_EVENT_ASSIGN );mutex_unlock (&sc->mutex);return 0 ;
@@ -2496,6 +2495,19 @@ static void ath9k_mgd_prepare_tx(struct ieee80211_hw *hw,if (!changed) goto out; +if (test_bit (ATH_OP_SCANNING , &common->op_flags)) { +ath_dbg (common,CHAN_CTX , +"%s: Aborting HW scan\n" , __func__); + +mutex_unlock (&sc->mutex); + +del_timer_sync (&sc->offchannel.timer); +ath_scan_complete (sc, true); +flush_work (&sc->chanctx_work); + +mutex_lock (&sc->mutex); + } + go_ctx =ath_is_go_chanctx_present (sc);if (go_ctx) {
Signature · 1 line
2.1.2
PATCH 9/9 ath9k: Improve flush() in mcc mode
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
The flush timeout in MCC mode is very small, since we are constrained by the time slice for each channel context, but since only the HW queues are flushed when switching contexts, it is acceptable.
Since the SW queues are also emptied in the mac80211 flush() callback, a larger duration is needed. Add an override argument to __ath9k_flush() and set it when flush() is called in MCC mode. This allows the driver to drain both the SW and HW queues.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- drivers/net/wireless/ath/ath9k/channel.c | 4 ++-- drivers/net/wireless/ath/ath9k/main.c | 28 +++++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
@@ -719,7 +719,7 @@ void ath_update_survey_nf(struct ath_softc *sc, int channel);void ath9k_queue_reset (struct ath_softc *sc,enum ath_reset_type type);void ath_ps_full_sleep (unsigned long data);void __ath9k_flush (struct ieee80211_hw *hw,u32 queues,bool drop, -bool sw_pending); +bool sw_pending,bool timeout_override);/**********/ /* BTCOEX */
drivers/net/wireless/ath/ath9k/channel.c +2 -2
@@ -1232,11 +1232,11 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force)ath9k_chanctx_stop_queues (sc, sc->cur_chan); queues_stopped = true; -__ath9k_flush (sc->hw, ~0 , true, false); +__ath9k_flush (sc->hw, ~0 , true, false, false);if (ath_chanctx_send_ps_frame (sc, true))__ath9k_flush (sc->hw,BIT (IEEE80211_AC_VO ), - false, false); + false, false, false); send_ps = true;spin_lock_bh (&sc->chan_lock);
drivers/net/wireless/ath/ath9k/main.c +25 -3
@@ -2031,14 +2031,33 @@ static void ath9k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop) {struct ath_softc *sc = hw->priv; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + +if (ath9k_is_chanctx_enabled ()) { +if (!test_bit (ATH_OP_MULTI_CHANNEL , &common->op_flags)) + goto flush; +/* +* If MCC is active, extend the flush timeout +* and wait for the HW/SW queues to become +* empty. This needs to be done outside the +* sc->mutex lock to allow the channel scheduler +* to switch channel contexts. +* +* The vif queues have been stopped in mac80211, +* so there won't be any incoming frames. +*/ +__ath9k_flush (hw, queues, drop, true, true); +return ; + } +flush:mutex_lock (&sc->mutex); -__ath9k_flush (hw, queues, drop, true); +__ath9k_flush (hw, queues, drop, true, false);mutex_unlock (&sc->mutex); }void __ath9k_flush (struct ieee80211_hw *hw,u32 queues,bool drop, -bool sw_pending) +bool sw_pending,bool timeout_override) {struct ath_softc *sc = hw->priv;struct ath_hw *ah = sc->sc_ah;
@@ -2059,7 +2078,10 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop, }spin_lock_bh (&sc->chan_lock); - timeout = sc->cur_chan->flush_timeout; +if (timeout_override) + timeout =HZ /5 ; +else + timeout = sc->cur_chan->flush_timeout;spin_unlock_bh (&sc->chan_lock); ath_dbg(common, CHAN_CTX,
Signature · 1 line
2.1.2