569bf7f06a8eff48c62e0faedbf07e959a900c38
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/common.h
2 +++ b/drivers/net/wireless/ath/ath9k/common.h
3 @@ -27,7 +27,7 @@
4 #define WME_MAX_BA WME_BA_BMP_SIZE
5 #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
6
7 -#define ATH_RSSI_DUMMY_MARKER 0x127
8 +#define ATH_RSSI_DUMMY_MARKER 127
9 #define ATH_RSSI_LPF_LEN 10
10 #define RSSI_LPF_THRESHOLD -20
11 #define ATH_RSSI_EP_MULTIPLIER (1<<7)
12 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
13 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
14 @@ -1067,15 +1067,19 @@ static bool ath9k_rx_prepare(struct ath9
15
16 last_rssi = priv->rx.last_rssi;
17
18 - if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
19 - rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
20 - ATH_RSSI_EP_MULTIPLIER);
21 + if (ieee80211_is_beacon(hdr->frame_control) &&
22 + !is_zero_ether_addr(common->curbssid) &&
23 + ether_addr_equal(hdr->addr3, common->curbssid)) {
24 + s8 rssi = rxbuf->rxstatus.rs_rssi;
25
26 - if (rxbuf->rxstatus.rs_rssi < 0)
27 - rxbuf->rxstatus.rs_rssi = 0;
28 + if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
29 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
30
31 - if (ieee80211_is_beacon(fc))
32 - priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
33 + if (rssi < 0)
34 + rssi = 0;
35 +
36 + priv->ah->stats.avgbrssi = rssi;
37 + }
38
39 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
40 rx_status->band = hw->conf.channel->band;
41 --- a/include/linux/ieee80211.h
42 +++ b/include/linux/ieee80211.h
43 @@ -185,7 +185,7 @@ struct ieee80211_hdr {
44 u8 addr3[6];
45 __le16 seq_ctrl;
46 u8 addr4[6];
47 -} __packed;
48 +} __packed __aligned(2);
49
50 struct ieee80211_hdr_3addr {
51 __le16 frame_control;
52 @@ -194,7 +194,7 @@ struct ieee80211_hdr_3addr {
53 u8 addr2[6];
54 u8 addr3[6];
55 __le16 seq_ctrl;
56 -} __packed;
57 +} __packed __aligned(2);
58
59 struct ieee80211_qos_hdr {
60 __le16 frame_control;
61 @@ -204,7 +204,7 @@ struct ieee80211_qos_hdr {
62 u8 addr3[6];
63 __le16 seq_ctrl;
64 __le16 qos_ctrl;
65 -} __packed;
66 +} __packed __aligned(2);
67
68 /**
69 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
70 @@ -581,7 +581,7 @@ struct ieee80211s_hdr {
71 __le32 seqnum;
72 u8 eaddr1[6];
73 u8 eaddr2[6];
74 -} __packed;
75 +} __packed __aligned(2);
76
77 /* Mesh flags */
78 #define MESH_FLAGS_AE_A4 0x1
79 @@ -875,7 +875,7 @@ struct ieee80211_mgmt {
80 } u;
81 } __packed action;
82 } u;
83 -} __packed;
84 +} __packed __aligned(2);
85
86 /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
87 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
88 @@ -906,20 +906,20 @@ struct ieee80211_rts {
89 __le16 duration;
90 u8 ra[6];
91 u8 ta[6];
92 -} __packed;
93 +} __packed __aligned(2);
94
95 struct ieee80211_cts {
96 __le16 frame_control;
97 __le16 duration;
98 u8 ra[6];
99 -} __packed;
100 +} __packed __aligned(2);
101
102 struct ieee80211_pspoll {
103 __le16 frame_control;
104 __le16 aid;
105 u8 bssid[6];
106 u8 ta[6];
107 -} __packed;
108 +} __packed __aligned(2);
109
110 /* TDLS */
111
112 --- a/net/mac80211/agg-rx.c
113 +++ b/net/mac80211/agg-rx.c
114 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
115 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
116 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
117 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
118 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
119 + memcpy(mgmt->bssid, da, ETH_ALEN);
120
121 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
122 IEEE80211_STYPE_ACTION);
123 --- a/net/mac80211/agg-tx.c
124 +++ b/net/mac80211/agg-tx.c
125 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
126 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
127 if (sdata->vif.type == NL80211_IFTYPE_AP ||
128 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
129 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
130 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
131 + sdata->vif.type == NL80211_IFTYPE_WDS)
132 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
133 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
134 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
135 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
136 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
137 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
138 sdata->vif.type != NL80211_IFTYPE_AP &&
139 + sdata->vif.type != NL80211_IFTYPE_WDS &&
140 sdata->vif.type != NL80211_IFTYPE_ADHOC)
141 return -EINVAL;
142
143 --- a/net/mac80211/debugfs_sta.c
144 +++ b/net/mac80211/debugfs_sta.c
145 @@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
146 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
147
148 int res = scnprintf(buf, sizeof(buf),
149 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
150 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
151 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
152 TEST(PS_DRIVER), TEST(AUTHORIZED),
153 TEST(SHORT_PREAMBLE),
154 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
155 + TEST(WME), TEST(CLEAR_PS_FILT),
156 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
157 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
158 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
159 --- a/net/mac80211/iface.c
160 +++ b/net/mac80211/iface.c
161 @@ -78,7 +78,7 @@ void ieee80211_recalc_txpower(struct iee
162 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
163 }
164
165 -static u32 ieee80211_idle_off(struct ieee80211_local *local)
166 +u32 ieee80211_idle_off(struct ieee80211_local *local)
167 {
168 if (!(local->hw.conf.flags & IEEE80211_CONF_IDLE))
169 return 0;
170 @@ -107,7 +107,7 @@ void ieee80211_recalc_idle(struct ieee80
171
172 lockdep_assert_held(&local->mtx);
173
174 - active = !list_empty(&local->chanctx_list);
175 + active = !list_empty(&local->chanctx_list) || local->monitors;
176
177 if (!local->ops->remain_on_channel) {
178 list_for_each_entry(roc, &local->roc_list, list) {
179 @@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
180 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
181 struct net_device *dev = wdev->netdev;
182 struct ieee80211_local *local = sdata->local;
183 - struct sta_info *sta;
184 u32 changed = 0;
185 int res;
186 u32 hw_reconf_flags = 0;
187 @@ -541,6 +540,9 @@ int ieee80211_do_open(struct wireless_de
188
189 ieee80211_adjust_monitor_flags(sdata, 1);
190 ieee80211_configure_filter(local);
191 + mutex_lock(&local->mtx);
192 + ieee80211_recalc_idle(local);
193 + mutex_unlock(&local->mtx);
194
195 netif_carrier_on(dev);
196 break;
197 @@ -595,30 +597,8 @@ int ieee80211_do_open(struct wireless_de
198
199 set_bit(SDATA_STATE_RUNNING, &sdata->state);
200
201 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
202 - /* Create STA entry for the WDS peer */
203 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
204 - GFP_KERNEL);
205 - if (!sta) {
206 - res = -ENOMEM;
207 - goto err_del_interface;
208 - }
209 -
210 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
211 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
212 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
213 -
214 - res = sta_info_insert(sta);
215 - if (res) {
216 - /* STA has been freed */
217 - goto err_del_interface;
218 - }
219 -
220 - rate_control_rate_init(sta);
221 - netif_carrier_on(dev);
222 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
223 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
224 rcu_assign_pointer(local->p2p_sdata, sdata);
225 - }
226
227 /*
228 * set_multicast_list will be invoked by the networking core
229 @@ -817,6 +797,9 @@ static void ieee80211_do_stop(struct iee
230
231 ieee80211_adjust_monitor_flags(sdata, -1);
232 ieee80211_configure_filter(local);
233 + mutex_lock(&local->mtx);
234 + ieee80211_recalc_idle(local);
235 + mutex_unlock(&local->mtx);
236 break;
237 case NL80211_IFTYPE_P2P_DEVICE:
238 /* relies on synchronize_rcu() below */
239 @@ -1022,6 +1005,72 @@ static void ieee80211_if_setup(struct ne
240 dev->destructor = free_netdev;
241 }
242
243 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
244 + struct sk_buff *skb)
245 +{
246 + struct ieee80211_local *local = sdata->local;
247 + struct ieee80211_rx_status *rx_status;
248 + struct ieee802_11_elems elems;
249 + struct ieee80211_mgmt *mgmt;
250 + struct sta_info *sta;
251 + size_t baselen;
252 + u32 rates = 0;
253 + u16 stype;
254 + bool new = false;
255 + enum ieee80211_band band = local->hw.conf.channel->band;
256 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
257 +
258 + rx_status = IEEE80211_SKB_RXCB(skb);
259 + mgmt = (struct ieee80211_mgmt *) skb->data;
260 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
261 +
262 + if (stype != IEEE80211_STYPE_BEACON)
263 + return;
264 +
265 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
266 + if (baselen > skb->len)
267 + return;
268 +
269 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
270 + skb->len - baselen, &elems);
271 +
272 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
273 +
274 + rcu_read_lock();
275 +
276 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
277 +
278 + if (!sta) {
279 + rcu_read_unlock();
280 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
281 + GFP_KERNEL);
282 + if (!sta)
283 + return;
284 +
285 + new = true;
286 + }
287 +
288 + sta->last_rx = jiffies;
289 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
290 +
291 + if (elems.ht_cap_elem)
292 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
293 + elems.ht_cap_elem, sta);
294 +
295 + if (elems.wmm_param)
296 + set_sta_flag(sta, WLAN_STA_WME);
297 +
298 + if (new) {
299 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
300 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
301 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
302 + rate_control_rate_init(sta);
303 + sta_info_insert_rcu(sta);
304 + }
305 +
306 + rcu_read_unlock();
307 +}
308 +
309 static void ieee80211_iface_work(struct work_struct *work)
310 {
311 struct ieee80211_sub_if_data *sdata =
312 @@ -1126,6 +1175,9 @@ static void ieee80211_iface_work(struct
313 break;
314 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
315 break;
316 + case NL80211_IFTYPE_WDS:
317 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
318 + break;
319 default:
320 WARN(1, "frame for unexpected interface type");
321 break;
322 --- a/net/mac80211/rx.c
323 +++ b/net/mac80211/rx.c
324 @@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
325 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
326 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
327 sdata->vif.type != NL80211_IFTYPE_AP &&
328 + sdata->vif.type != NL80211_IFTYPE_WDS &&
329 sdata->vif.type != NL80211_IFTYPE_ADHOC)
330 break;
331
332 @@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
333
334 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
335 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
336 - sdata->vif.type != NL80211_IFTYPE_STATION)
337 + sdata->vif.type != NL80211_IFTYPE_STATION &&
338 + sdata->vif.type != NL80211_IFTYPE_WDS)
339 return RX_DROP_MONITOR;
340
341 switch (stype) {
342 case cpu_to_le16(IEEE80211_STYPE_AUTH):
343 case cpu_to_le16(IEEE80211_STYPE_BEACON):
344 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
345 - /* process for all: mesh, mlme, ibss */
346 + /* process for all: mesh, mlme, ibss, wds */
347 break;
348 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
349 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
350 @@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
351 }
352 break;
353 case NL80211_IFTYPE_WDS:
354 - if (bssid || !ieee80211_is_data(hdr->frame_control))
355 - return 0;
356 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
357 return 0;
358 +
359 + if (ieee80211_is_data(hdr->frame_control) ||
360 + ieee80211_is_action(hdr->frame_control)) {
361 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
362 + return 0;
363 + } else if (!ieee80211_is_beacon(hdr->frame_control))
364 + return 0;
365 +
366 break;
367 case NL80211_IFTYPE_P2P_DEVICE:
368 if (!ieee80211_is_public_action(hdr, skb->len) &&
369 --- a/net/mac80211/sta_info.h
370 +++ b/net/mac80211/sta_info.h
371 @@ -32,7 +32,6 @@
372 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
373 * frames.
374 * @WLAN_STA_WME: Station is a QoS-STA.
375 - * @WLAN_STA_WDS: Station is one of our WDS peers.
376 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
377 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
378 * frame to this station is transmitted.
379 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
380 WLAN_STA_AUTHORIZED,
381 WLAN_STA_SHORT_PREAMBLE,
382 WLAN_STA_WME,
383 - WLAN_STA_WDS,
384 WLAN_STA_CLEAR_PS_FILT,
385 WLAN_STA_MFP,
386 WLAN_STA_BLOCK_BA,
387 --- a/net/mac80211/tx.c
388 +++ b/net/mac80211/tx.c
389 @@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
390 if (local->queue_stop_reasons[q] ||
391 (!txpending && !skb_queue_empty(&local->pending[q]))) {
392 if (unlikely(info->flags &
393 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
394 - local->queue_stop_reasons[q] &
395 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
396 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
397 + if (local->queue_stop_reasons[q] &
398 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
399 + /*
400 + * Drop off-channel frames if queues
401 + * are stopped for any reason other
402 + * than off-channel operation. Never
403 + * queue them.
404 + */
405 + spin_unlock_irqrestore(
406 + &local->queue_stop_reason_lock,
407 + flags);
408 + ieee80211_purge_tx_queue(&local->hw,
409 + skbs);
410 + return true;
411 + }
412 + } else {
413 +
414 /*
415 - * Drop off-channel frames if queues are stopped
416 - * for any reason other than off-channel
417 - * operation. Never queue them.
418 + * Since queue is stopped, queue up frames for
419 + * later transmission from the tx-pending
420 + * tasklet when the queue is woken again.
421 */
422 - spin_unlock_irqrestore(
423 - &local->queue_stop_reason_lock, flags);
424 - ieee80211_purge_tx_queue(&local->hw, skbs);
425 - return true;
426 + if (txpending)
427 + skb_queue_splice_init(skbs,
428 + &local->pending[q]);
429 + else
430 + skb_queue_splice_tail_init(skbs,
431 + &local->pending[q]);
432 +
433 + spin_unlock_irqrestore(&local->queue_stop_reason_lock,
434 + flags);
435 + return false;
436 }
437 -
438 - /*
439 - * Since queue is stopped, queue up frames for later
440 - * transmission from the tx-pending tasklet when the
441 - * queue is woken again.
442 - */
443 - if (txpending)
444 - skb_queue_splice_init(skbs, &local->pending[q]);
445 - else
446 - skb_queue_splice_tail_init(skbs,
447 - &local->pending[q]);
448 -
449 - spin_unlock_irqrestore(&local->queue_stop_reason_lock,
450 - flags);
451 - return false;
452 }
453 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
454
455 @@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
456 }
457
458 if (!is_multicast_ether_addr(skb->data)) {
459 + struct sta_info *next_hop;
460 + bool mpp_lookup = true;
461 +
462 mpath = mesh_path_lookup(sdata, skb->data);
463 - if (!mpath)
464 + if (mpath) {
465 + mpp_lookup = false;
466 + next_hop = rcu_dereference(mpath->next_hop);
467 + if (!next_hop ||
468 + !(mpath->flags & (MESH_PATH_ACTIVE |
469 + MESH_PATH_RESOLVING)))
470 + mpp_lookup = true;
471 + }
472 +
473 + if (mpp_lookup)
474 mppath = mpp_path_lookup(sdata, skb->data);
475 +
476 + if (mppath && mpath)
477 + mesh_path_del(mpath->sdata, mpath->dst);
478 }
479
480 /*
481 --- a/net/wireless/nl80211.c
482 +++ b/net/wireless/nl80211.c
483 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
484 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
485 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
486 goto nla_put_failure;
487 - if (chan->flags & IEEE80211_CHAN_RADAR) {
488 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
489 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
490 - goto nla_put_failure;
491 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
492 - chan->dfs_state))
493 - goto nla_put_failure;
494 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
495 - goto nla_put_failure;
496 - }
497 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
498 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
499 + goto nla_put_failure;
500 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
501 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
502 goto nla_put_failure;
503 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
504 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
505 c->max_interfaces))
506 goto nla_put_failure;
507 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
508 - c->radar_detect_widths))
509 - goto nla_put_failure;
510
511 nla_nest_end(msg, nl_combi);
512 }
513 @@ -914,48 +904,6 @@ nla_put_failure:
514 return -ENOBUFS;
515 }
516
517 -#ifdef CONFIG_PM
518 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
519 - struct sk_buff *msg)
520 -{
521 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
522 - struct nlattr *nl_tcp;
523 -
524 - if (!tcp)
525 - return 0;
526 -
527 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
528 - if (!nl_tcp)
529 - return -ENOBUFS;
530 -
531 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
532 - tcp->data_payload_max))
533 - return -ENOBUFS;
534 -
535 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
536 - tcp->data_payload_max))
537 - return -ENOBUFS;
538 -
539 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
540 - return -ENOBUFS;
541 -
542 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
543 - sizeof(*tcp->tok), tcp->tok))
544 - return -ENOBUFS;
545 -
546 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
547 - tcp->data_interval_max))
548 - return -ENOBUFS;
549 -
550 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
551 - tcp->wake_payload_max))
552 - return -ENOBUFS;
553 -
554 - nla_nest_end(msg, nl_tcp);
555 - return 0;
556 -}
557 -#endif
558 -
559 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
560 struct cfg80211_registered_device *dev)
561 {
562 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
563 goto nla_put_failure;
564 }
565
566 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
567 - goto nla_put_failure;
568 -
569 nla_nest_end(msg, nl_wowlan);
570 }
571 #endif
572 --- a/net/mac80211/cfg.c
573 +++ b/net/mac80211/cfg.c
574 @@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
575 struct cfg80211_chan_def *chandef)
576 {
577 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
578 + struct ieee80211_local *local = wiphy_priv(wiphy);
579 struct ieee80211_chanctx_conf *chanctx_conf;
580 int ret = -ENODATA;
581
582 rcu_read_lock();
583 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
584 - if (chanctx_conf) {
585 - *chandef = chanctx_conf->def;
586 + if (local->use_chanctx) {
587 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
588 + if (chanctx_conf) {
589 + *chandef = chanctx_conf->def;
590 + ret = 0;
591 + }
592 + } else if (local->open_count == local->monitors) {
593 + *chandef = local->monitor_chandef;
594 ret = 0;
595 }
596 rcu_read_unlock();
597 --- a/drivers/net/wireless/ath/ath9k/hw.c
598 +++ b/drivers/net/wireless/ath/ath9k/hw.c
599 @@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
600 reset_type = ATH9K_RESET_POWER_ON;
601 else
602 reset_type = ATH9K_RESET_COLD;
603 - }
604 + } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
605 + (REG_READ(ah, AR_CR) & AR_CR_RXE))
606 + reset_type = ATH9K_RESET_COLD;
607
608 if (!ath9k_hw_set_reset_reg(ah, reset_type))
609 return false;
610 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
611 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
612 @@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
613 */
614 if_limit = &rt2x00dev->if_limits_ap;
615 if_limit->max = rt2x00dev->ops->max_ap_intf;
616 - if_limit->types = BIT(NL80211_IFTYPE_AP) |
617 - BIT(NL80211_IFTYPE_MESH_POINT);
618 + if_limit->types = BIT(NL80211_IFTYPE_AP);
619 +#ifdef CONFIG_MAC80211_MESH
620 + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
621 +#endif
622
623 /*
624 * Build up AP interface combinations structure.
625 @@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
626 rt2x00dev->hw->wiphy->interface_modes |=
627 BIT(NL80211_IFTYPE_ADHOC) |
628 BIT(NL80211_IFTYPE_AP) |
629 +#ifdef CONFIG_MAC80211_MESH
630 BIT(NL80211_IFTYPE_MESH_POINT) |
631 +#endif
632 BIT(NL80211_IFTYPE_WDS);
633
634 rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
635 --- a/net/mac80211/rc80211_minstrel_ht.c
636 +++ b/net/mac80211/rc80211_minstrel_ht.c
637 @@ -26,11 +26,11 @@
638 /* Number of symbols for a packet with (bps) bits per symbol */
639 #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
640
641 -/* Transmission time for a packet containing (syms) symbols */
642 +/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
643 #define MCS_SYMBOL_TIME(sgi, syms) \
644 (sgi ? \
645 - ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \
646 - (syms) << 2 /* syms * 4 us */ \
647 + ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \
648 + ((syms) * 1000) << 2 /* syms * 4 us */ \
649 )
650
651 /* Transmit duration for the raw data part of an average sized packet */
652 @@ -64,9 +64,9 @@
653 }
654
655 #define CCK_DURATION(_bitrate, _short, _len) \
656 - (10 /* SIFS */ + \
657 + (1000 * (10 /* SIFS */ + \
658 (_short ? 72 + 24 : 144 + 48 ) + \
659 - (8 * (_len + 4) * 10) / (_bitrate))
660 + (8 * (_len + 4) * 10) / (_bitrate)))
661
662 #define CCK_ACK_DURATION(_bitrate, _short) \
663 (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
664 @@ -211,20 +211,32 @@ static void
665 minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
666 {
667 struct minstrel_rate_stats *mr;
668 - unsigned int usecs = 0;
669 + unsigned int nsecs = 0;
670 + unsigned int tp;
671 + unsigned int prob;
672
673 mr = &mi->groups[group].rates[rate];
674 + prob = mr->probability;
675
676 - if (mr->probability < MINSTREL_FRAC(1, 10)) {
677 + if (prob < MINSTREL_FRAC(1, 10)) {
678 mr->cur_tp = 0;
679 return;
680 }
681
682 + /*
683 + * For the throughput calculation, limit the probability value to 90% to
684 + * account for collision related packet error rate fluctuation
685 + */
686 + if (prob > MINSTREL_FRAC(9, 10))
687 + prob = MINSTREL_FRAC(9, 10);
688 +
689 if (group != MINSTREL_CCK_GROUP)
690 - usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
691 + nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
692
693 - usecs += minstrel_mcs_groups[group].duration[rate];
694 - mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
695 + nsecs += minstrel_mcs_groups[group].duration[rate];
696 + tp = 1000000 * ((mr->probability * 1000) / nsecs);
697 +
698 + mr->cur_tp = MINSTREL_TRUNC(tp);
699 }
700
701 /*
702 @@ -308,8 +320,8 @@ minstrel_ht_update_stats(struct minstrel
703 }
704 }
705
706 - /* try to sample up to half of the available rates during each interval */
707 - mi->sample_count *= 4;
708 + /* try to sample all available rates during each interval */
709 + mi->sample_count *= 8;
710
711 cur_prob = 0;
712 cur_prob_tp = 0;
713 @@ -320,20 +332,13 @@ minstrel_ht_update_stats(struct minstrel
714 if (!mg->supported)
715 continue;
716
717 - mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
718 - if (cur_prob_tp < mr->cur_tp &&
719 - minstrel_mcs_groups[group].streams == 1) {
720 - mi->max_prob_rate = mg->max_prob_rate;
721 - cur_prob = mr->cur_prob;
722 - cur_prob_tp = mr->cur_tp;
723 - }
724 -
725 mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
726 if (cur_tp < mr->cur_tp) {
727 mi->max_tp_rate2 = mi->max_tp_rate;
728 cur_tp2 = cur_tp;
729 mi->max_tp_rate = mg->max_tp_rate;
730 cur_tp = mr->cur_tp;
731 + mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
732 }
733
734 mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
735 @@ -343,6 +348,23 @@ minstrel_ht_update_stats(struct minstrel
736 }
737 }
738
739 + if (mi->max_prob_streams < 1)
740 + mi->max_prob_streams = 1;
741 +
742 + for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
743 + mg = &mi->groups[group];
744 + if (!mg->supported)
745 + continue;
746 + mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
747 + if (cur_prob_tp < mr->cur_tp &&
748 + minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
749 + mi->max_prob_rate = mg->max_prob_rate;
750 + cur_prob = mr->cur_prob;
751 + cur_prob_tp = mr->cur_tp;
752 + }
753 + }
754 +
755 +
756 mi->stats_update = jiffies;
757 }
758
759 @@ -467,7 +489,7 @@ minstrel_ht_tx_status(void *priv, struct
760
761 if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
762 mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
763 - mi->sample_tries = 2;
764 + mi->sample_tries = 1;
765 mi->sample_count--;
766 }
767
768 @@ -536,7 +558,7 @@ minstrel_calc_retransmit(struct minstrel
769 mr->retry_updated = true;
770
771 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
772 - tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
773 + tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
774
775 /* Contention time for first 2 tries */
776 ctime = (t_slot * cw) >> 1;
777 @@ -616,6 +638,7 @@ minstrel_get_sample_rate(struct minstrel
778 {
779 struct minstrel_rate_stats *mr;
780 struct minstrel_mcs_group_data *mg;
781 + unsigned int sample_dur, sample_group;
782 int sample_idx = 0;
783
784 if (mi->sample_wait > 0) {
785 @@ -626,39 +649,46 @@ minstrel_get_sample_rate(struct minstrel
786 if (!mi->sample_tries)
787 return -1;
788
789 - mi->sample_tries--;
790 mg = &mi->groups[mi->sample_group];
791 sample_idx = sample_table[mg->column][mg->index];
792 mr = &mg->rates[sample_idx];
793 - sample_idx += mi->sample_group * MCS_GROUP_RATES;
794 + sample_group = mi->sample_group;
795 + sample_idx += sample_group * MCS_GROUP_RATES;
796 minstrel_next_sample_idx(mi);
797
798 /*
799 * Sampling might add some overhead (RTS, no aggregation)
800 * to the frame. Hence, don't use sampling for the currently
801 - * used max TP rate.
802 + * used rates.
803 */
804 - if (sample_idx == mi->max_tp_rate)
805 + if (sample_idx == mi->max_tp_rate ||
806 + sample_idx == mi->max_tp_rate2 ||
807 + sample_idx == mi->max_prob_rate)
808 return -1;
809 +
810 /*
811 - * When not using MRR, do not sample if the probability is already
812 - * higher than 95% to avoid wasting airtime
813 + * Do not sample if the probability is already higher than 95%
814 + * to avoid wasting airtime.
815 */
816 - if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
817 + if (mr->probability > MINSTREL_FRAC(95, 100))
818 return -1;
819
820 /*
821 * Make sure that lower rates get sampled only occasionally,
822 * if the link is working perfectly.
823 */
824 - if (minstrel_get_duration(sample_idx) >
825 - minstrel_get_duration(mi->max_tp_rate)) {
826 + sample_dur = minstrel_get_duration(sample_idx);
827 + if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
828 + (mi->max_prob_streams <
829 + minstrel_mcs_groups[sample_group].streams ||
830 + sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
831 if (mr->sample_skipped < 20)
832 return -1;
833
834 if (mi->sample_slow++ > 2)
835 return -1;
836 }
837 + mi->sample_tries--;
838
839 return sample_idx;
840 }
841 --- a/net/mac80211/rc80211_minstrel_ht.h
842 +++ b/net/mac80211/rc80211_minstrel_ht.h
843 @@ -85,6 +85,7 @@ struct minstrel_ht_sta {
844
845 /* best probability rate */
846 unsigned int max_prob_rate;
847 + unsigned int max_prob_streams;
848
849 /* time of last status update */
850 unsigned long stats_update;
851 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
852 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
853 @@ -1023,6 +1023,7 @@ static bool ar9003_hw_init_cal(struct at
854 AR_PHY_AGC_CONTROL_FLTR_CAL |
855 AR_PHY_AGC_CONTROL_PKDET_CAL;
856
857 + /* Use chip chainmask only for calibration */
858 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
859
860 if (rtt) {
861 @@ -1150,6 +1151,9 @@ skip_tx_iqcal:
862 ar9003_hw_rtt_disable(ah);
863 }
864
865 + /* Revert chainmask to runtime parameters */
866 + ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
867 +
868 /* Initialize list pointers */
869 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
870
871 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
872 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
873 @@ -3606,6 +3606,12 @@ static void ar9003_hw_ant_ctrl_apply(str
874 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
875 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
876
877 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
878 + value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
879 + REG_RMW_FIELD(ah, switch_chain_reg[0],
880 + AR_SWITCH_TABLE_ALL, value);
881 + }
882 +
883 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
884 if ((ah->rxchainmask & BIT(chain)) ||
885 (ah->txchainmask & BIT(chain))) {
886 @@ -3772,6 +3778,17 @@ static void ar9003_hw_atten_apply(struct
887 AR_PHY_EXT_ATTEN_CTL_2,
888 };
889
890 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
891 + value = ar9003_hw_atten_chain_get(ah, 1, chan);
892 + REG_RMW_FIELD(ah, ext_atten_reg[0],
893 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
894 +
895 + value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
896 + REG_RMW_FIELD(ah, ext_atten_reg[0],
897 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
898 + value);
899 + }
900 +
901 /* Test value. if 0 then attenuation is unused. Don't load anything. */
902 for (i = 0; i < 3; i++) {
903 if (ah->txchainmask & BIT(i)) {
904 --- a/drivers/net/wireless/ath/ath9k/link.c
905 +++ b/drivers/net/wireless/ath/ath9k/link.c
906 @@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct wo
907 int i;
908 bool needreset = false;
909
910 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
911 - if (ATH_TXQ_SETUP(sc, i)) {
912 - txq = &sc->tx.txq[i];
913 - ath_txq_lock(sc, txq);
914 - if (txq->axq_depth) {
915 - if (txq->axq_tx_inprogress) {
916 - needreset = true;
917 - ath_txq_unlock(sc, txq);
918 - break;
919 - } else {
920 - txq->axq_tx_inprogress = true;
921 - }
922 + for (i = 0; i < IEEE80211_NUM_ACS; i++) {
923 + txq = sc->tx.txq_map[i];
924 +
925 + ath_txq_lock(sc, txq);
926 + if (txq->axq_depth) {
927 + if (txq->axq_tx_inprogress) {
928 + needreset = true;
929 + ath_txq_unlock(sc, txq);
930 + break;
931 + } else {
932 + txq->axq_tx_inprogress = true;
933 }
934 - ath_txq_unlock_complete(sc, txq);
935 }
936 + ath_txq_unlock_complete(sc, txq);
937 + }
938
939 if (needreset) {
940 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
941 --- a/net/mac80211/sta_info.c
942 +++ b/net/mac80211/sta_info.c
943 @@ -766,6 +766,7 @@ int __must_check __sta_info_destroy(stru
944 struct ieee80211_local *local;
945 struct ieee80211_sub_if_data *sdata;
946 int ret, i;
947 + bool have_key = false;
948
949 might_sleep();
950
951 @@ -793,12 +794,19 @@ int __must_check __sta_info_destroy(stru
952 list_del_rcu(&sta->list);
953
954 mutex_lock(&local->key_mtx);
955 - for (i = 0; i < NUM_DEFAULT_KEYS; i++)
956 + for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
957 __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
958 - if (sta->ptk)
959 + have_key = true;
960 + }
961 + if (sta->ptk) {
962 __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
963 + have_key = true;
964 + }
965 mutex_unlock(&local->key_mtx);
966
967 + if (!have_key)
968 + synchronize_net();
969 +
970 sta->dead = true;
971
972 local->num_sta--;
973 --- a/net/mac80211/chan.c
974 +++ b/net/mac80211/chan.c
975 @@ -63,6 +63,7 @@ ieee80211_new_chanctx(struct ieee80211_l
976 enum ieee80211_chanctx_mode mode)
977 {
978 struct ieee80211_chanctx *ctx;
979 + u32 changed;
980 int err;
981
982 lockdep_assert_held(&local->chanctx_mtx);
983 @@ -76,6 +77,13 @@ ieee80211_new_chanctx(struct ieee80211_l
984 ctx->conf.rx_chains_dynamic = 1;
985 ctx->mode = mode;
986
987 + /* acquire mutex to prevent idle from changing */
988 + mutex_lock(&local->mtx);
989 + /* turn idle off *before* setting channel -- some drivers need that */
990 + changed = ieee80211_idle_off(local);
991 + if (changed)
992 + ieee80211_hw_config(local, changed);
993 +
994 if (!local->use_chanctx) {
995 local->_oper_channel_type =
996 cfg80211_get_chandef_type(chandef);
997 @@ -85,14 +93,17 @@ ieee80211_new_chanctx(struct ieee80211_l
998 err = drv_add_chanctx(local, ctx);
999 if (err) {
1000 kfree(ctx);
1001 - return ERR_PTR(err);
1002 + ctx = ERR_PTR(err);
1003 +
1004 + ieee80211_recalc_idle(local);
1005 + goto out;
1006 }
1007 }
1008
1009 + /* and keep the mutex held until the new chanctx is on the list */
1010 list_add_rcu(&ctx->list, &local->chanctx_list);
1011
1012 - mutex_lock(&local->mtx);
1013 - ieee80211_recalc_idle(local);
1014 + out:
1015 mutex_unlock(&local->mtx);
1016
1017 return ctx;
1018 --- a/net/mac80211/ieee80211_i.h
1019 +++ b/net/mac80211/ieee80211_i.h
1020 @@ -1366,6 +1366,7 @@ int ieee80211_if_change_type(struct ieee
1021 enum nl80211_iftype type);
1022 void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
1023 void ieee80211_remove_interfaces(struct ieee80211_local *local);
1024 +u32 ieee80211_idle_off(struct ieee80211_local *local);
1025 void ieee80211_recalc_idle(struct ieee80211_local *local);
1026 void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
1027 const int offset);
1028 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
1029 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
1030 @@ -799,7 +799,7 @@ static int ath9k_init_firmware_version(s
1031 * required version.
1032 */
1033 if (priv->fw_version_major != MAJOR_VERSION_REQ ||
1034 - priv->fw_version_minor != MINOR_VERSION_REQ) {
1035 + priv->fw_version_minor < MINOR_VERSION_REQ) {
1036 dev_err(priv->dev, "ath9k_htc: Please upgrade to FW version %d.%d\n",
1037 MAJOR_VERSION_REQ, MINOR_VERSION_REQ);
1038 return -EINVAL;
1039 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1040 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1041 @@ -516,8 +516,7 @@ static void ath_tx_complete_aggr(struct
1042 * not a holding desc.
1043 */
1044 INIT_LIST_HEAD(&bf_head);
1045 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) ||
1046 - bf_next != NULL || !bf_last->bf_stale)
1047 + if (bf_next != NULL || !bf_last->bf_stale)
1048 list_move_tail(&bf->list, &bf_head);
1049
1050 if (!txpending || (tid->state & AGGR_CLEANUP)) {
1051 @@ -537,8 +536,7 @@ static void ath_tx_complete_aggr(struct
1052 !txfail);
1053 } else {
1054 /* retry the un-acked ones */
1055 - if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
1056 - bf->bf_next == NULL && bf_last->bf_stale) {
1057 + if (bf->bf_next == NULL && bf_last->bf_stale) {
1058 struct ath_buf *tbf;
1059
1060 tbf = ath_clone_txbuf(sc, bf_last);
1061 @@ -2264,6 +2262,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1062 struct ath_txq *txq;
1063 struct ath_buf *bf, *lastbf;
1064 struct list_head bf_head;
1065 + struct list_head *fifo_list;
1066 int status;
1067
1068 for (;;) {
1069 @@ -2291,20 +2290,24 @@ void ath_tx_edma_tasklet(struct ath_soft
1070
1071 TX_STAT_INC(txq->axq_qnum, txprocdesc);
1072
1073 - if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
1074 + fifo_list = &txq->txq_fifo[txq->txq_tailidx];
1075 + if (list_empty(fifo_list)) {
1076 ath_txq_unlock(sc, txq);
1077 return;
1078 }
1079
1080 - bf = list_first_entry(&txq->txq_fifo[txq->txq_tailidx],
1081 - struct ath_buf, list);
1082 + bf = list_first_entry(fifo_list, struct ath_buf, list);
1083 + if (bf->bf_stale) {
1084 + list_del(&bf->list);
1085 + ath_tx_return_buffer(sc, bf);
1086 + bf = list_first_entry(fifo_list, struct ath_buf, list);
1087 + }
1088 +
1089 lastbf = bf->bf_lastbf;
1090
1091 INIT_LIST_HEAD(&bf_head);
1092 - list_cut_position(&bf_head, &txq->txq_fifo[txq->txq_tailidx],
1093 - &lastbf->list);
1094 -
1095 - if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
1096 + if (list_is_last(&lastbf->list, fifo_list)) {
1097 + list_splice_tail_init(fifo_list, &bf_head);
1098 INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
1099
1100 if (!list_empty(&txq->axq_q)) {
1101 @@ -2315,6 +2318,11 @@ void ath_tx_edma_tasklet(struct ath_soft
1102 list_splice_tail_init(&txq->axq_q, &bf_q);
1103 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
1104 }
1105 + } else {
1106 + lastbf->bf_stale = true;
1107 + if (bf != lastbf)
1108 + list_cut_position(&bf_head, fifo_list,
1109 + lastbf->list.prev);
1110 }
1111
1112 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);