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