Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [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 | * |
Johannes Berg | 128e63e | 2013-01-21 21:39:26 +0100 | [diff] [blame] | 8 | * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved. |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 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 | * |
Johannes Berg | 128e63e | 2013-01-21 21:39:26 +0100 | [diff] [blame] | 33 | * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved. |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 34 | * All rights reserved. |
| 35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without |
| 37 | * modification, are permitted provided that the following conditions |
| 38 | * are met: |
| 39 | * |
| 40 | * * Redistributions of source code must retain the above copyright |
| 41 | * notice, this list of conditions and the following disclaimer. |
| 42 | * * Redistributions in binary form must reproduce the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer in |
| 44 | * the documentation and/or other materials provided with the |
| 45 | * distribution. |
| 46 | * * Neither the name Intel Corporation nor the names of its |
| 47 | * contributors may be used to endorse or promote products derived |
| 48 | * from this software without specific prior written permission. |
| 49 | * |
| 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 61 | * |
| 62 | *****************************************************************************/ |
| 63 | #include <linux/completion.h> |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 64 | #include <linux/dma-mapping.h> |
| 65 | #include <linux/firmware.h> |
| 66 | #include <linux/module.h> |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 67 | #include <linux/vmalloc.h> |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 68 | |
| 69 | #include "iwl-drv.h" |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 70 | #include "iwl-debug.h" |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 71 | #include "iwl-trans.h" |
Emmanuel Grumbach | d0f76d6 | 2012-02-09 16:08:15 +0200 | [diff] [blame] | 72 | #include "iwl-op-mode.h" |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 73 | #include "iwl-agn-hw.h" |
Johannes Berg | 6238b00 | 2012-04-02 15:04:33 +0200 | [diff] [blame] | 74 | #include "iwl-fw.h" |
| 75 | #include "iwl-config.h" |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 76 | #include "iwl-modparams.h" |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 77 | |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 78 | /* private includes */ |
Johannes Berg | 3995dea | 2012-03-06 13:30:44 -0800 | [diff] [blame] | 79 | #include "iwl-fw-file.h" |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 80 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 81 | /****************************************************************************** |
| 82 | * |
| 83 | * module boiler plate |
| 84 | * |
| 85 | ******************************************************************************/ |
| 86 | |
| 87 | /* |
| 88 | * module name, copyright, version, etc. |
| 89 | */ |
| 90 | #define DRV_DESCRIPTION "Intel(R) Wireless WiFi driver for Linux" |
| 91 | |
| 92 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 93 | #define VD "d" |
| 94 | #else |
| 95 | #define VD |
| 96 | #endif |
| 97 | |
| 98 | #define DRV_VERSION IWLWIFI_VERSION VD |
| 99 | |
| 100 | MODULE_DESCRIPTION(DRV_DESCRIPTION); |
| 101 | MODULE_VERSION(DRV_VERSION); |
| 102 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
| 103 | MODULE_LICENSE("GPL"); |
| 104 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 105 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 106 | static struct dentry *iwl_dbgfs_root; |
| 107 | #endif |
| 108 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 109 | /** |
| 110 | * struct iwl_drv - drv common data |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 111 | * @list: list of drv structures using this opmode |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 112 | * @fw: the iwl_fw structure |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 113 | * @op_mode: the running op_mode |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 114 | * @trans: transport layer |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 115 | * @dev: for debug prints only |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 116 | * @cfg: configuration struct |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 117 | * @fw_index: firmware revision to try loading |
| 118 | * @firmware_name: composite filename of ucode file to load |
| 119 | * @request_firmware_complete: the firmware has been obtained from user space |
| 120 | */ |
| 121 | struct iwl_drv { |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 122 | struct list_head list; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 123 | struct iwl_fw fw; |
| 124 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 125 | struct iwl_op_mode *op_mode; |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 126 | struct iwl_trans *trans; |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 127 | struct device *dev; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 128 | const struct iwl_cfg *cfg; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 129 | |
| 130 | int fw_index; /* firmware we're trying to load */ |
| 131 | char firmware_name[25]; /* name of firmware file to load */ |
| 132 | |
| 133 | struct completion request_firmware_complete; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 134 | |
| 135 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 136 | struct dentry *dbgfs_drv; |
| 137 | struct dentry *dbgfs_trans; |
| 138 | struct dentry *dbgfs_op_mode; |
| 139 | #endif |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 140 | }; |
| 141 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 142 | #define DVM_OP_MODE 0 |
| 143 | #define MVM_OP_MODE 1 |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 144 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 145 | /* Protects the table contents, i.e. the ops pointer & drv list */ |
| 146 | static struct mutex iwlwifi_opmode_table_mtx; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 147 | static struct iwlwifi_opmode_table { |
| 148 | const char *name; /* name: iwldvm, iwlmvm, etc */ |
| 149 | const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */ |
| 150 | struct list_head drv; /* list of devices using this op_mode */ |
| 151 | } iwlwifi_opmode_table[] = { /* ops set when driver is initialized */ |
| 152 | { .name = "iwldvm", .ops = NULL }, |
| 153 | { .name = "iwlmvm", .ops = NULL }, |
| 154 | }; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 155 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 156 | /* |
| 157 | * struct fw_sec: Just for the image parsing proccess. |
| 158 | * For the fw storage we are using struct fw_desc. |
| 159 | */ |
| 160 | struct fw_sec { |
| 161 | const void *data; /* the sec data */ |
| 162 | size_t size; /* section size */ |
| 163 | u32 offset; /* offset of writing in the device */ |
| 164 | }; |
| 165 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 166 | static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 167 | { |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 168 | vfree(desc->data); |
| 169 | desc->data = NULL; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 170 | desc->len = 0; |
| 171 | } |
| 172 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 173 | static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 174 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 175 | int i; |
| 176 | for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) |
| 177 | iwl_free_fw_desc(drv, &img->sec[i]); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 178 | } |
| 179 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 180 | static void iwl_dealloc_ucode(struct iwl_drv *drv) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 181 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 182 | int i; |
| 183 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
| 184 | iwl_free_fw_img(drv, drv->fw.img + i); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 187 | static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 188 | struct fw_sec *sec) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 189 | { |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 190 | void *data; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 191 | |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 192 | desc->data = NULL; |
| 193 | |
| 194 | if (!sec || !sec->size) |
| 195 | return -EINVAL; |
| 196 | |
| 197 | data = vmalloc(sec->size); |
| 198 | if (!data) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 199 | return -ENOMEM; |
| 200 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 201 | desc->len = sec->size; |
| 202 | desc->offset = sec->offset; |
Johannes Berg | 83f84d7 | 2012-09-10 11:50:18 +0200 | [diff] [blame] | 203 | memcpy(data, sec->data, desc->len); |
| 204 | desc->data = data; |
| 205 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 206 | return 0; |
| 207 | } |
| 208 | |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 209 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, |
| 210 | void *context); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 211 | |
| 212 | #define UCODE_EXPERIMENTAL_INDEX 100 |
| 213 | #define UCODE_EXPERIMENTAL_TAG "exp" |
| 214 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 215 | static int iwl_request_firmware(struct iwl_drv *drv, bool first) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 216 | { |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 217 | const char *name_pre = drv->cfg->fw_name_pre; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 218 | char tag[8]; |
| 219 | |
| 220 | if (first) { |
| 221 | #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 222 | drv->fw_index = UCODE_EXPERIMENTAL_INDEX; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 223 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 224 | } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 225 | #endif |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 226 | drv->fw_index = drv->cfg->ucode_api_max; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 227 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 228 | } else { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 229 | drv->fw_index--; |
| 230 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 233 | if (drv->fw_index < drv->cfg->ucode_api_min) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 234 | IWL_ERR(drv, "no suitable firmware found!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 235 | return -ENOENT; |
| 236 | } |
| 237 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 238 | sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 239 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 240 | IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", |
| 241 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 242 | ? "EXPERIMENTAL " : "", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 243 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 244 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 245 | return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 246 | drv->trans->dev, |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 247 | GFP_KERNEL, drv, iwl_req_fw_callback); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 248 | } |
| 249 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 250 | struct fw_img_parsing { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 251 | struct fw_sec sec[IWL_UCODE_SECTION_MAX]; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 252 | int sec_counter; |
| 253 | }; |
| 254 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 255 | /* |
| 256 | * struct fw_sec_parsing: to extract fw section and it's offset from tlv |
| 257 | */ |
| 258 | struct fw_sec_parsing { |
| 259 | __le32 offset; |
| 260 | const u8 data[]; |
| 261 | } __packed; |
| 262 | |
| 263 | /** |
| 264 | * struct iwl_tlv_calib_data - parse the default calib data from TLV |
| 265 | * |
| 266 | * @ucode_type: the uCode to which the following default calib relates. |
| 267 | * @calib: default calibrations. |
| 268 | */ |
| 269 | struct iwl_tlv_calib_data { |
| 270 | __le32 ucode_type; |
Johannes Berg | aa2b177 | 2013-01-24 14:12:07 +0100 | [diff] [blame] | 271 | struct iwl_tlv_calib_ctrl calib; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 272 | } __packed; |
| 273 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 274 | struct iwl_firmware_pieces { |
| 275 | struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 276 | |
| 277 | u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; |
| 278 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; |
| 279 | }; |
| 280 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 281 | /* |
| 282 | * These functions are just to extract uCode section data from the pieces |
| 283 | * structure. |
| 284 | */ |
| 285 | static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces, |
| 286 | enum iwl_ucode_type type, |
| 287 | int sec) |
| 288 | { |
| 289 | return &pieces->img[type].sec[sec]; |
| 290 | } |
| 291 | |
| 292 | static void set_sec_data(struct iwl_firmware_pieces *pieces, |
| 293 | enum iwl_ucode_type type, |
| 294 | int sec, |
| 295 | const void *data) |
| 296 | { |
| 297 | pieces->img[type].sec[sec].data = data; |
| 298 | } |
| 299 | |
| 300 | static void set_sec_size(struct iwl_firmware_pieces *pieces, |
| 301 | enum iwl_ucode_type type, |
| 302 | int sec, |
| 303 | size_t size) |
| 304 | { |
| 305 | pieces->img[type].sec[sec].size = size; |
| 306 | } |
| 307 | |
| 308 | static size_t get_sec_size(struct iwl_firmware_pieces *pieces, |
| 309 | enum iwl_ucode_type type, |
| 310 | int sec) |
| 311 | { |
| 312 | return pieces->img[type].sec[sec].size; |
| 313 | } |
| 314 | |
| 315 | static void set_sec_offset(struct iwl_firmware_pieces *pieces, |
| 316 | enum iwl_ucode_type type, |
| 317 | int sec, |
| 318 | u32 offset) |
| 319 | { |
| 320 | pieces->img[type].sec[sec].offset = offset; |
| 321 | } |
| 322 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 323 | /* |
| 324 | * Gets uCode section from tlv. |
| 325 | */ |
| 326 | static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces, |
| 327 | const void *data, enum iwl_ucode_type type, |
| 328 | int size) |
| 329 | { |
| 330 | struct fw_img_parsing *img; |
| 331 | struct fw_sec *sec; |
| 332 | struct fw_sec_parsing *sec_parse; |
| 333 | |
| 334 | if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX)) |
| 335 | return -1; |
| 336 | |
| 337 | sec_parse = (struct fw_sec_parsing *)data; |
| 338 | |
| 339 | img = &pieces->img[type]; |
| 340 | sec = &img->sec[img->sec_counter]; |
| 341 | |
| 342 | sec->offset = le32_to_cpu(sec_parse->offset); |
| 343 | sec->data = sec_parse->data; |
David Spinadel | 1176f43 | 2012-03-13 14:32:48 +0200 | [diff] [blame] | 344 | sec->size = size - sizeof(sec_parse->offset); |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 345 | |
| 346 | ++img->sec_counter; |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data) |
| 352 | { |
| 353 | struct iwl_tlv_calib_data *def_calib = |
| 354 | (struct iwl_tlv_calib_data *)data; |
| 355 | u32 ucode_type = le32_to_cpu(def_calib->ucode_type); |
| 356 | if (ucode_type >= IWL_UCODE_TYPE_MAX) { |
| 357 | IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n", |
| 358 | ucode_type); |
| 359 | return -EINVAL; |
| 360 | } |
Johannes Berg | aa2b177 | 2013-01-24 14:12:07 +0100 | [diff] [blame] | 361 | drv->fw.default_calib[ucode_type].flow_trigger = |
| 362 | def_calib->calib.flow_trigger; |
| 363 | drv->fw.default_calib[ucode_type].event_trigger = |
| 364 | def_calib->calib.event_trigger; |
| 365 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 366 | return 0; |
| 367 | } |
| 368 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 369 | static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 370 | const struct firmware *ucode_raw, |
| 371 | struct iwl_firmware_pieces *pieces) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 372 | { |
| 373 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; |
| 374 | u32 api_ver, hdr_size, build; |
| 375 | char buildstr[25]; |
| 376 | const u8 *src; |
| 377 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 378 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
| 379 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 380 | |
| 381 | switch (api_ver) { |
| 382 | default: |
| 383 | hdr_size = 28; |
| 384 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 385 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 386 | return -EINVAL; |
| 387 | } |
| 388 | build = le32_to_cpu(ucode->u.v2.build); |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 389 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 390 | le32_to_cpu(ucode->u.v2.inst_size)); |
| 391 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 392 | le32_to_cpu(ucode->u.v2.data_size)); |
| 393 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 394 | le32_to_cpu(ucode->u.v2.init_size)); |
| 395 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 396 | le32_to_cpu(ucode->u.v2.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 397 | src = ucode->u.v2.data; |
| 398 | break; |
| 399 | case 0: |
| 400 | case 1: |
| 401 | case 2: |
| 402 | hdr_size = 24; |
| 403 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 404 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 405 | return -EINVAL; |
| 406 | } |
| 407 | build = 0; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 408 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 409 | le32_to_cpu(ucode->u.v1.inst_size)); |
| 410 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 411 | le32_to_cpu(ucode->u.v1.data_size)); |
| 412 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 413 | le32_to_cpu(ucode->u.v1.init_size)); |
| 414 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 415 | le32_to_cpu(ucode->u.v1.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 416 | src = ucode->u.v1.data; |
| 417 | break; |
| 418 | } |
| 419 | |
| 420 | if (build) |
| 421 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 422 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 423 | ? " (EXP)" : ""); |
| 424 | else |
| 425 | buildstr[0] = '\0'; |
| 426 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 427 | snprintf(drv->fw.fw_version, |
| 428 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 429 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 430 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 431 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 432 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 433 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 434 | buildstr); |
| 435 | |
| 436 | /* Verify size of file vs. image size info in file's header */ |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 437 | |
| 438 | if (ucode_raw->size != hdr_size + |
| 439 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) + |
| 440 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) + |
| 441 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) + |
| 442 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 443 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 444 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 445 | "uCode file size %d does not match expected size\n", |
| 446 | (int)ucode_raw->size); |
| 447 | return -EINVAL; |
| 448 | } |
| 449 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 450 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 451 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src); |
| 452 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST); |
| 453 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 454 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 455 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src); |
| 456 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA); |
| 457 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 458 | IWLAGN_RTC_DATA_LOWER_BOUND); |
| 459 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src); |
| 460 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST); |
| 461 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 462 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 463 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src); |
| 464 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA); |
| 465 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 466 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 467 | return 0; |
| 468 | } |
| 469 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 470 | static int iwl_parse_tlv_firmware(struct iwl_drv *drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 471 | const struct firmware *ucode_raw, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 472 | struct iwl_firmware_pieces *pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 473 | struct iwl_ucode_capabilities *capa) |
| 474 | { |
| 475 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; |
| 476 | struct iwl_ucode_tlv *tlv; |
| 477 | size_t len = ucode_raw->size; |
| 478 | const u8 *data; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 479 | u32 tlv_len; |
| 480 | enum iwl_ucode_tlv_type tlv_type; |
| 481 | const u8 *tlv_data; |
| 482 | char buildstr[25]; |
| 483 | u32 build; |
| 484 | |
| 485 | if (len < sizeof(*ucode)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 486 | IWL_ERR(drv, "uCode has invalid length: %zd\n", len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 487 | return -EINVAL; |
| 488 | } |
| 489 | |
| 490 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 491 | IWL_ERR(drv, "invalid uCode magic: 0X%x\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 492 | le32_to_cpu(ucode->magic)); |
| 493 | return -EINVAL; |
| 494 | } |
| 495 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 496 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 497 | build = le32_to_cpu(ucode->build); |
| 498 | |
| 499 | if (build) |
| 500 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 501 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 502 | ? " (EXP)" : ""); |
| 503 | else |
| 504 | buildstr[0] = '\0'; |
| 505 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 506 | snprintf(drv->fw.fw_version, |
| 507 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 508 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 509 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 510 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 511 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 512 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 513 | buildstr); |
| 514 | |
| 515 | data = ucode->data; |
| 516 | |
| 517 | len -= sizeof(*ucode); |
| 518 | |
| 519 | while (len >= sizeof(*tlv)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 520 | len -= sizeof(*tlv); |
| 521 | tlv = (void *)data; |
| 522 | |
| 523 | tlv_len = le32_to_cpu(tlv->length); |
Johannes Berg | 0479c19 | 2012-03-09 09:16:35 +0100 | [diff] [blame] | 524 | tlv_type = le32_to_cpu(tlv->type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 525 | tlv_data = tlv->data; |
| 526 | |
| 527 | if (len < tlv_len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 528 | IWL_ERR(drv, "invalid TLV len: %zd/%u\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 529 | len, tlv_len); |
| 530 | return -EINVAL; |
| 531 | } |
| 532 | len -= ALIGN(tlv_len, 4); |
| 533 | data += sizeof(*tlv) + ALIGN(tlv_len, 4); |
| 534 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 535 | switch (tlv_type) { |
| 536 | case IWL_UCODE_TLV_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 537 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 538 | IWL_UCODE_SECTION_INST, tlv_data); |
| 539 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 540 | IWL_UCODE_SECTION_INST, tlv_len); |
| 541 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 542 | IWL_UCODE_SECTION_INST, |
| 543 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 544 | break; |
| 545 | case IWL_UCODE_TLV_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 546 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 547 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 548 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 549 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 550 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 551 | IWL_UCODE_SECTION_DATA, |
| 552 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 553 | break; |
| 554 | case IWL_UCODE_TLV_INIT: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 555 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 556 | IWL_UCODE_SECTION_INST, tlv_data); |
| 557 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 558 | IWL_UCODE_SECTION_INST, tlv_len); |
| 559 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 560 | IWL_UCODE_SECTION_INST, |
| 561 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 562 | break; |
| 563 | case IWL_UCODE_TLV_INIT_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 564 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 565 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 566 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 567 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 568 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 569 | IWL_UCODE_SECTION_DATA, |
| 570 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 571 | break; |
| 572 | case IWL_UCODE_TLV_BOOT: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 573 | IWL_ERR(drv, "Found unexpected BOOT ucode\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 574 | break; |
| 575 | case IWL_UCODE_TLV_PROBE_MAX_LEN: |
| 576 | if (tlv_len != sizeof(u32)) |
| 577 | goto invalid_tlv_len; |
| 578 | capa->max_probe_length = |
| 579 | le32_to_cpup((__le32 *)tlv_data); |
| 580 | break; |
| 581 | case IWL_UCODE_TLV_PAN: |
| 582 | if (tlv_len) |
| 583 | goto invalid_tlv_len; |
| 584 | capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; |
| 585 | break; |
| 586 | case IWL_UCODE_TLV_FLAGS: |
| 587 | /* must be at least one u32 */ |
| 588 | if (tlv_len < sizeof(u32)) |
| 589 | goto invalid_tlv_len; |
| 590 | /* and a proper number of u32s */ |
| 591 | if (tlv_len % sizeof(u32)) |
| 592 | goto invalid_tlv_len; |
| 593 | /* |
| 594 | * This driver only reads the first u32 as |
| 595 | * right now no more features are defined, |
| 596 | * if that changes then either the driver |
| 597 | * will not work with the new firmware, or |
| 598 | * it'll not take advantage of new features. |
| 599 | */ |
| 600 | capa->flags = le32_to_cpup((__le32 *)tlv_data); |
| 601 | break; |
| 602 | case IWL_UCODE_TLV_INIT_EVTLOG_PTR: |
| 603 | if (tlv_len != sizeof(u32)) |
| 604 | goto invalid_tlv_len; |
| 605 | pieces->init_evtlog_ptr = |
| 606 | le32_to_cpup((__le32 *)tlv_data); |
| 607 | break; |
| 608 | case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: |
| 609 | if (tlv_len != sizeof(u32)) |
| 610 | goto invalid_tlv_len; |
| 611 | pieces->init_evtlog_size = |
| 612 | le32_to_cpup((__le32 *)tlv_data); |
| 613 | break; |
| 614 | case IWL_UCODE_TLV_INIT_ERRLOG_PTR: |
| 615 | if (tlv_len != sizeof(u32)) |
| 616 | goto invalid_tlv_len; |
| 617 | pieces->init_errlog_ptr = |
| 618 | le32_to_cpup((__le32 *)tlv_data); |
| 619 | break; |
| 620 | case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: |
| 621 | if (tlv_len != sizeof(u32)) |
| 622 | goto invalid_tlv_len; |
| 623 | pieces->inst_evtlog_ptr = |
| 624 | le32_to_cpup((__le32 *)tlv_data); |
| 625 | break; |
| 626 | case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: |
| 627 | if (tlv_len != sizeof(u32)) |
| 628 | goto invalid_tlv_len; |
| 629 | pieces->inst_evtlog_size = |
| 630 | le32_to_cpup((__le32 *)tlv_data); |
| 631 | break; |
| 632 | case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: |
| 633 | if (tlv_len != sizeof(u32)) |
| 634 | goto invalid_tlv_len; |
| 635 | pieces->inst_errlog_ptr = |
| 636 | le32_to_cpup((__le32 *)tlv_data); |
| 637 | break; |
| 638 | case IWL_UCODE_TLV_ENHANCE_SENS_TBL: |
| 639 | if (tlv_len) |
| 640 | goto invalid_tlv_len; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 641 | drv->fw.enhance_sensitivity_table = true; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 642 | break; |
| 643 | case IWL_UCODE_TLV_WOWLAN_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 644 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 645 | IWL_UCODE_SECTION_INST, tlv_data); |
| 646 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 647 | IWL_UCODE_SECTION_INST, tlv_len); |
| 648 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 649 | IWL_UCODE_SECTION_INST, |
| 650 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 651 | break; |
| 652 | case IWL_UCODE_TLV_WOWLAN_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 653 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 654 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 655 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 656 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 657 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 658 | IWL_UCODE_SECTION_DATA, |
| 659 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 660 | break; |
| 661 | case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: |
| 662 | if (tlv_len != sizeof(u32)) |
| 663 | goto invalid_tlv_len; |
| 664 | capa->standard_phy_calibration_size = |
| 665 | le32_to_cpup((__le32 *)tlv_data); |
| 666 | break; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 667 | case IWL_UCODE_TLV_SEC_RT: |
| 668 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, |
| 669 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 670 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 671 | break; |
| 672 | case IWL_UCODE_TLV_SEC_INIT: |
| 673 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, |
| 674 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 675 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 676 | break; |
| 677 | case IWL_UCODE_TLV_SEC_WOWLAN: |
| 678 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, |
| 679 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 680 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 681 | break; |
| 682 | case IWL_UCODE_TLV_DEF_CALIB: |
| 683 | if (tlv_len != sizeof(struct iwl_tlv_calib_data)) |
| 684 | goto invalid_tlv_len; |
| 685 | if (iwl_set_default_calib(drv, tlv_data)) |
| 686 | goto tlv_error; |
| 687 | break; |
| 688 | case IWL_UCODE_TLV_PHY_SKU: |
| 689 | if (tlv_len != sizeof(u32)) |
| 690 | goto invalid_tlv_len; |
| 691 | drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data); |
| 692 | break; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 693 | default: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 694 | IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 695 | break; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | if (len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 700 | IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len); |
| 701 | iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 702 | return -EINVAL; |
| 703 | } |
| 704 | |
| 705 | return 0; |
| 706 | |
| 707 | invalid_tlv_len: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 708 | IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 709 | tlv_error: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 710 | iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 711 | |
| 712 | return -EINVAL; |
| 713 | } |
| 714 | |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 715 | static int iwl_alloc_ucode(struct iwl_drv *drv, |
| 716 | struct iwl_firmware_pieces *pieces, |
| 717 | enum iwl_ucode_type type) |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 718 | { |
| 719 | int i; |
| 720 | for (i = 0; |
| 721 | i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i); |
| 722 | i++) |
| 723 | if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]), |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 724 | get_sec(pieces, type, i))) |
| 725 | return -ENOMEM; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | static int validate_sec_sizes(struct iwl_drv *drv, |
| 730 | struct iwl_firmware_pieces *pieces, |
| 731 | const struct iwl_cfg *cfg) |
| 732 | { |
| 733 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", |
| 734 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 735 | IWL_UCODE_SECTION_INST)); |
| 736 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", |
| 737 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 738 | IWL_UCODE_SECTION_DATA)); |
| 739 | IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", |
| 740 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); |
| 741 | IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", |
| 742 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); |
| 743 | |
| 744 | /* Verify that uCode images will fit in card's SRAM. */ |
| 745 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > |
| 746 | cfg->max_inst_size) { |
| 747 | IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", |
| 748 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 749 | IWL_UCODE_SECTION_INST)); |
| 750 | return -1; |
| 751 | } |
| 752 | |
| 753 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > |
| 754 | cfg->max_data_size) { |
| 755 | IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", |
| 756 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 757 | IWL_UCODE_SECTION_DATA)); |
| 758 | return -1; |
| 759 | } |
| 760 | |
| 761 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > |
| 762 | cfg->max_inst_size) { |
| 763 | IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", |
| 764 | get_sec_size(pieces, IWL_UCODE_INIT, |
| 765 | IWL_UCODE_SECTION_INST)); |
| 766 | return -1; |
| 767 | } |
| 768 | |
| 769 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > |
| 770 | cfg->max_data_size) { |
| 771 | IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", |
| 772 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 773 | IWL_UCODE_SECTION_DATA)); |
| 774 | return -1; |
| 775 | } |
| 776 | return 0; |
| 777 | } |
| 778 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 779 | static struct iwl_op_mode * |
| 780 | _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op) |
| 781 | { |
| 782 | const struct iwl_op_mode_ops *ops = op->ops; |
| 783 | struct dentry *dbgfs_dir = NULL; |
| 784 | struct iwl_op_mode *op_mode = NULL; |
| 785 | |
| 786 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 787 | drv->dbgfs_op_mode = debugfs_create_dir(op->name, |
| 788 | drv->dbgfs_drv); |
| 789 | if (!drv->dbgfs_op_mode) { |
| 790 | IWL_ERR(drv, |
| 791 | "failed to create opmode debugfs directory\n"); |
| 792 | return op_mode; |
| 793 | } |
| 794 | dbgfs_dir = drv->dbgfs_op_mode; |
| 795 | #endif |
| 796 | |
| 797 | op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir); |
| 798 | |
| 799 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 800 | if (!op_mode) { |
| 801 | debugfs_remove_recursive(drv->dbgfs_op_mode); |
| 802 | drv->dbgfs_op_mode = NULL; |
| 803 | } |
| 804 | #endif |
| 805 | |
| 806 | return op_mode; |
| 807 | } |
| 808 | |
| 809 | static void _iwl_op_mode_stop(struct iwl_drv *drv) |
| 810 | { |
| 811 | /* op_mode can be NULL if its start failed */ |
| 812 | if (drv->op_mode) { |
| 813 | iwl_op_mode_stop(drv->op_mode); |
| 814 | drv->op_mode = NULL; |
| 815 | |
| 816 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 817 | debugfs_remove_recursive(drv->dbgfs_op_mode); |
| 818 | drv->dbgfs_op_mode = NULL; |
| 819 | #endif |
| 820 | } |
| 821 | } |
| 822 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 823 | /** |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 824 | * iwl_req_fw_callback - callback when firmware was loaded |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 825 | * |
| 826 | * If loaded successfully, copies the firmware into buffers |
| 827 | * for the card to fetch (via DMA). |
| 828 | */ |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 829 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 830 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 831 | struct iwl_drv *drv = context; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 832 | struct iwl_fw *fw = &drv->fw; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 833 | struct iwl_ucode_header *ucode; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 834 | struct iwlwifi_opmode_table *op; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 835 | int err; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 836 | struct iwl_firmware_pieces pieces; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 837 | const unsigned int api_max = drv->cfg->ucode_api_max; |
| 838 | unsigned int api_ok = drv->cfg->ucode_api_ok; |
| 839 | const unsigned int api_min = drv->cfg->ucode_api_min; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 840 | u32 api_ver; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 841 | int i; |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 842 | bool load_module = false; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 843 | |
| 844 | fw->ucode_capa.max_probe_length = 200; |
| 845 | fw->ucode_capa.standard_phy_calibration_size = |
| 846 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 847 | |
| 848 | if (!api_ok) |
| 849 | api_ok = api_max; |
| 850 | |
| 851 | memset(&pieces, 0, sizeof(pieces)); |
| 852 | |
| 853 | if (!ucode_raw) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 854 | if (drv->fw_index <= api_ok) |
| 855 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 856 | "request for firmware file '%s' failed.\n", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 857 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 858 | goto try_again; |
| 859 | } |
| 860 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 861 | IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n", |
| 862 | drv->firmware_name, ucode_raw->size); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 863 | |
| 864 | /* Make sure that we got at least the API version number */ |
| 865 | if (ucode_raw->size < 4) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 866 | IWL_ERR(drv, "File size way too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 867 | goto try_again; |
| 868 | } |
| 869 | |
| 870 | /* Data from ucode file: header followed by uCode images */ |
| 871 | ucode = (struct iwl_ucode_header *)ucode_raw->data; |
| 872 | |
| 873 | if (ucode->ver) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 874 | err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 875 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 876 | err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 877 | &fw->ucode_capa); |
| 878 | |
| 879 | if (err) |
| 880 | goto try_again; |
| 881 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 882 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 883 | |
| 884 | /* |
| 885 | * api_ver should match the api version forming part of the |
| 886 | * firmware filename ... but we don't check for that and only rely |
| 887 | * on the API version read from firmware header from here on forward |
| 888 | */ |
| 889 | /* no api version check required for experimental uCode */ |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 890 | if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 891 | if (api_ver < api_min || api_ver > api_max) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 892 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 893 | "Driver unable to support your firmware API. " |
| 894 | "Driver supports v%u, firmware is v%u.\n", |
| 895 | api_max, api_ver); |
| 896 | goto try_again; |
| 897 | } |
| 898 | |
| 899 | if (api_ver < api_ok) { |
| 900 | if (api_ok != api_max) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 901 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 902 | "expected v%u through v%u, got v%u.\n", |
| 903 | api_ok, api_max, api_ver); |
| 904 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 905 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 906 | "expected v%u, got v%u.\n", |
| 907 | api_max, api_ver); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 908 | IWL_ERR(drv, "New firmware can be obtained from " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 909 | "http://www.intellinuxwireless.org/.\n"); |
| 910 | } |
| 911 | } |
| 912 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 913 | IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 914 | |
| 915 | /* |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 916 | * In mvm uCode there is no difference between data and instructions |
| 917 | * sections. |
| 918 | */ |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 919 | if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 920 | goto try_again; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 921 | |
| 922 | /* Allocate ucode buffers for card's bus-master loading ... */ |
| 923 | |
| 924 | /* Runtime instructions and 2 copies of data: |
| 925 | * 1) unmodified from disk |
| 926 | * 2) backup cache for save/restore during power-downs */ |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 927 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 928 | if (iwl_alloc_ucode(drv, &pieces, i)) |
| 929 | goto out_free_fw; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 930 | |
| 931 | /* Now that we can no longer fail, copy information */ |
| 932 | |
| 933 | /* |
| 934 | * The (size - 16) / 12 formula is based on the information recorded |
| 935 | * for each event, which is of mode 1 (including timestamp) for all |
| 936 | * new microcodes that include this information. |
| 937 | */ |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 938 | fw->init_evtlog_ptr = pieces.init_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 939 | if (pieces.init_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 940 | fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 941 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 942 | fw->init_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 943 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 944 | fw->init_errlog_ptr = pieces.init_errlog_ptr; |
| 945 | fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 946 | if (pieces.inst_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 947 | fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 948 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 949 | fw->inst_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 950 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 951 | fw->inst_errlog_ptr = pieces.inst_errlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 952 | |
| 953 | /* |
| 954 | * figure out the offset of chain noise reset and gain commands |
| 955 | * base on the size of standard phy calibration commands table size |
| 956 | */ |
| 957 | if (fw->ucode_capa.standard_phy_calibration_size > |
| 958 | IWL_MAX_PHY_CALIBRATE_TBL_SIZE) |
| 959 | fw->ucode_capa.standard_phy_calibration_size = |
| 960 | IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 961 | |
| 962 | /* We have our copies now, allow OS release its copies */ |
| 963 | release_firmware(ucode_raw); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 964 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 965 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 966 | op = &iwlwifi_opmode_table[DVM_OP_MODE]; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 967 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 968 | /* add this device to the list of devices using this op_mode */ |
| 969 | list_add_tail(&drv->list, &op->drv); |
| 970 | |
| 971 | if (op->ops) { |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 972 | drv->op_mode = _iwl_op_mode_start(drv, op); |
John W. Linville | 7c9c46c | 2012-06-06 14:40:06 -0400 | [diff] [blame] | 973 | |
Dan Carpenter | daf67ce | 2012-06-14 21:35:26 +0300 | [diff] [blame] | 974 | if (!drv->op_mode) { |
| 975 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
John W. Linville | 7c9c46c | 2012-06-06 14:40:06 -0400 | [diff] [blame] | 976 | goto out_unbind; |
Dan Carpenter | daf67ce | 2012-06-14 21:35:26 +0300 | [diff] [blame] | 977 | } |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 978 | } else { |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 979 | load_module = true; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 980 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 981 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 982 | |
Johannes Berg | f69a23b | 2012-06-05 19:56:06 +0200 | [diff] [blame] | 983 | /* |
| 984 | * Complete the firmware request last so that |
| 985 | * a driver unbind (stop) doesn't run while we |
| 986 | * are doing the start() above. |
| 987 | */ |
| 988 | complete(&drv->request_firmware_complete); |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 989 | |
| 990 | /* |
| 991 | * Load the module last so we don't block anything |
| 992 | * else from proceeding if the module fails to load |
| 993 | * or hangs loading. |
| 994 | */ |
| 995 | if (load_module) |
| 996 | request_module("%s", op->name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 997 | return; |
| 998 | |
| 999 | try_again: |
| 1000 | /* try next, if any */ |
| 1001 | release_firmware(ucode_raw); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1002 | if (iwl_request_firmware(drv, false)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 1003 | goto out_unbind; |
| 1004 | return; |
| 1005 | |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 1006 | out_free_fw: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1007 | IWL_ERR(drv, "failed to allocate pci memory\n"); |
| 1008 | iwl_dealloc_ucode(drv); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 1009 | release_firmware(ucode_raw); |
| 1010 | out_unbind: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1011 | complete(&drv->request_firmware_complete); |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 1012 | device_release_driver(drv->trans->dev); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 1013 | } |
| 1014 | |
Emmanuel Grumbach | 87ce05a | 2012-03-26 09:03:18 -0700 | [diff] [blame] | 1015 | struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1016 | const struct iwl_cfg *cfg) |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1017 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1018 | struct iwl_drv *drv; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1019 | int ret; |
| 1020 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1021 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1022 | if (!drv) |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1023 | return NULL; |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1024 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1025 | drv->trans = trans; |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 1026 | drv->dev = trans->dev; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 1027 | drv->cfg = cfg; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1028 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1029 | init_completion(&drv->request_firmware_complete); |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1030 | INIT_LIST_HEAD(&drv->list); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1031 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1032 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1033 | /* Create the device debugfs entries. */ |
| 1034 | drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev), |
| 1035 | iwl_dbgfs_root); |
| 1036 | |
| 1037 | if (!drv->dbgfs_drv) { |
| 1038 | IWL_ERR(drv, "failed to create debugfs directory\n"); |
Emmanuel Grumbach | 59f547a | 2012-11-28 16:42:09 +0200 | [diff] [blame] | 1039 | ret = -ENOMEM; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1040 | goto err_free_drv; |
| 1041 | } |
| 1042 | |
| 1043 | /* Create transport layer debugfs dir */ |
| 1044 | drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv); |
| 1045 | |
| 1046 | if (!drv->trans->dbgfs_dir) { |
| 1047 | IWL_ERR(drv, "failed to create transport debugfs directory\n"); |
Emmanuel Grumbach | 59f547a | 2012-11-28 16:42:09 +0200 | [diff] [blame] | 1048 | ret = -ENOMEM; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1049 | goto err_free_dbgfs; |
| 1050 | } |
| 1051 | #endif |
| 1052 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1053 | ret = iwl_request_firmware(drv, true); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1054 | if (ret) { |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1055 | IWL_ERR(trans, "Couldn't request the fw\n"); |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1056 | goto err_fw; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1057 | } |
| 1058 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1059 | return drv; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1060 | |
| 1061 | err_fw: |
| 1062 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1063 | err_free_dbgfs: |
| 1064 | debugfs_remove_recursive(drv->dbgfs_drv); |
| 1065 | err_free_drv: |
| 1066 | #endif |
| 1067 | kfree(drv); |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1068 | |
Emmanuel Grumbach | 59f547a | 2012-11-28 16:42:09 +0200 | [diff] [blame] | 1069 | return ERR_PTR(ret); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1070 | } |
| 1071 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1072 | void iwl_drv_stop(struct iwl_drv *drv) |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1073 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1074 | wait_for_completion(&drv->request_firmware_complete); |
Johannes Berg | 2e7eb11 | 2012-03-05 11:24:51 -0800 | [diff] [blame] | 1075 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1076 | _iwl_op_mode_stop(drv); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1077 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1078 | iwl_dealloc_ucode(drv); |
Johannes Berg | 7db5b98 | 2012-03-05 11:24:48 -0800 | [diff] [blame] | 1079 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1080 | mutex_lock(&iwlwifi_opmode_table_mtx); |
| 1081 | /* |
| 1082 | * List is empty (this item wasn't added) |
| 1083 | * when firmware loading failed -- in that |
| 1084 | * case we can't remove it from any list. |
| 1085 | */ |
| 1086 | if (!list_empty(&drv->list)) |
| 1087 | list_del(&drv->list); |
| 1088 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
| 1089 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1090 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1091 | debugfs_remove_recursive(drv->dbgfs_drv); |
| 1092 | #endif |
| 1093 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1094 | kfree(drv); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1095 | } |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1096 | |
| 1097 | |
| 1098 | /* shared module parameters */ |
| 1099 | struct iwl_mod_params iwlwifi_mod_params = { |
| 1100 | .amsdu_size_8K = 1, |
| 1101 | .restart_fw = 1, |
| 1102 | .plcp_check = true, |
| 1103 | .bt_coex_active = true, |
| 1104 | .power_level = IWL_POWER_INDEX_1, |
| 1105 | .bt_ch_announce = true, |
| 1106 | .auto_agg = true, |
Emmanuel Grumbach | 020c876 | 2012-06-24 15:51:59 +0300 | [diff] [blame] | 1107 | .wd_disable = true, |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1108 | /* the rest are 0 by default */ |
| 1109 | }; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1110 | EXPORT_SYMBOL_GPL(iwlwifi_mod_params); |
| 1111 | |
| 1112 | int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops) |
| 1113 | { |
| 1114 | int i; |
| 1115 | struct iwl_drv *drv; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1116 | struct iwlwifi_opmode_table *op; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1117 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1118 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1119 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1120 | op = &iwlwifi_opmode_table[i]; |
| 1121 | if (strcmp(op->name, name)) |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1122 | continue; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1123 | op->ops = ops; |
| 1124 | /* TODO: need to handle exceptional case */ |
| 1125 | list_for_each_entry(drv, &op->drv, list) |
| 1126 | drv->op_mode = _iwl_op_mode_start(drv, op); |
| 1127 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1128 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1129 | return 0; |
| 1130 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1131 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1132 | return -EIO; |
| 1133 | } |
| 1134 | EXPORT_SYMBOL_GPL(iwl_opmode_register); |
| 1135 | |
| 1136 | void iwl_opmode_deregister(const char *name) |
| 1137 | { |
| 1138 | int i; |
| 1139 | struct iwl_drv *drv; |
| 1140 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1141 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1142 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
| 1143 | if (strcmp(iwlwifi_opmode_table[i].name, name)) |
| 1144 | continue; |
| 1145 | iwlwifi_opmode_table[i].ops = NULL; |
| 1146 | |
| 1147 | /* call the stop routine for all devices */ |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1148 | list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list) |
| 1149 | _iwl_op_mode_stop(drv); |
| 1150 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1151 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1152 | return; |
| 1153 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1154 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1155 | } |
| 1156 | EXPORT_SYMBOL_GPL(iwl_opmode_deregister); |
| 1157 | |
| 1158 | static int __init iwl_drv_init(void) |
| 1159 | { |
| 1160 | int i; |
| 1161 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1162 | mutex_init(&iwlwifi_opmode_table_mtx); |
| 1163 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1164 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) |
| 1165 | INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv); |
| 1166 | |
| 1167 | pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); |
| 1168 | pr_info(DRV_COPYRIGHT "\n"); |
| 1169 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1170 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1171 | /* Create the root of iwlwifi debugfs subsystem. */ |
| 1172 | iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL); |
| 1173 | |
| 1174 | if (!iwl_dbgfs_root) |
| 1175 | return -EFAULT; |
| 1176 | #endif |
| 1177 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1178 | return iwl_pci_register_driver(); |
| 1179 | } |
| 1180 | module_init(iwl_drv_init); |
| 1181 | |
| 1182 | static void __exit iwl_drv_exit(void) |
| 1183 | { |
| 1184 | iwl_pci_unregister_driver(); |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 1185 | |
| 1186 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1187 | debugfs_remove_recursive(iwl_dbgfs_root); |
| 1188 | #endif |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1189 | } |
| 1190 | module_exit(iwl_drv_exit); |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1191 | |
| 1192 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 1193 | module_param_named(debug, iwlwifi_mod_params.debug_level, uint, |
| 1194 | S_IRUGO | S_IWUSR); |
| 1195 | MODULE_PARM_DESC(debug, "debug output mask"); |
| 1196 | #endif |
| 1197 | |
| 1198 | module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO); |
| 1199 | MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); |
| 1200 | module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO); |
| 1201 | MODULE_PARM_DESC(11n_disable, |
| 1202 | "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX"); |
| 1203 | module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K, |
| 1204 | int, S_IRUGO); |
| 1205 | MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); |
| 1206 | module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO); |
| 1207 | MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); |
| 1208 | |
| 1209 | module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling, |
| 1210 | int, S_IRUGO); |
| 1211 | MODULE_PARM_DESC(antenna_coupling, |
| 1212 | "specify antenna coupling in dB (defualt: 0 dB)"); |
| 1213 | |
| 1214 | module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce, |
| 1215 | bool, S_IRUGO); |
| 1216 | MODULE_PARM_DESC(bt_ch_inhibition, |
| 1217 | "Enable BT channel inhibition (default: enable)"); |
| 1218 | |
| 1219 | module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO); |
| 1220 | MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])"); |
| 1221 | |
| 1222 | module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO); |
| 1223 | MODULE_PARM_DESC(wd_disable, |
| 1224 | "Disable stuck queue watchdog timer 0=system default, " |
| 1225 | "1=disable, 2=enable (default: 0)"); |
| 1226 | |
| 1227 | /* |
| 1228 | * set bt_coex_active to true, uCode will do kill/defer |
| 1229 | * every time the priority line is asserted (BT is sending signals on the |
| 1230 | * priority line in the PCIx). |
| 1231 | * set bt_coex_active to false, uCode will ignore the BT activity and |
| 1232 | * perform the normal operation |
| 1233 | * |
| 1234 | * User might experience transmit issue on some platform due to WiFi/BT |
| 1235 | * co-exist problem. The possible behaviors are: |
| 1236 | * Able to scan and finding all the available AP |
| 1237 | * Not able to associate with any AP |
| 1238 | * On those platforms, WiFi communication can be restored by set |
| 1239 | * "bt_coex_active" module parameter to "false" |
| 1240 | * |
| 1241 | * default: bt_coex_active = true (BT_COEX_ENABLE) |
| 1242 | */ |
| 1243 | module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active, |
| 1244 | bool, S_IRUGO); |
| 1245 | MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); |
| 1246 | |
| 1247 | module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO); |
| 1248 | MODULE_PARM_DESC(led_mode, "0=system default, " |
| 1249 | "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)"); |
| 1250 | |
| 1251 | module_param_named(power_save, iwlwifi_mod_params.power_save, |
| 1252 | bool, S_IRUGO); |
| 1253 | MODULE_PARM_DESC(power_save, |
| 1254 | "enable WiFi power management (default: disable)"); |
| 1255 | |
| 1256 | module_param_named(power_level, iwlwifi_mod_params.power_level, |
| 1257 | int, S_IRUGO); |
| 1258 | MODULE_PARM_DESC(power_level, |
| 1259 | "default power save level (range from 1 - 5, default: 1)"); |
| 1260 | |
| 1261 | module_param_named(auto_agg, iwlwifi_mod_params.auto_agg, |
| 1262 | bool, S_IRUGO); |
| 1263 | MODULE_PARM_DESC(auto_agg, |
| 1264 | "enable agg w/o check traffic load (default: enable)"); |
Stanislaw Gruszka | f6b1154 | 2012-04-19 09:51:24 -0700 | [diff] [blame] | 1265 | |
| 1266 | module_param_named(5ghz_disable, iwlwifi_mod_params.disable_5ghz, |
| 1267 | bool, S_IRUGO); |
| 1268 | MODULE_PARM_DESC(5ghz_disable, "disable 5GHz band (default: 0 [enabled])"); |