ath9k patches
v2 cover ath9k patches
From: Sujith Manoharan <[email protected]>
This is a rebase of all the pending ath9k patches over -wl, meant for -next.
Sujith Manoharan (23):
ath9k: Use sta_state() callback
ath9k: Enable multi-channel properly
ath9k: Process beacons properly
ath9k: Unify reset API
ath9k: Set ATH_OP_HW_RESET before HW reset
ath9k: Disable beacon tasklet during reset
ath9k: Clear NoA schedule properly
ath9k: Use configurable timeout for flush
ath9k: Fix MCC flush timeout
ath9k: Fix offchannel flush timeout
ath9k: Check for pending frames properly
ath9k: Send AUTHORIZED event only for station mode
ath9k: Fix address management
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
ath9k: Do not start BA when scanning
drivers/net/wireless/ath/ath.h | 2 +- drivers/net/wireless/ath/ath9k/ath9k.h | 15 +- drivers/net/wireless/ath/ath9k/channel.c | 319 +++++++++++++++++++++++-------- drivers/net/wireless/ath/ath9k/main.c | 193 +++++++++++++++---- drivers/net/wireless/ath/ath9k/tx99.c | 4 +- 5 files changed, 410 insertions(+), 123 deletions(-)
Signature · 1 line
2.1.2
PATCH v2 1/23 ath9k: Use sta_state() callback
From: Sujith Manoharan <[email protected]>
Instead of using the sta_add()/sta_remove() callbacks, use the sta_state() callback since this gives more fine-grained control.
--- drivers/net/wireless/ath/ath9k/main.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +26 -2
@@ -1547,6 +1547,31 @@ static int ath9k_sta_remove(struct ieee80211_hw *hw,return 0 ; } +static int ath9k_sta_state (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +enum ieee80211_sta_state old_state, +enum ieee80211_sta_state new_state) +{ +struct ath_softc *sc = hw->priv; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); +int ret =0 ; + +if (old_state ==IEEE80211_STA_AUTH && + new_state ==IEEE80211_STA_ASSOC ) { + ret =ath9k_sta_add (hw, vif, sta); +ath_dbg (common,CONFIG , +"Add station: %pM\n" , sta->addr); + }else if (old_state ==IEEE80211_STA_ASSOC && + new_state ==IEEE80211_STA_AUTH ) { + ret =ath9k_sta_remove (hw, vif, sta); +ath_dbg (common,CONFIG , +"Remove station: %pM\n" , sta->addr); + } + +return ret; +} +static void ath9k_sta_set_tx_filter (struct ath_hw *ah,struct ath_node *an,bool set)
@@ -2471,8 +2496,7 @@ struct ieee80211_ops ath9k_ops = { .remove_interface = ath9k_remove_interface, .config = ath9k_config, .configure_filter = ath9k_configure_filter, - .sta_add = ath9k_sta_add, - .sta_remove = ath9k_sta_remove, + .sta_state = ath9k_sta_state, .sta_notify = ath9k_sta_notify, .conf_tx = ath9k_conf_tx, .bss_info_changed = ath9k_bss_info_changed,
Signature · 1 line
2.1.2
PATCH v2 2/23 ath9k: Enable multi-channel properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
In MCC mode, currently the decision to enable the multi-channel state machine is done based on the association status if one of the interfaces assigned to a context is in station mode.
This allows the driver to switch to the other context before the current station is able to complete the 4-way handshake in case it is required and this causes problems.
Instead, enable multi-channel mode when the station moves to the authorized state. This disallows an early switch to the other channel.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- drivers/net/wireless/ath/ath9k/channel.c | 4 ++-- drivers/net/wireless/ath/ath9k/main.c | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
@@ -362,7 +362,7 @@ 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_AUTHORIZED ,ATH_CHANCTX_EVENT_SWITCH ,ATH_CHANCTX_EVENT_ASSIGN , ATH_CHANCTX_EVENT_UNASSIGN,
drivers/net/wireless/ath/ath9k/channel.c +2 -2
@@ -171,7 +171,7 @@ static const char *chanctx_event_string(enum ath_chanctx_event ev)case_rtn_string (ATH_CHANCTX_EVENT_BEACON_SENT );case_rtn_string (ATH_CHANCTX_EVENT_TSF_TIMER );case_rtn_string (ATH_CHANCTX_EVENT_BEACON_RECEIVED ); -case_rtn_string (ATH_CHANCTX_EVENT_ASSOC ); +case_rtn_string (ATH_CHANCTX_EVENT_AUTHORIZED );case_rtn_string (ATH_CHANCTX_EVENT_SWITCH );case_rtn_string (ATH_CHANCTX_EVENT_ASSIGN );case_rtn_string (ATH_CHANCTX_EVENT_UNASSIGN );
@@ -510,7 +510,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,ath_chanctx_setup_timer (sc, tsf_time);break ; -case ATH_CHANCTX_EVENT_ASSOC : +case ATH_CHANCTX_EVENT_AUTHORIZED :if (sc->sched.state !=ATH_CHANCTX_STATE_FORCE_ACTIVE || avp->chanctx != sc->cur_chan)break ;
drivers/net/wireless/ath/ath9k/main.c +7 -6
@@ -1569,6 +1569,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw, "Remove station: %pM\n", sta->addr); } +if (ath9k_is_chanctx_enabled ()) { +if (old_state ==IEEE80211_STA_ASSOC && + new_state ==IEEE80211_STA_AUTHORIZED ) +ath_chanctx_event (sc, vif, +ATH_CHANCTX_EVENT_AUTHORIZED ); + } +return ret; }
@@ -1761,12 +1768,6 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, avp->assoc = bss_conf->assoc;ath9k_calculate_summary_state (sc, avp->chanctx); - -if (ath9k_is_chanctx_enabled ()) { -if (bss_conf->assoc) -ath_chanctx_event (sc, vif, -ATH_CHANCTX_EVENT_ASSOC ); - } }if (changed &BSS_CHANGED_IBSS ) {
Signature · 1 line
2.1.2
PATCH v2 3/23 ath9k: Process beacons properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When the current operating channel context has been marked as ATH_CHANCTX_STATE_FORCE_ACTIVE, do not process beacons that might be received, since we have to wait for the station to become authorized.
Also, since the cached TSF value will be zero initially do not rearm the timer in this case when a beacon is received, since it results in spurious values.
--- drivers/net/wireless/ath/ath9k/channel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +6 -1
@@ -495,10 +495,15 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, sc->cur_chan == &sc->offchannel.chan)break ; -ath_chanctx_adjust_tbtt_delta (sc); sc->sched.beacon_pending = false; sc->sched.beacon_miss =0 ; +if (sc->sched.state ==ATH_CHANCTX_STATE_FORCE_ACTIVE || + !sc->cur_chan->tsf_val) +break ; + +ath_chanctx_adjust_tbtt_delta (sc); +/* TSF time might have been updated by the incoming beacon, * need update the channel switch timer to reflect the change. */
Signature · 1 line
2.1.2
PATCH v2 4/23 ath9k: Unify reset API
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Instead of having ath_reset_internal() and ath_reset() as two separate calls to perform a HW reset, have one function. This makes sure that the behavior will be the same at all callsites.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 3 +-- drivers/net/wireless/ath/ath9k/channel.c | 2 +- drivers/net/wireless/ath/ath9k/main.c | 12 +++++++----- drivers/net/wireless/ath/ath9k/tx99.c | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -2
@@ -540,7 +540,6 @@ static inline void ath_chanctx_check_active(struct ath_softc *sc,#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ -int ath_reset_internal (struct ath_softc *sc,struct ath9k_channel *hchan);void ath_startrecv (struct ath_softc *sc);bool ath_stoprecv (struct ath_softc *sc);u32 ath_calcrxfilter (struct ath_softc *sc);
@@ -1069,7 +1068,7 @@ void ath9k_tasklet(unsigned long data);int ath_cabq_update (struct ath_softc *);u8 ath9k_parse_mpdudensity (u8 mpdudensity);irqreturn_t ath_isr (int irq,void *dev); -int ath_reset (struct ath_softc *sc); +int ath_reset (struct ath_softc *sc,struct ath9k_channel *hchan);void ath_cancel_work (struct ath_softc *sc);void ath_restart_work (struct ath_softc *sc); int ath9k_init_device(u16 devid, struct ath_softc *sc,
drivers/net/wireless/ath/ath9k/channel.c +1 -1
@@ -66,7 +66,7 @@ static int ath_set_channel(struct ath_softc *sc) } hchan = &sc->sc_ah->channels[pos]; - r =ath_reset_internal (sc, hchan); + r =ath_reset (sc, hchan);if (r)return r;
drivers/net/wireless/ath/ath9k/main.c +7 -5
@@ -270,7 +270,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)return true; } -int ath_reset_internal (struct ath_softc *sc,struct ath9k_channel *hchan) +static int ath_reset_internal (struct ath_softc *sc,struct ath9k_channel *hchan) {struct ath_hw *ah = sc->sc_ah;struct ath_common *common =ath9k_hw_common (ah);
@@ -598,12 +598,12 @@ chip_reset:#undef SCHED_INTR } -int ath_reset (struct ath_softc *sc) +int ath_reset (struct ath_softc *sc,struct ath9k_channel *hchan) {int r;ath9k_ps_wakeup (sc); - r =ath_reset_internal (sc,NULL ); + r =ath_reset_internal (sc, hchan);ath9k_ps_restore (sc);return r;
@@ -623,7 +623,9 @@ void ath_reset_work(struct work_struct *work) { struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work); -ath_reset (sc); +ath9k_ps_wakeup (sc); +ath_reset_internal (sc,NULL ); +ath9k_ps_restore (sc); }/**********************/
@@ -2044,7 +2046,7 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)spin_unlock_bh (&sc->sc_pcu_lock);if (!drain_txq) -ath_reset (sc); +ath_reset (sc,NULL );ath9k_ps_restore (sc); }
drivers/net/wireless/ath/ath9k/tx99.c +2 -2
@@ -99,7 +99,7 @@ static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)static void ath9k_tx99_deinit (struct ath_softc *sc) { -ath_reset (sc); +ath_reset (sc,NULL );ath9k_ps_wakeup (sc);ath9k_tx99_stop (sc);
@@ -127,7 +127,7 @@ static int ath9k_tx99_init(struct ath_softc *sc)memset (&txctl,0 ,sizeof (txctl)); txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO ]; -ath_reset (sc); +ath_reset (sc,NULL );ath9k_ps_wakeup (sc);
Signature · 1 line
2.1.2
PATCH v2 5/23 ath9k: Set ATH_OP_HW_RESET before HW reset
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When a HW reset is done, the interrupt tasklet is disabled before ISRs are disabled in the HW. This allows a small window where the HW can still generate interrupts. Since the tasklet is disabled and not killed, it is not scheduled but deferred for execution at a later time.
This happens because ATH_OP_HW_RESET is not set when ath_reset() is called. When the hw_reset_work workqueue is used, this problem doesn't arise because ATH_OP_HW_RESET is set and the ISR bails out.
Set ATH_OP_HW_RESET properly in ath_reset() to avoid this race - all the ath_reset_internal() callers have been converted to use ath_reset() in the previous patch.
--- drivers/net/wireless/ath/ath9k/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/ath/ath9k/main.c +12 -0
@@ -598,10 +598,17 @@ chip_reset:#undef SCHED_INTR } +/* +* This function is called when a HW reset cannot be deferred +* and has to be immediate. +*/ int ath_reset (struct ath_softc *sc,struct ath9k_channel *hchan) { +struct ath_common *common =ath9k_hw_common (sc->sc_ah);int r; +set_bit (ATH_OP_HW_RESET , &common->op_flags); +ath9k_ps_wakeup (sc); r =ath_reset_internal (sc, hchan);ath9k_ps_restore (sc);
@@ -609,6 +616,11 @@ int ath_reset(struct ath_softc *sc, struct ath9k_channel *hchan)return r; } +/* +* When a HW reset can be deferred, it is added to the +* hw_reset_work workqueue, but we set ATH_OP_HW_RESET before +* queueing. +*/ void ath9k_queue_reset (struct ath_softc *sc,enum ath_reset_type type) {struct ath_common *common =ath9k_hw_common (sc->sc_ah);
Signature · 1 line
2.1.2
PATCH v2 6/23 ath9k: Disable beacon tasklet during reset
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When a chip reset is done, all running timers,
tasklets etc. are stopped but the beacon tasklet
is left running. Fix this.
--- drivers/net/wireless/ath/ath9k/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath9k/main.c +2 -0
@@ -281,6 +281,7 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)__ath_cancel_work (sc);tasklet_disable (&sc->intr_tq); +tasklet_disable (&sc->bcon_tasklet);spin_lock_bh (&sc->sc_pcu_lock);if (!sc->cur_chan->offchannel) {
@@ -326,6 +327,7 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) out:spin_unlock_bh (&sc->sc_pcu_lock); +tasklet_enable (&sc->bcon_tasklet);tasklet_enable (&sc->intr_tq);return r;
Signature · 1 line
2.1.2
PATCH v2 7/23 ath9k: Clear NoA schedule properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When an active context transitions to inactive state, the NoA schedule needs to be removed for the context that has beaconing enabled. Not doing this will affect p2p clients.
--- drivers/net/wireless/ath/ath9k/channel.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/wireless/ath/ath9k/channel.c +15 -0
@@ -356,6 +356,21 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, "Move chanctx state from WAIT_FOR_TIMER to WAIT_FOR_BEACON\n"); } +/* +* When a context becomes inactive, for example, +* disassociation of a station context, the NoA +* attribute needs to be removed from subsequent +* beacons. +*/ +if (!ctx->active && avp->noa_duration && + sc->sched.state !=ATH_CHANCTX_STATE_WAIT_FOR_BEACON ) { + avp->noa_duration =0 ; + avp->periodic_noa = false; + +ath_dbg (common,CHAN_CTX , +"Clearing NoA schedule\n" ); + } +if (sc->sched.state !=ATH_CHANCTX_STATE_WAIT_FOR_BEACON )break ;
Signature · 1 line
2.1.2
PATCH v2 8/23 ath9k: Use configurable timeout for flush
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
The timeout value for flushing the TX queues is hardcoded at 200ms right now. Use a channel context-specific value instead to allow adjustments to the timeout in case MCC is enabled.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/channel.c | 1 + drivers/net/wireless/ath/ath9k/main.c | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -0
@@ -345,6 +345,7 @@ struct ath_chanctx {u64 tsf_val;u32 last_beacon; +int flush_timeout;u16 txpower;bool offchannel;bool stopped;
drivers/net/wireless/ath/ath9k/channel.c +1 -0
@@ -117,6 +117,7 @@ void ath_chanctx_init(struct ath_softc *sc)cfg80211_chandef_create (&ctx->chandef, chan,NL80211_CHAN_HT20 );INIT_LIST_HEAD (&ctx->vifs); ctx->txpower =ATH_TXPOWER_MAX ; + ctx->flush_timeout =HZ /5 ;/* 200ms */ for (j =0 ; j <ARRAY_SIZE (ctx->acq); j++)INIT_LIST_HEAD (&ctx->acq[j]); }
drivers/net/wireless/ath/ath9k/main.c +8 -1
@@ -2034,7 +2034,7 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)struct ath_softc *sc = hw->priv;struct ath_hw *ah = sc->sc_ah;struct ath_common *common =ath9k_hw_common (ah); -int timeout =HZ /5 ;/* 200 ms */ +int timeout;bool drain_txq;cancel_delayed_work_sync (&sc->tx_complete_work);
@@ -2049,6 +2049,13 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)return ; } +spin_lock_bh (&sc->chan_lock); + timeout = sc->cur_chan->flush_timeout; +spin_unlock_bh (&sc->chan_lock); + +ath_dbg (common,CHAN_CTX , +"Flush timeout: %d\n" ,jiffies_to_msecs (timeout)); +if (wait_event_timeout (sc->tx_wait, !ath9k_has_tx_pending (sc), timeout) >0 ) drop = false;
Signature · 1 line
2.1.2
PATCH v2 9/23 ath9k: Fix MCC flush timeout
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
In MCC mode, the duration for a channel context is half the beacon interval and having a large flush timeout will adversely affect GO operation, since the default value of 200ms will overshoot the advertised NoA absence duration.
The scheduler initiates a channel context switch only when the slot duration for the current context expires, so there is no possibility of having a fixed timeout for flush.
Since the channel_switch_time is added to the absence duration when the GO sets up the NoA attribute, this is the maximum time that we have to flush the TX queues. The duration is very small, but we don't have a choice in MCC mode.
--- drivers/net/wireless/ath/ath9k/channel.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +15 -1
@@ -199,6 +199,7 @@ static const char *chanctx_state_string(enum ath_chanctx_state state)void ath_chanctx_check_active (struct ath_softc *sc,struct ath_chanctx *ctx) {struct ath_common *common =ath9k_hw_common (sc->sc_ah); +struct ath_chanctx *ictx;struct ath_vif *avp;bool active = false;u8 n_active =0 ;
@@ -206,6 +207,8 @@ void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)if (!ctx)return ; + ictx = ctx; +list_for_each_entry (avp, &ctx->vifs, list) {struct ieee80211_vif *vif = avp->vif;
@@ -228,12 +231,23 @@ void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx) n_active++; } +spin_lock_bh (&sc->chan_lock); +if (n_active <=1 ) { + ictx->flush_timeout =HZ /5 ;clear_bit (ATH_OP_MULTI_CHANNEL , &common->op_flags); +spin_unlock_bh (&sc->chan_lock);return ; } -if (test_and_set_bit (ATH_OP_MULTI_CHANNEL , &common->op_flags)) + + ictx->flush_timeout =usecs_to_jiffies (sc->sched.channel_switch_time); + +if (test_and_set_bit (ATH_OP_MULTI_CHANNEL , &common->op_flags)) { +spin_unlock_bh (&sc->chan_lock);return ; + } + +spin_unlock_bh (&sc->chan_lock);if (ath9k_is_chanctx_enabled ()) { ath_chanctx_event(sc, NULL,
Signature · 1 line
2.1.2
PATCH v2 10/23 ath9k: Fix offchannel flush timeout
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
An offchannel operation also needs to have a flush timeout that doesn't exceed the NoA absence duration of a GO context, so use channel_switch_time. The first offchannel operation is set a flush timeout of 10ms since channel_switch_time will be zero.
--- drivers/net/wireless/ath/ath9k/channel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/wireless/ath/ath9k/channel.c +20 -0
@@ -207,6 +207,26 @@ void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)if (!ctx)return ; +if (ctx == &sc->offchannel.chan) { +spin_lock_bh (&sc->chan_lock); + +if (likely (sc->sched.channel_switch_time)) + ctx->flush_timeout = +usecs_to_jiffies (sc->sched.channel_switch_time); +else + ctx->flush_timeout = +msecs_to_jiffies (10 ); + +spin_unlock_bh (&sc->chan_lock); + +/* +* There is no need to iterate over the +* active/assigned channel contexts if +* the current context is offchannel. +*/ +return ; + } + ictx = ctx;list_for_each_entry (avp, &ctx->vifs, list) {
Signature · 1 line
2.1.2
PATCH v2 11/23 ath9k: Check for pending frames properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Pending frames in the driver can be present either in the HW queues or SW. ath9k_has_pending_frames() currently checks for the HW queues first and then checks if any ACs are queued in the driver.
In MCC mode, we need to check the HW queues alone, since the SW queues are just marked as 'stopped' - they will be processed in the next context switch. But since we don't differentiate this now, mention whether we want to check if there are frames in the SW queues.
* The flush() callback checks both HW and SW queues.
* The tx_frames_pending() callback does the same.
* The call to __ath9k_flush() in MCC mode checks HW queues alone.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 3 ++- drivers/net/wireless/ath/ath9k/channel.c | 5 +++-- drivers/net/wireless/ath/ath9k/main.c | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +2 -1
@@ -715,7 +715,8 @@ int ath_update_survey_stats(struct ath_softc *sc);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); +void __ath9k_flush (struct ieee80211_hw *hw,u32 queues,bool drop, +bool sw_pending);/**********/ /* BTCOEX */
drivers/net/wireless/ath/ath9k/channel.c +3 -2
@@ -1137,10 +1137,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); +__ath9k_flush (sc->hw, ~0 , true, false);if (ath_chanctx_send_ps_frame (sc, true)) -__ath9k_flush (sc->hw,BIT (IEEE80211_AC_VO ), false); +__ath9k_flush (sc->hw,BIT (IEEE80211_AC_VO ), + false, false); send_ps = true;spin_lock_bh (&sc->chan_lock);
drivers/net/wireless/ath/ath9k/main.c +14 -7
@@ -54,7 +54,8 @@ u8 ath9k_parse_mpdudensity(u8 mpdudensity) } } -static bool ath9k_has_pending_frames (struct ath_softc *sc,struct ath_txq *txq) +static bool ath9k_has_pending_frames (struct ath_softc *sc,struct ath_txq *txq, +bool sw_pending) {bool pending = false;
@@ -65,6 +66,9 @@ static bool ath9k_has_pending_frames(struct ath_softc *sc, struct ath_txq *txq) goto out; } +if (!sw_pending) + goto out; +if (txq->mac80211_qnum >=0 ) {struct list_head *list;
@@ -2003,7 +2007,8 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw,mutex_unlock (&sc->mutex); } -static bool ath9k_has_tx_pending (struct ath_softc *sc) +static bool ath9k_has_tx_pending (struct ath_softc *sc, +bool sw_pending) {int i, npend =0 ;
@@ -2011,7 +2016,8 @@ static bool ath9k_has_tx_pending(struct ath_softc *sc)if (!ATH_TXQ_SETUP (sc, i))continue ; - npend =ath9k_has_pending_frames (sc, &sc->tx.txq[i]); + npend =ath9k_has_pending_frames (sc, &sc->tx.txq[i], + sw_pending);if (npend)break ; }
@@ -2025,11 +2031,12 @@ static void ath9k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,struct ath_softc *sc = hw->priv;mutex_lock (&sc->mutex); -__ath9k_flush (hw, queues, drop); +__ath9k_flush (hw, queues, drop, true);mutex_unlock (&sc->mutex); } -void __ath9k_flush (struct ieee80211_hw *hw,u32 queues,bool drop) +void __ath9k_flush (struct ieee80211_hw *hw,u32 queues,bool drop, +bool sw_pending) {struct ath_softc *sc = hw->priv;struct ath_hw *ah = sc->sc_ah;
@@ -2056,7 +2063,7 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)ath_dbg (common,CHAN_CTX ,"Flush timeout: %d\n" ,jiffies_to_msecs (timeout)); -if (wait_event_timeout (sc->tx_wait, !ath9k_has_tx_pending (sc), +if (wait_event_timeout (sc->tx_wait, !ath9k_has_tx_pending (sc, sw_pending), timeout) >0 ) drop = false;
@@ -2079,7 +2086,7 @@ static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw) {struct ath_softc *sc = hw->priv; -return ath9k_has_tx_pending (sc); +return ath9k_has_tx_pending (sc, true); }static int ath9k_tx_last_beacon (struct ieee80211_hw *hw)
Signature · 1 line
2.1.2
PATCH v2 12/23 ath9k: Send AUTHORIZED event only for station mode
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
ATH_CHANCTX_EVENT_AUTHORIZED is required to trigger the MCC scheduler when a station interface becomes authorized. But, since the driver gets station state notifications when the current operating mode is AP too, make sure that we send ATH_CHANCTX_EVENT_AUTHORIZED only when the interface is in station mode.
--- drivers/net/wireless/ath/ath9k/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +6 -4
@@ -1590,10 +1590,12 @@ static int ath9k_sta_state(struct ieee80211_hw *hw, }if (ath9k_is_chanctx_enabled ()) { -if (old_state ==IEEE80211_STA_ASSOC && - new_state ==IEEE80211_STA_AUTHORIZED ) -ath_chanctx_event (sc, vif, -ATH_CHANCTX_EVENT_AUTHORIZED ); +if (vif->type ==NL80211_IFTYPE_STATION ) { +if (old_state ==IEEE80211_STA_ASSOC && + new_state ==IEEE80211_STA_AUTHORIZED ) +ath_chanctx_event (sc, vif, +ATH_CHANCTX_EVENT_AUTHORIZED ); + } }return ret;
Signature · 1 line
2.1.2
PATCH v2 13/23 ath9k: Fix address management
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Since both the arguments need to satisfy the alignment requirements of ether_addr_copy(), use memcpy() in cases where there will be no big performance benefit and make sure that ether_addr_copy() calls use properly aligned arguments.
--- drivers/net/wireless/ath/ath.h | 2 +- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- drivers/net/wireless/ath/ath9k/main.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath.h +1 -1
@@ -147,7 +147,7 @@ struct ath_common {u16 cachelsz;u16 curaid;u8 macaddr[ETH_ALEN ]; -u8 curbssid[ETH_ALEN ]; +u8 curbssid[ETH_ALEN ]__aligned(2) ;u8 bssidmask[ETH_ALEN ];u32 rx_bufsize;
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
@@ -595,7 +595,7 @@ struct ath_vif {u16 seq_no;/* BSS info */ -u8 bssid[ETH_ALEN ]; +u8 bssid[ETH_ALEN ]__aligned(2) ;u16 aid;bool assoc;
drivers/net/wireless/ath/ath9k/main.c +3 -3
@@ -1057,7 +1057,7 @@ static void ath9k_set_offchannel_state(struct ath_softc *sc)eth_zero_addr (common->curbssid);eth_broadcast_addr (common->bssidmask); -ether_addr_copy (common->macaddr, vif->addr); +memcpy (common->macaddr, vif->addr,ETH_ALEN ); common->curaid =0 ; ah->opmode = vif->type; ah->imask &= ~ATH9K_INT_SWBA ;
@@ -1098,7 +1098,7 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,ath9k_calculate_iter_data (sc, ctx, &iter_data);if (iter_data.has_hw_macaddr) -ether_addr_copy (common->macaddr, iter_data.hw_macaddr); +memcpy (common->macaddr, iter_data.hw_macaddr,ETH_ALEN );memcpy (common->bssidmask, iter_data.mask,ETH_ALEN );ath_hw_setbssidmask (common);
@@ -1785,7 +1785,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,ath_dbg (common,CONFIG ,"BSSID %pM Changed ASSOC %d\n" , bss_conf->bssid, bss_conf->assoc); -ether_addr_copy (avp->bssid, bss_conf->bssid); +memcpy (avp->bssid, bss_conf->bssid,ETH_ALEN ); avp->aid = bss_conf->aid; avp->assoc = bss_conf->assoc;
Signature · 1 line
2.1.2
PATCH v2 14/23 ath9k: Add a function to check for an active GO
In reply to Sujith ManoharanFrom: 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 v2 15/23 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 v2 16/23 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 v2 17/23 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 v2 18/23 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 v2 19/23 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 v2 20/23 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 v2 21/23 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 v2 22/23 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
PATCH v2 23/23 ath9k: Do not start BA when scanning
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
mac80211 currently has a race which can be hit with this sequence:
* Start a scan operation.
* TX BA is initiated by ieee80211_start_tx_ba_session().
* Driver sets up internal state and calls ieee80211_start_tx_ba_cb_irqsafe().
* mac80211 adds a packet to sdata->skb_queue with type IEEE80211_SDATA_QUEUE_AGG_START.
* ieee80211_iface_work() doesn't process the packet because scan is in progress.
* ADDBA response timer expires and the sta/tid is torn down.
* Driver receives BA stop notification and calls ieee80211_stop_tx_ba_cb_irqsafe().
* This is also added to the queue by mac80211.
* Now, scan finishes.
At this point, the queued up packets might be processed if some other operation schedules the sdata work. Since the tids have been cleaned up already, warnings are hit.
If this doesn't happen, the packets are left in the queue until the interface is torn down.
Since initiating a BA session when scan is in progress leads to flaky connections, especially in MCC mode, we can drop the TX BA request. This improves connectivity with legacy clients in MCC mode.
--- drivers/net/wireless/ath/ath9k/main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/ath/ath9k/main.c +7 -0
@@ -1885,6 +1885,7 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw, u16 tid, u16 *ssn, u8 buf_size) { struct ath_softc *sc = hw->priv; +struct ath_common *common =ath9k_hw_common (sc->sc_ah);bool flush = false;int ret =0 ;
@@ -1896,6 +1897,12 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,case IEEE80211_AMPDU_RX_STOP :break ;case IEEE80211_AMPDU_TX_START : +if (ath9k_is_chanctx_enabled ()) { +if (test_bit (ATH_OP_SCANNING , &common->op_flags)) { + ret = -EBUSY ; +break ; + } + }ath9k_ps_wakeup (sc); ret =ath_tx_aggr_start (sc, sta, tid, ssn);if (!ret)
Signature · 1 line
2.1.2
Re: [PATCH v2 23/23] ath9k: Do not start BA when scanning
Quoted 4 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
mac80211 currently has a race which can be hit
with this sequence:
If it's a mac80211 race, wouldn't it make sense to fix it in mac80211?
johannes
Re: [PATCH v2 23/23] ath9k: Do not start BA when scanning
Quoted 1 line · Johannes Berg
If it's a mac80211 race, wouldn't it make sense to fix it in mac80211?
Yes, definitely. :-)
But, we also ran into issues where starting a BA session when HW scan was in progress (with MCC enabled) caused connectivity problems, hence this fix in ath9k.
Regarding the BA race, would it make sense to flush sdata->work after scan completion ?
Sujith
Re: [PATCH v2 23/23] ath9k: Do not start BA when scanning
Quoted 8 lines · Sujith Manoharan
Quoted 1 line · Johannes Berg
If it's a mac80211 race, wouldn't it make sense to fix it in mac80211?
Yes, definitely. :-)
But, we also ran into issues where starting a BA session when HW scan was in progress (with MCC enabled) caused connectivity problems, hence this fix in ath9k.
mac80211 is also aware of HW scanning, but I'm not sure what it should do, I guess.
Quoted 2 lines
Regarding the BA race, would it make sense to flush
sdata->workafter scan completion ?
Err, no idea, I haven't really looked :)
johannes