ath9k: fold patches that were merged upstream into 300-pending_work.patch
[openwrt/staging/mkresin.git] / package / mac80211 / patches / 300-pending_work.patch
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);
9
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
13 "%pM on tid %u\n",
14 mgmt->sa, tid);
15 #endif /* CONFIG_MAC80211_HT_DEBUG */
16 - goto end;
17 +
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,
21 + false);
22 }
23
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
38 */
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)
44 return -EINVAL;
45
46 if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
47 @@ -809,7 +811,7 @@ void ieee80211_process_addba_resp(struct
48 * of at least 1.
49 */
50 if (!buf_size)
51 - goto out;
52 + buf_size = 1;
53
54 if (test_and_set_bit(HT_AGG_STATE_RESPONSE_RECEIVED,
55 &tid_tx->state)) {
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
59 char buf[100];
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);
74 }
75 --- a/net/mac80211/iface.c
76 +++ b/net/mac80211/iface.c
77 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
78 {
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;
82 u32 changed = 0;
83 int res;
84 u32 hw_reconf_flags = 0;
85 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
86
87 set_bit(SDATA_STATE_RUNNING, &sdata->state);
88
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,
92 - GFP_KERNEL);
93 - if (!sta) {
94 - res = -ENOMEM;
95 - goto err_del_interface;
96 - }
97 -
98 - /* no locking required since STA is not live yet */
99 - sta->flags |= WLAN_STA_AUTHORIZED;
100 -
101 - res = sta_info_insert(sta);
102 - if (res) {
103 - /* STA has been freed */
104 - goto err_del_interface;
105 - }
106 -
107 - rate_control_rate_init(sta);
108 - }
109 -
110 /*
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);
115
116 return 0;
117 - err_del_interface:
118 - drv_remove_interface(local, &sdata->vif);
119 +
120 err_stop:
121 if (!local->open_count)
122 drv_stop(local);
123 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
124 dev->destructor = free_netdev;
125 }
126
127 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
128 + struct sk_buff *skb)
129 +{
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;
135 + size_t baselen;
136 + u32 rates = 0;
137 + u16 stype;
138 + bool new = false;
139 + enum ieee80211_band band = local->hw.conf.channel->band;
140 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
141 +
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;
145 +
146 + if (stype != IEEE80211_STYPE_BEACON)
147 + return;
148 +
149 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
150 + if (baselen > skb->len)
151 + return;
152 +
153 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
154 + skb->len - baselen, &elems);
155 +
156 + rates = ieee80211_sta_get_rates(local, &elems, band);
157 +
158 + rcu_read_lock();
159 +
160 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
161 +
162 + if (!sta) {
163 + rcu_read_unlock();
164 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
165 + GFP_KERNEL);
166 + if (!sta)
167 + return;
168 +
169 + new = true;
170 + }
171 +
172 + sta->last_rx = jiffies;
173 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
174 +
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);
178 +
179 + if (elems.wmm_param)
180 + set_sta_flags(sta, WLAN_STA_WME);
181 +
182 + if (new) {
183 + sta->flags = WLAN_STA_AUTHORIZED;
184 + rate_control_rate_init(sta);
185 + sta_info_insert_rcu(sta);
186 + }
187 +
188 + rcu_read_unlock();
189 +}
190 +
191 static void ieee80211_iface_work(struct work_struct *work)
192 {
193 struct ieee80211_sub_if_data *sdata =
194 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct
195 break;
196 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
197 break;
198 + case NL80211_IFTYPE_WDS:
199 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
200 + break;
201 default:
202 WARN(1, "frame for unexpected interface type");
203 break;
204 --- a/net/mac80211/rx.c
205 +++ b/net/mac80211/rx.c
206 @@ -2137,7 +2137,8 @@ ieee80211_rx_h_action(struct ieee80211_r
207 */
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)
213 break;
214
215 /* verify action_code is present */
216 @@ -2335,13 +2336,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
217
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;
224
225 switch (stype) {
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 */
230 break;
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
234 }
235 break;
236 case NL80211_IFTYPE_WDS:
237 - if (bssid || !ieee80211_is_data(hdr->frame_control))
238 - return 0;
239 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
240 return 0;
241 +
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))
245 + return 0;
246 + } else if (!ieee80211_is_beacon(hdr->frame_control))
247 + return 0;
248 +
249 break;
250 default:
251 /* should never get here */
252 --- a/net/mac80211/sta_info.h
253 +++ b/net/mac80211/sta_info.h
254 @@ -31,7 +31,6 @@
255 * frames.
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,
265 WLAN_STA_WME = 1<<6,
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;
277 int slot;
278 u32 bfaddr, bc = 0;
279
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);
285 ath_reset(sc, true);
286 + spin_unlock(&sc->sc_pcu_lock);
287 }
288
289 return;
290 @@ -464,6 +467,11 @@ void ath_beacon_tasklet(unsigned long da
291 ath9k_hw_txstart(ah, sc->beacon.beaconq);
292
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);
298 + }
299 }
300 }
301
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);
307 if (busy >= 99) {
308 - if (++sc->hw_busy_count >= 3)
309 + if (++sc->hw_busy_count >= 3) {
310 + spin_lock_bh(&sc->sc_pcu_lock);
311 ath_reset(sc, true);
312 + spin_unlock_bh(&sc->sc_pcu_lock);
313 + }
314 } else if (busy >= 0)
315 sc->hw_busy_count = 0;
316
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);
322 ath_reset(sc, true);
323 + spin_unlock_bh(&sc->sc_pcu_lock);
324 count = 0;
325 }
326 } else
327 @@ -674,7 +679,9 @@ void ath9k_tasklet(unsigned long data)
328
329 if ((status & ATH9K_INT_FATAL) ||
330 (status & ATH9K_INT_BB_WATCHDOG)) {
331 + spin_lock(&sc->sc_pcu_lock);
332 ath_reset(sc, true);
333 + spin_unlock(&sc->sc_pcu_lock);
334 return;
335 }
336
337 @@ -980,7 +987,6 @@ int ath_reset(struct ath_softc *sc, bool
338 del_timer_sync(&common->ani.timer);
339
340 ath9k_ps_wakeup(sc);
341 - spin_lock_bh(&sc->sc_pcu_lock);
342
343 ieee80211_stop_queues(hw);
344
345 @@ -1023,7 +1029,6 @@ int ath_reset(struct ath_softc *sc, bool
346 }
347
348 ieee80211_wake_queues(hw);
349 - spin_unlock_bh(&sc->sc_pcu_lock);
350
351 /* Start ANI */
352 if (!common->disable_ani)
353 @@ -2326,9 +2331,9 @@ static void ath9k_flush(struct ieee80211
354 ath9k_ps_wakeup(sc);
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);
358 if (!drain_txq)
359 ath_reset(sc, false);
360 + spin_unlock_bh(&sc->sc_pcu_lock);
361 ath9k_ps_restore(sc);
362 ieee80211_wake_queues(hw);
363
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
367
368 rcu_read_unlock();
369
370 - if (needreset) {
371 - spin_unlock_bh(&sc->sc_pcu_lock);
372 + if (needreset)
373 ath_reset(sc, false);
374 - spin_lock_bh(&sc->sc_pcu_lock);
375 - }
376 }
377
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
382 */
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;
387
388 /*
389 @@ -2169,7 +2167,9 @@ static void ath_tx_complete_poll_work(st
390 if (needreset) {
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);
394 ath_reset(sc, true);
395 + spin_unlock_bh(&sc->sc_pcu_lock);
396 }
397
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));
404
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;
409 reg += 4;
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,
412 int target_power)
413 {
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;
421 - u32 reg;
422 + u32 reg_olpc = 0, reg_cl_gain = 0;
423
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);
429
430 - if (chain == 0)
431 - reg = AR_PHY_TPC_11_B0;
432 - else if (chain == 1)
433 - reg = AR_PHY_TPC_11_B1;
434 - else
435 - reg = AR_PHY_TPC_11_B2;
436 + switch (chain) {
437 + case 0:
438 + reg_olpc = AR_PHY_TPC_11_B0;
439 + reg_cl_gain = AR_PHY_CL_TAB_0;
440 + break;
441 + case 1:
442 + reg_olpc = AR_PHY_TPC_11_B1;
443 + reg_cl_gain = AR_PHY_CL_TAB_1;
444 + break;
445 + case 2:
446 + reg_olpc = AR_PHY_TPC_11_B2;
447 + reg_cl_gain = AR_PHY_CL_TAB_2;
448 + break;
449 + default:
450 + ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
451 + "Invalid chainmask: %d\n", chain);
452 + break;
453 + }
454
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);
460
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) +
465 (128 / 2)) / 128;
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;
469
470 return desired_gain;
471 }
472 @@ -727,7 +741,7 @@ int ar9003_paprd_setup_gain_table(struct
473 desired_gain = ar9003_get_desired_gain(ah, chain, train_power);
474
475 gain_index = 0;
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)
479 break;
480 gain_index++;
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
486
487 +#define AR_PHY_CL_TAB_CL_GAIN_MOD 0x1f
488 +#define AR_PHY_CL_TAB_CL_GAIN_MOD_S 0
489 +
490 void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
491
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)
497 continue;
498
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];
503
504 - if (pd != NULL) {
505 - kfree(pd->pd_step);
506 - kfree(pd->pd_pwr);
507 - }
508 + kfree(pd->pd_step);
509 + kfree(pd->pd_pwr);
510 }
511
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)
518 {
519 + struct ar9003_txc *txc = (struct ar9003_txc *) ds;
520 struct ar9003_txs *ads;
521 u32 status;
522
523 @@ -238,7 +239,11 @@ static int ar9003_hw_proc_txdesc(struct
524 if ((status & AR_TxDone) == 0)
525 return -EINPROGRESS;
526
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;
531 + else
532 + return -ENOENT;
533
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);
539
540 - ts->qid = MS(ads->ds_info, AR_TxQcuNum);
541 ts->desc_id = MS(ads->status1, AR_TxDescId);
542 ts->ts_tstamp = ads->status4;
543 ts->ts_status = 0;
544 --- a/net/mac80211/wpa.c
545 +++ b/net/mac80211/wpa.c
546 @@ -15,6 +15,7 @@
547 #include <linux/gfp.h>
548 #include <asm/unaligned.h>
549 #include <net/mac80211.h>
550 +#include <crypto/aes.h>
551
552 #include "ieee80211_i.h"
553 #include "michael.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;
559 +
560 + /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */
561 + if (rx->queue == NUM_RX_DATA_QUEUES - 1)
562 + queue = 0;
563
564 /*
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
567
568 update_iv:
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;
574
575 return RX_CONTINUE;
576
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;
582 unsigned int hdrlen;
583 int len, tail;
584 u8 *pos;
585 @@ -192,11 +199,12 @@ static int tkip_encrypt_skb(struct ieee8
586 pos += hdrlen;
587
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++;
593 -
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);
597
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);
603
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);
608 }
609
610
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;
616 +
617 + /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */
618 + if (rx->queue == NUM_RX_DATA_QUEUES - 1)
619 + queue = 0;
620
621 hdrlen = ieee80211_hdrlen(hdr->frame_control);
622
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,
629 &rx->tkip_iv32,
630 &rx->tkip_iv16);
631 if (res != TKIP_DECRYPT_OK)
632 @@ -283,6 +295,8 @@ static void ccmp_special_blocks(struct s
633 unsigned int hdrlen;
634 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
635
636 + memset(scratch, 0, 6 * AES_BLOCK_LEN);
637 +
638 b_0 = scratch + 3 * AES_BLOCK_LEN;
639 aad = scratch + 4 * AES_BLOCK_LEN;
640
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;
645 - u8 *pos, *pn;
646 - int i;
647 + u8 *pos;
648 + u8 pn[6];
649 + u64 pn64;
650 + u8 scratch[6 * AES_BLOCK_LEN];
651
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;
656 pos += hdrlen;
657
658 - /* PN = PN + 1 */
659 - pn = key->u.ccmp.tx_pn;
660 + pn64 = atomic64_inc_return(&key->u.ccmp.tx_pn);
661
662 - for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
663 - pn[i]++;
664 - if (pn[i])
665 - break;
666 - }
667 + pn[5] = pn64;
668 + pn[4] = pn64 >> 8;
669 + pn[3] = pn64 >> 16;
670 + pn[2] = pn64 >> 24;
671 + pn[1] = pn64 >> 32;
672 + pn[0] = pn64 >> 40;
673
674 ccmp_pn2hdr(pos, pn, key->conf.keyidx);
675
676 @@ -418,8 +434,8 @@ static int ccmp_encrypt_skb(struct ieee8
677 return 0;
678
679 pos += CCMP_HDR_LEN;
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));
685
686 return 0;
687 @@ -475,11 +491,12 @@ ieee80211_crypto_ccmp_decrypt(struct iee
688 }
689
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);
695
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.
707 */
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
717
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");
724 break;
725
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
729
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");
736 break;
737
738 --- a/include/net/mac80211.h
739 +++ b/include/net/mac80211.h
740 @@ -960,21 +960,6 @@ enum sta_notify_cmd {
741 };
742
743 /**
744 - * enum ieee80211_tkip_key_type - get tkip key
745 - *
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.
749 - *
750 - * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
751 - * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
752 - */
753 -enum ieee80211_tkip_key_type {
754 - IEEE80211_TKIP_P1_KEY,
755 - IEEE80211_TKIP_P2_KEY,
756 -};
757 -
758 -/**
759 * enum ieee80211_hw_flags - hardware flags
760 *
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);
764
765 /**
766 - * ieee80211_get_tkip_key - get a TKIP rc4 for skb
767 + * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
768 + *
769 + * This function returns the TKIP phase 1 key for the IV32 taken
770 + * from the given packet.
771 + *
772 + * @keyconf: the parameter passed with the set key
773 + * @skb: the packet to take the IV32 value from that will be encrypted
774 + * with this P1K
775 + * @p1k: a buffer to which the key will be written, as 5 u16 values
776 + */
777 +void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
778 + struct sk_buff *skb, u16 *p1k);
779 +
780 +/**
781 + * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
782 *
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
788 + * in the packet.
789 *
790 * @keyconf: the parameter passed with the set key
791 - * @skb: the skb for which the key is needed
792 - * @type: TBD
793 - * @key: a buffer to which the key will be written
794 - */
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
801 + */
802 +void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
803 + struct sk_buff *skb, u8 *p2k);
804 +
805 /**
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);
812 }
813 }
814 + spin_lock_init(&key->u.tkip.txlock);
815 break;
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 {
821 };
822
823 struct tkip_ctx {
824 - u32 iv32;
825 - u16 iv16;
826 - u16 p1k[5];
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;
832 };
833
834 @@ -71,6 +72,9 @@ struct ieee80211_key {
835
836 union {
837 struct {
838 + /* protects tx context */
839 + spinlock_t txlock;
840 +
841 /* last used TSC */
842 struct tkip_ctx tx;
843
844 @@ -78,7 +82,7 @@ struct ieee80211_key {
845 struct tkip_ctx rx[NUM_RX_DATA_QUEUES];
846 } tkip;
847 struct {
848 - u8 tx_pn[6];
849 + atomic64_t tx_pn;
850 /*
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
860 #endif
861 - u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
862 - u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
863 } ccmp;
864 struct {
865 u8 tx_pn[6];
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;
870 }
871 ctx->state = TKIP_STATE_PHASE1_DONE;
872 + ctx->p1k_iv32 = tsc_IV32;
873 }
874
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)
882 {
883 - pos = write_tkip_iv(pos, iv16);
884 + lockdep_assert_held(&key->u.tkip.txlock);
885 +
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);
889 return pos + 4;
890 }
891
892 -void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
893 - struct sk_buff *skb, enum ieee80211_tkip_key_type type,
894 - u8 *outkey)
895 +static void ieee80211_compute_tkip_p1k(struct ieee80211_key *key, u32 iv32)
896 {
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;
900 - u8 *data;
901 - const u8 *tk;
902 - struct tkip_ctx *ctx;
903 - u16 iv16;
904 - u32 iv32;
905 -
906 - data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
907 - iv16 = data[2] | (data[0] << 8);
908 - iv32 = get_unaligned_le32(&data[4]);
909 -
910 - tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
911 - ctx = &key->u.tkip.tx;
912 -
913 -#ifdef CONFIG_MAC80211_TKIP_DEBUG
914 - printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n",
915 - iv16, iv32);
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];
919
920 - if (iv32 != ctx->iv32) {
921 - printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n",
922 - iv32, ctx->iv32);
923 - printk(KERN_DEBUG "Wrap around of iv16 in the middle of a "
924 - "fragmented packet\n");
925 - }
926 -#endif
927 + lockdep_assert_held(&key->u.tkip.txlock);
928
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);
934 + /*
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.
940 + */
941 + if (ctx->p1k_iv32 != iv32 || ctx->state == TKIP_STATE_NOT_INIT)
942 + tkip_mixing_phase1(tk, ctx, sdata->vif.addr, iv32);
943 +}
944
945 - if (type == IEEE80211_TKIP_P1_KEY) {
946 - memcpy(outkey, ctx->p1k, sizeof(u16) * 5);
947 - return;
948 - }
949 +void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
950 + struct sk_buff *skb, u16 *p1k)
951 +{
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;
959 +
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);
964 +}
965 +EXPORT_SYMBOL(ieee80211_get_tkip_p1k);
966
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)
970 +{
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;
980 +
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);
985 }
986 -EXPORT_SYMBOL(ieee80211_get_tkip_key);
987 +EXPORT_SYMBOL(ieee80211_get_tkip_p2k);
988
989 /*
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);
992 */
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)
998 {
999 u8 rc4key[16];
1000 - struct tkip_ctx *ctx = &key->u.tkip.tx;
1001 - const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
1002 -
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);
1006
1007 - tkip_mixing_phase2(tk, ctx, ctx->iv16, rc4key);
1008 + ieee80211_get_tkip_p2k(&key->conf, skb, rc4key);
1009
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);
1013 }
1014
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
1018 @@ -13,11 +13,13 @@
1019 #include <linux/crypto.h>
1020 #include "key.h"
1021
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);
1024
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);
1031 +
1032 enum {
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
1038 u8 seq[6] = {0};
1039 struct key_params params;
1040 struct ieee80211_key *key = NULL;
1041 + u64 pn64;
1042 u32 iv32;
1043 u16 iv16;
1044 int err = -ENOENT;
1045 @@ -256,12 +257,13 @@ static int ieee80211_get_key(struct wiph
1046 params.seq_len = 6;
1047 break;
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);
1056 + seq[0] = pn64;
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;
1062 params.seq = seq;
1063 params.seq_len = 6;
1064 break;
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)
1069 {
1070 const u8 *tpn;
1071 + u64 pn;
1072 char buf[20];
1073 int len;
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);
1077 break;
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);
1085 break;
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
1131 continue;
1132 if (wk->chan != local->tmp_channel)
1133 continue;
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))
1138 continue;
1139 remain_off_channel = true;
1140 }
1141
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.
1150 */
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);
1154
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
1159 else
1160 synthDelay /= 10;
1161
1162 + if (IS_CHAN_HALF_RATE(chan))
1163 + synthDelay *= 2;
1164 + else if (IS_CHAN_QUARTER_RATE(chan))
1165 + synthDelay *= 4;
1166 +
1167 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1168
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
1173 }
1174 }
1175
1176 -/*
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.
1179 - *
1180 - * The values below tested for ht40 2 chain.
1181 - * Overwrite the delay/timeouts initialized in process ini.
1182 - */
1183 -void ar9002_hw_update_async_fifo(struct ath_hw *ah)
1184 -{
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);
1192 -
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);
1195 -
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);
1200 - }
1201 -}
1202 -
1203 -/*
1204 - * We don't enable WEP aggregation on mac80211 but we keep this
1205 - * around for HAL unification purposes.
1206 - */
1207 -void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
1208 -{
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);
1212 - }
1213 -}
1214 -
1215 /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
1216 void ar9002_hw_attach_ops(struct ath_hw *ah)
1217 {
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
1221
1222 switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
1223 case 0:
1224 - if ((freq % 20) == 0)
1225 + if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
1226 + aModeRefSel = 0;
1227 + else if ((freq % 20) == 0)
1228 aModeRefSel = 3;
1229 else if ((freq % 10) == 0)
1230 aModeRefSel = 2;
1231 @@ -129,8 +131,9 @@ static int ar9002_hw_set_channel(struct
1232 channelSel = CHANSEL_5G(freq);
1233
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);
1240
1241 }
1242
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)
1246 {
1247 + int ref_div = 5;
1248 + int pll_div = 0x2c;
1249 u32 pll;
1250
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)) {
1254 + ref_div = 10;
1255 + pll_div = 0x50;
1256 + } else {
1257 + pll_div = 0x28;
1258 + }
1259 + }
1260 +
1261 + pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
1262 + pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
1263
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);
1268
1269 - if (chan && IS_CHAN_5GHZ(chan)) {
1270 - if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1271 - pll = 0x142c;
1272 - else if (AR_SREV_9280_20(ah))
1273 - pll = 0x2850;
1274 - else
1275 - pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
1276 - } else {
1277 - pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
1278 - }
1279 -
1280 return pll;
1281 }
1282
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;
1288
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))
1292 + clockrate = 117;
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))
1299 clockrate *= 2;
1300
1301 + if (ah->curchan) {
1302 + if (IS_CHAN_HALF_RATE(ah->curchan))
1303 + clockrate /= 2;
1304 + if (IS_CHAN_QUARTER_RATE(ah->curchan))
1305 + clockrate /= 4;
1306 + }
1307 +
1308 common->clockrate = clockrate;
1309 }
1310
1311 @@ -895,6 +905,13 @@ static void ath9k_hw_init_interrupt_mask
1312 }
1313 }
1314
1315 +static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
1316 +{
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);
1320 +}
1321 +
1322 static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
1323 {
1324 u32 val = ath9k_hw_mac_to_clks(ah, us);
1325 @@ -932,25 +949,60 @@ static bool ath9k_hw_set_global_txtimeou
1326
1327 void ath9k_hw_init_global_settings(struct ath_hw *ah)
1328 {
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;
1333 int acktimeout;
1334 int slottime;
1335 int sifstime;
1336 + int rx_lat = 0, tx_lat = 0, eifs = 0;
1337 + u32 reg;
1338
1339 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
1340 ah->misc_mode);
1341
1342 + if (!chan)
1343 + return;
1344 +
1345 if (ah->misc_mode != 0)
1346 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
1347
1348 - if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
1349 - sifstime = 16;
1350 - else
1351 - sifstime = 10;
1352 + rx_lat = 37;
1353 + tx_lat = 54;
1354 +
1355 + if (IS_CHAN_HALF_RATE(chan)) {
1356 + eifs = 175;
1357 + rx_lat *= 2;
1358 + tx_lat *= 2;
1359 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1360 + tx_lat += 11;
1361 +
1362 + slottime = 13;
1363 + sifstime = 32;
1364 + } else if (IS_CHAN_QUARTER_RATE(chan)) {
1365 + eifs = 340;
1366 + rx_lat *= 4;
1367 + tx_lat *= 4;
1368 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
1369 + tx_lat += 22;
1370 +
1371 + slottime = 21;
1372 + sifstime = 64;
1373 + } else {
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);
1378 +
1379 + slottime = ah->slottime;
1380 + if (IS_CHAN_5GHZ(chan))
1381 + sifstime = 16;
1382 + else
1383 + sifstime = 10;
1384 + }
1385
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;
1390
1391 /*
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;
1396
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);
1404 +
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);
1411 +
1412 }
1413 EXPORT_SYMBOL(ath9k_hw_init_global_settings);
1414
1415 @@ -1570,9 +1631,13 @@ int ath9k_hw_reset(struct ath_hw *ah, st
1416
1417 ath9k_hw_init_global_settings(ah);
1418
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);
1429 }
1430
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 /*******************/
1435
1436 +static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask)
1437 +{
1438 + eeprom_chainmask &= chip_chainmask;
1439 + if (eeprom_chainmask)
1440 + return eeprom_chainmask;
1441 + else
1442 + return chip_chainmask;
1443 +}
1444 +
1445 int ath9k_hw_fill_cap_info(struct ath_hw *ah)
1446 {
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;
1452
1453 u16 eeval;
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;
1458
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;
1465 + else
1466 + chip_chainmask = 7;
1467 +
1468 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
1469 /*
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);
1474
1475 + pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask);
1476 + pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask);
1477 +
1478 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
1479
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;
1483 } else {
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;
1491 }
1492
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);
1501
1502 /*
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)
1509 {
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))))
1513 -
1514 + bool is_mc, is_valid_tkip, strip_mic, mic_error = false;
1515 struct ath_hw *ah = common->ah;
1516 __le16 fc;
1517 u8 rx_status_len = ah->caps.rx_status_len;
1518
1519 fc = hdr->frame_control;
1520
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));
1526 +
1527 if (!rx_stats->rs_datalen)
1528 return false;
1529 /*
1530 @@ -838,6 +841,11 @@ static bool ath9k_rx_accept(struct ath_c
1531 if (rx_stats->rs_more)
1532 return true;
1533
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);
1538 +
1539 /*
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
1543 * descriptors.
1544 */
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;
1550 + }
1551 if (rx_stats->rs_status & ATH9K_RXERR_PHY)
1552 return false;
1553
1554 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
1555 *decrypt_error = true;
1556 - } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
1557 - bool is_mc;
1558 - /*
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.
1562 - */
1563 - is_mc = !!is_multicast_ether_addr(hdr->addr1);
1564 -
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;
1570 - else
1571 - rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
1572 + mic_error = false;
1573 }
1574 +
1575 /*
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
1579 }
1580 }
1581 }
1582 +
1583 + /*
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.
1588 + */
1589 + if (strip_mic)
1590 + rxs->flag |= RX_FLAG_MMIC_STRIPPED;
1591 + else if (is_mc && mic_error)
1592 + rxs->flag |= RX_FLAG_MMIC_ERROR;
1593 +
1594 return true;
1595 }
1596
1597 @@ -1938,6 +1946,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
1598 sc->rx.rxotherant = 0;
1599 }
1600
1601 + if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
1602 + skb_trim(skb, skb->len - 8);
1603 +
1604 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1605
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
1609 @@ -600,7 +600,6 @@
1610
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
1615
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
1622
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
1627
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
1635
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
1643
1644 #define AR_RESET_TSF 0x8020
1645 #define AR_RESET_TSF_ONCE 0x01000000