18 #include <linux/export.h>
19 #include <asm/unaligned.h>
25 #define REG_READ (common->ops->read)
26 #define REG_WRITE(_ah, _reg, _val) (common->ops->write)(_ah, _val, _reg)
27 #define ENABLE_REGWRITE_BUFFER(_ah) \
28 if (common->ops->enable_write_buffer) \
29 common->ops->enable_write_buffer((_ah));
31 #define REGWRITE_BUFFER_FLUSH(_ah) \
32 if (common->ops->write_flush) \
33 common->ops->write_flush((_ah));
36 #define IEEE80211_WEP_NKID 4
45 void *
ah = common->
ah;
47 if (entry >= common->
keymax) {
48 ath_err(common,
"keycache entry %u out of range\n", entry);
66 u16 micentry = entry + 64;
91 void *
ah = common->
ah;
93 if (entry >= common->
keymax) {
94 ath_err(common,
"keycache entry %u out of range\n", entry);
110 macHi = get_unaligned_le16(mac + 4);
112 macLo |= (macHi & 1) << 31;
127 static bool ath_hw_set_keycache_entry(
struct ath_common *common,
u16 entry,
131 void *ah = common->
ah;
132 u32 key0, key1, key2, key3, key4;
135 if (entry >= common->
keymax) {
136 ath_err(common,
"keycache entry %u out of range\n", entry);
147 "AES-CCM not supported by this mac rev\n");
154 if (entry + 64 >= common->
keymax) {
156 "entry %u inappropriate for TKIP\n", entry);
162 ath_dbg(common,
ANY,
"WEP key length %u too small\n",
182 key1 = get_unaligned_le16(k->
kv_val + 4);
184 key3 = get_unaligned_le16(k->
kv_val + 10);
197 u16 micentry = entry + 64;
217 (
void) ath_hw_keysetmac(common, entry, mac);
232 u32 mic0, mic1, mic2, mic3, mic4;
236 mic1 = get_unaligned_le16(k->
kv_txmic + 2) & 0xffff;
237 mic3 = get_unaligned_le16(k->
kv_txmic + 0) & 0xffff;
330 (
void) ath_hw_keysetmac(common, entry, mac);
359 return ath_hw_set_keycache_entry(common, keyix, hk, addr);
365 return ath_hw_set_keycache_entry(common, keyix, hk, addr);
372 if (!ath_hw_set_keycache_entry(common, keyix, hk,
NULL)) {
374 ath_err(common,
"Setting TX MIC Key Failed\n");
380 return ath_hw_set_keycache_entry(common, keyix + 32, hk, addr);
383 static int ath_reserve_key_cache_slot_tkip(
struct ath_common *common)
392 (
test_bit(i + 32, common->keymap) ||
393 test_bit(i + 64 + 32, common->keymap)))
402 static int ath_reserve_key_cache_slot(
struct ath_common *common,
408 return ath_reserve_key_cache_slot_tkip(common);
414 (
test_bit(i + 32, common->keymap) ||
416 test_bit(i + 64 + 32, common->keymap)))
418 if (!
test_bit(i + 32, common->keymap) &&
421 test_bit(i + 64 + 32, common->keymap)))
423 if (!
test_bit(i + 64, common->keymap) &&
426 test_bit(i + 64 + 32, common->keymap)))
428 if (!
test_bit(i + 64 + 32, common->keymap) &&
481 memset(&hk, 0,
sizeof(hk));
511 idx = ath_reserve_key_cache_slot(common, key->
cipher);
521 idx = ath_reserve_key_cache_slot(common, key->
cipher);
543 idx = ath_reserve_key_cache_slot(common, key->
cipher);
550 ret = ath_setkey_tkip(common, idx, key->
key, &hk, mac,
553 ret = ath_hw_set_keycache_entry(common, idx, &hk, mac);
560 set_bit(idx, common->ccmp_keymap);
563 set_bit(idx + 64, common->keymap);
564 set_bit(idx, common->tkip_keymap);
565 set_bit(idx + 64, common->tkip_keymap);
567 set_bit(idx + 32, common->keymap);
568 set_bit(idx + 64 + 32, common->keymap);
569 set_bit(idx + 32, common->tkip_keymap);
570 set_bit(idx + 64 + 32, common->tkip_keymap);