Path: blob/main/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_keycache.c
48525 views
/*1* Copyright (c) 2013 Qualcomm Atheros, Inc.2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH8* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY9* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,10* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM11* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR12* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR13* PERFORMANCE OF THIS SOFTWARE.14*/1516#include "opt_ah.h"1718#include "ah.h"19#include "ah_internal.h"2021#include "ar9300/ar9300.h"22#include "ar9300/ar9300reg.h"2324/*25* Note: The key cache hardware requires that each double-word26* pair be written in even/odd order (since the destination is27* a 64-bit register). Don't reorder the writes in this code28* w/o considering this!29*/30#define KEY_XOR 0xaa3132#define IS_MIC_ENABLED(ah) \33(AH9300(ah)->ah_sta_id1_defaults & AR_STA_ID1_CRPT_MIC_ENABLE)3435/*36* This isn't the keytable type; this is actually something separate37* for the TX descriptor.38*/39static const int keyType[] = {401, /* HAL_CIPHER_WEP */410, /* HAL_CIPHER_AES_OCB */422, /* HAL_CIPHER_AES_CCM */430, /* HAL_CIPHER_CKIP */443, /* HAL_CIPHER_TKIP */450 /* HAL_CIPHER_CLR */46};4748/*49* Return the size of the hardware key cache.50*/51u_int32_t52ar9300_get_key_cache_size(struct ath_hal *ah)53{54return AH_PRIVATE(ah)->ah_caps.halKeyCacheSize;55}5657/*58* Return AH_TRUE if the specific key cache entry is valid.59*/60HAL_BOOL61ar9300_is_key_cache_entry_valid(struct ath_hal *ah, u_int16_t entry)62{63if (entry < AH_PRIVATE(ah)->ah_caps.halKeyCacheSize) {64u_int32_t val = OS_REG_READ(ah, AR_KEYTABLE_MAC1(entry));65if (val & AR_KEYTABLE_VALID) {66return AH_TRUE;67}68}69return AH_FALSE;70}7172/*73* Clear the specified key cache entry and any associated MIC entry.74*/75HAL_BOOL76ar9300_reset_key_cache_entry(struct ath_hal *ah, u_int16_t entry)77{78u_int32_t key_type;79struct ath_hal_9300 *ahp = AH9300(ah);8081if (entry >= AH_PRIVATE(ah)->ah_caps.halKeyCacheSize) {82HALDEBUG(ah, HAL_DEBUG_KEYCACHE,83"%s: entry %u out of range\n", __func__, entry);84return AH_FALSE;85}8687ahp->ah_keytype[entry] = keyType[HAL_CIPHER_CLR];8889key_type = OS_REG_READ(ah, AR_KEYTABLE_TYPE(entry));9091/* XXX why not clear key type/valid bit first? */92OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);93OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);94OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);95OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);96OS_REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);97OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);98OS_REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);99OS_REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);100if (key_type == AR_KEYTABLE_TYPE_TKIP && IS_MIC_ENABLED(ah)) {101u_int16_t micentry = entry + 64; /* MIC goes at slot+64 */102103HALASSERT(micentry < AH_PRIVATE(ah)->ah_caps.halKeyCacheSize);104OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);105OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);106OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);107OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);108/* NB: key type and MAC are known to be ok */109}110111if (AH_PRIVATE(ah)->ah_curchan == AH_NULL) {112return AH_TRUE;113}114115if (ar9300_get_capability(ah, HAL_CAP_BB_RIFS_HANG, 0, AH_NULL)116== HAL_OK) {117if (key_type == AR_KEYTABLE_TYPE_TKIP ||118key_type == AR_KEYTABLE_TYPE_40 ||119key_type == AR_KEYTABLE_TYPE_104 ||120key_type == AR_KEYTABLE_TYPE_128) {121/* SW WAR for Bug 31602 */122if (--ahp->ah_rifs_sec_cnt == 0) {123HALDEBUG(ah, HAL_DEBUG_KEYCACHE,124"%s: Count = %d, enabling RIFS\n",125__func__, ahp->ah_rifs_sec_cnt);126ar9300_set_rifs_delay(ah, AH_TRUE);127}128}129}130return AH_TRUE;131}132133/*134* Sets the mac part of the specified key cache entry (and any135* associated MIC entry) and mark them valid.136*/137HAL_BOOL138ar9300_set_key_cache_entry_mac(139struct ath_hal *ah,140u_int16_t entry,141const u_int8_t *mac)142{143u_int32_t mac_hi, mac_lo;144u_int32_t unicast_addr = AR_KEYTABLE_VALID;145146if (entry >= AH_PRIVATE(ah)->ah_caps.halKeyCacheSize) {147HALDEBUG(ah, HAL_DEBUG_KEYCACHE,148"%s: entry %u out of range\n", __func__, entry);149return AH_FALSE;150}151/*152* Set MAC address -- shifted right by 1. mac_lo is153* the 4 MSBs, and mac_hi is the 2 LSBs.154*/155if (mac != AH_NULL) {156/*157* If upper layers have requested mcast MACaddr lookup, then158* signify this to the hw by setting the (poorly named) valid_bit159* to 0. Yes, really 0. The hardware specs, pcu_registers.txt, is160* has incorrectly named valid_bit. It should be called "Unicast".161* When the Key Cache entry is to decrypt Unicast frames, this bit162* should be '1'; for multicast and broadcast frames, this bit is '0'.163*/164if (mac[0] & 0x01) {165unicast_addr = 0; /* Not an unicast address */166}167168mac_hi = (mac[5] << 8) | mac[4];169mac_lo = (mac[3] << 24) | (mac[2] << 16)170| (mac[1] << 8) | mac[0];171mac_lo >>= 1; /* Note that the bit 0 is shifted out. This bit is used to172* indicate that this is a multicast key cache. */173mac_lo |= (mac_hi & 1) << 31; /* carry */174mac_hi >>= 1;175} else {176mac_lo = mac_hi = 0;177}178OS_REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), mac_lo);179OS_REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), mac_hi | unicast_addr);180return AH_TRUE;181}182183/*184* Sets the contents of the specified key cache entry185* and any associated MIC entry.186*/187HAL_BOOL188ar9300_set_key_cache_entry(struct ath_hal *ah, u_int16_t entry,189const HAL_KEYVAL *k, const u_int8_t *mac,190int xor_key)191{192const HAL_CAPABILITIES *p_cap = &AH_PRIVATE(ah)->ah_caps;193u_int32_t key0, key1, key2, key3, key4;194u_int32_t key_type;195u_int32_t xor_mask = xor_key ?196(KEY_XOR << 24 | KEY_XOR << 16 | KEY_XOR << 8 | KEY_XOR) : 0;197struct ath_hal_9300 *ahp = AH9300(ah);198u_int32_t pwrmgt, pwrmgt_mic, uapsd_cfg, psta = 0;199int is_proxysta_key = k->kv_type & HAL_KEY_PROXY_STA_MASK;200201202if (entry >= p_cap->halKeyCacheSize) {203HALDEBUG(ah, HAL_DEBUG_KEYCACHE,204"%s: entry %u out of range\n", __func__, entry);205return AH_FALSE;206}207HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s[%d] mac %s proxy %d\n",208__func__, __LINE__, mac ? ath_hal_ether_sprintf(mac) : "null",209is_proxysta_key);210211switch (k->kv_type & AH_KEYTYPE_MASK) {212case HAL_CIPHER_AES_OCB:213key_type = AR_KEYTABLE_TYPE_AES;214break;215case HAL_CIPHER_AES_CCM:216if (!p_cap->halCipherAesCcmSupport) {217HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: AES-CCM not supported by "218"mac rev 0x%x\n",219__func__, AH_PRIVATE(ah)->ah_macRev);220return AH_FALSE;221}222key_type = AR_KEYTABLE_TYPE_CCM;223break;224case HAL_CIPHER_TKIP:225key_type = AR_KEYTABLE_TYPE_TKIP;226if (IS_MIC_ENABLED(ah) && entry + 64 >= p_cap->halKeyCacheSize) {227HALDEBUG(ah, HAL_DEBUG_KEYCACHE,228"%s: entry %u inappropriate for TKIP\n",229__func__, entry);230return AH_FALSE;231}232break;233case HAL_CIPHER_WEP:234if (k->kv_len < 40 / NBBY) {235HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: WEP key length %u too small\n",236__func__, k->kv_len);237return AH_FALSE;238}239if (k->kv_len <= 40 / NBBY) {240key_type = AR_KEYTABLE_TYPE_40;241} else if (k->kv_len <= 104 / NBBY) {242key_type = AR_KEYTABLE_TYPE_104;243} else {244key_type = AR_KEYTABLE_TYPE_128;245}246break;247case HAL_CIPHER_CLR:248key_type = AR_KEYTABLE_TYPE_CLR;249break;250default:251HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: cipher %u not supported\n",252__func__, k->kv_type);253return AH_FALSE;254}255256key0 = LE_READ_4(k->kv_val + 0) ^ xor_mask;257key1 = (LE_READ_2(k->kv_val + 4) ^ xor_mask) & 0xffff;258key2 = LE_READ_4(k->kv_val + 6) ^ xor_mask;259key3 = (LE_READ_2(k->kv_val + 10) ^ xor_mask) & 0xffff;260key4 = LE_READ_4(k->kv_val + 12) ^ xor_mask;261if (k->kv_len <= 104 / NBBY) {262key4 &= 0xff;263}264265/* Extract the UAPSD AC bits and shift it appropriately */266uapsd_cfg = k->kv_apsd;267uapsd_cfg = (u_int32_t) SM(uapsd_cfg, AR_KEYTABLE_UAPSD);268269/* Need to preserve the power management bit used by MAC */270pwrmgt = OS_REG_READ(ah, AR_KEYTABLE_TYPE(entry)) & AR_KEYTABLE_PWRMGT;271272if (is_proxysta_key) {273u_int8_t bcast_mac[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};274if (!mac || OS_MEMCMP(mac, bcast_mac, 6)) {275psta = AR_KEYTABLE_DIR_ACK_BIT;276}277}278/*279* Note: key cache hardware requires that each double-word280* pair be written in even/odd order (since the destination is281* a 64-bit register). Don't reorder these writes w/o282* considering this!283*/284if (key_type == AR_KEYTABLE_TYPE_TKIP && IS_MIC_ENABLED(ah)) {285u_int16_t micentry = entry + 64; /* MIC goes at slot+64 */286287/* Need to preserve the power management bit used by MAC */288pwrmgt_mic =289OS_REG_READ(ah, AR_KEYTABLE_TYPE(micentry)) & AR_KEYTABLE_PWRMGT;290291/*292* Invalidate the encrypt/decrypt key until the MIC293* key is installed so pending rx frames will fail294* with decrypt errors rather than a MIC error.295*/296OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0);297OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1);298OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);299OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);300OS_REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);301OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(entry),302key_type | pwrmgt | uapsd_cfg | psta);303ar9300_set_key_cache_entry_mac(ah, entry, mac);304305/*306* since the AR_MISC_MODE register was written with the contents of307* ah_misc_mode (if any) in ar9300_attach, just check ah_misc_mode and308* save a pci read per key set.309*/310if (ahp->ah_misc_mode & AR_PCU_MIC_NEW_LOC_ENA) {311u_int32_t mic0, mic1, mic2, mic3, mic4;312/*313* both RX and TX mic values can be combined into314* one cache slot entry.315* 8*N + 800 31:0 RX Michael key 0316* 8*N + 804 15:0 TX Michael key 0 [31:16]317* 8*N + 808 31:0 RX Michael key 1318* 8*N + 80C 15:0 TX Michael key 0 [15:0]319* 8*N + 810 31:0 TX Michael key 1320* 8*N + 814 15:0 reserved321* 8*N + 818 31:0 reserved322* 8*N + 81C 14:0 reserved323* 15 key valid == 0324*/325/* RX mic */326mic0 = LE_READ_4(k->kv_mic + 0);327mic2 = LE_READ_4(k->kv_mic + 4);328/* TX mic */329mic1 = LE_READ_2(k->kv_txmic + 2) & 0xffff;330mic3 = LE_READ_2(k->kv_txmic + 0) & 0xffff;331mic4 = LE_READ_4(k->kv_txmic + 4);332OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);333OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1);334OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);335OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3);336OS_REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4);337OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),338AR_KEYTABLE_TYPE_CLR | pwrmgt_mic | uapsd_cfg);339340} else {341u_int32_t mic0, mic2;342343mic0 = LE_READ_4(k->kv_mic + 0);344mic2 = LE_READ_4(k->kv_mic + 4);345OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);346OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);347OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);348OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);349OS_REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);350OS_REG_WRITE(ah,351AR_KEYTABLE_TYPE(micentry | pwrmgt_mic | uapsd_cfg),352AR_KEYTABLE_TYPE_CLR);353}354/* NB: MIC key is not marked valid and has no MAC address */355OS_REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0);356OS_REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0);357358/* correct intentionally corrupted key */359OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);360OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);361} else {362OS_REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);363OS_REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);364OS_REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);365OS_REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);366OS_REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);367OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(entry),368key_type | pwrmgt | uapsd_cfg | psta);369370/*371ath_hal_printf(ah, "%s[%d] mac %s proxy %d\n",372__func__, __LINE__, mac ? ath_hal_ether_sprintf(mac) : "null",373is_proxysta_key);374*/375376ar9300_set_key_cache_entry_mac(ah, entry, mac);377}378379ahp->ah_keytype[entry] = keyType[k->kv_type];380HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: entry=%d, k->kv_type=%d,"381"keyType=%d\n", __func__, entry, k->kv_type, keyType[k->kv_type]);382383384if (AH_PRIVATE(ah)->ah_curchan == AH_NULL) {385return AH_TRUE;386}387388if (ar9300_get_capability(ah, HAL_CAP_BB_RIFS_HANG, 0, AH_NULL)389== HAL_OK) {390if (key_type == AR_KEYTABLE_TYPE_TKIP ||391key_type == AR_KEYTABLE_TYPE_40 ||392key_type == AR_KEYTABLE_TYPE_104 ||393key_type == AR_KEYTABLE_TYPE_128) {394/* SW WAR for Bug 31602 */395ahp->ah_rifs_sec_cnt++;396HALDEBUG(ah, HAL_DEBUG_KEYCACHE,397"%s: Count = %d, disabling RIFS\n",398__func__, ahp->ah_rifs_sec_cnt);399ar9300_set_rifs_delay(ah, AH_FALSE);400}401}402HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s[%d] mac %s proxy %d\n",403__func__, __LINE__, mac ? ath_hal_ether_sprintf(mac) : "null",404is_proxysta_key);405406return AH_TRUE;407}408409/*410* Enable the Keysearch for every subframe of an aggregate411*/412void413ar9300_enable_keysearch_always(struct ath_hal *ah, int enable)414{415u_int32_t val;416417if (!ah) {418return;419}420val = OS_REG_READ(ah, AR_PCU_MISC);421if (enable) {422val |= AR_PCU_ALWAYS_PERFORM_KEYSEARCH;423} else {424val &= ~AR_PCU_ALWAYS_PERFORM_KEYSEARCH;425}426OS_REG_WRITE(ah, AR_PCU_MISC, val);427}428void ar9300_dump_keycache(struct ath_hal *ah, int n, u_int32_t *entry)429{430#define AH_KEY_REG_SIZE 8431int i;432433for (i = 0; i < AH_KEY_REG_SIZE; i++) {434entry[i] = OS_REG_READ(ah, AR_KEYTABLE_KEY0(n) + i * 4);435}436#undef AH_KEY_REG_SIZE437}438439#if ATH_SUPPORT_KEYPLUMB_WAR440/*441* Check the contents of the specified key cache entry442* and any associated MIC entry.443*/444HAL_BOOL445ar9300_check_key_cache_entry(struct ath_hal *ah, u_int16_t entry,446const HAL_KEYVAL *k, int xorKey)447{448const HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps;449u_int32_t key0, key1, key2, key3, key4;450u_int32_t keyType;451u_int32_t xorMask = xorKey ?452(KEY_XOR << 24 | KEY_XOR << 16 | KEY_XOR << 8 | KEY_XOR) : 0;453struct ath_hal_9300 *ahp = AH9300(ah);454455456if (entry >= pCap->hal_key_cache_size) {457HALDEBUG(ah, HAL_DEBUG_KEYCACHE,458"%s: entry %u out of range\n", __func__, entry);459return AH_FALSE;460}461switch (k->kv_type) {462case HAL_CIPHER_AES_OCB:463keyType = AR_KEYTABLE_TYPE_AES;464break;465case HAL_CIPHER_AES_CCM:466if (!pCap->hal_cipher_aes_ccm_support) {467HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: AES-CCM not supported by "468"mac rev 0x%x\n",469__func__, AH_PRIVATE(ah)->ah_macRev);470return AH_FALSE;471}472keyType = AR_KEYTABLE_TYPE_CCM;473break;474case HAL_CIPHER_TKIP:475keyType = AR_KEYTABLE_TYPE_TKIP;476if (IS_MIC_ENABLED(ah) && entry + 64 >= pCap->hal_key_cache_size) {477HALDEBUG(ah, HAL_DEBUG_KEYCACHE,478"%s: entry %u inappropriate for TKIP\n",479__func__, entry);480return AH_FALSE;481}482break;483case HAL_CIPHER_WEP:484if (k->kv_len < 40 / NBBY) {485HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: WEP key length %u too small\n",486__func__, k->kv_len);487return AH_FALSE;488}489if (k->kv_len <= 40 / NBBY) {490keyType = AR_KEYTABLE_TYPE_40;491} else if (k->kv_len <= 104 / NBBY) {492keyType = AR_KEYTABLE_TYPE_104;493} else {494keyType = AR_KEYTABLE_TYPE_128;495}496break;497case HAL_CIPHER_CLR:498keyType = AR_KEYTABLE_TYPE_CLR;499return AH_TRUE;500default:501HALDEBUG(ah, HAL_DEBUG_KEYCACHE, "%s: cipher %u not supported\n",502__func__, k->kv_type);503return AH_TRUE;504}505506key0 = LE_READ_4(k->kv_val + 0) ^ xorMask;507key1 = (LE_READ_2(k->kv_val + 4) ^ xorMask) & 0xffff;508key2 = LE_READ_4(k->kv_val + 6) ^ xorMask;509key3 = (LE_READ_2(k->kv_val + 10) ^ xorMask) & 0xffff;510key4 = LE_READ_4(k->kv_val + 12) ^ xorMask;511if (k->kv_len <= 104 / NBBY) {512key4 &= 0xff;513}514515/*516* Note: key cache hardware requires that each double-word517* pair be written in even/odd order (since the destination is518* a 64-bit register). Don't reorder these writes w/o519* considering this!520*/521if (keyType == AR_KEYTABLE_TYPE_TKIP && IS_MIC_ENABLED(ah)) {522u_int16_t micentry = entry + 64; /* MIC goes at slot+64 */523524525/*526* Invalidate the encrypt/decrypt key until the MIC527* key is installed so pending rx frames will fail528* with decrypt errors rather than a MIC error.529*/530if ((OS_REG_READ(ah, AR_KEYTABLE_KEY0(entry)) == key0) &&531(OS_REG_READ(ah, AR_KEYTABLE_KEY1(entry)) == key1) &&532(OS_REG_READ(ah, AR_KEYTABLE_KEY2(entry)) == key2) &&533(OS_REG_READ(ah, AR_KEYTABLE_KEY3(entry)) == key3) &&534(OS_REG_READ(ah, AR_KEYTABLE_KEY4(entry)) == key4) &&535((OS_REG_READ(ah, AR_KEYTABLE_TYPE(entry)) & AR_KEY_TYPE) == (keyType & AR_KEY_TYPE)))536{537538/*539* since the AR_MISC_MODE register was written with the contents of540* ah_miscMode (if any) in ar9300Attach, just check ah_miscMode and541* save a pci read per key set.542*/543if (ahp->ah_misc_mode & AR_PCU_MIC_NEW_LOC_ENA) {544u_int32_t mic0,mic1,mic2,mic3,mic4;545/*546* both RX and TX mic values can be combined into547* one cache slot entry.548* 8*N + 800 31:0 RX Michael key 0549* 8*N + 804 15:0 TX Michael key 0 [31:16]550* 8*N + 808 31:0 RX Michael key 1551* 8*N + 80C 15:0 TX Michael key 0 [15:0]552* 8*N + 810 31:0 TX Michael key 1553* 8*N + 814 15:0 reserved554* 8*N + 818 31:0 reserved555* 8*N + 81C 14:0 reserved556* 15 key valid == 0557*/558/* RX mic */559mic0 = LE_READ_4(k->kv_mic + 0);560mic2 = LE_READ_4(k->kv_mic + 4);561/* TX mic */562mic1 = LE_READ_2(k->kv_txmic + 2) & 0xffff;563mic3 = LE_READ_2(k->kv_txmic + 0) & 0xffff;564mic4 = LE_READ_4(k->kv_txmic + 4);565if ((OS_REG_READ(ah, AR_KEYTABLE_KEY0(micentry)) == mic0) &&566(OS_REG_READ(ah, AR_KEYTABLE_KEY1(micentry)) == mic1) &&567(OS_REG_READ(ah, AR_KEYTABLE_KEY2(micentry)) == mic2) &&568(OS_REG_READ(ah, AR_KEYTABLE_KEY3(micentry)) == mic3) &&569(OS_REG_READ(ah, AR_KEYTABLE_KEY4(micentry)) == mic4) &&570((OS_REG_READ(ah, AR_KEYTABLE_TYPE(micentry)) & AR_KEY_TYPE) == (AR_KEYTABLE_TYPE_CLR & AR_KEY_TYPE))) {571return AH_TRUE;572}573574} else {575return AH_TRUE;576}577}578} else {579if ((OS_REG_READ(ah, AR_KEYTABLE_KEY0(entry)) == key0) &&580(OS_REG_READ(ah, AR_KEYTABLE_KEY1(entry)) == key1) &&581(OS_REG_READ(ah, AR_KEYTABLE_KEY2(entry)) == key2) &&582(OS_REG_READ(ah, AR_KEYTABLE_KEY3(entry)) == key3) &&583(OS_REG_READ(ah, AR_KEYTABLE_KEY4(entry)) == key4) &&584((OS_REG_READ(ah, AR_KEYTABLE_TYPE(entry)) & AR_KEY_TYPE) == (keyType & AR_KEY_TYPE))) {585return AH_TRUE;586}587}588return AH_FALSE;589}590#endif591592593