ath9k: add a patch that prevents excessive retry of single frames during an aggregati...
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath5k/base.c
2 +++ b/drivers/net/wireless/ath/ath5k/base.c
3 @@ -325,6 +325,8 @@ ath5k_setup_channels(struct ath5k_hw *ah
4                 if (!ath5k_is_standard_channel(ch, band))
5                         continue;
6  
7 +               channels[count].max_power = AR5K_TUNE_MAX_TXPOWER/2;
8 +
9                 count++;
10         }
11  
12 --- a/net/mac80211/agg-rx.c
13 +++ b/net/mac80211/agg-rx.c
14 @@ -203,6 +203,8 @@ static void ieee80211_send_addba_resp(st
15                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
16         else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
17                 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
18 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
19 +               memcpy(mgmt->bssid, da, ETH_ALEN);
20  
21         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
22                                           IEEE80211_STYPE_ACTION);
23 --- a/net/mac80211/agg-tx.c
24 +++ b/net/mac80211/agg-tx.c
25 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
26         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
27         if (sdata->vif.type == NL80211_IFTYPE_AP ||
28             sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
29 -           sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
30 +           sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
31 +           sdata->vif.type == NL80211_IFTYPE_WDS)
32                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
33         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
34                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
35 @@ -460,6 +461,7 @@ int ieee80211_start_tx_ba_session(struct
36             sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
37             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
38             sdata->vif.type != NL80211_IFTYPE_AP &&
39 +           sdata->vif.type != NL80211_IFTYPE_WDS &&
40             sdata->vif.type != NL80211_IFTYPE_ADHOC)
41                 return -EINVAL;
42  
43 @@ -869,7 +871,7 @@ void ieee80211_process_addba_resp(struct
44  
45         } else {
46                 ___ieee80211_stop_tx_ba_session(sta, tid, WLAN_BACK_INITIATOR,
47 -                                               true);
48 +                                               false);
49         }
50  
51   out:
52 --- a/net/mac80211/debugfs_sta.c
53 +++ b/net/mac80211/debugfs_sta.c
54 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
55         test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
56  
57         int res = scnprintf(buf, sizeof(buf),
58 -                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
59 +                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
60                             TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
61                             TEST(PS_DRIVER), TEST(AUTHORIZED),
62                             TEST(SHORT_PREAMBLE),
63 -                           TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
64 +                           TEST(WME), TEST(CLEAR_PS_FILT),
65                             TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
66                             TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
67                             TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
68 --- a/net/mac80211/iface.c
69 +++ b/net/mac80211/iface.c
70 @@ -420,7 +420,6 @@ int ieee80211_do_open(struct wireless_de
71         struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
72         struct net_device *dev = wdev->netdev;
73         struct ieee80211_local *local = sdata->local;
74 -       struct sta_info *sta;
75         u32 changed = 0;
76         int res;
77         u32 hw_reconf_flags = 0;
78 @@ -575,30 +574,8 @@ int ieee80211_do_open(struct wireless_de
79  
80         set_bit(SDATA_STATE_RUNNING, &sdata->state);
81  
82 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
83 -               /* Create STA entry for the WDS peer */
84 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
85 -                                    GFP_KERNEL);
86 -               if (!sta) {
87 -                       res = -ENOMEM;
88 -                       goto err_del_interface;
89 -               }
90 -
91 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
92 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
93 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
94 -
95 -               res = sta_info_insert(sta);
96 -               if (res) {
97 -                       /* STA has been freed */
98 -                       goto err_del_interface;
99 -               }
100 -
101 -               rate_control_rate_init(sta);
102 -               netif_carrier_on(dev);
103 -       } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
104 +       if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
105                 rcu_assign_pointer(local->p2p_sdata, sdata);
106 -       }
107  
108         /*
109          * set_multicast_list will be invoked by the networking core
110 @@ -997,6 +974,72 @@ static void ieee80211_if_setup(struct ne
111         dev->destructor = free_netdev;
112  }
113  
114 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
115 +                                        struct sk_buff *skb)
116 +{
117 +       struct ieee80211_local *local = sdata->local;
118 +       struct ieee80211_rx_status *rx_status;
119 +       struct ieee802_11_elems elems;
120 +       struct ieee80211_mgmt *mgmt;
121 +       struct sta_info *sta;
122 +       size_t baselen;
123 +       u32 rates = 0;
124 +       u16 stype;
125 +       bool new = false;
126 +       enum ieee80211_band band = local->hw.conf.channel->band;
127 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
128 +
129 +       rx_status = IEEE80211_SKB_RXCB(skb);
130 +       mgmt = (struct ieee80211_mgmt *) skb->data;
131 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
132 +
133 +       if (stype != IEEE80211_STYPE_BEACON)
134 +               return;
135 +
136 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
137 +       if (baselen > skb->len)
138 +               return;
139 +
140 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
141 +                              skb->len - baselen, &elems);
142 +
143 +       rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
144 +
145 +       rcu_read_lock();
146 +
147 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
148 +
149 +       if (!sta) {
150 +               rcu_read_unlock();
151 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
152 +                                    GFP_KERNEL);
153 +               if (!sta)
154 +                       return;
155 +
156 +               new = true;
157 +       }
158 +
159 +       sta->last_rx = jiffies;
160 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
161 +
162 +       if (elems.ht_cap_elem)
163 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
164 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
165 +
166 +       if (elems.wmm_param)
167 +               set_sta_flag(sta, WLAN_STA_WME);
168 +
169 +       if (new) {
170 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
171 +               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
172 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
173 +               rate_control_rate_init(sta);
174 +               sta_info_insert_rcu(sta);
175 +       }
176 +
177 +       rcu_read_unlock();
178 +}
179 +
180  static void ieee80211_iface_work(struct work_struct *work)
181  {
182         struct ieee80211_sub_if_data *sdata =
183 @@ -1101,6 +1144,9 @@ static void ieee80211_iface_work(struct 
184                                 break;
185                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
186                         break;
187 +               case NL80211_IFTYPE_WDS:
188 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
189 +                       break;
190                 default:
191                         WARN(1, "frame for unexpected interface type");
192                         break;
193 --- a/net/mac80211/rx.c
194 +++ b/net/mac80211/rx.c
195 @@ -2279,6 +2279,7 @@ ieee80211_rx_h_action(struct ieee80211_r
196                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
197                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
198                     sdata->vif.type != NL80211_IFTYPE_AP &&
199 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
200                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
201                         break;
202  
203 @@ -2496,14 +2497,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
204  
205         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
206             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
207 -           sdata->vif.type != NL80211_IFTYPE_STATION)
208 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
209 +           sdata->vif.type != NL80211_IFTYPE_WDS)
210                 return RX_DROP_MONITOR;
211  
212         switch (stype) {
213         case cpu_to_le16(IEEE80211_STYPE_AUTH):
214         case cpu_to_le16(IEEE80211_STYPE_BEACON):
215         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
216 -               /* process for all: mesh, mlme, ibss */
217 +               /* process for all: mesh, mlme, ibss, wds */
218                 break;
219         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
220         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
221 @@ -2827,10 +2829,16 @@ static int prepare_for_handlers(struct i
222                 }
223                 break;
224         case NL80211_IFTYPE_WDS:
225 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
226 -                       return 0;
227                 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
228                         return 0;
229 +
230 +               if (ieee80211_is_data(hdr->frame_control) ||
231 +                   ieee80211_is_action(hdr->frame_control)) {
232 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
233 +                               return 0;
234 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
235 +                       return 0;
236 +
237                 break;
238         case NL80211_IFTYPE_P2P_DEVICE:
239                 if (!ieee80211_is_public_action(hdr, skb->len) &&
240 --- a/net/mac80211/sta_info.h
241 +++ b/net/mac80211/sta_info.h
242 @@ -32,7 +32,6 @@
243   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
244   *     frames.
245   * @WLAN_STA_WME: Station is a QoS-STA.
246 - * @WLAN_STA_WDS: Station is one of our WDS peers.
247   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
248   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
249   *     frame to this station is transmitted.
250 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
251         WLAN_STA_AUTHORIZED,
252         WLAN_STA_SHORT_PREAMBLE,
253         WLAN_STA_WME,
254 -       WLAN_STA_WDS,
255         WLAN_STA_CLEAR_PS_FILT,
256         WLAN_STA_MFP,
257         WLAN_STA_BLOCK_BA,
258 --- a/net/mac80211/status.c
259 +++ b/net/mac80211/status.c
260 @@ -517,29 +517,41 @@ void ieee80211_tx_status(struct ieee8021
261  
262         if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
263                 u64 cookie = (unsigned long)skb;
264 +               bool found = false;
265 +
266                 acked = info->flags & IEEE80211_TX_STAT_ACK;
267  
268 -               if (ieee80211_is_nullfunc(hdr->frame_control) ||
269 -                   ieee80211_is_qos_nullfunc(hdr->frame_control)) {
270 -                       cfg80211_probe_status(skb->dev, hdr->addr1,
271 -                                             cookie, acked, GFP_ATOMIC);
272 -               } else if (skb->dev) {
273 -                       cfg80211_mgmt_tx_status(
274 -                               skb->dev->ieee80211_ptr, cookie, skb->data,
275 -                               skb->len, acked, GFP_ATOMIC);
276 -               } else {
277 -                       struct ieee80211_sub_if_data *p2p_sdata;
278 +               rcu_read_lock();
279  
280 -                       rcu_read_lock();
281 +               list_for_each_entry_rcu(sdata, &local->interfaces, list) {
282 +                       if (!sdata->dev)
283 +                               continue;
284  
285 -                       p2p_sdata = rcu_dereference(local->p2p_sdata);
286 -                       if (p2p_sdata) {
287 -                               cfg80211_mgmt_tx_status(
288 -                                       &p2p_sdata->wdev, cookie, skb->data,
289 -                                       skb->len, acked, GFP_ATOMIC);
290 -                       }
291 -                       rcu_read_unlock();
292 +                       if (skb->dev != sdata->dev)
293 +                               continue;
294 +
295 +                       found = true;
296 +                       break;
297                 }
298 +
299 +               if (!skb->dev) {
300 +                       sdata = rcu_dereference(local->p2p_sdata);
301 +                       if (sdata)
302 +                               found = true;
303 +               }
304 +
305 +               if (!found)
306 +                       skb->dev = NULL;
307 +               else if (ieee80211_is_nullfunc(hdr->frame_control) ||
308 +                        ieee80211_is_qos_nullfunc(hdr->frame_control)) {
309 +                       cfg80211_probe_status(sdata->dev, hdr->addr1,
310 +                                             cookie, acked, GFP_ATOMIC);
311 +               } else {
312 +                       cfg80211_mgmt_tx_status(&sdata->wdev, cookie, skb->data,
313 +                                               skb->len, acked, GFP_ATOMIC);
314 +               }
315 +
316 +               rcu_read_unlock();
317         }
318  
319         if (unlikely(info->ack_frame_id)) {
320 --- a/drivers/net/wireless/p54/main.c
321 +++ b/drivers/net/wireless/p54/main.c
322 @@ -139,6 +139,7 @@ static int p54_beacon_format_ie_tim(stru
323  static int p54_beacon_update(struct p54_common *priv,
324                         struct ieee80211_vif *vif)
325  {
326 +       struct ieee80211_tx_control control = { };
327         struct sk_buff *beacon;
328         int ret;
329  
330 @@ -158,7 +159,7 @@ static int p54_beacon_update(struct p54_
331          * to cancel the old beacon template by hand, instead the firmware
332          * will release the previous one through the feedback mechanism.
333          */
334 -       p54_tx_80211(priv->hw, NULL, beacon);
335 +       p54_tx_80211(priv->hw, &control, beacon);
336         priv->tsf_high32 = 0;
337         priv->tsf_low32 = 0;
338  
339 --- a/net/wireless/reg.c
340 +++ b/net/wireless/reg.c
341 @@ -352,6 +352,9 @@ static void reg_regdb_search(struct work
342         struct reg_regdb_search_request *request;
343         const struct ieee80211_regdomain *curdom, *regdom;
344         int i, r;
345 +       bool set_reg = false;
346 +
347 +       mutex_lock(&cfg80211_mutex);
348  
349         mutex_lock(&reg_regdb_search_mutex);
350         while (!list_empty(&reg_regdb_search_list)) {
351 @@ -367,9 +370,7 @@ static void reg_regdb_search(struct work
352                                 r = reg_copy_regd(&regdom, curdom);
353                                 if (r)
354                                         break;
355 -                               mutex_lock(&cfg80211_mutex);
356 -                               set_regdom(regdom);
357 -                               mutex_unlock(&cfg80211_mutex);
358 +                               set_reg = true;
359                                 break;
360                         }
361                 }
362 @@ -377,6 +378,11 @@ static void reg_regdb_search(struct work
363                 kfree(request);
364         }
365         mutex_unlock(&reg_regdb_search_mutex);
366 +
367 +       if (set_reg)
368 +               set_regdom(regdom);
369 +
370 +       mutex_unlock(&cfg80211_mutex);
371  }
372  
373  static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
374 --- a/drivers/net/wireless/ath/ath9k/recv.c
375 +++ b/drivers/net/wireless/ath/ath9k/recv.c
376 @@ -424,8 +424,8 @@ u32 ath_calcrxfilter(struct ath_softc *s
377                 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
378  
379         if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
380 -               /* The following may also be needed for other older chips */
381 -               if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
382 +               /* This is needed for older chips */
383 +               if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160)
384                         rfilt |= ATH9K_RX_FILTER_PROM;
385                 rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;
386         }
387 --- a/net/mac80211/mlme.c
388 +++ b/net/mac80211/mlme.c
389 @@ -818,23 +818,71 @@ void ieee80211_sta_process_chanswitch(st
390  }
391  
392  static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
393 -                                       u16 capab_info, u8 *pwr_constr_elem,
394 -                                       u8 pwr_constr_elem_len)
395 +                                       struct ieee80211_channel *channel,
396 +                                       const u8 *country_ie, u8 country_ie_len,
397 +                                       const u8 *pwr_constr_elem)
398  {
399 -       struct ieee80211_conf *conf = &sdata->local->hw.conf;
400 +       struct ieee80211_country_ie_triplet *triplet;
401 +       int chan = ieee80211_frequency_to_channel(channel->center_freq);
402 +       int i, chan_pwr, chan_increment, new_ap_level;
403 +       bool have_chan_pwr = false;
404  
405 -       if (!(capab_info & WLAN_CAPABILITY_SPECTRUM_MGMT))
406 +       /* Invalid IE */
407 +       if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
408                 return;
409  
410 -       /* Power constraint IE length should be 1 octet */
411 -       if (pwr_constr_elem_len != 1)
412 -               return;
413 +       triplet = (void *)(country_ie + 3);
414 +       country_ie_len -= 3;
415  
416 -       if ((*pwr_constr_elem <= conf->channel->max_reg_power) &&
417 -           (*pwr_constr_elem != sdata->local->power_constr_level)) {
418 -               sdata->local->power_constr_level = *pwr_constr_elem;
419 -               ieee80211_hw_config(sdata->local, 0);
420 +       switch (channel->band) {
421 +       default:
422 +               WARN_ON_ONCE(1);
423 +               /* fall through */
424 +       case IEEE80211_BAND_2GHZ:
425 +       case IEEE80211_BAND_60GHZ:
426 +               chan_increment = 1;
427 +               break;
428 +       case IEEE80211_BAND_5GHZ:
429 +               chan_increment = 4;
430 +               break;
431         }
432 +
433 +       /* find channel */
434 +       while (country_ie_len >= 3) {
435 +               u8 first_channel = triplet->chans.first_channel;
436 +
437 +               if (first_channel >= IEEE80211_COUNTRY_EXTENSION_ID)
438 +                       goto next;
439 +
440 +               for (i = 0; i < triplet->chans.num_channels; i++) {
441 +                       if (first_channel + i * chan_increment == chan) {
442 +                               have_chan_pwr = true;
443 +                               chan_pwr = triplet->chans.max_power;
444 +                               break;
445 +                       }
446 +               }
447 +               if (have_chan_pwr)
448 +                       break;
449 +
450 + next:
451 +               triplet++;
452 +               country_ie_len -= 3;
453 +       }
454 +
455 +       if (!have_chan_pwr)
456 +               return;
457 +
458 +       new_ap_level = max_t(int, 0, chan_pwr - *pwr_constr_elem);
459 +
460 +       if (sdata->local->ap_power_level == new_ap_level)
461 +               return;
462 +
463 +       sdata_info(sdata,
464 +                  "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n",
465 +                  new_ap_level, chan_pwr, *pwr_constr_elem,
466 +                  sdata->u.mgd.bssid);
467 +       sdata->local->ap_power_level = new_ap_level;
468 +       ieee80211_hw_config(sdata->local, 0);
469  }
470  
471  void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif)
472 @@ -1390,7 +1438,7 @@ static void ieee80211_set_disassoc(struc
473         sta = sta_info_get(sdata, ifmgd->bssid);
474         if (sta) {
475                 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
476 -               ieee80211_sta_tear_down_BA_sessions(sta, tx);
477 +               ieee80211_sta_tear_down_BA_sessions(sta, false);
478         }
479         mutex_unlock(&local->sta_mtx);
480  
481 @@ -1438,7 +1486,7 @@ static void ieee80211_set_disassoc(struc
482         memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa));
483         memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask));
484  
485 -       local->power_constr_level = 0;
486 +       local->ap_power_level = 0;
487  
488         del_timer_sync(&local->dynamic_ps_timer);
489         cancel_work_sync(&local->dynamic_ps_enable_work);
490 @@ -2530,15 +2578,13 @@ static void ieee80211_rx_mgmt_beacon(str
491                                                   bssid, true);
492         }
493  
494 -       /* Note: country IE parsing is done for us by cfg80211 */
495 -       if (elems.country_elem) {
496 -               /* TODO: IBSS also needs this */
497 -               if (elems.pwr_constr_elem)
498 -                       ieee80211_handle_pwr_constr(sdata,
499 -                               le16_to_cpu(mgmt->u.probe_resp.capab_info),
500 -                               elems.pwr_constr_elem,
501 -                               elems.pwr_constr_elem_len);
502 -       }
503 +       if (elems.country_elem && elems.pwr_constr_elem &&
504 +           mgmt->u.probe_resp.capab_info &
505 +                               cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT))
506 +               ieee80211_handle_pwr_constr(sdata, local->oper_channel,
507 +                                           elems.country_elem,
508 +                                           elems.country_elem_len,
509 +                                           elems.pwr_constr_elem);
510  
511         ieee80211_bss_info_change_notify(sdata, changed);
512  }
513 @@ -3526,6 +3572,7 @@ int ieee80211_mgd_deauth(struct ieee8021
514  {
515         struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
516         u8 frame_buf[DEAUTH_DISASSOC_LEN];
517 +       bool tx = !req->local_state_change;
518  
519         mutex_lock(&ifmgd->mtx);
520  
521 @@ -3542,12 +3589,12 @@ int ieee80211_mgd_deauth(struct ieee8021
522         if (ifmgd->associated &&
523             ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
524                 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
525 -                                      req->reason_code, true, frame_buf);
526 +                                      req->reason_code, tx, frame_buf);
527         } else {
528                 drv_mgd_prepare_tx(sdata->local, sdata);
529                 ieee80211_send_deauth_disassoc(sdata, req->bssid,
530                                                IEEE80211_STYPE_DEAUTH,
531 -                                              req->reason_code, true,
532 +                                              req->reason_code, tx,
533                                                frame_buf);
534         }
535  
536 --- a/net/mac80211/sta_info.c
537 +++ b/net/mac80211/sta_info.c
538 @@ -674,7 +674,7 @@ int __must_check __sta_info_destroy(stru
539          * will be sufficient.
540          */
541         set_sta_flag(sta, WLAN_STA_BLOCK_BA);
542 -       ieee80211_sta_tear_down_BA_sessions(sta, true);
543 +       ieee80211_sta_tear_down_BA_sessions(sta, false);
544  
545         ret = sta_info_hash_del(local, sta);
546         if (ret)
547 --- a/drivers/net/wireless/ath/ath5k/phy.c
548 +++ b/drivers/net/wireless/ath/ath5k/phy.c
549 @@ -1977,11 +1977,13 @@ ath5k_hw_set_spur_mitigation_filter(stru
550                         spur_delta_phase = (spur_offset << 18) / 25;
551                         spur_freq_sigma_delta = (spur_delta_phase >> 10);
552                         symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 2;
553 +                       break;
554                 case AR5K_BWMODE_5MHZ:
555                         /* Both sample_freq and chip_freq are 10MHz (?) */
556                         spur_delta_phase = (spur_offset << 19) / 25;
557                         spur_freq_sigma_delta = (spur_delta_phase >> 10);
558                         symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 4;
559 +                       break;
560                 default:
561                         if (channel->band == IEEE80211_BAND_5GHZ) {
562                                 /* Both sample_freq and chip_freq are 40MHz */
563 --- a/net/mac80211/ieee80211_i.h
564 +++ b/net/mac80211/ieee80211_i.h
565 @@ -1062,7 +1062,7 @@ struct ieee80211_local {
566         bool disable_dynamic_ps;
567  
568         int user_power_level; /* in dBm */
569 -       int power_constr_level; /* in dBm */
570 +       int ap_power_level; /* in dBm */
571  
572         enum ieee80211_smps_mode smps_mode;
573  
574 @@ -1170,7 +1170,6 @@ struct ieee802_11_elems {
575         u8 prep_len;
576         u8 perr_len;
577         u8 country_elem_len;
578 -       u8 pwr_constr_elem_len;
579         u8 quiet_elem_len;
580         u8 num_of_quiet_elem;   /* can be more the one */
581         u8 timeout_int_len;
582 --- a/net/mac80211/util.c
583 +++ b/net/mac80211/util.c
584 @@ -792,8 +792,11 @@ u32 ieee802_11_parse_elems_crc(u8 *start
585                         elems->country_elem_len = elen;
586                         break;
587                 case WLAN_EID_PWR_CONSTRAINT:
588 +                       if (elen != 1) {
589 +                               elem_parse_failed = true;
590 +                               break;
591 +                       }
592                         elems->pwr_constr_elem = pos;
593 -                       elems->pwr_constr_elem_len = elen;
594                         break;
595                 case WLAN_EID_TIMEOUT_INTERVAL:
596                         elems->timeout_int = pos;
597 --- a/net/mac80211/main.c
598 +++ b/net/mac80211/main.c
599 @@ -154,13 +154,11 @@ int ieee80211_hw_config(struct ieee80211
600  
601         if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
602             test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
603 -           test_bit(SCAN_HW_SCANNING, &local->scanning))
604 +           test_bit(SCAN_HW_SCANNING, &local->scanning) ||
605 +           !local->ap_power_level)
606                 power = chan->max_power;
607         else
608 -               power = local->power_constr_level ?
609 -                       min(chan->max_power,
610 -                               (chan->max_reg_power  - local->power_constr_level)) :
611 -                       chan->max_power;
612 +               power = min(chan->max_power, local->ap_power_level);
613  
614         if (local->user_power_level >= 0)
615                 power = min(power, local->user_power_level);
616 --- a/include/net/cfg80211.h
617 +++ b/include/net/cfg80211.h
618 @@ -1218,6 +1218,7 @@ struct cfg80211_deauth_request {
619         const u8 *ie;
620         size_t ie_len;
621         u16 reason_code;
622 +       bool local_state_change;
623  };
624  
625  /**
626 --- a/net/wireless/mlme.c
627 +++ b/net/wireless/mlme.c
628 @@ -457,20 +457,14 @@ int __cfg80211_mlme_deauth(struct cfg802
629                 .reason_code = reason,
630                 .ie = ie,
631                 .ie_len = ie_len,
632 +               .local_state_change = local_state_change,
633         };
634  
635         ASSERT_WDEV_LOCK(wdev);
636  
637 -       if (local_state_change) {
638 -               if (wdev->current_bss &&
639 -                   ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
640 -                       cfg80211_unhold_bss(wdev->current_bss);
641 -                       cfg80211_put_bss(&wdev->current_bss->pub);
642 -                       wdev->current_bss = NULL;
643 -               }
644 -
645 +       if (local_state_change && (!wdev->current_bss ||
646 +           !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
647                 return 0;
648 -       }
649  
650         return rdev->ops->deauth(&rdev->wiphy, dev, &req);
651  }
652 --- a/drivers/net/wireless/ath/ath9k/xmit.c
653 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
654 @@ -386,7 +386,7 @@ static void ath_tx_complete_aggr(struct 
655         u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first;
656         u32 ba[WME_BA_BMP_SIZE >> 5];
657         int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
658 -       bool rc_update = true;
659 +       bool rc_update = true, isba;
660         struct ieee80211_tx_rate rates[4];
661         struct ath_frame_info *fi;
662         int nframes;
663 @@ -430,13 +430,17 @@ static void ath_tx_complete_aggr(struct 
664         tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
665         tid = ATH_AN_2_TID(an, tidno);
666         seq_first = tid->seq_start;
667 +       isba = ts->ts_flags & ATH9K_TX_BA;
668  
669         /*
670          * The hardware occasionally sends a tx status for the wrong TID.
671          * In this case, the BA status cannot be considered valid and all
672          * subframes need to be retransmitted
673 +        *
674 +        * Only BlockAcks have a TID and therefore normal Acks cannot be
675 +        * checked
676          */
677 -       if (tidno != ts->tid)
678 +       if (isba && tidno != ts->tid)
679                 txok = false;
680  
681         isaggr = bf_isaggr(bf);