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 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 63 | #ifndef __il_core_h__ |
| 64 | #define __il_core_h__ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 65 | |
| 66 | /************************ |
| 67 | * forward declarations * |
| 68 | ************************/ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 69 | struct il_host_cmd; |
| 70 | struct il_cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 71 | |
| 72 | |
| 73 | #define IWLWIFI_VERSION "in-tree:" |
| 74 | #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" |
| 75 | #define DRV_AUTHOR "<ilw@linux.intel.com>" |
| 76 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 77 | #define IL_PCI_DEVICE(dev, subdev, cfg) \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 78 | .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ |
| 79 | .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ |
| 80 | .driver_data = (kernel_ulong_t)&(cfg) |
| 81 | |
| 82 | #define TIME_UNIT 1024 |
| 83 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 84 | #define IL_SKU_G 0x1 |
| 85 | #define IL_SKU_A 0x2 |
| 86 | #define IL_SKU_N 0x8 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 87 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 88 | #define IL_CMD(x) case x: return #x |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 89 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 90 | struct il_hcmd_ops { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 91 | int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); |
| 92 | int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); |
| 93 | void (*set_rxon_chain)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 94 | struct il_rxon_context *ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 95 | }; |
| 96 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 97 | struct il_hcmd_utils_ops { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 98 | u16 (*get_hcmd_size)(u8 cmd_id, u16 len); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 99 | u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 100 | u8 *data); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 101 | int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); |
| 102 | void (*post_scan)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 103 | }; |
| 104 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 105 | struct il_apm_ops { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 106 | int (*init)(struct il_priv *il); |
| 107 | void (*config)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 110 | struct il_debugfs_ops { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 111 | ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, |
| 112 | size_t count, loff_t *ppos); |
| 113 | ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, |
| 114 | size_t count, loff_t *ppos); |
| 115 | ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, |
| 116 | size_t count, loff_t *ppos); |
| 117 | }; |
| 118 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 119 | struct il_temp_ops { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 120 | void (*temperature)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 121 | }; |
| 122 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 123 | struct il_lib_ops { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 124 | /* set hw dependent parameters */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 125 | int (*set_hw_params)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 126 | /* Handling TX */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 127 | void (*txq_update_byte_cnt_tbl)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 128 | struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 129 | u16 byte_cnt); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 130 | int (*txq_attach_buf_to_tfd)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 131 | struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 132 | dma_addr_t addr, |
| 133 | u16 len, u8 reset, u8 pad); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 134 | void (*txq_free_tfd)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 135 | struct il_tx_queue *txq); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 136 | int (*txq_init)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 137 | struct il_tx_queue *txq); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 138 | /* setup Rx handler */ |
Stanislaw Gruszka | d0c7234 | 2011-08-30 15:39:42 +0200 | [diff] [blame] | 139 | void (*handler_setup)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 140 | /* alive notification after init uCode load */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 141 | void (*init_alive_start)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 142 | /* check validity of rtc data address */ |
| 143 | int (*is_valid_rtc_data_addr)(u32 addr); |
| 144 | /* 1st ucode load */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 145 | int (*load_ucode)(struct il_priv *il); |
Stanislaw Gruszka | 1ba2f12 | 2011-06-08 15:28:27 +0200 | [diff] [blame] | 146 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 147 | void (*dump_nic_error_log)(struct il_priv *il); |
| 148 | int (*dump_fh)(struct il_priv *il, char **buf, bool display); |
| 149 | int (*set_channel_switch)(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 150 | struct ieee80211_channel_switch *ch_switch); |
| 151 | /* power management */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 152 | struct il_apm_ops apm_ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 153 | |
| 154 | /* power */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 155 | int (*send_tx_power) (struct il_priv *il); |
| 156 | void (*update_chain_flags)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 157 | |
| 158 | /* eeprom operations (as defined in iwl-eeprom.h) */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 159 | struct il_eeprom_ops eeprom_ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 160 | |
| 161 | /* temperature */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 162 | struct il_temp_ops temp_ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 163 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 164 | struct il_debugfs_ops debugfs_ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 165 | |
| 166 | }; |
| 167 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 168 | struct il_led_ops { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 169 | int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 170 | }; |
| 171 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 172 | struct il_legacy_ops { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 173 | void (*post_associate)(struct il_priv *il); |
| 174 | void (*config_ap)(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 175 | /* station management */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 176 | int (*update_bcast_stations)(struct il_priv *il); |
| 177 | int (*manage_ibss_station)(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 178 | struct ieee80211_vif *vif, bool add); |
| 179 | }; |
| 180 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 181 | struct il_ops { |
| 182 | const struct il_lib_ops *lib; |
| 183 | const struct il_hcmd_ops *hcmd; |
| 184 | const struct il_hcmd_utils_ops *utils; |
| 185 | const struct il_led_ops *led; |
| 186 | const struct il_nic_ops *nic; |
| 187 | const struct il_legacy_ops *legacy; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 188 | const struct ieee80211_ops *ieee80211_ops; |
| 189 | }; |
| 190 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 191 | struct il_mod_params { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 192 | int sw_crypto; /* def: 0 = using hardware encryption */ |
| 193 | int disable_hw_scan; /* def: 0 = use h/w scan */ |
| 194 | int num_of_queues; /* def: HW dependent */ |
| 195 | int disable_11n; /* def: 0 = 11n capabilities enabled */ |
| 196 | int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ |
| 197 | int antenna; /* def: 0 = both antennas (use diversity) */ |
| 198 | int restart_fw; /* def: 1 = restart firmware */ |
| 199 | }; |
| 200 | |
| 201 | /* |
| 202 | * @led_compensation: compensate on the led on/off time per HW according |
| 203 | * to the deviation to achieve the desired led frequency. |
| 204 | * The detail algorithm is described in iwl-led.c |
| 205 | * @chain_noise_num_beacons: number of beacons used to compute chain noise |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 206 | * @wd_timeout: TX queues watchdog timeout |
| 207 | * @temperature_kelvin: temperature report by uCode in kelvin |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 208 | * @ucode_tracing: support ucode continuous tracing |
| 209 | * @sensitivity_calib_by_driver: driver has the capability to perform |
| 210 | * sensitivity calibration operation |
| 211 | * @chain_noise_calib_by_driver: driver has the capability to perform |
| 212 | * chain noise calibration operation |
| 213 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 214 | struct il_base_params { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 215 | int eeprom_size; |
| 216 | int num_of_queues; /* def: HW dependent */ |
| 217 | int num_of_ampdu_queues;/* def: HW dependent */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 218 | /* for il_apm_init() */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 219 | u32 pll_cfg_val; |
| 220 | bool set_l0s; |
| 221 | bool use_bsm; |
| 222 | |
| 223 | u16 led_compensation; |
| 224 | int chain_noise_num_beacons; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 225 | unsigned int wd_timeout; |
| 226 | bool temperature_kelvin; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 227 | const bool ucode_tracing; |
| 228 | const bool sensitivity_calib_by_driver; |
| 229 | const bool chain_noise_calib_by_driver; |
| 230 | }; |
| 231 | |
| 232 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 233 | * struct il_cfg |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 234 | * @fw_name_pre: Firmware filename prefix. The api version and extension |
| 235 | * (.ucode) will be added to filename before loading from disk. The |
| 236 | * filename is constructed as fw_name_pre<api>.ucode. |
| 237 | * @ucode_api_max: Highest version of uCode API supported by driver. |
| 238 | * @ucode_api_min: Lowest version of uCode API supported by driver. |
| 239 | * @scan_antennas: available antenna for scan operation |
| 240 | * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) |
| 241 | * |
| 242 | * We enable the driver to be backward compatible wrt API version. The |
| 243 | * driver specifies which APIs it supports (with @ucode_api_max being the |
| 244 | * highest and @ucode_api_min the lowest). Firmware will only be loaded if |
| 245 | * it has a supported API version. The firmware's API version will be |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 246 | * stored in @il_priv, enabling the driver to make runtime changes based |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 247 | * on firmware version used. |
| 248 | * |
| 249 | * For example, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 250 | * if (IL_UCODE_API(il->ucode_ver) >= 2) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 251 | * Driver interacts with Firmware API version >= 2. |
| 252 | * } else { |
| 253 | * Driver interacts with Firmware API version 1. |
| 254 | * } |
| 255 | * |
| 256 | * The ideal usage of this infrastructure is to treat a new ucode API |
| 257 | * release as a new hardware revision. That is, through utilizing the |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 258 | * il_hcmd_utils_ops etc. we accommodate different command structures |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 259 | * and flows between hardware versions as well as their API |
| 260 | * versions. |
| 261 | * |
| 262 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 263 | struct il_cfg { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 264 | /* params specific to an individual device within a device family */ |
| 265 | const char *name; |
| 266 | const char *fw_name_pre; |
| 267 | const unsigned int ucode_api_max; |
| 268 | const unsigned int ucode_api_min; |
| 269 | u8 valid_tx_ant; |
| 270 | u8 valid_rx_ant; |
| 271 | unsigned int sku; |
| 272 | u16 eeprom_ver; |
| 273 | u16 eeprom_calib_ver; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 274 | const struct il_ops *ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 275 | /* module based parameters which can be set from modprobe cmd */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 276 | const struct il_mod_params *mod_params; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 277 | /* params not likely to change within a device family */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 278 | struct il_base_params *base_params; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 279 | /* params likely to change within a device family */ |
| 280 | u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 281 | enum il_led_mode led_mode; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | /*************************** |
| 285 | * L i b * |
| 286 | ***************************/ |
| 287 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 288 | struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); |
| 289 | int il_mac_conf_tx(struct ieee80211_hw *hw, |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 290 | struct ieee80211_vif *vif, u16 queue, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 291 | const struct ieee80211_tx_queue_params *params); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 292 | int il_mac_tx_last_beacon(struct ieee80211_hw *hw); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 293 | void il_set_rxon_hwcrypto(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 294 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 295 | int hw_decrypt); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 296 | int il_check_rxon_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 297 | struct il_rxon_context *ctx); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 298 | int il_full_rxon_required(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 299 | struct il_rxon_context *ctx); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 300 | int il_set_rxon_channel(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 301 | struct ieee80211_channel *ch, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 302 | struct il_rxon_context *ctx); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 303 | void il_set_flags_for_band(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 304 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 305 | enum ieee80211_band band, |
| 306 | struct ieee80211_vif *vif); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 307 | u8 il_get_single_channel_number(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 308 | enum ieee80211_band band); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 309 | void il_set_rxon_ht(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 310 | struct il_ht_config *ht_conf); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 311 | bool il_is_ht40_tx_allowed(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 312 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 313 | struct ieee80211_sta_ht_cap *ht_cap); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 314 | void il_connection_init_rx_config(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 315 | struct il_rxon_context *ctx); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 316 | void il_set_rate(struct il_priv *il); |
| 317 | int il_set_decrypted_flag(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 318 | struct ieee80211_hdr *hdr, |
| 319 | u32 decrypt_res, |
| 320 | struct ieee80211_rx_status *stats); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 321 | void il_irq_handle_error(struct il_priv *il); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 322 | int il_mac_add_interface(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 323 | struct ieee80211_vif *vif); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 324 | void il_mac_remove_interface(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 325 | struct ieee80211_vif *vif); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 326 | int il_mac_change_interface(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 327 | struct ieee80211_vif *vif, |
| 328 | enum nl80211_iftype newtype, bool newp2p); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 329 | int il_alloc_txq_mem(struct il_priv *il); |
| 330 | void il_txq_mem(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 331 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 332 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 333 | int il_alloc_traffic_mem(struct il_priv *il); |
| 334 | void il_free_traffic_mem(struct il_priv *il); |
| 335 | void il_reset_traffic_log(struct il_priv *il); |
| 336 | void il_dbg_log_tx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 337 | u16 length, struct ieee80211_hdr *header); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 338 | void il_dbg_log_rx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 339 | u16 length, struct ieee80211_hdr *header); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 340 | const char *il_get_mgmt_string(int cmd); |
| 341 | const char *il_get_ctrl_string(int cmd); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 342 | void il_clear_traffic_stats(struct il_priv *il); |
| 343 | void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 344 | u16 len); |
| 345 | #else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 346 | static inline int il_alloc_traffic_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 347 | { |
| 348 | return 0; |
| 349 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 350 | static inline void il_free_traffic_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 351 | { |
| 352 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 353 | static inline void il_reset_traffic_log(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 354 | { |
| 355 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 356 | static inline void il_dbg_log_tx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 357 | u16 length, struct ieee80211_hdr *header) |
| 358 | { |
| 359 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 360 | static inline void il_dbg_log_rx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 361 | u16 length, struct ieee80211_hdr *header) |
| 362 | { |
| 363 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 364 | static inline void il_update_stats(struct il_priv *il, bool is_tx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 365 | __le16 fc, u16 len) |
| 366 | { |
| 367 | } |
| 368 | #endif |
| 369 | /***************************************************** |
| 370 | * RX handlers. |
| 371 | * **************************************************/ |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 372 | void il_hdl_pm_sleep(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 373 | struct il_rx_buf *rxb); |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 374 | void il_hdl_pm_debug_stats(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 375 | struct il_rx_buf *rxb); |
Stanislaw Gruszka | 6e9848b4 | 2011-08-30 15:45:31 +0200 | [diff] [blame] | 376 | void il_hdl_error(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 377 | struct il_rx_buf *rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 378 | |
| 379 | /***************************************************** |
| 380 | * RX |
| 381 | ******************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 382 | void il_cmd_queue_unmap(struct il_priv *il); |
| 383 | void il_cmd_queue_free(struct il_priv *il); |
| 384 | int il_rx_queue_alloc(struct il_priv *il); |
| 385 | void il_rx_queue_update_write_ptr(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 386 | struct il_rx_queue *q); |
| 387 | int il_rx_queue_space(const struct il_rx_queue *q); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 388 | void il_tx_cmd_complete(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 389 | struct il_rx_buf *rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 390 | /* Handlers */ |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 391 | void il_hdl_spectrum_measurement(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 392 | struct il_rx_buf *rxb); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 393 | void il_recover_from_stats(struct il_priv *il, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 394 | struct il_rx_pkt *pkt); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 395 | void il_chswitch_done(struct il_priv *il, bool is_success); |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 396 | void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 397 | |
| 398 | /* TX helpers */ |
| 399 | |
| 400 | /***************************************************** |
| 401 | * TX |
| 402 | ******************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 403 | void il_txq_update_write_ptr(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 404 | struct il_tx_queue *txq); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 405 | int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 406 | int slots_num, u32 txq_id); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 407 | void il_tx_queue_reset(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 408 | struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 409 | int slots_num, u32 txq_id); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 410 | void il_tx_queue_unmap(struct il_priv *il, int txq_id); |
| 411 | void il_tx_queue_free(struct il_priv *il, int txq_id); |
| 412 | void il_setup_watchdog(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 413 | /***************************************************** |
| 414 | * TX power |
| 415 | ****************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 416 | int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 417 | |
| 418 | /******************************************************************************* |
| 419 | * Rate |
| 420 | ******************************************************************************/ |
| 421 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 422 | u8 il_get_lowest_plcp(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 423 | struct il_rxon_context *ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 424 | |
| 425 | /******************************************************************************* |
| 426 | * Scanning |
| 427 | ******************************************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 428 | void il_init_scan_params(struct il_priv *il); |
| 429 | int il_scan_cancel(struct il_priv *il); |
| 430 | int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); |
| 431 | void il_force_scan_end(struct il_priv *il); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 432 | int il_mac_hw_scan(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 433 | struct ieee80211_vif *vif, |
| 434 | struct cfg80211_scan_request *req); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 435 | void il_internal_short_hw_scan(struct il_priv *il); |
| 436 | int il_force_reset(struct il_priv *il, bool external); |
| 437 | u16 il_fill_probe_req(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 438 | struct ieee80211_mgmt *frame, |
| 439 | const u8 *ta, const u8 *ie, int ie_len, int left); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 440 | void il_setup_rx_scan_handlers(struct il_priv *il); |
| 441 | u16 il_get_active_dwell_time(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 442 | enum ieee80211_band band, |
| 443 | u8 n_probes); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 444 | u16 il_get_passive_dwell_time(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 445 | enum ieee80211_band band, |
| 446 | struct ieee80211_vif *vif); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 447 | void il_setup_scan_deferred_work(struct il_priv *il); |
| 448 | void il_cancel_scan_deferred_work(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 449 | |
| 450 | /* For faster active scanning, scan will move to the next channel if fewer than |
| 451 | * PLCP_QUIET_THRESH packets are heard on this channel within |
| 452 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell |
| 453 | * time if it's a quiet channel (nothing responded to our probe, and there's |
| 454 | * no other traffic). |
| 455 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 456 | #define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ |
| 457 | #define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 458 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 459 | #define IL_SCAN_CHECK_WATCHDOG (HZ * 7) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 460 | |
| 461 | /***************************************************** |
| 462 | * S e n d i n g H o s t C o m m a n d s * |
| 463 | *****************************************************/ |
| 464 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 465 | const char *il_get_cmd_string(u8 cmd); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 466 | int __must_check il_send_cmd_sync(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 467 | struct il_host_cmd *cmd); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 468 | int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); |
| 469 | int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 470 | u16 len, const void *data); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 471 | int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 472 | const void *data, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 473 | void (*callback)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 474 | struct il_device_cmd *cmd, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 475 | struct il_rx_pkt *pkt)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 476 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 477 | int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 478 | |
| 479 | |
| 480 | /***************************************************** |
| 481 | * PCI * |
| 482 | *****************************************************/ |
| 483 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 484 | static inline u16 il_pcie_link_ctl(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 485 | { |
| 486 | int pos; |
| 487 | u16 pci_lnk_ctl; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 488 | pos = pci_pcie_cap(il->pci_dev); |
| 489 | pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 490 | return pci_lnk_ctl; |
| 491 | } |
| 492 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 493 | void il_bg_watchdog(unsigned long data); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 494 | u32 il_usecs_to_beacons(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 495 | u32 usec, u32 beacon_interval); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 496 | __le32 il_add_beacon_time(struct il_priv *il, u32 base, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 497 | u32 addon, u32 beacon_interval); |
| 498 | |
| 499 | #ifdef CONFIG_PM |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 500 | int il_pci_suspend(struct device *device); |
| 501 | int il_pci_resume(struct device *device); |
| 502 | extern const struct dev_pm_ops il_pm_ops; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 503 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 504 | #define IL_LEGACY_PM_OPS (&il_pm_ops) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 505 | |
| 506 | #else /* !CONFIG_PM */ |
| 507 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 508 | #define IL_LEGACY_PM_OPS NULL |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 509 | |
| 510 | #endif /* !CONFIG_PM */ |
| 511 | |
| 512 | /***************************************************** |
| 513 | * Error Handling Debugging |
| 514 | ******************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 515 | void il4965_dump_nic_error_log(struct il_priv *il); |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 516 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 517 | void il_print_rx_config_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 518 | struct il_rxon_context *ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 519 | #else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 520 | static inline void il_print_rx_config_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 521 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 522 | { |
| 523 | } |
| 524 | #endif |
| 525 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 526 | void il_clear_isr_stats(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 527 | |
| 528 | /***************************************************** |
| 529 | * GEOS |
| 530 | ******************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 531 | int il_init_geos(struct il_priv *il); |
| 532 | void il_free_geos(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 533 | |
| 534 | /*************** DRIVER STATUS FUNCTIONS *****/ |
| 535 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 536 | #define S_HCMD_ACTIVE 0 /* host command in progress */ |
| 537 | /* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ |
| 538 | #define S_INT_ENABLED 2 |
| 539 | #define S_RF_KILL_HW 3 |
| 540 | #define S_CT_KILL 4 |
| 541 | #define S_INIT 5 |
| 542 | #define S_ALIVE 6 |
| 543 | #define S_READY 7 |
| 544 | #define S_TEMPERATURE 8 |
| 545 | #define S_GEO_CONFIGURED 9 |
| 546 | #define S_EXIT_PENDING 10 |
Stanislaw Gruszka | db7746f | 2011-11-15 13:11:50 +0100 | [diff] [blame] | 547 | #define S_STATS 12 |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 548 | #define S_SCANNING 13 |
| 549 | #define S_SCAN_ABORTING 14 |
| 550 | #define S_SCAN_HW 15 |
| 551 | #define S_POWER_PMI 16 |
| 552 | #define S_FW_ERROR 17 |
| 553 | #define S_CHANNEL_SWITCH_PENDING 18 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 554 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 555 | static inline int il_is_ready(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 556 | { |
| 557 | /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are |
| 558 | * set but EXIT_PENDING is not */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 559 | return test_bit(S_READY, &il->status) && |
| 560 | test_bit(S_GEO_CONFIGURED, &il->status) && |
| 561 | !test_bit(S_EXIT_PENDING, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 562 | } |
| 563 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 564 | static inline int il_is_alive(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 565 | { |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 566 | return test_bit(S_ALIVE, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 567 | } |
| 568 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 569 | static inline int il_is_init(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 570 | { |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 571 | return test_bit(S_INIT, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 572 | } |
| 573 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 574 | static inline int il_is_rfkill_hw(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 575 | { |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 576 | return test_bit(S_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 577 | } |
| 578 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 579 | static inline int il_is_rfkill(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 580 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 581 | return il_is_rfkill_hw(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 582 | } |
| 583 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 584 | static inline int il_is_ctkill(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 585 | { |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 586 | return test_bit(S_CT_KILL, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 587 | } |
| 588 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 589 | static inline int il_is_ready_rf(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 590 | { |
| 591 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 592 | if (il_is_rfkill(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 593 | return 0; |
| 594 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 595 | return il_is_ready(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 596 | } |
| 597 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 598 | extern void il_send_bt_config(struct il_priv *il); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 599 | extern int il_send_stats_request(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 600 | u8 flags, bool clear); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 601 | void il_apm_stop(struct il_priv *il); |
| 602 | int il_apm_init(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 603 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 604 | int il_send_rxon_timing(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 605 | struct il_rxon_context *ctx); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 606 | static inline int il_send_rxon_assoc(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 607 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 608 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 609 | return il->cfg->ops->hcmd->rxon_assoc(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 610 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 611 | static inline int il_commit_rxon(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 612 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 613 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 614 | return il->cfg->ops->hcmd->commit_rxon(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 615 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 616 | static inline const struct ieee80211_supported_band *il_get_hw_mode( |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 617 | struct il_priv *il, enum ieee80211_band band) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 618 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 619 | return il->hw->wiphy->bands[band]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 620 | } |
| 621 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 622 | /* mac80211 handlers */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 623 | int il_mac_config(struct ieee80211_hw *hw, u32 changed); |
| 624 | void il_mac_reset_tsf(struct ieee80211_hw *hw, |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 625 | struct ieee80211_vif *vif); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 626 | void il_mac_bss_info_changed(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 627 | struct ieee80211_vif *vif, |
| 628 | struct ieee80211_bss_conf *bss_conf, |
| 629 | u32 changes); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 630 | void il_tx_cmd_protection(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 631 | struct ieee80211_tx_info *info, |
| 632 | __le16 fc, __le32 *tx_flags); |
| 633 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 634 | irqreturn_t il_isr(int irq, void *data); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 635 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 636 | #endif /* __il_core_h__ */ |