ath9k_htc: fix signal strength reporting issues
[12.09/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 @@ -850,7 +852,7 @@ ath5k_txbuf_free_skb(struct ath5k_hw *ah
13                 return;
14         dma_unmap_single(ah->dev, bf->skbaddr, bf->skb->len,
15                         DMA_TO_DEVICE);
16 -       dev_kfree_skb_any(bf->skb);
17 +       ieee80211_free_txskb(ah->hw, bf->skb);
18         bf->skb = NULL;
19         bf->skbaddr = 0;
20         bf->desc->ds_data = 0;
21 @@ -1577,7 +1579,7 @@ ath5k_tx_queue(struct ieee80211_hw *hw, 
22         return;
23  
24  drop_packet:
25 -       dev_kfree_skb_any(skb);
26 +       ieee80211_free_txskb(hw, skb);
27  }
28  
29  static void
30 --- a/net/mac80211/agg-rx.c
31 +++ b/net/mac80211/agg-rx.c
32 @@ -203,6 +203,8 @@ static void ieee80211_send_addba_resp(st
33                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
34         else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
35                 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
36 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
37 +               memcpy(mgmt->bssid, da, ETH_ALEN);
38  
39         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
40                                           IEEE80211_STYPE_ACTION);
41 --- a/net/mac80211/agg-tx.c
42 +++ b/net/mac80211/agg-tx.c
43 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
44         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
45         if (sdata->vif.type == NL80211_IFTYPE_AP ||
46             sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
47 -           sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
48 +           sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
49 +           sdata->vif.type == NL80211_IFTYPE_WDS)
50                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
51         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
52                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
53 @@ -460,6 +461,7 @@ int ieee80211_start_tx_ba_session(struct
54             sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
55             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
56             sdata->vif.type != NL80211_IFTYPE_AP &&
57 +           sdata->vif.type != NL80211_IFTYPE_WDS &&
58             sdata->vif.type != NL80211_IFTYPE_ADHOC)
59                 return -EINVAL;
60  
61 @@ -869,7 +871,7 @@ void ieee80211_process_addba_resp(struct
62  
63         } else {
64                 ___ieee80211_stop_tx_ba_session(sta, tid, WLAN_BACK_INITIATOR,
65 -                                               true);
66 +                                               false);
67         }
68  
69   out:
70 --- a/net/mac80211/debugfs_sta.c
71 +++ b/net/mac80211/debugfs_sta.c
72 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
73         test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
74  
75         int res = scnprintf(buf, sizeof(buf),
76 -                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
77 +                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
78                             TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
79                             TEST(PS_DRIVER), TEST(AUTHORIZED),
80                             TEST(SHORT_PREAMBLE),
81 -                           TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
82 +                           TEST(WME), TEST(CLEAR_PS_FILT),
83                             TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
84                             TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
85                             TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
86 --- a/net/mac80211/iface.c
87 +++ b/net/mac80211/iface.c
88 @@ -420,7 +420,6 @@ int ieee80211_do_open(struct wireless_de
89         struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
90         struct net_device *dev = wdev->netdev;
91         struct ieee80211_local *local = sdata->local;
92 -       struct sta_info *sta;
93         u32 changed = 0;
94         int res;
95         u32 hw_reconf_flags = 0;
96 @@ -575,30 +574,8 @@ int ieee80211_do_open(struct wireless_de
97  
98         set_bit(SDATA_STATE_RUNNING, &sdata->state);
99  
100 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
101 -               /* Create STA entry for the WDS peer */
102 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
103 -                                    GFP_KERNEL);
104 -               if (!sta) {
105 -                       res = -ENOMEM;
106 -                       goto err_del_interface;
107 -               }
108 -
109 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
110 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
111 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
112 -
113 -               res = sta_info_insert(sta);
114 -               if (res) {
115 -                       /* STA has been freed */
116 -                       goto err_del_interface;
117 -               }
118 -
119 -               rate_control_rate_init(sta);
120 -               netif_carrier_on(dev);
121 -       } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
122 +       if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
123                 rcu_assign_pointer(local->p2p_sdata, sdata);
124 -       }
125  
126         /*
127          * set_multicast_list will be invoked by the networking core
128 @@ -849,7 +826,7 @@ static void ieee80211_do_stop(struct iee
129                         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
130                         if (info->control.vif == &sdata->vif) {
131                                 __skb_unlink(skb, &local->pending[i]);
132 -                               dev_kfree_skb_irq(skb);
133 +                               ieee80211_free_txskb(&local->hw, skb);
134                         }
135                 }
136         }
137 @@ -997,6 +974,72 @@ static void ieee80211_if_setup(struct ne
138         dev->destructor = free_netdev;
139  }
140  
141 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
142 +                                        struct sk_buff *skb)
143 +{
144 +       struct ieee80211_local *local = sdata->local;
145 +       struct ieee80211_rx_status *rx_status;
146 +       struct ieee802_11_elems elems;
147 +       struct ieee80211_mgmt *mgmt;
148 +       struct sta_info *sta;
149 +       size_t baselen;
150 +       u32 rates = 0;
151 +       u16 stype;
152 +       bool new = false;
153 +       enum ieee80211_band band = local->hw.conf.channel->band;
154 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
155 +
156 +       rx_status = IEEE80211_SKB_RXCB(skb);
157 +       mgmt = (struct ieee80211_mgmt *) skb->data;
158 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
159 +
160 +       if (stype != IEEE80211_STYPE_BEACON)
161 +               return;
162 +
163 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
164 +       if (baselen > skb->len)
165 +               return;
166 +
167 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
168 +                              skb->len - baselen, &elems);
169 +
170 +       rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
171 +
172 +       rcu_read_lock();
173 +
174 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
175 +
176 +       if (!sta) {
177 +               rcu_read_unlock();
178 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
179 +                                    GFP_KERNEL);
180 +               if (!sta)
181 +                       return;
182 +
183 +               new = true;
184 +       }
185 +
186 +       sta->last_rx = jiffies;
187 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
188 +
189 +       if (elems.ht_cap_elem)
190 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
191 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
192 +
193 +       if (elems.wmm_param)
194 +               set_sta_flag(sta, WLAN_STA_WME);
195 +
196 +       if (new) {
197 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
198 +               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
199 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
200 +               rate_control_rate_init(sta);
201 +               sta_info_insert_rcu(sta);
202 +       }
203 +
204 +       rcu_read_unlock();
205 +}
206 +
207  static void ieee80211_iface_work(struct work_struct *work)
208  {
209         struct ieee80211_sub_if_data *sdata =
210 @@ -1101,6 +1144,9 @@ static void ieee80211_iface_work(struct 
211                                 break;
212                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
213                         break;
214 +               case NL80211_IFTYPE_WDS:
215 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
216 +                       break;
217                 default:
218                         WARN(1, "frame for unexpected interface type");
219                         break;
220 --- a/net/mac80211/rx.c
221 +++ b/net/mac80211/rx.c
222 @@ -2279,6 +2279,7 @@ ieee80211_rx_h_action(struct ieee80211_r
223                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
224                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
225                     sdata->vif.type != NL80211_IFTYPE_AP &&
226 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
227                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
228                         break;
229  
230 @@ -2496,14 +2497,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
231  
232         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
233             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
234 -           sdata->vif.type != NL80211_IFTYPE_STATION)
235 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
236 +           sdata->vif.type != NL80211_IFTYPE_WDS)
237                 return RX_DROP_MONITOR;
238  
239         switch (stype) {
240         case cpu_to_le16(IEEE80211_STYPE_AUTH):
241         case cpu_to_le16(IEEE80211_STYPE_BEACON):
242         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
243 -               /* process for all: mesh, mlme, ibss */
244 +               /* process for all: mesh, mlme, ibss, wds */
245                 break;
246         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
247         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
248 @@ -2827,10 +2829,16 @@ static int prepare_for_handlers(struct i
249                 }
250                 break;
251         case NL80211_IFTYPE_WDS:
252 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
253 -                       return 0;
254                 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
255                         return 0;
256 +
257 +               if (ieee80211_is_data(hdr->frame_control) ||
258 +                   ieee80211_is_action(hdr->frame_control)) {
259 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
260 +                               return 0;
261 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
262 +                       return 0;
263 +
264                 break;
265         case NL80211_IFTYPE_P2P_DEVICE:
266                 if (!ieee80211_is_public_action(hdr, skb->len) &&
267 --- a/net/mac80211/sta_info.h
268 +++ b/net/mac80211/sta_info.h
269 @@ -32,7 +32,6 @@
270   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
271   *     frames.
272   * @WLAN_STA_WME: Station is a QoS-STA.
273 - * @WLAN_STA_WDS: Station is one of our WDS peers.
274   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
275   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
276   *     frame to this station is transmitted.
277 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
278         WLAN_STA_AUTHORIZED,
279         WLAN_STA_SHORT_PREAMBLE,
280         WLAN_STA_WME,
281 -       WLAN_STA_WDS,
282         WLAN_STA_CLEAR_PS_FILT,
283         WLAN_STA_MFP,
284         WLAN_STA_BLOCK_BA,
285 --- a/net/mac80211/status.c
286 +++ b/net/mac80211/status.c
287 @@ -34,7 +34,7 @@ void ieee80211_tx_status_irqsafe(struct 
288                 skb_queue_len(&local->skb_queue_unreliable);
289         while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
290                (skb = skb_dequeue(&local->skb_queue_unreliable))) {
291 -               dev_kfree_skb_irq(skb);
292 +               ieee80211_free_txskb(hw, skb);
293                 tmp--;
294                 I802_DEBUG_INC(local->tx_status_drop);
295         }
296 @@ -159,7 +159,7 @@ static void ieee80211_handle_filtered_fr
297                            "dropped TX filtered frame, queue_len=%d PS=%d @%lu\n",
298                            skb_queue_len(&sta->tx_filtered[ac]),
299                            !!test_sta_flag(sta, WLAN_STA_PS_STA), jiffies);
300 -       dev_kfree_skb(skb);
301 +       ieee80211_free_txskb(&local->hw, skb);
302  }
303  
304  static void ieee80211_check_pending_bar(struct sta_info *sta, u8 *addr, u8 tid)
305 @@ -324,6 +324,75 @@ static void ieee80211_add_tx_radiotap_he
306  
307  }
308  
309 +static void ieee80211_report_used_skb(struct ieee80211_local *local,
310 +                                     struct sk_buff *skb, bool dropped)
311 +{
312 +       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
313 +       struct ieee80211_hdr *hdr = (void *)skb->data;
314 +       bool acked = info->flags & IEEE80211_TX_STAT_ACK;
315 +
316 +       if (dropped)
317 +               acked = false;
318 +
319 +       if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
320 +               struct ieee80211_sub_if_data *sdata = NULL;
321 +               struct ieee80211_sub_if_data *iter_sdata;
322 +               u64 cookie = (unsigned long)skb;
323 +
324 +               rcu_read_lock();
325 +
326 +               if (skb->dev) {
327 +                       list_for_each_entry_rcu(iter_sdata, &local->interfaces,
328 +                                               list) {
329 +                               if (!iter_sdata->dev)
330 +                                       continue;
331 +
332 +                               if (skb->dev == iter_sdata->dev) {
333 +                                       sdata = iter_sdata;
334 +                                       break;
335 +                               }
336 +                       }
337 +               } else {
338 +                       sdata = rcu_dereference(local->p2p_sdata);
339 +               }
340 +
341 +               if (!sdata)
342 +                       skb->dev = NULL;
343 +               else if (ieee80211_is_nullfunc(hdr->frame_control) ||
344 +                        ieee80211_is_qos_nullfunc(hdr->frame_control)) {
345 +                       cfg80211_probe_status(sdata->dev, hdr->addr1,
346 +                                             cookie, acked, GFP_ATOMIC);
347 +               } else {
348 +                       cfg80211_mgmt_tx_status(&sdata->wdev, cookie, skb->data,
349 +                                               skb->len, acked, GFP_ATOMIC);
350 +               }
351 +
352 +               rcu_read_unlock();
353 +       }
354 +
355 +       if (unlikely(info->ack_frame_id)) {
356 +               struct sk_buff *ack_skb;
357 +               unsigned long flags;
358 +
359 +               spin_lock_irqsave(&local->ack_status_lock, flags);
360 +               ack_skb = idr_find(&local->ack_status_frames,
361 +                                  info->ack_frame_id);
362 +               if (ack_skb)
363 +                       idr_remove(&local->ack_status_frames,
364 +                                  info->ack_frame_id);
365 +               spin_unlock_irqrestore(&local->ack_status_lock, flags);
366 +
367 +               if (ack_skb) {
368 +                       if (!dropped) {
369 +                               /* consumes ack_skb */
370 +                               skb_complete_wifi_ack(ack_skb, acked);
371 +                       } else {
372 +                               dev_kfree_skb_any(ack_skb);
373 +                       }
374 +               }
375 +       }
376 +}
377 +
378  /*
379   * Use a static threshold for now, best value to be determined
380   * by testing ...
381 @@ -515,50 +584,7 @@ void ieee80211_tx_status(struct ieee8021
382                                         msecs_to_jiffies(10));
383         }
384  
385 -       if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
386 -               u64 cookie = (unsigned long)skb;
387 -               acked = info->flags & IEEE80211_TX_STAT_ACK;
388 -
389 -               if (ieee80211_is_nullfunc(hdr->frame_control) ||
390 -                   ieee80211_is_qos_nullfunc(hdr->frame_control)) {
391 -                       cfg80211_probe_status(skb->dev, hdr->addr1,
392 -                                             cookie, acked, GFP_ATOMIC);
393 -               } else if (skb->dev) {
394 -                       cfg80211_mgmt_tx_status(
395 -                               skb->dev->ieee80211_ptr, cookie, skb->data,
396 -                               skb->len, acked, GFP_ATOMIC);
397 -               } else {
398 -                       struct ieee80211_sub_if_data *p2p_sdata;
399 -
400 -                       rcu_read_lock();
401 -
402 -                       p2p_sdata = rcu_dereference(local->p2p_sdata);
403 -                       if (p2p_sdata) {
404 -                               cfg80211_mgmt_tx_status(
405 -                                       &p2p_sdata->wdev, cookie, skb->data,
406 -                                       skb->len, acked, GFP_ATOMIC);
407 -                       }
408 -                       rcu_read_unlock();
409 -               }
410 -       }
411 -
412 -       if (unlikely(info->ack_frame_id)) {
413 -               struct sk_buff *ack_skb;
414 -               unsigned long flags;
415 -
416 -               spin_lock_irqsave(&local->ack_status_lock, flags);
417 -               ack_skb = idr_find(&local->ack_status_frames,
418 -                                  info->ack_frame_id);
419 -               if (ack_skb)
420 -                       idr_remove(&local->ack_status_frames,
421 -                                  info->ack_frame_id);
422 -               spin_unlock_irqrestore(&local->ack_status_lock, flags);
423 -
424 -               /* consumes ack_skb */
425 -               if (ack_skb)
426 -                       skb_complete_wifi_ack(ack_skb,
427 -                               info->flags & IEEE80211_TX_STAT_ACK);
428 -       }
429 +       ieee80211_report_used_skb(local, skb, false);
430  
431         /* this was a transmitted frame, but now we want to reuse it */
432         skb_orphan(skb);
433 @@ -634,25 +660,17 @@ EXPORT_SYMBOL(ieee80211_report_low_ack);
434  void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
435  {
436         struct ieee80211_local *local = hw_to_local(hw);
437 -       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
438 -
439 -       if (unlikely(info->ack_frame_id)) {
440 -               struct sk_buff *ack_skb;
441 -               unsigned long flags;
442 -
443 -               spin_lock_irqsave(&local->ack_status_lock, flags);
444 -               ack_skb = idr_find(&local->ack_status_frames,
445 -                                  info->ack_frame_id);
446 -               if (ack_skb)
447 -                       idr_remove(&local->ack_status_frames,
448 -                                  info->ack_frame_id);
449 -               spin_unlock_irqrestore(&local->ack_status_lock, flags);
450 -
451 -               /* consumes ack_skb */
452 -               if (ack_skb)
453 -                       dev_kfree_skb_any(ack_skb);
454 -       }
455  
456 +       ieee80211_report_used_skb(local, skb, true);
457         dev_kfree_skb_any(skb);
458  }
459  EXPORT_SYMBOL(ieee80211_free_txskb);
460 +
461 +void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
462 +                             struct sk_buff_head *skbs)
463 +{
464 +       struct sk_buff *skb;
465 +
466 +       while ((skb = __skb_dequeue(skbs)))
467 +               ieee80211_free_txskb(hw, skb);
468 +}
469 --- a/drivers/net/wireless/p54/main.c
470 +++ b/drivers/net/wireless/p54/main.c
471 @@ -139,6 +139,7 @@ static int p54_beacon_format_ie_tim(stru
472  static int p54_beacon_update(struct p54_common *priv,
473                         struct ieee80211_vif *vif)
474  {
475 +       struct ieee80211_tx_control control = { };
476         struct sk_buff *beacon;
477         int ret;
478  
479 @@ -158,7 +159,7 @@ static int p54_beacon_update(struct p54_
480          * to cancel the old beacon template by hand, instead the firmware
481          * will release the previous one through the feedback mechanism.
482          */
483 -       p54_tx_80211(priv->hw, NULL, beacon);
484 +       p54_tx_80211(priv->hw, &control, beacon);
485         priv->tsf_high32 = 0;
486         priv->tsf_low32 = 0;
487  
488 --- a/net/wireless/reg.c
489 +++ b/net/wireless/reg.c
490 @@ -352,6 +352,9 @@ static void reg_regdb_search(struct work
491         struct reg_regdb_search_request *request;
492         const struct ieee80211_regdomain *curdom, *regdom;
493         int i, r;
494 +       bool set_reg = false;
495 +
496 +       mutex_lock(&cfg80211_mutex);
497  
498         mutex_lock(&reg_regdb_search_mutex);
499         while (!list_empty(&reg_regdb_search_list)) {
500 @@ -367,9 +370,7 @@ static void reg_regdb_search(struct work
501                                 r = reg_copy_regd(&regdom, curdom);
502                                 if (r)
503                                         break;
504 -                               mutex_lock(&cfg80211_mutex);
505 -                               set_regdom(regdom);
506 -                               mutex_unlock(&cfg80211_mutex);
507 +                               set_reg = true;
508                                 break;
509                         }
510                 }
511 @@ -377,6 +378,11 @@ static void reg_regdb_search(struct work
512                 kfree(request);
513         }
514         mutex_unlock(&reg_regdb_search_mutex);
515 +
516 +       if (set_reg)
517 +               set_regdom(regdom);
518 +
519 +       mutex_unlock(&cfg80211_mutex);
520  }
521  
522  static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
523 --- a/drivers/net/wireless/ath/ath9k/recv.c
524 +++ b/drivers/net/wireless/ath/ath9k/recv.c
525 @@ -254,8 +254,6 @@ rx_init_fail:
526  
527  static void ath_edma_start_recv(struct ath_softc *sc)
528  {
529 -       spin_lock_bh(&sc->rx.rxbuflock);
530 -
531         ath9k_hw_rxena(sc->sc_ah);
532  
533         ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP,
534 @@ -267,8 +265,6 @@ static void ath_edma_start_recv(struct a
535         ath_opmode_init(sc);
536  
537         ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
538 -
539 -       spin_unlock_bh(&sc->rx.rxbuflock);
540  }
541  
542  static void ath_edma_stop_recv(struct ath_softc *sc)
543 @@ -285,8 +281,6 @@ int ath_rx_init(struct ath_softc *sc, in
544         int error = 0;
545  
546         spin_lock_init(&sc->sc_pcu_lock);
547 -       spin_lock_init(&sc->rx.rxbuflock);
548 -       clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
549  
550         common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
551                              sc->sc_ah->caps.rx_status_len;
552 @@ -424,8 +418,8 @@ u32 ath_calcrxfilter(struct ath_softc *s
553                 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
554  
555         if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
556 -               /* The following may also be needed for other older chips */
557 -               if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
558 +               /* This is needed for older chips */
559 +               if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160)
560                         rfilt |= ATH9K_RX_FILTER_PROM;
561                 rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;
562         }
563 @@ -447,7 +441,6 @@ int ath_startrecv(struct ath_softc *sc)
564                 return 0;
565         }
566  
567 -       spin_lock_bh(&sc->rx.rxbuflock);
568         if (list_empty(&sc->rx.rxbuf))
569                 goto start_recv;
570  
571 @@ -468,26 +461,31 @@ start_recv:
572         ath_opmode_init(sc);
573         ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
574  
575 -       spin_unlock_bh(&sc->rx.rxbuflock);
576 -
577         return 0;
578  }
579  
580 +static void ath_flushrecv(struct ath_softc *sc)
581 +{
582 +       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
583 +               ath_rx_tasklet(sc, 1, true);
584 +       ath_rx_tasklet(sc, 1, false);
585 +}
586 +
587  bool ath_stoprecv(struct ath_softc *sc)
588  {
589         struct ath_hw *ah = sc->sc_ah;
590         bool stopped, reset = false;
591  
592 -       spin_lock_bh(&sc->rx.rxbuflock);
593         ath9k_hw_abortpcurecv(ah);
594         ath9k_hw_setrxfilter(ah, 0);
595         stopped = ath9k_hw_stopdmarecv(ah, &reset);
596  
597 +       ath_flushrecv(sc);
598 +
599         if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
600                 ath_edma_stop_recv(sc);
601         else
602                 sc->rx.rxlink = NULL;
603 -       spin_unlock_bh(&sc->rx.rxbuflock);
604  
605         if (!(ah->ah_flags & AH_UNPLUGGED) &&
606             unlikely(!stopped)) {
607 @@ -499,15 +497,6 @@ bool ath_stoprecv(struct ath_softc *sc)
608         return stopped && !reset;
609  }
610  
611 -void ath_flushrecv(struct ath_softc *sc)
612 -{
613 -       set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
614 -       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
615 -               ath_rx_tasklet(sc, 1, true);
616 -       ath_rx_tasklet(sc, 1, false);
617 -       clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
618 -}
619 -
620  static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
621  {
622         /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
623 @@ -744,6 +733,7 @@ static struct ath_buf *ath_get_next_rx_b
624                         return NULL;
625         }
626  
627 +       list_del(&bf->list);
628         if (!bf->bf_mpdu)
629                 return bf;
630  
631 @@ -1059,16 +1049,12 @@ int ath_rx_tasklet(struct ath_softc *sc,
632                 dma_type = DMA_FROM_DEVICE;
633  
634         qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
635 -       spin_lock_bh(&sc->rx.rxbuflock);
636  
637         tsf = ath9k_hw_gettsf64(ah);
638         tsf_lower = tsf & 0xffffffff;
639  
640         do {
641                 bool decrypt_error = false;
642 -               /* If handling rx interrupt and flush is in progress => exit */
643 -               if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
644 -                       break;
645  
646                 memset(&rs, 0, sizeof(rs));
647                 if (edma)
648 @@ -1108,15 +1094,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
649                 sc->rx.num_pkts++;
650                 ath_debug_stat_rx(sc, &rs);
651  
652 -               /*
653 -                * If we're asked to flush receive queue, directly
654 -                * chain it back at the queue without processing it.
655 -                */
656 -               if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
657 -                       RX_STAT_INC(rx_drop_rxflush);
658 -                       goto requeue_drop_frag;
659 -               }
660 -
661                 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
662  
663                 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
664 @@ -1251,19 +1228,18 @@ requeue_drop_frag:
665                         sc->rx.frag = NULL;
666                 }
667  requeue:
668 +               list_add_tail(&bf->list, &sc->rx.rxbuf);
669 +               if (flush)
670 +                       continue;
671 +
672                 if (edma) {
673 -                       list_add_tail(&bf->list, &sc->rx.rxbuf);
674                         ath_rx_edma_buf_link(sc, qtype);
675                 } else {
676 -                       list_move_tail(&bf->list, &sc->rx.rxbuf);
677                         ath_rx_buf_link(sc, bf);
678 -                       if (!flush)
679 -                               ath9k_hw_rxena(ah);
680 +                       ath9k_hw_rxena(ah);
681                 }
682         } while (1);
683  
684 -       spin_unlock_bh(&sc->rx.rxbuflock);
685 -
686         if (!(ah->imask & ATH9K_INT_RXEOL)) {
687                 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
688                 ath9k_hw_set_interrupts(ah);
689 --- a/net/mac80211/mlme.c
690 +++ b/net/mac80211/mlme.c
691 @@ -818,23 +818,71 @@ void ieee80211_sta_process_chanswitch(st
692  }
693  
694  static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
695 -                                       u16 capab_info, u8 *pwr_constr_elem,
696 -                                       u8 pwr_constr_elem_len)
697 +                                       struct ieee80211_channel *channel,
698 +                                       const u8 *country_ie, u8 country_ie_len,
699 +                                       const u8 *pwr_constr_elem)
700  {
701 -       struct ieee80211_conf *conf = &sdata->local->hw.conf;
702 +       struct ieee80211_country_ie_triplet *triplet;
703 +       int chan = ieee80211_frequency_to_channel(channel->center_freq);
704 +       int i, chan_pwr, chan_increment, new_ap_level;
705 +       bool have_chan_pwr = false;
706  
707 -       if (!(capab_info & WLAN_CAPABILITY_SPECTRUM_MGMT))
708 +       /* Invalid IE */
709 +       if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
710                 return;
711  
712 -       /* Power constraint IE length should be 1 octet */
713 -       if (pwr_constr_elem_len != 1)
714 -               return;
715 +       triplet = (void *)(country_ie + 3);
716 +       country_ie_len -= 3;
717  
718 -       if ((*pwr_constr_elem <= conf->channel->max_reg_power) &&
719 -           (*pwr_constr_elem != sdata->local->power_constr_level)) {
720 -               sdata->local->power_constr_level = *pwr_constr_elem;
721 -               ieee80211_hw_config(sdata->local, 0);
722 +       switch (channel->band) {
723 +       default:
724 +               WARN_ON_ONCE(1);
725 +               /* fall through */
726 +       case IEEE80211_BAND_2GHZ:
727 +       case IEEE80211_BAND_60GHZ:
728 +               chan_increment = 1;
729 +               break;
730 +       case IEEE80211_BAND_5GHZ:
731 +               chan_increment = 4;
732 +               break;
733         }
734 +
735 +       /* find channel */
736 +       while (country_ie_len >= 3) {
737 +               u8 first_channel = triplet->chans.first_channel;
738 +
739 +               if (first_channel >= IEEE80211_COUNTRY_EXTENSION_ID)
740 +                       goto next;
741 +
742 +               for (i = 0; i < triplet->chans.num_channels; i++) {
743 +                       if (first_channel + i * chan_increment == chan) {
744 +                               have_chan_pwr = true;
745 +                               chan_pwr = triplet->chans.max_power;
746 +                               break;
747 +                       }
748 +               }
749 +               if (have_chan_pwr)
750 +                       break;
751 +
752 + next:
753 +               triplet++;
754 +               country_ie_len -= 3;
755 +       }
756 +
757 +       if (!have_chan_pwr)
758 +               return;
759 +
760 +       new_ap_level = max_t(int, 0, chan_pwr - *pwr_constr_elem);
761 +
762 +       if (sdata->local->ap_power_level == new_ap_level)
763 +               return;
764 +
765 +       sdata_info(sdata,
766 +                  "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n",
767 +                  new_ap_level, chan_pwr, *pwr_constr_elem,
768 +                  sdata->u.mgd.bssid);
769 +       sdata->local->ap_power_level = new_ap_level;
770 +       ieee80211_hw_config(sdata->local, 0);
771  }
772  
773  void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif)
774 @@ -1390,7 +1438,7 @@ static void ieee80211_set_disassoc(struc
775         sta = sta_info_get(sdata, ifmgd->bssid);
776         if (sta) {
777                 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
778 -               ieee80211_sta_tear_down_BA_sessions(sta, tx);
779 +               ieee80211_sta_tear_down_BA_sessions(sta, false);
780         }
781         mutex_unlock(&local->sta_mtx);
782  
783 @@ -1438,7 +1486,7 @@ static void ieee80211_set_disassoc(struc
784         memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa));
785         memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask));
786  
787 -       local->power_constr_level = 0;
788 +       local->ap_power_level = 0;
789  
790         del_timer_sync(&local->dynamic_ps_timer);
791         cancel_work_sync(&local->dynamic_ps_enable_work);
792 @@ -2530,15 +2578,13 @@ static void ieee80211_rx_mgmt_beacon(str
793                                                   bssid, true);
794         }
795  
796 -       /* Note: country IE parsing is done for us by cfg80211 */
797 -       if (elems.country_elem) {
798 -               /* TODO: IBSS also needs this */
799 -               if (elems.pwr_constr_elem)
800 -                       ieee80211_handle_pwr_constr(sdata,
801 -                               le16_to_cpu(mgmt->u.probe_resp.capab_info),
802 -                               elems.pwr_constr_elem,
803 -                               elems.pwr_constr_elem_len);
804 -       }
805 +       if (elems.country_elem && elems.pwr_constr_elem &&
806 +           mgmt->u.probe_resp.capab_info &
807 +                               cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT))
808 +               ieee80211_handle_pwr_constr(sdata, local->oper_channel,
809 +                                           elems.country_elem,
810 +                                           elems.country_elem_len,
811 +                                           elems.pwr_constr_elem);
812  
813         ieee80211_bss_info_change_notify(sdata, changed);
814  }
815 @@ -3526,6 +3572,7 @@ int ieee80211_mgd_deauth(struct ieee8021
816  {
817         struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
818         u8 frame_buf[DEAUTH_DISASSOC_LEN];
819 +       bool tx = !req->local_state_change;
820  
821         mutex_lock(&ifmgd->mtx);
822  
823 @@ -3542,12 +3589,12 @@ int ieee80211_mgd_deauth(struct ieee8021
824         if (ifmgd->associated &&
825             ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
826                 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
827 -                                      req->reason_code, true, frame_buf);
828 +                                      req->reason_code, tx, frame_buf);
829         } else {
830                 drv_mgd_prepare_tx(sdata->local, sdata);
831                 ieee80211_send_deauth_disassoc(sdata, req->bssid,
832                                                IEEE80211_STYPE_DEAUTH,
833 -                                              req->reason_code, true,
834 +                                              req->reason_code, tx,
835                                                frame_buf);
836         }
837  
838 --- a/net/mac80211/sta_info.c
839 +++ b/net/mac80211/sta_info.c
840 @@ -585,7 +585,7 @@ static bool sta_info_cleanup_expire_buff
841                  */
842                 if (!skb)
843                         break;
844 -               dev_kfree_skb(skb);
845 +               ieee80211_free_txskb(&local->hw, skb);
846         }
847  
848         /*
849 @@ -614,7 +614,7 @@ static bool sta_info_cleanup_expire_buff
850                 local->total_ps_buffered--;
851                 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n",
852                        sta->sta.addr);
853 -               dev_kfree_skb(skb);
854 +               ieee80211_free_txskb(&local->hw, skb);
855         }
856  
857         /*
858 @@ -674,7 +674,7 @@ int __must_check __sta_info_destroy(stru
859          * will be sufficient.
860          */
861         set_sta_flag(sta, WLAN_STA_BLOCK_BA);
862 -       ieee80211_sta_tear_down_BA_sessions(sta, true);
863 +       ieee80211_sta_tear_down_BA_sessions(sta, false);
864  
865         ret = sta_info_hash_del(local, sta);
866         if (ret)
867 @@ -730,8 +730,8 @@ int __must_check __sta_info_destroy(stru
868  
869         for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
870                 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
871 -               __skb_queue_purge(&sta->ps_tx_buf[ac]);
872 -               __skb_queue_purge(&sta->tx_filtered[ac]);
873 +               ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]);
874 +               ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]);
875         }
876  
877  #ifdef CONFIG_MAC80211_MESH
878 @@ -765,7 +765,7 @@ int __must_check __sta_info_destroy(stru
879                 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
880                 if (!tid_tx)
881                         continue;
882 -               __skb_queue_purge(&tid_tx->pending);
883 +               ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
884                 kfree(tid_tx);
885         }
886  
887 --- a/drivers/net/wireless/ath/ath5k/phy.c
888 +++ b/drivers/net/wireless/ath/ath5k/phy.c
889 @@ -1977,11 +1977,13 @@ ath5k_hw_set_spur_mitigation_filter(stru
890                         spur_delta_phase = (spur_offset << 18) / 25;
891                         spur_freq_sigma_delta = (spur_delta_phase >> 10);
892                         symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 2;
893 +                       break;
894                 case AR5K_BWMODE_5MHZ:
895                         /* Both sample_freq and chip_freq are 10MHz (?) */
896                         spur_delta_phase = (spur_offset << 19) / 25;
897                         spur_freq_sigma_delta = (spur_delta_phase >> 10);
898                         symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 4;
899 +                       break;
900                 default:
901                         if (channel->band == IEEE80211_BAND_5GHZ) {
902                                 /* Both sample_freq and chip_freq are 40MHz */
903 --- a/net/mac80211/ieee80211_i.h
904 +++ b/net/mac80211/ieee80211_i.h
905 @@ -1062,7 +1062,7 @@ struct ieee80211_local {
906         bool disable_dynamic_ps;
907  
908         int user_power_level; /* in dBm */
909 -       int power_constr_level; /* in dBm */
910 +       int ap_power_level; /* in dBm */
911  
912         enum ieee80211_smps_mode smps_mode;
913  
914 @@ -1170,7 +1170,6 @@ struct ieee802_11_elems {
915         u8 prep_len;
916         u8 perr_len;
917         u8 country_elem_len;
918 -       u8 pwr_constr_elem_len;
919         u8 quiet_elem_len;
920         u8 num_of_quiet_elem;   /* can be more the one */
921         u8 timeout_int_len;
922 @@ -1318,6 +1317,8 @@ netdev_tx_t ieee80211_monitor_start_xmit
923                                          struct net_device *dev);
924  netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
925                                        struct net_device *dev);
926 +void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
927 +                             struct sk_buff_head *skbs);
928  
929  /* HT */
930  void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
931 --- a/net/mac80211/util.c
932 +++ b/net/mac80211/util.c
933 @@ -406,7 +406,7 @@ void ieee80211_add_pending_skb(struct ie
934         int queue = info->hw_queue;
935  
936         if (WARN_ON(!info->control.vif)) {
937 -               kfree_skb(skb);
938 +               ieee80211_free_txskb(&local->hw, skb);
939                 return;
940         }
941  
942 @@ -431,7 +431,7 @@ void ieee80211_add_pending_skbs_fn(struc
943                 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
944  
945                 if (WARN_ON(!info->control.vif)) {
946 -                       kfree_skb(skb);
947 +                       ieee80211_free_txskb(&local->hw, skb);
948                         continue;
949                 }
950  
951 @@ -792,8 +792,11 @@ u32 ieee802_11_parse_elems_crc(u8 *start
952                         elems->country_elem_len = elen;
953                         break;
954                 case WLAN_EID_PWR_CONSTRAINT:
955 +                       if (elen != 1) {
956 +                               elem_parse_failed = true;
957 +                               break;
958 +                       }
959                         elems->pwr_constr_elem = pos;
960 -                       elems->pwr_constr_elem_len = elen;
961                         break;
962                 case WLAN_EID_TIMEOUT_INTERVAL:
963                         elems->timeout_int = pos;
964 --- a/net/mac80211/main.c
965 +++ b/net/mac80211/main.c
966 @@ -154,13 +154,11 @@ int ieee80211_hw_config(struct ieee80211
967  
968         if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
969             test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
970 -           test_bit(SCAN_HW_SCANNING, &local->scanning))
971 +           test_bit(SCAN_HW_SCANNING, &local->scanning) ||
972 +           !local->ap_power_level)
973                 power = chan->max_power;
974         else
975 -               power = local->power_constr_level ?
976 -                       min(chan->max_power,
977 -                               (chan->max_reg_power  - local->power_constr_level)) :
978 -                       chan->max_power;
979 +               power = min(chan->max_power, local->ap_power_level);
980  
981         if (local->user_power_level >= 0)
982                 power = min(power, local->user_power_level);
983 --- a/include/net/cfg80211.h
984 +++ b/include/net/cfg80211.h
985 @@ -1218,6 +1218,7 @@ struct cfg80211_deauth_request {
986         const u8 *ie;
987         size_t ie_len;
988         u16 reason_code;
989 +       bool local_state_change;
990  };
991  
992  /**
993 --- a/net/wireless/mlme.c
994 +++ b/net/wireless/mlme.c
995 @@ -457,20 +457,14 @@ int __cfg80211_mlme_deauth(struct cfg802
996                 .reason_code = reason,
997                 .ie = ie,
998                 .ie_len = ie_len,
999 +               .local_state_change = local_state_change,
1000         };
1001  
1002         ASSERT_WDEV_LOCK(wdev);
1003  
1004 -       if (local_state_change) {
1005 -               if (wdev->current_bss &&
1006 -                   ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
1007 -                       cfg80211_unhold_bss(wdev->current_bss);
1008 -                       cfg80211_put_bss(&wdev->current_bss->pub);
1009 -                       wdev->current_bss = NULL;
1010 -               }
1011 -
1012 +       if (local_state_change && (!wdev->current_bss ||
1013 +           !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
1014                 return 0;
1015 -       }
1016  
1017         return rdev->ops->deauth(&rdev->wiphy, dev, &req);
1018  }
1019 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1020 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1021 @@ -386,7 +386,7 @@ static void ath_tx_complete_aggr(struct 
1022         u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first;
1023         u32 ba[WME_BA_BMP_SIZE >> 5];
1024         int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
1025 -       bool rc_update = true;
1026 +       bool rc_update = true, isba;
1027         struct ieee80211_tx_rate rates[4];
1028         struct ath_frame_info *fi;
1029         int nframes;
1030 @@ -430,13 +430,17 @@ static void ath_tx_complete_aggr(struct 
1031         tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
1032         tid = ATH_AN_2_TID(an, tidno);
1033         seq_first = tid->seq_start;
1034 +       isba = ts->ts_flags & ATH9K_TX_BA;
1035  
1036         /*
1037          * The hardware occasionally sends a tx status for the wrong TID.
1038          * In this case, the BA status cannot be considered valid and all
1039          * subframes need to be retransmitted
1040 +        *
1041 +        * Only BlockAcks have a TID and therefore normal Acks cannot be
1042 +        * checked
1043          */
1044 -       if (tidno != ts->tid)
1045 +       if (isba && tidno != ts->tid)
1046                 txok = false;
1047  
1048         isaggr = bf_isaggr(bf);
1049 --- a/net/mac80211/cfg.c
1050 +++ b/net/mac80211/cfg.c
1051 @@ -2563,6 +2563,9 @@ static void ieee80211_mgmt_frame_registe
1052                 else
1053                         local->probe_req_reg--;
1054  
1055 +               if (!local->open_count)
1056 +                       break;
1057 +
1058                 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
1059                 break;
1060         default:
1061 --- a/net/mac80211/tx.c
1062 +++ b/net/mac80211/tx.c
1063 @@ -354,7 +354,7 @@ static void purge_old_ps_buffers(struct 
1064                         total += skb_queue_len(&sta->ps_tx_buf[ac]);
1065                         if (skb) {
1066                                 purged++;
1067 -                               dev_kfree_skb(skb);
1068 +                               ieee80211_free_txskb(&local->hw, skb);
1069                                 break;
1070                         }
1071                 }
1072 @@ -466,7 +466,7 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1073                         ps_dbg(tx->sdata,
1074                                "STA %pM TX buffer for AC %d full - dropping oldest frame\n",
1075                                sta->sta.addr, ac);
1076 -                       dev_kfree_skb(old);
1077 +                       ieee80211_free_txskb(&local->hw, old);
1078                 } else
1079                         tx->local->total_ps_buffered++;
1080  
1081 @@ -1103,7 +1103,7 @@ static bool ieee80211_tx_prep_agg(struct
1082                 spin_unlock(&tx->sta->lock);
1083  
1084                 if (purge_skb)
1085 -                       dev_kfree_skb(purge_skb);
1086 +                       ieee80211_free_txskb(&tx->local->hw, purge_skb);
1087         }
1088  
1089         /* reset session timer */
1090 @@ -1214,7 +1214,7 @@ static bool ieee80211_tx_frags(struct ie
1091  #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1092                 if (WARN_ON_ONCE(q >= local->hw.queues)) {
1093                         __skb_unlink(skb, skbs);
1094 -                       dev_kfree_skb(skb);
1095 +                       ieee80211_free_txskb(&local->hw, skb);
1096                         continue;
1097                 }
1098  #endif
1099 @@ -1356,9 +1356,9 @@ static int invoke_tx_handlers(struct iee
1100         if (unlikely(res == TX_DROP)) {
1101                 I802_DEBUG_INC(tx->local->tx_handlers_drop);
1102                 if (tx->skb)
1103 -                       dev_kfree_skb(tx->skb);
1104 +                       ieee80211_free_txskb(&tx->local->hw, tx->skb);
1105                 else
1106 -                       __skb_queue_purge(&tx->skbs);
1107 +                       ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
1108                 return -1;
1109         } else if (unlikely(res == TX_QUEUED)) {
1110                 I802_DEBUG_INC(tx->local->tx_handlers_queued);
1111 @@ -1393,7 +1393,7 @@ static bool ieee80211_tx(struct ieee8021
1112         res_prepare = ieee80211_tx_prepare(sdata, &tx, skb);
1113  
1114         if (unlikely(res_prepare == TX_DROP)) {
1115 -               dev_kfree_skb(skb);
1116 +               ieee80211_free_txskb(&local->hw, skb);
1117                 goto out;
1118         } else if (unlikely(res_prepare == TX_QUEUED)) {
1119                 goto out;
1120 @@ -1465,7 +1465,7 @@ void ieee80211_xmit(struct ieee80211_sub
1121         headroom = max_t(int, 0, headroom);
1122  
1123         if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
1124 -               dev_kfree_skb(skb);
1125 +               ieee80211_free_txskb(&local->hw, skb);
1126                 rcu_read_unlock();
1127                 return;
1128         }
1129 @@ -2056,8 +2056,10 @@ netdev_tx_t ieee80211_subif_start_xmit(s
1130                 head_need += IEEE80211_ENCRYPT_HEADROOM;
1131                 head_need += local->tx_headroom;
1132                 head_need = max_t(int, 0, head_need);
1133 -               if (ieee80211_skb_resize(sdata, skb, head_need, true))
1134 -                       goto fail;
1135 +               if (ieee80211_skb_resize(sdata, skb, head_need, true)) {
1136 +                       ieee80211_free_txskb(&local->hw, skb);
1137 +                       return NETDEV_TX_OK;
1138 +               }
1139         }
1140  
1141         if (encaps_data) {
1142 @@ -2124,10 +2126,13 @@ netdev_tx_t ieee80211_subif_start_xmit(s
1143   */
1144  void ieee80211_clear_tx_pending(struct ieee80211_local *local)
1145  {
1146 +       struct sk_buff *skb;
1147         int i;
1148  
1149 -       for (i = 0; i < local->hw.queues; i++)
1150 -               skb_queue_purge(&local->pending[i]);
1151 +       for (i = 0; i < local->hw.queues; i++) {
1152 +               while ((skb = skb_dequeue(&local->pending[i])) != NULL)
1153 +                       ieee80211_free_txskb(&local->hw, skb);
1154 +       }
1155  }
1156  
1157  /*
1158 @@ -2190,7 +2195,7 @@ void ieee80211_tx_pending(unsigned long 
1159                         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1160  
1161                         if (WARN_ON(!info->control.vif)) {
1162 -                               kfree_skb(skb);
1163 +                               ieee80211_free_txskb(&local->hw, skb);
1164                                 continue;
1165                         }
1166  
1167 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
1168 +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
1169 @@ -65,7 +65,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct
1170         u16 qnum = skb_get_queue_mapping(skb);
1171  
1172         if (WARN_ON(qnum >= ah->ah_capabilities.cap_queues.q_tx_num)) {
1173 -               dev_kfree_skb_any(skb);
1174 +               ieee80211_free_txskb(hw, skb);
1175                 return;
1176         }
1177  
1178 --- a/drivers/net/wireless/ath/ath9k/hw.c
1179 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1180 @@ -2568,7 +2568,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
1181  
1182         if (AR_SREV_9300_20_OR_LATER(ah)) {
1183                 ah->enabled_cals |= TX_IQ_CAL;
1184 -               if (AR_SREV_9485_OR_LATER(ah))
1185 +               if (AR_SREV_9485_OR_LATER(ah) && !AR_SREV_9340(ah))
1186                         ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
1187         }
1188  
1189 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1190 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1191 @@ -313,7 +313,6 @@ struct ath_rx {
1192         u32 *rxlink;
1193         u32 num_pkts;
1194         unsigned int rxfilter;
1195 -       spinlock_t rxbuflock;
1196         struct list_head rxbuf;
1197         struct ath_descdma rxdma;
1198         struct ath_buf *rx_bufptr;
1199 @@ -324,7 +323,6 @@ struct ath_rx {
1200  
1201  int ath_startrecv(struct ath_softc *sc);
1202  bool ath_stoprecv(struct ath_softc *sc);
1203 -void ath_flushrecv(struct ath_softc *sc);
1204  u32 ath_calcrxfilter(struct ath_softc *sc);
1205  int ath_rx_init(struct ath_softc *sc, int nbufs);
1206  void ath_rx_cleanup(struct ath_softc *sc);
1207 @@ -627,7 +625,6 @@ void ath_ant_comb_update(struct ath_soft
1208  enum sc_op_flags {
1209         SC_OP_INVALID,
1210         SC_OP_BEACONS,
1211 -       SC_OP_RXFLUSH,
1212         SC_OP_ANI_RUN,
1213         SC_OP_PRIM_STA_VIF,
1214         SC_OP_HW_RESET,
1215 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1216 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1217 @@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_gene
1218                                  skb->len, DMA_TO_DEVICE);
1219                 dev_kfree_skb_any(skb);
1220                 bf->bf_buf_addr = 0;
1221 +               bf->bf_mpdu = NULL;
1222         }
1223  
1224         skb = ieee80211_beacon_get(hw, vif);
1225 @@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long 
1226                 return;
1227  
1228         bf = ath9k_beacon_generate(sc->hw, vif);
1229 -       WARN_ON(!bf);
1230  
1231         if (sc->beacon.bmisscnt != 0) {
1232                 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
1233 --- a/drivers/net/wireless/ath/ath9k/debug.c
1234 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1235 @@ -919,7 +919,6 @@ static ssize_t read_file_recv(struct fil
1236         RXS_ERR("RX-LENGTH-ERR", rx_len_err);
1237         RXS_ERR("RX-OOM-ERR", rx_oom_err);
1238         RXS_ERR("RX-RATE-ERR", rx_rate_err);
1239 -       RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
1240         RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
1241  
1242         PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
1243 --- a/drivers/net/wireless/ath/ath9k/debug.h
1244 +++ b/drivers/net/wireless/ath/ath9k/debug.h
1245 @@ -198,7 +198,6 @@ struct ath_tx_stats {
1246   * @rx_oom_err:  No. of frames dropped due to OOM issues.
1247   * @rx_rate_err:  No. of frames dropped due to rate errors.
1248   * @rx_too_many_frags_err:  Frames dropped due to too-many-frags received.
1249 - * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
1250   * @rx_beacons:  No. of beacons received.
1251   * @rx_frags:  No. of rx-fragements received.
1252   */
1253 @@ -217,7 +216,6 @@ struct ath_rx_stats {
1254         u32 rx_oom_err;
1255         u32 rx_rate_err;
1256         u32 rx_too_many_frags_err;
1257 -       u32 rx_drop_rxflush;
1258         u32 rx_beacons;
1259         u32 rx_frags;
1260  };
1261 --- a/drivers/net/wireless/ath/ath9k/main.c
1262 +++ b/drivers/net/wireless/ath/ath9k/main.c
1263 @@ -181,7 +181,7 @@ static void ath_restart_work(struct ath_
1264         ath_start_ani(sc);
1265  }
1266  
1267 -static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
1268 +static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
1269  {
1270         struct ath_hw *ah = sc->sc_ah;
1271         bool ret = true;
1272 @@ -201,14 +201,6 @@ static bool ath_prepare_reset(struct ath
1273         if (!ath_drain_all_txq(sc, retry_tx))
1274                 ret = false;
1275  
1276 -       if (!flush) {
1277 -               if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1278 -                       ath_rx_tasklet(sc, 1, true);
1279 -               ath_rx_tasklet(sc, 1, false);
1280 -       } else {
1281 -               ath_flushrecv(sc);
1282 -       }
1283 -
1284         return ret;
1285  }
1286  
1287 @@ -261,11 +253,11 @@ static int ath_reset_internal(struct ath
1288         struct ath_common *common = ath9k_hw_common(ah);
1289         struct ath9k_hw_cal_data *caldata = NULL;
1290         bool fastcc = true;
1291 -       bool flush = false;
1292         int r;
1293  
1294         __ath_cancel_work(sc);
1295  
1296 +       tasklet_disable(&sc->intr_tq);
1297         spin_lock_bh(&sc->sc_pcu_lock);
1298  
1299         if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
1300 @@ -275,11 +267,10 @@ static int ath_reset_internal(struct ath
1301  
1302         if (!hchan) {
1303                 fastcc = false;
1304 -               flush = true;
1305                 hchan = ah->curchan;
1306         }
1307  
1308 -       if (!ath_prepare_reset(sc, retry_tx, flush))
1309 +       if (!ath_prepare_reset(sc, retry_tx))
1310                 fastcc = false;
1311  
1312         ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
1313 @@ -297,6 +288,8 @@ static int ath_reset_internal(struct ath
1314  
1315  out:
1316         spin_unlock_bh(&sc->sc_pcu_lock);
1317 +       tasklet_enable(&sc->intr_tq);
1318 +
1319         return r;
1320  }
1321  
1322 @@ -821,7 +814,7 @@ static void ath9k_stop(struct ieee80211_
1323                 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
1324         }
1325  
1326 -       ath_prepare_reset(sc, false, true);
1327 +       ath_prepare_reset(sc, false);
1328  
1329         if (sc->rx.frag) {
1330                 dev_kfree_skb_any(sc->rx.frag);
1331 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
1332 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
1333 @@ -893,7 +893,7 @@ static bool ar9003_hw_init_cal(struct at
1334         struct ath9k_hw_cal_data *caldata = ah->caldata;
1335         bool txiqcal_done = false, txclcal_done = false;
1336         bool is_reusable = true, status = true;
1337 -       bool run_rtt_cal = false, run_agc_cal;
1338 +       bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false;
1339         bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT);
1340         u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL |
1341                                           AR_PHY_AGC_CONTROL_FLTR_CAL   |
1342 @@ -939,7 +939,8 @@ static bool ar9003_hw_init_cal(struct at
1343                 }
1344         }
1345  
1346 -       if (!(ah->enabled_cals & TX_IQ_CAL))
1347 +       if ((IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan)) ||
1348 +           !(ah->enabled_cals & TX_IQ_CAL))
1349                 goto skip_tx_iqcal;
1350  
1351         /* Do Tx IQ Calibration */
1352 @@ -959,21 +960,22 @@ static bool ar9003_hw_init_cal(struct at
1353                         REG_CLR_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
1354                                     AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
1355                 txiqcal_done = run_agc_cal = true;
1356 -               goto skip_tx_iqcal;
1357 -       } else if (caldata && !caldata->done_txiqcal_once)
1358 +       } else if (caldata && !caldata->done_txiqcal_once) {
1359                 run_agc_cal = true;
1360 +               sep_iq_cal = true;
1361 +       }
1362  
1363 +skip_tx_iqcal:
1364         if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
1365                 ar9003_mci_init_cal_req(ah, &is_reusable);
1366  
1367 -       if (!(IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))) {
1368 +       if (sep_iq_cal) {
1369                 txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
1370                 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
1371                 udelay(5);
1372                 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1373         }
1374  
1375 -skip_tx_iqcal:
1376         if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
1377                 /* Calibrate the AGC */
1378                 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
1379 --- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
1380 +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
1381 @@ -744,6 +744,186 @@ static const u32 ar9300Modes_high_ob_db_
1382         {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1383  };
1384  
1385 +static const u32 ar9300Modes_mixed_ob_db_tx_gain_table_2p2[][5] = {
1386 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1387 +       {0x0000a2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
1388 +       {0x0000a2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
1389 +       {0x0000a2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
1390 +       {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1391 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1392 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1393 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
1394 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
1395 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
1396 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
1397 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x11000400, 0x11000400},
1398 +       {0x0000a518, 0x21002220, 0x21002220, 0x15000402, 0x15000402},
1399 +       {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
1400 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1b000603, 0x1b000603},
1401 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x1f000a02, 0x1f000a02},
1402 +       {0x0000a528, 0x34022225, 0x34022225, 0x23000a04, 0x23000a04},
1403 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x26000a20, 0x26000a20},
1404 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2a000e20, 0x2a000e20},
1405 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x2e000e22, 0x2e000e22},
1406 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x31000e24, 0x31000e24},
1407 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x34001640, 0x34001640},
1408 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x38001660, 0x38001660},
1409 +       {0x0000a544, 0x52022470, 0x52022470, 0x3b001861, 0x3b001861},
1410 +       {0x0000a548, 0x55022490, 0x55022490, 0x3e001a81, 0x3e001a81},
1411 +       {0x0000a54c, 0x59022492, 0x59022492, 0x42001a83, 0x42001a83},
1412 +       {0x0000a550, 0x5d022692, 0x5d022692, 0x44001c84, 0x44001c84},
1413 +       {0x0000a554, 0x61022892, 0x61022892, 0x48001ce3, 0x48001ce3},
1414 +       {0x0000a558, 0x65024890, 0x65024890, 0x4c001ce5, 0x4c001ce5},
1415 +       {0x0000a55c, 0x69024892, 0x69024892, 0x50001ce9, 0x50001ce9},
1416 +       {0x0000a560, 0x6e024c92, 0x6e024c92, 0x54001ceb, 0x54001ceb},
1417 +       {0x0000a564, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1418 +       {0x0000a568, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1419 +       {0x0000a56c, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1420 +       {0x0000a570, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1421 +       {0x0000a574, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1422 +       {0x0000a578, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1423 +       {0x0000a57c, 0x74026e92, 0x74026e92, 0x56001eec, 0x56001eec},
1424 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
1425 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
1426 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
1427 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
1428 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
1429 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x11800400, 0x11800400},
1430 +       {0x0000a598, 0x21802220, 0x21802220, 0x15800402, 0x15800402},
1431 +       {0x0000a59c, 0x27802223, 0x27802223, 0x19800404, 0x19800404},
1432 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1b800603, 0x1b800603},
1433 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x1f800a02, 0x1f800a02},
1434 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x23800a04, 0x23800a04},
1435 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x26800a20, 0x26800a20},
1436 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2a800e20, 0x2a800e20},
1437 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x2e800e22, 0x2e800e22},
1438 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x31800e24, 0x31800e24},
1439 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x34801640, 0x34801640},
1440 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x38801660, 0x38801660},
1441 +       {0x0000a5c4, 0x52822470, 0x52822470, 0x3b801861, 0x3b801861},
1442 +       {0x0000a5c8, 0x55822490, 0x55822490, 0x3e801a81, 0x3e801a81},
1443 +       {0x0000a5cc, 0x59822492, 0x59822492, 0x42801a83, 0x42801a83},
1444 +       {0x0000a5d0, 0x5d822692, 0x5d822692, 0x44801c84, 0x44801c84},
1445 +       {0x0000a5d4, 0x61822892, 0x61822892, 0x48801ce3, 0x48801ce3},
1446 +       {0x0000a5d8, 0x65824890, 0x65824890, 0x4c801ce5, 0x4c801ce5},
1447 +       {0x0000a5dc, 0x69824892, 0x69824892, 0x50801ce9, 0x50801ce9},
1448 +       {0x0000a5e0, 0x6e824c92, 0x6e824c92, 0x54801ceb, 0x54801ceb},
1449 +       {0x0000a5e4, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1450 +       {0x0000a5e8, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1451 +       {0x0000a5ec, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1452 +       {0x0000a5f0, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1453 +       {0x0000a5f4, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1454 +       {0x0000a5f8, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1455 +       {0x0000a5fc, 0x74826e92, 0x74826e92, 0x56801eec, 0x56801eec},
1456 +       {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1457 +       {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1458 +       {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1459 +       {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1460 +       {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1461 +       {0x0000a614, 0x02004000, 0x02004000, 0x01404000, 0x01404000},
1462 +       {0x0000a618, 0x02004801, 0x02004801, 0x01404501, 0x01404501},
1463 +       {0x0000a61c, 0x02808a02, 0x02808a02, 0x02008501, 0x02008501},
1464 +       {0x0000a620, 0x0380ce03, 0x0380ce03, 0x0280ca03, 0x0280ca03},
1465 +       {0x0000a624, 0x04411104, 0x04411104, 0x03010c04, 0x03010c04},
1466 +       {0x0000a628, 0x04411104, 0x04411104, 0x04014c04, 0x04014c04},
1467 +       {0x0000a62c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
1468 +       {0x0000a630, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
1469 +       {0x0000a634, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
1470 +       {0x0000a638, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
1471 +       {0x0000a63c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
1472 +       {0x0000b2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
1473 +       {0x0000b2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
1474 +       {0x0000b2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
1475 +       {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1476 +       {0x0000c2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
1477 +       {0x0000c2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
1478 +       {0x0000c2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
1479 +       {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1480 +       {0x00016044, 0x012492d4, 0x012492d4, 0x056db2e4, 0x056db2e4},
1481 +       {0x00016048, 0x66480001, 0x66480001, 0x8e480001, 0x8e480001},
1482 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1483 +       {0x00016444, 0x012492d4, 0x012492d4, 0x056db2e4, 0x056db2e4},
1484 +       {0x00016448, 0x66480001, 0x66480001, 0x8e480001, 0x8e480001},
1485 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1486 +       {0x00016844, 0x012492d4, 0x012492d4, 0x056db2e4, 0x056db2e4},
1487 +       {0x00016848, 0x66480001, 0x66480001, 0x8e480001, 0x8e480001},
1488 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1489 +};
1490 +
1491 +static const u32 ar9300Modes_type5_tx_gain_table_2p2[][5] = {
1492 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1493 +       {0x0000a2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1494 +       {0x0000a2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1495 +       {0x0000a2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1496 +       {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1497 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1498 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1499 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
1500 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
1501 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
1502 +       {0x0000a510, 0x15000028, 0x15000028, 0x0f000202, 0x0f000202},
1503 +       {0x0000a514, 0x1b00002b, 0x1b00002b, 0x12000400, 0x12000400},
1504 +       {0x0000a518, 0x1f020028, 0x1f020028, 0x16000402, 0x16000402},
1505 +       {0x0000a51c, 0x2502002b, 0x2502002b, 0x19000404, 0x19000404},
1506 +       {0x0000a520, 0x2a04002a, 0x2a04002a, 0x1c000603, 0x1c000603},
1507 +       {0x0000a524, 0x2e06002a, 0x2e06002a, 0x21000a02, 0x21000a02},
1508 +       {0x0000a528, 0x3302202d, 0x3302202d, 0x25000a04, 0x25000a04},
1509 +       {0x0000a52c, 0x3804202c, 0x3804202c, 0x28000a20, 0x28000a20},
1510 +       {0x0000a530, 0x3c06202c, 0x3c06202c, 0x2c000e20, 0x2c000e20},
1511 +       {0x0000a534, 0x4108202d, 0x4108202d, 0x30000e22, 0x30000e22},
1512 +       {0x0000a538, 0x4506402d, 0x4506402d, 0x34000e24, 0x34000e24},
1513 +       {0x0000a53c, 0x4906222d, 0x4906222d, 0x38001640, 0x38001640},
1514 +       {0x0000a540, 0x4d062231, 0x4d062231, 0x3c001660, 0x3c001660},
1515 +       {0x0000a544, 0x50082231, 0x50082231, 0x3f001861, 0x3f001861},
1516 +       {0x0000a548, 0x5608422e, 0x5608422e, 0x43001a81, 0x43001a81},
1517 +       {0x0000a54c, 0x5e08442e, 0x5e08442e, 0x47001a83, 0x47001a83},
1518 +       {0x0000a550, 0x620a4431, 0x620a4431, 0x4a001c84, 0x4a001c84},
1519 +       {0x0000a554, 0x640a4432, 0x640a4432, 0x4e001ce3, 0x4e001ce3},
1520 +       {0x0000a558, 0x680a4434, 0x680a4434, 0x52001ce5, 0x52001ce5},
1521 +       {0x0000a55c, 0x6c0a6434, 0x6c0a6434, 0x56001ce9, 0x56001ce9},
1522 +       {0x0000a560, 0x6f0a6633, 0x6f0a6633, 0x5a001ceb, 0x5a001ceb},
1523 +       {0x0000a564, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1524 +       {0x0000a568, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1525 +       {0x0000a56c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1526 +       {0x0000a570, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1527 +       {0x0000a574, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1528 +       {0x0000a578, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1529 +       {0x0000a57c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1530 +       {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1531 +       {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1532 +       {0x0000a608, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1533 +       {0x0000a60c, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1534 +       {0x0000a610, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1535 +       {0x0000a614, 0x01804601, 0x01804601, 0x01404000, 0x01404000},
1536 +       {0x0000a618, 0x01804601, 0x01804601, 0x01404501, 0x01404501},
1537 +       {0x0000a61c, 0x01804601, 0x01804601, 0x02008501, 0x02008501},
1538 +       {0x0000a620, 0x03408d02, 0x03408d02, 0x0280ca03, 0x0280ca03},
1539 +       {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
1540 +       {0x0000a628, 0x03410d04, 0x03410d04, 0x04014c04, 0x04014c04},
1541 +       {0x0000a62c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1542 +       {0x0000a630, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1543 +       {0x0000a634, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1544 +       {0x0000a638, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1545 +       {0x0000a63c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1546 +       {0x0000b2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1547 +       {0x0000b2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1548 +       {0x0000b2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1549 +       {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1550 +       {0x0000c2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1551 +       {0x0000c2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1552 +       {0x0000c2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1553 +       {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1554 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1555 +       {0x00016048, 0x65240001, 0x65240001, 0x66480001, 0x66480001},
1556 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1557 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1558 +       {0x00016448, 0x65240001, 0x65240001, 0x66480001, 0x66480001},
1559 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1560 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1561 +       {0x00016848, 0x65240001, 0x65240001, 0x66480001, 0x66480001},
1562 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1563 +};
1564 +
1565  static const u32 ar9300Common_rx_gain_table_2p2[][2] = {
1566         /* Addr      allmodes  */
1567         {0x0000a000, 0x00010000},
1568 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
1569 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
1570 @@ -459,28 +459,59 @@ static void ar9003_tx_gain_table_mode4(s
1571         else if (AR_SREV_9580(ah))
1572                 INIT_INI_ARRAY(&ah->iniModesTxGain,
1573                         ar9580_1p0_mixed_ob_db_tx_gain_table);
1574 +       else
1575 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1576 +                       ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
1577 +}
1578 +
1579 +static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
1580 +{
1581 +       if (AR_SREV_9485_11(ah))
1582 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1583 +                       ar9485Modes_green_ob_db_tx_gain_1_1);
1584 +       else if (AR_SREV_9340(ah))
1585 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1586 +                       ar9340Modes_ub124_tx_gain_table_1p0);
1587 +       else if (AR_SREV_9580(ah))
1588 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1589 +                       ar9580_1p0_type5_tx_gain_table);
1590 +       else if (AR_SREV_9300_22(ah))
1591 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1592 +                       ar9300Modes_type5_tx_gain_table_2p2);
1593 +}
1594 +
1595 +static void ar9003_tx_gain_table_mode6(struct ath_hw *ah)
1596 +{
1597 +       if (AR_SREV_9340(ah))
1598 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1599 +                       ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
1600 +       else if (AR_SREV_9485_11(ah))
1601 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1602 +                       ar9485Modes_green_spur_ob_db_tx_gain_1_1);
1603 +       else if (AR_SREV_9580(ah))
1604 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
1605 +                       ar9580_1p0_type6_tx_gain_table);
1606  }
1607  
1608 +typedef void (*ath_txgain_tab)(struct ath_hw *ah);
1609 +
1610  static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
1611  {
1612 -       switch (ar9003_hw_get_tx_gain_idx(ah)) {
1613 -       case 0:
1614 -       default:
1615 -               ar9003_tx_gain_table_mode0(ah);
1616 -               break;
1617 -       case 1:
1618 -               ar9003_tx_gain_table_mode1(ah);
1619 -               break;
1620 -       case 2:
1621 -               ar9003_tx_gain_table_mode2(ah);
1622 -               break;
1623 -       case 3:
1624 -               ar9003_tx_gain_table_mode3(ah);
1625 -               break;
1626 -       case 4:
1627 -               ar9003_tx_gain_table_mode4(ah);
1628 -               break;
1629 -       }
1630 +       static const ath_txgain_tab modes[] = {
1631 +               ar9003_tx_gain_table_mode0,
1632 +               ar9003_tx_gain_table_mode1,
1633 +               ar9003_tx_gain_table_mode2,
1634 +               ar9003_tx_gain_table_mode3,
1635 +               ar9003_tx_gain_table_mode4,
1636 +               ar9003_tx_gain_table_mode5,
1637 +               ar9003_tx_gain_table_mode6,
1638 +       };
1639 +       int idx = ar9003_hw_get_tx_gain_idx(ah);
1640 +
1641 +       if (idx >= ARRAY_SIZE(modes))
1642 +               idx = 0;
1643 +
1644 +       modes[idx](ah);
1645  }
1646  
1647  static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
1648 --- a/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
1649 +++ b/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
1650 @@ -1170,6 +1170,106 @@ static const u32 ar9340Modes_mixed_ob_db
1651         {0x00016448, 0x24925666, 0x24925666, 0x8e481266, 0x8e481266},
1652  };
1653  
1654 +static const u32 ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0[][5] = {
1655 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1656 +       {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03eaac5a, 0x03eaac5a},
1657 +       {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03f330ac, 0x03f330ac},
1658 +       {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03fc3f00, 0x03fc3f00},
1659 +       {0x0000a2e8, 0x00000000, 0x00000000, 0x03ffc000, 0x03ffc000},
1660 +       {0x0000a394, 0x00000444, 0x00000444, 0x00000404, 0x00000404},
1661 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1662 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1663 +       {0x0000a504, 0x06000003, 0x06000003, 0x02000001, 0x02000001},
1664 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x05000003, 0x05000003},
1665 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0a000005, 0x0a000005},
1666 +       {0x0000a510, 0x16000220, 0x16000220, 0x0e000201, 0x0e000201},
1667 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x11000203, 0x11000203},
1668 +       {0x0000a518, 0x21002220, 0x21002220, 0x14000401, 0x14000401},
1669 +       {0x0000a51c, 0x27002223, 0x27002223, 0x18000403, 0x18000403},
1670 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1b000602, 0x1b000602},
1671 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x1f000802, 0x1f000802},
1672 +       {0x0000a528, 0x34022225, 0x34022225, 0x21000620, 0x21000620},
1673 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x25000820, 0x25000820},
1674 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x29000822, 0x29000822},
1675 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x2d000824, 0x2d000824},
1676 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x30000828, 0x30000828},
1677 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x3400082a, 0x3400082a},
1678 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x38000849, 0x38000849},
1679 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3b000a2c, 0x3b000a2c},
1680 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x3e000e2b, 0x3e000e2b},
1681 +       {0x0000a54c, 0x5c02486b, 0x5c02486b, 0x42000e2d, 0x42000e2d},
1682 +       {0x0000a550, 0x61024a6c, 0x61024a6c, 0x4500124a, 0x4500124a},
1683 +       {0x0000a554, 0x66026a6c, 0x66026a6c, 0x4900124c, 0x4900124c},
1684 +       {0x0000a558, 0x6b026e6c, 0x6b026e6c, 0x4c00126c, 0x4c00126c},
1685 +       {0x0000a55c, 0x7002708c, 0x7002708c, 0x4f00128c, 0x4f00128c},
1686 +       {0x0000a560, 0x7302b08a, 0x7302b08a, 0x52001290, 0x52001290},
1687 +       {0x0000a564, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1688 +       {0x0000a568, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1689 +       {0x0000a56c, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1690 +       {0x0000a570, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1691 +       {0x0000a574, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1692 +       {0x0000a578, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1693 +       {0x0000a57c, 0x7702b08c, 0x7702b08c, 0x56001292, 0x56001292},
1694 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
1695 +       {0x0000a584, 0x06800003, 0x06800003, 0x02800001, 0x02800001},
1696 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x05800003, 0x05800003},
1697 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0a800005, 0x0a800005},
1698 +       {0x0000a590, 0x16800220, 0x16800220, 0x0e800201, 0x0e800201},
1699 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x11800203, 0x11800203},
1700 +       {0x0000a598, 0x21820220, 0x21820220, 0x14800401, 0x14800401},
1701 +       {0x0000a59c, 0x27820223, 0x27820223, 0x18800403, 0x18800403},
1702 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1b800602, 0x1b800602},
1703 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x1f800802, 0x1f800802},
1704 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x21800620, 0x21800620},
1705 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x25800820, 0x25800820},
1706 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x29800822, 0x29800822},
1707 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x2d800824, 0x2d800824},
1708 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x30800828, 0x30800828},
1709 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x3480082a, 0x3480082a},
1710 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x38800849, 0x38800849},
1711 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3b800a2c, 0x3b800a2c},
1712 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x3e800e2b, 0x3e800e2b},
1713 +       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x42800e2d, 0x42800e2d},
1714 +       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x4580124a, 0x4580124a},
1715 +       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x4980124c, 0x4980124c},
1716 +       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x4c80126c, 0x4c80126c},
1717 +       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x4f80128c, 0x4f80128c},
1718 +       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x52801290, 0x52801290},
1719 +       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1720 +       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1721 +       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1722 +       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1723 +       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1724 +       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1725 +       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x56801292, 0x56801292},
1726 +       {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1727 +       {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1728 +       {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1729 +       {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1730 +       {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1731 +       {0x0000a614, 0x01404000, 0x01404000, 0x01404501, 0x01404501},
1732 +       {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501},
1733 +       {0x0000a61c, 0x02008802, 0x02008802, 0x01404501, 0x01404501},
1734 +       {0x0000a620, 0x0300cc03, 0x0300cc03, 0x03c0cf02, 0x03c0cf02},
1735 +       {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03c0cf03, 0x03c0cf03},
1736 +       {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04011004, 0x04011004},
1737 +       {0x0000a62c, 0x03810c03, 0x03810c03, 0x05419405, 0x05419405},
1738 +       {0x0000a630, 0x03810e04, 0x03810e04, 0x05419506, 0x05419506},
1739 +       {0x0000a634, 0x03810e04, 0x03810e04, 0x05419506, 0x05419506},
1740 +       {0x0000a638, 0x03810e04, 0x03810e04, 0x05419506, 0x05419506},
1741 +       {0x0000a63c, 0x03810e04, 0x03810e04, 0x05419506, 0x05419506},
1742 +       {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x03eaac5a, 0x03eaac5a},
1743 +       {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03f330ac, 0x03f330ac},
1744 +       {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03fc3f00, 0x03fc3f00},
1745 +       {0x0000b2e8, 0x00000000, 0x00000000, 0x03ffc000, 0x03ffc000},
1746 +       {0x00016044, 0x022492db, 0x022492db, 0x022492db, 0x022492db},
1747 +       {0x00016048, 0x24925666, 0x24925666, 0x24925266, 0x24925266},
1748 +       {0x00016280, 0x01000015, 0x01000015, 0x01001015, 0x01001015},
1749 +       {0x00016288, 0xf0318000, 0xf0318000, 0xf0318000, 0xf0318000},
1750 +       {0x00016444, 0x022492db, 0x022492db, 0x022492db, 0x022492db},
1751 +       {0x00016448, 0x24925666, 0x24925666, 0x24925266, 0x24925266},
1752 +};
1753 +
1754  static const u32 ar9340_1p0_mac_core[][2] = {
1755         /* Addr      allmodes  */
1756         {0x00000008, 0x00000000},
1757 --- a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
1758 +++ b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
1759 @@ -234,12 +234,158 @@ static const u32 ar9485Modes_high_power_
1760         {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
1761  };
1762  
1763 +static const u32 ar9485Modes_green_ob_db_tx_gain_1_1[][5] = {
1764 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1765 +       {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003},
1766 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8},
1767 +       {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000},
1768 +       {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006},
1769 +       {0x0000a504, 0x05062002, 0x05062002, 0x03000201, 0x03000201},
1770 +       {0x0000a508, 0x0c002e00, 0x0c002e00, 0x06000203, 0x06000203},
1771 +       {0x0000a50c, 0x11062202, 0x11062202, 0x0a000401, 0x0a000401},
1772 +       {0x0000a510, 0x17022e00, 0x17022e00, 0x0e000403, 0x0e000403},
1773 +       {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x12000405, 0x12000405},
1774 +       {0x0000a518, 0x25020ec0, 0x25020ec0, 0x15000604, 0x15000604},
1775 +       {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x18000605, 0x18000605},
1776 +       {0x0000a520, 0x2f001f04, 0x2f001f04, 0x1c000a04, 0x1c000a04},
1777 +       {0x0000a524, 0x35001fc4, 0x35001fc4, 0x21000a06, 0x21000a06},
1778 +       {0x0000a528, 0x3c022f04, 0x3c022f04, 0x29000a24, 0x29000a24},
1779 +       {0x0000a52c, 0x41023e85, 0x41023e85, 0x2f000e21, 0x2f000e21},
1780 +       {0x0000a530, 0x48023ec6, 0x48023ec6, 0x31000e20, 0x31000e20},
1781 +       {0x0000a534, 0x4d023f01, 0x4d023f01, 0x33000e20, 0x33000e20},
1782 +       {0x0000a538, 0x53023f4b, 0x53023f4b, 0x43000e62, 0x43000e62},
1783 +       {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x45000e63, 0x45000e63},
1784 +       {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x49000e65, 0x49000e65},
1785 +       {0x0000a544, 0x6502feca, 0x6502feca, 0x4b000e66, 0x4b000e66},
1786 +       {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x4d001645, 0x4d001645},
1787 +       {0x0000a54c, 0x7203feca, 0x7203feca, 0x51001865, 0x51001865},
1788 +       {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x55001a86, 0x55001a86},
1789 +       {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x57001ce9, 0x57001ce9},
1790 +       {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5a001ceb, 0x5a001ceb},
1791 +       {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x5e001eeb, 0x5e001eeb},
1792 +       {0x0000a560, 0x900fff0b, 0x900fff0b, 0x5e001eeb, 0x5e001eeb},
1793 +       {0x0000a564, 0x960fffcb, 0x960fffcb, 0x5e001eeb, 0x5e001eeb},
1794 +       {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1795 +       {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1796 +       {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1797 +       {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1798 +       {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1799 +       {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
1800 +       {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1801 +       {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1802 +       {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1803 +       {0x0000b50c, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1804 +       {0x0000b510, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1805 +       {0x0000b514, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1806 +       {0x0000b518, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1807 +       {0x0000b51c, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1808 +       {0x0000b520, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1809 +       {0x0000b524, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1810 +       {0x0000b528, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1811 +       {0x0000b52c, 0x0000002a, 0x0000002a, 0x0000002a, 0x0000002a},
1812 +       {0x0000b530, 0x0000003a, 0x0000003a, 0x0000003a, 0x0000003a},
1813 +       {0x0000b534, 0x0000004a, 0x0000004a, 0x0000004a, 0x0000004a},
1814 +       {0x0000b538, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1815 +       {0x0000b53c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1816 +       {0x0000b540, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1817 +       {0x0000b544, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1818 +       {0x0000b548, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1819 +       {0x0000b54c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1820 +       {0x0000b550, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1821 +       {0x0000b554, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1822 +       {0x0000b558, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1823 +       {0x0000b55c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1824 +       {0x0000b560, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1825 +       {0x0000b564, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1826 +       {0x0000b568, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1827 +       {0x0000b56c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1828 +       {0x0000b570, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1829 +       {0x0000b574, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1830 +       {0x0000b578, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1831 +       {0x0000b57c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1832 +       {0x00016044, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db},
1833 +       {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
1834 +};
1835 +
1836  #define ar9485Modes_high_ob_db_tx_gain_1_1 ar9485Modes_high_power_tx_gain_1_1
1837  
1838  #define ar9485Modes_low_ob_db_tx_gain_1_1 ar9485Modes_high_ob_db_tx_gain_1_1
1839  
1840  #define ar9485_modes_lowest_ob_db_tx_gain_1_1 ar9485Modes_low_ob_db_tx_gain_1_1
1841  
1842 +static const u32 ar9485Modes_green_spur_ob_db_tx_gain_1_1[][5] = {
1843 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1844 +       {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003},
1845 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8},
1846 +       {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000},
1847 +       {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006},
1848 +       {0x0000a504, 0x05062002, 0x05062002, 0x03000201, 0x03000201},
1849 +       {0x0000a508, 0x0c002e00, 0x0c002e00, 0x07000203, 0x07000203},
1850 +       {0x0000a50c, 0x11062202, 0x11062202, 0x0a000401, 0x0a000401},
1851 +       {0x0000a510, 0x17022e00, 0x17022e00, 0x0e000403, 0x0e000403},
1852 +       {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x12000405, 0x12000405},
1853 +       {0x0000a518, 0x25020ec0, 0x25020ec0, 0x14000406, 0x14000406},
1854 +       {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1800040a, 0x1800040a},
1855 +       {0x0000a520, 0x2f001f04, 0x2f001f04, 0x1c000460, 0x1c000460},
1856 +       {0x0000a524, 0x35001fc4, 0x35001fc4, 0x22000463, 0x22000463},
1857 +       {0x0000a528, 0x3c022f04, 0x3c022f04, 0x26000465, 0x26000465},
1858 +       {0x0000a52c, 0x41023e85, 0x41023e85, 0x2e0006e0, 0x2e0006e0},
1859 +       {0x0000a530, 0x48023ec6, 0x48023ec6, 0x310006e0, 0x310006e0},
1860 +       {0x0000a534, 0x4d023f01, 0x4d023f01, 0x330006e0, 0x330006e0},
1861 +       {0x0000a538, 0x53023f4b, 0x53023f4b, 0x3e0008e3, 0x3e0008e3},
1862 +       {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x410008e5, 0x410008e5},
1863 +       {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x430008e6, 0x430008e6},
1864 +       {0x0000a544, 0x6502feca, 0x6502feca, 0x4a0008ec, 0x4a0008ec},
1865 +       {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x4e0008f1, 0x4e0008f1},
1866 +       {0x0000a54c, 0x7203feca, 0x7203feca, 0x520008f3, 0x520008f3},
1867 +       {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x54000eed, 0x54000eed},
1868 +       {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x58000ef1, 0x58000ef1},
1869 +       {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5c000ef3, 0x5c000ef3},
1870 +       {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x60000ef5, 0x60000ef5},
1871 +       {0x0000a560, 0x900fff0b, 0x900fff0b, 0x62000ef6, 0x62000ef6},
1872 +       {0x0000a564, 0x960fffcb, 0x960fffcb, 0x62000ef6, 0x62000ef6},
1873 +       {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1874 +       {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1875 +       {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1876 +       {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1877 +       {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1878 +       {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6},
1879 +       {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1880 +       {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1881 +       {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1882 +       {0x0000b50c, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1883 +       {0x0000b510, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1884 +       {0x0000b514, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1885 +       {0x0000b518, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1886 +       {0x0000b51c, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1887 +       {0x0000b520, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1888 +       {0x0000b524, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1889 +       {0x0000b528, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
1890 +       {0x0000b52c, 0x0000002a, 0x0000002a, 0x0000002a, 0x0000002a},
1891 +       {0x0000b530, 0x0000003a, 0x0000003a, 0x0000003a, 0x0000003a},
1892 +       {0x0000b534, 0x0000004a, 0x0000004a, 0x0000004a, 0x0000004a},
1893 +       {0x0000b538, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1894 +       {0x0000b53c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1895 +       {0x0000b540, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1896 +       {0x0000b544, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1897 +       {0x0000b548, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1898 +       {0x0000b54c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1899 +       {0x0000b550, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1900 +       {0x0000b554, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1901 +       {0x0000b558, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1902 +       {0x0000b55c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1903 +       {0x0000b560, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1904 +       {0x0000b564, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1905 +       {0x0000b568, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1906 +       {0x0000b56c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1907 +       {0x0000b570, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1908 +       {0x0000b574, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1909 +       {0x0000b578, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1910 +       {0x0000b57c, 0x0000005b, 0x0000005b, 0x0000005b, 0x0000005b},
1911 +       {0x00016044, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db},
1912 +       {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
1913 +};
1914 +
1915  static const u32 ar9485_1_1[][2] = {
1916         /* Addr      allmodes  */
1917         {0x0000a580, 0x00000000},
1918 --- a/drivers/net/wireless/ath/ath9k/ar9580_1p0_initvals.h
1919 +++ b/drivers/net/wireless/ath/ath9k/ar9580_1p0_initvals.h
1920 @@ -685,6 +685,82 @@ static const u32 ar9580_1p0_mixed_ob_db_
1921  
1922  #define ar9580_1p0_high_ob_db_tx_gain_table ar9300Modes_high_ob_db_tx_gain_table_2p2
1923  
1924 +#define ar9580_1p0_type5_tx_gain_table ar9300Modes_type5_tx_gain_table_2p2
1925 +
1926 +static const u32 ar9580_1p0_type6_tx_gain_table[][5] = {
1927 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1928 +       {0x0000a2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1929 +       {0x0000a2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1930 +       {0x0000a2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1931 +       {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1932 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1933 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1934 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
1935 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
1936 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
1937 +       {0x0000a510, 0x15000028, 0x15000028, 0x0f000202, 0x0f000202},
1938 +       {0x0000a514, 0x1b00002b, 0x1b00002b, 0x12000400, 0x12000400},
1939 +       {0x0000a518, 0x1f020028, 0x1f020028, 0x16000402, 0x16000402},
1940 +       {0x0000a51c, 0x2502002b, 0x2502002b, 0x19000404, 0x19000404},
1941 +       {0x0000a520, 0x2a04002a, 0x2a04002a, 0x1c000603, 0x1c000603},
1942 +       {0x0000a524, 0x2e06002a, 0x2e06002a, 0x21000a02, 0x21000a02},
1943 +       {0x0000a528, 0x3302202d, 0x3302202d, 0x25000a04, 0x25000a04},
1944 +       {0x0000a52c, 0x3804202c, 0x3804202c, 0x28000a20, 0x28000a20},
1945 +       {0x0000a530, 0x3c06202c, 0x3c06202c, 0x2c000e20, 0x2c000e20},
1946 +       {0x0000a534, 0x4108202d, 0x4108202d, 0x30000e22, 0x30000e22},
1947 +       {0x0000a538, 0x4506402d, 0x4506402d, 0x34000e24, 0x34000e24},
1948 +       {0x0000a53c, 0x4906222d, 0x4906222d, 0x38001640, 0x38001640},
1949 +       {0x0000a540, 0x4d062231, 0x4d062231, 0x3c001660, 0x3c001660},
1950 +       {0x0000a544, 0x50082231, 0x50082231, 0x3f001861, 0x3f001861},
1951 +       {0x0000a548, 0x5608422e, 0x5608422e, 0x43001a81, 0x43001a81},
1952 +       {0x0000a54c, 0x5e08442e, 0x5e08442e, 0x47001a83, 0x47001a83},
1953 +       {0x0000a550, 0x620a4431, 0x620a4431, 0x4a001c84, 0x4a001c84},
1954 +       {0x0000a554, 0x640a4432, 0x640a4432, 0x4e001ce3, 0x4e001ce3},
1955 +       {0x0000a558, 0x680a4434, 0x680a4434, 0x52001ce5, 0x52001ce5},
1956 +       {0x0000a55c, 0x6c0a6434, 0x6c0a6434, 0x56001ce9, 0x56001ce9},
1957 +       {0x0000a560, 0x6f0a6633, 0x6f0a6633, 0x5a001ceb, 0x5a001ceb},
1958 +       {0x0000a564, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1959 +       {0x0000a568, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1960 +       {0x0000a56c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1961 +       {0x0000a570, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1962 +       {0x0000a574, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1963 +       {0x0000a578, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1964 +       {0x0000a57c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec},
1965 +       {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1966 +       {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1967 +       {0x0000a608, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1968 +       {0x0000a60c, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1969 +       {0x0000a610, 0x01804601, 0x01804601, 0x00000000, 0x00000000},
1970 +       {0x0000a614, 0x01804601, 0x01804601, 0x01404000, 0x01404000},
1971 +       {0x0000a618, 0x01804601, 0x01804601, 0x01404501, 0x01404501},
1972 +       {0x0000a61c, 0x01804601, 0x01804601, 0x02008501, 0x02008501},
1973 +       {0x0000a620, 0x03408d02, 0x03408d02, 0x0280ca03, 0x0280ca03},
1974 +       {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
1975 +       {0x0000a628, 0x03410d04, 0x03410d04, 0x04014c04, 0x04014c04},
1976 +       {0x0000a62c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1977 +       {0x0000a630, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1978 +       {0x0000a634, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1979 +       {0x0000a638, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1980 +       {0x0000a63c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005},
1981 +       {0x0000b2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1982 +       {0x0000b2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1983 +       {0x0000b2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1984 +       {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1985 +       {0x0000c2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352},
1986 +       {0x0000c2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584},
1987 +       {0x0000c2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800},
1988 +       {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
1989 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1990 +       {0x00016048, 0x61200001, 0x61200001, 0x66480001, 0x66480001},
1991 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1992 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1993 +       {0x00016448, 0x61200001, 0x61200001, 0x66480001, 0x66480001},
1994 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1995 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1996 +       {0x00016848, 0x61200001, 0x61200001, 0x66480001, 0x66480001},
1997 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1998 +};
1999 +
2000  static const u32 ar9580_1p0_soc_preamble[][2] = {
2001         /* Addr      allmodes  */
2002         {0x000040a4, 0x00a0c1c9},
2003 --- a/drivers/net/wireless/ath/ath9k/reg.h
2004 +++ b/drivers/net/wireless/ath/ath9k/reg.h
2005 @@ -789,6 +789,7 @@
2006  #define AR_SREV_REVISION_9271_11       1
2007  #define AR_SREV_VERSION_9300           0x1c0
2008  #define AR_SREV_REVISION_9300_20       2 /* 2.0 and 2.1 */
2009 +#define AR_SREV_REVISION_9300_22       3
2010  #define AR_SREV_VERSION_9330           0x200
2011  #define AR_SREV_REVISION_9330_10       0
2012  #define AR_SREV_REVISION_9330_11       1
2013 @@ -867,6 +868,9 @@
2014         (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9300))
2015  #define AR_SREV_9300_20_OR_LATER(_ah) \
2016         ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9300)
2017 +#define AR_SREV_9300_22(_ah) \
2018 +       (AR_SREV_9300(ah) && \
2019 +        ((_ah)->hw_version.macRev == AR_SREV_REVISION_9300_22))
2020  
2021  #define AR_SREV_9330(_ah) \
2022         (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9330))
2023 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
2024 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
2025 @@ -1067,15 +1067,19 @@ static bool ath9k_rx_prepare(struct ath9
2026  
2027         last_rssi = priv->rx.last_rssi;
2028  
2029 -       if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
2030 -               rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
2031 -                                                    ATH_RSSI_EP_MULTIPLIER);
2032 +       if (ieee80211_is_beacon(hdr->frame_control) &&
2033 +           !is_zero_ether_addr(common->curbssid) &&
2034 +           ether_addr_equal(hdr->addr3, common->curbssid)) {
2035 +               s8 rssi = rxbuf->rxstatus.rs_rssi;
2036  
2037 -       if (rxbuf->rxstatus.rs_rssi < 0)
2038 -               rxbuf->rxstatus.rs_rssi = 0;
2039 +               if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
2040 +                       rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
2041  
2042 -       if (ieee80211_is_beacon(fc))
2043 -               priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
2044 +               if (rssi < 0)
2045 +                       rssi = 0;
2046 +
2047 +               priv->ah->stats.avgbrssi = rssi;
2048 +       }
2049  
2050         rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
2051         rx_status->band = hw->conf.channel->band;