2b457197c5d334fcc8eea1bfd809953cae951902
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/b43/main.c
2 +++ b/drivers/net/wireless/b43/main.c
3 @@ -320,6 +320,10 @@ static void b43_wireless_core_exit(struc
4  static int b43_wireless_core_init(struct b43_wldev *dev);
5  static struct b43_wldev * b43_wireless_core_stop(struct b43_wldev *dev);
6  static int b43_wireless_core_start(struct b43_wldev *dev);
7 +static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
8 +                                   struct ieee80211_vif *vif,
9 +                                   struct ieee80211_bss_conf *conf,
10 +                                   u32 changed);
11  
12  static int b43_ratelimit(struct b43_wl *wl)
13  {
14 @@ -3754,14 +3758,24 @@ static int b43_op_config(struct ieee8021
15         struct ieee80211_conf *conf = &hw->conf;
16         int antenna;
17         int err = 0;
18 +       bool reload_bss = false;
19  
20         mutex_lock(&wl->mutex);
21  
22 +       dev = wl->current_dev;
23 +
24         /* Switch the band (if necessary). This might change the active core. */
25         err = b43_switch_band(wl, conf->channel);
26         if (err)
27                 goto out_unlock_mutex;
28 -       dev = wl->current_dev;
29 +
30 +       /* Need to reload all settings if the core changed */
31 +       if (dev != wl->current_dev) {
32 +               dev = wl->current_dev;
33 +               changed = ~0;
34 +               reload_bss = true;
35 +       }
36 +
37         phy = &dev->phy;
38  
39         if (conf_is_ht(conf))
40 @@ -3822,6 +3836,9 @@ out_mac_enable:
41  out_unlock_mutex:
42         mutex_unlock(&wl->mutex);
43  
44 +       if (wl->vif && reload_bss)
45 +               b43_op_bss_info_changed(hw, wl->vif, &wl->vif->bss_conf, ~0);
46 +
47         return err;
48  }
49  
50 @@ -3910,7 +3927,8 @@ static void b43_op_bss_info_changed(stru
51         if (changed & BSS_CHANGED_BEACON_INT &&
52             (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
53              b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT) ||
54 -            b43_is_mode(wl, NL80211_IFTYPE_ADHOC)))
55 +            b43_is_mode(wl, NL80211_IFTYPE_ADHOC)) &&
56 +           conf->beacon_int)
57                 b43_set_beacon_int(dev, conf->beacon_int);
58  
59         if (changed & BSS_CHANGED_BASIC_RATES)
60 @@ -4691,6 +4709,9 @@ static int b43_op_add_interface(struct i
61   out_mutex_unlock:
62         mutex_unlock(&wl->mutex);
63  
64 +       if (err == 0)
65 +               b43_op_bss_info_changed(hw, vif, &vif->bss_conf, ~0);
66 +
67         return err;
68  }
69  
70 @@ -4761,6 +4782,9 @@ static int b43_op_start(struct ieee80211
71   out_mutex_unlock:
72         mutex_unlock(&wl->mutex);
73  
74 +       /* reload configuration */
75 +       b43_op_config(hw, ~0);
76 +
77         return err;
78  }
79  
80 @@ -4917,10 +4941,18 @@ out:
81         if (err)
82                 wl->current_dev = NULL; /* Failed to init the dev. */
83         mutex_unlock(&wl->mutex);
84 -       if (err)
85 +
86 +       if (err) {
87                 b43err(wl, "Controller restart FAILED\n");
88 -       else
89 -               b43info(wl, "Controller restarted\n");
90 +               return;
91 +       }
92 +
93 +       /* reload configuration */
94 +       b43_op_config(wl->hw, ~0);
95 +       if (wl->vif)
96 +               b43_op_bss_info_changed(wl->hw, wl->vif, &wl->vif->bss_conf, ~0);
97 +
98 +       b43info(wl, "Controller restarted\n");
99  }
100  
101  static int b43_setup_bands(struct b43_wldev *dev,
102 --- a/net/mac80211/agg-rx.c
103 +++ b/net/mac80211/agg-rx.c
104 @@ -184,6 +184,8 @@ static void ieee80211_send_addba_resp(st
105                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
106         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
107                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
108 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
109 +               memcpy(mgmt->bssid, da, ETH_ALEN);
110  
111         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
112                                           IEEE80211_STYPE_ACTION);
113 --- a/net/mac80211/agg-tx.c
114 +++ b/net/mac80211/agg-tx.c
115 @@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
116         memcpy(mgmt->da, da, ETH_ALEN);
117         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
118         if (sdata->vif.type == NL80211_IFTYPE_AP ||
119 -           sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
120 +           sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
121 +           sdata->vif.type == NL80211_IFTYPE_WDS)
122                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
123         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
124                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
125 @@ -398,7 +399,8 @@ int ieee80211_start_tx_ba_session(struct
126          */
127         if (sdata->vif.type != NL80211_IFTYPE_STATION &&
128             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
129 -           sdata->vif.type != NL80211_IFTYPE_AP)
130 +           sdata->vif.type != NL80211_IFTYPE_AP &&
131 +           sdata->vif.type != NL80211_IFTYPE_WDS)
132                 return -EINVAL;
133  
134         if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
135 --- a/net/mac80211/debugfs_sta.c
136 +++ b/net/mac80211/debugfs_sta.c
137 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
138         char buf[100];
139         struct sta_info *sta = file->private_data;
140         u32 staflags = get_sta_flags(sta);
141 -       int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
142 +       int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
143                 staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
144                 staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
145                 staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
146 @@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
147                 staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
148                 staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
149                 staflags & WLAN_STA_WME ? "WME\n" : "",
150 -               staflags & WLAN_STA_WDS ? "WDS\n" : "",
151                 staflags & WLAN_STA_MFP ? "MFP\n" : "");
152         return simple_read_from_buffer(userbuf, count, ppos, buf, res);
153  }
154 --- a/net/mac80211/iface.c
155 +++ b/net/mac80211/iface.c
156 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
157  {
158         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
159         struct ieee80211_local *local = sdata->local;
160 -       struct sta_info *sta;
161         u32 changed = 0;
162         int res;
163         u32 hw_reconf_flags = 0;
164 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
165  
166         set_bit(SDATA_STATE_RUNNING, &sdata->state);
167  
168 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
169 -               /* Create STA entry for the WDS peer */
170 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
171 -                                    GFP_KERNEL);
172 -               if (!sta) {
173 -                       res = -ENOMEM;
174 -                       goto err_del_interface;
175 -               }
176 -
177 -               /* no locking required since STA is not live yet */
178 -               sta->flags |= WLAN_STA_AUTHORIZED;
179 -
180 -               res = sta_info_insert(sta);
181 -               if (res) {
182 -                       /* STA has been freed */
183 -                       goto err_del_interface;
184 -               }
185 -
186 -               rate_control_rate_init(sta);
187 -       }
188 -
189         /*
190          * set_multicast_list will be invoked by the networking core
191          * which will check whether any increments here were done in
192 @@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
193         netif_tx_start_all_queues(dev);
194  
195         return 0;
196 - err_del_interface:
197 -       drv_remove_interface(local, &sdata->vif);
198 +
199   err_stop:
200         if (!local->open_count)
201                 drv_stop(local);
202 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
203         dev->destructor = free_netdev;
204  }
205  
206 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
207 +                                        struct sk_buff *skb)
208 +{
209 +       struct ieee80211_local *local = sdata->local;
210 +       struct ieee80211_rx_status *rx_status;
211 +       struct ieee802_11_elems elems;
212 +       struct ieee80211_mgmt *mgmt;
213 +       struct sta_info *sta;
214 +       size_t baselen;
215 +       u32 rates = 0;
216 +       u16 stype;
217 +       bool new = false;
218 +       enum ieee80211_band band = local->hw.conf.channel->band;
219 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
220 +
221 +       rx_status = IEEE80211_SKB_RXCB(skb);
222 +       mgmt = (struct ieee80211_mgmt *) skb->data;
223 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
224 +
225 +       if (stype != IEEE80211_STYPE_BEACON)
226 +               return;
227 +
228 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
229 +       if (baselen > skb->len)
230 +               return;
231 +
232 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
233 +                              skb->len - baselen, &elems);
234 +
235 +       rates = ieee80211_sta_get_rates(local, &elems, band);
236 +
237 +       rcu_read_lock();
238 +
239 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
240 +
241 +       if (!sta) {
242 +               rcu_read_unlock();
243 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
244 +                                    GFP_KERNEL);
245 +               if (!sta)
246 +                       return;
247 +
248 +               new = true;
249 +       }
250 +
251 +       sta->last_rx = jiffies;
252 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
253 +
254 +       if (elems.ht_cap_elem)
255 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
256 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
257 +
258 +       if (elems.wmm_param)
259 +               set_sta_flags(sta, WLAN_STA_WME);
260 +
261 +       if (new) {
262 +               sta->flags = WLAN_STA_AUTHORIZED;
263 +               rate_control_rate_init(sta);
264 +               sta_info_insert_rcu(sta);
265 +       }
266 +
267 +       rcu_read_unlock();
268 +}
269 +
270  static void ieee80211_iface_work(struct work_struct *work)
271  {
272         struct ieee80211_sub_if_data *sdata =
273 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct 
274                                 break;
275                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
276                         break;
277 +               case NL80211_IFTYPE_WDS:
278 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
279 +                       break;
280                 default:
281                         WARN(1, "frame for unexpected interface type");
282                         break;
283 --- a/net/mac80211/rx.c
284 +++ b/net/mac80211/rx.c
285 @@ -2147,7 +2147,8 @@ ieee80211_rx_h_action(struct ieee80211_r
286                  */
287                 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
288                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
289 -                   sdata->vif.type != NL80211_IFTYPE_AP)
290 +                   sdata->vif.type != NL80211_IFTYPE_AP &&
291 +                   sdata->vif.type != NL80211_IFTYPE_WDS)
292                         break;
293  
294                 /* verify action_code is present */
295 @@ -2345,13 +2346,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
296  
297         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
298             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
299 -           sdata->vif.type != NL80211_IFTYPE_STATION)
300 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
301 +           sdata->vif.type != NL80211_IFTYPE_WDS)
302                 return RX_DROP_MONITOR;
303  
304         switch (stype) {
305         case cpu_to_le16(IEEE80211_STYPE_BEACON):
306         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
307 -               /* process for all: mesh, mlme, ibss */
308 +               /* process for all: mesh, mlme, ibss, wds */
309                 break;
310         case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
311         case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
312 @@ -2692,10 +2694,16 @@ static int prepare_for_handlers(struct i
313                 }
314                 break;
315         case NL80211_IFTYPE_WDS:
316 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
317 -                       return 0;
318                 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
319                         return 0;
320 +
321 +               if (ieee80211_is_data(hdr->frame_control) ||
322 +                   ieee80211_is_action(hdr->frame_control)) {
323 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
324 +                               return 0;
325 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
326 +                       return 0;
327 +
328                 break;
329         default:
330                 /* should never get here */
331 --- a/net/mac80211/sta_info.h
332 +++ b/net/mac80211/sta_info.h
333 @@ -31,7 +31,6 @@
334   *     frames.
335   * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
336   * @WLAN_STA_WME: Station is a QoS-STA.
337 - * @WLAN_STA_WDS: Station is one of our WDS peers.
338   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
339   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
340   *     frame to this station is transmitted.
341 @@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
342         WLAN_STA_SHORT_PREAMBLE = 1<<4,
343         WLAN_STA_ASSOC_AP       = 1<<5,
344         WLAN_STA_WME            = 1<<6,
345 -       WLAN_STA_WDS            = 1<<7,
346         WLAN_STA_CLEAR_PS_FILT  = 1<<9,
347         WLAN_STA_MFP            = 1<<10,
348         WLAN_STA_BLOCK_BA       = 1<<11,
349 --- a/drivers/net/wireless/ath/ath9k/xmit.c
350 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
351 @@ -551,7 +551,8 @@ static void ath_tx_complete_aggr(struct 
352                 if (clear_filter)
353                         tid->ac->clear_ps_filter = true;
354                 list_splice(&bf_pending, &tid->buf_q);
355 -               ath_tx_queue_tid(txq, tid);
356 +               if (!an->sleeping)
357 +                       ath_tx_queue_tid(txq, tid);
358                 spin_unlock_bh(&txq->axq_lock);
359         }
360  
361 @@ -643,8 +644,10 @@ static u32 ath_lookup_rate(struct ath_so
362   * meet the minimum required mpdudensity.
363   */
364  static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
365 -                                 struct ath_buf *bf, u16 frmlen)
366 +                                 struct ath_buf *bf, u16 frmlen,
367 +                                 bool first_subfrm)
368  {
369 +#define FIRST_DESC_NDELIMS 60
370         struct sk_buff *skb = bf->bf_mpdu;
371         struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
372         u32 nsymbits, nsymbols;
373 @@ -667,6 +670,13 @@ static int ath_compute_num_delims(struct
374                 ndelim += ATH_AGGR_ENCRYPTDELIM;
375  
376         /*
377 +        * Add delimiter when using RTS/CTS with aggregation
378 +        * and non enterprise AR9003 card
379 +        */
380 +       if (first_subfrm)
381 +               ndelim = max(ndelim, FIRST_DESC_NDELIMS);
382 +
383 +       /*
384          * Convert desired mpdu density from microeconds to bytes based
385          * on highest rate in rate series (i.e. first rate) to determine
386          * required minimum length for subframe. Take into account
387 @@ -755,7 +765,6 @@ static enum ATH_AGGR_STATUS ath_tx_form_
388                         status = ATH_AGGR_LIMITED;
389                         break;
390                 }
391 -               nframes++;
392  
393                 /* add padding for previous frame to aggregation length */
394                 al += bpad + al_delta;
395 @@ -764,9 +773,11 @@ static enum ATH_AGGR_STATUS ath_tx_form_
396                  * Get the delimiters needed to meet the MPDU
397                  * density for this node.
398                  */
399 -               ndelim = ath_compute_num_delims(sc, tid, bf_first, fi->framelen);
400 +               ndelim = ath_compute_num_delims(sc, tid, bf_first, fi->framelen,
401 +                                               !nframes);
402                 bpad = PADBYTES(al_delta) + (ndelim << 2);
403  
404 +               nframes++;
405                 bf->bf_next = NULL;
406                 ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, 0);
407  
408 @@ -1413,7 +1424,8 @@ static void ath_tx_send_ampdu(struct ath
409                  */
410                 TX_STAT_INC(txctl->txq->axq_qnum, a_queued_sw);
411                 list_add_tail(&bf->list, &tid->buf_q);
412 -               ath_tx_queue_tid(txctl->txq, tid);
413 +               if (!txctl->an || !txctl->an->sleeping)
414 +                       ath_tx_queue_tid(txctl->txq, tid);
415                 return;
416         }
417  
418 @@ -1572,9 +1584,9 @@ u8 ath_txchainmask_reduction(struct ath_
419  {
420         struct ath_hw *ah = sc->sc_ah;
421         struct ath9k_channel *curchan = ah->curchan;
422 -       if ((sc->sc_flags & SC_OP_ENABLE_APM) &&
423 -                       (curchan->channelFlags & CHANNEL_5GHZ) &&
424 -                       (chainmask == 0x7) && (rate < 0x90))
425 +       if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) &&
426 +           (curchan->channelFlags & CHANNEL_5GHZ) &&
427 +           (chainmask == 0x7) && (rate < 0x90))
428                 return 0x3;
429         else
430                 return chainmask;
431 --- a/include/net/cfg80211.h
432 +++ b/include/net/cfg80211.h
433 @@ -421,6 +421,7 @@ struct station_parameters {
434   * @STATION_INFO_RX_BITRATE: @rxrate fields are filled
435   * @STATION_INFO_BSS_PARAM: @bss_param filled
436   * @STATION_INFO_CONNECTED_TIME: @connected_time filled
437 + * @STATION_INFO_ASSOC_REQ_IES: @assoc_req_ies filled
438   */
439  enum station_info_flags {
440         STATION_INFO_INACTIVE_TIME      = 1<<0,
441 @@ -439,7 +440,8 @@ enum station_info_flags {
442         STATION_INFO_SIGNAL_AVG         = 1<<13,
443         STATION_INFO_RX_BITRATE         = 1<<14,
444         STATION_INFO_BSS_PARAM          = 1<<15,
445 -       STATION_INFO_CONNECTED_TIME     = 1<<16
446 +       STATION_INFO_CONNECTED_TIME     = 1<<16,
447 +       STATION_INFO_ASSOC_REQ_IES      = 1<<17
448  };
449  
450  /**
451 --- a/net/wireless/nl80211.c
452 +++ b/net/wireless/nl80211.c
453 @@ -2236,7 +2236,7 @@ static int nl80211_send_station(struct s
454         }
455         nla_nest_end(msg, sinfoattr);
456  
457 -       if (sinfo->assoc_req_ies)
458 +       if (sinfo->filled & STATION_INFO_ASSOC_REQ_IES)
459                 NLA_PUT(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len,
460                         sinfo->assoc_req_ies);
461  
462 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
463 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
464 @@ -415,36 +415,12 @@ static void ar9003_hw_set11n_ratescenari
465  static void ar9003_hw_set11n_aggr_first(struct ath_hw *ah, void *ds,
466                                         u32 aggrLen)
467  {
468 -#define FIRST_DESC_NDELIMS 60
469         struct ar9003_txc *ads = (struct ar9003_txc *) ds;
470  
471         ads->ctl12 |= (AR_IsAggr | AR_MoreAggr);
472  
473 -       if (ah->ent_mode & AR_ENT_OTP_MPSD) {
474 -               u32 ctl17, ndelim;
475 -               /*
476 -                * Add delimiter when using RTS/CTS with aggregation
477 -                * and non enterprise AR9003 card
478 -                */
479 -               ctl17 = ads->ctl17;
480 -               ndelim = MS(ctl17, AR_PadDelim);
481 -
482 -               if (ndelim < FIRST_DESC_NDELIMS) {
483 -                       aggrLen += (FIRST_DESC_NDELIMS - ndelim) * 4;
484 -                       ndelim = FIRST_DESC_NDELIMS;
485 -               }
486 -
487 -               ctl17 &= ~AR_AggrLen;
488 -               ctl17 |= SM(aggrLen, AR_AggrLen);
489 -
490 -               ctl17 &= ~AR_PadDelim;
491 -               ctl17 |= SM(ndelim, AR_PadDelim);
492 -
493 -               ads->ctl17 = ctl17;
494 -       } else {
495 -               ads->ctl17 &= ~AR_AggrLen;
496 -               ads->ctl17 |= SM(aggrLen, AR_AggrLen);
497 -       }
498 +       ads->ctl17 &= ~AR_AggrLen;
499 +       ads->ctl17 |= SM(aggrLen, AR_AggrLen);
500  }
501  
502  static void ar9003_hw_set11n_aggr_middle(struct ath_hw *ah, void *ds,
503 --- a/drivers/net/wireless/ath/ath9k/main.c
504 +++ b/drivers/net/wireless/ath/ath9k/main.c
505 @@ -565,7 +565,6 @@ set_timer:
506  static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
507  {
508         struct ath_node *an;
509 -       struct ath_hw *ah = sc->sc_ah;
510         an = (struct ath_node *)sta->drv_priv;
511  
512  #ifdef CONFIG_ATH9K_DEBUGFS
513 @@ -574,9 +573,6 @@ static void ath_node_attach(struct ath_s
514         spin_unlock(&sc->nodes_lock);
515         an->sta = sta;
516  #endif
517 -       if ((ah->caps.hw_caps) & ATH9K_HW_CAP_APM)
518 -               sc->sc_flags |= SC_OP_ENABLE_APM;
519 -
520         if (sc->sc_flags & SC_OP_TXAGGR) {
521                 ath_tx_node_init(sc, an);
522                 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
523 @@ -826,11 +822,9 @@ irqreturn_t ath_isr(int irq, void *dev)
524         if (status & ATH9K_INT_TXURN)
525                 ath9k_hw_updatetxtriglevel(ah, true);
526  
527 -       if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
528 -               if (status & ATH9K_INT_RXEOL) {
529 -                       ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
530 -                       ath9k_hw_set_interrupts(ah, ah->imask);
531 -               }
532 +       if (status & ATH9K_INT_RXEOL) {
533 +               ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
534 +               ath9k_hw_set_interrupts(ah, ah->imask);
535         }
536  
537         if (status & ATH9K_INT_MIB) {
538 @@ -1680,6 +1674,7 @@ static int ath9k_config(struct ieee80211
539  
540         if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
541                 struct ieee80211_channel *curchan = hw->conf.channel;
542 +               struct ath9k_channel old_chan;
543                 int pos = curchan->hw_value;
544                 int old_pos = -1;
545                 unsigned long flags;
546 @@ -1696,15 +1691,25 @@ static int ath9k_config(struct ieee80211
547                         "Set channel: %d MHz type: %d\n",
548                         curchan->center_freq, conf->channel_type);
549  
550 -               ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
551 -                                         curchan, conf->channel_type);
552 -
553                 /* update survey stats for the old channel before switching */
554                 spin_lock_irqsave(&common->cc_lock, flags);
555                 ath_update_survey_stats(sc);
556                 spin_unlock_irqrestore(&common->cc_lock, flags);
557  
558                 /*
559 +                * Preserve the current channel values, before updating
560 +                * the same channel
561 +                */
562 +               if (old_pos == pos) {
563 +                       memcpy(&old_chan, &sc->sc_ah->channels[pos],
564 +                               sizeof(struct ath9k_channel));
565 +                       ah->curchan = &old_chan;
566 +               }
567 +
568 +               ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
569 +                                         curchan, conf->channel_type);
570 +
571 +               /*
572                  * If the operating channel changes, change the survey in-use flags
573                  * along with it.
574                  * Reset the survey data for the new channel, unless we're switching
575 --- a/drivers/net/wireless/ath/ath9k/recv.c
576 +++ b/drivers/net/wireless/ath/ath9k/recv.c
577 @@ -761,7 +761,7 @@ static struct ath_buf *ath_get_next_rx_b
578          * on.  All this is necessary because of our use of
579          * a self-linked list to avoid rx overruns.
580          */
581 -       ret = ath9k_hw_rxprocdesc(ah, ds, rs, 0);
582 +       ret = ath9k_hw_rxprocdesc(ah, ds, rs);
583         if (ret == -EINPROGRESS) {
584                 struct ath_rx_status trs;
585                 struct ath_buf *tbf;
586 @@ -787,7 +787,7 @@ static struct ath_buf *ath_get_next_rx_b
587                  */
588  
589                 tds = tbf->bf_desc;
590 -               ret = ath9k_hw_rxprocdesc(ah, tds, &trs, 0);
591 +               ret = ath9k_hw_rxprocdesc(ah, tds, &trs);
592                 if (ret == -EINPROGRESS)
593                         return NULL;
594         }
595 @@ -1978,5 +1978,10 @@ requeue:
596  
597         spin_unlock_bh(&sc->rx.rxbuflock);
598  
599 +       if (!(ah->imask & ATH9K_INT_RXEOL)) {
600 +               ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
601 +               ath9k_hw_set_interrupts(ah, ah->imask);
602 +       }
603 +
604         return 0;
605  }
606 --- a/drivers/net/wireless/ath/ath9k/mac.c
607 +++ b/drivers/net/wireless/ath/ath9k/mac.c
608 @@ -345,21 +345,8 @@ int ath9k_hw_setuptxqueue(struct ath_hw 
609         }
610         memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
611         qi->tqi_type = type;
612 -       if (qinfo == NULL) {
613 -               qi->tqi_qflags =
614 -                       TXQ_FLAG_TXOKINT_ENABLE
615 -                       | TXQ_FLAG_TXERRINT_ENABLE
616 -                       | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
617 -               qi->tqi_aifs = INIT_AIFS;
618 -               qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
619 -               qi->tqi_cwmax = INIT_CWMAX;
620 -               qi->tqi_shretry = INIT_SH_RETRY;
621 -               qi->tqi_lgretry = INIT_LG_RETRY;
622 -               qi->tqi_physCompBuf = 0;
623 -       } else {
624 -               qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
625 -               (void) ath9k_hw_set_txq_props(ah, q, qinfo);
626 -       }
627 +       qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
628 +       (void) ath9k_hw_set_txq_props(ah, q, qinfo);
629  
630         return q;
631  }
632 @@ -564,7 +551,7 @@ bool ath9k_hw_resettxqueue(struct ath_hw
633  EXPORT_SYMBOL(ath9k_hw_resettxqueue);
634  
635  int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
636 -                       struct ath_rx_status *rs, u64 tsf)
637 +                       struct ath_rx_status *rs)
638  {
639         struct ar5416_desc ads;
640         struct ar5416_desc *adsp = AR5416DESC(ds);
641 --- a/drivers/net/wireless/ath/ath9k/mac.h
642 +++ b/drivers/net/wireless/ath/ath9k/mac.h
643 @@ -687,7 +687,7 @@ int ath9k_hw_setuptxqueue(struct ath_hw 
644  bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q);
645  bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q);
646  int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
647 -                       struct ath_rx_status *rs, u64 tsf);
648 +                       struct ath_rx_status *rs);
649  void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds,
650                           u32 size, u32 flags);
651  bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set);
652 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
653 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
654 @@ -839,20 +839,8 @@ static bool ar9003_hw_init_cal(struct at
655                                struct ath9k_channel *chan)
656  {
657         struct ath_common *common = ath9k_hw_common(ah);
658 -       struct ath9k_hw_capabilities *pCap = &ah->caps;
659 -       int val;
660         bool txiqcal_done = false;
661  
662 -       val = REG_READ(ah, AR_ENT_OTP);
663 -       ath_dbg(common, ATH_DBG_CALIBRATE, "ath9k: AR_ENT_OTP 0x%x\n", val);
664 -
665 -       /* Configure rx/tx chains before running AGC/TxiQ cals */
666 -       if (val & AR_ENT_OTP_CHAIN2_DISABLE)
667 -               ar9003_hw_set_chain_masks(ah, 0x3, 0x3);
668 -       else
669 -               ar9003_hw_set_chain_masks(ah, pCap->rx_chainmask,
670 -                                         pCap->tx_chainmask);
671 -
672         /* Do Tx IQ Calibration */
673         REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_1,
674                       AR_PHY_TX_IQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT,
675 @@ -887,9 +875,6 @@ static bool ar9003_hw_init_cal(struct at
676         if (txiqcal_done)
677                 ar9003_hw_tx_iq_cal_post_proc(ah);
678  
679 -       /* Revert chainmasks to their original values before NF cal */
680 -       ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
681 -
682         ath9k_hw_start_nfcal(ah, true);
683  
684         /* Initialize list pointers */
685 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
686 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
687 @@ -540,7 +540,7 @@ static void ar9003_hw_init_bb(struct ath
688         udelay(synthDelay + BASE_ACTIVATE_DELAY);
689  }
690  
691 -void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
692 +static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
693  {
694         switch (rx) {
695         case 0x5:
696 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
697 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
698 @@ -1124,6 +1124,4 @@
699  #define AR_PHY_CL_TAB_CL_GAIN_MOD              0x1f
700  #define AR_PHY_CL_TAB_CL_GAIN_MOD_S            0
701  
702 -void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
703 -
704  #endif  /* AR9003_PHY_H */
705 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
706 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
707 @@ -558,8 +558,7 @@ struct ath_ant_comb {
708  #define SC_OP_BT_PRIORITY_DETECTED   BIT(12)
709  #define SC_OP_BT_SCAN               BIT(13)
710  #define SC_OP_ANI_RUN               BIT(14)
711 -#define SC_OP_ENABLE_APM            BIT(15)
712 -#define SC_OP_PRIM_STA_VIF          BIT(16)
713 +#define SC_OP_PRIM_STA_VIF          BIT(15)
714  
715  /* Powersave flags */
716  #define PS_WAIT_FOR_BEACON        BIT(0)
717 @@ -664,7 +663,6 @@ extern int led_blink;
718  extern bool is_ath9k_unloaded;
719  
720  irqreturn_t ath_isr(int irq, void *dev);
721 -void ath9k_init_crypto(struct ath_softc *sc);
722  int ath9k_init_device(u16 devid, struct ath_softc *sc,
723                     const struct ath_bus_ops *bus_ops);
724  void ath9k_deinit_device(struct ath_softc *sc);
725 --- a/drivers/net/wireless/ath/ath9k/common.c
726 +++ b/drivers/net/wireless/ath/ath9k/common.c
727 @@ -169,6 +169,32 @@ void ath9k_cmn_update_txpow(struct ath_h
728  }
729  EXPORT_SYMBOL(ath9k_cmn_update_txpow);
730  
731 +void ath9k_cmn_init_crypto(struct ath_hw *ah)
732 +{
733 +       struct ath_common *common = ath9k_hw_common(ah);
734 +       int i = 0;
735 +
736 +       /* Get the hardware key cache size. */
737 +       common->keymax = AR_KEYTABLE_SIZE;
738 +
739 +       /*
740 +        * Check whether the separate key cache entries
741 +        * are required to handle both tx+rx MIC keys.
742 +        * With split mic keys the number of stations is limited
743 +        * to 27 otherwise 59.
744 +        */
745 +       if (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)
746 +               common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
747 +
748 +       /*
749 +        * Reset the key cache since some parts do not
750 +        * reset the contents on initial power up.
751 +        */
752 +       for (i = 0; i < common->keymax; i++)
753 +               ath_hw_keyreset(common, (u16) i);
754 +}
755 +EXPORT_SYMBOL(ath9k_cmn_init_crypto);
756 +
757  static int __init ath9k_cmn_init(void)
758  {
759         return 0;
760 --- a/drivers/net/wireless/ath/ath9k/common.h
761 +++ b/drivers/net/wireless/ath/ath9k/common.h
762 @@ -62,3 +62,4 @@ void ath9k_cmn_btcoex_bt_stomp(struct at
763                                   enum ath_stomp_type stomp_type);
764  void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
765                             u16 new_txpow, u16 *txpower);
766 +void ath9k_cmn_init_crypto(struct ath_hw *ah);
767 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
768 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
769 @@ -572,25 +572,6 @@ err:
770         return -EINVAL;
771  }
772  
773 -static void ath9k_init_crypto(struct ath9k_htc_priv *priv)
774 -{
775 -       struct ath_common *common = ath9k_hw_common(priv->ah);
776 -       int i = 0;
777 -
778 -       /* Get the hardware key cache size. */
779 -       common->keymax = AR_KEYTABLE_SIZE;
780 -
781 -       if (priv->ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)
782 -               common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
783 -
784 -       /*
785 -        * Reset the key cache since some parts do not
786 -        * reset the contents on initial power up.
787 -        */
788 -       for (i = 0; i < common->keymax; i++)
789 -               ath_hw_keyreset(common, (u16) i);
790 -}
791 -
792  static void ath9k_init_channels_rates(struct ath9k_htc_priv *priv)
793  {
794         if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
795 @@ -720,7 +701,7 @@ static int ath9k_init_priv(struct ath9k_
796         for (i = 0; i < ATH9K_HTC_MAX_BCN_VIF; i++)
797                 priv->cur_beacon_conf.bslot[i] = NULL;
798  
799 -       ath9k_init_crypto(priv);
800 +       ath9k_cmn_init_crypto(ah);
801         ath9k_init_channels_rates(priv);
802         ath9k_init_misc(priv);
803  
804 --- a/drivers/net/wireless/ath/ath9k/init.c
805 +++ b/drivers/net/wireless/ath/ath9k/init.c
806 @@ -404,31 +404,6 @@ fail:
807         return error;
808  }
809  
810 -void ath9k_init_crypto(struct ath_softc *sc)
811 -{
812 -       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
813 -       int i = 0;
814 -
815 -       /* Get the hardware key cache size. */
816 -       common->keymax = AR_KEYTABLE_SIZE;
817 -
818 -       /*
819 -        * Reset the key cache since some parts do not
820 -        * reset the contents on initial power up.
821 -        */
822 -       for (i = 0; i < common->keymax; i++)
823 -               ath_hw_keyreset(common, (u16) i);
824 -
825 -       /*
826 -        * Check whether the separate key cache entries
827 -        * are required to handle both tx+rx MIC keys.
828 -        * With split mic keys the number of stations is limited
829 -        * to 27 otherwise 59.
830 -        */
831 -       if (sc->sc_ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)
832 -               common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
833 -}
834 -
835  static int ath9k_init_btcoex(struct ath_softc *sc)
836  {
837         struct ath_txq *txq;
838 @@ -630,7 +605,7 @@ static int ath9k_init_softc(u16 devid, s
839         if (ret)
840                 goto err_btcoex;
841  
842 -       ath9k_init_crypto(sc);
843 +       ath9k_cmn_init_crypto(sc->sc_ah);
844         ath9k_init_misc(sc);
845  
846         return 0;
847 --- a/drivers/net/wireless/ath/ath9k/pci.c
848 +++ b/drivers/net/wireless/ath/ath9k/pci.c
849 @@ -129,7 +129,7 @@ static void ath_pci_aspm_init(struct ath
850                 return;
851  
852         parent = pdev->bus->self;
853 -       if (WARN_ON(!parent))
854 +       if (!parent)
855                 return;
856  
857         pos = pci_pcie_cap(parent);
858 @@ -338,7 +338,7 @@ static int ath_pci_resume(struct device 
859            * semi-random values after suspend/resume.
860            */
861         ath9k_ps_wakeup(sc);
862 -       ath9k_init_crypto(sc);
863 +       ath9k_cmn_init_crypto(sc->sc_ah);
864         ath9k_ps_restore(sc);
865  
866         sc->ps_idle = true;
867 --- a/drivers/net/wireless/ath/ath9k/calib.c
868 +++ b/drivers/net/wireless/ath/ath9k/calib.c
869 @@ -82,7 +82,6 @@ static void ath9k_hw_update_nfcal_hist_b
870                                               int16_t *nfarray)
871  {
872         struct ath_common *common = ath9k_hw_common(ah);
873 -       struct ieee80211_conf *conf = &common->hw->conf;
874         struct ath_nf_limits *limit;
875         struct ath9k_nfcal_hist *h;
876         bool high_nf_mid = false;
877 @@ -94,7 +93,7 @@ static void ath9k_hw_update_nfcal_hist_b
878  
879         for (i = 0; i < NUM_NF_READINGS; i++) {
880                 if (!(chainmask & (1 << i)) ||
881 -                   ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
882 +                   ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(ah->curchan)))
883                         continue;
884  
885                 h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
886 --- a/drivers/net/wireless/ath/ath9k/debug.c
887 +++ b/drivers/net/wireless/ath/ath9k/debug.c
888 @@ -1163,6 +1163,59 @@ static const struct file_operations fops
889         .llseek = default_llseek,/* read accesses f_pos */
890  };
891  
892 +static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
893 +                                   size_t count, loff_t *ppos)
894 +{
895 +       struct ath_softc *sc = file->private_data;
896 +       struct ath_hw *ah = sc->sc_ah;
897 +       struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
898 +       struct ath_common *common = ath9k_hw_common(ah);
899 +       struct ieee80211_conf *conf = &common->hw->conf;
900 +       u32 len = 0, size = 1500;
901 +       u32 i, j;
902 +       ssize_t retval = 0;
903 +       char *buf;
904 +       u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
905 +       u8 nread;
906 +
907 +       buf = kzalloc(size, GFP_KERNEL);
908 +       if (!buf)
909 +               return -ENOMEM;
910 +
911 +       len += snprintf(buf + len, size - len,
912 +                       "Channel Noise Floor : %d\n", ah->noise);
913 +       len += snprintf(buf + len, size - len,
914 +                       "Chain | privNF | # Readings | NF Readings\n");
915 +       for (i = 0; i < NUM_NF_READINGS; i++) {
916 +               if (!(chainmask & (1 << i)) ||
917 +                   ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
918 +                       continue;
919 +
920 +               nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
921 +               len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
922 +                               i, h[i].privNF, nread);
923 +               for (j = 0; j < nread; j++)
924 +                       len += snprintf(buf + len, size - len,
925 +                                       " %d", h[i].nfCalBuffer[j]);
926 +               len += snprintf(buf + len, size - len, "\n");
927 +       }
928 +
929 +       if (len > size)
930 +               len = size;
931 +
932 +       retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
933 +       kfree(buf);
934 +
935 +       return retval;
936 +}
937 +
938 +static const struct file_operations fops_dump_nfcal = {
939 +       .read = read_file_dump_nfcal,
940 +       .open = ath9k_debugfs_open,
941 +       .owner = THIS_MODULE,
942 +       .llseek = default_llseek,
943 +};
944 +
945  static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
946                                      size_t count, loff_t *ppos)
947  {
948 @@ -1262,6 +1315,8 @@ int ath9k_init_debug(struct ath_hw *ah)
949                             &ah->config.cwm_ignore_extcca);
950         debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
951                             &fops_regdump);
952 +       debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
953 +                           &fops_dump_nfcal);
954         debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
955                             &fops_base_eeprom);
956         debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
957 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
958 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
959 @@ -69,7 +69,7 @@ static int ar9003_hw_power_interpolate(i
960  static const struct ar9300_eeprom ar9300_default = {
961         .eepromVersion = 2,
962         .templateVersion = 2,
963 -       .macAddr = {1, 2, 3, 4, 5, 6},
964 +       .macAddr = {0, 2, 3, 4, 5, 6},
965         .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
966                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
967         .baseEepHeader = {
968 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
969 +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
970 @@ -349,10 +349,7 @@ static u32 ath9k_hw_4k_get_eeprom(struct
971         case EEP_ANT_DIV_CTL1:
972                 return pModal->antdiv_ctl1;
973         case EEP_TXGAIN_TYPE:
974 -               if (ver_minor >= AR5416_EEP_MINOR_VER_19)
975 -                       return pBase->txGainType;
976 -               else
977 -                       return AR5416_EEP_TXGAIN_ORIGINAL;
978 +               return pBase->txGainType;
979         default:
980                 return 0;
981         }