1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -176,6 +176,8 @@ static void ieee80211_send_addba_resp(st
4 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
5 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
6 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
7 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
8 + memcpy(mgmt->bssid, da, ETH_ALEN);
10 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11 IEEE80211_STYPE_ACTION);
12 @@ -262,7 +264,11 @@ void ieee80211_process_addba_request(str
15 #endif /* CONFIG_MAC80211_HT_DEBUG */
18 + /* delete existing Rx BA session on the same tid */
19 + ___ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
20 + WLAN_STATUS_UNSPECIFIED_QOS,
24 /* prepare A-MPDU MLME for Rx aggregation */
25 --- a/net/mac80211/agg-tx.c
26 +++ b/net/mac80211/agg-tx.c
27 @@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
28 memcpy(mgmt->da, da, ETH_ALEN);
29 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
30 if (sdata->vif.type == NL80211_IFTYPE_AP ||
31 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
32 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
33 + sdata->vif.type == NL80211_IFTYPE_WDS)
34 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
35 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
36 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
37 @@ -398,7 +399,8 @@ int ieee80211_start_tx_ba_session(struct
39 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
40 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
41 - sdata->vif.type != NL80211_IFTYPE_AP)
42 + sdata->vif.type != NL80211_IFTYPE_AP &&
43 + sdata->vif.type != NL80211_IFTYPE_WDS)
46 if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
47 @@ -809,7 +811,7 @@ void ieee80211_process_addba_resp(struct
54 if (test_and_set_bit(HT_AGG_STATE_RESPONSE_RECEIVED,
56 --- a/net/mac80211/debugfs_sta.c
57 +++ b/net/mac80211/debugfs_sta.c
58 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
60 struct sta_info *sta = file->private_data;
61 u32 staflags = get_sta_flags(sta);
62 - int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
63 + int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
64 staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
65 staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
66 staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
67 @@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
68 staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
69 staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
70 staflags & WLAN_STA_WME ? "WME\n" : "",
71 - staflags & WLAN_STA_WDS ? "WDS\n" : "",
72 staflags & WLAN_STA_MFP ? "MFP\n" : "");
73 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
75 --- a/net/mac80211/iface.c
76 +++ b/net/mac80211/iface.c
77 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
79 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
80 struct ieee80211_local *local = sdata->local;
81 - struct sta_info *sta;
84 u32 hw_reconf_flags = 0;
85 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
87 set_bit(SDATA_STATE_RUNNING, &sdata->state);
89 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
90 - /* Create STA entry for the WDS peer */
91 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
95 - goto err_del_interface;
98 - /* no locking required since STA is not live yet */
99 - sta->flags |= WLAN_STA_AUTHORIZED;
101 - res = sta_info_insert(sta);
103 - /* STA has been freed */
104 - goto err_del_interface;
107 - rate_control_rate_init(sta);
111 * set_multicast_list will be invoked by the networking core
112 * which will check whether any increments here were done in
113 @@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
114 netif_tx_start_all_queues(dev);
118 - drv_remove_interface(local, &sdata->vif);
121 if (!local->open_count)
123 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
124 dev->destructor = free_netdev;
127 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
128 + struct sk_buff *skb)
130 + struct ieee80211_local *local = sdata->local;
131 + struct ieee80211_rx_status *rx_status;
132 + struct ieee802_11_elems elems;
133 + struct ieee80211_mgmt *mgmt;
134 + struct sta_info *sta;
139 + enum ieee80211_band band = local->hw.conf.channel->band;
140 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
142 + rx_status = IEEE80211_SKB_RXCB(skb);
143 + mgmt = (struct ieee80211_mgmt *) skb->data;
144 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
146 + if (stype != IEEE80211_STYPE_BEACON)
149 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
150 + if (baselen > skb->len)
153 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
154 + skb->len - baselen, &elems);
156 + rates = ieee80211_sta_get_rates(local, &elems, band);
160 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
164 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
172 + sta->last_rx = jiffies;
173 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
175 + if (elems.ht_cap_elem)
176 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
177 + elems.ht_cap_elem, &sta->sta.ht_cap);
179 + if (elems.wmm_param)
180 + set_sta_flags(sta, WLAN_STA_WME);
183 + sta->flags = WLAN_STA_AUTHORIZED;
184 + rate_control_rate_init(sta);
185 + sta_info_insert_rcu(sta);
191 static void ieee80211_iface_work(struct work_struct *work)
193 struct ieee80211_sub_if_data *sdata =
194 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct
196 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
198 + case NL80211_IFTYPE_WDS:
199 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
202 WARN(1, "frame for unexpected interface type");
204 --- a/net/mac80211/rx.c
205 +++ b/net/mac80211/rx.c
206 @@ -2137,7 +2137,8 @@ ieee80211_rx_h_action(struct ieee80211_r
208 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
209 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
210 - sdata->vif.type != NL80211_IFTYPE_AP)
211 + sdata->vif.type != NL80211_IFTYPE_AP &&
212 + sdata->vif.type != NL80211_IFTYPE_WDS)
215 /* verify action_code is present */
216 @@ -2335,13 +2336,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
218 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
219 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
220 - sdata->vif.type != NL80211_IFTYPE_STATION)
221 + sdata->vif.type != NL80211_IFTYPE_STATION &&
222 + sdata->vif.type != NL80211_IFTYPE_WDS)
223 return RX_DROP_MONITOR;
226 case cpu_to_le16(IEEE80211_STYPE_BEACON):
227 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
228 - /* process for all: mesh, mlme, ibss */
229 + /* process for all: mesh, mlme, ibss, wds */
231 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
232 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
233 @@ -2680,10 +2682,16 @@ static int prepare_for_handlers(struct i
236 case NL80211_IFTYPE_WDS:
237 - if (bssid || !ieee80211_is_data(hdr->frame_control))
239 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
242 + if (ieee80211_is_data(hdr->frame_control) ||
243 + ieee80211_is_action(hdr->frame_control)) {
244 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
246 + } else if (!ieee80211_is_beacon(hdr->frame_control))
251 /* should never get here */
252 --- a/net/mac80211/sta_info.h
253 +++ b/net/mac80211/sta_info.h
256 * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
257 * @WLAN_STA_WME: Station is a QoS-STA.
258 - * @WLAN_STA_WDS: Station is one of our WDS peers.
259 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
260 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
261 * frame to this station is transmitted.
262 @@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
263 WLAN_STA_SHORT_PREAMBLE = 1<<4,
264 WLAN_STA_ASSOC_AP = 1<<5,
266 - WLAN_STA_WDS = 1<<7,
267 WLAN_STA_CLEAR_PS_FILT = 1<<9,
268 WLAN_STA_MFP = 1<<10,
269 WLAN_STA_BLOCK_BA = 1<<11,
270 --- a/drivers/net/wireless/ath/ath9k/beacon.c
271 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
272 @@ -360,6 +360,7 @@ void ath_beacon_tasklet(unsigned long da
273 struct ath_common *common = ath9k_hw_common(ah);
274 struct ath_buf *bf = NULL;
275 struct ieee80211_vif *vif;
276 + struct ath_tx_status ts;
280 @@ -384,7 +385,9 @@ void ath_beacon_tasklet(unsigned long da
281 ath_dbg(common, ATH_DBG_BSTUCK,
282 "beacon is officially stuck\n");
283 sc->sc_flags |= SC_OP_TSF_RESET;
284 + spin_lock(&sc->sc_pcu_lock);
286 + spin_unlock(&sc->sc_pcu_lock);
290 @@ -464,6 +467,11 @@ void ath_beacon_tasklet(unsigned long da
291 ath9k_hw_txstart(ah, sc->beacon.beaconq);
293 sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */
294 + if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
295 + spin_lock_bh(&sc->sc_pcu_lock);
296 + ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts);
297 + spin_unlock_bh(&sc->sc_pcu_lock);
302 --- a/drivers/net/wireless/ath/ath9k/main.c
303 +++ b/drivers/net/wireless/ath/ath9k/main.c
304 @@ -617,8 +617,11 @@ void ath_hw_check(struct work_struct *wo
305 ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
306 "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
308 - if (++sc->hw_busy_count >= 3)
309 + if (++sc->hw_busy_count >= 3) {
310 + spin_lock_bh(&sc->sc_pcu_lock);
312 + spin_unlock_bh(&sc->sc_pcu_lock);
314 } else if (busy >= 0)
315 sc->hw_busy_count = 0;
317 @@ -637,7 +640,9 @@ static void ath_hw_pll_rx_hang_check(str
318 /* Rx is hung for more than 500ms. Reset it */
319 ath_dbg(common, ATH_DBG_RESET,
320 "Possible RX hang, resetting");
321 + spin_lock_bh(&sc->sc_pcu_lock);
323 + spin_unlock_bh(&sc->sc_pcu_lock);
327 @@ -674,7 +679,9 @@ void ath9k_tasklet(unsigned long data)
329 if ((status & ATH9K_INT_FATAL) ||
330 (status & ATH9K_INT_BB_WATCHDOG)) {
331 + spin_lock(&sc->sc_pcu_lock);
333 + spin_unlock(&sc->sc_pcu_lock);
337 @@ -980,7 +987,6 @@ int ath_reset(struct ath_softc *sc, bool
338 del_timer_sync(&common->ani.timer);
341 - spin_lock_bh(&sc->sc_pcu_lock);
343 ieee80211_stop_queues(hw);
345 @@ -1023,7 +1029,6 @@ int ath_reset(struct ath_softc *sc, bool
348 ieee80211_wake_queues(hw);
349 - spin_unlock_bh(&sc->sc_pcu_lock);
352 if (!common->disable_ani)
353 @@ -2326,9 +2331,9 @@ static void ath9k_flush(struct ieee80211
355 spin_lock_bh(&sc->sc_pcu_lock);
356 drain_txq = ath_drain_all_txq(sc, false);
357 - spin_unlock_bh(&sc->sc_pcu_lock);
359 ath_reset(sc, false);
360 + spin_unlock_bh(&sc->sc_pcu_lock);
361 ath9k_ps_restore(sc);
362 ieee80211_wake_queues(hw);
364 --- a/drivers/net/wireless/ath/ath9k/xmit.c
365 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
366 @@ -565,11 +565,8 @@ static void ath_tx_complete_aggr(struct
371 - spin_unlock_bh(&sc->sc_pcu_lock);
373 ath_reset(sc, false);
374 - spin_lock_bh(&sc->sc_pcu_lock);
378 static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
379 @@ -664,7 +661,8 @@ static int ath_compute_num_delims(struct
380 * TODO - this could be improved to be dependent on the rate.
381 * The hardware can keep up at lower rates, but not higher rates
383 - if (fi->keyix != ATH9K_TXKEYIX_INVALID)
384 + if ((fi->keyix != ATH9K_TXKEYIX_INVALID) &&
385 + !(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA))
386 ndelim += ATH_AGGR_ENCRYPTDELIM;
389 @@ -2169,7 +2167,9 @@ static void ath_tx_complete_poll_work(st
391 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
392 "tx hung, resetting the chip\n");
393 + spin_lock_bh(&sc->sc_pcu_lock);
395 + spin_unlock_bh(&sc->sc_pcu_lock);
398 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
399 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
400 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
401 @@ -236,7 +236,7 @@ static void ar9003_paprd_get_gain_table(
402 memset(entry, 0, sizeof(ah->paprd_gain_table_entries));
403 memset(index, 0, sizeof(ah->paprd_gain_table_index));
405 - for (i = 0; i < 32; i++) {
406 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
407 entry[i] = REG_READ(ah, reg);
408 index[i] = (entry[i] >> 24) & 0xff;
410 @@ -246,13 +246,13 @@ static void ar9003_paprd_get_gain_table(
411 static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
414 - int olpc_gain_delta = 0;
415 + int olpc_gain_delta = 0, cl_gain_mod;
416 int alpha_therm, alpha_volt;
417 int therm_cal_value, volt_cal_value;
418 int therm_value, volt_value;
419 int thermal_gain_corr, voltage_gain_corr;
420 int desired_scale, desired_gain = 0;
422 + u32 reg_olpc = 0, reg_cl_gain = 0;
424 REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1,
425 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE);
426 @@ -271,15 +271,29 @@ static unsigned int ar9003_get_desired_g
427 volt_value = REG_READ_FIELD(ah, AR_PHY_BB_THERM_ADC_4,
428 AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE);
431 - reg = AR_PHY_TPC_11_B0;
432 - else if (chain == 1)
433 - reg = AR_PHY_TPC_11_B1;
435 - reg = AR_PHY_TPC_11_B2;
438 + reg_olpc = AR_PHY_TPC_11_B0;
439 + reg_cl_gain = AR_PHY_CL_TAB_0;
442 + reg_olpc = AR_PHY_TPC_11_B1;
443 + reg_cl_gain = AR_PHY_CL_TAB_1;
446 + reg_olpc = AR_PHY_TPC_11_B2;
447 + reg_cl_gain = AR_PHY_CL_TAB_2;
450 + ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
451 + "Invalid chainmask: %d\n", chain);
455 - olpc_gain_delta = REG_READ_FIELD(ah, reg,
456 + olpc_gain_delta = REG_READ_FIELD(ah, reg_olpc,
457 AR_PHY_TPC_11_OLPC_GAIN_DELTA);
458 + cl_gain_mod = REG_READ_FIELD(ah, reg_cl_gain,
459 + AR_PHY_CL_TAB_CL_GAIN_MOD);
461 if (olpc_gain_delta >= 128)
462 olpc_gain_delta = olpc_gain_delta - 256;
463 @@ -289,7 +303,7 @@ static unsigned int ar9003_get_desired_g
464 voltage_gain_corr = (alpha_volt * (volt_value - volt_cal_value) +
466 desired_gain = target_power - olpc_gain_delta - thermal_gain_corr -
467 - voltage_gain_corr + desired_scale;
468 + voltage_gain_corr + desired_scale + cl_gain_mod;
472 @@ -727,7 +741,7 @@ int ar9003_paprd_setup_gain_table(struct
473 desired_gain = ar9003_get_desired_gain(ah, chain, train_power);
476 - for (i = 0; i < 32; i++) {
477 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
478 if (ah->paprd_gain_table_index[i] >= desired_gain)
481 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
482 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
483 @@ -1121,6 +1121,9 @@
484 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5 0x3F00
485 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5_S 8
487 +#define AR_PHY_CL_TAB_CL_GAIN_MOD 0x1f
488 +#define AR_PHY_CL_TAB_CL_GAIN_MOD_S 0
490 void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
492 #endif /* AR9003_PHY_H */
493 --- a/drivers/net/wireless/ath/ath5k/eeprom.c
494 +++ b/drivers/net/wireless/ath/ath5k/eeprom.c
495 @@ -691,14 +691,12 @@ ath5k_eeprom_free_pcal_info(struct ath5k
496 if (!chinfo[pier].pd_curves)
499 - for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
500 + for (pdg = 0; pdg < AR5K_EEPROM_N_PD_CURVES; pdg++) {
501 struct ath5k_pdgain_info *pd =
502 &chinfo[pier].pd_curves[pdg];
505 - kfree(pd->pd_step);
508 + kfree(pd->pd_step);
512 kfree(chinfo[pier].pd_curves);
513 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
514 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
515 @@ -229,6 +229,7 @@ static void ar9003_hw_fill_txdesc(struct
516 static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
517 struct ath_tx_status *ts)
519 + struct ar9003_txc *txc = (struct ar9003_txc *) ds;
520 struct ar9003_txs *ads;
523 @@ -238,7 +239,11 @@ static int ar9003_hw_proc_txdesc(struct
524 if ((status & AR_TxDone) == 0)
527 - ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
528 + ts->qid = MS(ads->ds_info, AR_TxQcuNum);
529 + if (!txc || (MS(txc->info, AR_TxQcuNum) == ts->qid))
530 + ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
534 if ((MS(ads->ds_info, AR_DescId) != ATHEROS_VENDOR_ID) ||
535 (MS(ads->ds_info, AR_TxRxDesc) != 1)) {
536 @@ -254,7 +259,6 @@ static int ar9003_hw_proc_txdesc(struct
537 ts->ts_seqnum = MS(status, AR_SeqNum);
538 ts->tid = MS(status, AR_TxTid);
540 - ts->qid = MS(ads->ds_info, AR_TxQcuNum);
541 ts->desc_id = MS(ads->status1, AR_TxDescId);
542 ts->ts_tstamp = ads->status4;
544 --- a/net/mac80211/wpa.c
545 +++ b/net/mac80211/wpa.c
547 #include <linux/gfp.h>
548 #include <asm/unaligned.h>
549 #include <net/mac80211.h>
550 +#include <crypto/aes.h>
552 #include "ieee80211_i.h"
554 @@ -86,6 +87,11 @@ ieee80211_rx_h_michael_mic_verify(struct
555 struct sk_buff *skb = rx->skb;
556 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
557 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
558 + int queue = rx->queue;
560 + /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */
561 + if (rx->queue == NUM_RX_DATA_QUEUES - 1)
565 * it makes no sense to check for MIC errors on anything other
566 @@ -148,8 +154,8 @@ ieee80211_rx_h_michael_mic_verify(struct
569 /* update IV in key information to be able to detect replays */
570 - rx->key->u.tkip.rx[rx->queue].iv32 = rx->tkip_iv32;
571 - rx->key->u.tkip.rx[rx->queue].iv16 = rx->tkip_iv16;
572 + rx->key->u.tkip.rx[queue].iv32 = rx->tkip_iv32;
573 + rx->key->u.tkip.rx[queue].iv16 = rx->tkip_iv16;
577 @@ -165,6 +171,7 @@ static int tkip_encrypt_skb(struct ieee8
578 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
579 struct ieee80211_key *key = tx->key;
580 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
581 + unsigned long flags;
585 @@ -192,11 +199,12 @@ static int tkip_encrypt_skb(struct ieee8
588 /* Increase IV for the frame */
589 + spin_lock_irqsave(&key->u.tkip.txlock, flags);
590 key->u.tkip.tx.iv16++;
591 if (key->u.tkip.tx.iv16 == 0)
592 key->u.tkip.tx.iv32++;
594 - pos = ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16);
595 + pos = ieee80211_tkip_add_iv(pos, key);
596 + spin_unlock_irqrestore(&key->u.tkip.txlock, flags);
598 /* hwaccel - with software IV */
599 if (info->control.hw_key)
600 @@ -205,9 +213,8 @@ static int tkip_encrypt_skb(struct ieee8
601 /* Add room for ICV */
602 skb_put(skb, TKIP_ICV_LEN);
604 - hdr = (struct ieee80211_hdr *) skb->data;
605 return ieee80211_tkip_encrypt_data(tx->local->wep_tx_tfm,
606 - key, pos, len, hdr->addr2);
607 + key, skb, pos, len);
611 @@ -235,6 +242,11 @@ ieee80211_crypto_tkip_decrypt(struct iee
612 struct ieee80211_key *key = rx->key;
613 struct sk_buff *skb = rx->skb;
614 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
615 + int queue = rx->queue;
617 + /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */
618 + if (rx->queue == NUM_RX_DATA_QUEUES - 1)
621 hdrlen = ieee80211_hdrlen(hdr->frame_control);
623 @@ -255,7 +267,7 @@ ieee80211_crypto_tkip_decrypt(struct iee
624 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
625 key, skb->data + hdrlen,
626 skb->len - hdrlen, rx->sta->sta.addr,
627 - hdr->addr1, hwaccel, rx->queue,
628 + hdr->addr1, hwaccel, queue,
631 if (res != TKIP_DECRYPT_OK)
632 @@ -283,6 +295,8 @@ static void ccmp_special_blocks(struct s
634 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
636 + memset(scratch, 0, 6 * AES_BLOCK_LEN);
638 b_0 = scratch + 3 * AES_BLOCK_LEN;
639 aad = scratch + 4 * AES_BLOCK_LEN;
641 @@ -373,8 +387,10 @@ static int ccmp_encrypt_skb(struct ieee8
642 struct ieee80211_key *key = tx->key;
643 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
644 int hdrlen, len, tail;
650 + u8 scratch[6 * AES_BLOCK_LEN];
652 if (info->control.hw_key &&
653 !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
654 @@ -402,14 +418,14 @@ static int ccmp_encrypt_skb(struct ieee8
655 hdr = (struct ieee80211_hdr *) pos;
659 - pn = key->u.ccmp.tx_pn;
660 + pn64 = atomic64_inc_return(&key->u.ccmp.tx_pn);
662 - for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
669 + pn[3] = pn64 >> 16;
670 + pn[2] = pn64 >> 24;
671 + pn[1] = pn64 >> 32;
672 + pn[0] = pn64 >> 40;
674 ccmp_pn2hdr(pos, pn, key->conf.keyidx);
676 @@ -418,8 +434,8 @@ static int ccmp_encrypt_skb(struct ieee8
680 - ccmp_special_blocks(skb, pn, key->u.ccmp.tx_crypto_buf, 0);
681 - ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, key->u.ccmp.tx_crypto_buf, pos, len,
682 + ccmp_special_blocks(skb, pn, scratch, 0);
683 + ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, pos, len,
684 pos, skb_put(skb, CCMP_MIC_LEN));
687 @@ -475,11 +491,12 @@ ieee80211_crypto_ccmp_decrypt(struct iee
690 if (!(status->flag & RX_FLAG_DECRYPTED)) {
691 + u8 scratch[6 * AES_BLOCK_LEN];
692 /* hardware didn't decrypt/verify MIC */
693 - ccmp_special_blocks(skb, pn, key->u.ccmp.rx_crypto_buf, 1);
694 + ccmp_special_blocks(skb, pn, scratch, 1);
696 if (ieee80211_aes_ccm_decrypt(
697 - key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
698 + key->u.ccmp.tfm, scratch,
699 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
700 skb->data + skb->len - CCMP_MIC_LEN,
701 skb->data + hdrlen + CCMP_HDR_LEN))
702 --- a/drivers/net/wireless/b43/xmit.c
703 +++ b/drivers/net/wireless/b43/xmit.c
704 @@ -323,8 +323,7 @@ int b43_generate_txhdr(struct b43_wldev
705 /* we give the phase1key and iv16 here, the key is stored in
706 * shm. With that the hardware can do phase 2 and encryption.
708 - ieee80211_get_tkip_key(info->control.hw_key, skb_frag,
709 - IEEE80211_TKIP_P1_KEY, (u8*)phase1key);
710 + ieee80211_get_tkip_p1k(info->control.hw_key, skb_frag, phase1key);
711 /* phase1key is in host endian. Copy to little-endian txhdr->iv. */
712 for (i = 0; i < 5; i++) {
713 txhdr->iv[i * 2 + 0] = phase1key[i];
714 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
715 +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
716 @@ -240,8 +240,7 @@ static void iwl4965_tx_cmd_build_hwcrypt
718 case WLAN_CIPHER_SUITE_TKIP:
719 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
720 - ieee80211_get_tkip_key(keyconf, skb_frag,
721 - IEEE80211_TKIP_P2_KEY, tx_cmd->key);
722 + ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
723 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
726 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
727 +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
728 @@ -497,8 +497,7 @@ static void iwlagn_tx_cmd_build_hwcrypto
730 case WLAN_CIPHER_SUITE_TKIP:
731 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
732 - ieee80211_get_tkip_key(keyconf, skb_frag,
733 - IEEE80211_TKIP_P2_KEY, tx_cmd->key);
734 + ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
735 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
738 --- a/include/net/mac80211.h
739 +++ b/include/net/mac80211.h
740 @@ -960,21 +960,6 @@ enum sta_notify_cmd {
744 - * enum ieee80211_tkip_key_type - get tkip key
746 - * Used by drivers which need to get a tkip key for skb. Some drivers need a
747 - * phase 1 key, others need a phase 2 key. A single function allows the driver
748 - * to get the key, this enum indicates what type of key is required.
750 - * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
751 - * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
753 -enum ieee80211_tkip_key_type {
754 - IEEE80211_TKIP_P1_KEY,
755 - IEEE80211_TKIP_P2_KEY,
759 * enum ieee80211_hw_flags - hardware flags
761 * These flags are used to indicate hardware capabilities to
762 @@ -2568,21 +2553,33 @@ struct sk_buff *
763 ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
766 - * ieee80211_get_tkip_key - get a TKIP rc4 for skb
767 + * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
769 + * This function returns the TKIP phase 1 key for the IV32 taken
770 + * from the given packet.
772 + * @keyconf: the parameter passed with the set key
773 + * @skb: the packet to take the IV32 value from that will be encrypted
775 + * @p1k: a buffer to which the key will be written, as 5 u16 values
777 +void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
778 + struct sk_buff *skb, u16 *p1k);
781 + * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
783 - * This function computes a TKIP rc4 key for an skb. It computes
784 - * a phase 1 key if needed (iv16 wraps around). This function is to
785 - * be used by drivers which can do HW encryption but need to compute
786 - * to phase 1/2 key in SW.
787 + * This function computes the TKIP RC4 key for the IV values
790 * @keyconf: the parameter passed with the set key
791 - * @skb: the skb for which the key is needed
793 - * @key: a buffer to which the key will be written
795 -void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
796 - struct sk_buff *skb,
797 - enum ieee80211_tkip_key_type type, u8 *key);
798 + * @skb: the packet to take the IV32/IV16 values from that will be
799 + * encrypted with this key
800 + * @p2k: a buffer to which the key will be written, 16 bytes
802 +void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
803 + struct sk_buff *skb, u8 *p2k);
806 * ieee80211_wake_queue - wake specific queue
807 * @hw: pointer as obtained from ieee80211_alloc_hw().
808 --- a/net/mac80211/key.c
809 +++ b/net/mac80211/key.c
810 @@ -333,6 +333,7 @@ struct ieee80211_key *ieee80211_key_allo
811 get_unaligned_le16(seq);
814 + spin_lock_init(&key->u.tkip.txlock);
816 case WLAN_CIPHER_SUITE_CCMP:
817 key->conf.iv_len = CCMP_HDR_LEN;
818 --- a/net/mac80211/key.h
819 +++ b/net/mac80211/key.h
820 @@ -52,9 +52,10 @@ enum ieee80211_internal_tkip_state {
827 + u32 iv32; /* current iv32 */
828 + u16 iv16; /* current iv16 */
829 + u16 p1k[5]; /* p1k cache */
830 + u32 p1k_iv32; /* iv32 for which p1k computed */
831 enum ieee80211_internal_tkip_state state;
834 @@ -71,6 +72,9 @@ struct ieee80211_key {
838 + /* protects tx context */
844 @@ -78,7 +82,7 @@ struct ieee80211_key {
845 struct tkip_ctx rx[NUM_RX_DATA_QUEUES];
851 * Last received packet number. The first
852 * NUM_RX_DATA_QUEUES counters are used with Data
853 @@ -88,12 +92,9 @@ struct ieee80211_key {
854 u8 rx_pn[NUM_RX_DATA_QUEUES + 1][6];
855 struct crypto_cipher *tfm;
856 u32 replays; /* dot11RSNAStatsCCMPReplays */
857 - /* scratch buffers for virt_to_page() (crypto API) */
858 #ifndef AES_BLOCK_LEN
859 #define AES_BLOCK_LEN 16
861 - u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
862 - u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
866 --- a/net/mac80211/tkip.c
867 +++ b/net/mac80211/tkip.c
868 @@ -101,6 +101,7 @@ static void tkip_mixing_phase1(const u8
869 p1k[4] += tkipS(p1k[3] ^ get_unaligned_le16(tk + 0 + j)) + i;
871 ctx->state = TKIP_STATE_PHASE1_DONE;
872 + ctx->p1k_iv32 = tsc_IV32;
875 static void tkip_mixing_phase2(const u8 *tk, struct tkip_ctx *ctx,
876 @@ -140,60 +141,72 @@ static void tkip_mixing_phase2(const u8
877 /* Add TKIP IV and Ext. IV at @pos. @iv0, @iv1, and @iv2 are the first octets
878 * of the IV. Returns pointer to the octet following IVs (i.e., beginning of
879 * the packet payload). */
880 -u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, u16 iv16)
881 +u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key)
883 - pos = write_tkip_iv(pos, iv16);
884 + lockdep_assert_held(&key->u.tkip.txlock);
886 + pos = write_tkip_iv(pos, key->u.tkip.tx.iv16);
887 *pos++ = (key->conf.keyidx << 6) | (1 << 5) /* Ext IV */;
888 put_unaligned_le32(key->u.tkip.tx.iv32, pos);
892 -void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
893 - struct sk_buff *skb, enum ieee80211_tkip_key_type type,
895 +static void ieee80211_compute_tkip_p1k(struct ieee80211_key *key, u32 iv32)
897 - struct ieee80211_key *key = (struct ieee80211_key *)
898 - container_of(keyconf, struct ieee80211_key, conf);
899 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
902 - struct tkip_ctx *ctx;
906 - data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
907 - iv16 = data[2] | (data[0] << 8);
908 - iv32 = get_unaligned_le32(&data[4]);
910 - tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
911 - ctx = &key->u.tkip.tx;
913 -#ifdef CONFIG_MAC80211_TKIP_DEBUG
914 - printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n",
916 + struct ieee80211_sub_if_data *sdata = key->sdata;
917 + struct tkip_ctx *ctx = &key->u.tkip.tx;
918 + const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
920 - if (iv32 != ctx->iv32) {
921 - printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n",
923 - printk(KERN_DEBUG "Wrap around of iv16 in the middle of a "
924 - "fragmented packet\n");
927 + lockdep_assert_held(&key->u.tkip.txlock);
929 - /* Update the p1k only when the iv16 in the packet wraps around, this
930 - * might occur after the wrap around of iv16 in the key in case of
931 - * fragmented packets. */
932 - if (iv16 == 0 || ctx->state == TKIP_STATE_NOT_INIT)
933 - tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32);
935 + * Update the P1K when the IV32 is different from the value it
936 + * had when we last computed it (or when not initialised yet).
937 + * This might flip-flop back and forth if packets are processed
938 + * out-of-order due to the different ACs, but then we have to
939 + * just compute the P1K more often.
941 + if (ctx->p1k_iv32 != iv32 || ctx->state == TKIP_STATE_NOT_INIT)
942 + tkip_mixing_phase1(tk, ctx, sdata->vif.addr, iv32);
945 - if (type == IEEE80211_TKIP_P1_KEY) {
946 - memcpy(outkey, ctx->p1k, sizeof(u16) * 5);
949 +void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
950 + struct sk_buff *skb, u16 *p1k)
952 + struct ieee80211_key *key = (struct ieee80211_key *)
953 + container_of(keyconf, struct ieee80211_key, conf);
954 + struct tkip_ctx *ctx = &key->u.tkip.tx;
955 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
956 + const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
957 + u32 iv32 = get_unaligned_le32(&data[4]);
958 + unsigned long flags;
960 + spin_lock_irqsave(&key->u.tkip.txlock, flags);
961 + ieee80211_compute_tkip_p1k(key, iv32);
962 + memcpy(p1k, ctx->p1k, sizeof(ctx->p1k));
963 + spin_unlock_irqrestore(&key->u.tkip.txlock, flags);
965 +EXPORT_SYMBOL(ieee80211_get_tkip_p1k);
967 - tkip_mixing_phase2(tk, ctx, iv16, outkey);
968 +void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
969 + struct sk_buff *skb, u8 *p2k)
971 + struct ieee80211_key *key = (struct ieee80211_key *)
972 + container_of(keyconf, struct ieee80211_key, conf);
973 + const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
974 + struct tkip_ctx *ctx = &key->u.tkip.tx;
975 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
976 + const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
977 + u32 iv32 = get_unaligned_le32(&data[4]);
978 + u16 iv16 = data[2] | (data[0] << 8);
979 + unsigned long flags;
981 + spin_lock_irqsave(&key->u.tkip.txlock, flags);
982 + ieee80211_compute_tkip_p1k(key, iv32);
983 + tkip_mixing_phase2(tk, ctx, iv16, p2k);
984 + spin_unlock_irqrestore(&key->u.tkip.txlock, flags);
986 -EXPORT_SYMBOL(ieee80211_get_tkip_key);
987 +EXPORT_SYMBOL(ieee80211_get_tkip_p2k);
990 * Encrypt packet payload with TKIP using @key. @pos is a pointer to the
991 @@ -204,19 +217,15 @@ EXPORT_SYMBOL(ieee80211_get_tkip_key);
993 int ieee80211_tkip_encrypt_data(struct crypto_cipher *tfm,
994 struct ieee80211_key *key,
995 - u8 *pos, size_t payload_len, u8 *ta)
996 + struct sk_buff *skb,
997 + u8 *payload, size_t payload_len)
1000 - struct tkip_ctx *ctx = &key->u.tkip.tx;
1001 - const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
1003 - /* Calculate per-packet key */
1004 - if (ctx->iv16 == 0 || ctx->state == TKIP_STATE_NOT_INIT)
1005 - tkip_mixing_phase1(tk, ctx, ta, ctx->iv32);
1007 - tkip_mixing_phase2(tk, ctx, ctx->iv16, rc4key);
1008 + ieee80211_get_tkip_p2k(&key->conf, skb, rc4key);
1010 - return ieee80211_wep_encrypt_data(tfm, rc4key, 16, pos, payload_len);
1011 + return ieee80211_wep_encrypt_data(tfm, rc4key, 16,
1012 + payload, payload_len);
1015 /* Decrypt packet payload with TKIP using @key. @pos is a pointer to the
1016 --- a/net/mac80211/tkip.h
1017 +++ b/net/mac80211/tkip.h
1019 #include <linux/crypto.h>
1022 -u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, u16 iv16);
1023 +u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key);
1025 int ieee80211_tkip_encrypt_data(struct crypto_cipher *tfm,
1026 - struct ieee80211_key *key,
1027 - u8 *pos, size_t payload_len, u8 *ta);
1028 + struct ieee80211_key *key,
1029 + struct sk_buff *skb,
1030 + u8 *payload, size_t payload_len);
1033 TKIP_DECRYPT_OK = 0,
1034 TKIP_DECRYPT_NO_EXT_IV = -1,
1035 --- a/net/mac80211/cfg.c
1036 +++ b/net/mac80211/cfg.c
1037 @@ -209,6 +209,7 @@ static int ieee80211_get_key(struct wiph
1039 struct key_params params;
1040 struct ieee80211_key *key = NULL;
1045 @@ -256,12 +257,13 @@ static int ieee80211_get_key(struct wiph
1048 case WLAN_CIPHER_SUITE_CCMP:
1049 - seq[0] = key->u.ccmp.tx_pn[5];
1050 - seq[1] = key->u.ccmp.tx_pn[4];
1051 - seq[2] = key->u.ccmp.tx_pn[3];
1052 - seq[3] = key->u.ccmp.tx_pn[2];
1053 - seq[4] = key->u.ccmp.tx_pn[1];
1054 - seq[5] = key->u.ccmp.tx_pn[0];
1055 + pn64 = atomic64_read(&key->u.ccmp.tx_pn);
1057 + seq[1] = pn64 >> 8;
1058 + seq[2] = pn64 >> 16;
1059 + seq[3] = pn64 >> 24;
1060 + seq[4] = pn64 >> 32;
1061 + seq[5] = pn64 >> 40;
1065 --- a/net/mac80211/debugfs_key.c
1066 +++ b/net/mac80211/debugfs_key.c
1067 @@ -79,6 +79,7 @@ static ssize_t key_tx_spec_read(struct f
1068 size_t count, loff_t *ppos)
1074 struct ieee80211_key *key = file->private_data;
1075 @@ -94,9 +95,10 @@ static ssize_t key_tx_spec_read(struct f
1076 key->u.tkip.tx.iv16);
1078 case WLAN_CIPHER_SUITE_CCMP:
1079 - tpn = key->u.ccmp.tx_pn;
1080 + pn = atomic64_read(&key->u.ccmp.tx_pn);
1081 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
1082 - tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
1083 + (u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
1084 + (u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
1086 case WLAN_CIPHER_SUITE_AES_CMAC:
1087 tpn = key->u.aes_cmac.tx_pn;
1088 --- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
1089 +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
1090 @@ -653,8 +653,8 @@ static const u32 ar9300_2p2_baseband_pos
1091 {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110},
1092 {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
1093 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
1094 - {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982},
1095 - {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a},
1096 + {0x0000a2d0, 0x00041981, 0x00041981, 0x00041981, 0x00041982},
1097 + {0x0000a2d8, 0x7999a83b, 0x7999a83b, 0x7999a83b, 0x7999a83b},
1098 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1099 {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
1100 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x001c0000},
1101 @@ -761,7 +761,7 @@ static const u32 ar9300_2p2_baseband_cor
1102 {0x0000a3ec, 0x20202020},
1103 {0x0000a3f0, 0x00000000},
1104 {0x0000a3f4, 0x00000246},
1105 - {0x0000a3f8, 0x0cdbd380},
1106 + {0x0000a3f8, 0x0c9bd380},
1107 {0x0000a3fc, 0x000f0f01},
1108 {0x0000a400, 0x8fa91f01},
1109 {0x0000a404, 0x00000000},
1110 @@ -780,7 +780,7 @@ static const u32 ar9300_2p2_baseband_cor
1111 {0x0000a43c, 0x00100000},
1112 {0x0000a440, 0x00000000},
1113 {0x0000a444, 0x00000000},
1114 - {0x0000a448, 0x06000080},
1115 + {0x0000a448, 0x05000080},
1116 {0x0000a44c, 0x00000001},
1117 {0x0000a450, 0x00010000},
1118 {0x0000a458, 0x00000000},
1119 @@ -1500,8 +1500,6 @@ static const u32 ar9300_2p2_mac_core[][2
1120 {0x0000816c, 0x00000000},
1121 {0x000081c0, 0x00000000},
1122 {0x000081c4, 0x33332210},
1123 - {0x000081c8, 0x00000000},
1124 - {0x000081cc, 0x00000000},
1125 {0x000081ec, 0x00000000},
1126 {0x000081f0, 0x00000000},
1127 {0x000081f4, 0x00000000},
1128 --- a/net/mac80211/work.c
1129 +++ b/net/mac80211/work.c
1130 @@ -1075,14 +1075,13 @@ static void ieee80211_work_work(struct w
1132 if (wk->chan != local->tmp_channel)
1134 - if (ieee80211_work_ct_coexists(wk->chan_type,
1135 - local->tmp_channel_type))
1136 + if (!ieee80211_work_ct_coexists(wk->chan_type,
1137 + local->tmp_channel_type))
1139 remain_off_channel = true;
1142 if (!remain_off_channel && local->tmp_channel) {
1143 - bool on_oper_chan = ieee80211_cfg_on_oper_channel(local);
1144 local->tmp_channel = NULL;
1145 /* If tmp_channel wasn't operating channel, then
1146 * we need to go back on-channel.
1147 @@ -1092,7 +1091,7 @@ static void ieee80211_work_work(struct w
1148 * we still need to do a hardware config. Currently,
1149 * we cannot be here while scanning, however.
1151 - if (ieee80211_cfg_on_oper_channel(local) && !on_oper_chan)
1152 + if (!ieee80211_cfg_on_oper_channel(local))
1153 ieee80211_hw_config(local, 0);
1155 /* At the least, we need to disable offchannel_ps,
1156 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
1157 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
1158 @@ -627,6 +627,11 @@ static void ar5008_hw_init_bb(struct ath
1162 + if (IS_CHAN_HALF_RATE(chan))
1164 + else if (IS_CHAN_QUARTER_RATE(chan))
1167 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1169 udelay(synthDelay + BASE_ACTIVATE_DELAY);
1170 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
1171 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
1172 @@ -499,45 +499,6 @@ void ar9002_hw_enable_async_fifo(struct
1177 - * If Async FIFO is enabled, the following counters change as MAC now runs
1178 - * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
1180 - * The values below tested for ht40 2 chain.
1181 - * Overwrite the delay/timeouts initialized in process ini.
1183 -void ar9002_hw_update_async_fifo(struct ath_hw *ah)
1185 - if (AR_SREV_9287_13_OR_LATER(ah)) {
1186 - REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
1187 - AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
1188 - REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
1189 - AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
1190 - REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
1191 - AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
1193 - REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
1194 - REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
1196 - REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
1197 - AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
1198 - REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
1199 - AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
1204 - * We don't enable WEP aggregation on mac80211 but we keep this
1205 - * around for HAL unification purposes.
1207 -void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
1209 - if (AR_SREV_9287_13_OR_LATER(ah)) {
1210 - REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
1211 - AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
1215 /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
1216 void ar9002_hw_attach_ops(struct ath_hw *ah)
1218 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
1219 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
1220 @@ -111,7 +111,9 @@ static int ar9002_hw_set_channel(struct
1222 switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
1224 - if ((freq % 20) == 0)
1225 + if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
1227 + else if ((freq % 20) == 0)
1229 else if ((freq % 10) == 0)
1231 @@ -129,8 +131,9 @@ static int ar9002_hw_set_channel(struct
1232 channelSel = CHANSEL_5G(freq);
1234 /* RefDivA setting */
1235 - REG_RMW_FIELD(ah, AR_AN_SYNTH9,
1236 - AR_AN_SYNTH9_REFDIVA, refDivA);
1237 + ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9,
1238 + AR_AN_SYNTH9_REFDIVA,
1239 + AR_AN_SYNTH9_REFDIVA_S, refDivA);
1243 @@ -447,26 +450,27 @@ static void ar9002_olc_init(struct ath_h
1244 static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
1245 struct ath9k_channel *chan)
1248 + int pll_div = 0x2c;
1251 - pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
1252 + if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) {
1253 + if (AR_SREV_9280_20(ah)) {
1261 + pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
1262 + pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
1264 if (chan && IS_CHAN_HALF_RATE(chan))
1265 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
1266 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1267 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
1269 - if (chan && IS_CHAN_5GHZ(chan)) {
1270 - if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1272 - else if (AR_SREV_9280_20(ah))
1275 - pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
1277 - pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
1283 --- a/drivers/net/wireless/ath/ath9k/hw.c
1284 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1285 @@ -87,7 +87,10 @@ static void ath9k_hw_set_clockrate(struc
1286 struct ath_common *common = ath9k_hw_common(ah);
1287 unsigned int clockrate;
1289 - if (!ah->curchan) /* should really check for CCK instead */
1290 + /* AR9287 v1.3+ uses async FIFO and runs the MAC at 117 MHz */
1291 + if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah))
1293 + else if (!ah->curchan) /* should really check for CCK instead */
1294 clockrate = ATH9K_CLOCK_RATE_CCK;
1295 else if (conf->channel->band == IEEE80211_BAND_2GHZ)
1296 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
1297 @@ -99,6 +102,13 @@ static void ath9k_hw_set_clockrate(struc
1298 if (conf_is_ht40(conf))
1301 + if (ah->curchan) {
1302 + if (IS_CHAN_HALF_RATE(ah->curchan))
1304 + if (IS_CHAN_QUARTER_RATE(ah->curchan))
1308 common->clockrate = clockrate;
1311 @@ -895,6 +905,13 @@ static void ath9k_hw_init_interrupt_mask
1315 +static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
1317 + u32 val = ath9k_hw_mac_to_clks(ah, us - 2);
1318 + val = min(val, (u32) 0xFFFF);
1319 + REG_WRITE(ah, AR_D_GBL_IFS_SIFS, val);
1322 static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
1324 u32 val = ath9k_hw_mac_to_clks(ah, us);
1325 @@ -932,25 +949,60 @@ static bool ath9k_hw_set_global_txtimeou
1327 void ath9k_hw_init_global_settings(struct ath_hw *ah)
1329 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
1330 + struct ath_common *common = ath9k_hw_common(ah);
1331 + struct ieee80211_conf *conf = &common->hw->conf;
1332 + const struct ath9k_channel *chan = ah->curchan;
1336 + int rx_lat = 0, tx_lat = 0, eifs = 0;
1339 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
1345 if (ah->misc_mode != 0)
1346 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
1348 - if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
1355 + if (IS_CHAN_HALF_RATE(chan)) {
1359 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1364 + } else if (IS_CHAN_QUARTER_RATE(chan)) {
1368 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1374 + eifs = REG_READ(ah, AR_D_GBL_IFS_EIFS);
1375 + reg = REG_READ(ah, AR_USEC);
1376 + rx_lat = MS(reg, AR_USEC_RX_LAT);
1377 + tx_lat = MS(reg, AR_USEC_TX_LAT);
1379 + slottime = ah->slottime;
1380 + if (IS_CHAN_5GHZ(chan))
1386 /* As defined by IEEE 802.11-2007 17.3.8.6 */
1387 - slottime = ah->slottime + 3 * ah->coverage_class;
1388 - acktimeout = slottime + sifstime;
1389 + acktimeout = slottime + sifstime + 3 * ah->coverage_class;
1392 * Workaround for early ACK timeouts, add an offset to match the
1393 @@ -962,11 +1014,20 @@ void ath9k_hw_init_global_settings(struc
1394 if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
1395 acktimeout += 64 - sifstime - ah->slottime;
1397 - ath9k_hw_setslottime(ah, ah->slottime);
1398 + ath9k_hw_set_sifs_time(ah, sifstime);
1399 + ath9k_hw_setslottime(ah, slottime);
1400 ath9k_hw_set_ack_timeout(ah, acktimeout);
1401 ath9k_hw_set_cts_timeout(ah, acktimeout);
1402 if (ah->globaltxtimeout != (u32) -1)
1403 ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
1405 + REG_WRITE(ah, AR_D_GBL_IFS_EIFS, ath9k_hw_mac_to_clks(ah, eifs));
1406 + REG_RMW(ah, AR_USEC,
1407 + (common->clockrate - 1) |
1408 + SM(rx_lat, AR_USEC_RX_LAT) |
1409 + SM(tx_lat, AR_USEC_TX_LAT),
1410 + AR_USEC_TX_LAT | AR_USEC_RX_LAT | AR_USEC_USEC);
1413 EXPORT_SYMBOL(ath9k_hw_init_global_settings);
1415 @@ -1570,9 +1631,13 @@ int ath9k_hw_reset(struct ath_hw *ah, st
1417 ath9k_hw_init_global_settings(ah);
1419 - if (!AR_SREV_9300_20_OR_LATER(ah)) {
1420 - ar9002_hw_update_async_fifo(ah);
1421 - ar9002_hw_enable_wep_aggregation(ah);
1422 + if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
1423 + REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
1424 + AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
1425 + REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
1426 + AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
1427 + REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
1428 + AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
1431 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
1432 @@ -1932,12 +1997,22 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_ti
1433 /* HW Capabilities */
1434 /*******************/
1436 +static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask)
1438 + eeprom_chainmask &= chip_chainmask;
1439 + if (eeprom_chainmask)
1440 + return eeprom_chainmask;
1442 + return chip_chainmask;
1445 int ath9k_hw_fill_cap_info(struct ath_hw *ah)
1447 struct ath9k_hw_capabilities *pCap = &ah->caps;
1448 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1449 struct ath_common *common = ath9k_hw_common(ah);
1450 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
1451 + unsigned int chip_chainmask;
1454 u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
1455 @@ -1974,6 +2049,15 @@ int ath9k_hw_fill_cap_info(struct ath_hw
1456 if (eeval & AR5416_OPFLAGS_11G)
1457 pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
1459 + if (AR_SREV_9485(ah) || AR_SREV_9285(ah) || AR_SREV_9330(ah))
1460 + chip_chainmask = 1;
1461 + else if (!AR_SREV_9280_20_OR_LATER(ah))
1462 + chip_chainmask = 7;
1463 + else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah))
1464 + chip_chainmask = 3;
1466 + chip_chainmask = 7;
1468 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
1470 * For AR9271 we will temporarilly uses the rx chainmax as read from
1471 @@ -1990,6 +2074,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw
1472 /* Use rx_chainmask from EEPROM. */
1473 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
1475 + pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask);
1476 + pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask);
1478 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
1480 /* enable key search for every frame in an aggregate */
1481 @@ -2079,10 +2166,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
1482 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
1484 pCap->tx_desc_len = sizeof(struct ath_desc);
1485 - if (AR_SREV_9280_20(ah) &&
1486 - ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <=
1487 - AR5416_EEP_MINOR_VER_16) ||
1488 - ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G)))
1489 + if (AR_SREV_9280_20(ah))
1490 pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
1493 --- a/drivers/net/wireless/ath/ath9k/hw.h
1494 +++ b/drivers/net/wireless/ath/ath9k/hw.h
1495 @@ -983,8 +983,6 @@ void ath9k_hw_get_delta_slope_vals(struc
1496 void ar9002_hw_cck_chan14_spread(struct ath_hw *ah);
1497 int ar9002_hw_rf_claim(struct ath_hw *ah);
1498 void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
1499 -void ar9002_hw_update_async_fifo(struct ath_hw *ah);
1500 -void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
1503 * Code specific to AR9003, we stuff these here to avoid callbacks
1504 --- a/drivers/net/wireless/ath/ath9k/recv.c
1505 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1506 @@ -814,16 +814,19 @@ static bool ath9k_rx_accept(struct ath_c
1507 struct ath_rx_status *rx_stats,
1508 bool *decrypt_error)
1510 -#define is_mc_or_valid_tkip_keyix ((is_mc || \
1511 - (rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
1512 - test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
1514 + bool is_mc, is_valid_tkip, strip_mic, mic_error = false;
1515 struct ath_hw *ah = common->ah;
1517 u8 rx_status_len = ah->caps.rx_status_len;
1519 fc = hdr->frame_control;
1521 + is_mc = !!is_multicast_ether_addr(hdr->addr1);
1522 + is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
1523 + test_bit(rx_stats->rs_keyix, common->tkip_keymap);
1524 + strip_mic = is_valid_tkip && !(rx_stats->rs_status &
1525 + (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
1527 if (!rx_stats->rs_datalen)
1530 @@ -838,6 +841,11 @@ static bool ath9k_rx_accept(struct ath_c
1531 if (rx_stats->rs_more)
1534 + mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
1535 + !ieee80211_has_morefrags(fc) &&
1536 + !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
1537 + (rx_stats->rs_status & ATH9K_RXERR_MIC);
1540 * The rx_stats->rs_status will not be set until the end of the
1541 * chained descriptors so it can be ignored if rs_more is set. The
1542 @@ -845,30 +853,18 @@ static bool ath9k_rx_accept(struct ath_c
1545 if (rx_stats->rs_status != 0) {
1546 - if (rx_stats->rs_status & ATH9K_RXERR_CRC)
1547 + if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
1548 rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
1549 + mic_error = false;
1551 if (rx_stats->rs_status & ATH9K_RXERR_PHY)
1554 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
1555 *decrypt_error = true;
1556 - } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
1559 - * The MIC error bit is only valid if the frame
1560 - * is not a control frame or fragment, and it was
1561 - * decrypted using a valid TKIP key.
1563 - is_mc = !!is_multicast_ether_addr(hdr->addr1);
1565 - if (!ieee80211_is_ctl(fc) &&
1566 - !ieee80211_has_morefrags(fc) &&
1567 - !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
1568 - is_mc_or_valid_tkip_keyix)
1569 - rxs->flag |= RX_FLAG_MMIC_ERROR;
1571 - rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
1572 + mic_error = false;
1576 * Reject error frames with the exception of
1577 * decryption and MIC failures. For monitor mode,
1578 @@ -886,6 +882,18 @@ static bool ath9k_rx_accept(struct ath_c
1584 + * For unicast frames the MIC error bit can have false positives,
1585 + * so all MIC error reports need to be validated in software.
1586 + * False negatives are not common, so skip software verification
1587 + * if the hardware considers the MIC valid.
1590 + rxs->flag |= RX_FLAG_MMIC_STRIPPED;
1591 + else if (is_mc && mic_error)
1592 + rxs->flag |= RX_FLAG_MMIC_ERROR;
1597 @@ -1938,6 +1946,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
1598 sc->rx.rxotherant = 0;
1601 + if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
1602 + skb_trim(skb, skb->len - 8);
1604 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1606 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
1607 --- a/drivers/net/wireless/ath/ath9k/reg.h
1608 +++ b/drivers/net/wireless/ath/ath9k/reg.h
1611 #define AR_D_GBL_IFS_SIFS 0x1030
1612 #define AR_D_GBL_IFS_SIFS_M 0x0000FFFF
1613 -#define AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR 0x000003AB
1614 #define AR_D_GBL_IFS_SIFS_RESV0 0xFFFFFFFF
1616 #define AR_D_TXBLK_BASE 0x1038
1617 @@ -616,12 +615,10 @@
1618 #define AR_D_GBL_IFS_SLOT 0x1070
1619 #define AR_D_GBL_IFS_SLOT_M 0x0000FFFF
1620 #define AR_D_GBL_IFS_SLOT_RESV0 0xFFFF0000
1621 -#define AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR 0x00000420
1623 #define AR_D_GBL_IFS_EIFS 0x10b0
1624 #define AR_D_GBL_IFS_EIFS_M 0x0000FFFF
1625 #define AR_D_GBL_IFS_EIFS_RESV0 0xFFFF0000
1626 -#define AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR 0x0000A5EB
1628 #define AR_D_GBL_IFS_MISC 0x10f0
1629 #define AR_D_GBL_IFS_MISC_LFSR_SLICE_SEL 0x00000007
1630 @@ -1477,7 +1474,6 @@ enum {
1631 #define AR_TIME_OUT_ACK_S 0
1632 #define AR_TIME_OUT_CTS 0x3FFF0000
1633 #define AR_TIME_OUT_CTS_S 16
1634 -#define AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR 0x16001D56
1636 #define AR_RSSI_THR 0x8018
1637 #define AR_RSSI_THR_MASK 0x000000FF
1638 @@ -1493,7 +1489,6 @@ enum {
1639 #define AR_USEC_TX_LAT_S 14
1640 #define AR_USEC_RX_LAT 0x1F800000
1641 #define AR_USEC_RX_LAT_S 23
1642 -#define AR_USEC_ASYNC_FIFO_DUR 0x12e00074
1644 #define AR_RESET_TSF 0x8020
1645 #define AR_RESET_TSF_ONCE 0x01000000