iwl-core.h 11.3 KB
Newer Older
T
Tomas Winkler 已提交
1 2 3 4 5 6 7
/******************************************************************************
 *
 * This file is provided under a dual BSD/GPLv2 license.  When using or
 * redistributing this file, you may do so under either license.
 *
 * GPL LICENSE SUMMARY
 *
W
Wey-Yi Guy 已提交
8
 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
T
Tomas Winkler 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
 * USA
 *
 * The full GNU General Public License is included in this distribution
 * in the file called LICENSE.GPL.
 *
 * Contact Information:
28
 *  Intel Linux Wireless <ilw@linux.intel.com>
T
Tomas Winkler 已提交
29 30 31 32
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 * BSD LICENSE
 *
W
Wey-Yi Guy 已提交
33
 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
T
Tomas Winkler 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name Intel Corporation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *****************************************************************************/

#ifndef __iwl_core_h__
#define __iwl_core_h__

J
Johannes Berg 已提交
66
#include "iwl-dev.h"
67
#include "iwl-io.h"
J
Johannes Berg 已提交
68

69 70 71 72 73 74
/************************
 * forward declarations *
 ************************/
struct iwl_host_cmd;
struct iwl_cmd;

75 76
#define TIME_UNIT		1024

A
Assaf Krauss 已提交
77
struct iwl_lib_ops {
T
Tomas Winkler 已提交
78
	/* set hw dependent parameters */
79
	void (*set_hw_params)(struct iwl_priv *priv);
80 81
	/* setup BT Rx handler */
	void (*bt_rx_handler_setup)(struct iwl_priv *priv);
82 83
	/* setup BT related deferred work */
	void (*bt_setup_deferred_work)(struct iwl_priv *priv);
84 85
	/* cancel deferred work */
	void (*cancel_deferred_work)(struct iwl_priv *priv);
86 87
	int (*set_channel_switch)(struct iwl_priv *priv,
				  struct ieee80211_channel_switch *ch_switch);
88 89
	/* device specific configuration */
	void (*nic_config)(struct iwl_priv *priv);
90

A
Assaf Krauss 已提交
91 92
	/* eeprom operations (as defined in iwl-eeprom.h) */
	struct iwl_eeprom_ops eeprom_ops;
93 94

	/* temperature */
95
	void (*temperature)(struct iwl_priv *priv);
A
Assaf Krauss 已提交
96 97
};

98
/*
99 100
 * @max_ll_items: max number of OTP blocks
 * @shadow_ram_support: shadow support for OTP memory
101 102 103
 * @led_compensation: compensate on the led on/off time per HW according
 *	to the deviation to achieve the desired led frequency.
 *	The detail algorithm is described in iwl-led.c
104
 * @chain_noise_num_beacons: number of beacons used to compute chain noise
105
 * @adv_thermal_throttle: support advance thermal throttle
106
 * @support_ct_kill_exit: support ct kill exit condition
107
 * @support_wimax_coexist: support wimax/wifi co-exist
108 109
 * @plcp_delta_threshold: plcp error rate threshold used to trigger
 *	radio tuning when there is a high receiving plcp error rate
110
 * @chain_noise_scale: default chain noise scale used for gain computation
111
 * @wd_timeout: TX queues watchdog timeout
112
 * @max_event_log_size: size of event log buffer size for ucode event logging
W
Wey-Yi Guy 已提交
113
 * @shadow_reg_enable: HW shadhow register bit
114
 * @no_idle_support: do not support idle mode
115
 * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
116
 * wd_disable: disable watchdog timer
117
 */
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
struct iwl_base_params {
	int eeprom_size;
	int num_of_queues;	/* def: HW dependent */
	int num_of_ampdu_queues;/* def: HW dependent */
	/* for iwl_apm_init() */
	u32 pll_cfg_val;

	const u16 max_ll_items;
	const bool shadow_ram_support;
	u16 led_compensation;
	bool adv_thermal_throttle;
	bool support_ct_kill_exit;
	const bool support_wimax_coexist;
	u8 plcp_delta_threshold;
	s32 chain_noise_scale;
133
	unsigned int wd_timeout;
134
	u32 max_event_log_size;
W
Wey-Yi Guy 已提交
135
	const bool shadow_reg_enable;
136
	const bool no_idle_support;
137
	const bool hd_v2;
138
	const bool wd_disable;
139 140
};
/*
141
 * @advanced_bt_coexist: support advanced bt coexist
142
 * @bt_init_traffic_load: specify initial bt traffic load
W
Wey-Yi Guy 已提交
143
 * @bt_prio_boost: default bt priority boost value
144
 * @agg_time_limit: maximum number of uSec in aggregation
145
 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
146
 */
147 148 149 150 151
struct iwl_bt_params {
	bool advanced_bt_coexist;
	u8 bt_init_traffic_load;
	u8 bt_prio_boost;
	u16 agg_time_limit;
152
	bool bt_sco_disable;
153
	bool bt_session_2;
154 155 156
};
/*
 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
157
 */
158 159 160
struct iwl_ht_params {
	const bool ht_greenfield_support; /* if used set to true */
	bool use_rts_for_aggregation;
161
	enum ieee80211_smps_mode smps_mode;
162 163
};

164 165 166 167
/***************************
 *   L i b                 *
 ***************************/

168 169 170 171
void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
			   int hw_decrypt);
