key.c 16 KB

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