1ebacd801SBjoern A. Zeeb /*
2ebacd801SBjoern A. Zeeb * Copyright (c) 2009 Atheros Communications Inc.
3ebacd801SBjoern A. Zeeb * Copyright (c) 2010 Bruno Randolf <br1@einfach.org>
4ebacd801SBjoern A. Zeeb *
5ebacd801SBjoern A. Zeeb * Permission to use, copy, modify, and/or distribute this software for any
6ebacd801SBjoern A. Zeeb * purpose with or without fee is hereby granted, provided that the above
7ebacd801SBjoern A. Zeeb * copyright notice and this permission notice appear in all copies.
8ebacd801SBjoern A. Zeeb *
9ebacd801SBjoern A. Zeeb * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10ebacd801SBjoern A. Zeeb * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11ebacd801SBjoern A. Zeeb * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12ebacd801SBjoern A. Zeeb * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13ebacd801SBjoern A. Zeeb * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14ebacd801SBjoern A. Zeeb * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15ebacd801SBjoern A. Zeeb * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16ebacd801SBjoern A. Zeeb */
17ebacd801SBjoern A. Zeeb
18ebacd801SBjoern A. Zeeb #include <linux/export.h>
19ebacd801SBjoern A. Zeeb #include <asm/unaligned.h>
20ebacd801SBjoern A. Zeeb #include <net/mac80211.h>
21ebacd801SBjoern A. Zeeb
22ebacd801SBjoern A. Zeeb #include "ath.h"
23ebacd801SBjoern A. Zeeb #include "reg.h"
24ebacd801SBjoern A. Zeeb
25ebacd801SBjoern A. Zeeb #define REG_READ (common->ops->read)
26ebacd801SBjoern A. Zeeb #define REG_WRITE(_ah, _reg, _val) (common->ops->write)(_ah, _val, _reg)
27ebacd801SBjoern A. Zeeb #define ENABLE_REGWRITE_BUFFER(_ah) \
28ebacd801SBjoern A. Zeeb if (common->ops->enable_write_buffer) \
29ebacd801SBjoern A. Zeeb common->ops->enable_write_buffer((_ah));
30ebacd801SBjoern A. Zeeb
31ebacd801SBjoern A. Zeeb #define REGWRITE_BUFFER_FLUSH(_ah) \
32ebacd801SBjoern A. Zeeb if (common->ops->write_flush) \
33ebacd801SBjoern A. Zeeb common->ops->write_flush((_ah));
34ebacd801SBjoern A. Zeeb
35ebacd801SBjoern A. Zeeb
36ebacd801SBjoern A. Zeeb #define IEEE80211_WEP_NKID 4 /* number of key ids */
37ebacd801SBjoern A. Zeeb
38ebacd801SBjoern A. Zeeb /************************/
39ebacd801SBjoern A. Zeeb /* Key Cache Management */
40ebacd801SBjoern A. Zeeb /************************/
41ebacd801SBjoern A. Zeeb
ath_hw_keyreset(struct ath_common * common,u16 entry)42ebacd801SBjoern A. Zeeb bool ath_hw_keyreset(struct ath_common *common, u16 entry)
43ebacd801SBjoern A. Zeeb {
44ebacd801SBjoern A. Zeeb u32 keyType;
45ebacd801SBjoern A. Zeeb void *ah = common->ah;
46ebacd801SBjoern A. Zeeb
47ebacd801SBjoern A. Zeeb if (entry >= common->keymax) {
48ebacd801SBjoern A. Zeeb ath_err(common, "keyreset: keycache entry %u out of range\n",
49ebacd801SBjoern A. Zeeb entry);
50ebacd801SBjoern A. Zeeb return false;
51ebacd801SBjoern A. Zeeb }
52ebacd801SBjoern A. Zeeb
53ebacd801SBjoern A. Zeeb keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry));
54ebacd801SBjoern A. Zeeb
55ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
56ebacd801SBjoern A. Zeeb
57ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);
58ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);
59ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);
60ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);
61ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);
62ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);
63ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);
64ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);
65ebacd801SBjoern A. Zeeb
66ebacd801SBjoern A. Zeeb if (keyType == AR_KEYTABLE_TYPE_TKIP) {
67ebacd801SBjoern A. Zeeb u16 micentry = entry + 64;
68ebacd801SBjoern A. Zeeb
69ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);
70ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
71ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);
72ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
73ebacd801SBjoern A. Zeeb if (common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) {
74ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
75ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
76ebacd801SBjoern A. Zeeb AR_KEYTABLE_TYPE_CLR);
77ebacd801SBjoern A. Zeeb }
78ebacd801SBjoern A. Zeeb
79ebacd801SBjoern A. Zeeb }
80ebacd801SBjoern A. Zeeb
81ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
82ebacd801SBjoern A. Zeeb
83ebacd801SBjoern A. Zeeb return true;
84ebacd801SBjoern A. Zeeb }
85ebacd801SBjoern A. Zeeb EXPORT_SYMBOL(ath_hw_keyreset);
86ebacd801SBjoern A. Zeeb
ath_hw_keysetmac(struct ath_common * common,u16 entry,const u8 * mac)87ebacd801SBjoern A. Zeeb bool ath_hw_keysetmac(struct ath_common *common, u16 entry, const u8 *mac)
88ebacd801SBjoern A. Zeeb {
89ebacd801SBjoern A. Zeeb u32 macHi, macLo;
90ebacd801SBjoern A. Zeeb u32 unicast_flag = AR_KEYTABLE_VALID;
91ebacd801SBjoern A. Zeeb void *ah = common->ah;
92ebacd801SBjoern A. Zeeb
93ebacd801SBjoern A. Zeeb if (entry >= common->keymax) {
94ebacd801SBjoern A. Zeeb ath_err(common, "keysetmac: keycache entry %u out of range\n",
95ebacd801SBjoern A. Zeeb entry);
96ebacd801SBjoern A. Zeeb return false;
97ebacd801SBjoern A. Zeeb }
98ebacd801SBjoern A. Zeeb
99ebacd801SBjoern A. Zeeb if (mac != NULL) {
100ebacd801SBjoern A. Zeeb /*
101ebacd801SBjoern A. Zeeb * AR_KEYTABLE_VALID indicates that the address is a unicast
102ebacd801SBjoern A. Zeeb * address, which must match the transmitter address for
103ebacd801SBjoern A. Zeeb * decrypting frames.
104ebacd801SBjoern A. Zeeb * Not setting this bit allows the hardware to use the key
105ebacd801SBjoern A. Zeeb * for multicast frame decryption.
106ebacd801SBjoern A. Zeeb */
107ebacd801SBjoern A. Zeeb if (mac[0] & 0x01)
108ebacd801SBjoern A. Zeeb unicast_flag = 0;
109ebacd801SBjoern A. Zeeb
110ebacd801SBjoern A. Zeeb macLo = get_unaligned_le32(mac);
111ebacd801SBjoern A. Zeeb macHi = get_unaligned_le16(mac + 4);
112ebacd801SBjoern A. Zeeb macLo >>= 1;
113ebacd801SBjoern A. Zeeb macLo |= (macHi & 1) << 31;
114ebacd801SBjoern A. Zeeb macHi >>= 1;
115ebacd801SBjoern A. Zeeb } else {
116ebacd801SBjoern A. Zeeb macLo = macHi = 0;
117ebacd801SBjoern A. Zeeb }
118ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
119ebacd801SBjoern A. Zeeb
120ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), macLo);
121ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), macHi | unicast_flag);
122ebacd801SBjoern A. Zeeb
123ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
124ebacd801SBjoern A. Zeeb
125ebacd801SBjoern A. Zeeb return true;
126ebacd801SBjoern A. Zeeb }
127ebacd801SBjoern A. Zeeb EXPORT_SYMBOL(ath_hw_keysetmac);
128ebacd801SBjoern A. Zeeb
ath_hw_set_keycache_entry(struct ath_common * common,u16 entry,const struct ath_keyval * k,const u8 * mac)129ebacd801SBjoern A. Zeeb static bool ath_hw_set_keycache_entry(struct ath_common *common, u16 entry,
130ebacd801SBjoern A. Zeeb const struct ath_keyval *k,
131ebacd801SBjoern A. Zeeb const u8 *mac)
132ebacd801SBjoern A. Zeeb {
133ebacd801SBjoern A. Zeeb void *ah = common->ah;
134ebacd801SBjoern A. Zeeb u32 key0, key1, key2, key3, key4;
135ebacd801SBjoern A. Zeeb u32 keyType;
136ebacd801SBjoern A. Zeeb
137ebacd801SBjoern A. Zeeb if (entry >= common->keymax) {
138ebacd801SBjoern A. Zeeb ath_err(common, "set-entry: keycache entry %u out of range\n",
139ebacd801SBjoern A. Zeeb entry);
140ebacd801SBjoern A. Zeeb return false;
141ebacd801SBjoern A. Zeeb }
142ebacd801SBjoern A. Zeeb
143ebacd801SBjoern A. Zeeb switch (k->kv_type) {
144ebacd801SBjoern A. Zeeb case ATH_CIPHER_AES_OCB:
145ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_AES;
146ebacd801SBjoern A. Zeeb break;
147ebacd801SBjoern A. Zeeb case ATH_CIPHER_AES_CCM:
148ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_CIPHER_AESCCM)) {
149ebacd801SBjoern A. Zeeb ath_dbg(common, ANY,
150ebacd801SBjoern A. Zeeb "AES-CCM not supported by this mac rev\n");
151ebacd801SBjoern A. Zeeb return false;
152ebacd801SBjoern A. Zeeb }
153ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_CCM;
154ebacd801SBjoern A. Zeeb break;
155ebacd801SBjoern A. Zeeb case ATH_CIPHER_TKIP:
156ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_TKIP;
157ebacd801SBjoern A. Zeeb if (entry + 64 >= common->keymax) {
158ebacd801SBjoern A. Zeeb ath_dbg(common, ANY,
159ebacd801SBjoern A. Zeeb "entry %u inappropriate for TKIP\n", entry);
160ebacd801SBjoern A. Zeeb return false;
161ebacd801SBjoern A. Zeeb }
162ebacd801SBjoern A. Zeeb break;
163ebacd801SBjoern A. Zeeb case ATH_CIPHER_WEP:
164ebacd801SBjoern A. Zeeb if (k->kv_len < WLAN_KEY_LEN_WEP40) {
165ebacd801SBjoern A. Zeeb ath_dbg(common, ANY, "WEP key length %u too small\n",
166ebacd801SBjoern A. Zeeb k->kv_len);
167ebacd801SBjoern A. Zeeb return false;
168ebacd801SBjoern A. Zeeb }
169ebacd801SBjoern A. Zeeb if (k->kv_len <= WLAN_KEY_LEN_WEP40)
170ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_40;
171ebacd801SBjoern A. Zeeb else if (k->kv_len <= WLAN_KEY_LEN_WEP104)
172ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_104;
173ebacd801SBjoern A. Zeeb else
174ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_128;
175ebacd801SBjoern A. Zeeb break;
176ebacd801SBjoern A. Zeeb case ATH_CIPHER_CLR:
177ebacd801SBjoern A. Zeeb keyType = AR_KEYTABLE_TYPE_CLR;
178ebacd801SBjoern A. Zeeb break;
179ebacd801SBjoern A. Zeeb default:
180ebacd801SBjoern A. Zeeb ath_err(common, "cipher %u not supported\n", k->kv_type);
181ebacd801SBjoern A. Zeeb return false;
182ebacd801SBjoern A. Zeeb }
183ebacd801SBjoern A. Zeeb
184ebacd801SBjoern A. Zeeb key0 = get_unaligned_le32(k->kv_val + 0);
185ebacd801SBjoern A. Zeeb key1 = get_unaligned_le16(k->kv_val + 4);
186ebacd801SBjoern A. Zeeb key2 = get_unaligned_le32(k->kv_val + 6);
187ebacd801SBjoern A. Zeeb key3 = get_unaligned_le16(k->kv_val + 10);
188ebacd801SBjoern A. Zeeb key4 = get_unaligned_le32(k->kv_val + 12);
189ebacd801SBjoern A. Zeeb if (k->kv_len <= WLAN_KEY_LEN_WEP104)
190ebacd801SBjoern A. Zeeb key4 &= 0xff;
191ebacd801SBjoern A. Zeeb
192ebacd801SBjoern A. Zeeb /*
193ebacd801SBjoern A. Zeeb * Note: Key cache registers access special memory area that requires
194ebacd801SBjoern A. Zeeb * two 32-bit writes to actually update the values in the internal
195ebacd801SBjoern A. Zeeb * memory. Consequently, the exact order and pairs used here must be
196ebacd801SBjoern A. Zeeb * maintained.
197ebacd801SBjoern A. Zeeb */
198ebacd801SBjoern A. Zeeb
199ebacd801SBjoern A. Zeeb if (keyType == AR_KEYTABLE_TYPE_TKIP) {
200ebacd801SBjoern A. Zeeb u16 micentry = entry + 64;
201ebacd801SBjoern A. Zeeb
202ebacd801SBjoern A. Zeeb /*
203ebacd801SBjoern A. Zeeb * Write inverted key[47:0] first to avoid Michael MIC errors
204ebacd801SBjoern A. Zeeb * on frames that could be sent or received at the same time.
205ebacd801SBjoern A. Zeeb * The correct key will be written in the end once everything
206ebacd801SBjoern A. Zeeb * else is ready.
207ebacd801SBjoern A. Zeeb */
208ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0);
209ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1);
210ebacd801SBjoern A. Zeeb
211ebacd801SBjoern A. Zeeb /* Write key[95:48] */
212ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
213ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
214ebacd801SBjoern A. Zeeb
215ebacd801SBjoern A. Zeeb /* Write key[127:96] and key type */
216ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
217ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
218ebacd801SBjoern A. Zeeb
219ebacd801SBjoern A. Zeeb /* Write MAC address for the entry */
220ebacd801SBjoern A. Zeeb (void) ath_hw_keysetmac(common, entry, mac);
221ebacd801SBjoern A. Zeeb
222ebacd801SBjoern A. Zeeb if (common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) {
223ebacd801SBjoern A. Zeeb /*
224ebacd801SBjoern A. Zeeb * TKIP uses two key cache entries:
225ebacd801SBjoern A. Zeeb * Michael MIC TX/RX keys in the same key cache entry
226ebacd801SBjoern A. Zeeb * (idx = main index + 64):
227ebacd801SBjoern A. Zeeb * key0 [31:0] = RX key [31:0]
228ebacd801SBjoern A. Zeeb * key1 [15:0] = TX key [31:16]
229ebacd801SBjoern A. Zeeb * key1 [31:16] = reserved
230ebacd801SBjoern A. Zeeb * key2 [31:0] = RX key [63:32]
231ebacd801SBjoern A. Zeeb * key3 [15:0] = TX key [15:0]
232ebacd801SBjoern A. Zeeb * key3 [31:16] = reserved
233ebacd801SBjoern A. Zeeb * key4 [31:0] = TX key [63:32]
234ebacd801SBjoern A. Zeeb */
235ebacd801SBjoern A. Zeeb u32 mic0, mic1, mic2, mic3, mic4;
236ebacd801SBjoern A. Zeeb
237ebacd801SBjoern A. Zeeb mic0 = get_unaligned_le32(k->kv_mic + 0);
238ebacd801SBjoern A. Zeeb mic2 = get_unaligned_le32(k->kv_mic + 4);
239ebacd801SBjoern A. Zeeb mic1 = get_unaligned_le16(k->kv_txmic + 2) & 0xffff;
240ebacd801SBjoern A. Zeeb mic3 = get_unaligned_le16(k->kv_txmic + 0) & 0xffff;
241ebacd801SBjoern A. Zeeb mic4 = get_unaligned_le32(k->kv_txmic + 4);
242ebacd801SBjoern A. Zeeb
243ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
244ebacd801SBjoern A. Zeeb
245ebacd801SBjoern A. Zeeb /* Write RX[31:0] and TX[31:16] */
246ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
247ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1);
248ebacd801SBjoern A. Zeeb
249ebacd801SBjoern A. Zeeb /* Write RX[63:32] and TX[15:0] */
250ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
251ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3);
252ebacd801SBjoern A. Zeeb
253ebacd801SBjoern A. Zeeb /* Write TX[63:32] and keyType(reserved) */
254ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4);
255ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
256ebacd801SBjoern A. Zeeb AR_KEYTABLE_TYPE_CLR);
257ebacd801SBjoern A. Zeeb
258ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
259ebacd801SBjoern A. Zeeb
260ebacd801SBjoern A. Zeeb } else {
261ebacd801SBjoern A. Zeeb /*
262ebacd801SBjoern A. Zeeb * TKIP uses four key cache entries (two for group
263ebacd801SBjoern A. Zeeb * keys):
264ebacd801SBjoern A. Zeeb * Michael MIC TX/RX keys are in different key cache
265ebacd801SBjoern A. Zeeb * entries (idx = main index + 64 for TX and
266ebacd801SBjoern A. Zeeb * main index + 32 + 96 for RX):
267ebacd801SBjoern A. Zeeb * key0 [31:0] = TX/RX MIC key [31:0]
268ebacd801SBjoern A. Zeeb * key1 [31:0] = reserved
269ebacd801SBjoern A. Zeeb * key2 [31:0] = TX/RX MIC key [63:32]
270ebacd801SBjoern A. Zeeb * key3 [31:0] = reserved
271ebacd801SBjoern A. Zeeb * key4 [31:0] = reserved
272ebacd801SBjoern A. Zeeb *
273ebacd801SBjoern A. Zeeb * Upper layer code will call this function separately
274ebacd801SBjoern A. Zeeb * for TX and RX keys when these registers offsets are
275ebacd801SBjoern A. Zeeb * used.
276ebacd801SBjoern A. Zeeb */
277ebacd801SBjoern A. Zeeb u32 mic0, mic2;
278ebacd801SBjoern A. Zeeb
279ebacd801SBjoern A. Zeeb mic0 = get_unaligned_le32(k->kv_mic + 0);
280ebacd801SBjoern A. Zeeb mic2 = get_unaligned_le32(k->kv_mic + 4);
281ebacd801SBjoern A. Zeeb
282ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
283ebacd801SBjoern A. Zeeb
284ebacd801SBjoern A. Zeeb /* Write MIC key[31:0] */
285ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
286ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
287ebacd801SBjoern A. Zeeb
288ebacd801SBjoern A. Zeeb /* Write MIC key[63:32] */
289ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
290ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
291ebacd801SBjoern A. Zeeb
292ebacd801SBjoern A. Zeeb /* Write TX[63:32] and keyType(reserved) */
293ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
294ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
295ebacd801SBjoern A. Zeeb AR_KEYTABLE_TYPE_CLR);
296ebacd801SBjoern A. Zeeb
297ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
298ebacd801SBjoern A. Zeeb }
299ebacd801SBjoern A. Zeeb
300ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
301ebacd801SBjoern A. Zeeb
302ebacd801SBjoern A. Zeeb /* MAC address registers are reserved for the MIC entry */
303ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0);
304ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0);
305ebacd801SBjoern A. Zeeb
306ebacd801SBjoern A. Zeeb /*
307ebacd801SBjoern A. Zeeb * Write the correct (un-inverted) key[47:0] last to enable
308ebacd801SBjoern A. Zeeb * TKIP now that all other registers are set with correct
309ebacd801SBjoern A. Zeeb * values.
310ebacd801SBjoern A. Zeeb */
311ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
312ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
313ebacd801SBjoern A. Zeeb
314ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
315ebacd801SBjoern A. Zeeb } else {
316ebacd801SBjoern A. Zeeb ENABLE_REGWRITE_BUFFER(ah);
317ebacd801SBjoern A. Zeeb
318ebacd801SBjoern A. Zeeb /* Write key[47:0] */
319ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
320ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
321ebacd801SBjoern A. Zeeb
322ebacd801SBjoern A. Zeeb /* Write key[95:48] */
323ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
324ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
325ebacd801SBjoern A. Zeeb
326ebacd801SBjoern A. Zeeb /* Write key[127:96] and key type */
327ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
328ebacd801SBjoern A. Zeeb REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
329ebacd801SBjoern A. Zeeb
330ebacd801SBjoern A. Zeeb REGWRITE_BUFFER_FLUSH(ah);
331ebacd801SBjoern A. Zeeb
332ebacd801SBjoern A. Zeeb /* Write MAC address for the entry */
333ebacd801SBjoern A. Zeeb (void) ath_hw_keysetmac(common, entry, mac);
334ebacd801SBjoern A. Zeeb }
335ebacd801SBjoern A. Zeeb
336ebacd801SBjoern A. Zeeb return true;
337ebacd801SBjoern A. Zeeb }
338ebacd801SBjoern A. Zeeb
ath_setkey_tkip(struct ath_common * common,u16 keyix,const u8 * key,struct ath_keyval * hk,const u8 * addr,bool authenticator)339ebacd801SBjoern A. Zeeb static int ath_setkey_tkip(struct ath_common *common, u16 keyix, const u8 *key,
340ebacd801SBjoern A. Zeeb struct ath_keyval *hk, const u8 *addr,
341ebacd801SBjoern A. Zeeb bool authenticator)
342ebacd801SBjoern A. Zeeb {
343ebacd801SBjoern A. Zeeb const u8 *key_rxmic;
344ebacd801SBjoern A. Zeeb const u8 *key_txmic;
345ebacd801SBjoern A. Zeeb
346ebacd801SBjoern A. Zeeb key_txmic = key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
347ebacd801SBjoern A. Zeeb key_rxmic = key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
348ebacd801SBjoern A. Zeeb
349ebacd801SBjoern A. Zeeb if (addr == NULL) {
350ebacd801SBjoern A. Zeeb /*
351ebacd801SBjoern A. Zeeb * Group key installation - only two key cache entries are used
352ebacd801SBjoern A. Zeeb * regardless of splitmic capability since group key is only
353ebacd801SBjoern A. Zeeb * used either for TX or RX.
354ebacd801SBjoern A. Zeeb */
355ebacd801SBjoern A. Zeeb if (authenticator) {
356ebacd801SBjoern A. Zeeb memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
357ebacd801SBjoern A. Zeeb memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_mic));
358ebacd801SBjoern A. Zeeb } else {
359ebacd801SBjoern A. Zeeb memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
360ebacd801SBjoern A. Zeeb memcpy(hk->kv_txmic, key_rxmic, sizeof(hk->kv_mic));
361ebacd801SBjoern A. Zeeb }
362ebacd801SBjoern A. Zeeb return ath_hw_set_keycache_entry(common, keyix, hk, addr);
363ebacd801SBjoern A. Zeeb }
364ebacd801SBjoern A. Zeeb if (common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) {
365ebacd801SBjoern A. Zeeb /* TX and RX keys share the same key cache entry. */
366ebacd801SBjoern A. Zeeb memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
367ebacd801SBjoern A. Zeeb memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_txmic));
368ebacd801SBjoern A. Zeeb return ath_hw_set_keycache_entry(common, keyix, hk, addr);
369ebacd801SBjoern A. Zeeb }
370ebacd801SBjoern A. Zeeb
371ebacd801SBjoern A. Zeeb /* Separate key cache entries for TX and RX */
372ebacd801SBjoern A. Zeeb
373ebacd801SBjoern A. Zeeb /* TX key goes at first index, RX key at +32. */
374ebacd801SBjoern A. Zeeb memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
375ebacd801SBjoern A. Zeeb if (!ath_hw_set_keycache_entry(common, keyix, hk, NULL)) {
376ebacd801SBjoern A. Zeeb /* TX MIC entry failed. No need to proceed further */
377ebacd801SBjoern A. Zeeb ath_err(common, "Setting TX MIC Key Failed\n");
378ebacd801SBjoern A. Zeeb return 0;
379ebacd801SBjoern A. Zeeb }
380ebacd801SBjoern A. Zeeb
381ebacd801SBjoern A. Zeeb memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
382ebacd801SBjoern A. Zeeb /* XXX delete tx key on failure? */
383ebacd801SBjoern A. Zeeb return ath_hw_set_keycache_entry(common, keyix + 32, hk, addr);
384ebacd801SBjoern A. Zeeb }
385ebacd801SBjoern A. Zeeb
ath_reserve_key_cache_slot_tkip(struct ath_common * common)386ebacd801SBjoern A. Zeeb static int ath_reserve_key_cache_slot_tkip(struct ath_common *common)
387ebacd801SBjoern A. Zeeb {
388ebacd801SBjoern A. Zeeb int i;
389ebacd801SBjoern A. Zeeb
390ebacd801SBjoern A. Zeeb for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) {
391ebacd801SBjoern A. Zeeb if (test_bit(i, common->keymap) ||
392ebacd801SBjoern A. Zeeb test_bit(i + 64, common->keymap))
393ebacd801SBjoern A. Zeeb continue; /* At least one part of TKIP key allocated */
394ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) &&
395ebacd801SBjoern A. Zeeb (test_bit(i + 32, common->keymap) ||
396ebacd801SBjoern A. Zeeb test_bit(i + 64 + 32, common->keymap)))
397ebacd801SBjoern A. Zeeb continue; /* At least one part of TKIP key allocated */
398ebacd801SBjoern A. Zeeb
399ebacd801SBjoern A. Zeeb /* Found a free slot for a TKIP key */
400ebacd801SBjoern A. Zeeb return i;
401ebacd801SBjoern A. Zeeb }
402ebacd801SBjoern A. Zeeb return -1;
403ebacd801SBjoern A. Zeeb }
404ebacd801SBjoern A. Zeeb
ath_reserve_key_cache_slot(struct ath_common * common,u32 cipher)405ebacd801SBjoern A. Zeeb static int ath_reserve_key_cache_slot(struct ath_common *common,
406ebacd801SBjoern A. Zeeb u32 cipher)
407ebacd801SBjoern A. Zeeb {
408ebacd801SBjoern A. Zeeb int i;
409ebacd801SBjoern A. Zeeb
410ebacd801SBjoern A. Zeeb if (cipher == WLAN_CIPHER_SUITE_TKIP)
411ebacd801SBjoern A. Zeeb return ath_reserve_key_cache_slot_tkip(common);
412ebacd801SBjoern A. Zeeb
413ebacd801SBjoern A. Zeeb /* First, try to find slots that would not be available for TKIP. */
414ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
415ebacd801SBjoern A. Zeeb for (i = IEEE80211_WEP_NKID; i < common->keymax / 4; i++) {
416ebacd801SBjoern A. Zeeb if (!test_bit(i, common->keymap) &&
417ebacd801SBjoern A. Zeeb (test_bit(i + 32, common->keymap) ||
418ebacd801SBjoern A. Zeeb test_bit(i + 64, common->keymap) ||
419ebacd801SBjoern A. Zeeb test_bit(i + 64 + 32, common->keymap)))
420ebacd801SBjoern A. Zeeb return i;
421ebacd801SBjoern A. Zeeb if (!test_bit(i + 32, common->keymap) &&
422ebacd801SBjoern A. Zeeb (test_bit(i, common->keymap) ||
423ebacd801SBjoern A. Zeeb test_bit(i + 64, common->keymap) ||
424ebacd801SBjoern A. Zeeb test_bit(i + 64 + 32, common->keymap)))
425ebacd801SBjoern A. Zeeb return i + 32;
426ebacd801SBjoern A. Zeeb if (!test_bit(i + 64, common->keymap) &&
427ebacd801SBjoern A. Zeeb (test_bit(i , common->keymap) ||
428ebacd801SBjoern A. Zeeb test_bit(i + 32, common->keymap) ||
429ebacd801SBjoern A. Zeeb test_bit(i + 64 + 32, common->keymap)))
430ebacd801SBjoern A. Zeeb return i + 64;
431ebacd801SBjoern A. Zeeb if (!test_bit(i + 64 + 32, common->keymap) &&
432ebacd801SBjoern A. Zeeb (test_bit(i, common->keymap) ||
433ebacd801SBjoern A. Zeeb test_bit(i + 32, common->keymap) ||
434ebacd801SBjoern A. Zeeb test_bit(i + 64, common->keymap)))
435ebacd801SBjoern A. Zeeb return i + 64 + 32;
436ebacd801SBjoern A. Zeeb }
437ebacd801SBjoern A. Zeeb } else {
438ebacd801SBjoern A. Zeeb for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) {
439ebacd801SBjoern A. Zeeb if (!test_bit(i, common->keymap) &&
440ebacd801SBjoern A. Zeeb test_bit(i + 64, common->keymap))
441ebacd801SBjoern A. Zeeb return i;
442ebacd801SBjoern A. Zeeb if (test_bit(i, common->keymap) &&
443ebacd801SBjoern A. Zeeb !test_bit(i + 64, common->keymap))
444ebacd801SBjoern A. Zeeb return i + 64;
445ebacd801SBjoern A. Zeeb }
446ebacd801SBjoern A. Zeeb }
447ebacd801SBjoern A. Zeeb
448ebacd801SBjoern A. Zeeb /* No partially used TKIP slots, pick any available slot */
449ebacd801SBjoern A. Zeeb for (i = IEEE80211_WEP_NKID; i < common->keymax; i++) {
450ebacd801SBjoern A. Zeeb /* Do not allow slots that could be needed for TKIP group keys
451ebacd801SBjoern A. Zeeb * to be used. This limitation could be removed if we know that
452ebacd801SBjoern A. Zeeb * TKIP will not be used. */
453ebacd801SBjoern A. Zeeb if (i >= 64 && i < 64 + IEEE80211_WEP_NKID)
454ebacd801SBjoern A. Zeeb continue;
455ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
456ebacd801SBjoern A. Zeeb if (i >= 32 && i < 32 + IEEE80211_WEP_NKID)
457ebacd801SBjoern A. Zeeb continue;
458ebacd801SBjoern A. Zeeb if (i >= 64 + 32 && i < 64 + 32 + IEEE80211_WEP_NKID)
459ebacd801SBjoern A. Zeeb continue;
460ebacd801SBjoern A. Zeeb }
461ebacd801SBjoern A. Zeeb
462ebacd801SBjoern A. Zeeb if (!test_bit(i, common->keymap))
463ebacd801SBjoern A. Zeeb return i; /* Found a free slot for a key */
464ebacd801SBjoern A. Zeeb }
465ebacd801SBjoern A. Zeeb
466ebacd801SBjoern A. Zeeb /* No free slot found */
467ebacd801SBjoern A. Zeeb return -1;
468ebacd801SBjoern A. Zeeb }
469ebacd801SBjoern A. Zeeb
470ebacd801SBjoern A. Zeeb /*
471ebacd801SBjoern A. Zeeb * Configure encryption in the HW.
472ebacd801SBjoern A. Zeeb */
ath_key_config(struct ath_common * common,struct ieee80211_vif * vif,struct ieee80211_sta * sta,struct ieee80211_key_conf * key)473ebacd801SBjoern A. Zeeb int ath_key_config(struct ath_common *common,
474ebacd801SBjoern A. Zeeb struct ieee80211_vif *vif,
475ebacd801SBjoern A. Zeeb struct ieee80211_sta *sta,
476ebacd801SBjoern A. Zeeb struct ieee80211_key_conf *key)
477ebacd801SBjoern A. Zeeb {
478ebacd801SBjoern A. Zeeb struct ath_keyval hk;
479ebacd801SBjoern A. Zeeb const u8 *mac = NULL;
480ebacd801SBjoern A. Zeeb u8 gmac[ETH_ALEN];
481ebacd801SBjoern A. Zeeb int ret = 0;
482ebacd801SBjoern A. Zeeb int idx;
483ebacd801SBjoern A. Zeeb
484ebacd801SBjoern A. Zeeb memset(&hk, 0, sizeof(hk));
485ebacd801SBjoern A. Zeeb
486ebacd801SBjoern A. Zeeb switch (key->cipher) {
487ebacd801SBjoern A. Zeeb case 0:
488ebacd801SBjoern A. Zeeb hk.kv_type = ATH_CIPHER_CLR;
489ebacd801SBjoern A. Zeeb break;
490ebacd801SBjoern A. Zeeb case WLAN_CIPHER_SUITE_WEP40:
491ebacd801SBjoern A. Zeeb case WLAN_CIPHER_SUITE_WEP104:
492ebacd801SBjoern A. Zeeb hk.kv_type = ATH_CIPHER_WEP;
493ebacd801SBjoern A. Zeeb break;
494ebacd801SBjoern A. Zeeb case WLAN_CIPHER_SUITE_TKIP:
495ebacd801SBjoern A. Zeeb hk.kv_type = ATH_CIPHER_TKIP;
496ebacd801SBjoern A. Zeeb break;
497ebacd801SBjoern A. Zeeb case WLAN_CIPHER_SUITE_CCMP:
498ebacd801SBjoern A. Zeeb hk.kv_type = ATH_CIPHER_AES_CCM;
499ebacd801SBjoern A. Zeeb break;
500ebacd801SBjoern A. Zeeb default:
501ebacd801SBjoern A. Zeeb return -EOPNOTSUPP;
502ebacd801SBjoern A. Zeeb }
503ebacd801SBjoern A. Zeeb
504ebacd801SBjoern A. Zeeb hk.kv_len = key->keylen;
505ebacd801SBjoern A. Zeeb if (key->keylen)
506*eb50aa68SBjoern A. Zeeb memcpy(&hk.kv_values, key->key, key->keylen);
507ebacd801SBjoern A. Zeeb
508ebacd801SBjoern A. Zeeb if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
509ebacd801SBjoern A. Zeeb switch (vif->type) {
510ebacd801SBjoern A. Zeeb case NL80211_IFTYPE_AP:
511ebacd801SBjoern A. Zeeb memcpy(gmac, vif->addr, ETH_ALEN);
512ebacd801SBjoern A. Zeeb gmac[0] |= 0x01;
513ebacd801SBjoern A. Zeeb mac = gmac;
514ebacd801SBjoern A. Zeeb idx = ath_reserve_key_cache_slot(common, key->cipher);
515ebacd801SBjoern A. Zeeb break;
516ebacd801SBjoern A. Zeeb case NL80211_IFTYPE_ADHOC:
517ebacd801SBjoern A. Zeeb if (!sta) {
518ebacd801SBjoern A. Zeeb idx = key->keyidx;
519ebacd801SBjoern A. Zeeb break;
520ebacd801SBjoern A. Zeeb }
521ebacd801SBjoern A. Zeeb memcpy(gmac, sta->addr, ETH_ALEN);
522ebacd801SBjoern A. Zeeb gmac[0] |= 0x01;
523ebacd801SBjoern A. Zeeb mac = gmac;
524ebacd801SBjoern A. Zeeb idx = ath_reserve_key_cache_slot(common, key->cipher);
525ebacd801SBjoern A. Zeeb break;
526ebacd801SBjoern A. Zeeb default:
527ebacd801SBjoern A. Zeeb idx = key->keyidx;
528ebacd801SBjoern A. Zeeb break;
529ebacd801SBjoern A. Zeeb }
530ebacd801SBjoern A. Zeeb } else if (key->keyidx) {
531ebacd801SBjoern A. Zeeb if (WARN_ON(!sta))
532ebacd801SBjoern A. Zeeb return -EOPNOTSUPP;
533ebacd801SBjoern A. Zeeb mac = sta->addr;
534ebacd801SBjoern A. Zeeb
535ebacd801SBjoern A. Zeeb if (vif->type != NL80211_IFTYPE_AP) {
536ebacd801SBjoern A. Zeeb /* Only keyidx 0 should be used with unicast key, but
537ebacd801SBjoern A. Zeeb * allow this for client mode for now. */
538ebacd801SBjoern A. Zeeb idx = key->keyidx;
539ebacd801SBjoern A. Zeeb } else
540ebacd801SBjoern A. Zeeb return -EIO;
541ebacd801SBjoern A. Zeeb } else {
542ebacd801SBjoern A. Zeeb if (WARN_ON(!sta))
543ebacd801SBjoern A. Zeeb return -EOPNOTSUPP;
544ebacd801SBjoern A. Zeeb mac = sta->addr;
545ebacd801SBjoern A. Zeeb
546ebacd801SBjoern A. Zeeb idx = ath_reserve_key_cache_slot(common, key->cipher);
547ebacd801SBjoern A. Zeeb }
548ebacd801SBjoern A. Zeeb
549ebacd801SBjoern A. Zeeb if (idx < 0)
550ebacd801SBjoern A. Zeeb return -ENOSPC; /* no free key cache entries */
551ebacd801SBjoern A. Zeeb
552ebacd801SBjoern A. Zeeb if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
553ebacd801SBjoern A. Zeeb ret = ath_setkey_tkip(common, idx, key->key, &hk, mac,
554ebacd801SBjoern A. Zeeb vif->type == NL80211_IFTYPE_AP);
555ebacd801SBjoern A. Zeeb else
556ebacd801SBjoern A. Zeeb ret = ath_hw_set_keycache_entry(common, idx, &hk, mac);
557ebacd801SBjoern A. Zeeb
558ebacd801SBjoern A. Zeeb if (!ret)
559ebacd801SBjoern A. Zeeb return -EIO;
560ebacd801SBjoern A. Zeeb
561ebacd801SBjoern A. Zeeb set_bit(idx, common->keymap);
562ebacd801SBjoern A. Zeeb if (key->cipher == WLAN_CIPHER_SUITE_CCMP)
563ebacd801SBjoern A. Zeeb set_bit(idx, common->ccmp_keymap);
564ebacd801SBjoern A. Zeeb
565ebacd801SBjoern A. Zeeb if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
566ebacd801SBjoern A. Zeeb set_bit(idx + 64, common->keymap);
567ebacd801SBjoern A. Zeeb set_bit(idx, common->tkip_keymap);
568ebacd801SBjoern A. Zeeb set_bit(idx + 64, common->tkip_keymap);
569ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
570ebacd801SBjoern A. Zeeb set_bit(idx + 32, common->keymap);
571ebacd801SBjoern A. Zeeb set_bit(idx + 64 + 32, common->keymap);
572ebacd801SBjoern A. Zeeb set_bit(idx + 32, common->tkip_keymap);
573ebacd801SBjoern A. Zeeb set_bit(idx + 64 + 32, common->tkip_keymap);
574ebacd801SBjoern A. Zeeb }
575ebacd801SBjoern A. Zeeb }
576ebacd801SBjoern A. Zeeb
577ebacd801SBjoern A. Zeeb return idx;
578ebacd801SBjoern A. Zeeb }
579ebacd801SBjoern A. Zeeb EXPORT_SYMBOL(ath_key_config);
580ebacd801SBjoern A. Zeeb
581ebacd801SBjoern A. Zeeb /*
582ebacd801SBjoern A. Zeeb * Delete Key.
583ebacd801SBjoern A. Zeeb */
ath_key_delete(struct ath_common * common,u8 hw_key_idx)584ebacd801SBjoern A. Zeeb void ath_key_delete(struct ath_common *common, u8 hw_key_idx)
585ebacd801SBjoern A. Zeeb {
586ebacd801SBjoern A. Zeeb /* Leave CCMP and TKIP (main key) configured to avoid disabling
587ebacd801SBjoern A. Zeeb * encryption for potentially pending frames already in a TXQ with the
588ebacd801SBjoern A. Zeeb * keyix pointing to this key entry. Instead, only clear the MAC address
589ebacd801SBjoern A. Zeeb * to prevent RX processing from using this key cache entry.
590ebacd801SBjoern A. Zeeb */
591ebacd801SBjoern A. Zeeb if (test_bit(hw_key_idx, common->ccmp_keymap) ||
592ebacd801SBjoern A. Zeeb test_bit(hw_key_idx, common->tkip_keymap))
593ebacd801SBjoern A. Zeeb ath_hw_keysetmac(common, hw_key_idx, NULL);
594ebacd801SBjoern A. Zeeb else
595ebacd801SBjoern A. Zeeb ath_hw_keyreset(common, hw_key_idx);
596ebacd801SBjoern A. Zeeb if (hw_key_idx < IEEE80211_WEP_NKID)
597ebacd801SBjoern A. Zeeb return;
598ebacd801SBjoern A. Zeeb
599ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx, common->keymap);
600ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx, common->ccmp_keymap);
601ebacd801SBjoern A. Zeeb if (!test_bit(hw_key_idx, common->tkip_keymap))
602ebacd801SBjoern A. Zeeb return;
603ebacd801SBjoern A. Zeeb
604ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 64, common->keymap);
605ebacd801SBjoern A. Zeeb
606ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx, common->tkip_keymap);
607ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 64, common->tkip_keymap);
608ebacd801SBjoern A. Zeeb
609ebacd801SBjoern A. Zeeb if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
610ebacd801SBjoern A. Zeeb ath_hw_keyreset(common, hw_key_idx + 32);
611ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 32, common->keymap);
612ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 64 + 32, common->keymap);
613ebacd801SBjoern A. Zeeb
614ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 32, common->tkip_keymap);
615ebacd801SBjoern A. Zeeb clear_bit(hw_key_idx + 64 + 32, common->tkip_keymap);
616ebacd801SBjoern A. Zeeb }
617ebacd801SBjoern A. Zeeb }
618ebacd801SBjoern A. Zeeb EXPORT_SYMBOL(ath_key_delete);
619