You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ath_key.c 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2009 Atheros Communications Inc.
  3. * Copyright (c) 2010 Bruno Randolf <br1@einfach.org>
  4. *
  5. * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
  6. * Original from Linux kernel 3.0.1
  7. *
  8. * Permission to use, copy, modify, and/or distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. */
  20. #include "ath.h"
  21. #include "reg.h"
  22. #define REG_READ (common->ops->read)
  23. #define REG_WRITE(_ah, _reg, _val) (common->ops->write)(_ah, _val, _reg)
  24. #define ENABLE_REGWRITE_BUFFER(_ah) \
  25. if (common->ops->enable_write_buffer) \
  26. common->ops->enable_write_buffer((_ah));
  27. #define REGWRITE_BUFFER_FLUSH(_ah) \
  28. if (common->ops->write_flush) \
  29. common->ops->write_flush((_ah));
  30. #define IEEE80211_WEP_NKID 4 /* number of key ids */
  31. /************************/
  32. /* Key Cache Management */
  33. /************************/
  34. int ath_hw_keyreset(struct ath_common *common, u16 entry)
  35. {
  36. u32 keyType;
  37. void *ah = common->ah;
  38. if (entry >= common->keymax) {
  39. DBG("ath: keycache entry %d out of range\n", entry);
  40. return 0;
  41. }
  42. keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry));
  43. ENABLE_REGWRITE_BUFFER(ah);
  44. REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);
  45. REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);
  46. REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);
  47. REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);
  48. REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);
  49. REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);
  50. REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);
  51. REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);
  52. if (keyType == AR_KEYTABLE_TYPE_TKIP) {
  53. u16 micentry = entry + 64;
  54. REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);
  55. REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
  56. REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);
  57. REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
  58. if (common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) {
  59. REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
  60. REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
  61. AR_KEYTABLE_TYPE_CLR);
  62. }
  63. }
  64. REGWRITE_BUFFER_FLUSH(ah);
  65. return 1;
  66. }