ath.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef ATH_H
  17. #define ATH_H
  18. #include <linux/skbuff.h>
  19. #include <linux/if_ether.h>
  20. #include <net/mac80211.h>
  21. /*
  22. * The key cache is used for h/w cipher state and also for
  23. * tracking station state such as the current tx antenna.
  24. * We also setup a mapping table between key cache slot indices
  25. * and station state to short-circuit node lookups on rx.
  26. * Different parts have different size key caches. We handle
  27. * up to ATH_KEYMAX entries (could dynamically allocate state).
  28. */
  29. #define ATH_KEYMAX 128 /* max key cache size we handle */
  30. static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  31. struct ath_ani {
  32. bool caldone;
  33. int16_t noise_floor;
  34. unsigned int longcal_timer;
  35. unsigned int shortcal_timer;
  36. unsigned int resetcal_timer;
  37. unsigned int checkani_timer;
  38. struct timer_list timer;
  39. };
  40. enum ath_device_state {
  41. ATH_HW_UNAVAILABLE,
  42. ATH_HW_INITIALIZED,
  43. };
  44. enum ath_bus_type {
  45. ATH_PCI,
  46. ATH_AHB,
  47. ATH_USB,
  48. };
  49. struct reg_dmn_pair_mapping {
  50. u16 regDmnEnum;
  51. u16 reg_5ghz_ctl;
  52. u16 reg_2ghz_ctl;
  53. };
  54. struct ath_regulatory {
  55. char alpha2[2];
  56. u16 country_code;
  57. u16 max_power_level;
  58. u32 tp_scale;
  59. u16 current_rd;
  60. u16 current_rd_ext;
  61. int16_t power_limit;
  62. struct reg_dmn_pair_mapping *regpair;
  63. };
  64. /**
  65. * struct ath_ops - Register read/write operations
  66. *
  67. * @read: Register read
  68. * @write: Register write
  69. * @enable_write_buffer: Enable multiple register writes
  70. * @disable_write_buffer: Disable multiple register writes
  71. * @write_flush: Flush buffered register writes
  72. */
  73. struct ath_ops {
  74. unsigned int (*read)(void *, u32 reg_offset);
  75. void (*write)(void *, u32 val, u32 reg_offset);
  76. void (*enable_write_buffer)(void *);
  77. void (*disable_write_buffer)(void *);
  78. void (*write_flush) (void *);
  79. };
  80. struct ath_common;
  81. struct ath_bus_ops {
  82. enum ath_bus_type ath_bus_type;
  83. void (*read_cachesize)(struct ath_common *common, int *csz);
  84. bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
  85. void (*bt_coex_prep)(struct ath_common *common);
  86. };
  87. struct ath_common {
  88. void *ah;
  89. void *priv;
  90. struct ieee80211_hw *hw;
  91. int debug_mask;
  92. enum ath_device_state state;
  93. struct ath_ani ani;
  94. u16 cachelsz;
  95. u16 curaid;
  96. u8 macaddr[ETH_ALEN];
  97. u8 curbssid[ETH_ALEN];
  98. u8 bssidmask[ETH_ALEN];
  99. u8 tx_chainmask;
  100. u8 rx_chainmask;
  101. u32 rx_bufsize;
  102. u32 keymax;
  103. DECLARE_BITMAP(keymap, ATH_KEYMAX);
  104. u8 splitmic;
  105. struct ath_regulatory regulatory;
  106. const struct ath_ops *ops;
  107. const struct ath_bus_ops *bus_ops;
  108. };
  109. struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
  110. u32 len,
  111. gfp_t gfp_mask);
  112. void ath_hw_setbssidmask(struct ath_common *common);
  113. #endif /* ATH_H */