ath9k: fix spurious MIC failure detection, causing instability issues in AP mode
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 570-ath9k_mic_failure_fix.patch
1 --- a/drivers/net/wireless/ath/ath.h
2 +++ b/drivers/net/wireless/ath/ath.h
3 @@ -119,6 +119,7 @@ struct ath_common {
4
5 u32 keymax;
6 DECLARE_BITMAP(keymap, ATH_KEYMAX);
7 + DECLARE_BITMAP(tkip_keymap, ATH_KEYMAX);
8 u8 splitmic;
9
10 struct ath_regulatory regulatory;
11 --- a/drivers/net/wireless/ath/ath9k/common.c
12 +++ b/drivers/net/wireless/ath/ath9k/common.c
13 @@ -366,9 +366,13 @@ int ath9k_cmn_key_config(struct ath_comm
14 set_bit(idx, common->keymap);
15 if (key->alg == ALG_TKIP) {
16 set_bit(idx + 64, common->keymap);
17 + set_bit(idx, common->tkip_keymap);
18 + set_bit(idx + 64, common->tkip_keymap);
19 if (common->splitmic) {
20 set_bit(idx + 32, common->keymap);
21 set_bit(idx + 64 + 32, common->keymap);
22 + set_bit(idx + 32, common->tkip_keymap);
23 + set_bit(idx + 64 + 32, common->tkip_keymap);
24 }
25 }
26
27 @@ -393,10 +397,17 @@ void ath9k_cmn_key_delete(struct ath_com
28 return;
29
30 clear_bit(key->hw_key_idx + 64, common->keymap);
31 +
32 + clear_bit(key->hw_key_idx, common->tkip_keymap);
33 + clear_bit(key->hw_key_idx + 64, common->tkip_keymap);
34 +
35 if (common->splitmic) {
36 ath9k_hw_keyreset(ah, key->hw_key_idx + 32);
37 clear_bit(key->hw_key_idx + 32, common->keymap);
38 clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
39 +
40 + clear_bit(key->hw_key_idx + 32, common->tkip_keymap);
41 + clear_bit(key->hw_key_idx + 64 + 32, common->tkip_keymap);
42 }
43 }
44 EXPORT_SYMBOL(ath9k_cmn_key_delete);
45 --- a/drivers/net/wireless/ath/ath9k/recv.c
46 +++ b/drivers/net/wireless/ath/ath9k/recv.c
47 @@ -870,15 +870,19 @@ static bool ath9k_rx_accept(struct ath_c
48 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
49 *decrypt_error = true;
50 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
51 - if (ieee80211_is_ctl(fc))
52 - /*
53 - * Sometimes, we get invalid
54 - * MIC failures on valid control frames.
55 - * Remove these mic errors.
56 - */
57 - rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
58 - else
59 + /*
60 + * The MIC error bit is only valid if the frame
61 + * is not a control frame, and it was decrypted using
62 + * a TKIP key.
63 + */
64 + if (!ieee80211_is_ctl(fc) &&
65 + rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
66 + test_bit(rx_stats->rs_keyix, common->tkip_keymap)) {
67 rxs->flag |= RX_FLAG_MMIC_ERROR;
68 + } else {
69 + rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
70 + *decrypt_error = true;
71 + }
72 }
73 /*
74 * Reject error frames with the exception of