key.c 16 KB

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