iwl-4965.h 10 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 __il_4965_h__
  63. #define __il_4965_h__
  64. #include "iwl-dev.h"
  65. /* configuration for the _4965 devices */
  66. extern struct il_cfg il4965_cfg;
  67. extern struct il_mod_params il4965_mod_params;
  68. extern struct ieee80211_ops il4965_hw_ops;
  69. /* tx queue */
  70. void il4965_free_tfds_in_queue(struct il_priv *il,
  71. int sta_id, int tid, int freed);
  72. /* RXON */
  73. void il4965_set_rxon_chain(struct il_priv *il,
  74. struct il_rxon_context *ctx);
  75. /* uCode */
  76. int il4965_verify_ucode(struct il_priv *il);
  77. /* lib */
  78. void il4965_check_abort_status(struct il_priv *il,
  79. u8 frame_count, u32 status);
  80. void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
  81. int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq);
  82. int il4965_hw_nic_init(struct il_priv *il);
  83. int il4965_dump_fh(struct il_priv *il, char **buf, bool display);
  84. /* rx */
  85. void il4965_rx_queue_restock(struct il_priv *il);
  86. void il4965_rx_replenish(struct il_priv *il);
  87. void il4965_rx_replenish_now(struct il_priv *il);
  88. void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq);
  89. int il4965_rxq_stop(struct il_priv *il);
  90. int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
  91. void il4965_rx_reply_rx(struct il_priv *il,
  92. struct il_rx_buf *rxb);
  93. void il4965_rx_reply_rx_phy(struct il_priv *il,
  94. struct il_rx_buf *rxb);
  95. void il4965_rx_handle(struct il_priv *il);
  96. /* tx */
  97. void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
  98. int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il,
  99. struct il_tx_queue *txq,
  100. dma_addr_t addr, u16 len, u8 reset, u8 pad);
  101. int il4965_hw_tx_queue_init(struct il_priv *il,
  102. struct il_tx_queue *txq);
  103. void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
  104. struct ieee80211_tx_info *info);
  105. int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb);
  106. int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
  107. struct ieee80211_sta *sta, u16 tid, u16 *ssn);
  108. int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
  109. struct ieee80211_sta *sta, u16 tid);
  110. int il4965_txq_check_empty(struct il_priv *il,
  111. int sta_id, u8 tid, int txq_id);
  112. void il4965_rx_reply_compressed_ba(struct il_priv *il,
  113. struct il_rx_buf *rxb);
  114. int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index);
  115. void il4965_hw_txq_ctx_free(struct il_priv *il);
  116. int il4965_txq_ctx_alloc(struct il_priv *il);
  117. void il4965_txq_ctx_reset(struct il_priv *il);
  118. void il4965_txq_ctx_stop(struct il_priv *il);
  119. void il4965_txq_set_sched(struct il_priv *il, u32 mask);
  120. /*
  121. * Acquire il->lock before calling this function !
  122. */
  123. void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index);
  124. /**
  125. * il4965_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 il->lock before calling this function !
  130. */
  131. void il4965_tx_queue_set_status(struct il_priv *il,
  132. struct il_tx_queue *txq,
  133. int tx_fifo_id, int scd_retry);
  134. static inline u32 il4965_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 il4965_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 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid);
  154. /* rx */
  155. void il4965_rx_missed_beacon_notif(struct il_priv *il,
  156. struct il_rx_buf *rxb);
  157. bool il4965_good_plcp_health(struct il_priv *il,
  158. struct il_rx_pkt *pkt);
  159. void il4965_rx_statistics(struct il_priv *il,
  160. struct il_rx_buf *rxb);
  161. void il4965_reply_statistics(struct il_priv *il,
  162. struct il_rx_buf *rxb);
  163. /* scan */
  164. int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
  165. /* station mgmt */
  166. int il4965_manage_ibss_station(struct il_priv *il,
  167. struct ieee80211_vif *vif, bool add);
  168. /* hcmd */
  169. int il4965_send_beacon_cmd(struct il_priv *il);
  170. #ifdef CONFIG_IWLEGACY_DEBUG
  171. const char *il4965_get_tx_fail_reason(u32 status);
  172. #else
  173. static inline const char *
  174. il4965_get_tx_fail_reason(u32 status) { return ""; }
  175. #endif
  176. /* station management */
  177. int il4965_alloc_bcast_station(struct il_priv *il,
  178. struct il_rxon_context *ctx);
  179. int il4965_add_bssid_station(struct il_priv *il,
  180. struct il_rxon_context *ctx,
  181. const u8 *addr, u8 *sta_id_r);
  182. int il4965_remove_default_wep_key(struct il_priv *il,
  183. struct il_rxon_context *ctx,
  184. struct ieee80211_key_conf *key);
  185. int il4965_set_default_wep_key(struct il_priv *il,
  186. struct il_rxon_context *ctx,
  187. struct ieee80211_key_conf *key);
  188. int il4965_restore_default_wep_keys(struct il_priv *il,
  189. struct il_rxon_context *ctx);
  190. int il4965_set_dynamic_key(struct il_priv *il,
  191. struct il_rxon_context *ctx,
  192. struct ieee80211_key_conf *key, u8 sta_id);
  193. int il4965_remove_dynamic_key(struct il_priv *il,
  194. struct il_rxon_context *ctx,
  195. struct ieee80211_key_conf *key, u8 sta_id);
  196. void il4965_update_tkip_key(struct il_priv *il,
  197. struct il_rxon_context *ctx,
  198. struct ieee80211_key_conf *keyconf,
  199. struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
  200. int il4965_sta_tx_modify_enable_tid(struct il_priv *il,
  201. int sta_id, int tid);
  202. int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
  203. int tid, u16 ssn);
  204. int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
  205. int tid);
  206. void il4965_sta_modify_sleep_tx_count(struct il_priv *il,
  207. int sta_id, int cnt);
  208. int il4965_update_bcast_stations(struct il_priv *il);
  209. /* rate */
  210. static inline u32 il4965_ant_idx_to_flags(u8 ant_idx)
  211. {
  212. return BIT(ant_idx) << RATE_MCS_ANT_POS;
  213. }
  214. static inline u8 il4965_hw_get_rate(__le32 rate_n_flags)
  215. {
  216. return le32_to_cpu(rate_n_flags) & 0xFF;
  217. }
  218. static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags)
  219. {
  220. return cpu_to_le32(flags|(u32)rate);
  221. }
  222. /* eeprom */
  223. void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac);
  224. int il4965_eeprom_acquire_semaphore(struct il_priv *il);
  225. void il4965_eeprom_release_semaphore(struct il_priv *il);
  226. int il4965_eeprom_check_version(struct il_priv *il);
  227. /* mac80211 handlers (for 4965) */
  228. void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
  229. int il4965_mac_start(struct ieee80211_hw *hw);
  230. void il4965_mac_stop(struct ieee80211_hw *hw);
  231. void il4965_configure_filter(struct ieee80211_hw *hw,
  232. unsigned int changed_flags,
  233. unsigned int *total_flags,
  234. u64 multicast);
  235. int il4965_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 il4965_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 il4965_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 il4965_mac_sta_add(struct ieee80211_hw *hw,
  249. struct ieee80211_vif *vif,
  250. struct ieee80211_sta *sta);
  251. void il4965_mac_channel_switch(struct ieee80211_hw *hw,
  252. struct ieee80211_channel_switch *ch_switch);
  253. #endif /* __il_4965_h__ */