ar9170.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * Atheros AR9170 driver
  3. *
  4. * Driver specific definitions
  5. *
  6. * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; see the file COPYING. If not, see
  20. * http://www.gnu.org/licenses/.
  21. *
  22. * This file incorporates work covered by the following copyright and
  23. * permission notice:
  24. * Copyright (c) 2007-2008 Atheros Communications, Inc.
  25. *
  26. * Permission to use, copy, modify, and/or distribute this software for any
  27. * purpose with or without fee is hereby granted, provided that the above
  28. * copyright notice and this permission notice appear in all copies.
  29. *
  30. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  31. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  32. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  33. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  34. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  35. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  36. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  37. */
  38. #ifndef __AR9170_H
  39. #define __AR9170_H
  40. #include <linux/completion.h>
  41. #include <linux/spinlock.h>
  42. #include <net/cfg80211.h>
  43. #include <net/mac80211.h>
  44. #ifdef CONFIG_AR9170_LEDS
  45. #include <linux/leds.h>
  46. #endif /* CONFIG_AR9170_LEDS */
  47. #include "eeprom.h"
  48. #include "hw.h"
  49. #include "../regd.h"
  50. #define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
  51. enum ar9170_bw {
  52. AR9170_BW_20,
  53. AR9170_BW_40_BELOW,
  54. AR9170_BW_40_ABOVE,
  55. __AR9170_NUM_BW,
  56. };
  57. static inline enum ar9170_bw nl80211_to_ar9170(enum nl80211_channel_type type)
  58. {
  59. switch (type) {
  60. case NL80211_CHAN_NO_HT:
  61. case NL80211_CHAN_HT20:
  62. return AR9170_BW_20;
  63. case NL80211_CHAN_HT40MINUS:
  64. return AR9170_BW_40_BELOW;
  65. case NL80211_CHAN_HT40PLUS:
  66. return AR9170_BW_40_ABOVE;
  67. default:
  68. BUG();
  69. }
  70. }
  71. enum ar9170_rf_init_mode {
  72. AR9170_RFI_NONE,
  73. AR9170_RFI_WARM,
  74. AR9170_RFI_COLD,
  75. };
  76. #define AR9170_MAX_RX_BUFFER_SIZE 8192
  77. #ifdef CONFIG_AR9170_LEDS
  78. struct ar9170;
  79. struct ar9170_led {
  80. struct ar9170 *ar;
  81. struct led_classdev l;
  82. char name[32];
  83. unsigned int toggled;
  84. bool registered;
  85. };
  86. #endif /* CONFIG_AR9170_LEDS */
  87. enum ar9170_device_state {
  88. AR9170_UNKNOWN_STATE,
  89. AR9170_STOPPED,
  90. AR9170_IDLE,
  91. AR9170_STARTED,
  92. AR9170_ASSOCIATED,
  93. };
  94. struct ar9170_rxstream_mpdu_merge {
  95. struct ar9170_rx_head plcp;
  96. bool has_plcp;
  97. };
  98. struct ar9170 {
  99. struct ieee80211_hw *hw;
  100. struct mutex mutex;
  101. enum ar9170_device_state state;
  102. unsigned long bad_hw_nagger;
  103. int (*open)(struct ar9170 *);
  104. void (*stop)(struct ar9170 *);
  105. int (*tx)(struct ar9170 *, struct sk_buff *, bool, unsigned int);
  106. int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
  107. void *, u32 , void *);
  108. void (*callback_cmd)(struct ar9170 *, u32 , void *);
  109. /* interface mode settings */
  110. struct ieee80211_vif *vif;
  111. u8 mac_addr[ETH_ALEN];
  112. u8 bssid[ETH_ALEN];
  113. /* beaconing */
  114. struct sk_buff *beacon;
  115. struct work_struct beacon_work;
  116. /* cryptographic engine */
  117. u64 usedkeys;
  118. bool rx_software_decryption;
  119. bool disable_offload;
  120. /* filter settings */
  121. struct work_struct filter_config_work;
  122. u64 cur_mc_hash, want_mc_hash;
  123. u32 cur_filter, want_filter;
  124. unsigned int filter_changed;
  125. unsigned int filter_state;
  126. bool sniffer_enabled;
  127. /* PHY */
  128. struct ieee80211_channel *channel;
  129. int noise[4];
  130. /* power calibration data */
  131. u8 power_5G_leg[4];
  132. u8 power_2G_cck[4];
  133. u8 power_2G_ofdm[4];
  134. u8 power_5G_ht20[8];
  135. u8 power_5G_ht40[8];
  136. u8 power_2G_ht20[8];
  137. u8 power_2G_ht40[8];
  138. #ifdef CONFIG_AR9170_LEDS
  139. struct delayed_work led_work;
  140. struct ar9170_led leds[AR9170_NUM_LEDS];
  141. #endif /* CONFIG_AR9170_LEDS */
  142. /* qos queue settings */
  143. spinlock_t tx_stats_lock;
  144. struct ieee80211_tx_queue_stats tx_stats[5];
  145. struct ieee80211_tx_queue_params edcf[5];
  146. spinlock_t cmdlock;
  147. __le32 cmdbuf[PAYLOAD_MAX + 1];
  148. /* MAC statistics */
  149. struct ieee80211_low_level_stats stats;
  150. /* EEPROM */
  151. struct ar9170_eeprom eeprom;
  152. struct ath_regulatory regulatory;
  153. /* global tx status for unregistered Stations. */
  154. struct sk_buff_head global_tx_status;
  155. struct sk_buff_head global_tx_status_waste;
  156. struct delayed_work tx_status_janitor;
  157. /* rxstream mpdu merge */
  158. struct ar9170_rxstream_mpdu_merge rx_mpdu;
  159. struct sk_buff *rx_failover;
  160. int rx_failover_missing;
  161. };
  162. struct ar9170_sta_info {
  163. struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
  164. };
  165. #define IS_STARTED(a) (a->state >= AR9170_STARTED)
  166. #define IS_ACCEPTING_CMD(a) (a->state >= AR9170_IDLE)
  167. #define AR9170_FILTER_CHANGED_PROMISC BIT(0)
  168. #define AR9170_FILTER_CHANGED_MULTICAST BIT(1)
  169. #define AR9170_FILTER_CHANGED_FRAMEFILTER BIT(2)
  170. /* exported interface */
  171. void *ar9170_alloc(size_t priv_size);
  172. int ar9170_register(struct ar9170 *ar, struct device *pdev);
  173. void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
  174. void ar9170_unregister(struct ar9170 *ar);
  175. void ar9170_handle_tx_status(struct ar9170 *ar, struct sk_buff *skb,
  176. bool update_statistics, u16 tx_status);
  177. /* MAC */
  178. int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
  179. int ar9170_init_mac(struct ar9170 *ar);
  180. int ar9170_set_qos(struct ar9170 *ar);
  181. int ar9170_update_multicast(struct ar9170 *ar);
  182. int ar9170_update_frame_filter(struct ar9170 *ar);
  183. int ar9170_set_operating_mode(struct ar9170 *ar);
  184. int ar9170_set_beacon_timers(struct ar9170 *ar);
  185. int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
  186. int ar9170_update_beacon(struct ar9170 *ar);
  187. void ar9170_new_beacon(struct work_struct *work);
  188. int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
  189. u8 keyidx, u8 *keydata, int keylen);
  190. int ar9170_disable_key(struct ar9170 *ar, u8 id);
  191. /* LEDs */
  192. #ifdef CONFIG_AR9170_LEDS
  193. int ar9170_register_leds(struct ar9170 *ar);
  194. void ar9170_unregister_leds(struct ar9170 *ar);
  195. #endif /* CONFIG_AR9170_LEDS */
  196. int ar9170_init_leds(struct ar9170 *ar);
  197. int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
  198. /* PHY / RF */
  199. int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
  200. int ar9170_init_rf(struct ar9170 *ar);
  201. int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
  202. enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
  203. #endif /* __AR9170_H */