key.c 16 KB

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