mac80211: more patch reorganization, merge an upstream performance optimization patch
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
2 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
3 @@ -326,7 +326,6 @@ static bool ar9003_hw_get_isr(struct ath
4  static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
5                                  struct ath_tx_status *ts)
6  {
7 -       struct ar9003_txc *txc = (struct ar9003_txc *) ds;
8         struct ar9003_txs *ads;
9         u32 status;
10  
11 @@ -336,11 +335,7 @@ static int ar9003_hw_proc_txdesc(struct 
12         if ((status & AR_TxDone) == 0)
13                 return -EINPROGRESS;
14  
15 -       ts->qid = MS(ads->ds_info, AR_TxQcuNum);
16 -       if (!txc || (MS(txc->info, AR_TxQcuNum) == ts->qid))
17 -               ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
18 -       else
19 -               return -ENOENT;
20 +       ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
21  
22         if ((MS(ads->ds_info, AR_DescId) != ATHEROS_VENDOR_ID) ||
23             (MS(ads->ds_info, AR_TxRxDesc) != 1)) {
24 @@ -354,6 +349,7 @@ static int ar9003_hw_proc_txdesc(struct 
25         ts->ts_seqnum = MS(status, AR_SeqNum);
26         ts->tid = MS(status, AR_TxTid);
27  
28 +       ts->qid = MS(ads->ds_info, AR_TxQcuNum);
29         ts->desc_id = MS(ads->status1, AR_TxDescId);
30         ts->ts_tstamp = ads->status4;
31         ts->ts_status = 0;
32 @@ -440,20 +436,14 @@ int ath9k_hw_process_rxdesc_edma(struct 
33         struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr;
34         unsigned int phyerr;
35  
36 -       /* TODO: byte swap on big endian for ar9300_10 */
37 -
38 -       if (!rxs) {
39 -               if ((rxsp->status11 & AR_RxDone) == 0)
40 -                       return -EINPROGRESS;
41 -
42 -               if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
43 -                       return -EINVAL;
44 +       if ((rxsp->status11 & AR_RxDone) == 0)
45 +               return -EINPROGRESS;
46  
47 -               if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
48 -                       return -EINPROGRESS;
49 +       if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
50 +               return -EINVAL;
51  
52 -               return 0;
53 -       }
54 +       if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
55 +               return -EINPROGRESS;
56  
57         rxs->rs_status = 0;
58         rxs->rs_flags =  0;
59 @@ -510,7 +500,11 @@ int ath9k_hw_process_rxdesc_edma(struct 
60                  */
61                 if (rxsp->status11 & AR_CRCErr)
62                         rxs->rs_status |= ATH9K_RXERR_CRC;
63 -               else if (rxsp->status11 & AR_PHYErr) {
64 +               else if (rxsp->status11 & AR_DecryptCRCErr)
65 +                       rxs->rs_status |= ATH9K_RXERR_DECRYPT;
66 +               else if (rxsp->status11 & AR_MichaelErr)
67 +                       rxs->rs_status |= ATH9K_RXERR_MIC;
68 +               if (rxsp->status11 & AR_PHYErr) {
69                         phyerr = MS(rxsp->status11, AR_PHYErrCode);
70                         /*
71                          * If we reach a point here where AR_PostDelimCRCErr is
72 @@ -532,11 +526,7 @@ int ath9k_hw_process_rxdesc_edma(struct 
73                                 rxs->rs_status |= ATH9K_RXERR_PHY;
74                                 rxs->rs_phyerr = phyerr;
75                         }
76 -
77 -               } else if (rxsp->status11 & AR_DecryptCRCErr)
78 -                       rxs->rs_status |= ATH9K_RXERR_DECRYPT;
79 -               else if (rxsp->status11 & AR_MichaelErr)
80 -                       rxs->rs_status |= ATH9K_RXERR_MIC;
81 +               };
82         }
83  
84         if (rxsp->status11 & AR_KeyMiss)
85 --- a/drivers/net/wireless/ath/carl9170/tx.c
86 +++ b/drivers/net/wireless/ath/carl9170/tx.c
87 @@ -1236,6 +1236,7 @@ static bool carl9170_tx_ps_drop(struct a
88  {
89         struct ieee80211_sta *sta;
90         struct carl9170_sta_info *sta_info;
91 +       struct ieee80211_tx_info *tx_info;
92  
93         rcu_read_lock();
94         sta = __carl9170_get_tx_sta(ar, skb);
95 @@ -1243,12 +1244,13 @@ static bool carl9170_tx_ps_drop(struct a
96                 goto out_rcu;
97  
98         sta_info = (void *) sta->drv_priv;
99 -       if (unlikely(sta_info->sleeping)) {
100 -               struct ieee80211_tx_info *tx_info;
101 +       tx_info = IEEE80211_SKB_CB(skb);
102  
103 +       if (unlikely(sta_info->sleeping) &&
104 +           !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
105 +                               IEEE80211_TX_CTL_CLEAR_PS_FILT))) {
106                 rcu_read_unlock();
107  
108 -               tx_info = IEEE80211_SKB_CB(skb);
109                 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
110                         atomic_dec(&ar->tx_ampdu_upload);
111  
112 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
113 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
114 @@ -1694,7 +1694,7 @@ il4965_tx_skb(struct il_priv *il, struct
115                 sta_priv = (void *)sta->drv_priv;
116  
117         if (sta_priv && sta_priv->asleep &&
118 -           (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
119 +           (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
120                 /*
121                  * This sends an asynchronous command to the device,
122                  * but we can rely on it being processed before the
123 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
124 +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
125 @@ -322,7 +322,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv,
126                 sta_priv = (void *)info->control.sta->drv_priv;
127  
128         if (sta_priv && sta_priv->asleep &&
129 -           (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
130 +           (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
131                 /*
132                  * This sends an asynchronous command to the device,
133                  * but we can rely on it being processed before the
134 @@ -331,6 +331,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv,
135                  * counter.
136                  * For now set the counter to just 1 since we do not
137                  * support uAPSD yet.
138 +                *
139 +                * FIXME: If we get two non-bufferable frames one
140 +                * after the other, we might only send out one of
141 +                * them because this is racy.
142                  */
143                 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
144         }
145 --- a/drivers/net/wireless/p54/txrx.c
146 +++ b/drivers/net/wireless/p54/txrx.c
147 @@ -690,7 +690,7 @@ static void p54_tx_80211_header(struct p
148         if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
149                 *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
150  
151 -       if (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)
152 +       if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)
153                 *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
154  
155         if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
156 --- a/include/net/mac80211.h
157 +++ b/include/net/mac80211.h
158 @@ -341,9 +341,9 @@ struct ieee80211_bss_conf {
159   *     used to indicate that a frame was already retried due to PS
160   * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
161   *     used to indicate frame should not be encrypted
162 - * @IEEE80211_TX_CTL_POLL_RESPONSE: This frame is a response to a poll
163 - *     frame (PS-Poll or uAPSD) and should be sent although the station
164 - *     is in powersave mode.
165 + * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll
166 + *     frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must
167 + *     be sent although the station is in powersave mode.
168   * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
169   *     transmit function after the current frame, this can be used
170   *     by drivers to kick the DMA queue only if unset or when the
171 @@ -399,7 +399,7 @@ enum mac80211_tx_control_flags {
172         IEEE80211_TX_INTFL_NEED_TXPROCESSING    = BIT(14),
173         IEEE80211_TX_INTFL_RETRIED              = BIT(15),
174         IEEE80211_TX_INTFL_DONT_ENCRYPT         = BIT(16),
175 -       IEEE80211_TX_CTL_POLL_RESPONSE          = BIT(17),
176 +       IEEE80211_TX_CTL_NO_PS_BUFFER           = BIT(17),
177         IEEE80211_TX_CTL_MORE_FRAMES            = BIT(18),
178         IEEE80211_TX_INTFL_RETRANSMISSION       = BIT(19),
179         /* hole at 20, use later */
180 @@ -425,7 +425,7 @@ enum mac80211_tx_control_flags {
181         IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU |           \
182         IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK |               \
183         IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK |           \
184 -       IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_POLL_RESPONSE |   \
185 +       IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER |    \
186         IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC |                \
187         IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP)
188  
189 @@ -659,6 +659,8 @@ ieee80211_tx_info_clear_status(struct ie
190   * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
191   * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
192   * @RX_FLAG_SHORT_GI: Short guard interval was used
193 + * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present.
194 + *     Valid only for data frames (mainly A-MPDU)
195   */
196  enum mac80211_rx_flags {
197         RX_FLAG_MMIC_ERROR      = 1<<0,
198 @@ -672,6 +674,7 @@ enum mac80211_rx_flags {
199         RX_FLAG_HT              = 1<<9,
200         RX_FLAG_40MHZ           = 1<<10,
201         RX_FLAG_SHORT_GI        = 1<<11,
202 +       RX_FLAG_NO_SIGNAL_VAL   = 1<<12,
203  };
204  
205  /**
206 @@ -1634,7 +1637,7 @@ void ieee80211_free_txskb(struct ieee802
207   * the station sends a PS-Poll or a uAPSD trigger frame, mac80211
208   * will inform the driver of this with the @allow_buffered_frames
209   * callback; this callback is optional. mac80211 will then transmit
210 - * the frames as usual and set the %IEEE80211_TX_CTL_POLL_RESPONSE
211 + * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER
212   * on each frame. The last frame in the service period (or the only
213   * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to
214   * indicate that it ends the service period; as this frame must have
215 @@ -1642,6 +1645,9 @@ void ieee80211_free_txskb(struct ieee802
216   * When TX status is reported for this frame, the service period is
217   * marked has having ended and a new one can be started by the peer.
218   *
219 + * Additionally, non-bufferable MMPDUs can also be transmitted by
220 + * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them.
221 + *
222   * Another race condition can happen on some devices like iwlwifi
223   * when there are frames queued for the station and it wakes up
224   * or polls; the frames that are already queued could end up being
225 @@ -2140,7 +2146,7 @@ enum ieee80211_frame_release_type {
226   * @allow_buffered_frames: Prepare device to allow the given number of frames
227   *     to go out to the given station. The frames will be sent by mac80211
228   *     via the usual TX path after this call. The TX information for frames
229 - *     released will also have the %IEEE80211_TX_CTL_POLL_RESPONSE flag set
230 + *     released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set
231   *     and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case
232   *     frames from multiple TIDs are released and the driver might reorder
233   *     them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag
234 --- a/net/mac80211/agg-rx.c
235 +++ b/net/mac80211/agg-rx.c
236 @@ -187,6 +187,8 @@ static void ieee80211_send_addba_resp(st
237                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
238         else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
239                 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
240 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
241 +               memcpy(mgmt->bssid, da, ETH_ALEN);
242  
243         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
244                                           IEEE80211_STYPE_ACTION);
245 --- a/net/mac80211/agg-tx.c
246 +++ b/net/mac80211/agg-tx.c
247 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
248         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
249         if (sdata->vif.type == NL80211_IFTYPE_AP ||
250             sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
251 -           sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
252 +           sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
253 +           sdata->vif.type == NL80211_IFTYPE_WDS)
254                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
255         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
256                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
257 @@ -471,6 +472,7 @@ int ieee80211_start_tx_ba_session(struct
258             sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
259             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
260             sdata->vif.type != NL80211_IFTYPE_AP &&
261 +           sdata->vif.type != NL80211_IFTYPE_WDS &&
262             sdata->vif.type != NL80211_IFTYPE_ADHOC)
263                 return -EINVAL;
264  
265 --- a/net/mac80211/debugfs_sta.c
266 +++ b/net/mac80211/debugfs_sta.c
267 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
268         test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
269  
270         int res = scnprintf(buf, sizeof(buf),
271 -                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
272 +                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
273                             TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
274                             TEST(PS_DRIVER), TEST(AUTHORIZED),
275                             TEST(SHORT_PREAMBLE),
276 -                           TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
277 +                           TEST(WME), TEST(CLEAR_PS_FILT),
278                             TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
279                             TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
280                             TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
281 --- a/net/mac80211/iface.c
282 +++ b/net/mac80211/iface.c
283 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
284  {
285         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
286         struct ieee80211_local *local = sdata->local;
287 -       struct sta_info *sta;
288         u32 changed = 0;
289         int res;
290         u32 hw_reconf_flags = 0;
291 @@ -309,28 +308,6 @@ static int ieee80211_do_open(struct net_
292  
293         set_bit(SDATA_STATE_RUNNING, &sdata->state);
294  
295 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
296 -               /* Create STA entry for the WDS peer */
297 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
298 -                                    GFP_KERNEL);
299 -               if (!sta) {
300 -                       res = -ENOMEM;
301 -                       goto err_del_interface;
302 -               }
303 -
304 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
305 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
306 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
307 -
308 -               res = sta_info_insert(sta);
309 -               if (res) {
310 -                       /* STA has been freed */
311 -                       goto err_del_interface;
312 -               }
313 -
314 -               rate_control_rate_init(sta);
315 -       }
316 -
317         /*
318          * set_multicast_list will be invoked by the networking core
319          * which will check whether any increments here were done in
320 @@ -357,8 +334,7 @@ static int ieee80211_do_open(struct net_
321         netif_tx_start_all_queues(dev);
322  
323         return 0;
324 - err_del_interface:
325 -       drv_remove_interface(local, sdata);
326 +
327   err_stop:
328         if (!local->open_count)
329                 drv_stop(local);
330 @@ -722,6 +698,70 @@ static void ieee80211_if_setup(struct ne
331         dev->destructor = free_netdev;
332  }
333  
334 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
335 +                                        struct sk_buff *skb)
336 +{
337 +       struct ieee80211_local *local = sdata->local;
338 +       struct ieee80211_rx_status *rx_status;
339 +       struct ieee802_11_elems elems;
340 +       struct ieee80211_mgmt *mgmt;
341 +       struct sta_info *sta;
342 +       size_t baselen;
343 +       u32 rates = 0;
344 +       u16 stype;
345 +       bool new = false;
346 +       enum ieee80211_band band = local->hw.conf.channel->band;
347 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
348 +
349 +       rx_status = IEEE80211_SKB_RXCB(skb);
350 +       mgmt = (struct ieee80211_mgmt *) skb->data;
351 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
352 +
353 +       if (stype != IEEE80211_STYPE_BEACON)
354 +               return;
355 +
356 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
357 +       if (baselen > skb->len)
358 +               return;
359 +
360 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
361 +                              skb->len - baselen, &elems);
362 +
363 +       rates = ieee80211_sta_get_rates(local, &elems, band);
364 +
365 +       rcu_read_lock();
366 +
367 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
368 +
369 +       if (!sta) {
370 +               rcu_read_unlock();
371 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
372 +                                    GFP_KERNEL);
373 +               if (!sta)
374 +                       return;
375 +
376 +               new = true;
377 +       }
378 +
379 +       sta->last_rx = jiffies;
380 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
381 +
382 +       if (elems.ht_cap_elem)
383 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
384 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
385 +
386 +       if (elems.wmm_param)
387 +               set_sta_flag(sta, WLAN_STA_WME);
388 +
389 +       if (new) {
390 +               set_sta_flag(sta, WLAN_STA_AUTHORIZED);
391 +               rate_control_rate_init(sta);
392 +               sta_info_insert_rcu(sta);
393 +       }
394 +
395 +       rcu_read_unlock();
396 +}
397 +
398  static void ieee80211_iface_work(struct work_struct *work)
399  {
400         struct ieee80211_sub_if_data *sdata =
401 @@ -826,6 +866,9 @@ static void ieee80211_iface_work(struct 
402                                 break;
403                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
404                         break;
405 +               case NL80211_IFTYPE_WDS:
406 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
407 +                       break;
408                 default:
409                         WARN(1, "frame for unexpected interface type");
410                         break;
411 --- a/net/mac80211/rx.c
412 +++ b/net/mac80211/rx.c
413 @@ -177,7 +177,8 @@ ieee80211_add_rx_radiotap_header(struct 
414         pos += 2;
415  
416         /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
417 -       if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
418 +       if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM &&
419 +           !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
420                 *pos = status->signal;
421                 rthdr->it_present |=
422                         cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
423 @@ -489,12 +490,12 @@ ieee80211_rx_mesh_check(struct ieee80211
424                         if (ieee80211_has_tods(hdr->frame_control) ||
425                                 !ieee80211_has_fromds(hdr->frame_control))
426                                 return RX_DROP_MONITOR;
427 -                       if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0)
428 +                       if (compare_ether_addr(hdr->addr3, dev_addr) == 0)
429                                 return RX_DROP_MONITOR;
430                 } else {
431                         if (!ieee80211_has_a4(hdr->frame_control))
432                                 return RX_DROP_MONITOR;
433 -                       if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0)
434 +                       if (compare_ether_addr(hdr->addr4, dev_addr) == 0)
435                                 return RX_DROP_MONITOR;
436                 }
437         }
438 @@ -1309,8 +1310,10 @@ ieee80211_rx_h_sta_process(struct ieee80
439  
440         sta->rx_fragments++;
441         sta->rx_bytes += rx->skb->len;
442 -       sta->last_signal = status->signal;
443 -       ewma_add(&sta->avg_signal, -status->signal);
444 +       if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
445 +               sta->last_signal = status->signal;
446 +               ewma_add(&sta->avg_signal, -status->signal);
447 +       }
448  
449         /*
450          * Change STA power saving mode only at the end of a frame
451 @@ -2282,6 +2285,7 @@ ieee80211_rx_h_action(struct ieee80211_r
452                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
453                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
454                     sdata->vif.type != NL80211_IFTYPE_AP &&
455 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
456                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
457                         break;
458  
459 @@ -2336,7 +2340,7 @@ ieee80211_rx_h_action(struct ieee80211_r
460                         if (sdata->vif.type != NL80211_IFTYPE_STATION)
461                                 break;
462  
463 -                       if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN))
464 +                       if (compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid))
465                                 break;
466  
467                         goto queue;
468 @@ -2492,14 +2496,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
469  
470         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
471             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
472 -           sdata->vif.type != NL80211_IFTYPE_STATION)
473 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
474 +           sdata->vif.type != NL80211_IFTYPE_WDS)
475                 return RX_DROP_MONITOR;
476  
477         switch (stype) {
478         case cpu_to_le16(IEEE80211_STYPE_AUTH):
479         case cpu_to_le16(IEEE80211_STYPE_BEACON):
480         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
481 -               /* process for all: mesh, mlme, ibss */
482 +               /* process for all: mesh, mlme, ibss, wds */
483                 break;
484         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
485         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
486 @@ -2853,10 +2858,16 @@ static int prepare_for_handlers(struct i
487                 }
488                 break;
489         case NL80211_IFTYPE_WDS:
490 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
491 -                       return 0;
492                 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
493                         return 0;
494 +
495 +               if (ieee80211_is_data(hdr->frame_control) ||
496 +                   ieee80211_is_action(hdr->frame_control)) {
497 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
498 +                               return 0;
499 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
500 +                       return 0;
501 +
502                 break;
503         default:
504                 /* should never get here */
505 --- a/net/mac80211/sta_info.c
506 +++ b/net/mac80211/sta_info.c
507 @@ -9,6 +9,7 @@
508  
509  #include <linux/module.h>
510  #include <linux/init.h>
511 +#include <linux/etherdevice.h>
512  #include <linux/netdevice.h>
513  #include <linux/types.h>
514  #include <linux/slab.h>
515 @@ -101,7 +102,7 @@ struct sta_info *sta_info_get(struct iee
516                                     lockdep_is_held(&local->sta_mtx));
517         while (sta) {
518                 if (sta->sdata == sdata &&
519 -                   memcmp(sta->sta.addr, addr, ETH_ALEN) == 0)
520 +                   compare_ether_addr(sta->sta.addr, addr) == 0)
521                         break;
522                 sta = rcu_dereference_check(sta->hnext,
523                                             lockdep_is_held(&local->sta_mtx));
524 @@ -124,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct
525         while (sta) {
526                 if ((sta->sdata == sdata ||
527                      (sta->sdata->bss && sta->sdata->bss == sdata->bss)) &&
528 -                   memcmp(sta->sta.addr, addr, ETH_ALEN) == 0)
529 +                   compare_ether_addr(sta->sta.addr, addr) == 0)
530                         break;
531                 sta = rcu_dereference_check(sta->hnext,
532                                             lockdep_is_held(&local->sta_mtx));
533 @@ -1050,7 +1051,7 @@ static void ieee80211_send_null_response
534          * exchange. Also set EOSP to indicate this packet
535          * ends the poll/service period.
536          */
537 -       info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE |
538 +       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
539                        IEEE80211_TX_STATUS_EOSP |
540                        IEEE80211_TX_CTL_REQ_TX_STATUS;
541  
542 @@ -1177,7 +1178,7 @@ ieee80211_sta_ps_deliver_response(struct
543                          * STA may still remain is PS mode after this frame
544                          * exchange.
545                          */
546 -                       info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE;
547 +                       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
548  
549                         /*
550                          * Use MoreData flag to indicate whether there are
551 --- a/net/mac80211/sta_info.h
552 +++ b/net/mac80211/sta_info.h
553 @@ -14,6 +14,7 @@
554  #include <linux/if_ether.h>
555  #include <linux/workqueue.h>
556  #include <linux/average.h>
557 +#include <linux/etherdevice.h>
558  #include "key.h"
559  
560  /**
561 @@ -31,7 +32,6 @@
562   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
563   *     frames.
564   * @WLAN_STA_WME: Station is a QoS-STA.
565 - * @WLAN_STA_WDS: Station is one of our WDS peers.
566   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
567   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
568   *     frame to this station is transmitted.
569 @@ -62,7 +62,6 @@ enum ieee80211_sta_info_flags {
570         WLAN_STA_AUTHORIZED,
571         WLAN_STA_SHORT_PREAMBLE,
572         WLAN_STA_WME,
573 -       WLAN_STA_WDS,
574         WLAN_STA_CLEAR_PS_FILT,
575         WLAN_STA_MFP,
576         WLAN_STA_BLOCK_BA,
577 @@ -489,7 +488,7 @@ void for_each_sta_info_type_check(struct
578                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL        \
579              )                                                          \
580         /* compare address and run code only if it matches */           \
581 -       if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0)
582 +       if (compare_ether_addr(_sta->sta.addr, (_addr)) == 0)
583  
584  /*
585   * Get STA info by index, BROKEN!
586 --- a/net/mac80211/tx.c
587 +++ b/net/mac80211/tx.c
588 @@ -448,18 +448,23 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
589         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
590         struct ieee80211_local *local = tx->local;
591  
592 -       if (unlikely(!sta ||
593 -                    ieee80211_is_probe_resp(hdr->frame_control) ||
594 -                    ieee80211_is_auth(hdr->frame_control) ||
595 -                    ieee80211_is_assoc_resp(hdr->frame_control) ||
596 -                    ieee80211_is_reassoc_resp(hdr->frame_control)))
597 +       if (unlikely(!sta))
598                 return TX_CONTINUE;
599  
600         if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) ||
601                       test_sta_flag(sta, WLAN_STA_PS_DRIVER)) &&
602 -                    !(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE))) {
603 +                    !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
604                 int ac = skb_get_queue_mapping(tx->skb);
605  
606 +               /* only deauth, disassoc and action are bufferable MMPDUs */
607 +               if (ieee80211_is_mgmt(hdr->frame_control) &&
608 +                   !ieee80211_is_deauth(hdr->frame_control) &&
609 +                   !ieee80211_is_disassoc(hdr->frame_control) &&
610 +                   !ieee80211_is_action(hdr->frame_control)) {
611 +                       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
612 +                       return TX_CONTINUE;
613 +               }
614 +
615  #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
616                 printk(KERN_DEBUG "STA %pM aid %d: PS buffer for AC %d\n",
617                        sta->sta.addr, sta->sta.aid, ac);
618 --- a/net/mac80211/ieee80211_i.h
619 +++ b/net/mac80211/ieee80211_i.h
620 @@ -480,7 +480,7 @@ struct ieee80211_if_ibss {
621  
622         bool control_port;
623  
624 -       u8 bssid[ETH_ALEN];
625 +       u8 bssid[ETH_ALEN] __aligned(2);
626         u8 ssid[IEEE80211_MAX_SSID_LEN];
627         u8 ssid_len, ie_len;
628         u8 *ie;
629 --- a/net/mac80211/ibss.c
630 +++ b/net/mac80211/ibss.c
631 @@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(st
632         skb_reset_tail_pointer(skb);
633         skb_reserve(skb, sdata->local->hw.extra_tx_headroom);
634  
635 -       if (memcmp(ifibss->bssid, bssid, ETH_ALEN))
636 +       if (compare_ether_addr(ifibss->bssid, bssid))
637                 sta_info_flush(sdata->local, sdata);
638  
639         /* if merging, indicate to driver that we leave the old IBSS */
640 @@ -403,7 +403,7 @@ static void ieee80211_rx_bss_info(struct
641                 return;
642  
643         if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
644 -           memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) {
645 +           compare_ether_addr(mgmt->bssid, sdata->u.ibss.bssid) == 0) {
646  
647                 rcu_read_lock();
648                 sta = sta_info_get(sdata, mgmt->sa);
649 @@ -508,7 +508,7 @@ static void ieee80211_rx_bss_info(struct
650                 goto put_bss;
651  
652         /* same BSSID */
653 -       if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0)
654 +       if (compare_ether_addr(cbss->bssid, sdata->u.ibss.bssid) == 0)
655                 goto put_bss;
656  
657         if (rx_status->flag & RX_FLAG_MACTIME_MPDU) {
658 @@ -831,8 +831,8 @@ static void ieee80211_rx_mgmt_probe_req(
659         if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da))
660                 return;
661  
662 -       if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 &&
663 -           memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0)
664 +       if (compare_ether_addr(mgmt->bssid, ifibss->bssid) != 0 &&
665 +           !is_broadcast_ether_addr(mgmt->bssid))
666                 return;
667  
668         end = ((u8 *) mgmt) + len;
669 --- a/net/mac80211/mesh.c
670 +++ b/net/mac80211/mesh.c
671 @@ -204,7 +204,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80
672                         kmem_cache_free(rm_cache, p);
673                         --entries;
674                 } else if ((seqnum == p->seqnum) &&
675 -                          (memcmp(sa, p->sa, ETH_ALEN) == 0))
676 +                          (compare_ether_addr(sa, p->sa) == 0))
677                         return -1;
678         }
679  
680 --- a/net/mac80211/mesh_hwmp.c
681 +++ b/net/mac80211/mesh_hwmp.c
682 @@ -8,6 +8,7 @@
683   */
684  
685  #include <linux/slab.h>
686 +#include <linux/etherdevice.h>
687  #include <asm/unaligned.h>
688  #include "wme.h"
689  #include "mesh.h"
690 @@ -419,7 +420,7 @@ static u32 hwmp_route_info_get(struct ie
691                 new_metric = MAX_METRIC;
692         exp_time = TU_TO_EXP_TIME(orig_lifetime);
693  
694 -       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) {
695 +       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) {
696                 /* This MP is the originator, we are not interested in this
697                  * frame, except for updating transmitter's path info.
698                  */
699 @@ -469,7 +470,7 @@ static u32 hwmp_route_info_get(struct ie
700  
701         /* Update and check transmitter routing info */
702         ta = mgmt->sa;
703 -       if (memcmp(orig_addr, ta, ETH_ALEN) == 0)
704 +       if (compare_ether_addr(orig_addr, ta) == 0)
705                 fresh_info = false;
706         else {
707                 fresh_info = true;
708 @@ -529,7 +530,7 @@ static void hwmp_preq_frame_process(stru
709  
710         mhwmp_dbg("received PREQ from %pM", orig_addr);
711  
712 -       if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) {
713 +       if (compare_ether_addr(target_addr, sdata->vif.addr) == 0) {
714                 mhwmp_dbg("PREQ is for us");
715                 forward = false;
716                 reply = true;
717 @@ -624,7 +625,7 @@ static void hwmp_prep_frame_process(stru
718         mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem));
719  
720         orig_addr = PREP_IE_ORIG_ADDR(prep_elem);
721 -       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
722 +       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
723                 /* destination, no forwarding required */
724                 return;
725  
726 @@ -694,10 +695,12 @@ static void hwmp_perr_frame_process(stru
727         rcu_read_lock();
728         mpath = mesh_path_lookup(target_addr, sdata);
729         if (mpath) {
730 +               struct sta_info *sta;
731 +
732                 spin_lock_bh(&mpath->state_lock);
733 +               sta = next_hop_deref_protected(mpath);
734                 if (mpath->flags & MESH_PATH_ACTIVE &&
735 -                   memcmp(ta, next_hop_deref_protected(mpath)->sta.addr,
736 -                                                       ETH_ALEN) == 0 &&
737 +                   compare_ether_addr(ta, sta->sta.addr) == 0 &&
738                     (!(mpath->flags & MESH_PATH_SN_VALID) ||
739                     SN_GT(target_sn, mpath->sn))) {
740                         mpath->flags &= ~MESH_PATH_ACTIVE;
741 @@ -739,7 +742,7 @@ static void hwmp_rann_frame_process(stru
742         metric = rann->rann_metric;
743  
744         /*  Ignore our own RANNs */
745 -       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
746 +       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
747                 return;
748  
749         mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr,
750 @@ -1064,7 +1067,7 @@ int mesh_nexthop_lookup(struct sk_buff *
751         if (time_after(jiffies,
752                        mpath->exp_time -
753                        msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) &&
754 -           !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) &&
755 +           !compare_ether_addr(sdata->vif.addr, hdr->addr4) &&
756             !(mpath->flags & MESH_PATH_RESOLVING) &&
757             !(mpath->flags & MESH_PATH_FIXED))
758                 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH);
759 --- a/net/mac80211/mesh_pathtbl.c
760 +++ b/net/mac80211/mesh_pathtbl.c
761 @@ -350,7 +350,7 @@ static struct mesh_path *mpath_lookup(st
762         hlist_for_each_entry_rcu(node, n, bucket, list) {
763                 mpath = node->mpath;
764                 if (mpath->sdata == sdata &&
765 -                               memcmp(dst, mpath->dst, ETH_ALEN) == 0) {
766 +                               compare_ether_addr(dst, mpath->dst) == 0) {
767                         if (MPATH_EXPIRED(mpath)) {
768                                 spin_lock_bh(&mpath->state_lock);
769                                 mpath->flags &= ~MESH_PATH_ACTIVE;
770 @@ -525,7 +525,7 @@ int mesh_path_add(u8 *dst, struct ieee80
771         int err = 0;
772         u32 hash_idx;
773  
774 -       if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
775 +       if (compare_ether_addr(dst, sdata->vif.addr) == 0)
776                 /* never add ourselves as neighbours */
777                 return -ENOTSUPP;
778  
779 @@ -566,7 +566,8 @@ int mesh_path_add(u8 *dst, struct ieee80
780         err = -EEXIST;
781         hlist_for_each_entry(node, n, bucket, list) {
782                 mpath = node->mpath;
783 -               if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
784 +               if (mpath->sdata == sdata &&
785 +                   compare_ether_addr(dst, mpath->dst) == 0)
786                         goto err_exists;
787         }
788  
789 @@ -657,7 +658,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struc
790         int err = 0;
791         u32 hash_idx;
792  
793 -       if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
794 +       if (compare_ether_addr(dst, sdata->vif.addr) == 0)
795                 /* never add ourselves as neighbours */
796                 return -ENOTSUPP;
797  
798 @@ -694,7 +695,8 @@ int mpp_path_add(u8 *dst, u8 *mpp, struc
799         err = -EEXIST;
800         hlist_for_each_entry(node, n, bucket, list) {
801                 mpath = node->mpath;
802 -               if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
803 +               if (mpath->sdata == sdata &&
804 +                   compare_ether_addr(dst, mpath->dst) == 0)
805                         goto err_exists;
806         }
807  
808 @@ -887,7 +889,7 @@ int mesh_path_del(u8 *addr, struct ieee8
809         hlist_for_each_entry(node, n, bucket, list) {
810                 mpath = node->mpath;
811                 if (mpath->sdata == sdata &&
812 -                   memcmp(addr, mpath->dst, ETH_ALEN) == 0) {
813 +                   compare_ether_addr(addr, mpath->dst) == 0) {
814                         __mesh_path_del(tbl, node);
815                         goto enddel;
816                 }
817 --- a/net/mac80211/mlme.c
818 +++ b/net/mac80211/mlme.c
819 @@ -1812,7 +1812,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_
820  
821         memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
822  
823 -       if (memcmp(bssid, mgmt->bssid, ETH_ALEN))
824 +       if (compare_ether_addr(bssid, mgmt->bssid))
825                 return RX_MGMT_NONE;
826  
827         auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
828 @@ -1893,7 +1893,7 @@ ieee80211_rx_mgmt_deauth(struct ieee8021
829                 return RX_MGMT_NONE;
830  
831         if (!ifmgd->associated ||
832 -           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
833 +           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
834                 return RX_MGMT_NONE;
835  
836         bssid = ifmgd->associated->bssid;
837 @@ -1925,7 +1925,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80
838                 return RX_MGMT_NONE;
839  
840         if (!ifmgd->associated ||
841 -           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
842 +           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
843                 return RX_MGMT_NONE;
844  
845         reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
846 @@ -2190,7 +2190,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee
847  
848         if (!assoc_data)
849                 return RX_MGMT_NONE;
850 -       if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN))
851 +       if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid))
852                 return RX_MGMT_NONE;
853  
854         /*
855 @@ -2278,8 +2278,8 @@ static void ieee80211_rx_bss_info(struct
856         bool need_ps = false;
857  
858         if (sdata->u.mgd.associated &&
859 -           memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid,
860 -                  ETH_ALEN) == 0) {
861 +           compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid)
862 +           == 0) {
863                 bss = (void *)sdata->u.mgd.associated->priv;
864                 /* not previously set so we may need to recalc */
865                 need_ps = !bss->dtim_period;
866 @@ -2334,7 +2334,7 @@ static void ieee80211_rx_mgmt_probe_resp
867  
868         ASSERT_MGD_MTX(ifmgd);
869  
870 -       if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN))
871 +       if (compare_ether_addr(mgmt->da, sdata->vif.addr))
872                 return; /* ignore ProbeResp to foreign address */
873  
874         baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
875 @@ -2347,11 +2347,12 @@ static void ieee80211_rx_mgmt_probe_resp
876         ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
877  
878         if (ifmgd->associated &&
879 -           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0)
880 +           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0)
881                 ieee80211_reset_ap_probe(sdata);
882  
883         if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies &&
884 -           memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) {
885 +           compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid)
886 +           == 0) {
887                 /* got probe response, continue with auth */
888                 printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name);
889                 ifmgd->auth_data->tries = 0;
890 @@ -2408,7 +2409,8 @@ static void ieee80211_rx_mgmt_beacon(str
891                 return;
892  
893         if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
894 -           memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) {
895 +           compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid)
896 +           == 0) {
897                 ieee802_11_parse_elems(mgmt->u.beacon.variable,
898                                        len - baselen, &elems);
899  
900 @@ -2423,7 +2425,7 @@ static void ieee80211_rx_mgmt_beacon(str
901         }
902  
903         if (!ifmgd->associated ||
904 -           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
905 +           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
906                 return;
907         bssid = ifmgd->associated->bssid;
908  
909 @@ -3285,7 +3287,7 @@ int ieee80211_mgd_assoc(struct ieee80211
910                 bool match;
911  
912                 /* keep sta info, bssid if matching */
913 -               match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0;
914 +               match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0;
915                 ieee80211_destroy_auth_data(sdata, match);
916         }
917  
918 @@ -3407,7 +3409,7 @@ int ieee80211_mgd_assoc(struct ieee80211
919                         goto err_clear;
920                 }
921         } else
922 -               WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN));
923 +               WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid));
924  
925         if (!bss->dtim_period &&
926             sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) {
927 @@ -3448,7 +3450,7 @@ int ieee80211_mgd_deauth(struct ieee8021
928         mutex_lock(&ifmgd->mtx);
929  
930         if (ifmgd->associated &&
931 -           memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) {
932 +           compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0) {
933                 ieee80211_set_disassoc(sdata, false, true);
934                 assoc_bss = true;
935         } else if (ifmgd->auth_data) {
936 --- a/net/mac80211/status.c
937 +++ b/net/mac80211/status.c
938 @@ -10,6 +10,7 @@
939   */
940  
941  #include <linux/export.h>
942 +#include <linux/etherdevice.h>
943  #include <net/mac80211.h>
944  #include <asm/unaligned.h>
945  #include "ieee80211_i.h"
946 @@ -377,7 +378,7 @@ void ieee80211_tx_status(struct ieee8021
947  
948         for_each_sta_info(local, hdr->addr1, sta, tmp) {
949                 /* skip wrong virtual interface */
950 -               if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN))
951 +               if (compare_ether_addr(hdr->addr2, sta->sdata->vif.addr))
952                         continue;
953  
954                 if (info->flags & IEEE80211_TX_STATUS_EOSP)
955 --- a/net/wireless/mlme.c
956 +++ b/net/wireless/mlme.c
957 @@ -6,6 +6,7 @@
958  
959  #include <linux/kernel.h>
960  #include <linux/module.h>
961 +#include <linux/etherdevice.h>
962  #include <linux/netdevice.h>
963  #include <linux/nl80211.h>
964  #include <linux/slab.h>
965 @@ -100,7 +101,7 @@ void __cfg80211_send_deauth(struct net_d
966         ASSERT_WDEV_LOCK(wdev);
967  
968         if (wdev->current_bss &&
969 -           memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
970 +           compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) {
971                 cfg80211_unhold_bss(wdev->current_bss);
972                 cfg80211_put_bss(&wdev->current_bss->pub);
973                 wdev->current_bss = NULL;
974 @@ -115,7 +116,7 @@ void __cfg80211_send_deauth(struct net_d
975  
976                 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
977  
978 -               from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
979 +               from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0;
980                 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
981         } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
982                 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
983 @@ -154,7 +155,7 @@ void __cfg80211_send_disassoc(struct net
984                 return;
985  
986         if (wdev->current_bss &&
987 -           memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
988 +           compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) {
989                 cfg80211_sme_disassoc(dev, wdev->current_bss);
990                 cfg80211_unhold_bss(wdev->current_bss);
991                 cfg80211_put_bss(&wdev->current_bss->pub);
992 @@ -165,7 +166,7 @@ void __cfg80211_send_disassoc(struct net
993  
994         reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
995  
996 -       from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
997 +       from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0;
998         __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
999  }
1000  EXPORT_SYMBOL(__cfg80211_send_disassoc);
1001 @@ -285,7 +286,7 @@ int __cfg80211_mlme_auth(struct cfg80211
1002                         return -EINVAL;
1003  
1004         if (wdev->current_bss &&
1005 -           memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0)
1006 +           compare_ether_addr(bssid, wdev->current_bss->pub.bssid) == 0)
1007                 return -EALREADY;
1008  
1009         memset(&req, 0, sizeof(req));
1010 @@ -362,7 +363,7 @@ int __cfg80211_mlme_assoc(struct cfg8021
1011         memset(&req, 0, sizeof(req));
1012  
1013         if (wdev->current_bss && prev_bssid &&
1014 -           memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) {
1015 +           compare_ether_addr(wdev->current_bss->pub.bssid, prev_bssid) == 0) {
1016                 /*
1017                  * Trying to reassociate: Allow this to proceed and let the old
1018                  * association to be dropped when the new one is completed.
1019 @@ -446,7 +447,8 @@ int __cfg80211_mlme_deauth(struct cfg802
1020  
1021         if (local_state_change) {
1022                 if (wdev->current_bss &&
1023 -                   memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
1024 +                   compare_ether_addr(wdev->current_bss->pub.bssid, bssid)
1025 +                   == 0) {
1026                         cfg80211_unhold_bss(wdev->current_bss);
1027                         cfg80211_put_bss(&wdev->current_bss->pub);
1028                         wdev->current_bss = NULL;
1029 @@ -495,7 +497,7 @@ static int __cfg80211_mlme_disassoc(stru
1030         req.local_state_change = local_state_change;
1031         req.ie = ie;
1032         req.ie_len = ie_len;
1033 -       if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0)
1034 +       if (compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0)
1035                 req.bss = &wdev->current_bss->pub;
1036         else
1037                 return -ENOTCONN;
1038 @@ -758,8 +760,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1039                                 break;
1040                         }
1041  
1042 -                       if (memcmp(wdev->current_bss->pub.bssid,
1043 -                                  mgmt->bssid, ETH_ALEN)) {
1044 +                       if (compare_ether_addr(wdev->current_bss->pub.bssid,
1045 +                                              mgmt->bssid)) {
1046                                 err = -ENOTCONN;
1047                                 break;
1048                         }
1049 @@ -772,8 +774,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1050                                 break;
1051  
1052                         /* for station, check that DA is the AP */
1053 -                       if (memcmp(wdev->current_bss->pub.bssid,
1054 -                                  mgmt->da, ETH_ALEN)) {
1055 +                       if (compare_ether_addr(wdev->current_bss->pub.bssid,
1056 +                                              mgmt->da)) {
1057                                 err = -ENOTCONN;
1058                                 break;
1059                         }
1060 @@ -781,11 +783,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1061                 case NL80211_IFTYPE_AP:
1062                 case NL80211_IFTYPE_P2P_GO:
1063                 case NL80211_IFTYPE_AP_VLAN:
1064 -                       if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN))
1065 +                       if (compare_ether_addr(mgmt->bssid, dev->dev_addr))
1066                                 err = -EINVAL;
1067                         break;
1068                 case NL80211_IFTYPE_MESH_POINT:
1069 -                       if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) {
1070 +                       if (compare_ether_addr(mgmt->sa, mgmt->bssid)) {
1071                                 err = -EINVAL;
1072                                 break;
1073                         }
1074 @@ -804,7 +806,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1075                         return err;
1076         }
1077  
1078 -       if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0)
1079 +       if (compare_ether_addr(mgmt->sa, dev->dev_addr) != 0)
1080                 return -EINVAL;
1081  
1082         /* Transmit the Action frame as requested by user space */
1083 --- a/net/wireless/scan.c
1084 +++ b/net/wireless/scan.c
1085 @@ -378,7 +378,7 @@ static int cmp_bss_core(struct cfg80211_
1086                                b->len_information_elements);
1087         }
1088  
1089 -       return memcmp(a->bssid, b->bssid, ETH_ALEN);
1090 +       return compare_ether_addr(a->bssid, b->bssid);
1091  }
1092  
1093  static int cmp_bss(struct cfg80211_bss *a,
1094 --- a/drivers/net/wireless/ath/ath9k/Kconfig
1095 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
1096 @@ -81,6 +81,14 @@ config ATH9K_DFS_CERTIFIED
1097           developed. At this point enabling this option won't do anything
1098           except increase code size.
1099  
1100 +config ATH9K_MAC_DEBUG
1101 +       bool "Atheros MAC statistics"
1102 +       depends on ATH9K_DEBUGFS
1103 +       default y
1104 +       ---help---
1105 +         This option enables collection of statistics for Rx/Tx status
1106 +         data and some other MAC related statistics
1107 +
1108  config ATH9K_RATE_CONTROL
1109         bool "Atheros ath9k rate control"
1110         depends on ATH9K
1111 --- a/drivers/net/wireless/ath/ath9k/debug.c
1112 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1113 @@ -818,6 +818,7 @@ void ath_debug_stat_tx(struct ath_softc 
1114         if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
1115                 TX_STAT_INC(qnum, delim_underrun);
1116  
1117 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1118         spin_lock(&sc->debug.samp_lock);
1119         TX_SAMP_DBG(jiffies) = jiffies;
1120         TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
1121 @@ -844,6 +845,7 @@ void ath_debug_stat_tx(struct ath_softc 
1122  
1123         sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
1124         spin_unlock(&sc->debug.samp_lock);
1125 +#endif
1126  
1127  #undef TX_SAMP_DBG
1128  }
1129 @@ -942,27 +944,6 @@ static ssize_t read_file_recv(struct fil
1130         PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
1131  
1132         len += snprintf(buf + len, size - len,
1133 -                       "%22s : %10d\n", "RSSI-CTL0",
1134 -                       sc->debug.stats.rxstats.rs_rssi_ctl0);
1135 -       len += snprintf(buf + len, size - len,
1136 -                       "%22s : %10d\n", "RSSI-CTL1",
1137 -                       sc->debug.stats.rxstats.rs_rssi_ctl1);
1138 -       len += snprintf(buf + len, size - len,
1139 -                       "%22s : %10d\n", "RSSI-CTL2",
1140 -                       sc->debug.stats.rxstats.rs_rssi_ctl2);
1141 -       len += snprintf(buf + len, size - len,
1142 -                       "%22s : %10d\n", "RSSI-EXT0",
1143 -                       sc->debug.stats.rxstats.rs_rssi_ext0);
1144 -       len += snprintf(buf + len, size - len,
1145 -                       "%22s : %10d\n", "RSSI-EXT1",
1146 -                       sc->debug.stats.rxstats.rs_rssi_ext1);
1147 -       len += snprintf(buf + len, size - len,
1148 -                       "%22s : %10d\n", "RSSI-EXT2",
1149 -                       sc->debug.stats.rxstats.rs_rssi_ext2);
1150 -       len += snprintf(buf + len, size - len,
1151 -                       "%22s : %10d\n", "Rx Antenna",
1152 -                       sc->debug.stats.rxstats.rs_antenna);
1153 -       len += snprintf(buf + len, size - len,
1154                         "%22s : %10u\n", "RX-Pkts-All",
1155                         sc->debug.stats.rxstats.rx_pkts_all);
1156         len += snprintf(buf + len, size - len,
1157 @@ -1009,16 +990,7 @@ void ath_debug_stat_rx(struct ath_softc 
1158                         RX_PHY_ERR_INC(rs->rs_phyerr);
1159         }
1160  
1161 -       sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
1162 -       sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
1163 -       sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
1164 -
1165 -       sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
1166 -       sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
1167 -       sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
1168 -
1169 -       sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
1170 -
1171 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1172         spin_lock(&sc->debug.samp_lock);
1173         RX_SAMP_DBG(jiffies) = jiffies;
1174         RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
1175 @@ -1035,6 +1007,8 @@ void ath_debug_stat_rx(struct ath_softc 
1176         sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1177         spin_unlock(&sc->debug.samp_lock);
1178  
1179 +#endif
1180 +
1181  #undef RX_STAT_INC
1182  #undef RX_PHY_ERR_INC
1183  #undef RX_SAMP_DBG
1184 @@ -1278,6 +1252,8 @@ static const struct file_operations fops
1185         .llseek = default_llseek,
1186  };
1187  
1188 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1189 +
1190  void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1191  {
1192  #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1193 @@ -1551,6 +1527,7 @@ static const struct file_operations fops
1194         .llseek = default_llseek,
1195  };
1196  
1197 +#endif
1198  
1199  int ath9k_init_debug(struct ath_hw *ah)
1200  {
1201 @@ -1604,8 +1581,10 @@ int ath9k_init_debug(struct ath_hw *ah)
1202                             &fops_base_eeprom);
1203         debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1204                             &fops_modal_eeprom);
1205 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1206         debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1207                             &fops_samps);
1208 +#endif
1209  
1210         debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1211                            sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1212 --- a/drivers/net/wireless/ath/ath9k/debug.h
1213 +++ b/drivers/net/wireless/ath/ath9k/debug.h
1214 @@ -165,13 +165,6 @@ struct ath_rx_stats {
1215         u32 post_delim_crc_err;
1216         u32 decrypt_busy_err;
1217         u32 phy_err_stats[ATH9K_PHYERR_MAX];
1218 -       int8_t rs_rssi_ctl0;
1219 -       int8_t rs_rssi_ctl1;
1220 -       int8_t rs_rssi_ctl2;
1221 -       int8_t rs_rssi_ext0;
1222 -       int8_t rs_rssi_ext1;
1223 -       int8_t rs_rssi_ext2;
1224 -       u8 rs_antenna;
1225  };
1226  
1227  enum ath_reset_type {
1228 @@ -235,16 +228,17 @@ struct ath9k_debug {
1229         struct dentry *debugfs_phy;
1230         u32 regidx;
1231         struct ath_stats stats;
1232 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1233         spinlock_t samp_lock;
1234         struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
1235         u8 sampidx;
1236         u8 tsidx;
1237         u8 rsidx;
1238 +#endif
1239  };
1240  
1241  int ath9k_init_debug(struct ath_hw *ah);
1242  
1243 -void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
1244  void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
1245  void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
1246                        struct ath_tx_status *ts, struct ath_txq *txq,
1247 @@ -258,10 +252,6 @@ static inline int ath9k_init_debug(struc
1248         return 0;
1249  }
1250  
1251 -static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1252 -{
1253 -}
1254 -
1255  static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
1256                                             enum ath9k_int status)
1257  {
1258 @@ -282,4 +272,17 @@ static inline void ath_debug_stat_rx(str
1259  
1260  #endif /* CONFIG_ATH9K_DEBUGFS */
1261  
1262 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1263 +
1264 +void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
1265 +
1266 +#else
1267 +
1268 +static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1269 +{
1270 +}
1271 +
1272 +#endif
1273 +
1274 +
1275  #endif /* DEBUG_H */
1276 --- a/drivers/net/wireless/ath/ath9k/init.c
1277 +++ b/drivers/net/wireless/ath/ath9k/init.c
1278 @@ -555,9 +555,11 @@ static int ath9k_init_softc(u16 devid, s
1279         mutex_init(&sc->mutex);
1280  #ifdef CONFIG_ATH9K_DEBUGFS
1281         spin_lock_init(&sc->nodes_lock);
1282 -       spin_lock_init(&sc->debug.samp_lock);
1283         INIT_LIST_HEAD(&sc->nodes);
1284  #endif
1285 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1286 +       spin_lock_init(&sc->debug.samp_lock);
1287 +#endif
1288         tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
1289         tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
1290                      (unsigned long)sc);
1291 --- a/drivers/net/wireless/ath/ath9k/hw.c
1292 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1293 @@ -1386,10 +1386,16 @@ static bool ath9k_hw_set_reset_reg(struc
1294  static bool ath9k_hw_chip_reset(struct ath_hw *ah,
1295                                 struct ath9k_channel *chan)
1296  {
1297 -       if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
1298 -               if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
1299 -                       return false;
1300 -       } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
1301 +       int reset_type = ATH9K_RESET_WARM;
1302 +
1303 +       if (AR_SREV_9280(ah)) {
1304 +               if (ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
1305 +                       reset_type = ATH9K_RESET_POWER_ON;
1306 +               else
1307 +                       reset_type = ATH9K_RESET_COLD;
1308 +       }
1309 +
1310 +       if (!ath9k_hw_set_reset_reg(ah, reset_type))
1311                 return false;
1312  
1313         if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1314 --- a/drivers/net/wireless/ath/ath5k/base.c
1315 +++ b/drivers/net/wireless/ath/ath5k/base.c
1316 @@ -2330,15 +2330,6 @@ ath5k_calibrate_work(struct work_struct 
1317                                         "got new rfgain, resetting\n");
1318                         ieee80211_queue_work(ah->hw, &ah->reset_work);
1319                 }
1320 -
1321 -               /* TODO: On full calibration we should stop TX here,
1322 -                * so that it doesn't interfere (mostly due to gain_f
1323 -                * calibration that messes with tx packets -see phy.c).
1324 -                *
1325 -                * NOTE: Stopping the queues from above is not enough
1326 -                * to stop TX but saves us from disconecting (at least
1327 -                * we don't lose packets). */
1328 -               ieee80211_stop_queues(ah->hw);
1329         } else
1330                 ah->ah_cal_mask |= AR5K_CALIBRATION_SHORT;
1331  
1332 @@ -2353,10 +2344,9 @@ ath5k_calibrate_work(struct work_struct 
1333                                 ah->curchan->center_freq));
1334  
1335         /* Clear calibration flags */
1336 -       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
1337 -               ieee80211_wake_queues(ah->hw);
1338 +       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL)
1339                 ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL;
1340 -       } else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
1341 +       else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
1342                 ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT;
1343  }
1344  
1345 --- a/drivers/net/wireless/ath/ath5k/phy.c
1346 +++ b/drivers/net/wireless/ath/ath5k/phy.c
1347 @@ -1871,31 +1871,15 @@ ath5k_hw_phy_calibrate(struct ath5k_hw *
1348                 ret = 0;
1349         }
1350  
1351 -       /* On full calibration do an AGC calibration and
1352 -        * request a PAPD probe for gainf calibration if
1353 -        * needed */
1354 -       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
1355 +       /* On full calibration request a PAPD probe for
1356 +        * gainf calibration if needed */
1357 +       if ((ah->ah_cal_mask & AR5K_CALIBRATION_FULL) &&
1358 +           (ah->ah_radio == AR5K_RF5111 ||
1359 +            ah->ah_radio == AR5K_RF5112) &&
1360 +           channel->hw_value != AR5K_MODE_11B)
1361 +               ath5k_hw_request_rfgain_probe(ah);
1362  
1363 -               AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL,
1364 -                                       AR5K_PHY_AGCCTL_CAL);
1365 -
1366 -               ret = ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
1367 -                       AR5K_PHY_AGCCTL_CAL | AR5K_PHY_AGCCTL_NF,
1368 -                       0, false);
1369 -               if (ret) {
1370 -                       ATH5K_ERR(ah,
1371 -                               "gain calibration timeout (%uMHz)\n",
1372 -                               channel->center_freq);
1373 -               }
1374 -
1375 -               if ((ah->ah_radio == AR5K_RF5111 ||
1376 -                       ah->ah_radio == AR5K_RF5112)
1377 -                       && (channel->hw_value != AR5K_MODE_11B))
1378 -                       ath5k_hw_request_rfgain_probe(ah);
1379 -       }
1380 -
1381 -       /* Update noise floor
1382 -        * XXX: Only do this after AGC calibration */
1383 +       /* Update noise floor */
1384         if (!(ah->ah_cal_mask & AR5K_CALIBRATION_NF))
1385                 ath5k_hw_update_noise_floor(ah);
1386  
1387 --- a/drivers/net/wireless/ath/ath9k/recv.c
1388 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1389 @@ -232,7 +232,6 @@ static void ath_rx_edma_cleanup(struct a
1390  static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
1391  {
1392         skb_queue_head_init(&rx_edma->rx_fifo);
1393 -       skb_queue_head_init(&rx_edma->rx_buffers);
1394         rx_edma->rx_fifo_hwsize = size;
1395  }
1396  
1397 @@ -658,7 +657,9 @@ static void ath_rx_ps(struct ath_softc *
1398  }
1399  
1400  static bool ath_edma_get_buffers(struct ath_softc *sc,
1401 -                                enum ath9k_rx_qtype qtype)
1402 +                                enum ath9k_rx_qtype qtype,
1403 +                                struct ath_rx_status *rs,
1404 +                                struct ath_buf **dest)
1405  {
1406         struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
1407         struct ath_hw *ah = sc->sc_ah;
1408 @@ -677,7 +678,7 @@ static bool ath_edma_get_buffers(struct 
1409         dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
1410                                 common->rx_bufsize, DMA_FROM_DEVICE);
1411  
1412 -       ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data);
1413 +       ret = ath9k_hw_process_rxdesc_edma(ah, rs, skb->data);
1414         if (ret == -EINPROGRESS) {
1415                 /*let device gain the buffer again*/
1416                 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
1417 @@ -690,20 +691,21 @@ static bool ath_edma_get_buffers(struct 
1418                 /* corrupt descriptor, skip this one and the following one */
1419                 list_add_tail(&bf->list, &sc->rx.rxbuf);
1420                 ath_rx_edma_buf_link(sc, qtype);
1421 -               skb = skb_peek(&rx_edma->rx_fifo);
1422 -               if (!skb)
1423 -                       return true;
1424  
1425 -               bf = SKB_CB_ATHBUF(skb);
1426 -               BUG_ON(!bf);
1427 +               skb = skb_peek(&rx_edma->rx_fifo);
1428 +               if (skb) {
1429 +                       bf = SKB_CB_ATHBUF(skb);
1430 +                       BUG_ON(!bf);
1431  
1432 -               __skb_unlink(skb, &rx_edma->rx_fifo);
1433 -               list_add_tail(&bf->list, &sc->rx.rxbuf);
1434 -               ath_rx_edma_buf_link(sc, qtype);
1435 -               return true;
1436 +                       __skb_unlink(skb, &rx_edma->rx_fifo);
1437 +                       list_add_tail(&bf->list, &sc->rx.rxbuf);
1438 +                       ath_rx_edma_buf_link(sc, qtype);
1439 +               } else {
1440 +                       bf = NULL;
1441 +               }
1442         }
1443 -       skb_queue_tail(&rx_edma->rx_buffers, skb);
1444  
1445 +       *dest = bf;
1446         return true;
1447  }
1448  
1449 @@ -711,18 +713,15 @@ static struct ath_buf *ath_edma_get_next
1450                                                 struct ath_rx_status *rs,
1451                                                 enum ath9k_rx_qtype qtype)
1452  {
1453 -       struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
1454 -       struct sk_buff *skb;
1455 -       struct ath_buf *bf;
1456 +       struct ath_buf *bf = NULL;
1457  
1458 -       while (ath_edma_get_buffers(sc, qtype));
1459 -       skb = __skb_dequeue(&rx_edma->rx_buffers);
1460 -       if (!skb)
1461 -               return NULL;
1462 +       while (ath_edma_get_buffers(sc, qtype, rs, &bf)) {
1463 +               if (!bf)
1464 +                       continue;
1465  
1466 -       bf = SKB_CB_ATHBUF(skb);
1467 -       ath9k_hw_process_rxdesc_edma(sc->sc_ah, rs, skb->data);
1468 -       return bf;
1469 +               return bf;
1470 +       }
1471 +       return NULL;
1472  }
1473  
1474  static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
1475 @@ -954,6 +953,7 @@ static void ath9k_process_rssi(struct at
1476         struct ath_softc *sc = hw->priv;
1477         struct ath_hw *ah = common->ah;
1478         int last_rssi;
1479 +       int rssi = rx_stats->rs_rssi;
1480  
1481         if (!rx_stats->is_mybeacon ||
1482             ((ah->opmode != NL80211_IFTYPE_STATION) &&
1483 @@ -965,13 +965,12 @@ static void ath9k_process_rssi(struct at
1484  
1485         last_rssi = sc->last_rssi;
1486         if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
1487 -               rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
1488 -                                             ATH_RSSI_EP_MULTIPLIER);
1489 -       if (rx_stats->rs_rssi < 0)
1490 -               rx_stats->rs_rssi = 0;
1491 +               rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
1492 +       if (rssi < 0)
1493 +               rssi = 0;
1494  
1495         /* Update Beacon RSSI, this is used by ANI. */
1496 -       ah->stats.avgbrssi = rx_stats->rs_rssi;
1497 +       ah->stats.avgbrssi = rssi;
1498  }
1499  
1500  /*
1501 @@ -1011,6 +1010,8 @@ static int ath9k_rx_skb_preprocess(struc
1502         rx_status->signal = ah->noise + rx_stats->rs_rssi;
1503         rx_status->antenna = rx_stats->rs_antenna;
1504         rx_status->flag |= RX_FLAG_MACTIME_MPDU;
1505 +       if (rx_stats->rs_moreaggr)
1506 +               rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
1507  
1508         return 0;
1509  }
1510 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1511 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1512 @@ -91,7 +91,7 @@ static void ath_beacon_setup(struct ath_
1513         info.txpower = MAX_RATE_POWER;
1514         info.keyix = ATH9K_TXKEYIX_INVALID;
1515         info.keytype = ATH9K_KEY_TYPE_CLEAR;
1516 -       info.flags = ATH9K_TXDESC_NOACK;
1517 +       info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_INTREQ;
1518  
1519         info.buf_addr[0] = bf->bf_buf_addr;
1520         info.buf_len[0] = roundup(skb->len, 4);
1521 @@ -355,7 +355,6 @@ void ath_beacon_tasklet(unsigned long da
1522         struct ath_common *common = ath9k_hw_common(ah);
1523         struct ath_buf *bf = NULL;
1524         struct ieee80211_vif *vif;
1525 -       struct ath_tx_status ts;
1526         bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1527         int slot;
1528         u32 bfaddr, bc = 0;
1529 @@ -462,11 +461,6 @@ void ath_beacon_tasklet(unsigned long da
1530                         ath9k_hw_txstart(ah, sc->beacon.beaconq);
1531  
1532                 sc->beacon.ast_be_xmit += bc;     /* XXX per-vif? */
1533 -               if (edma) {
1534 -                       spin_lock_bh(&sc->sc_pcu_lock);
1535 -                       ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts);
1536 -                       spin_unlock_bh(&sc->sc_pcu_lock);
1537 -               }
1538         }
1539  }
1540  
1541 --- a/drivers/net/wireless/ath/ath9k/mac.c
1542 +++ b/drivers/net/wireless/ath/ath9k/mac.c
1543 @@ -745,7 +745,11 @@ int ath9k_hw_beaconq_setup(struct ath_hw
1544         qi.tqi_aifs = 1;
1545         qi.tqi_cwmin = 0;
1546         qi.tqi_cwmax = 0;
1547 -       /* NB: don't enable any interrupts */
1548 +
1549 +       if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1550 +               qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE |
1551 +                               TXQ_FLAG_TXERRINT_ENABLE;
1552 +
1553         return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
1554  }
1555  EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
1556 --- a/drivers/net/wireless/ath/ath9k/main.c
1557 +++ b/drivers/net/wireless/ath/ath9k/main.c
1558 @@ -118,13 +118,15 @@ void ath9k_ps_restore(struct ath_softc *
1559         if (--sc->ps_usecount != 0)
1560                 goto unlock;
1561  
1562 -       if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
1563 +       if (sc->ps_flags & PS_WAIT_FOR_TX_ACK)
1564 +               goto unlock;
1565 +
1566 +       if (sc->ps_idle)
1567                 mode = ATH9K_PM_FULL_SLEEP;
1568         else if (sc->ps_enabled &&
1569                  !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
1570                               PS_WAIT_FOR_CAB |
1571 -                             PS_WAIT_FOR_PSPOLL_DATA |
1572 -                             PS_WAIT_FOR_TX_ACK)))
1573 +                             PS_WAIT_FOR_PSPOLL_DATA)))
1574                 mode = ATH9K_PM_NETWORK_SLEEP;
1575         else
1576                 goto unlock;
1577 @@ -2300,6 +2302,7 @@ static int ath9k_tx_last_beacon(struct i
1578         struct ath_vif *avp;
1579         struct ath_buf *bf;
1580         struct ath_tx_status ts;
1581 +       bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1582         int status;
1583  
1584         vif = sc->beacon.bslot[0];
1585 @@ -2310,7 +2313,7 @@ static int ath9k_tx_last_beacon(struct i
1586         if (!avp->is_bslot_active)
1587                 return 0;
1588  
1589 -       if (!sc->beacon.tx_processed) {
1590 +       if (!sc->beacon.tx_processed && !edma) {
1591                 tasklet_disable(&sc->bcon_tasklet);
1592  
1593                 bf = avp->av_bcbuf;
1594 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1595 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1596 @@ -2296,9 +2296,12 @@ void ath_tx_edma_tasklet(struct ath_soft
1597                         break;
1598                 }
1599  
1600 -               /* Skip beacon completions */
1601 -               if (ts.qid == sc->beacon.beaconq)
1602 +               /* Process beacon completions separately */
1603 +               if (ts.qid == sc->beacon.beaconq) {
1604 +                       sc->beacon.tx_processed = true;
1605 +                       sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
1606                         continue;
1607 +               }
1608  
1609                 txq = &sc->tx.txq[ts.qid];
1610  
1611 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1612 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1613 @@ -299,7 +299,6 @@ struct ath_tx {
1614  
1615  struct ath_rx_edma {
1616         struct sk_buff_head rx_fifo;
1617 -       struct sk_buff_head rx_buffers;
1618         u32 rx_fifo_hwsize;
1619  };
1620