Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 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 | |
| 63 | #ifndef __iwl_4965_h__ |
| 64 | #define __iwl_4965_h__ |
| 65 | |
| 66 | #include "iwl-dev.h" |
| 67 | |
| 68 | /* configuration for the _4965 devices */ |
| 69 | extern struct iwl_cfg iwl4965_cfg; |
| 70 | |
| 71 | extern struct iwl_mod_params iwl4965_mod_params; |
| 72 | |
| 73 | extern struct ieee80211_ops iwl4965_hw_ops; |
| 74 | |
| 75 | /* tx queue */ |
| 76 | void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, |
| 77 | int sta_id, int tid, int freed); |
| 78 | |
| 79 | /* RXON */ |
| 80 | void iwl4965_set_rxon_chain(struct iwl_priv *priv, |
| 81 | struct iwl_rxon_context *ctx); |
| 82 | |
| 83 | /* uCode */ |
| 84 | int iwl4965_verify_ucode(struct iwl_priv *priv); |
| 85 | |
| 86 | /* lib */ |
| 87 | void iwl4965_check_abort_status(struct iwl_priv *priv, |
| 88 | u8 frame_count, u32 status); |
| 89 | |
| 90 | void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); |
| 91 | int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); |
| 92 | int iwl4965_hw_nic_init(struct iwl_priv *priv); |
| 93 | int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display); |
| 94 | |
| 95 | /* rx */ |
| 96 | void iwl4965_rx_queue_restock(struct iwl_priv *priv); |
| 97 | void iwl4965_rx_replenish(struct iwl_priv *priv); |
| 98 | void iwl4965_rx_replenish_now(struct iwl_priv *priv); |
| 99 | void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq); |
| 100 | int iwl4965_rxq_stop(struct iwl_priv *priv); |
| 101 | int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); |
| 102 | void iwl4965_rx_reply_rx(struct iwl_priv *priv, |
| 103 | struct iwl_rx_mem_buffer *rxb); |
| 104 | void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, |
| 105 | struct iwl_rx_mem_buffer *rxb); |
| 106 | void iwl4965_rx_handle(struct iwl_priv *priv); |
| 107 | |
| 108 | /* tx */ |
| 109 | void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); |
| 110 | int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, |
| 111 | struct iwl_tx_queue *txq, |
| 112 | dma_addr_t addr, u16 len, u8 reset, u8 pad); |
| 113 | int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, |
| 114 | struct iwl_tx_queue *txq); |
| 115 | void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, |
| 116 | struct ieee80211_tx_info *info); |
| 117 | int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); |
| 118 | int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, |
| 119 | struct ieee80211_sta *sta, u16 tid, u16 *ssn); |
| 120 | int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, |
| 121 | struct ieee80211_sta *sta, u16 tid); |
| 122 | int iwl4965_txq_check_empty(struct iwl_priv *priv, |
| 123 | int sta_id, u8 tid, int txq_id); |
| 124 | void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, |
| 125 | struct iwl_rx_mem_buffer *rxb); |
| 126 | int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); |
| 127 | void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv); |
| 128 | int iwl4965_txq_ctx_alloc(struct iwl_priv *priv); |
| 129 | void iwl4965_txq_ctx_reset(struct iwl_priv *priv); |
| 130 | void iwl4965_txq_ctx_stop(struct iwl_priv *priv); |
| 131 | void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask); |
| 132 | |
| 133 | /* |
| 134 | * Acquire priv->lock before calling this function ! |
| 135 | */ |
| 136 | void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index); |
| 137 | /** |
| 138 | * iwl4965_tx_queue_set_status - (optionally) start Tx/Cmd queue |
| 139 | * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed |
| 140 | * @scd_retry: (1) Indicates queue will be used in aggregation mode |
| 141 | * |
| 142 | * NOTE: Acquire priv->lock before calling this function ! |
| 143 | */ |
| 144 | void iwl4965_tx_queue_set_status(struct iwl_priv *priv, |
| 145 | struct iwl_tx_queue *txq, |
| 146 | int tx_fifo_id, int scd_retry); |
| 147 | |
| 148 | static inline u32 iwl4965_tx_status_to_mac80211(u32 status) |
| 149 | { |
| 150 | status &= TX_STATUS_MSK; |
| 151 | |
| 152 | switch (status) { |
| 153 | case TX_STATUS_SUCCESS: |
| 154 | case TX_STATUS_DIRECT_DONE: |
| 155 | return IEEE80211_TX_STAT_ACK; |
| 156 | case TX_STATUS_FAIL_DEST_PS: |
| 157 | return IEEE80211_TX_STAT_TX_FILTERED; |
| 158 | default: |
| 159 | return 0; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static inline bool iwl4965_is_tx_success(u32 status) |
| 164 | { |
| 165 | status &= TX_STATUS_MSK; |
| 166 | return (status == TX_STATUS_SUCCESS) || |
| 167 | (status == TX_STATUS_DIRECT_DONE); |
| 168 | } |
| 169 | |
| 170 | u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); |
| 171 | |
| 172 | /* rx */ |
| 173 | void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, |
| 174 | struct iwl_rx_mem_buffer *rxb); |
| 175 | bool iwl4965_good_plcp_health(struct iwl_priv *priv, |
| 176 | struct iwl_rx_packet *pkt); |
| 177 | void iwl4965_rx_statistics(struct iwl_priv *priv, |
| 178 | struct iwl_rx_mem_buffer *rxb); |
| 179 | void iwl4965_reply_statistics(struct iwl_priv *priv, |
| 180 | struct iwl_rx_mem_buffer *rxb); |
| 181 | |
| 182 | /* scan */ |
| 183 | int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); |
| 184 | |
| 185 | /* station mgmt */ |
| 186 | int iwl4965_manage_ibss_station(struct iwl_priv *priv, |
| 187 | struct ieee80211_vif *vif, bool add); |
| 188 | |
| 189 | /* hcmd */ |
| 190 | int iwl4965_send_beacon_cmd(struct iwl_priv *priv); |
| 191 | |
| 192 | #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG |
| 193 | const char *iwl4965_get_tx_fail_reason(u32 status); |
| 194 | #else |
| 195 | static inline const char * |
| 196 | iwl4965_get_tx_fail_reason(u32 status) { return ""; } |
| 197 | #endif |
| 198 | |
| 199 | /* station management */ |
| 200 | int iwl4965_alloc_bcast_station(struct iwl_priv *priv, |
| 201 | struct iwl_rxon_context *ctx); |
| 202 | int iwl4965_add_bssid_station(struct iwl_priv *priv, |
| 203 | struct iwl_rxon_context *ctx, |
| 204 | const u8 *addr, u8 *sta_id_r); |
| 205 | int iwl4965_remove_default_wep_key(struct iwl_priv *priv, |
| 206 | struct iwl_rxon_context *ctx, |
| 207 | struct ieee80211_key_conf *key); |
| 208 | int iwl4965_set_default_wep_key(struct iwl_priv *priv, |
| 209 | struct iwl_rxon_context *ctx, |
| 210 | struct ieee80211_key_conf *key); |
| 211 | int iwl4965_restore_default_wep_keys(struct iwl_priv *priv, |
| 212 | struct iwl_rxon_context *ctx); |
| 213 | int iwl4965_set_dynamic_key(struct iwl_priv *priv, |
| 214 | struct iwl_rxon_context *ctx, |
| 215 | struct ieee80211_key_conf *key, u8 sta_id); |
| 216 | int iwl4965_remove_dynamic_key(struct iwl_priv *priv, |
| 217 | struct iwl_rxon_context *ctx, |
| 218 | struct ieee80211_key_conf *key, u8 sta_id); |
| 219 | void iwl4965_update_tkip_key(struct iwl_priv *priv, |
| 220 | struct iwl_rxon_context *ctx, |
| 221 | struct ieee80211_key_conf *keyconf, |
| 222 | struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); |
| 223 | int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, |
| 224 | int sta_id, int tid); |
| 225 | int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, |
| 226 | int tid, u16 ssn); |
| 227 | int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, |
| 228 | int tid); |
| 229 | void iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, |
| 230 | int sta_id, int cnt); |
| 231 | int iwl4965_update_bcast_stations(struct iwl_priv *priv); |
| 232 | |
| 233 | /* rate */ |
| 234 | static inline u32 iwl4965_ant_idx_to_flags(u8 ant_idx) |
| 235 | { |
| 236 | return BIT(ant_idx) << RATE_MCS_ANT_POS; |
| 237 | } |
| 238 | |
| 239 | static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags) |
| 240 | { |
| 241 | return le32_to_cpu(rate_n_flags) & 0xFF; |
| 242 | } |
| 243 | |
| 244 | static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u32 flags) |
| 245 | { |
| 246 | return cpu_to_le32(flags|(u32)rate); |
| 247 | } |
| 248 | |
| 249 | /* eeprom */ |
| 250 | void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); |
| 251 | int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv); |
| 252 | void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv); |
| 253 | int iwl4965_eeprom_check_version(struct iwl_priv *priv); |
| 254 | |
| 255 | /* mac80211 handlers (for 4965) */ |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 256 | void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 257 | int iwl4965_mac_start(struct ieee80211_hw *hw); |
| 258 | void iwl4965_mac_stop(struct ieee80211_hw *hw); |
| 259 | void iwl4965_configure_filter(struct ieee80211_hw *hw, |
| 260 | unsigned int changed_flags, |
| 261 | unsigned int *total_flags, |
| 262 | u64 multicast); |
| 263 | int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 264 | struct ieee80211_vif *vif, struct ieee80211_sta *sta, |
| 265 | struct ieee80211_key_conf *key); |
| 266 | void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 267 | struct ieee80211_vif *vif, |
| 268 | struct ieee80211_key_conf *keyconf, |
| 269 | struct ieee80211_sta *sta, |
| 270 | u32 iv32, u16 *phase1key); |
| 271 | int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, |
| 272 | struct ieee80211_vif *vif, |
| 273 | enum ieee80211_ampdu_mlme_action action, |
| 274 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, |
| 275 | u8 buf_size); |
| 276 | int iwl4965_mac_sta_add(struct ieee80211_hw *hw, |
| 277 | struct ieee80211_vif *vif, |
| 278 | struct ieee80211_sta *sta); |
| 279 | void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, |
| 280 | struct ieee80211_channel_switch *ch_switch); |
| 281 | |
| 282 | #endif /* __iwl_4965_h__ */ |