int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
int iwl_full_rxon_required(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
W
Wey-Yi Guy 已提交
172
void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
173
			 struct iwl_rxon_context *ctx);
174
void iwl_set_flags_for_band(struct iwl_priv *priv,
175
			    struct iwl_rxon_context *ctx,
176 177
			    enum ieee80211_band band,
			    struct ieee80211_vif *vif);
A
Abhijeet Kolekar 已提交
178 179
u8 iwl_get_single_channel_number(struct iwl_priv *priv,
				  enum ieee80211_band band);
J
Johannes Berg 已提交
180
void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
181 182 183
bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
			    struct iwl_rxon_context *ctx,
			    struct ieee80211_sta_ht_cap *ht_cap);
184
void iwl_connection_init_rx_config(struct iwl_priv *priv,
185
				   struct iwl_rxon_context *ctx);
186
void iwl_set_rate(struct iwl_priv *priv);
187
int iwl_cmd_echo_test(struct iwl_priv *priv);
188 189 190 191 192 193 194
#ifdef CONFIG_IWLWIFI_DEBUGFS
int iwl_alloc_traffic_mem(struct iwl_priv *priv);
void iwl_free_traffic_mem(struct iwl_priv *priv);
void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
				u16 length, struct ieee80211_hdr *header);
void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
				u16 length, struct ieee80211_hdr *header);
195 196
const char *get_mgmt_string(int cmd);
const char *get_ctrl_string(int cmd);
197
void iwl_clear_traffic_stats(struct iwl_priv *priv);
198 199
void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc,
		      u16 len);
200 201
void iwl_reset_traffic_log(struct iwl_priv *priv);

202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
#else
static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv)
{
	return 0;
}
static inline void iwl_free_traffic_mem(struct iwl_priv *priv)
{
}
static inline void iwl_reset_traffic_log(struct iwl_priv *priv)
{
}
static inline void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
		      u16 length, struct ieee80211_hdr *header)
{
}
static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
		      u16 length, struct ieee80211_hdr *header)
{
}
221 222 223 224
static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
				    __le16 fc, u16 len)
{
}
225
#endif
A
Abhijeet Kolekar 已提交
226

227 228 229
/*****************************************************
* RX
******************************************************/
230
void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
231

232
void iwl_setup_watchdog(struct iwl_priv *priv);
233 234 235 236 237
/*****************************************************
 * TX power
 ****************************************************/
int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);

238 239 240
/*******************************************************************************
 * Scanning
 ******************************************************************************/
T
Tomas Winkler 已提交
241
void iwl_init_scan_params(struct iwl_priv *priv);
242
int iwl_scan_cancel(struct iwl_priv *priv);
243
void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
244
void iwl_force_scan_end(struct iwl_priv *priv);
J
Johannes Berg 已提交
245
void iwl_internal_short_hw_scan(struct iwl_priv *priv);
246
int iwl_force_reset(struct iwl_priv *priv, int mode, bool external);
J
Johannes Berg 已提交
247
u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
248
		       const u8 *ta, const u8 *ie, int ie_len, int left);
249 250
void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
251
void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
J
Johannes Berg 已提交
252 253 254 255
int __must_check iwl_scan_initiate(struct iwl_priv *priv,
				   struct ieee80211_vif *vif,
				   enum iwl_scan_type scan_type,
				   enum ieee80211_band band);
256

S
Samuel Ortiz 已提交
257 258 259 260 261 262
/* For faster active scanning, scan will move to the next channel if fewer than
 * PLCP_QUIET_THRESH packets are heard on this channel within
 * ACTIVE_QUIET_TIME after sending probe request.  This shortens the dwell
 * time if it's a quiet channel (nothing responded to our probe, and there's
 * no other traffic).
 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
263 264
#define IWL_ACTIVE_QUIET_TIME       cpu_to_le16(10)  /* msec */
#define IWL_PLCP_QUIET_THRESH       cpu_to_le16(1)  /* packets */
S
Samuel Ortiz 已提交
265

266
#define IWL_SCAN_CHECK_WATCHDOG		(HZ * 7)
S
Samuel Ortiz 已提交
267

268 269 270 271
/*****************************************************
 *   S e n d i n g     H o s t     C o m m a n d s   *
 *****************************************************/

272
void iwl_bg_watchdog(unsigned long data);
273 274 275
u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval);
__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
			   u32 addon, u32 beacon_interval);
276

277

278 279 280
/*****************************************************
*  GEOS
******************************************************/
W
Wey-Yi Guy 已提交
281 282
int iwl_init_geos(struct iwl_priv *priv);
void iwl_free_geos(struct iwl_priv *priv);
T
Tomas Winkler 已提交
283

284
extern void iwl_send_bt_config(struct iwl_priv *priv);
285 286
extern int iwl_send_statistics_request(struct iwl_priv *priv,
				       u8 flags, bool clear);
287

288
int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
289

290 291 292 293 294
static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
			struct iwl_priv *priv, enum ieee80211_band band)
{
	return priv->hw->wiphy->bands[band];
}
295

296 297
static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
{
298 299
	return cfg(priv)->bt_params &&
	       cfg(priv)->bt_params->advanced_bt_coexist;
300 301
}

302
extern bool bt_siso_mode;
303

T
Tomas Winkler 已提交
304
#endif /* __iwl_core_h__ */