ar9170.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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/wireless.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. #define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
  50. enum ar9170_bw {
  51. AR9170_BW_20,
  52. AR9170_BW_40_BELOW,
  53. AR9170_BW_40_ABOVE,
  54. __AR9170_NUM_BW,
  55. };
  56. enum ar9170_rf_init_mode {
  57. AR9170_RFI_NONE,
  58. AR9170_RFI_WARM,
  59. AR9170_RFI_COLD,
  60. };
  61. #define AR9170_MAX_RX_BUFFER_SIZE 8192
  62. #ifdef CONFIG_AR9170_LEDS
  63. struct ar9170;
  64. struct ar9170_led {
  65. struct ar9170 *ar;
  66. struct led_classdev l;
  67. char name[32];
  68. unsigned int toggled;
  69. bool registered;
  70. };
  71. #endif /* CONFIG_AR9170_LEDS */
  72. enum ar9170_device_state {
  73. AR9170_UNKNOWN_STATE,
  74. AR9170_STOPPED,
  75. AR9170_IDLE,
  76. AR9170_STARTED,
  77. AR9170_ASSOCIATED,
  78. };
  79. struct ar9170 {
  80. struct ieee80211_hw *hw;
  81. struct mutex mutex;
  82. enum ar9170_device_state state;
  83. int (*open)(struct ar9170 *);
  84. void (*stop)(struct ar9170 *);
  85. int (*tx)(struct ar9170 *, struct sk_buff *, bool, unsigned int);
  86. int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
  87. void *, u32 , void *);
  88. void (*callback_cmd)(struct ar9170 *, u32 , void *);
  89. /* interface mode settings */
  90. struct ieee80211_vif *vif;
  91. u8 mac_addr[ETH_ALEN];
  92. u8 bssid[ETH_ALEN];
  93. /* beaconing */
  94. struct sk_buff *beacon;
  95. struct work_struct beacon_work;
  96. /* cryptographic engine */
  97. u64 usedkeys;
  98. bool rx_software_decryption;
  99. bool disable_offload;
  100. /* filter settings */
  101. struct work_struct filter_config_work;
  102. u64 cur_mc_hash, want_mc_hash;
  103. u32 cur_filter, want_filter;
  104. unsigned int filter_changed;
  105. bool sniffer_enabled;
  106. /* PHY */
  107. struct ieee80211_channel *channel;
  108. int noise[4];
  109. /* power calibration data */
  110. u8 power_5G_leg[4];
  111. u8 power_2G_cck[4];
  112. u8 power_2G_ofdm[4];
  113. u8 power_5G_ht20[8];
  114. u8 power_5G_ht40[8];
  115. u8 power_2G_ht20[8];
  116. u8 power_2G_ht40[8];
  117. #ifdef CONFIG_AR9170_LEDS
  118. struct delayed_work led_work;
  119. struct ar9170_led leds[AR9170_NUM_LEDS];
  120. #endif /* CONFIG_AR9170_LEDS */
  121. /* qos queue settings */
  122. spinlock_t tx_stats_lock;
  123. struct ieee80211_tx_queue_stats tx_stats[5];
  124. struct ieee80211_tx_queue_params edcf[5];
  125. spinlock_t cmdlock;
  126. __le32 cmdbuf[PAYLOAD_MAX + 1];
  127. /* MAC statistics */
  128. struct ieee80211_low_level_stats stats;
  129. /* EEPROM */
  130. struct ar9170_eeprom eeprom;
  131. /* global tx status for unregistered Stations. */
  132. struct sk_buff_head global_tx_status;
  133. struct sk_buff_head global_tx_status_waste;
  134. struct delayed_work tx_status_janitor;
  135. };
  136. struct ar9170_sta_info {
  137. struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
  138. };
  139. #define IS_STARTED(a) (a->state >= AR9170_STARTED)
  140. #define IS_ACCEPTING_CMD(a) (a->state >= AR9170_IDLE)
  141. #define AR9170_FILTER_CHANGED_PROMISC BIT(0)
  142. #define AR9170_FILTER_CHANGED_MULTICAST BIT(1)
  143. #define AR9170_FILTER_CHANGED_FRAMEFILTER BIT(2)
  144. /* exported interface */
  145. void *ar9170_alloc(size_t priv_size);
  146. int ar9170_register(struct ar9170 *ar, struct device *pdev);
  147. void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
  148. void ar9170_unregister(struct ar9170 *ar);
  149. void ar9170_handle_tx_status(struct ar9170 *ar, struct sk_buff *skb,
  150. bool update_statistics, u16 tx_status);
  151. /* MAC */
  152. int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
  153. int ar9170_init_mac(struct ar9170 *ar);
  154. int ar9170_set_qos(struct ar9170 *ar);
  155. int ar9170_update_multicast(struct ar9170 *ar);
  156. int ar9170_update_frame_filter(struct ar9170 *ar);
  157. int ar9170_set_operating_mode(struct ar9170 *ar);
  158. int ar9170_set_beacon_timers(struct ar9170 *ar);
  159. int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
  160. int ar9170_update_beacon(struct ar9170 *ar);
  161. void ar9170_new_beacon(struct work_struct *work);
  162. int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
  163. u8 keyidx, u8 *keydata, int keylen);
  164. int ar9170_disable_key(struct ar9170 *ar, u8 id);
  165. /* LEDs */
  166. #ifdef CONFIG_AR9170_LEDS
  167. int ar9170_register_leds(struct ar9170 *ar);
  168. void ar9170_unregister_leds(struct ar9170 *ar);
  169. #endif /* CONFIG_AR9170_LEDS */
  170. int ar9170_init_leds(struct ar9170 *ar);
  171. int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
  172. /* PHY / RF */
  173. int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
  174. int ar9170_init_rf(struct ar9170 *ar);
  175. int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
  176. enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
  177. #endif /* __AR9170_H */