blob: 7259cbf77da4647ce508a8b2f6f7dbf74072b6ab [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 Guy4e318262011-12-27 11:21:32 -08008 * Copyright(c) 2008 - 2012 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 Guy4e318262011-12-27 11:21:32 -080033 * Copyright(c) 2005 - 2012 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"
Emmanuel Grumbach6a686c62011-10-10 07:27:17 -070067#include "iwl-io.h"
Johannes Berg266af4c72011-03-10 20:13:26 -080068
Tomas Winkler857485c2008-03-21 13:53:44 -070069/************************
70 * forward declarations *
71 ************************/
72struct iwl_host_cmd;
73struct iwl_cmd;
74
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -070075#define TIME_UNIT 1024
76
Assaf Krauss6bc913b2008-03-11 16:17:18 -070077struct iwl_lib_ops {
Tomas Winklera96a27f2008-10-23 23:48:56 -070078 /* set hw dependent parameters */
Emmanuel Grumbach6d4dec72012-02-17 10:52:03 -080079 void (*set_hw_params)(struct iwl_priv *priv);
Emmanuel Grumbach8d301192011-07-03 15:45:34 +030080 /* setup BT Rx handler */
81 void (*bt_rx_handler_setup)(struct iwl_priv *priv);
Emmanuel Grumbach6bd4dba2011-07-03 15:45:34 +030082 /* setup BT related deferred work */
83 void (*bt_setup_deferred_work)(struct iwl_priv *priv);
Emmanuel Grumbach4e393172008-06-12 09:46:53 +080084 /* cancel deferred work */
85 void (*cancel_deferred_work)(struct iwl_priv *priv);
Wey-Yi Guy79d07322010-05-06 08:54:11 -070086 int (*set_channel_switch)(struct iwl_priv *priv,
87 struct ieee80211_channel_switch *ch_switch);
Fry, Donald He4c598b2011-07-08 08:46:18 -070088 /* device specific configuration */
89 void (*nic_config)(struct iwl_priv *priv);
Wey-Yi Guy62161ae2009-05-21 13:44:23 -070090
Assaf Krauss6bc913b2008-03-11 16:17:18 -070091 /* eeprom operations (as defined in iwl-eeprom.h) */
92 struct iwl_eeprom_ops eeprom_ops;
Wey-Yi Guy62161ae2009-05-21 13:44:23 -070093
94 /* temperature */
Wey-Yi Guy909fc3c2011-07-08 08:46:20 -070095 void (*temperature)(struct iwl_priv *priv);
Assaf Krauss6bc913b2008-03-11 16:17:18 -070096};
97
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -070098/*
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -070099 * @advanced_bt_coexist: support advanced bt coexist
100 * @bt_init_traffic_load: specify initial bt traffic load
101 * @bt_prio_boost: default bt priority boost value
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700102 * @agg_time_limit: maximum number of uSec in aggregation
Wey-Yi Guye3661762010-11-23 10:58:54 -0800103 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700104 */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700105struct iwl_bt_params {
Johannes Berg670245e2010-08-23 07:56:55 -0700106 bool advanced_bt_coexist;
Wey-Yi Guya4b96cc2010-08-23 07:57:08 -0700107 u8 bt_init_traffic_load;
Wey-Yi Guy5d297d52010-08-23 07:57:09 -0700108 u8 bt_prio_boost;
Wey-Yi Guy74697012010-07-28 09:18:54 -0700109 u16 agg_time_limit;
Wey-Yi Guye3661762010-11-23 10:58:54 -0800110 bool bt_sco_disable;
Wey-Yi Guy60132702011-02-18 17:23:54 -0800111 bool bt_session_2;
Tomas Winkler82b9a122008-03-04 18:09:30 -0800112};
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700113/*
114 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700115 */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700116struct iwl_ht_params {
117 const bool ht_greenfield_support; /* if used set to true */
118 bool use_rts_for_aggregation;
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700119 enum ieee80211_smps_mode smps_mode;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700120};
121
Assaf Krauss1d0a0822008-03-14 10:38:48 -0700122/***************************
123 * L i b *
124 ***************************/
125
Johannes Berg246ed352010-08-23 10:46:32 +0200126void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
127 int hw_decrypt);
128int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
129int iwl_full_rxon_required(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
Wey-Yi Guydd63b842012-02-08 15:57:39 -0800130void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
Johannes Berg246ed352010-08-23 10:46:32 +0200131 struct iwl_rxon_context *ctx);
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700132void iwl_set_flags_for_band(struct iwl_priv *priv,
Johannes Berg246ed352010-08-23 10:46:32 +0200133 struct iwl_rxon_context *ctx,
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700134 enum ieee80211_band band,
135 struct ieee80211_vif *vif);
Abhijeet Kolekar14023642010-06-02 21:15:10 -0700136u8 iwl_get_single_channel_number(struct iwl_priv *priv,
137 enum ieee80211_band band);
Johannes Bergfad95bf2009-09-11 10:38:15 -0700138void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
Johannes Berg7e6a5882010-08-23 10:46:46 +0200139bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
140 struct iwl_rxon_context *ctx,
141 struct ieee80211_sta_ht_cap *ht_cap);
Johannes Berg1dda6d22010-04-29 04:43:06 -0700142void iwl_connection_init_rx_config(struct iwl_priv *priv,
Johannes Bergd0fe4782010-08-23 10:46:58 +0200143 struct iwl_rxon_context *ctx);
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700144void iwl_set_rate(struct iwl_priv *priv);
Wey-Yi Guy317d09f2011-10-10 07:26:49 -0700145int iwl_cmd_echo_test(struct iwl_priv *priv);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700146#ifdef CONFIG_IWLWIFI_DEBUGFS
147int iwl_alloc_traffic_mem(struct iwl_priv *priv);
148void iwl_free_traffic_mem(struct iwl_priv *priv);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700149void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
150 u16 length, struct ieee80211_hdr *header);
151void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
152 u16 length, struct ieee80211_hdr *header);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700153const char *get_mgmt_string(int cmd);
154const char *get_ctrl_string(int cmd);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800155void iwl_clear_traffic_stats(struct iwl_priv *priv);
Reinette Chatre450ccb32009-08-07 15:41:49 -0700156void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc,
157 u16 len);
Emmanuel Grumbach4d660ce2012-02-15 12:48:04 +0200158void iwl_reset_traffic_log(struct iwl_priv *priv);
159
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700160#else
161static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv)
162{
163 return 0;
164}
165static inline void iwl_free_traffic_mem(struct iwl_priv *priv)
166{
167}
168static inline void iwl_reset_traffic_log(struct iwl_priv *priv)
169{
170}
171static inline void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
172 u16 length, struct ieee80211_hdr *header)
173{
174}
175static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
176 u16 length, struct ieee80211_hdr *header)
177{
178}
Reinette Chatre450ccb32009-08-07 15:41:49 -0700179static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
180 __le16 fc, u16 len)
181{
Reinette Chatre450ccb32009-08-07 15:41:49 -0700182}
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700183#endif
Abhijeet Kolekar030f05e2009-02-18 15:54:28 -0800184
185/*****************************************************
Tomas Winklera55360e2008-05-05 10:22:28 +0800186* RX
187******************************************************/
Wey-Yi Guy79d07322010-05-06 08:54:11 -0700188void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
Tomas Winklera55360e2008-05-05 10:22:28 +0800189
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100190void iwl_setup_watchdog(struct iwl_priv *priv);
Ron Rindjunsky1053d352008-05-05 10:22:43 +0800191/*****************************************************
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800192 * TX power
193 ****************************************************/
194int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);
195
Tomas Winkler2a421b92008-06-12 09:47:10 +0800196/*******************************************************************************
197 * Scanning
198 ******************************************************************************/
Tomas Winklerf53696d2008-06-12 09:47:12 +0800199void iwl_init_scan_params(struct iwl_priv *priv);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800200int iwl_scan_cancel(struct iwl_priv *priv);
Johannes Berg98efb4a2011-09-22 15:14:57 -0700201void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
Stanislaw Gruszkae7e16b92010-09-13 14:46:41 +0200202void iwl_force_scan_end(struct iwl_priv *priv);
Johannes Berg88be0262010-04-07 00:21:36 -0700203void iwl_internal_short_hw_scan(struct iwl_priv *priv);
Wey-Yi Guyc04f9f22010-06-21 16:52:55 -0700204int iwl_force_reset(struct iwl_priv *priv, int mode, bool external);
Johannes Berg1ecf9fc2009-04-20 14:36:56 -0700205u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
Johannes Berg3a0b9aa2010-05-12 03:33:12 -0700206 const u8 *ta, const u8 *ie, int ie_len, int left);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800207void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
208void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
Stanislaw Gruszkae7e16b92010-09-13 14:46:41 +0200209void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
Johannes Berg266af4c72011-03-10 20:13:26 -0800210int __must_check iwl_scan_initiate(struct iwl_priv *priv,
211 struct ieee80211_vif *vif,
212 enum iwl_scan_type scan_type,
213 enum ieee80211_band band);
Tomas Winkler2a421b92008-06-12 09:47:10 +0800214
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800215/* For faster active scanning, scan will move to the next channel if fewer than
216 * PLCP_QUIET_THRESH packets are heard on this channel within
217 * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
218 * time if it's a quiet channel (nothing responded to our probe, and there's
219 * no other traffic).
220 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
Harvey Harrisonc1b4aa32009-01-29 13:26:44 -0800221#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
222#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800223
Johannes Bergb6e4c552010-04-06 04:12:42 -0700224#define IWL_SCAN_CHECK_WATCHDOG (HZ * 7)
Samuel Ortiz77fecfb82009-01-23 13:45:12 -0800225
Johannes Berg61f04392012-03-05 11:24:46 -0800226/* traffic log definitions */
227#define IWL_TRAFFIC_ENTRIES (256)
228#define IWL_TRAFFIC_ENTRY_SIZE (64)
229
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800230/*****************************************************
Tomas Winkler857485c2008-03-21 13:53:44 -0700231 * S e n d i n g H o s t C o m m a n d s *
232 *****************************************************/
233
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100234void iwl_bg_watchdog(unsigned long data);
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700235u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval);
236__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
237 u32 addon, u32 beacon_interval);
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800238
Emmanuel Grumbachc1c81402011-07-11 11:18:48 +0300239
Winkler, Tomas0ad91a32008-12-02 12:14:00 -0800240/*****************************************************
Samuel Ortiz534166d2009-01-23 13:45:16 -0800241* GEOS
242******************************************************/
Wey-Yi Guyb39488a2011-08-25 23:10:33 -0700243int iwl_init_geos(struct iwl_priv *priv);
244void iwl_free_geos(struct iwl_priv *priv);
Tomas Winkler76eff182008-10-14 12:32:45 -0700245
Johannes Berg65b52bd2010-04-13 01:04:31 -0700246extern void iwl_send_bt_config(struct iwl_priv *priv);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -0800247extern int iwl_send_statistics_request(struct iwl_priv *priv,
248 u8 flags, bool clear);
Tomas Winkler7e8c5192008-04-15 16:01:43 -0700249
Johannes Berg47313e32010-08-23 10:46:55 +0200250int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
Wey-Yi Guy805a3b82011-06-03 07:54:16 -0700251
Ron Rindjunsky3c576012008-05-29 16:35:19 +0800252static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
253 struct iwl_priv *priv, enum ieee80211_band band)
254{
255 return priv->hw->wiphy->bands[band];
256}
Johannes Berg670245e2010-08-23 07:56:55 -0700257
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +0100258static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
259{
Don Fry38622412011-12-16 07:07:36 -0800260 return cfg(priv)->bt_params &&
261 cfg(priv)->bt_params->advanced_bt_coexist;
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +0100262}
263
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700264extern bool bt_siso_mode;
Johannes Berg670245e2010-08-23 07:56:55 -0700265
Tomas Winkler82b9a122008-03-04 18:09:30 -0800266#endif /* __iwl_core_h__ */