iwl-4965.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called LICENSE.GPL.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *****************************************************************************/
  62. #ifndef __iwl_4965_h__
  63. #define __iwl_4965_h__
  64. #include "iwl-dev.h"
  65. /* configuration for the _4965 devices */
  66. extern struct iwl_cfg iwl4965_cfg;
  67. extern struct iwl_mod_params iwl4965_mod_params;
  68. extern struct ieee80211_ops iwl4965_hw_ops;
  69. /* tx queue */
  70. void iwl4965_free_tfds_in_queue(struct iwl_priv *priv,
  71. int sta_id, int tid, int freed);
  72. /* RXON */
  73. void iwl4965_set_rxon_chain(struct iwl_priv *priv,
  74. struct iwl_rxon_context *ctx);
  75. /* uCode */
  76. int iwl4965_verify_ucode(struct iwl_priv *priv);
  77. /* lib */
  78. void iwl4965_check_abort_status(struct iwl_priv *priv,
  79. u8 frame_count, u32 status);
  80. void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
  81. int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
  82. int iwl4965_hw_nic_init(struct iwl_priv *priv);
  83. int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display);
  84. /* rx */
  85. void iwl4965_rx_queue_restock(struct iwl_priv *priv);
  86. void iwl4965_rx_replenish(struct iwl_priv *priv);
  87. void iwl4965_rx_replenish_now(struct iwl_priv *priv);
  88. void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
  89. int iwl4965_rxq_stop(struct iwl_priv *priv);
  90. int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
  91. void iwl4965_rx_reply_rx(struct iwl_priv *priv,
  92. struct iwl_rx_mem_buffer *rxb);
  93. void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv,
  94. struct iwl_rx_mem_buffer *rxb);
  95. void iwl4965_rx_handle(struct iwl_priv *priv);
  96. /* tx */
  97. void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  98. int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
  99. struct iwl_tx_queue *txq,
  100. dma_addr_t addr, u16 len, u8 reset, u8 pad);
  101. int iwl4965_hw_tx_queue_init(struct iwl_priv *priv,
  102. struct iwl_tx_queue *txq);
  103. void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
  104. struct ieee80211_tx_info *info);
  105. int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb);
  106. int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
  107. struct ieee80211_sta *sta, u16 tid, u16 *ssn);
  108. int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
  109. struct ieee80211_sta *sta, u16 tid);
  110. int iwl4965_txq_check_empty(struct iwl_priv *priv,
  111. int sta_id, u8 tid, int txq_id);
  112. void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv,
  113. struct iwl_rx_mem_buffer *rxb);
  114. int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
  115. void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv);
  116. int iwl4965_txq_ctx_alloc(struct iwl_priv *priv);
  117. void iwl4965_txq_ctx_reset(struct iwl_priv *priv);
  118. void iwl4965_txq_ctx_stop(struct iwl_priv *priv);
  119. void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask);
  120. /*
  121. * Acquire priv->lock before calling this function !
  122. */
  123. void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index);
  124. /**
  125. * iwl4965_tx_queue_set_status - (optionally) start Tx/Cmd queue
  126. * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed
  127. * @scd_retry: (1) Indicates queue will be used in aggregation mode
  128. *
  129. * NOTE: Acquire priv->lock before calling this function !
  130. */
  131. void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
  132. struct iwl_tx_queue *txq,
  133. int tx_fifo_id, int scd_retry);
  134. static inline u32 iwl4965_tx_status_to_mac80211(u32 status)
  135. {
  136. status &= TX_STATUS_MSK;
  137. switch (status) {
  138. case TX_STATUS_SUCCESS:
  139. case TX_STATUS_DIRECT_DONE:
  140. return IEEE80211_TX_STAT_ACK;
  141. case TX_STATUS_FAIL_DEST_PS:
  142. return IEEE80211_TX_STAT_TX_FILTERED;
  143. default:
  144. return 0;
  145. }
  146. }
  147. static inline bool iwl4965_is_tx_success(u32 status)
  148. {
  149. status &= TX_STATUS_MSK;
  150. return (status == TX_STATUS_SUCCESS) ||
  151. (status == TX_STATUS_DIRECT_DONE);
  152. }
  153. u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid);
  154. /* rx */
  155. void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv,
  156. struct iwl_rx_mem_buffer *rxb);
  157. bool iwl4965_good_plcp_health(struct iwl_priv *priv,
  158. struct iwl_rx_packet *pkt);
  159. void iwl4965_rx_statistics(struct iwl_priv *priv,
  160. struct iwl_rx_mem_buffer *rxb);
  161. void iwl4965_reply_statistics(struct iwl_priv *priv,
  162. struct iwl_rx_mem_buffer *rxb);
  163. /* scan */
  164. int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
  165. /* station mgmt */
  166. int iwl4965_manage_ibss_station(struct iwl_priv *priv,
  167. struct ieee80211_vif *vif, bool add);
  168. /* hcmd */
  169. int iwl4965_send_beacon_cmd(struct iwl_priv *priv);
  170. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  171. const char *iwl4965_get_tx_fail_reason(u32 status);
  172. #else
  173. static inline const char *
  174. iwl4965_get_tx_fail_reason(u32 status) { return ""; }
  175. #endif
  176. /* station management */
  177. int iwl4965_alloc_bcast_station(struct iwl_priv *priv,
  178. struct iwl_rxon_context *ctx);
  179. int iwl4965_add_bssid_station(struct iwl_priv *priv,
  180. struct iwl_rxon_context *ctx,
  181. const u8 *addr, u8 *sta_id_r);
  182. int iwl4965_remove_default_wep_key(struct iwl_priv *priv,
  183. struct iwl_rxon_context *ctx,
  184. struct ieee80211_key_conf *key);
  185. int iwl4965_set_default_wep_key(struct iwl_priv *priv,
  186. struct iwl_rxon_context *ctx,
  187. struct ieee80211_key_conf *key);
  188. int iwl4965_restore_default_wep_keys(struct iwl_priv *priv,
  189. struct iwl_rxon_context *ctx);
  190. int iwl4965_set_dynamic_key(struct iwl_priv *priv,
  191. struct iwl_rxon_context *ctx,
  192. struct ieee80211_key_conf *key, u8 sta_id);
  193. int iwl4965_remove_dynamic_key(struct iwl_priv *priv,
  194. struct iwl_rxon_context *ctx,
  195. struct ieee80211_key_conf *key, u8 sta_id);
  196. void iwl4965_update_tkip_key(struct iwl_priv *priv,
  197. struct iwl_rxon_context *ctx,
  198. struct ieee80211_key_conf *keyconf,
  199. struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
  200. int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv,
  201. int sta_id, int tid);
  202. int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
  203. int tid, u16 ssn);
  204. int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
  205. int tid);
  206. void iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv,
  207. int sta_id, int cnt);
  208. int iwl4965_update_bcast_stations(struct iwl_priv *priv);
  209. /* rate */
  210. static inline u32 iwl4965_ant_idx_to_flags(u8 ant_idx)
  211. {
  212. return BIT(ant_idx) << RATE_MCS_ANT_POS;
  213. }
  214. static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
  215. {
  216. return le32_to_cpu(rate_n_flags) & 0xFF;
  217. }
  218. static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u32 flags)
  219. {
  220. return cpu_to_le32(flags|(u32)rate);
  221. }
  222. /* eeprom */
  223. void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac);
  224. int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv);
  225. void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv);
  226. int iwl4965_eeprom_check_version(struct iwl_priv *priv);
  227. /* mac80211 handlers (for 4965) */
  228. void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
  229. int iwl4965_mac_start(struct ieee80211_hw *hw);
  230. void iwl4965_mac_stop(struct ieee80211_hw *hw);
  231. void iwl4965_configure_filter(struct ieee80211_hw *hw,
  232. unsigned int changed_flags,
  233. unsigned int *total_flags,
  234. u64 multicast);
  235. int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  236. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  237. struct ieee80211_key_conf *key);
  238. void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw,
  239. struct ieee80211_vif *vif,
  240. struct ieee80211_key_conf *keyconf,
  241. struct ieee80211_sta *sta,
  242. u32 iv32, u16 *phase1key);
  243. int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
  244. struct ieee80211_vif *vif,
  245. enum ieee80211_ampdu_mlme_action action,
  246. struct ieee80211_sta *sta, u16 tid, u16 *ssn,
  247. u8 buf_size);
  248. int iwl4965_mac_sta_add(struct ieee80211_hw *hw,
  249. struct ieee80211_vif *vif,
  250. struct ieee80211_sta *sta);
  251. void iwl4965_mac_channel_switch(struct ieee80211_hw *hw,
  252. struct ieee80211_channel_switch *ch_switch);
  253. #endif /* __iwl_4965_h__ */