blob: f950da02b21182842ddb32748d311c5426f4373e [file] [log] [blame]
Tomas Winkler82b9a122008-03-04 18:09:30 -08001/******************************************************************************
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 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07008 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
Tomas Winkler82b9a122008-03-04 18:09:30 -08009 *
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:
Winkler, Tomas759ef892008-12-09 11:28:58 -080028 * Intel Linux Wireless <ilw@linux.intel.com>
Tomas Winkler82b9a122008-03-04 18:09:30 -080029 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -070033 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
Tomas Winkler82b9a122008-03-04 18:09:30 -080034 * 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_core_h__
64#define __iwl_core_h__
65
Johannes Berg266af4c72011-03-10 20:13:26 -080066#include "iwl-dev.h"
67
Tomas Winkler857485c2008-03-21 13:53:44 -070068/************************
69 * forward declarations *
70 ************************/
71struct iwl_host_cmd;
72struct iwl_cmd;
73
74
Zhu Yi61b91c12009-12-24 15:31:10 +080075#define IWLWIFI_VERSION "in-tree:"
Wey-Yi Guy901069c2011-04-05 09:42:00 -070076#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation"
Tomas Winklera7b75202008-12-11 10:33:41 -080077#define DRV_AUTHOR "<ilw@linux.intel.com>"
Tomas Winklerdf48c322008-03-06 10:40:19 -080078
Tomas Winkler82b9a122008-03-04 18:09:30 -080079#define IWL_PCI_DEVICE(dev, subdev, cfg) \
80 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
81 .subvendor = PCI_ANY_ID, .subdevice = (subdev), \
82 .driver_data = (kernel_ulong_t)&(cfg)
83
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -070084#define TIME_UNIT 1024
85
Tomas Winkler82b9a122008-03-04 18:09:30 -080086#define IWL_SKU_G 0x1
87#define IWL_SKU_A 0x2
88#define IWL_SKU_N 0x8
89
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -070090#define IWL_CMD(x) case x: return #x
91
Tomas Winkler3c424c22008-04-15 16:01:42 -070092struct iwl_hcmd_ops {
Johannes Berg246ed352010-08-23 10:46:32 +020093 void (*set_rxon_chain)(struct iwl_priv *priv,
94 struct iwl_rxon_context *ctx);
Wey-Yi Guy2f748de2009-09-17 10:43:51 -070095 int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant);
Johannes Berg65b52bd2010-04-13 01:04:31 -070096 void (*send_bt_config)(struct iwl_priv *priv);
Johannes Berg52a02d12010-08-27 09:44:50 -070097 int (*set_pan_params)(struct iwl_priv *priv);
Tomas Winkler3c424c22008-04-15 16:01:42 -070098};
Abhijeet Kolekar79fa4552009-04-08 11:26:39 -070099
Tomas Winkler857485c2008-03-21 13:53:44 -0700100struct iwl_hcmd_utils_ops {
Tomas Winkler133636d2008-05-05 10:22:34 +0800101 u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data);
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700102 void (*gain_computation)(struct iwl_priv *priv,
103 u32 *average_noise,
104 u16 min_average_noise_antennat_i,
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700105 u32 min_average_noise,
106 u8 default_chain);
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700107 void (*chain_noise_reset)(struct iwl_priv *priv);
Johannes Berg94597ab2010-08-09 10:57:02 -0700108 void (*tx_cmd_protection)(struct iwl_priv *priv,
109 struct ieee80211_tx_info *info,
110 __le16 fc, __le32 *tx_flags);
Tomas Winklercaab8f12008-08-04 16:00:42 +0800111 int (*calc_rssi)(struct iwl_priv *priv,
112 struct iwl_rx_phy_res *rx_resp);
Johannes Berg3eecce52010-09-13 14:46:33 +0200113 int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
Tomas Winkler857485c2008-03-21 13:53:44 -0700114};
115
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700116struct iwl_apm_ops {
117 int (*init)(struct iwl_priv *priv);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700118 void (*config)(struct iwl_priv *priv);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700119};
120
121struct iwl_temp_ops {
122 void (*temperature)(struct iwl_priv *priv);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700123};
124
Assaf Krauss6bc913b2008-03-11 16:17:18 -0700125struct iwl_lib_ops {
Tomas Winklera96a27f2008-10-23 23:48:56 -0700126 /* set hw dependent parameters */
Tomas Winkler5425e492008-04-15 16:01:38 -0700127 int (*set_hw_params)(struct iwl_priv *priv);
Emmanuel Grumbachd4789ef2008-04-24 11:55:20 -0700128 /* setup Rx handler */
129 void (*rx_handler_setup)(struct iwl_priv *priv);
Emmanuel Grumbach4e393172008-06-12 09:46:53 +0800130 /* setup deferred work */
131 void (*setup_deferred_work)(struct iwl_priv *priv);
132 /* cancel deferred work */
133 void (*cancel_deferred_work)(struct iwl_priv *priv);
Tomas Winkler57aab752008-04-14 21:16:03 -0700134 /* check validity of rtc data address */
135 int (*is_valid_rtc_data_addr)(u32 addr);
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700136 int (*set_channel_switch)(struct iwl_priv *priv,
137 struct ieee80211_channel_switch *ch_switch);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700138 /* power management */
139 struct iwl_apm_ops apm_ops;
140
Mohamed Abbas5da4b55f2008-04-21 15:41:51 -0700141 /* power */
Mohamed Abbas5da4b55f2008-04-21 15:41:51 -0700142 void (*update_chain_flags)(struct iwl_priv *priv);
Wey-Yi Guye39fdee2010-11-10 09:56:40 -0800143
Assaf Krauss6bc913b2008-03-11 16:17:18 -0700144 /* eeprom operations (as defined in iwl-eeprom.h) */
145 struct iwl_eeprom_ops eeprom_ops;
Wey-Yi Guy62161ae2009-05-21 13:44:23 -0700146
147 /* temperature */
148 struct iwl_temp_ops temp_ops;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100149
Wey-Yi Guy716c74b2010-06-24 13:22:36 -0700150 int (*txfifo_flush)(struct iwl_priv *priv, u16 flush_control);
Wey-Yi Guy65550632010-06-24 13:18:35 -0700151 void (*dev_txfifo_flush)(struct iwl_priv *priv, u16 flush_control);
Wey-Yi Guy716c74b2010-06-24 13:22:36 -0700152
Assaf Krauss6bc913b2008-03-11 16:17:18 -0700153};
154
Shanyu Zhao6b5ce502010-09-14 16:23:32 -0700155/* NIC specific ops */
156struct iwl_nic_ops {
157 void (*additional_nic_config)(struct iwl_priv *priv);
158};
159
Assaf Krauss6bc913b2008-03-11 16:17:18 -0700160struct iwl_ops {
161 const struct iwl_lib_ops *lib;
Tomas Winkler3c424c22008-04-15 16:01:42 -0700162 const struct iwl_hcmd_ops *hcmd;
Tomas Winkler857485c2008-03-21 13:53:44 -0700163 const struct iwl_hcmd_utils_ops *utils;
Shanyu Zhao6b5ce502010-09-14 16:23:32 -0700164 const struct iwl_nic_ops *nic;
Assaf Krauss6bc913b2008-03-11 16:17:18 -0700165};
166
Assaf Krauss00acbc92008-03-14 10:38:47 -0700167struct iwl_mod_params {
Emmanuel Grumbachfcc76c62008-04-15 16:01:47 -0700168 int sw_crypto; /* def: 0 = using hardware encryption */
Assaf Krauss00acbc92008-03-14 10:38:47 -0700169 int num_of_queues; /* def: HW dependent */
Reinette Chatrec18bd872009-06-03 11:44:12 -0700170 int disable_11n; /* def: 0 = 11n capabilities enabled */
Assaf Krauss00acbc92008-03-14 10:38:47 -0700171 int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */
172 int antenna; /* def: 0 = both antennas (use diversity) */
Ester Kummer3a1081e2008-05-06 11:05:14 +0800173 int restart_fw; /* def: 1 = restart firmware */
Stanislaw Gruszkab7977ff2011-02-28 14:33:15 +0100174 bool plcp_check; /* def: true = enable plcp health check */
175 bool ack_check; /* def: false = disable ack health check */
Wey-Yi Guyb60eec92011-06-03 13:52:38 -0700176 bool bt_coex_active; /* def: true = enable bt coex */
Wey-Yi Guy6b0184c2011-06-03 13:52:39 -0700177 int led_mode; /* def: 0 = system default */
Assaf Krauss00acbc92008-03-14 10:38:47 -0700178};
179
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700180/*
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700181 * @max_ll_items: max number of OTP blocks
182 * @shadow_ram_support: shadow support for OTP memory
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -0700183 * @led_compensation: compensate on the led on/off time per HW according
184 * to the deviation to achieve the desired led frequency.
185 * The detail algorithm is described in iwl-led.c
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700186 * @chain_noise_num_beacons: number of beacons used to compute chain noise
Wey-Yi Guy6047b4f2009-10-23 13:42:27 -0700187 * @adv_thermal_throttle: support advance thermal throttle
Wey-Yi Guy480e8402009-10-23 13:42:28 -0700188 * @support_ct_kill_exit: support ct kill exit condition
Wey-Yi Guy1933ac42009-10-30 14:36:18 -0700189 * @support_wimax_coexist: support wimax/wifi co-exist
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800190 * @plcp_delta_threshold: plcp error rate threshold used to trigger
191 * radio tuning when there is a high receiving plcp error rate
Wey-Yi Guy4ff73972010-04-30 11:35:16 -0700192 * @chain_noise_scale: default chain noise scale used for gain computation
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100193 * @wd_timeout: TX queues watchdog timeout
Wey-Yi Guy4ff73972010-04-30 11:35:16 -0700194 * @temperature_kelvin: temperature report by uCode in kelvin
195 * @max_event_log_size: size of event log buffer size for ucode event logging
Wey-Yi Guyf81c1f42010-11-10 09:56:50 -0800196 * @shadow_reg_enable: HW shadhow register bit
Wey-Yi Guy8829c9e2010-11-10 11:05:38 -0800197 */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700198struct iwl_base_params {
Tomas Winkler073d3f52008-04-21 15:41:52 -0700199 int eeprom_size;
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700200 int num_of_queues; /* def: HW dependent */
201 int num_of_ampdu_queues;/* def: HW dependent */
Ben Cahillfadb3582009-10-23 13:42:21 -0700202 /* for iwl_apm_init() */
203 u32 pll_cfg_val;
Ben Cahillfadb3582009-10-23 13:42:21 -0700204
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700205 const u16 max_ll_items;
206 const bool shadow_ram_support;
Wey-Yi Guyf2d0d0e2009-09-11 10:38:14 -0700207 u16 led_compensation;
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700208 int chain_noise_num_beacons;
Wey-Yi Guy6047b4f2009-10-23 13:42:27 -0700209 bool adv_thermal_throttle;
Wey-Yi Guy480e8402009-10-23 13:42:28 -0700210 bool support_ct_kill_exit;
Wey-Yi Guy1933ac42009-10-30 14:36:18 -0700211 const bool support_wimax_coexist;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800212 u8 plcp_delta_threshold;
Ben Cahilld4fe5ac2010-02-05 11:33:46 -0800213 s32 chain_noise_scale;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100214 unsigned int wd_timeout;
Wey-Yi Guy2f3f7f92010-03-18 10:56:32 -0700215 bool temperature_kelvin;
Wey-Yi Guy678b3852010-03-26 12:54:37 -0700216 u32 max_event_log_size;
Wey-Yi Guyf81c1f42010-11-10 09:56:50 -0800217 const bool shadow_reg_enable;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700218};
219/*
220 * @advanced_bt_coexist: support advanced bt coexist
221 * @bt_init_traffic_load: specify initial bt traffic load
222 * @bt_prio_boost: default bt priority boost value
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700223 * @agg_time_limit: maximum number of uSec in aggregation
224 * @ampdu_factor: Maximum A-MPDU length factor
225 * @ampdu_density: Minimum A-MPDU spacing
Wey-Yi Guye3661762010-11-23 10:58:54 -0800226 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700227 */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700228struct iwl_bt_params {
Johannes Berg670245e2010-08-23 07:56:55 -0700229 bool advanced_bt_coexist;
Wey-Yi Guya4b96cc2010-08-23 07:57:08 -0700230 u8 bt_init_traffic_load;
Wey-Yi Guy5d297d52010-08-23 07:57:09 -0700231 u8 bt_prio_boost;
Wey-Yi Guy74697012010-07-28 09:18:54 -0700232 u16 agg_time_limit;
Wey-Yi Guy172c1d12010-08-04 12:02:43 -0700233 u8 ampdu_factor;
234 u8 ampdu_density;
Wey-Yi Guye3661762010-11-23 10:58:54 -0800235 bool bt_sco_disable;
Wey-Yi Guy60132702011-02-18 17:23:54 -0800236 bool bt_session_2;
Tomas Winkler82b9a122008-03-04 18:09:30 -0800237};
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700238/*
239 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700240 */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700241struct iwl_ht_params {
242 const bool ht_greenfield_support; /* if used set to true */
243 bool use_rts_for_aggregation;
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700244 enum ieee80211_smps_mode smps_mode;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700245};
246
247/**
248 * struct iwl_cfg
249 * @fw_name_pre: Firmware filename prefix. The api version and extension
250 * (.ucode) will be added to filename before loading from disk. The
251 * filename is constructed as fw_name_pre<api>.ucode.
252 * @ucode_api_max: Highest version of uCode API supported by driver.
253 * @ucode_api_min: Lowest version of uCode API supported by driver.
254 * @pa_type: used by 6000 series only to identify the type of Power Amplifier
255 * @need_dc_calib: need to perform init dc calibration
Shanyu Zhaobf53f932010-09-21 16:54:01 -0700256 * @need_temp_offset_calib: need to perform temperature offset calibration
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700257 * @scan_antennas: available antenna for scan operation
Wey-Yi Guy564b3442010-11-09 09:21:34 -0800258 * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off)
Wey-Yi Guy35162ba2010-11-23 10:58:56 -0800259 * @adv_pm: advance power management
Wey-Yi Guy17423ea2010-12-06 11:51:39 -0800260 * @rx_with_siso_diversity: 1x1 device with rx antenna diversity
Wey-Yi Guy50619ac2010-12-07 08:06:31 -0800261 * @internal_wimax_coex: internal wifi/wimax combo device
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800262 * @iq_invert: I/Q inversion
Wey-Yi Guydcf66402011-04-01 13:20:44 -0700263 * @disable_otp_refresh: disable OTP refresh current limit
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700264 *
265 * We enable the driver to be backward compatible wrt API version. The
266 * driver specifies which APIs it supports (with @ucode_api_max being the
267 * highest and @ucode_api_min the lowest). Firmware will only be loaded if
268 * it has a supported API version. The firmware's API version will be
269 * stored in @iwl_priv, enabling the driver to make runtime changes based
270 * on firmware version used.
271 *
272 * For example,
273 * if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
274 * Driver interacts with Firmware API version >= 2.
275 * } else {
276 * Driver interacts with Firmware API version 1.
277 * }
278 *
279 * The ideal usage of this infrastructure is to treat a new ucode API
280 * release as a new hardware revision. That is, through utilizing the
281 * iwl_hcmd_utils_ops etc. we accommodate different command structures
282 * and flows between hardware versions (4965/5000) as well as their API
283 * versions.
284 *
285 */
286struct iwl_cfg {
287 /* params specific to an individual device within a device family */
288 const char *name;
289 const char *fw_name_pre;
290 const unsigned int ucode_api_max;
291 const unsigned int ucode_api_min;
292 u8 valid_tx_ant;
293 u8 valid_rx_ant;
294 unsigned int sku;
295 u16 eeprom_ver;
296 u16 eeprom_calib_ver;
297 const struct iwl_ops *ops;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700298 /* params not likely to change within a device family */
299 struct iwl_base_params *base_params;
300 /* params likely to change within a device family */
301 struct iwl_ht_params *ht_params;
302 struct iwl_bt_params *bt_params;
303 enum iwl_pa_type pa_type; /* if used set to IWL_PA_SYSTEM */
304 const bool need_dc_calib; /* if used set to true */
Shanyu Zhaobf53f932010-09-21 16:54:01 -0700305 const bool need_temp_offset_calib; /* if used set to true */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700306 u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
Wey-Yi Guy564b3442010-11-09 09:21:34 -0800307 enum iwl_led_mode led_mode;
Wey-Yi Guy35162ba2010-11-23 10:58:56 -0800308 const bool adv_pm;
Wey-Yi Guy17423ea2010-12-06 11:51:39 -0800309 const bool rx_with_siso_diversity;
Wey-Yi Guy50619ac2010-12-07 08:06:31 -0800310 const bool internal_wimax_coex;
Wey-Yi Guy52e6b852011-01-18 08:58:48 -0800311 const bool iq_invert;
Wey-Yi Guydcf66402011-04-01 13:20:44 -0700312 const bool disable_otp_refresh;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700313};
Tomas Winkler82b9a122008-03-04 18:09:30 -0800314
Assaf Krauss1d0a0822008-03-14 10:38:48 -0700315/***************************
316 * L i b *
317 ***************************/
318
Abhijeet Kolekar488829f2009-03-26 10:14:10 -0700319int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
320 const struct ieee80211_tx_queue_params *params);
Johannes Berga85d7cc2010-07-31 08:34:10 -0700321int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw);
Johannes Berg246ed352010-08-23 10:46:32 +0200322void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
323 int hw_decrypt);
324int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
325int iwl_full_rxon_required(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
Johannes Berg246ed352010-08-23 10:46:32 +0200326int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
327 struct iwl_rxon_context *ctx);
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700328void iwl_set_flags_for_band(struct iwl_priv *priv,
Johannes Berg246ed352010-08-23 10:46:32 +0200329 struct iwl_rxon_context *ctx,
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700330 enum ieee80211_band band,
331 struct ieee80211_vif *vif);
Abhijeet Kolekar14023642010-06-02 21:15:10 -0700332u8 iwl_get_single_channel_number(struct iwl_priv *priv,
333 enum ieee80211_band band);
Johannes Bergfad95bf2009-09-11 10:38:15 -0700334void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
Johannes Berg7e6a5882010-08-23 10:46:46 +0200335bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
336 struct iwl_rxon_context *ctx,
337 struct ieee80211_sta_ht_cap *ht_cap);
Johannes Berg1dda6d22010-04-29 04:43:06 -0700338void iwl_connection_init_rx_config(struct iwl_priv *priv,
Johannes Bergd0fe4782010-08-23 10:46:58 +0200339 struct iwl_rxon_context *ctx);
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700340void iwl_set_rate(struct iwl_priv *priv);
Samuel Ortiz8ccde882009-01-27 14:27:52 -0800341void iwl_irq_handle_error(struct iwl_priv *priv);
Abhijeet Kolekarcbb6ab92009-04-08 11:26:46 -0700342int iwl_mac_add_interface(struct ieee80211_hw *hw,
Johannes Berg1ed32e42009-12-23 13:15:45 +0100343 struct ieee80211_vif *vif);
Abhijeet Kolekard8052312009-04-08 11:26:47 -0700344void iwl_mac_remove_interface(struct ieee80211_hw *hw,
Johannes Berg1ed32e42009-12-23 13:15:45 +0100345 struct ieee80211_vif *vif);
Johannes Bergd4daaea2010-10-23 09:15:43 -0700346int iwl_mac_change_interface(struct ieee80211_hw *hw,
347 struct ieee80211_vif *vif,
348 enum nl80211_iftype newtype, bool newp2p);
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700349int iwl_alloc_txq_mem(struct iwl_priv *priv);
350void iwl_free_txq_mem(struct iwl_priv *priv);
Wey-Yi Guy708068d2010-11-10 09:56:41 -0800351
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700352#ifdef CONFIG_IWLWIFI_DEBUGFS
353int iwl_alloc_traffic_mem(struct iwl_priv *priv);
354void iwl_free_traffic_mem(struct iwl_priv *priv);
355void iwl_reset_traffic_log(struct iwl_priv *priv);
356void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
357 u16 length, struct ieee80211_hdr *header);
358void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
359 u16 length, struct ieee80211_hdr *header);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700360const char *get_mgmt_string(int cmd);
361const char *get_ctrl_string(int cmd);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800362void iwl_clear_traffic_stats(struct iwl_priv *priv);
Reinette Chatre450ccb32009-08-07 15:41:49 -0700363void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc,
364 u16 len);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700365#else
366static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv)
367{
368 return 0;
369}
370static inline void iwl_free_traffic_mem(struct iwl_priv *priv)
371{
372}
373static inline void iwl_reset_traffic_log(struct iwl_priv *priv)
374{
375}
376static inline void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
377 u16 length, struct ieee80211_hdr *header)
378{
379}
380static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
381 u16 length, struct ieee80211_hdr *header)
382{
383}
Reinette Chatre450ccb32009-08-07 15:41:49 -0700384static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
385 __le16 fc, u16 len)
386{
Reinette Chatre450ccb32009-08-07 15:41:49 -0700387}
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700388#endif
Abhijeet Kolekar030f05e2009-02-18 15:54:28 -0800389
390/*****************************************************
Tomas Winklera55360e2008-05-05 10:22:28 +0800391* RX
392******************************************************/
Abhijeet Kolekar3e5d2382009-03-17 21:51:49 -0700393void iwl_cmd_queue_free(struct iwl_priv *priv);
Stanislaw Gruszka387f3382011-02-28 14:33:13 +0100394void iwl_cmd_queue_unmap(struct iwl_priv *priv);
Tomas Winklera55360e2008-05-05 10:22:28 +0800395int iwl_rx_queue_alloc(struct iwl_priv *priv);
Abhijeet Kolekar7bfedc52010-02-03 13:47:56 -0800396void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
Tomas Winklera55360e2008-05-05 10:22:28 +0800397 struct iwl_rx_queue *q);
Tomas Winklera55360e2008-05-05 10:22:28 +0800398int iwl_rx_queue_space(const struct iwl_rx_queue *q);
Tomas Winkler17b88922008-05-29 16:35:12 +0800399void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100400
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700401void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
Tomas Winklera55360e2008-05-05 10:22:28 +0800402
Tomas Winklera332f8d2008-05-29 16:35:08 +0800403/* TX helpers */
404
Tomas Winklera55360e2008-05-05 10:22:28 +0800405/*****************************************************
Ron Rindjunsky1053d352008-05-05 10:22:43 +0800406* TX
407******************************************************/
Abhijeet Kolekar7bfedc52010-02-03 13:47:56 -0800408void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
Samuel Ortiza8e74e22009-01-23 13:45:14 -0800409int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
410 int slots_num, u32 txq_id);
Zhu Yide0f60e2010-03-23 00:45:03 -0700411void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq,
412 int slots_num, u32 txq_id);
Samuel Ortiza8e74e22009-01-23 13:45:14 -0800413void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id);
Stanislaw Gruszka387f3382011-02-28 14:33:13 +0100414void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id);
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100415void iwl_setup_watchdog(struct iwl_priv *priv);
Ron Rindjunsky1053d352008-05-05 10:22:43 +0800416/*****************************************************
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800417 * TX power
418 ****************************************************/
419int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);
420
Tomas Winkler2a421b92008-06-12 09:47:10 +0800421/*******************************************************************************
Tomas Winklere7d326a2008-06-12 09:47:11 +0800422 * Rate
423 ******************************************************************************/
424
Johannes Berg76d04812010-08-23 10:46:47 +0200425u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv,
426 struct iwl_rxon_context *ctx);
Samuel Ortiz8ccde882009-01-27 14:27:52 -0800427
Tomas Winklere7d326a2008-06-12 09:47:11 +0800428/*******************************************************************************
Tomas Winkler2a421b92008-06-12 09:47:10 +0800429 * Scanning
430 ******************************************************************************/
Tomas Winklerf53696d2008-06-12 09:47:12 +0800431void iwl_init_scan_params(struct iwl_priv *priv);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800432int iwl_scan_cancel(struct iwl_priv *priv);
433int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
Stanislaw Gruszkae7e16b92010-09-13 14:46:41 +0200434void iwl_force_scan_end(struct iwl_priv *priv);
Johannes Berga060bbf2010-04-27 11:59:34 +0200435int iwl_mac_hw_scan(struct ieee80211_hw *hw,
436 struct ieee80211_vif *vif,
437 struct cfg80211_scan_request *req);
Johannes Berg88be0262010-04-07 00:21:36 -0700438void iwl_internal_short_hw_scan(struct iwl_priv *priv);
Wey-Yi Guyc04f9f22010-06-21 16:52:55 -0700439int iwl_force_reset(struct iwl_priv *priv, int mode, bool external);
Johannes Berg1ecf9fc2009-04-20 14:36:56 -0700440u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
Johannes Berg3a0b9aa2010-05-12 03:33:12 -0700441 const u8 *ta, const u8 *ie, int ie_len, int left);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800442void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800443u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
444 enum ieee80211_band band,
445 u8 n_probes);
446u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
Johannes Berg1dda6d22010-04-29 04:43:06 -0700447 enum ieee80211_band band,
448 struct ieee80211_vif *vif);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800449void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
Stanislaw Gruszkae7e16b92010-09-13 14:46:41 +0200450void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
Johannes Berg266af4c72011-03-10 20:13:26 -0800451int __must_check iwl_scan_initiate(struct iwl_priv *priv,
452 struct ieee80211_vif *vif,
453 enum iwl_scan_type scan_type,
454 enum ieee80211_band band);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800455
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800456/* For faster active scanning, scan will move to the next channel if fewer than
457 * PLCP_QUIET_THRESH packets are heard on this channel within
458 * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
459 * time if it's a quiet channel (nothing responded to our probe, and there's
460 * no other traffic).
461 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
Harvey Harrisonc1b4aa32009-01-29 13:26:44 -0800462#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
463#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800464
Johannes Bergb6e4c552010-04-06 04:12:42 -0700465#define IWL_SCAN_CHECK_WATCHDOG (HZ * 7)
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800466
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800467/*****************************************************
Tomas Winkler857485c2008-03-21 13:53:44 -0700468 * S e n d i n g H o s t C o m m a n d s *
469 *****************************************************/
470
471const char *get_cmd_string(u8 cmd);
Tomas Winklere5472972008-03-28 16:21:12 -0700472int __must_check iwl_send_cmd_sync(struct iwl_priv *priv,
473 struct iwl_host_cmd *cmd);
Tomas Winkler857485c2008-03-21 13:53:44 -0700474int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
Tomas Winklere5472972008-03-28 16:21:12 -0700475int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id,
476 u16 len, const void *data);
Tomas Winkler857485c2008-03-21 13:53:44 -0700477int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
478 const void *data,
Johannes Berg5696aea2009-07-24 11:13:06 -0700479 void (*callback)(struct iwl_priv *priv,
480 struct iwl_device_cmd *cmd,
Zhu Yi2f301222009-10-09 17:19:45 +0800481 struct iwl_rx_packet *pkt));
Tomas Winklerfd4abac2008-05-15 13:54:07 +0800482
483int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
Ester Kummer189a2b52008-05-15 13:54:18 +0800484
Samuel Ortizc4962942008-12-22 11:31:18 +0800485
Ester Kummer189a2b52008-05-15 13:54:18 +0800486/*****************************************************
Winkler, Tomas0ad91a32008-12-02 12:14:00 -0800487 * PCI *
488 *****************************************************/
Mohamed Abbasef850d72009-05-22 11:01:50 -0700489
Tomas Winkler3fdb68d2009-02-10 15:19:02 -0800490static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv)
491{
492 int pos;
493 u16 pci_lnk_ctl;
494 pos = pci_find_capability(priv->pci_dev, PCI_CAP_ID_EXP);
495 pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
496 return pci_lnk_ctl;
497}
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800498
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100499void iwl_bg_watchdog(unsigned long data);
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700500u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval);
501__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
502 u32 addon, u32 beacon_interval);
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800503
Wey-Yi Guy6da3a132009-03-26 10:14:08 -0700504#ifdef CONFIG_PM
John W. Linvillef60dc012010-10-25 16:12:37 -0400505int iwl_pci_suspend(struct device *device);
506int iwl_pci_resume(struct device *device);
507extern const struct dev_pm_ops iwl_pm_ops;
508
509#define IWL_PM_OPS (&iwl_pm_ops)
510
511#else /* !CONFIG_PM */
512
513#define IWL_PM_OPS NULL
514
515#endif /* !CONFIG_PM */
Winkler, Tomas0ad91a32008-12-02 12:14:00 -0800516
517/*****************************************************
Ester Kummer189a2b52008-05-15 13:54:18 +0800518* Error Handling Debugging
519******************************************************/
Wey-Yi Guy3a3ff722009-11-20 12:05:05 -0800520void iwl_dump_nic_error_log(struct iwl_priv *priv);
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800521int iwl_dump_nic_event_log(struct iwl_priv *priv,
522 bool full_log, char **buf, bool display);
Wey-Yi Guy3ecccbc2011-03-29 17:53:15 -0700523void iwl_dump_csr(struct iwl_priv *priv);
524int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display);
Reinette Chatreb7a79402009-09-25 14:24:23 -0700525#ifdef CONFIG_IWLWIFI_DEBUG
Johannes Berg246ed352010-08-23 10:46:32 +0200526void iwl_print_rx_config_cmd(struct iwl_priv *priv,
527 struct iwl_rxon_context *ctx);
Reinette Chatreb7a79402009-09-25 14:24:23 -0700528#else
Johannes Berg246ed352010-08-23 10:46:32 +0200529static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
530 struct iwl_rxon_context *ctx)
Wey-Yi Guya6435652009-11-06 14:52:46 -0800531{
532}
Reinette Chatreb7a79402009-09-25 14:24:23 -0700533#endif
534
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700535void iwl_clear_isr_stats(struct iwl_priv *priv);
Ester Kummer189a2b52008-05-15 13:54:18 +0800536
Samuel Ortiz534166d2009-01-23 13:45:16 -0800537/*****************************************************
538* GEOS
539******************************************************/
540int iwlcore_init_geos(struct iwl_priv *priv);
541void iwlcore_free_geos(struct iwl_priv *priv);
Tomas Winkler76eff182008-10-14 12:32:45 -0700542
Tomas Winklerfee12472008-04-03 16:05:21 -0700543/*************** DRIVER STATUS FUNCTIONS *****/
544
545#define STATUS_HCMD_ACTIVE 0 /* host command in progress */
Reinette Chatred2dfe6d2010-02-18 22:03:04 -0800546/* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */
Tomas Winklerfee12472008-04-03 16:05:21 -0700547#define STATUS_INT_ENABLED 2
548#define STATUS_RF_KILL_HW 3
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700549#define STATUS_CT_KILL 4
Tomas Winklerfee12472008-04-03 16:05:21 -0700550#define STATUS_INIT 5
551#define STATUS_ALIVE 6
552#define STATUS_READY 7
553#define STATUS_TEMPERATURE 8
554#define STATUS_GEO_CONFIGURED 9
555#define STATUS_EXIT_PENDING 10
Tomas Winklerfee12472008-04-03 16:05:21 -0700556#define STATUS_STATISTICS 12
557#define STATUS_SCANNING 13
558#define STATUS_SCAN_ABORTING 14
559#define STATUS_SCAN_HW 15
560#define STATUS_POWER_PMI 16
561#define STATUS_FW_ERROR 17
Johannes Berg9d39e5b2011-04-19 07:38:23 -0700562#define STATUS_DEVICE_ENABLED 18
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200563#define STATUS_CHANNEL_SWITCH_PENDING 19
Tomas Winklerfee12472008-04-03 16:05:21 -0700564
565
566static inline int iwl_is_ready(struct iwl_priv *priv)
567{
568 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
569 * set but EXIT_PENDING is not */
570 return test_bit(STATUS_READY, &priv->status) &&
571 test_bit(STATUS_GEO_CONFIGURED, &priv->status) &&
572 !test_bit(STATUS_EXIT_PENDING, &priv->status);
573}
574
575static inline int iwl_is_alive(struct iwl_priv *priv)
576{
577 return test_bit(STATUS_ALIVE, &priv->status);
578}
579
580static inline int iwl_is_init(struct iwl_priv *priv)
581{
582 return test_bit(STATUS_INIT, &priv->status);
583}
584
Adel Gadllah80fcc9e2008-07-01 17:49:50 +0200585static inline int iwl_is_rfkill_hw(struct iwl_priv *priv)
586{
587 return test_bit(STATUS_RF_KILL_HW, &priv->status);
588}
589
Tomas Winklerfee12472008-04-03 16:05:21 -0700590static inline int iwl_is_rfkill(struct iwl_priv *priv)
591{
Johannes Berga60e77e2009-06-04 18:26:06 +0200592 return iwl_is_rfkill_hw(priv);
Tomas Winklerfee12472008-04-03 16:05:21 -0700593}
594
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700595static inline int iwl_is_ctkill(struct iwl_priv *priv)
596{
597 return test_bit(STATUS_CT_KILL, &priv->status);
598}
599
Tomas Winklerfee12472008-04-03 16:05:21 -0700600static inline int iwl_is_ready_rf(struct iwl_priv *priv)
601{
602
603 if (iwl_is_rfkill(priv))
604 return 0;
605
606 return iwl_is_ready(priv);
607}
608
Johannes Berg65b52bd2010-04-13 01:04:31 -0700609extern void iwl_send_bt_config(struct iwl_priv *priv);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -0800610extern int iwl_send_statistics_request(struct iwl_priv *priv,
611 u8 flags, bool clear);
Abhijeet Kolekard68b6032009-10-02 13:44:04 -0700612void iwl_apm_stop(struct iwl_priv *priv);
Ben Cahillfadb3582009-10-23 13:42:21 -0700613int iwl_apm_init(struct iwl_priv *priv);
Tomas Winkler7e8c5192008-04-15 16:01:43 -0700614
Johannes Berg47313e32010-08-23 10:46:55 +0200615int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
Wey-Yi Guy805a3b82011-06-03 07:54:16 -0700616
Ron Rindjunsky3c576012008-05-29 16:35:19 +0800617static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
618 struct iwl_priv *priv, enum ieee80211_band band)
619{
620 return priv->hw->wiphy->bands[band];
621}
Johannes Berg670245e2010-08-23 07:56:55 -0700622
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +0100623static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
624{
625 return priv->cfg->bt_params &&
626 priv->cfg->bt_params->advanced_bt_coexist;
627}
628
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700629extern bool bt_siso_mode;
Johannes Berg670245e2010-08-23 07:56:55 -0700630
Johannes Berge6494372011-04-05 09:41:58 -0700631
632void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand);
633
Tomas Winkler82b9a122008-03-04 18:09:30 -0800634#endif /* __iwl_core_h__ */