1 --- a/drivers/net/wireless/ath/ath9k/mac.c
2 +++ b/drivers/net/wireless/ath/ath9k/mac.c
3 @@ -766,14 +766,6 @@ void ath9k_hw_startpcureceive(struct ath
5 EXPORT_SYMBOL(ath9k_hw_startpcureceive);
7 -void ath9k_hw_stoppcurecv(struct ath_hw *ah)
9 - REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
11 - ath9k_hw_disable_mib_counters(ah);
13 -EXPORT_SYMBOL(ath9k_hw_stoppcurecv);
15 void ath9k_hw_abortpcurecv(struct ath_hw *ah)
17 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS);
18 --- a/drivers/net/wireless/ath/ath9k/mac.h
19 +++ b/drivers/net/wireless/ath/ath9k/mac.h
20 @@ -691,7 +691,6 @@ void ath9k_hw_setuprxdesc(struct ath_hw
21 bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set);
22 void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
23 void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
24 -void ath9k_hw_stoppcurecv(struct ath_hw *ah);
25 void ath9k_hw_abortpcurecv(struct ath_hw *ah);
26 bool ath9k_hw_stopdmarecv(struct ath_hw *ah);
27 int ath9k_hw_beaconq_setup(struct ath_hw *ah);
28 --- a/drivers/net/wireless/ath/ath9k/recv.c
29 +++ b/drivers/net/wireless/ath/ath9k/recv.c
30 @@ -518,7 +518,7 @@ bool ath_stoprecv(struct ath_softc *sc)
33 spin_lock_bh(&sc->rx.rxbuflock);
34 - ath9k_hw_stoppcurecv(ah);
35 + ath9k_hw_abortpcurecv(ah);
36 ath9k_hw_setrxfilter(ah, 0);
37 stopped = ath9k_hw_stopdmarecv(ah);
39 --- a/drivers/net/wireless/ath/ath9k/xmit.c
40 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
41 @@ -163,6 +163,7 @@ static void ath_tx_flush_tid(struct ath_
42 bf = list_first_entry(&tid->buf_q, struct ath_buf, list);
43 list_move_tail(&bf->list, &bf_head);
45 + spin_unlock_bh(&txq->axq_lock);
46 fi = get_frame_info(bf->bf_mpdu);
48 ath_tx_update_baw(sc, tid, fi->seqno);
49 @@ -170,6 +171,7 @@ static void ath_tx_flush_tid(struct ath_
51 ath_tx_send_normal(sc, txq, tid, &bf_head);
53 + spin_lock_bh(&txq->axq_lock);
56 spin_unlock_bh(&txq->axq_lock);
57 --- a/net/mac80211/ieee80211_i.h
58 +++ b/net/mac80211/ieee80211_i.h
59 @@ -349,6 +349,7 @@ struct ieee80211_if_managed {
60 struct work_struct chswitch_work;
61 struct work_struct beacon_connection_loss_work;
63 + unsigned long beacon_timeout;
64 unsigned long probe_timeout;
67 @@ -1269,6 +1270,8 @@ void ieee80211_send_nullfunc(struct ieee
69 void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
70 struct ieee80211_hdr *hdr);
71 +void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
72 + struct ieee80211_hdr *hdr);
73 void ieee80211_beacon_connection_loss_work(struct work_struct *work);
75 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
76 --- a/net/mac80211/mlme.c
77 +++ b/net/mac80211/mlme.c
82 +#define IEEE80211_MAX_NULLFUNC_TRIES 2
83 #define IEEE80211_MAX_PROBE_TRIES 5
86 - * beacon loss detection timeout
87 - * XXX: should depend on beacon interval
88 + * Beacon loss timeout is calculated as N frames times the
89 + * advertised beacon interval. This may need to be somewhat
90 + * higher than what hardware might detect to account for
91 + * delays in the host processing frames. But since we also
92 + * probe on beacon miss before declaring the connection lost
93 + * default to what we want.
95 -#define IEEE80211_BEACON_LOSS_TIME (2 * HZ)
96 +#define IEEE80211_BEACON_LOSS_COUNT 7
99 * Time the connection can be idle before we probe
100 * it to see if we can still talk to the AP.
101 @@ -121,7 +127,7 @@ void ieee80211_sta_reset_beacon_monitor(
104 mod_timer(&sdata->u.mgd.bcn_mon_timer,
105 - round_jiffies_up(jiffies + IEEE80211_BEACON_LOSS_TIME));
106 + round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout));
109 void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata)
110 @@ -871,6 +877,9 @@ static void ieee80211_set_associated(str
111 bss_info_changed |= ieee80211_handle_bss_capability(sdata,
112 cbss->capability, bss->has_erp_value, bss->erp_value);
114 + sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec(
115 + IEEE80211_BEACON_LOSS_COUNT * bss_conf->beacon_int));
117 sdata->u.mgd.associated = cbss;
118 memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN);
120 @@ -1026,6 +1035,51 @@ void ieee80211_sta_rx_notify(struct ieee
121 ieee80211_sta_reset_conn_monitor(sdata);
124 +static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata)
126 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
128 + if (!(ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
129 + IEEE80211_STA_CONNECTION_POLL)))
132 + ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
133 + IEEE80211_STA_BEACON_POLL);
134 + mutex_lock(&sdata->local->iflist_mtx);
135 + ieee80211_recalc_ps(sdata->local, -1);
136 + mutex_unlock(&sdata->local->iflist_mtx);
138 + if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
142 + * We've received a probe response, but are not sure whether
143 + * we have or will be receiving any beacons or data, so let's
144 + * schedule the timers again, just in case.
146 + ieee80211_sta_reset_beacon_monitor(sdata);
148 + mod_timer(&ifmgd->conn_mon_timer,
149 + round_jiffies_up(jiffies +
150 + IEEE80211_CONNECTION_IDLE_TIME));
153 +void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
154 + struct ieee80211_hdr *hdr)
156 + if (!ieee80211_is_data(hdr->frame_control) &&
157 + !ieee80211_is_nullfunc(hdr->frame_control))
160 + ieee80211_sta_reset_conn_monitor(sdata);
162 + if (ieee80211_is_nullfunc(hdr->frame_control) &&
163 + sdata->u.mgd.probe_send_count > 0) {
164 + sdata->u.mgd.probe_send_count = 0;
165 + ieee80211_queue_work(&sdata->local->hw, &sdata->work);
169 static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
171 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
172 @@ -1041,8 +1095,19 @@ static void ieee80211_mgd_probe_ap_send(
173 if (ifmgd->probe_send_count >= unicast_limit)
176 - ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
177 - ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0);
179 + * When the hardware reports an accurate Tx ACK status, it's
180 + * better to send a nullfunc frame instead of a probe request,
181 + * as it will kick us off the AP quickly if we aren't associated
182 + * anymore. The timeout will be reset if the frame is ACKed by
185 + if (sdata->local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
186 + ieee80211_send_nullfunc(sdata->local, sdata, 0);
188 + ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
189 + ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0);
192 ifmgd->probe_send_count++;
193 ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
194 @@ -1509,29 +1574,8 @@ static void ieee80211_rx_mgmt_probe_resp
195 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
197 if (ifmgd->associated &&
198 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0 &&
199 - ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
200 - IEEE80211_STA_CONNECTION_POLL)) {
201 - ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
202 - IEEE80211_STA_BEACON_POLL);
203 - mutex_lock(&sdata->local->iflist_mtx);
204 - ieee80211_recalc_ps(sdata->local, -1);
205 - mutex_unlock(&sdata->local->iflist_mtx);
207 - if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
211 - * We've received a probe response, but are not sure whether
212 - * we have or will be receiving any beacons or data, so let's
213 - * schedule the timers again, just in case.
215 - ieee80211_sta_reset_beacon_monitor(sdata);
217 - mod_timer(&ifmgd->conn_mon_timer,
218 - round_jiffies_up(jiffies +
219 - IEEE80211_CONNECTION_IDLE_TIME));
221 + memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0)
222 + ieee80211_reset_ap_probe(sdata);
226 @@ -1881,12 +1925,23 @@ void ieee80211_sta_work(struct ieee80211
227 IEEE80211_STA_CONNECTION_POLL) &&
232 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
233 + max_tries = IEEE80211_MAX_NULLFUNC_TRIES;
235 + max_tries = IEEE80211_MAX_PROBE_TRIES;
237 memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
238 - if (time_is_after_jiffies(ifmgd->probe_timeout))
240 + /* ACK received for nullfunc probing frame */
241 + if (!ifmgd->probe_send_count)
242 + ieee80211_reset_ap_probe(sdata);
244 + else if (time_is_after_jiffies(ifmgd->probe_timeout))
245 run_again(ifmgd, ifmgd->probe_timeout);
247 - else if (ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES) {
248 + else if (ifmgd->probe_send_count < max_tries) {
249 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
250 wiphy_debug(local->hw.wiphy,
251 "%s: No probe response from AP %pM"
252 @@ -2012,6 +2067,8 @@ void ieee80211_sta_restart(struct ieee80
253 add_timer(&ifmgd->timer);
254 if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running))
255 add_timer(&ifmgd->chswitch_timer);
256 + ieee80211_sta_reset_beacon_monitor(sdata);
257 + ieee80211_send_nullfunc(sdata->local, sdata, 0);
261 --- a/net/mac80211/status.c
262 +++ b/net/mac80211/status.c
263 @@ -155,6 +155,10 @@ static void ieee80211_frame_acked(struct
265 ieee80211_queue_work(&local->hw, &local->recalc_smps);
268 + if ((sdata->vif.type == NL80211_IFTYPE_STATION) &&
269 + (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS))
270 + ieee80211_sta_tx_notify(sdata, (void *) skb->data);
273 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)