key.c 16 KB

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