mac80211: revert the probe request timeout change
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 311-pending_work.patch
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
4 }
5 EXPORT_SYMBOL(ath9k_hw_startpcureceive);
6
7 -void ath9k_hw_stoppcurecv(struct ath_hw *ah)
8 -{
9 - REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
10 -
11 - ath9k_hw_disable_mib_counters(ah);
12 -}
13 -EXPORT_SYMBOL(ath9k_hw_stoppcurecv);
14 -
15 void ath9k_hw_abortpcurecv(struct ath_hw *ah)
16 {
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)
31 bool stopped;
32
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);
38
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);
44
45 + spin_unlock_bh(&txq->axq_lock);
46 fi = get_frame_info(bf->bf_mpdu);
47 if (fi->retries) {
48 ath_tx_update_baw(sc, tid, fi->seqno);
49 @@ -170,6 +171,7 @@ static void ath_tx_flush_tid(struct ath_
50 } else {
51 ath_tx_send_normal(sc, txq, tid, &bf_head);
52 }
53 + spin_lock_bh(&txq->axq_lock);
54 }
55
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;
62
63 + unsigned long beacon_timeout;
64 unsigned long probe_timeout;
65 int probe_send_count;
66
67 @@ -1269,6 +1270,8 @@ void ieee80211_send_nullfunc(struct ieee
68 int powersave);
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);
74
75 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
76 --- a/net/mac80211/mlme.c
77 +++ b/net/mac80211/mlme.c
78 @@ -28,13 +28,19 @@
79 #include "rate.h"
80 #include "led.h"
81
82 +#define IEEE80211_MAX_NULLFUNC_TRIES 2
83 #define IEEE80211_MAX_PROBE_TRIES 5
84
85 /*
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.
94 */
95 -#define IEEE80211_BEACON_LOSS_TIME (2 * HZ)
96 +#define IEEE80211_BEACON_LOSS_COUNT 7
97 +
98 /*
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(
102 return;
103
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));
107 }
108
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);
113
114 + sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec(
115 + IEEE80211_BEACON_LOSS_COUNT * bss_conf->beacon_int));
116 +
117 sdata->u.mgd.associated = cbss;
118 memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN);
119
120 @@ -1026,6 +1035,50 @@ void ieee80211_sta_rx_notify(struct ieee
121 ieee80211_sta_reset_conn_monitor(sdata);
122 }
123
124 +static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata)
125 +{
126 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
127 +
128 + if (!(ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
129 + IEEE80211_STA_CONNECTION_POLL)))
130 + return;
131 +
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);
137 +
138 + if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
139 + return;
140 +
141 + /*
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.
145 + */
146 + ieee80211_sta_reset_beacon_monitor(sdata);
147 +
148 + mod_timer(&ifmgd->conn_mon_timer,
149 + round_jiffies_up(jiffies +
150 + IEEE80211_CONNECTION_IDLE_TIME));
151 +}
152 +
153 +void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
154 + struct ieee80211_hdr *hdr)
155 +{
156 + if (!ieee80211_is_data(hdr->frame_control) &&
157 + !ieee80211_is_nullfunc(hdr->frame_control))
158 + return;
159 +
160 + ieee80211_sta_reset_conn_monitor(sdata);
161 +
162 + if (ieee80211_is_nullfunc(hdr->frame_control)) {
163 + sdata->u.mgd.probe_send_count = 0;
164 + ieee80211_queue_work(&sdata->local->hw, &sdata->work);
165 + }
166 +}
167 +
168 static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
169 {
170 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
171 @@ -1041,8 +1094,19 @@ static void ieee80211_mgd_probe_ap_send(
172 if (ifmgd->probe_send_count >= unicast_limit)
173 dst = NULL;
174
175 - ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
176 - ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0);
177 + /*
178 + * When the hardware reports an accurate Tx ACK status, it's
179 + * better to send a nullfunc frame instead of a probe request,
180 + * as it will kick us off the AP quickly if we aren't associated
181 + * anymore. The timeout will be reset if the frame is ACKed by
182 + * the AP.
183 + */
184 + if (sdata->local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
185 + ieee80211_send_nullfunc(sdata->local, sdata, 0);
186 + else {
187 + ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
188 + ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0);
189 + }
190
191 ifmgd->probe_send_count++;
192 ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
193 @@ -1509,29 +1573,8 @@ static void ieee80211_rx_mgmt_probe_resp
194 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
195
196 if (ifmgd->associated &&
197 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0 &&
198 - ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
199 - IEEE80211_STA_CONNECTION_POLL)) {
200 - ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
201 - IEEE80211_STA_BEACON_POLL);
202 - mutex_lock(&sdata->local->iflist_mtx);
203 - ieee80211_recalc_ps(sdata->local, -1);
204 - mutex_unlock(&sdata->local->iflist_mtx);
205 -
206 - if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
207 - return;
208 -
209 - /*
210 - * We've received a probe response, but are not sure whether
211 - * we have or will be receiving any beacons or data, so let's
212 - * schedule the timers again, just in case.
213 - */
214 - ieee80211_sta_reset_beacon_monitor(sdata);
215 -
216 - mod_timer(&ifmgd->conn_mon_timer,
217 - round_jiffies_up(jiffies +
218 - IEEE80211_CONNECTION_IDLE_TIME));
219 - }
220 + memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0)
221 + ieee80211_reset_ap_probe(sdata);
222 }
223
224 /*
225 @@ -1881,12 +1924,22 @@ void ieee80211_sta_work(struct ieee80211
226 IEEE80211_STA_CONNECTION_POLL) &&
227 ifmgd->associated) {
228 u8 bssid[ETH_ALEN];
229 + int max_tries;
230 +
231 + /* ACK received for nullfunc probing frame */
232 + if (!ifmgd->probe_send_count)
233 + ieee80211_reset_ap_probe(sdata);
234 +
235 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
236 + max_tries = IEEE80211_MAX_NULLFUNC_TRIES;
237 + else
238 + max_tries = IEEE80211_MAX_PROBE_TRIES;
239
240 memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
241 if (time_is_after_jiffies(ifmgd->probe_timeout))
242 run_again(ifmgd, ifmgd->probe_timeout);
243
244 - else if (ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES) {
245 + else if (ifmgd->probe_send_count < max_tries) {
246 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
247 wiphy_debug(local->hw.wiphy,
248 "%s: No probe response from AP %pM"
249 @@ -2012,6 +2065,8 @@ void ieee80211_sta_restart(struct ieee80
250 add_timer(&ifmgd->timer);
251 if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running))
252 add_timer(&ifmgd->chswitch_timer);
253 + ieee80211_sta_reset_beacon_monitor(sdata);
254 + ieee80211_send_nullfunc(sdata->local, sdata, 0);
255 }
256 #endif
257
258 --- a/net/mac80211/status.c
259 +++ b/net/mac80211/status.c
260 @@ -155,6 +155,10 @@ static void ieee80211_frame_acked(struct
261
262 ieee80211_queue_work(&local->hw, &local->recalc_smps);
263 }
264 +
265 + if ((sdata->vif.type == NL80211_IFTYPE_STATION) &&
266 + (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS))
267 + ieee80211_sta_tx_notify(sdata, (void *) skb->data);
268 }
269
270 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)