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)
7 - struct ar9003_txc *txc = (struct ar9003_txc *) ds;
8 struct ar9003_txs *ads;
11 @@ -336,11 +335,7 @@ static int ar9003_hw_proc_txdesc(struct
12 if ((status & AR_TxDone) == 0)
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;
20 + ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
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);
28 + ts->qid = MS(ads->ds_info, AR_TxQcuNum);
29 ts->desc_id = MS(ads->status1, AR_TxDescId);
30 ts->ts_tstamp = ads->status4;
32 @@ -440,20 +436,14 @@ int ath9k_hw_process_rxdesc_edma(struct
33 struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr;
36 - /* TODO: byte swap on big endian for ar9300_10 */
39 - if ((rxsp->status11 & AR_RxDone) == 0)
40 - return -EINPROGRESS;
42 - if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
44 + if ((rxsp->status11 & AR_RxDone) == 0)
45 + return -EINPROGRESS;
47 - if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
48 - return -EINPROGRESS;
49 + if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
54 + if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
55 + return -EINPROGRESS;
59 @@ -510,7 +500,11 @@ int ath9k_hw_process_rxdesc_edma(struct
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);
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;
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;
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
89 struct ieee80211_sta *sta;
90 struct carl9170_sta_info *sta_info;
91 + struct ieee80211_tx_info *tx_info;
94 sta = __carl9170_get_tx_sta(ar, skb);
95 @@ -1243,12 +1244,13 @@ static bool carl9170_tx_ps_drop(struct a
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);
103 + if (unlikely(sta_info->sleeping) &&
104 + !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
105 + IEEE80211_TX_CTL_CLEAR_PS_FILT))) {
108 - tx_info = IEEE80211_SKB_CB(skb);
109 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
110 atomic_dec(&ar->tx_ampdu_upload);
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;
117 if (sta_priv && sta_priv->asleep &&
118 - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
119 + (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
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;
128 if (sta_priv && sta_priv->asleep &&
129 - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
130 + (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
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,
136 * For now set the counter to just 1 since we do not
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.
143 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
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;
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;
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)
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)
196 enum mac80211_rx_flags {
197 RX_FLAG_MMIC_ERROR = 1<<0,
198 @@ -672,6 +674,7 @@ enum mac80211_rx_flags {
200 RX_FLAG_40MHZ = 1<<10,
201 RX_FLAG_SHORT_GI = 1<<11,
202 + RX_FLAG_NO_SIGNAL_VAL = 1<<12,
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.
219 + * Additionally, non-bufferable MMPDUs can also be transmitted by
220 + * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them.
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);
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)
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" : ""
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_
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;
290 u32 hw_reconf_flags = 0;
291 @@ -309,28 +308,6 @@ static int ieee80211_do_open(struct net_
293 set_bit(SDATA_STATE_RUNNING, &sdata->state);
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,
301 - goto err_del_interface;
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);
308 - res = sta_info_insert(sta);
310 - /* STA has been freed */
311 - goto err_del_interface;
314 - rate_control_rate_init(sta);
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);
325 - drv_remove_interface(local, sdata);
328 if (!local->open_count)
330 @@ -722,6 +698,70 @@ static void ieee80211_if_setup(struct ne
331 dev->destructor = free_netdev;
334 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
335 + struct sk_buff *skb)
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;
346 + enum ieee80211_band band = local->hw.conf.channel->band;
347 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
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;
353 + if (stype != IEEE80211_STYPE_BEACON)
356 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
357 + if (baselen > skb->len)
360 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
361 + skb->len - baselen, &elems);
363 + rates = ieee80211_sta_get_rates(local, &elems, band);
367 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
371 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
379 + sta->last_rx = jiffies;
380 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
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);
386 + if (elems.wmm_param)
387 + set_sta_flag(sta, WLAN_STA_WME);
390 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
391 + rate_control_rate_init(sta);
392 + sta_info_insert_rcu(sta);
398 static void ieee80211_iface_work(struct work_struct *work)
400 struct ieee80211_sub_if_data *sdata =
401 @@ -826,6 +866,9 @@ static void ieee80211_iface_work(struct
403 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
405 + case NL80211_IFTYPE_WDS:
406 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
409 WARN(1, "frame for unexpected interface type");
411 --- a/net/mac80211/rx.c
412 +++ b/net/mac80211/rx.c
413 @@ -177,7 +177,8 @@ ieee80211_add_rx_radiotap_header(struct
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;
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;
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;
438 @@ -1309,8 +1310,10 @@ ieee80211_rx_h_sta_process(struct ieee80
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);
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)
459 @@ -2336,7 +2340,7 @@ ieee80211_rx_h_action(struct ieee80211_r
460 if (sdata->vif.type != NL80211_IFTYPE_STATION)
463 - if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN))
464 + if (compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid))
468 @@ -2492,14 +2496,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
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;
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 */
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
489 case NL80211_IFTYPE_WDS:
490 - if (bssid || !ieee80211_is_data(hdr->frame_control))
492 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
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))
499 + } else if (!ieee80211_is_beacon(hdr->frame_control))
504 /* should never get here */
505 --- a/net/mac80211/sta_info.c
506 +++ b/net/mac80211/sta_info.c
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));
518 if (sta->sdata == sdata &&
519 - memcmp(sta->sta.addr, addr, ETH_ALEN) == 0)
520 + compare_ether_addr(sta->sta.addr, addr) == 0)
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
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)
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.
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;
542 @@ -1177,7 +1178,7 @@ ieee80211_sta_ps_deliver_response(struct
543 * STA may still remain is PS mode after this frame
546 - info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE;
547 + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
550 * Use MoreData flag to indicate whether there are
551 --- a/net/mac80211/sta_info.h
552 +++ b/net/mac80211/sta_info.h
554 #include <linux/if_ether.h>
555 #include <linux/workqueue.h>
556 #include <linux/average.h>
557 +#include <linux/etherdevice.h>
562 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
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 {
571 WLAN_STA_SHORT_PREAMBLE,
574 WLAN_STA_CLEAR_PS_FILT,
577 @@ -489,7 +488,7 @@ void for_each_sta_info_type_check(struct
578 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL \
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)
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;
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))
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);
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;
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 @@ -1060,6 +1065,7 @@ static bool ieee80211_tx_prep_agg(struct
621 bool reset_agg_timer = false;
622 + struct sk_buff *purge_skb = NULL;
624 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
625 info->flags |= IEEE80211_TX_CTL_AMPDU;
626 @@ -1101,8 +1107,13 @@ static bool ieee80211_tx_prep_agg(struct
627 info->control.vif = &tx->sdata->vif;
628 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
629 __skb_queue_tail(&tid_tx->pending, skb);
630 + if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER)
631 + purge_skb = __skb_dequeue(&tid_tx->pending);
633 spin_unlock(&tx->sta->lock);
636 + dev_kfree_skb(purge_skb);
639 /* reset session timer */
640 --- a/net/mac80211/ieee80211_i.h
641 +++ b/net/mac80211/ieee80211_i.h
642 @@ -480,7 +480,7 @@ struct ieee80211_if_ibss {
646 - u8 bssid[ETH_ALEN];
647 + u8 bssid[ETH_ALEN] __aligned(2);
648 u8 ssid[IEEE80211_MAX_SSID_LEN];
651 --- a/net/mac80211/ibss.c
652 +++ b/net/mac80211/ibss.c
653 @@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(st
654 skb_reset_tail_pointer(skb);
655 skb_reserve(skb, sdata->local->hw.extra_tx_headroom);
657 - if (memcmp(ifibss->bssid, bssid, ETH_ALEN))
658 + if (compare_ether_addr(ifibss->bssid, bssid))
659 sta_info_flush(sdata->local, sdata);
661 /* if merging, indicate to driver that we leave the old IBSS */
662 @@ -403,7 +403,7 @@ static void ieee80211_rx_bss_info(struct
665 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
666 - memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) {
667 + compare_ether_addr(mgmt->bssid, sdata->u.ibss.bssid) == 0) {
670 sta = sta_info_get(sdata, mgmt->sa);
671 @@ -508,7 +508,7 @@ static void ieee80211_rx_bss_info(struct
675 - if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0)
676 + if (compare_ether_addr(cbss->bssid, sdata->u.ibss.bssid) == 0)
679 if (rx_status->flag & RX_FLAG_MACTIME_MPDU) {
680 @@ -831,8 +831,8 @@ static void ieee80211_rx_mgmt_probe_req(
681 if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da))
684 - if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 &&
685 - memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0)
686 + if (compare_ether_addr(mgmt->bssid, ifibss->bssid) != 0 &&
687 + !is_broadcast_ether_addr(mgmt->bssid))
690 end = ((u8 *) mgmt) + len;
691 --- a/net/mac80211/mesh.c
692 +++ b/net/mac80211/mesh.c
693 @@ -204,7 +204,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80
694 kmem_cache_free(rm_cache, p);
696 } else if ((seqnum == p->seqnum) &&
697 - (memcmp(sa, p->sa, ETH_ALEN) == 0))
698 + (compare_ether_addr(sa, p->sa) == 0))
702 --- a/net/mac80211/mesh_hwmp.c
703 +++ b/net/mac80211/mesh_hwmp.c
707 #include <linux/slab.h>
708 +#include <linux/etherdevice.h>
709 #include <asm/unaligned.h>
712 @@ -419,7 +420,7 @@ static u32 hwmp_route_info_get(struct ie
713 new_metric = MAX_METRIC;
714 exp_time = TU_TO_EXP_TIME(orig_lifetime);
716 - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) {
717 + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) {
718 /* This MP is the originator, we are not interested in this
719 * frame, except for updating transmitter's path info.
721 @@ -469,7 +470,7 @@ static u32 hwmp_route_info_get(struct ie
723 /* Update and check transmitter routing info */
725 - if (memcmp(orig_addr, ta, ETH_ALEN) == 0)
726 + if (compare_ether_addr(orig_addr, ta) == 0)
730 @@ -529,7 +530,7 @@ static void hwmp_preq_frame_process(stru
732 mhwmp_dbg("received PREQ from %pM", orig_addr);
734 - if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) {
735 + if (compare_ether_addr(target_addr, sdata->vif.addr) == 0) {
736 mhwmp_dbg("PREQ is for us");
739 @@ -624,7 +625,7 @@ static void hwmp_prep_frame_process(stru
740 mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem));
742 orig_addr = PREP_IE_ORIG_ADDR(prep_elem);
743 - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
744 + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
745 /* destination, no forwarding required */
748 @@ -694,10 +695,12 @@ static void hwmp_perr_frame_process(stru
750 mpath = mesh_path_lookup(target_addr, sdata);
752 + struct sta_info *sta;
754 spin_lock_bh(&mpath->state_lock);
755 + sta = next_hop_deref_protected(mpath);
756 if (mpath->flags & MESH_PATH_ACTIVE &&
757 - memcmp(ta, next_hop_deref_protected(mpath)->sta.addr,
759 + compare_ether_addr(ta, sta->sta.addr) == 0 &&
760 (!(mpath->flags & MESH_PATH_SN_VALID) ||
761 SN_GT(target_sn, mpath->sn))) {
762 mpath->flags &= ~MESH_PATH_ACTIVE;
763 @@ -739,7 +742,7 @@ static void hwmp_rann_frame_process(stru
764 metric = rann->rann_metric;
766 /* Ignore our own RANNs */
767 - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
768 + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
771 mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr,
772 @@ -1064,7 +1067,7 @@ int mesh_nexthop_lookup(struct sk_buff *
773 if (time_after(jiffies,
775 msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) &&
776 - !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) &&
777 + !compare_ether_addr(sdata->vif.addr, hdr->addr4) &&
778 !(mpath->flags & MESH_PATH_RESOLVING) &&
779 !(mpath->flags & MESH_PATH_FIXED))
780 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH);
781 --- a/net/mac80211/mesh_pathtbl.c
782 +++ b/net/mac80211/mesh_pathtbl.c
783 @@ -350,7 +350,7 @@ static struct mesh_path *mpath_lookup(st
784 hlist_for_each_entry_rcu(node, n, bucket, list) {
786 if (mpath->sdata == sdata &&
787 - memcmp(dst, mpath->dst, ETH_ALEN) == 0) {
788 + compare_ether_addr(dst, mpath->dst) == 0) {
789 if (MPATH_EXPIRED(mpath)) {
790 spin_lock_bh(&mpath->state_lock);
791 mpath->flags &= ~MESH_PATH_ACTIVE;
792 @@ -525,7 +525,7 @@ int mesh_path_add(u8 *dst, struct ieee80
796 - if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
797 + if (compare_ether_addr(dst, sdata->vif.addr) == 0)
798 /* never add ourselves as neighbours */
801 @@ -566,7 +566,8 @@ int mesh_path_add(u8 *dst, struct ieee80
803 hlist_for_each_entry(node, n, bucket, list) {
805 - if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
806 + if (mpath->sdata == sdata &&
807 + compare_ether_addr(dst, mpath->dst) == 0)
811 @@ -657,7 +658,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struc
815 - if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
816 + if (compare_ether_addr(dst, sdata->vif.addr) == 0)
817 /* never add ourselves as neighbours */
820 @@ -694,7 +695,8 @@ int mpp_path_add(u8 *dst, u8 *mpp, struc
822 hlist_for_each_entry(node, n, bucket, list) {
824 - if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
825 + if (mpath->sdata == sdata &&
826 + compare_ether_addr(dst, mpath->dst) == 0)
830 @@ -887,7 +889,7 @@ int mesh_path_del(u8 *addr, struct ieee8
831 hlist_for_each_entry(node, n, bucket, list) {
833 if (mpath->sdata == sdata &&
834 - memcmp(addr, mpath->dst, ETH_ALEN) == 0) {
835 + compare_ether_addr(addr, mpath->dst) == 0) {
836 __mesh_path_del(tbl, node);
839 --- a/net/mac80211/mlme.c
840 +++ b/net/mac80211/mlme.c
841 @@ -1812,7 +1812,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_
843 memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
845 - if (memcmp(bssid, mgmt->bssid, ETH_ALEN))
846 + if (compare_ether_addr(bssid, mgmt->bssid))
849 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
850 @@ -1893,7 +1893,7 @@ ieee80211_rx_mgmt_deauth(struct ieee8021
853 if (!ifmgd->associated ||
854 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
855 + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
858 bssid = ifmgd->associated->bssid;
859 @@ -1925,7 +1925,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80
862 if (!ifmgd->associated ||
863 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
864 + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
867 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
868 @@ -2190,7 +2190,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee
872 - if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN))
873 + if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid))
877 @@ -2278,8 +2278,8 @@ static void ieee80211_rx_bss_info(struct
878 bool need_ps = false;
880 if (sdata->u.mgd.associated &&
881 - memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid,
883 + compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid)
885 bss = (void *)sdata->u.mgd.associated->priv;
886 /* not previously set so we may need to recalc */
887 need_ps = !bss->dtim_period;
888 @@ -2334,7 +2334,7 @@ static void ieee80211_rx_mgmt_probe_resp
890 ASSERT_MGD_MTX(ifmgd);
892 - if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN))
893 + if (compare_ether_addr(mgmt->da, sdata->vif.addr))
894 return; /* ignore ProbeResp to foreign address */
896 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
897 @@ -2347,11 +2347,12 @@ static void ieee80211_rx_mgmt_probe_resp
898 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
900 if (ifmgd->associated &&
901 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0)
902 + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0)
903 ieee80211_reset_ap_probe(sdata);
905 if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies &&
906 - memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) {
907 + compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid)
909 /* got probe response, continue with auth */
910 printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name);
911 ifmgd->auth_data->tries = 0;
912 @@ -2408,7 +2409,8 @@ static void ieee80211_rx_mgmt_beacon(str
915 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
916 - memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) {
917 + compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid)
919 ieee802_11_parse_elems(mgmt->u.beacon.variable,
920 len - baselen, &elems);
922 @@ -2423,7 +2425,7 @@ static void ieee80211_rx_mgmt_beacon(str
925 if (!ifmgd->associated ||
926 - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
927 + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
929 bssid = ifmgd->associated->bssid;
931 @@ -3285,7 +3287,7 @@ int ieee80211_mgd_assoc(struct ieee80211
934 /* keep sta info, bssid if matching */
935 - match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0;
936 + match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0;
937 ieee80211_destroy_auth_data(sdata, match);
940 @@ -3407,7 +3409,7 @@ int ieee80211_mgd_assoc(struct ieee80211
944 - WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN));
945 + WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid));
947 if (!bss->dtim_period &&
948 sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) {
949 @@ -3448,7 +3450,7 @@ int ieee80211_mgd_deauth(struct ieee8021
950 mutex_lock(&ifmgd->mtx);
952 if (ifmgd->associated &&
953 - memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) {
954 + compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0) {
955 ieee80211_set_disassoc(sdata, false, true);
957 } else if (ifmgd->auth_data) {
958 --- a/net/mac80211/status.c
959 +++ b/net/mac80211/status.c
963 #include <linux/export.h>
964 +#include <linux/etherdevice.h>
965 #include <net/mac80211.h>
966 #include <asm/unaligned.h>
967 #include "ieee80211_i.h"
968 @@ -377,7 +378,7 @@ void ieee80211_tx_status(struct ieee8021
970 for_each_sta_info(local, hdr->addr1, sta, tmp) {
971 /* skip wrong virtual interface */
972 - if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN))
973 + if (compare_ether_addr(hdr->addr2, sta->sdata->vif.addr))
976 if (info->flags & IEEE80211_TX_STATUS_EOSP)
977 --- a/net/wireless/mlme.c
978 +++ b/net/wireless/mlme.c
981 #include <linux/kernel.h>
982 #include <linux/module.h>
983 +#include <linux/etherdevice.h>
984 #include <linux/netdevice.h>
985 #include <linux/nl80211.h>
986 #include <linux/slab.h>
987 @@ -100,7 +101,7 @@ void __cfg80211_send_deauth(struct net_d
988 ASSERT_WDEV_LOCK(wdev);
990 if (wdev->current_bss &&
991 - memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
992 + compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) {
993 cfg80211_unhold_bss(wdev->current_bss);
994 cfg80211_put_bss(&wdev->current_bss->pub);
995 wdev->current_bss = NULL;
996 @@ -115,7 +116,7 @@ void __cfg80211_send_deauth(struct net_d
998 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
1000 - from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
1001 + from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0;
1002 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
1003 } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
1004 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
1005 @@ -154,7 +155,7 @@ void __cfg80211_send_disassoc(struct net
1008 if (wdev->current_bss &&
1009 - memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
1010 + compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) {
1011 cfg80211_sme_disassoc(dev, wdev->current_bss);
1012 cfg80211_unhold_bss(wdev->current_bss);
1013 cfg80211_put_bss(&wdev->current_bss->pub);
1014 @@ -165,7 +166,7 @@ void __cfg80211_send_disassoc(struct net
1016 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
1018 - from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
1019 + from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0;
1020 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
1022 EXPORT_SYMBOL(__cfg80211_send_disassoc);
1023 @@ -285,7 +286,7 @@ int __cfg80211_mlme_auth(struct cfg80211
1026 if (wdev->current_bss &&
1027 - memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0)
1028 + compare_ether_addr(bssid, wdev->current_bss->pub.bssid) == 0)
1031 memset(&req, 0, sizeof(req));
1032 @@ -362,7 +363,7 @@ int __cfg80211_mlme_assoc(struct cfg8021
1033 memset(&req, 0, sizeof(req));
1035 if (wdev->current_bss && prev_bssid &&
1036 - memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) {
1037 + compare_ether_addr(wdev->current_bss->pub.bssid, prev_bssid) == 0) {
1039 * Trying to reassociate: Allow this to proceed and let the old
1040 * association to be dropped when the new one is completed.
1041 @@ -446,7 +447,8 @@ int __cfg80211_mlme_deauth(struct cfg802
1043 if (local_state_change) {
1044 if (wdev->current_bss &&
1045 - memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
1046 + compare_ether_addr(wdev->current_bss->pub.bssid, bssid)
1048 cfg80211_unhold_bss(wdev->current_bss);
1049 cfg80211_put_bss(&wdev->current_bss->pub);
1050 wdev->current_bss = NULL;
1051 @@ -495,7 +497,7 @@ static int __cfg80211_mlme_disassoc(stru
1052 req.local_state_change = local_state_change;
1054 req.ie_len = ie_len;
1055 - if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0)
1056 + if (compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0)
1057 req.bss = &wdev->current_bss->pub;
1060 @@ -758,8 +760,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1064 - if (memcmp(wdev->current_bss->pub.bssid,
1065 - mgmt->bssid, ETH_ALEN)) {
1066 + if (compare_ether_addr(wdev->current_bss->pub.bssid,
1071 @@ -772,8 +774,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1074 /* for station, check that DA is the AP */
1075 - if (memcmp(wdev->current_bss->pub.bssid,
1076 - mgmt->da, ETH_ALEN)) {
1077 + if (compare_ether_addr(wdev->current_bss->pub.bssid,
1082 @@ -781,11 +783,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1083 case NL80211_IFTYPE_AP:
1084 case NL80211_IFTYPE_P2P_GO:
1085 case NL80211_IFTYPE_AP_VLAN:
1086 - if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN))
1087 + if (compare_ether_addr(mgmt->bssid, dev->dev_addr))
1090 case NL80211_IFTYPE_MESH_POINT:
1091 - if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) {
1092 + if (compare_ether_addr(mgmt->sa, mgmt->bssid)) {
1096 @@ -804,7 +806,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021
1100 - if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0)
1101 + if (compare_ether_addr(mgmt->sa, dev->dev_addr) != 0)
1104 /* Transmit the Action frame as requested by user space */
1105 --- a/net/wireless/scan.c
1106 +++ b/net/wireless/scan.c
1107 @@ -378,7 +378,7 @@ static int cmp_bss_core(struct cfg80211_
1108 b->len_information_elements);
1111 - return memcmp(a->bssid, b->bssid, ETH_ALEN);
1112 + return compare_ether_addr(a->bssid, b->bssid);
1115 static int cmp_bss(struct cfg80211_bss *a,
1116 --- a/drivers/net/wireless/ath/ath9k/Kconfig
1117 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
1118 @@ -81,6 +81,14 @@ config ATH9K_DFS_CERTIFIED
1119 developed. At this point enabling this option won't do anything
1120 except increase code size.
1122 +config ATH9K_MAC_DEBUG
1123 + bool "Atheros MAC statistics"
1124 + depends on ATH9K_DEBUGFS
1127 + This option enables collection of statistics for Rx/Tx status
1128 + data and some other MAC related statistics
1130 config ATH9K_RATE_CONTROL
1131 bool "Atheros ath9k rate control"
1133 --- a/drivers/net/wireless/ath/ath9k/debug.c
1134 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1135 @@ -818,6 +818,7 @@ void ath_debug_stat_tx(struct ath_softc
1136 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
1137 TX_STAT_INC(qnum, delim_underrun);
1139 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1140 spin_lock(&sc->debug.samp_lock);
1141 TX_SAMP_DBG(jiffies) = jiffies;
1142 TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
1143 @@ -844,6 +845,7 @@ void ath_debug_stat_tx(struct ath_softc
1145 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
1146 spin_unlock(&sc->debug.samp_lock);
1151 @@ -942,27 +944,6 @@ static ssize_t read_file_recv(struct fil
1152 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
1154 len += snprintf(buf + len, size - len,
1155 - "%22s : %10d\n", "RSSI-CTL0",
1156 - sc->debug.stats.rxstats.rs_rssi_ctl0);
1157 - len += snprintf(buf + len, size - len,
1158 - "%22s : %10d\n", "RSSI-CTL1",
1159 - sc->debug.stats.rxstats.rs_rssi_ctl1);
1160 - len += snprintf(buf + len, size - len,
1161 - "%22s : %10d\n", "RSSI-CTL2",
1162 - sc->debug.stats.rxstats.rs_rssi_ctl2);
1163 - len += snprintf(buf + len, size - len,
1164 - "%22s : %10d\n", "RSSI-EXT0",
1165 - sc->debug.stats.rxstats.rs_rssi_ext0);
1166 - len += snprintf(buf + len, size - len,
1167 - "%22s : %10d\n", "RSSI-EXT1",
1168 - sc->debug.stats.rxstats.rs_rssi_ext1);
1169 - len += snprintf(buf + len, size - len,
1170 - "%22s : %10d\n", "RSSI-EXT2",
1171 - sc->debug.stats.rxstats.rs_rssi_ext2);
1172 - len += snprintf(buf + len, size - len,
1173 - "%22s : %10d\n", "Rx Antenna",
1174 - sc->debug.stats.rxstats.rs_antenna);
1175 - len += snprintf(buf + len, size - len,
1176 "%22s : %10u\n", "RX-Pkts-All",
1177 sc->debug.stats.rxstats.rx_pkts_all);
1178 len += snprintf(buf + len, size - len,
1179 @@ -1009,16 +990,7 @@ void ath_debug_stat_rx(struct ath_softc
1180 RX_PHY_ERR_INC(rs->rs_phyerr);
1183 - sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
1184 - sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
1185 - sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
1187 - sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
1188 - sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
1189 - sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
1191 - sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
1193 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1194 spin_lock(&sc->debug.samp_lock);
1195 RX_SAMP_DBG(jiffies) = jiffies;
1196 RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
1197 @@ -1035,6 +1007,8 @@ void ath_debug_stat_rx(struct ath_softc
1198 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1199 spin_unlock(&sc->debug.samp_lock);
1204 #undef RX_PHY_ERR_INC
1206 @@ -1278,6 +1252,8 @@ static const struct file_operations fops
1207 .llseek = default_llseek,
1210 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1212 void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1214 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1215 @@ -1551,6 +1527,7 @@ static const struct file_operations fops
1216 .llseek = default_llseek,
1221 int ath9k_init_debug(struct ath_hw *ah)
1223 @@ -1604,8 +1581,10 @@ int ath9k_init_debug(struct ath_hw *ah)
1225 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1226 &fops_modal_eeprom);
1227 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1228 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1232 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1233 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1234 --- a/drivers/net/wireless/ath/ath9k/debug.h
1235 +++ b/drivers/net/wireless/ath/ath9k/debug.h
1236 @@ -165,13 +165,6 @@ struct ath_rx_stats {
1237 u32 post_delim_crc_err;
1238 u32 decrypt_busy_err;
1239 u32 phy_err_stats[ATH9K_PHYERR_MAX];
1240 - int8_t rs_rssi_ctl0;
1241 - int8_t rs_rssi_ctl1;
1242 - int8_t rs_rssi_ctl2;
1243 - int8_t rs_rssi_ext0;
1244 - int8_t rs_rssi_ext1;
1245 - int8_t rs_rssi_ext2;
1249 enum ath_reset_type {
1250 @@ -235,16 +228,17 @@ struct ath9k_debug {
1251 struct dentry *debugfs_phy;
1253 struct ath_stats stats;
1254 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1255 spinlock_t samp_lock;
1256 struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
1263 int ath9k_init_debug(struct ath_hw *ah);
1265 -void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
1266 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
1267 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
1268 struct ath_tx_status *ts, struct ath_txq *txq,
1269 @@ -258,10 +252,6 @@ static inline int ath9k_init_debug(struc
1273 -static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1277 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
1278 enum ath9k_int status)
1280 @@ -282,4 +272,17 @@ static inline void ath_debug_stat_rx(str
1282 #endif /* CONFIG_ATH9K_DEBUGFS */
1284 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1286 +void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
1290 +static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1297 #endif /* DEBUG_H */
1298 --- a/drivers/net/wireless/ath/ath9k/init.c
1299 +++ b/drivers/net/wireless/ath/ath9k/init.c
1300 @@ -555,9 +555,11 @@ static int ath9k_init_softc(u16 devid, s
1301 mutex_init(&sc->mutex);
1302 #ifdef CONFIG_ATH9K_DEBUGFS
1303 spin_lock_init(&sc->nodes_lock);
1304 - spin_lock_init(&sc->debug.samp_lock);
1305 INIT_LIST_HEAD(&sc->nodes);
1307 +#ifdef CONFIG_ATH9K_MAC_DEBUG
1308 + spin_lock_init(&sc->debug.samp_lock);
1310 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
1311 tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
1313 --- a/drivers/net/wireless/ath/ath9k/hw.c
1314 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1315 @@ -1386,10 +1386,16 @@ static bool ath9k_hw_set_reset_reg(struc
1316 static bool ath9k_hw_chip_reset(struct ath_hw *ah,
1317 struct ath9k_channel *chan)
1319 - if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
1320 - if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
1322 - } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
1323 + int reset_type = ATH9K_RESET_WARM;
1325 + if (AR_SREV_9280(ah)) {
1326 + if (ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
1327 + reset_type = ATH9K_RESET_POWER_ON;
1329 + reset_type = ATH9K_RESET_COLD;
1332 + if (!ath9k_hw_set_reset_reg(ah, reset_type))
1335 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1336 --- a/drivers/net/wireless/ath/ath5k/base.c
1337 +++ b/drivers/net/wireless/ath/ath5k/base.c
1338 @@ -2330,15 +2330,6 @@ ath5k_calibrate_work(struct work_struct
1339 "got new rfgain, resetting\n");
1340 ieee80211_queue_work(ah->hw, &ah->reset_work);
1343 - /* TODO: On full calibration we should stop TX here,
1344 - * so that it doesn't interfere (mostly due to gain_f
1345 - * calibration that messes with tx packets -see phy.c).
1347 - * NOTE: Stopping the queues from above is not enough
1348 - * to stop TX but saves us from disconecting (at least
1349 - * we don't lose packets). */
1350 - ieee80211_stop_queues(ah->hw);
1352 ah->ah_cal_mask |= AR5K_CALIBRATION_SHORT;
1354 @@ -2353,10 +2344,9 @@ ath5k_calibrate_work(struct work_struct
1355 ah->curchan->center_freq));
1357 /* Clear calibration flags */
1358 - if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
1359 - ieee80211_wake_queues(ah->hw);
1360 + if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL)
1361 ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL;
1362 - } else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
1363 + else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
1364 ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT;
1367 --- a/drivers/net/wireless/ath/ath5k/phy.c
1368 +++ b/drivers/net/wireless/ath/ath5k/phy.c
1369 @@ -1871,31 +1871,15 @@ ath5k_hw_phy_calibrate(struct ath5k_hw *
1373 - /* On full calibration do an AGC calibration and
1374 - * request a PAPD probe for gainf calibration if
1376 - if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
1377 + /* On full calibration request a PAPD probe for
1378 + * gainf calibration if needed */
1379 + if ((ah->ah_cal_mask & AR5K_CALIBRATION_FULL) &&
1380 + (ah->ah_radio == AR5K_RF5111 ||
1381 + ah->ah_radio == AR5K_RF5112) &&
1382 + channel->hw_value != AR5K_MODE_11B)
1383 + ath5k_hw_request_rfgain_probe(ah);
1385 - AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL,
1386 - AR5K_PHY_AGCCTL_CAL);
1388 - ret = ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
1389 - AR5K_PHY_AGCCTL_CAL | AR5K_PHY_AGCCTL_NF,
1393 - "gain calibration timeout (%uMHz)\n",
1394 - channel->center_freq);
1397 - if ((ah->ah_radio == AR5K_RF5111 ||
1398 - ah->ah_radio == AR5K_RF5112)
1399 - && (channel->hw_value != AR5K_MODE_11B))
1400 - ath5k_hw_request_rfgain_probe(ah);
1403 - /* Update noise floor
1404 - * XXX: Only do this after AGC calibration */
1405 + /* Update noise floor */
1406 if (!(ah->ah_cal_mask & AR5K_CALIBRATION_NF))
1407 ath5k_hw_update_noise_floor(ah);
1409 --- a/drivers/net/wireless/ath/ath9k/recv.c
1410 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1411 @@ -232,7 +232,6 @@ static void ath_rx_edma_cleanup(struct a
1412 static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
1414 skb_queue_head_init(&rx_edma->rx_fifo);
1415 - skb_queue_head_init(&rx_edma->rx_buffers);
1416 rx_edma->rx_fifo_hwsize = size;
1419 @@ -658,7 +657,9 @@ static void ath_rx_ps(struct ath_softc *
1422 static bool ath_edma_get_buffers(struct ath_softc *sc,
1423 - enum ath9k_rx_qtype qtype)
1424 + enum ath9k_rx_qtype qtype,
1425 + struct ath_rx_status *rs,
1426 + struct ath_buf **dest)
1428 struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
1429 struct ath_hw *ah = sc->sc_ah;
1430 @@ -677,7 +678,7 @@ static bool ath_edma_get_buffers(struct
1431 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
1432 common->rx_bufsize, DMA_FROM_DEVICE);
1434 - ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data);
1435 + ret = ath9k_hw_process_rxdesc_edma(ah, rs, skb->data);
1436 if (ret == -EINPROGRESS) {
1437 /*let device gain the buffer again*/
1438 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
1439 @@ -690,20 +691,21 @@ static bool ath_edma_get_buffers(struct
1440 /* corrupt descriptor, skip this one and the following one */
1441 list_add_tail(&bf->list, &sc->rx.rxbuf);
1442 ath_rx_edma_buf_link(sc, qtype);
1443 - skb = skb_peek(&rx_edma->rx_fifo);
1447 - bf = SKB_CB_ATHBUF(skb);
1449 + skb = skb_peek(&rx_edma->rx_fifo);
1451 + bf = SKB_CB_ATHBUF(skb);
1454 - __skb_unlink(skb, &rx_edma->rx_fifo);
1455 - list_add_tail(&bf->list, &sc->rx.rxbuf);
1456 - ath_rx_edma_buf_link(sc, qtype);
1458 + __skb_unlink(skb, &rx_edma->rx_fifo);
1459 + list_add_tail(&bf->list, &sc->rx.rxbuf);
1460 + ath_rx_edma_buf_link(sc, qtype);
1465 - skb_queue_tail(&rx_edma->rx_buffers, skb);
1471 @@ -711,18 +713,15 @@ static struct ath_buf *ath_edma_get_next
1472 struct ath_rx_status *rs,
1473 enum ath9k_rx_qtype qtype)
1475 - struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
1476 - struct sk_buff *skb;
1477 - struct ath_buf *bf;
1478 + struct ath_buf *bf = NULL;
1480 - while (ath_edma_get_buffers(sc, qtype));
1481 - skb = __skb_dequeue(&rx_edma->rx_buffers);
1484 + while (ath_edma_get_buffers(sc, qtype, rs, &bf)) {
1488 - bf = SKB_CB_ATHBUF(skb);
1489 - ath9k_hw_process_rxdesc_edma(sc->sc_ah, rs, skb->data);
1496 static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
1497 @@ -954,6 +953,7 @@ static void ath9k_process_rssi(struct at
1498 struct ath_softc *sc = hw->priv;
1499 struct ath_hw *ah = common->ah;
1501 + int rssi = rx_stats->rs_rssi;
1503 if (!rx_stats->is_mybeacon ||
1504 ((ah->opmode != NL80211_IFTYPE_STATION) &&
1505 @@ -965,13 +965,12 @@ static void ath9k_process_rssi(struct at
1507 last_rssi = sc->last_rssi;
1508 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
1509 - rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
1510 - ATH_RSSI_EP_MULTIPLIER);
1511 - if (rx_stats->rs_rssi < 0)
1512 - rx_stats->rs_rssi = 0;
1513 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
1517 /* Update Beacon RSSI, this is used by ANI. */
1518 - ah->stats.avgbrssi = rx_stats->rs_rssi;
1519 + ah->stats.avgbrssi = rssi;
1523 @@ -988,8 +987,6 @@ static int ath9k_rx_skb_preprocess(struc
1525 struct ath_hw *ah = common->ah;
1527 - memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
1530 * everything but the rate is checked here, the rate check is done
1531 * separately to avoid doing two lookups for a rate for each frame.
1532 @@ -1011,6 +1008,8 @@ static int ath9k_rx_skb_preprocess(struc
1533 rx_status->signal = ah->noise + rx_stats->rs_rssi;
1534 rx_status->antenna = rx_stats->rs_antenna;
1535 rx_status->flag |= RX_FLAG_MACTIME_MPDU;
1536 + if (rx_stats->rs_moreaggr)
1537 + rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
1541 @@ -1845,6 +1844,8 @@ int ath_rx_tasklet(struct ath_softc *sc,
1542 if (sc->sc_flags & SC_OP_RXFLUSH)
1543 goto requeue_drop_frag;
1545 + memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1547 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1548 if (rs.rs_tstamp > tsf_lower &&
1549 unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
1550 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1551 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1552 @@ -91,7 +91,7 @@ static void ath_beacon_setup(struct ath_
1553 info.txpower = MAX_RATE_POWER;
1554 info.keyix = ATH9K_TXKEYIX_INVALID;
1555 info.keytype = ATH9K_KEY_TYPE_CLEAR;
1556 - info.flags = ATH9K_TXDESC_NOACK;
1557 + info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_INTREQ;
1559 info.buf_addr[0] = bf->bf_buf_addr;
1560 info.buf_len[0] = roundup(skb->len, 4);
1561 @@ -355,7 +355,6 @@ void ath_beacon_tasklet(unsigned long da
1562 struct ath_common *common = ath9k_hw_common(ah);
1563 struct ath_buf *bf = NULL;
1564 struct ieee80211_vif *vif;
1565 - struct ath_tx_status ts;
1566 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1569 @@ -462,11 +461,6 @@ void ath_beacon_tasklet(unsigned long da
1570 ath9k_hw_txstart(ah, sc->beacon.beaconq);
1572 sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */
1574 - spin_lock_bh(&sc->sc_pcu_lock);
1575 - ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts);
1576 - spin_unlock_bh(&sc->sc_pcu_lock);
1581 --- a/drivers/net/wireless/ath/ath9k/mac.c
1582 +++ b/drivers/net/wireless/ath/ath9k/mac.c
1583 @@ -745,7 +745,11 @@ int ath9k_hw_beaconq_setup(struct ath_hw
1587 - /* NB: don't enable any interrupts */
1589 + if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
1590 + qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE |
1591 + TXQ_FLAG_TXERRINT_ENABLE;
1593 return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
1595 EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
1596 --- a/drivers/net/wireless/ath/ath9k/main.c
1597 +++ b/drivers/net/wireless/ath/ath9k/main.c
1598 @@ -118,13 +118,15 @@ void ath9k_ps_restore(struct ath_softc *
1599 if (--sc->ps_usecount != 0)
1602 - if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
1603 + if (sc->ps_flags & PS_WAIT_FOR_TX_ACK)
1607 mode = ATH9K_PM_FULL_SLEEP;
1608 else if (sc->ps_enabled &&
1609 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
1611 - PS_WAIT_FOR_PSPOLL_DATA |
1612 - PS_WAIT_FOR_TX_ACK)))
1613 + PS_WAIT_FOR_PSPOLL_DATA)))
1614 mode = ATH9K_PM_NETWORK_SLEEP;
1617 @@ -1955,6 +1957,7 @@ static void ath9k_config_bss(struct ath_
1618 sc->sc_flags &= ~SC_OP_ANI_RUN;
1619 del_timer_sync(&common->ani.timer);
1620 memset(&sc->caldata, 0, sizeof(sc->caldata));
1621 + ath9k_hw_ani_init(sc->sc_ah);
1625 @@ -2300,6 +2303,7 @@ static int ath9k_tx_last_beacon(struct i
1626 struct ath_vif *avp;
1628 struct ath_tx_status ts;
1629 + bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1632 vif = sc->beacon.bslot[0];
1633 @@ -2310,7 +2314,7 @@ static int ath9k_tx_last_beacon(struct i
1634 if (!avp->is_bslot_active)
1637 - if (!sc->beacon.tx_processed) {
1638 + if (!sc->beacon.tx_processed && !edma) {
1639 tasklet_disable(&sc->bcon_tasklet);
1642 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1643 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1644 @@ -2296,9 +2296,12 @@ void ath_tx_edma_tasklet(struct ath_soft
1648 - /* Skip beacon completions */
1649 - if (ts.qid == sc->beacon.beaconq)
1650 + /* Process beacon completions separately */
1651 + if (ts.qid == sc->beacon.beaconq) {
1652 + sc->beacon.tx_processed = true;
1653 + sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
1657 txq = &sc->tx.txq[ts.qid];
1659 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1660 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1661 @@ -299,7 +299,6 @@ struct ath_tx {
1663 struct ath_rx_edma {
1664 struct sk_buff_head rx_fifo;
1665 - struct sk_buff_head rx_buffers;
1669 --- a/drivers/net/wireless/ath/ath9k/ani.c
1670 +++ b/drivers/net/wireless/ath/ath9k/ani.c
1671 @@ -46,8 +46,8 @@ static const struct ani_ofdm_level_entry
1672 { 5, 4, 1 }, /* lvl 5 */
1673 { 6, 5, 1 }, /* lvl 6 */
1674 { 7, 6, 1 }, /* lvl 7 */
1675 - { 7, 7, 1 }, /* lvl 8 */
1676 - { 7, 8, 0 } /* lvl 9 */
1677 + { 7, 6, 0 }, /* lvl 8 */
1678 + { 7, 7, 0 } /* lvl 9 */
1680 #define ATH9K_ANI_OFDM_NUM_LEVEL \
1681 ARRAY_SIZE(ofdm_level_table)
1682 @@ -91,8 +91,8 @@ static const struct ani_cck_level_entry
1683 { 4, 0 }, /* lvl 4 */
1684 { 5, 0 }, /* lvl 5 */
1685 { 6, 0 }, /* lvl 6 */
1686 - { 7, 0 }, /* lvl 7 (only for high rssi) */
1687 - { 8, 0 } /* lvl 8 (only for high rssi) */
1688 + { 6, 0 }, /* lvl 7 (only for high rssi) */
1689 + { 7, 0 } /* lvl 8 (only for high rssi) */
1692 #define ATH9K_ANI_CCK_NUM_LEVEL \
1693 @@ -290,16 +290,9 @@ static void ath9k_hw_set_ofdm_nil(struct
1694 ATH9K_ANI_FIRSTEP_LEVEL,
1695 entry_ofdm->fir_step_level);
1697 - if ((ah->opmode != NL80211_IFTYPE_STATION &&
1698 - ah->opmode != NL80211_IFTYPE_ADHOC) ||
1699 - aniState->noiseFloor <= aniState->rssiThrHigh) {
1700 - if (aniState->ofdmWeakSigDetectOff)
1701 - /* force on ofdm weak sig detect */
1702 - ath9k_hw_ani_control(ah,
1703 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
1705 - else if (aniState->ofdmWeakSigDetectOff ==
1706 - entry_ofdm->ofdm_weak_signal_on)
1707 + if ((aniState->noiseFloor >= aniState->rssiThrHigh) &&
1708 + (aniState->ofdmWeakSigDetectOff !=
1709 + entry_ofdm->ofdm_weak_signal_on)) {
1710 ath9k_hw_ani_control(ah,
1711 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
1712 entry_ofdm->ofdm_weak_signal_on);
1713 @@ -717,26 +710,30 @@ void ath9k_hw_ani_monitor(struct ath_hw
1714 ofdmPhyErrRate, aniState->cckNoiseImmunityLevel,
1715 cckPhyErrRate, aniState->ofdmsTurn);
1717 - if (aniState->listenTime > 5 * ah->aniperiod) {
1718 - if (ofdmPhyErrRate <= ah->config.ofdm_trig_low &&
1719 - cckPhyErrRate <= ah->config.cck_trig_low) {
1720 + if (aniState->listenTime > ah->aniperiod) {
1721 + if (cckPhyErrRate < ah->config.cck_trig_low &&
1722 + ((ofdmPhyErrRate < ah->config.ofdm_trig_low &&
1723 + aniState->ofdmNoiseImmunityLevel <
1724 + ATH9K_ANI_OFDM_DEF_LEVEL) ||
1725 + (ofdmPhyErrRate < ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI &&
1726 + aniState->ofdmNoiseImmunityLevel >=
1727 + ATH9K_ANI_OFDM_DEF_LEVEL))) {
1728 ath9k_hw_ani_lower_immunity(ah);
1729 aniState->ofdmsTurn = !aniState->ofdmsTurn;
1731 - ath9k_ani_restart(ah);
1732 - } else if (aniState->listenTime > ah->aniperiod) {
1733 - /* check to see if need to raise immunity */
1734 - if (ofdmPhyErrRate > ah->config.ofdm_trig_high &&
1735 - (cckPhyErrRate <= ah->config.cck_trig_high ||
1736 - aniState->ofdmsTurn)) {
1737 + } else if ((ofdmPhyErrRate > ah->config.ofdm_trig_high &&
1738 + aniState->ofdmNoiseImmunityLevel >=
1739 + ATH9K_ANI_OFDM_DEF_LEVEL) ||
1741 + ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI &&
1742 + aniState->ofdmNoiseImmunityLevel <
1743 + ATH9K_ANI_OFDM_DEF_LEVEL)) {
1744 ath9k_hw_ani_ofdm_err_trigger(ah);
1745 - ath9k_ani_restart(ah);
1746 aniState->ofdmsTurn = false;
1747 } else if (cckPhyErrRate > ah->config.cck_trig_high) {
1748 ath9k_hw_ani_cck_err_trigger(ah);
1749 - ath9k_ani_restart(ah);
1750 aniState->ofdmsTurn = true;
1752 + ath9k_ani_restart(ah);
1755 EXPORT_SYMBOL(ath9k_hw_ani_monitor);
1756 @@ -911,3 +908,4 @@ void ath9k_hw_ani_init(struct ath_hw *ah
1757 ath9k_ani_restart(ah);
1758 ath9k_enable_mib_counters(ah);
1760 +EXPORT_SYMBOL(ath9k_hw_ani_init);
1761 --- a/drivers/net/wireless/ath/ath9k/ani.h
1762 +++ b/drivers/net/wireless/ath/ath9k/ani.h
1765 /* units are errors per second */
1766 #define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500
1767 -#define ATH9K_ANI_OFDM_TRIG_HIGH_NEW 1000
1768 +#define ATH9K_ANI_OFDM_TRIG_HIGH_NEW 3500
1769 +#define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
1771 /* units are errors per second */
1772 #define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200
1773 #define ATH9K_ANI_OFDM_TRIG_LOW_NEW 400
1774 +#define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
1776 /* units are errors per second */
1777 #define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200
1779 #define ATH9K_ANI_RSSI_THR_LOW 7
1781 #define ATH9K_ANI_PERIOD_OLD 100
1782 -#define ATH9K_ANI_PERIOD_NEW 1000
1783 +#define ATH9K_ANI_PERIOD_NEW 300
1786 #define ATH9K_ANI_POLLINTERVAL_OLD 100
1787 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
1788 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
1789 @@ -1056,46 +1056,8 @@ static bool ar5008_hw_ani_control_old(st
1792 case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
1793 - static const int m1ThreshLow[] = { 127, 50 };
1794 - static const int m2ThreshLow[] = { 127, 40 };
1795 - static const int m1Thresh[] = { 127, 0x4d };
1796 - static const int m2Thresh[] = { 127, 0x40 };
1797 - static const int m2CountThr[] = { 31, 16 };
1798 - static const int m2CountThrLow[] = { 63, 48 };
1799 u32 on = param ? 1 : 0;
1801 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1802 - AR_PHY_SFCORR_LOW_M1_THRESH_LOW,
1804 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1805 - AR_PHY_SFCORR_LOW_M2_THRESH_LOW,
1807 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1808 - AR_PHY_SFCORR_M1_THRESH,
1810 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1811 - AR_PHY_SFCORR_M2_THRESH,
1813 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1814 - AR_PHY_SFCORR_M2COUNT_THR,
1816 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1817 - AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW,
1818 - m2CountThrLow[on]);
1820 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1821 - AR_PHY_SFCORR_EXT_M1_THRESH_LOW,
1823 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1824 - AR_PHY_SFCORR_EXT_M2_THRESH_LOW,
1826 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1827 - AR_PHY_SFCORR_EXT_M1_THRESH,
1829 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1830 - AR_PHY_SFCORR_EXT_M2_THRESH,
1834 REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
1835 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
1836 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1837 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1838 @@ -824,55 +824,6 @@ static bool ar9003_hw_ani_control(struct
1839 * on == 0 means more noise imm
1841 u32 on = param ? 1 : 0;
1843 - * make register setting for default
1844 - * (weak sig detect ON) come from INI file
1846 - int m1ThreshLow = on ?
1847 - aniState->iniDef.m1ThreshLow : m1ThreshLow_off;
1848 - int m2ThreshLow = on ?
1849 - aniState->iniDef.m2ThreshLow : m2ThreshLow_off;
1850 - int m1Thresh = on ?
1851 - aniState->iniDef.m1Thresh : m1Thresh_off;
1852 - int m2Thresh = on ?
1853 - aniState->iniDef.m2Thresh : m2Thresh_off;
1854 - int m2CountThr = on ?
1855 - aniState->iniDef.m2CountThr : m2CountThr_off;
1856 - int m2CountThrLow = on ?
1857 - aniState->iniDef.m2CountThrLow : m2CountThrLow_off;
1858 - int m1ThreshLowExt = on ?
1859 - aniState->iniDef.m1ThreshLowExt : m1ThreshLowExt_off;
1860 - int m2ThreshLowExt = on ?
1861 - aniState->iniDef.m2ThreshLowExt : m2ThreshLowExt_off;
1862 - int m1ThreshExt = on ?
1863 - aniState->iniDef.m1ThreshExt : m1ThreshExt_off;
1864 - int m2ThreshExt = on ?
1865 - aniState->iniDef.m2ThreshExt : m2ThreshExt_off;
1867 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1868 - AR_PHY_SFCORR_LOW_M1_THRESH_LOW,
1870 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1871 - AR_PHY_SFCORR_LOW_M2_THRESH_LOW,
1873 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1874 - AR_PHY_SFCORR_M1_THRESH, m1Thresh);
1875 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1876 - AR_PHY_SFCORR_M2_THRESH, m2Thresh);
1877 - REG_RMW_FIELD(ah, AR_PHY_SFCORR,
1878 - AR_PHY_SFCORR_M2COUNT_THR, m2CountThr);
1879 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
1880 - AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW,
1883 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1884 - AR_PHY_SFCORR_EXT_M1_THRESH_LOW, m1ThreshLowExt);
1885 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1886 - AR_PHY_SFCORR_EXT_M2_THRESH_LOW, m2ThreshLowExt);
1887 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1888 - AR_PHY_SFCORR_EXT_M1_THRESH, m1ThreshExt);
1889 - REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT,
1890 - AR_PHY_SFCORR_EXT_M2_THRESH, m2ThreshExt);
1893 REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
1894 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1895 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1896 @@ -430,10 +430,14 @@ void rt2x00lib_txdone(struct queue_entry
1898 * If the data queue was below the threshold before the txdone
1899 * handler we must make sure the packet queue in the mac80211 stack
1900 - * is reenabled when the txdone handler has finished.
1901 + * is reenabled when the txdone handler has finished. This has to be
1902 + * serialized with rt2x00mac_tx(), otherwise we can wake up queue
1903 + * before it was stopped.
1905 + spin_lock_bh(&entry->queue->tx_lock);
1906 if (!rt2x00queue_threshold(entry->queue))
1907 rt2x00queue_unpause_queue(entry->queue);
1908 + spin_unlock_bh(&entry->queue->tx_lock);
1910 EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
1912 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1913 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1914 @@ -152,13 +152,22 @@ void rt2x00mac_tx(struct ieee80211_hw *h
1915 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
1919 + * Pausing queue has to be serialized with rt2x00lib_txdone(). Note
1920 + * we should not use spin_lock_bh variant as bottom halve was already
1921 + * disabled before ieee80211_xmit() call.
1923 + spin_lock(&queue->tx_lock);
1924 if (rt2x00queue_threshold(queue))
1925 rt2x00queue_pause_queue(queue);
1926 + spin_unlock(&queue->tx_lock);
1931 + spin_lock(&queue->tx_lock);
1932 rt2x00queue_pause_queue(queue);
1933 + spin_unlock(&queue->tx_lock);
1935 ieee80211_free_txskb(hw, skb);
1937 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1938 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1939 @@ -619,6 +619,9 @@ int rt2x00queue_write_tx_frame(struct da
1940 else if (test_bit(REQUIRE_DMA, &queue->rt2x00dev->cap_flags))
1941 rt2x00queue_align_frame(skb);
1944 + * That function must be called with bh disabled.
1946 spin_lock(&queue->tx_lock);
1948 if (unlikely(rt2x00queue_full(queue))) {