Commit | Line | Data |
---|---|---|
5c58edc6 EG |
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 | * | |
51368bf7 | 8 | * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. |
5c58edc6 EG |
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 | |
410dc5aa | 25 | * in the file called COPYING. |
5c58edc6 EG |
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 | * | |
51368bf7 | 33 | * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. |
5c58edc6 EG |
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> | |
15854ef9 JB |
64 | #include <linux/dma-mapping.h> |
65 | #include <linux/firmware.h> | |
66 | #include <linux/module.h> | |
83f84d7b | 67 | #include <linux/vmalloc.h> |
5c58edc6 EG |
68 | |
69 | #include "iwl-drv.h" | |
c15797e6 | 70 | #include "iwl-debug.h" |
5c58edc6 | 71 | #include "iwl-trans.h" |
d0f76d68 | 72 | #include "iwl-op-mode.h" |
0cedacc5 | 73 | #include "iwl-agn-hw.h" |
6238b008 JB |
74 | #include "iwl-fw.h" |
75 | #include "iwl-config.h" | |
65de7e84 | 76 | #include "iwl-modparams.h" |
5c58edc6 | 77 | |
0692fe41 | 78 | /* private includes */ |
3995deaf | 79 | #include "iwl-fw-file.h" |
0692fe41 | 80 | |
cc5f7e39 DF |
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 | ||
9da987ac MV |
105 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
106 | static struct dentry *iwl_dbgfs_root; | |
107 | #endif | |
108 | ||
965974a6 JB |
109 | /** |
110 | * struct iwl_drv - drv common data | |
cc5f7e39 | 111 | * @list: list of drv structures using this opmode |
965974a6 | 112 | * @fw: the iwl_fw structure |
965974a6 | 113 | * @op_mode: the running op_mode |
68f360dc | 114 | * @trans: transport layer |
4b9844f5 | 115 | * @dev: for debug prints only |
68f360dc | 116 | * @cfg: configuration struct |
965974a6 JB |
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 { | |
cc5f7e39 | 122 | struct list_head list; |
965974a6 JB |
123 | struct iwl_fw fw; |
124 | ||
965974a6 | 125 | struct iwl_op_mode *op_mode; |
9130bab1 | 126 | struct iwl_trans *trans; |
4b9844f5 | 127 | struct device *dev; |
68f360dc | 128 | const struct iwl_cfg *cfg; |
965974a6 JB |
129 | |
130 | int fw_index; /* firmware we're trying to load */ | |
84b0312e | 131 | char firmware_name[32]; /* name of firmware file to load */ |
965974a6 JB |
132 | |
133 | struct completion request_firmware_complete; | |
9da987ac MV |
134 | |
135 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
136 | struct dentry *dbgfs_drv; | |
137 | struct dentry *dbgfs_trans; | |
138 | struct dentry *dbgfs_op_mode; | |
139 | #endif | |
965974a6 JB |
140 | }; |
141 | ||
8ca151b5 JB |
142 | enum { |
143 | DVM_OP_MODE = 0, | |
144 | MVM_OP_MODE = 1, | |
145 | }; | |
965974a6 | 146 | |
ff1ffb85 JB |
147 | /* Protects the table contents, i.e. the ops pointer & drv list */ |
148 | static struct mutex iwlwifi_opmode_table_mtx; | |
cc5f7e39 DF |
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 */ | |
8ca151b5 JB |
154 | [DVM_OP_MODE] = { .name = "iwldvm", .ops = NULL }, |
155 | [MVM_OP_MODE] = { .name = "iwlmvm", .ops = NULL }, | |
cc5f7e39 | 156 | }; |
965974a6 | 157 | |
0cedacc5 DS |
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 | ||
965974a6 | 168 | static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) |
15854ef9 | 169 | { |
83f84d7b JB |
170 | vfree(desc->data); |
171 | desc->data = NULL; | |
15854ef9 JB |
172 | desc->len = 0; |
173 | } | |
174 | ||
965974a6 | 175 | static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img) |
15854ef9 | 176 | { |
6dfa8d01 DS |
177 | int i; |
178 | for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) | |
179 | iwl_free_fw_desc(drv, &img->sec[i]); | |
15854ef9 JB |
180 | } |
181 | ||
965974a6 | 182 | static void iwl_dealloc_ucode(struct iwl_drv *drv) |
15854ef9 | 183 | { |
6dfa8d01 DS |
184 | int i; |
185 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) | |
186 | iwl_free_fw_img(drv, drv->fw.img + i); | |
15854ef9 JB |
187 | } |
188 | ||
965974a6 | 189 | static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, |
83f84d7b | 190 | struct fw_sec *sec) |
15854ef9 | 191 | { |
83f84d7b JB |
192 | void *data; |
193 | ||
194 | desc->data = NULL; | |
195 | ||
196 | if (!sec || !sec->size) | |
15854ef9 | 197 | return -EINVAL; |
15854ef9 | 198 | |
83f84d7b JB |
199 | data = vmalloc(sec->size); |
200 | if (!data) | |
15854ef9 JB |
201 | return -ENOMEM; |
202 | ||
0cedacc5 DS |
203 | desc->len = sec->size; |
204 | desc->offset = sec->offset; | |
83f84d7b JB |
205 | memcpy(data, sec->data, desc->len); |
206 | desc->data = data; | |
207 | ||
15854ef9 JB |
208 | return 0; |
209 | } | |
210 | ||
1c8e11e1 EG |
211 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, |
212 | void *context); | |
15854ef9 JB |
213 | |
214 | #define UCODE_EXPERIMENTAL_INDEX 100 | |
215 | #define UCODE_EXPERIMENTAL_TAG "exp" | |
216 | ||
965974a6 | 217 | static int iwl_request_firmware(struct iwl_drv *drv, bool first) |
15854ef9 | 218 | { |
68f360dc | 219 | const char *name_pre = drv->cfg->fw_name_pre; |
15854ef9 JB |
220 | char tag[8]; |
221 | ||
222 | if (first) { | |
223 | #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE | |
965974a6 | 224 | drv->fw_index = UCODE_EXPERIMENTAL_INDEX; |
15854ef9 | 225 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
965974a6 | 226 | } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
15854ef9 | 227 | #endif |
68f360dc | 228 | drv->fw_index = drv->cfg->ucode_api_max; |
965974a6 | 229 | sprintf(tag, "%d", drv->fw_index); |
15854ef9 | 230 | } else { |
965974a6 JB |
231 | drv->fw_index--; |
232 | sprintf(tag, "%d", drv->fw_index); | |
15854ef9 JB |
233 | } |
234 | ||
68f360dc | 235 | if (drv->fw_index < drv->cfg->ucode_api_min) { |
965974a6 | 236 | IWL_ERR(drv, "no suitable firmware found!\n"); |
15854ef9 JB |
237 | return -ENOENT; |
238 | } | |
239 | ||
84b0312e LK |
240 | snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode", |
241 | name_pre, tag); | |
15854ef9 | 242 | |
965974a6 JB |
243 | IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", |
244 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) | |
15854ef9 | 245 | ? "EXPERIMENTAL " : "", |
965974a6 | 246 | drv->firmware_name); |
15854ef9 | 247 | |
965974a6 | 248 | return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, |
93faaeea | 249 | drv->trans->dev, |
1c8e11e1 | 250 | GFP_KERNEL, drv, iwl_req_fw_callback); |
15854ef9 JB |
251 | } |
252 | ||
0cedacc5 | 253 | struct fw_img_parsing { |
6dfa8d01 | 254 | struct fw_sec sec[IWL_UCODE_SECTION_MAX]; |
0cedacc5 DS |
255 | int sec_counter; |
256 | }; | |
257 | ||
ed8c8365 DS |
258 | /* |
259 | * struct fw_sec_parsing: to extract fw section and it's offset from tlv | |
260 | */ | |
261 | struct fw_sec_parsing { | |
262 | __le32 offset; | |
263 | const u8 data[]; | |
264 | } __packed; | |
265 | ||
266 | /** | |
267 | * struct iwl_tlv_calib_data - parse the default calib data from TLV | |
268 | * | |
269 | * @ucode_type: the uCode to which the following default calib relates. | |
270 | * @calib: default calibrations. | |
271 | */ | |
272 | struct iwl_tlv_calib_data { | |
273 | __le32 ucode_type; | |
aa2b1770 | 274 | struct iwl_tlv_calib_ctrl calib; |
ed8c8365 DS |
275 | } __packed; |
276 | ||
0cedacc5 DS |
277 | struct iwl_firmware_pieces { |
278 | struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; | |
15854ef9 JB |
279 | |
280 | u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; | |
281 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; | |
282 | }; | |
283 | ||
0cedacc5 DS |
284 | /* |
285 | * These functions are just to extract uCode section data from the pieces | |
286 | * structure. | |
287 | */ | |
288 | static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces, | |
289 | enum iwl_ucode_type type, | |
290 | int sec) | |
291 | { | |
292 | return &pieces->img[type].sec[sec]; | |
293 | } | |
294 | ||
295 | static void set_sec_data(struct iwl_firmware_pieces *pieces, | |
296 | enum iwl_ucode_type type, | |
297 | int sec, | |
298 | const void *data) | |
299 | { | |
300 | pieces->img[type].sec[sec].data = data; | |
301 | } | |
302 | ||
303 | static void set_sec_size(struct iwl_firmware_pieces *pieces, | |
304 | enum iwl_ucode_type type, | |
305 | int sec, | |
306 | size_t size) | |
307 | { | |
308 | pieces->img[type].sec[sec].size = size; | |
309 | } | |
310 | ||
311 | static size_t get_sec_size(struct iwl_firmware_pieces *pieces, | |
312 | enum iwl_ucode_type type, | |
313 | int sec) | |
314 | { | |
315 | return pieces->img[type].sec[sec].size; | |
316 | } | |
317 | ||
318 | static void set_sec_offset(struct iwl_firmware_pieces *pieces, | |
319 | enum iwl_ucode_type type, | |
320 | int sec, | |
321 | u32 offset) | |
322 | { | |
323 | pieces->img[type].sec[sec].offset = offset; | |
324 | } | |
325 | ||
e36e5433 MS |
326 | static int iwl_store_cscheme(struct iwl_fw *fw, const u8 *data, const u32 len) |
327 | { | |
328 | int i, j; | |
329 | struct iwl_fw_cscheme_list *l = (struct iwl_fw_cscheme_list *)data; | |
330 | struct iwl_fw_cipher_scheme *fwcs; | |
331 | struct ieee80211_cipher_scheme *cs; | |
332 | u32 cipher; | |
333 | ||
334 | if (len < sizeof(*l) || | |
335 | len < sizeof(l->size) + l->size * sizeof(l->cs[0])) | |
336 | return -EINVAL; | |
337 | ||
338 | for (i = 0, j = 0; i < IWL_UCODE_MAX_CS && i < l->size; i++) { | |
339 | fwcs = &l->cs[j]; | |
340 | cipher = le32_to_cpu(fwcs->cipher); | |
341 | ||
342 | /* we skip schemes with zero cipher suite selector */ | |
343 | if (!cipher) | |
344 | continue; | |
345 | ||
346 | cs = &fw->cs[j++]; | |
347 | cs->cipher = cipher; | |
348 | cs->iftype = BIT(NL80211_IFTYPE_STATION); | |
349 | cs->hdr_len = fwcs->hdr_len; | |
350 | cs->pn_len = fwcs->pn_len; | |
351 | cs->pn_off = fwcs->pn_off; | |
352 | cs->key_idx_off = fwcs->key_idx_off; | |
353 | cs->key_idx_mask = fwcs->key_idx_mask; | |
354 | cs->key_idx_shift = fwcs->key_idx_shift; | |
355 | cs->mic_len = fwcs->mic_len; | |
356 | } | |
357 | ||
358 | return 0; | |
359 | } | |
360 | ||
ed8c8365 DS |
361 | /* |
362 | * Gets uCode section from tlv. | |
363 | */ | |
364 | static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces, | |
365 | const void *data, enum iwl_ucode_type type, | |
366 | int size) | |
367 | { | |
368 | struct fw_img_parsing *img; | |
369 | struct fw_sec *sec; | |
370 | struct fw_sec_parsing *sec_parse; | |
371 | ||
372 | if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX)) | |
373 | return -1; | |
374 | ||
375 | sec_parse = (struct fw_sec_parsing *)data; | |
376 | ||
377 | img = &pieces->img[type]; | |
378 | sec = &img->sec[img->sec_counter]; | |
379 | ||
380 | sec->offset = le32_to_cpu(sec_parse->offset); | |
381 | sec->data = sec_parse->data; | |
1176f431 | 382 | sec->size = size - sizeof(sec_parse->offset); |
ed8c8365 DS |
383 | |
384 | ++img->sec_counter; | |
385 | ||
386 | return 0; | |
387 | } | |
388 | ||
389 | static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data) | |
390 | { | |
391 | struct iwl_tlv_calib_data *def_calib = | |
392 | (struct iwl_tlv_calib_data *)data; | |
393 | u32 ucode_type = le32_to_cpu(def_calib->ucode_type); | |
394 | if (ucode_type >= IWL_UCODE_TYPE_MAX) { | |
395 | IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n", | |
396 | ucode_type); | |
397 | return -EINVAL; | |
398 | } | |
aa2b1770 JB |
399 | drv->fw.default_calib[ucode_type].flow_trigger = |
400 | def_calib->calib.flow_trigger; | |
401 | drv->fw.default_calib[ucode_type].event_trigger = | |
402 | def_calib->calib.event_trigger; | |
403 | ||
ed8c8365 DS |
404 | return 0; |
405 | } | |
406 | ||
a2978b11 EH |
407 | static int iwl_set_ucode_api_flags(struct iwl_drv *drv, const u8 *data, |
408 | struct iwl_ucode_capabilities *capa) | |
409 | { | |
410 | const struct iwl_ucode_api *ucode_api = (void *)data; | |
411 | u32 api_index = le32_to_cpu(ucode_api->api_index); | |
412 | ||
413 | if (api_index >= IWL_API_ARRAY_SIZE) { | |
414 | IWL_ERR(drv, "api_index larger than supported by driver\n"); | |
415 | return -EINVAL; | |
416 | } | |
417 | ||
418 | capa->api[api_index] = le32_to_cpu(ucode_api->api_flags); | |
419 | ||
420 | return 0; | |
421 | } | |
422 | ||
423 | static int iwl_set_ucode_capabilities(struct iwl_drv *drv, const u8 *data, | |
424 | struct iwl_ucode_capabilities *capa) | |
425 | { | |
426 | const struct iwl_ucode_capa *ucode_capa = (void *)data; | |
427 | u32 api_index = le32_to_cpu(ucode_capa->api_index); | |
428 | ||
429 | if (api_index >= IWL_CAPABILITIES_ARRAY_SIZE) { | |
430 | IWL_ERR(drv, "api_index larger than supported by driver\n"); | |
431 | return -EINVAL; | |
432 | } | |
433 | ||
434 | capa->capa[api_index] = le32_to_cpu(ucode_capa->api_capa); | |
435 | ||
436 | return 0; | |
437 | } | |
438 | ||
965974a6 | 439 | static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, |
0cedacc5 DS |
440 | const struct firmware *ucode_raw, |
441 | struct iwl_firmware_pieces *pieces) | |
15854ef9 JB |
442 | { |
443 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; | |
444 | u32 api_ver, hdr_size, build; | |
445 | char buildstr[25]; | |
446 | const u8 *src; | |
447 | ||
965974a6 JB |
448 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
449 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); | |
15854ef9 JB |
450 | |
451 | switch (api_ver) { | |
452 | default: | |
453 | hdr_size = 28; | |
454 | if (ucode_raw->size < hdr_size) { | |
965974a6 | 455 | IWL_ERR(drv, "File size too small!\n"); |
15854ef9 JB |
456 | return -EINVAL; |
457 | } | |
458 | build = le32_to_cpu(ucode->u.v2.build); | |
0cedacc5 DS |
459 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
460 | le32_to_cpu(ucode->u.v2.inst_size)); | |
461 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, | |
462 | le32_to_cpu(ucode->u.v2.data_size)); | |
463 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, | |
464 | le32_to_cpu(ucode->u.v2.init_size)); | |
465 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, | |
466 | le32_to_cpu(ucode->u.v2.init_data_size)); | |
15854ef9 JB |
467 | src = ucode->u.v2.data; |
468 | break; | |
469 | case 0: | |
470 | case 1: | |
471 | case 2: | |
472 | hdr_size = 24; | |
473 | if (ucode_raw->size < hdr_size) { | |
965974a6 | 474 | IWL_ERR(drv, "File size too small!\n"); |
15854ef9 JB |
475 | return -EINVAL; |
476 | } | |
477 | build = 0; | |
0cedacc5 DS |
478 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
479 | le32_to_cpu(ucode->u.v1.inst_size)); | |
480 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, | |
481 | le32_to_cpu(ucode->u.v1.data_size)); | |
482 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, | |
483 | le32_to_cpu(ucode->u.v1.init_size)); | |
484 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, | |
485 | le32_to_cpu(ucode->u.v1.init_data_size)); | |
15854ef9 JB |
486 | src = ucode->u.v1.data; |
487 | break; | |
488 | } | |
489 | ||
490 | if (build) | |
491 | sprintf(buildstr, " build %u%s", build, | |
965974a6 | 492 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
15854ef9 JB |
493 | ? " (EXP)" : ""); |
494 | else | |
495 | buildstr[0] = '\0'; | |
496 | ||
965974a6 JB |
497 | snprintf(drv->fw.fw_version, |
498 | sizeof(drv->fw.fw_version), | |
15854ef9 | 499 | "%u.%u.%u.%u%s", |
965974a6 JB |
500 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
501 | IWL_UCODE_MINOR(drv->fw.ucode_ver), | |
502 | IWL_UCODE_API(drv->fw.ucode_ver), | |
503 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), | |
15854ef9 JB |
504 | buildstr); |
505 | ||
506 | /* Verify size of file vs. image size info in file's header */ | |
0cedacc5 DS |
507 | |
508 | if (ucode_raw->size != hdr_size + | |
509 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) + | |
510 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) + | |
511 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) + | |
512 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { | |
15854ef9 | 513 | |
965974a6 | 514 | IWL_ERR(drv, |
15854ef9 JB |
515 | "uCode file size %d does not match expected size\n", |
516 | (int)ucode_raw->size); | |
517 | return -EINVAL; | |
518 | } | |
519 | ||
15854ef9 | 520 | |
0cedacc5 DS |
521 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src); |
522 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST); | |
523 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, | |
524 | IWLAGN_RTC_INST_LOWER_BOUND); | |
525 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src); | |
526 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA); | |
527 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, | |
528 | IWLAGN_RTC_DATA_LOWER_BOUND); | |
529 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src); | |
530 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST); | |
531 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, | |
532 | IWLAGN_RTC_INST_LOWER_BOUND); | |
533 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src); | |
534 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA); | |
535 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, | |
536 | IWLAGN_RTC_DATA_LOWER_BOUND); | |
15854ef9 JB |
537 | return 0; |
538 | } | |
539 | ||
965974a6 | 540 | static int iwl_parse_tlv_firmware(struct iwl_drv *drv, |
15854ef9 | 541 | const struct firmware *ucode_raw, |
0cedacc5 | 542 | struct iwl_firmware_pieces *pieces, |
15854ef9 JB |
543 | struct iwl_ucode_capabilities *capa) |
544 | { | |
545 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; | |
546 | struct iwl_ucode_tlv *tlv; | |
547 | size_t len = ucode_raw->size; | |
548 | const u8 *data; | |
15854ef9 JB |
549 | u32 tlv_len; |
550 | enum iwl_ucode_tlv_type tlv_type; | |
551 | const u8 *tlv_data; | |
552 | char buildstr[25]; | |
553 | u32 build; | |
e2d6f4e7 | 554 | int num_of_cpus; |
15854ef9 JB |
555 | |
556 | if (len < sizeof(*ucode)) { | |
965974a6 | 557 | IWL_ERR(drv, "uCode has invalid length: %zd\n", len); |
15854ef9 JB |
558 | return -EINVAL; |
559 | } | |
560 | ||
561 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { | |
965974a6 | 562 | IWL_ERR(drv, "invalid uCode magic: 0X%x\n", |
15854ef9 JB |
563 | le32_to_cpu(ucode->magic)); |
564 | return -EINVAL; | |
565 | } | |
566 | ||
965974a6 | 567 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
15854ef9 JB |
568 | build = le32_to_cpu(ucode->build); |
569 | ||
570 | if (build) | |
571 | sprintf(buildstr, " build %u%s", build, | |
965974a6 | 572 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
15854ef9 JB |
573 | ? " (EXP)" : ""); |
574 | else | |
575 | buildstr[0] = '\0'; | |
576 | ||
965974a6 JB |
577 | snprintf(drv->fw.fw_version, |
578 | sizeof(drv->fw.fw_version), | |
15854ef9 | 579 | "%u.%u.%u.%u%s", |
965974a6 JB |
580 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
581 | IWL_UCODE_MINOR(drv->fw.ucode_ver), | |
582 | IWL_UCODE_API(drv->fw.ucode_ver), | |
583 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), | |
15854ef9 JB |
584 | buildstr); |
585 | ||
586 | data = ucode->data; | |
587 | ||
588 | len -= sizeof(*ucode); | |
589 | ||
590 | while (len >= sizeof(*tlv)) { | |
15854ef9 JB |
591 | len -= sizeof(*tlv); |
592 | tlv = (void *)data; | |
593 | ||
594 | tlv_len = le32_to_cpu(tlv->length); | |
0479c19d | 595 | tlv_type = le32_to_cpu(tlv->type); |
15854ef9 JB |
596 | tlv_data = tlv->data; |
597 | ||
598 | if (len < tlv_len) { | |
965974a6 | 599 | IWL_ERR(drv, "invalid TLV len: %zd/%u\n", |
15854ef9 JB |
600 | len, tlv_len); |
601 | return -EINVAL; | |
602 | } | |
603 | len -= ALIGN(tlv_len, 4); | |
604 | data += sizeof(*tlv) + ALIGN(tlv_len, 4); | |
605 | ||
15854ef9 JB |
606 | switch (tlv_type) { |
607 | case IWL_UCODE_TLV_INST: | |
0cedacc5 DS |
608 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
609 | IWL_UCODE_SECTION_INST, tlv_data); | |
610 | set_sec_size(pieces, IWL_UCODE_REGULAR, | |
611 | IWL_UCODE_SECTION_INST, tlv_len); | |
612 | set_sec_offset(pieces, IWL_UCODE_REGULAR, | |
613 | IWL_UCODE_SECTION_INST, | |
614 | IWLAGN_RTC_INST_LOWER_BOUND); | |
15854ef9 JB |
615 | break; |
616 | case IWL_UCODE_TLV_DATA: | |
0cedacc5 DS |
617 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
618 | IWL_UCODE_SECTION_DATA, tlv_data); | |
619 | set_sec_size(pieces, IWL_UCODE_REGULAR, | |
620 | IWL_UCODE_SECTION_DATA, tlv_len); | |
621 | set_sec_offset(pieces, IWL_UCODE_REGULAR, | |
622 | IWL_UCODE_SECTION_DATA, | |
623 | IWLAGN_RTC_DATA_LOWER_BOUND); | |
15854ef9 JB |
624 | break; |
625 | case IWL_UCODE_TLV_INIT: | |
0cedacc5 DS |
626 | set_sec_data(pieces, IWL_UCODE_INIT, |
627 | IWL_UCODE_SECTION_INST, tlv_data); | |
628 | set_sec_size(pieces, IWL_UCODE_INIT, | |
629 | IWL_UCODE_SECTION_INST, tlv_len); | |
630 | set_sec_offset(pieces, IWL_UCODE_INIT, | |
631 | IWL_UCODE_SECTION_INST, | |
632 | IWLAGN_RTC_INST_LOWER_BOUND); | |
15854ef9 JB |
633 | break; |
634 | case IWL_UCODE_TLV_INIT_DATA: | |
0cedacc5 DS |
635 | set_sec_data(pieces, IWL_UCODE_INIT, |
636 | IWL_UCODE_SECTION_DATA, tlv_data); | |
637 | set_sec_size(pieces, IWL_UCODE_INIT, | |
638 | IWL_UCODE_SECTION_DATA, tlv_len); | |
639 | set_sec_offset(pieces, IWL_UCODE_INIT, | |
640 | IWL_UCODE_SECTION_DATA, | |
641 | IWLAGN_RTC_DATA_LOWER_BOUND); | |
15854ef9 JB |
642 | break; |
643 | case IWL_UCODE_TLV_BOOT: | |
965974a6 | 644 | IWL_ERR(drv, "Found unexpected BOOT ucode\n"); |
15854ef9 JB |
645 | break; |
646 | case IWL_UCODE_TLV_PROBE_MAX_LEN: | |
647 | if (tlv_len != sizeof(u32)) | |
648 | goto invalid_tlv_len; | |
649 | capa->max_probe_length = | |
650 | le32_to_cpup((__le32 *)tlv_data); | |
651 | break; | |
652 | case IWL_UCODE_TLV_PAN: | |
653 | if (tlv_len) | |
654 | goto invalid_tlv_len; | |
655 | capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; | |
656 | break; | |
657 | case IWL_UCODE_TLV_FLAGS: | |
658 | /* must be at least one u32 */ | |
659 | if (tlv_len < sizeof(u32)) | |
660 | goto invalid_tlv_len; | |
661 | /* and a proper number of u32s */ | |
662 | if (tlv_len % sizeof(u32)) | |
663 | goto invalid_tlv_len; | |
664 | /* | |
665 | * This driver only reads the first u32 as | |
666 | * right now no more features are defined, | |
667 | * if that changes then either the driver | |
668 | * will not work with the new firmware, or | |
669 | * it'll not take advantage of new features. | |
670 | */ | |
671 | capa->flags = le32_to_cpup((__le32 *)tlv_data); | |
672 | break; | |
a2978b11 EH |
673 | case IWL_UCODE_TLV_API_CHANGES_SET: |
674 | if (tlv_len != sizeof(struct iwl_ucode_api)) | |
675 | goto invalid_tlv_len; | |
676 | if (iwl_set_ucode_api_flags(drv, tlv_data, capa)) | |
677 | goto tlv_error; | |
678 | break; | |
679 | case IWL_UCODE_TLV_ENABLED_CAPABILITIES: | |
680 | if (tlv_len != sizeof(struct iwl_ucode_capa)) | |
681 | goto invalid_tlv_len; | |
682 | if (iwl_set_ucode_capabilities(drv, tlv_data, capa)) | |
683 | goto tlv_error; | |
684 | break; | |
15854ef9 JB |
685 | case IWL_UCODE_TLV_INIT_EVTLOG_PTR: |
686 | if (tlv_len != sizeof(u32)) | |
687 | goto invalid_tlv_len; | |
688 | pieces->init_evtlog_ptr = | |
689 | le32_to_cpup((__le32 *)tlv_data); | |
690 | break; | |
691 | case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: | |
692 | if (tlv_len != sizeof(u32)) | |
693 | goto invalid_tlv_len; | |
694 | pieces->init_evtlog_size = | |
695 | le32_to_cpup((__le32 *)tlv_data); | |
696 | break; | |
697 | case IWL_UCODE_TLV_INIT_ERRLOG_PTR: | |
698 | if (tlv_len != sizeof(u32)) | |
699 | goto invalid_tlv_len; | |
700 | pieces->init_errlog_ptr = | |
701 | le32_to_cpup((__le32 *)tlv_data); | |
702 | break; | |
703 | case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: | |
704 | if (tlv_len != sizeof(u32)) | |
705 | goto invalid_tlv_len; | |
706 | pieces->inst_evtlog_ptr = | |
707 | le32_to_cpup((__le32 *)tlv_data); | |
708 | break; | |
709 | case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: | |
710 | if (tlv_len != sizeof(u32)) | |
711 | goto invalid_tlv_len; | |
712 | pieces->inst_evtlog_size = | |
713 | le32_to_cpup((__le32 *)tlv_data); | |
714 | break; | |
715 | case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: | |
716 | if (tlv_len != sizeof(u32)) | |
717 | goto invalid_tlv_len; | |
718 | pieces->inst_errlog_ptr = | |
719 | le32_to_cpup((__le32 *)tlv_data); | |
720 | break; | |
721 | case IWL_UCODE_TLV_ENHANCE_SENS_TBL: | |
722 | if (tlv_len) | |
723 | goto invalid_tlv_len; | |
965974a6 | 724 | drv->fw.enhance_sensitivity_table = true; |
15854ef9 JB |
725 | break; |
726 | case IWL_UCODE_TLV_WOWLAN_INST: | |
0cedacc5 DS |
727 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
728 | IWL_UCODE_SECTION_INST, tlv_data); | |
729 | set_sec_size(pieces, IWL_UCODE_WOWLAN, | |
730 | IWL_UCODE_SECTION_INST, tlv_len); | |
731 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, | |
732 | IWL_UCODE_SECTION_INST, | |
733 | IWLAGN_RTC_INST_LOWER_BOUND); | |
15854ef9 JB |
734 | break; |
735 | case IWL_UCODE_TLV_WOWLAN_DATA: | |
0cedacc5 DS |
736 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
737 | IWL_UCODE_SECTION_DATA, tlv_data); | |
738 | set_sec_size(pieces, IWL_UCODE_WOWLAN, | |
739 | IWL_UCODE_SECTION_DATA, tlv_len); | |
740 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, | |
741 | IWL_UCODE_SECTION_DATA, | |
742 | IWLAGN_RTC_DATA_LOWER_BOUND); | |
15854ef9 JB |
743 | break; |
744 | case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: | |
745 | if (tlv_len != sizeof(u32)) | |
746 | goto invalid_tlv_len; | |
747 | capa->standard_phy_calibration_size = | |
748 | le32_to_cpup((__le32 *)tlv_data); | |
749 | break; | |
ed8c8365 DS |
750 | case IWL_UCODE_TLV_SEC_RT: |
751 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, | |
752 | tlv_len); | |
4db2c9ae | 753 | drv->fw.mvm_fw = true; |
ed8c8365 DS |
754 | break; |
755 | case IWL_UCODE_TLV_SEC_INIT: | |
756 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, | |
757 | tlv_len); | |
4db2c9ae | 758 | drv->fw.mvm_fw = true; |
ed8c8365 DS |
759 | break; |
760 | case IWL_UCODE_TLV_SEC_WOWLAN: | |
761 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, | |
762 | tlv_len); | |
4db2c9ae | 763 | drv->fw.mvm_fw = true; |
ed8c8365 DS |
764 | break; |
765 | case IWL_UCODE_TLV_DEF_CALIB: | |
766 | if (tlv_len != sizeof(struct iwl_tlv_calib_data)) | |
767 | goto invalid_tlv_len; | |
768 | if (iwl_set_default_calib(drv, tlv_data)) | |
769 | goto tlv_error; | |
770 | break; | |
771 | case IWL_UCODE_TLV_PHY_SKU: | |
772 | if (tlv_len != sizeof(u32)) | |
773 | goto invalid_tlv_len; | |
774 | drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data); | |
77db0a3c EH |
775 | drv->fw.valid_tx_ant = (drv->fw.phy_config & |
776 | FW_PHY_CFG_TX_CHAIN) >> | |
777 | FW_PHY_CFG_TX_CHAIN_POS; | |
778 | drv->fw.valid_rx_ant = (drv->fw.phy_config & | |
779 | FW_PHY_CFG_RX_CHAIN) >> | |
780 | FW_PHY_CFG_RX_CHAIN_POS; | |
ed8c8365 | 781 | break; |
e2d6f4e7 EH |
782 | case IWL_UCODE_TLV_SECURE_SEC_RT: |
783 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, | |
784 | tlv_len); | |
785 | drv->fw.mvm_fw = true; | |
786 | drv->fw.img[IWL_UCODE_REGULAR].is_secure = true; | |
787 | break; | |
788 | case IWL_UCODE_TLV_SECURE_SEC_INIT: | |
789 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, | |
790 | tlv_len); | |
791 | drv->fw.mvm_fw = true; | |
792 | drv->fw.img[IWL_UCODE_INIT].is_secure = true; | |
793 | break; | |
794 | case IWL_UCODE_TLV_SECURE_SEC_WOWLAN: | |
795 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, | |
796 | tlv_len); | |
797 | drv->fw.mvm_fw = true; | |
798 | drv->fw.img[IWL_UCODE_WOWLAN].is_secure = true; | |
799 | break; | |
800 | case IWL_UCODE_TLV_NUM_OF_CPU: | |
801 | if (tlv_len != sizeof(u32)) | |
802 | goto invalid_tlv_len; | |
803 | num_of_cpus = | |
804 | le32_to_cpup((__le32 *)tlv_data); | |
805 | ||
806 | if (num_of_cpus == 2) { | |
807 | drv->fw.img[IWL_UCODE_REGULAR].is_dual_cpus = | |
808 | true; | |
809 | drv->fw.img[IWL_UCODE_INIT].is_dual_cpus = | |
810 | true; | |
811 | drv->fw.img[IWL_UCODE_WOWLAN].is_dual_cpus = | |
812 | true; | |
813 | } else if ((num_of_cpus > 2) || (num_of_cpus < 1)) { | |
814 | IWL_ERR(drv, "Driver support upto 2 CPUs\n"); | |
815 | return -EINVAL; | |
816 | } | |
817 | break; | |
e36e5433 MS |
818 | case IWL_UCODE_TLV_CSCHEME: |
819 | if (iwl_store_cscheme(&drv->fw, tlv_data, tlv_len)) | |
820 | goto invalid_tlv_len; | |
821 | break; | |
15854ef9 | 822 | default: |
965974a6 | 823 | IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); |
15854ef9 JB |
824 | break; |
825 | } | |
826 | } | |
827 | ||
828 | if (len) { | |
965974a6 JB |
829 | IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len); |
830 | iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len); | |
15854ef9 JB |
831 | return -EINVAL; |
832 | } | |
833 | ||
834 | return 0; | |
835 | ||
836 | invalid_tlv_len: | |
965974a6 | 837 | IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); |
ed8c8365 | 838 | tlv_error: |
965974a6 | 839 | iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); |
15854ef9 JB |
840 | |
841 | return -EINVAL; | |
842 | } | |
843 | ||
75813bde JB |
844 | static int iwl_alloc_ucode(struct iwl_drv *drv, |
845 | struct iwl_firmware_pieces *pieces, | |
846 | enum iwl_ucode_type type) | |
6dfa8d01 DS |
847 | { |
848 | int i; | |
849 | for (i = 0; | |
850 | i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i); | |
851 | i++) | |
852 | if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]), | |
75813bde JB |
853 | get_sec(pieces, type, i))) |
854 | return -ENOMEM; | |
6dfa8d01 DS |
855 | return 0; |
856 | } | |
857 | ||
858 | static int validate_sec_sizes(struct iwl_drv *drv, | |
859 | struct iwl_firmware_pieces *pieces, | |
860 | const struct iwl_cfg *cfg) | |
861 | { | |
862 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", | |
863 | get_sec_size(pieces, IWL_UCODE_REGULAR, | |
864 | IWL_UCODE_SECTION_INST)); | |
865 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", | |
866 | get_sec_size(pieces, IWL_UCODE_REGULAR, | |
867 | IWL_UCODE_SECTION_DATA)); | |
868 | IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", | |
869 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); | |
870 | IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", | |
871 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); | |
872 | ||
873 | /* Verify that uCode images will fit in card's SRAM. */ | |
874 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > | |
875 | cfg->max_inst_size) { | |
876 | IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", | |
877 | get_sec_size(pieces, IWL_UCODE_REGULAR, | |
878 | IWL_UCODE_SECTION_INST)); | |
879 | return -1; | |
880 | } | |
881 | ||
882 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > | |
883 | cfg->max_data_size) { | |
884 | IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", | |
885 | get_sec_size(pieces, IWL_UCODE_REGULAR, | |
886 | IWL_UCODE_SECTION_DATA)); | |
887 | return -1; | |
888 | } | |
889 | ||
890 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > | |
891 | cfg->max_inst_size) { | |
892 | IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", | |
893 | get_sec_size(pieces, IWL_UCODE_INIT, | |
894 | IWL_UCODE_SECTION_INST)); | |
895 | return -1; | |
896 | } | |
897 | ||
898 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > | |
899 | cfg->max_data_size) { | |
900 | IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", | |
901 | get_sec_size(pieces, IWL_UCODE_REGULAR, | |
902 | IWL_UCODE_SECTION_DATA)); | |
903 | return -1; | |
904 | } | |
905 | return 0; | |
906 | } | |
907 | ||
9da987ac MV |
908 | static struct iwl_op_mode * |
909 | _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op) | |
910 | { | |
911 | const struct iwl_op_mode_ops *ops = op->ops; | |
912 | struct dentry *dbgfs_dir = NULL; | |
913 | struct iwl_op_mode *op_mode = NULL; | |
914 | ||
915 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
916 | drv->dbgfs_op_mode = debugfs_create_dir(op->name, | |
917 | drv->dbgfs_drv); | |
918 | if (!drv->dbgfs_op_mode) { | |
919 | IWL_ERR(drv, | |
920 | "failed to create opmode debugfs directory\n"); | |
921 | return op_mode; | |
922 | } | |
923 | dbgfs_dir = drv->dbgfs_op_mode; | |
924 | #endif | |
925 | ||
926 | op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir); | |
927 | ||
928 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
929 | if (!op_mode) { | |
930 | debugfs_remove_recursive(drv->dbgfs_op_mode); | |
931 | drv->dbgfs_op_mode = NULL; | |
932 | } | |
933 | #endif | |
934 | ||
935 | return op_mode; | |
936 | } | |
937 | ||
938 | static void _iwl_op_mode_stop(struct iwl_drv *drv) | |
939 | { | |
940 | /* op_mode can be NULL if its start failed */ | |
941 | if (drv->op_mode) { | |
942 | iwl_op_mode_stop(drv->op_mode); | |
943 | drv->op_mode = NULL; | |
944 | ||
945 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
946 | debugfs_remove_recursive(drv->dbgfs_op_mode); | |
947 | drv->dbgfs_op_mode = NULL; | |
948 | #endif | |
949 | } | |
950 | } | |
951 | ||
15854ef9 | 952 | /** |
1c8e11e1 | 953 | * iwl_req_fw_callback - callback when firmware was loaded |
15854ef9 JB |
954 | * |
955 | * If loaded successfully, copies the firmware into buffers | |
956 | * for the card to fetch (via DMA). | |
957 | */ | |
1c8e11e1 | 958 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context) |
15854ef9 | 959 | { |
965974a6 | 960 | struct iwl_drv *drv = context; |
965974a6 | 961 | struct iwl_fw *fw = &drv->fw; |
15854ef9 | 962 | struct iwl_ucode_header *ucode; |
cc5f7e39 | 963 | struct iwlwifi_opmode_table *op; |
15854ef9 | 964 | int err; |
0cedacc5 | 965 | struct iwl_firmware_pieces pieces; |
68f360dc EG |
966 | const unsigned int api_max = drv->cfg->ucode_api_max; |
967 | unsigned int api_ok = drv->cfg->ucode_api_ok; | |
968 | const unsigned int api_min = drv->cfg->ucode_api_min; | |
15854ef9 | 969 | u32 api_ver; |
6dfa8d01 | 970 | int i; |
d4b10483 | 971 | bool load_module = false; |
15854ef9 | 972 | |
66140adc | 973 | fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH; |
15854ef9 JB |
974 | fw->ucode_capa.standard_phy_calibration_size = |
975 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; | |
976 | ||
977 | if (!api_ok) | |
978 | api_ok = api_max; | |
979 | ||
980 | memset(&pieces, 0, sizeof(pieces)); | |
981 | ||
982 | if (!ucode_raw) { | |
965974a6 JB |
983 | if (drv->fw_index <= api_ok) |
984 | IWL_ERR(drv, | |
15854ef9 | 985 | "request for firmware file '%s' failed.\n", |
965974a6 | 986 | drv->firmware_name); |
15854ef9 JB |
987 | goto try_again; |
988 | } | |
989 | ||
965974a6 JB |
990 | IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n", |
991 | drv->firmware_name, ucode_raw->size); | |
15854ef9 JB |
992 | |
993 | /* Make sure that we got at least the API version number */ | |
994 | if (ucode_raw->size < 4) { | |
965974a6 | 995 | IWL_ERR(drv, "File size way too small!\n"); |
15854ef9 JB |
996 | goto try_again; |
997 | } | |
998 | ||
999 | /* Data from ucode file: header followed by uCode images */ | |
1000 | ucode = (struct iwl_ucode_header *)ucode_raw->data; | |
1001 | ||
1002 | if (ucode->ver) | |
965974a6 | 1003 | err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces); |
15854ef9 | 1004 | else |
965974a6 | 1005 | err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces, |
15854ef9 JB |
1006 | &fw->ucode_capa); |
1007 | ||
1008 | if (err) | |
1009 | goto try_again; | |
1010 | ||
965974a6 | 1011 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
15854ef9 JB |
1012 | |
1013 | /* | |
1014 | * api_ver should match the api version forming part of the | |
1015 | * firmware filename ... but we don't check for that and only rely | |
1016 | * on the API version read from firmware header from here on forward | |
1017 | */ | |
1018 | /* no api version check required for experimental uCode */ | |
965974a6 | 1019 | if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
15854ef9 | 1020 | if (api_ver < api_min || api_ver > api_max) { |
965974a6 | 1021 | IWL_ERR(drv, |
15854ef9 JB |
1022 | "Driver unable to support your firmware API. " |
1023 | "Driver supports v%u, firmware is v%u.\n", | |
1024 | api_max, api_ver); | |
1025 | goto try_again; | |
1026 | } | |
1027 | ||
1028 | if (api_ver < api_ok) { | |
1029 | if (api_ok != api_max) | |
965974a6 | 1030 | IWL_ERR(drv, "Firmware has old API version, " |
15854ef9 JB |
1031 | "expected v%u through v%u, got v%u.\n", |
1032 | api_ok, api_max, api_ver); | |
1033 | else | |
965974a6 | 1034 | IWL_ERR(drv, "Firmware has old API version, " |
15854ef9 JB |
1035 | "expected v%u, got v%u.\n", |
1036 | api_max, api_ver); | |
965974a6 | 1037 | IWL_ERR(drv, "New firmware can be obtained from " |
15854ef9 JB |
1038 | "http://www.intellinuxwireless.org/.\n"); |
1039 | } | |
1040 | } | |
1041 | ||
4db2c9ae DS |
1042 | /* |
1043 | * In mvm uCode there is no difference between data and instructions | |
1044 | * sections. | |
1045 | */ | |
68f360dc | 1046 | if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg)) |
15854ef9 | 1047 | goto try_again; |
15854ef9 JB |
1048 | |
1049 | /* Allocate ucode buffers for card's bus-master loading ... */ | |
1050 | ||
1051 | /* Runtime instructions and 2 copies of data: | |
1052 | * 1) unmodified from disk | |
1053 | * 2) backup cache for save/restore during power-downs */ | |
6dfa8d01 | 1054 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
75813bde JB |
1055 | if (iwl_alloc_ucode(drv, &pieces, i)) |
1056 | goto out_free_fw; | |
15854ef9 JB |
1057 | |
1058 | /* Now that we can no longer fail, copy information */ | |
1059 | ||
1060 | /* | |
1061 | * The (size - 16) / 12 formula is based on the information recorded | |
1062 | * for each event, which is of mode 1 (including timestamp) for all | |
1063 | * new microcodes that include this information. | |
1064 | */ | |
0692fe41 | 1065 | fw->init_evtlog_ptr = pieces.init_evtlog_ptr; |
15854ef9 | 1066 | if (pieces.init_evtlog_size) |
0692fe41 | 1067 | fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
15854ef9 | 1068 | else |
0692fe41 | 1069 | fw->init_evtlog_size = |
68f360dc | 1070 | drv->cfg->base_params->max_event_log_size; |
0692fe41 JB |
1071 | fw->init_errlog_ptr = pieces.init_errlog_ptr; |
1072 | fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; | |
15854ef9 | 1073 | if (pieces.inst_evtlog_size) |
0692fe41 | 1074 | fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
15854ef9 | 1075 | else |
0692fe41 | 1076 | fw->inst_evtlog_size = |
68f360dc | 1077 | drv->cfg->base_params->max_event_log_size; |
0692fe41 | 1078 | fw->inst_errlog_ptr = pieces.inst_errlog_ptr; |
15854ef9 JB |
1079 | |
1080 | /* | |
1081 | * figure out the offset of chain noise reset and gain commands | |
1082 | * base on the size of standard phy calibration commands table size | |
1083 | */ | |
1084 | if (fw->ucode_capa.standard_phy_calibration_size > | |
1085 | IWL_MAX_PHY_CALIBRATE_TBL_SIZE) | |
1086 | fw->ucode_capa.standard_phy_calibration_size = | |
1087 | IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; | |
1088 | ||
1089 | /* We have our copies now, allow OS release its copies */ | |
1090 | release_firmware(ucode_raw); | |
15854ef9 | 1091 | |
ff1ffb85 | 1092 | mutex_lock(&iwlwifi_opmode_table_mtx); |
8ca151b5 JB |
1093 | if (fw->mvm_fw) |
1094 | op = &iwlwifi_opmode_table[MVM_OP_MODE]; | |
1095 | else | |
1096 | op = &iwlwifi_opmode_table[DVM_OP_MODE]; | |
15854ef9 | 1097 | |
2b2719c7 JB |
1098 | IWL_INFO(drv, "loaded firmware version %s op_mode %s\n", |
1099 | drv->fw.fw_version, op->name); | |
1100 | ||
cc5f7e39 DF |
1101 | /* add this device to the list of devices using this op_mode */ |
1102 | list_add_tail(&drv->list, &op->drv); | |
1103 | ||
1104 | if (op->ops) { | |
9da987ac | 1105 | drv->op_mode = _iwl_op_mode_start(drv, op); |
7c9c46c1 | 1106 | |
daf67ce8 DC |
1107 | if (!drv->op_mode) { |
1108 | mutex_unlock(&iwlwifi_opmode_table_mtx); | |
7c9c46c1 | 1109 | goto out_unbind; |
daf67ce8 | 1110 | } |
cc5f7e39 | 1111 | } else { |
d4b10483 | 1112 | load_module = true; |
cc5f7e39 | 1113 | } |
ff1ffb85 | 1114 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
15854ef9 | 1115 | |
f69a23b7 JB |
1116 | /* |
1117 | * Complete the firmware request last so that | |
1118 | * a driver unbind (stop) doesn't run while we | |
1119 | * are doing the start() above. | |
1120 | */ | |
1121 | complete(&drv->request_firmware_complete); | |
d4b10483 JB |
1122 | |
1123 | /* | |
1124 | * Load the module last so we don't block anything | |
1125 | * else from proceeding if the module fails to load | |
1126 | * or hangs loading. | |
1127 | */ | |
1618b2b0 JB |
1128 | if (load_module) { |
1129 | err = request_module("%s", op->name); | |
8edf3fd6 | 1130 | #ifdef CONFIG_IWLWIFI_OPMODE_MODULAR |
1618b2b0 JB |
1131 | if (err) |
1132 | IWL_ERR(drv, | |
1133 | "failed to load module %s (error %d), is dynamic loading enabled?\n", | |
1134 | op->name, err); | |
8edf3fd6 | 1135 | #endif |
1618b2b0 | 1136 | } |
15854ef9 JB |
1137 | return; |
1138 | ||
1139 | try_again: | |
1140 | /* try next, if any */ | |
1141 | release_firmware(ucode_raw); | |
965974a6 | 1142 | if (iwl_request_firmware(drv, false)) |
15854ef9 JB |
1143 | goto out_unbind; |
1144 | return; | |
1145 | ||
75813bde | 1146 | out_free_fw: |
965974a6 JB |
1147 | IWL_ERR(drv, "failed to allocate pci memory\n"); |
1148 | iwl_dealloc_ucode(drv); | |
15854ef9 JB |
1149 | release_firmware(ucode_raw); |
1150 | out_unbind: | |
965974a6 | 1151 | complete(&drv->request_firmware_complete); |
93faaeea | 1152 | device_release_driver(drv->trans->dev); |
15854ef9 JB |
1153 | } |
1154 | ||
87ce05a2 | 1155 | struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, |
9130bab1 | 1156 | const struct iwl_cfg *cfg) |
5c58edc6 | 1157 | { |
965974a6 | 1158 | struct iwl_drv *drv; |
5c58edc6 EG |
1159 | int ret; |
1160 | ||
965974a6 | 1161 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); |
eafe25e0 LC |
1162 | if (!drv) { |
1163 | ret = -ENOMEM; | |
1164 | goto err; | |
1165 | } | |
c15797e6 | 1166 | |
9130bab1 | 1167 | drv->trans = trans; |
4b9844f5 | 1168 | drv->dev = trans->dev; |
68f360dc | 1169 | drv->cfg = cfg; |
5c58edc6 | 1170 | |
965974a6 | 1171 | init_completion(&drv->request_firmware_complete); |
ff1ffb85 | 1172 | INIT_LIST_HEAD(&drv->list); |
5c58edc6 | 1173 | |
9da987ac MV |
1174 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
1175 | /* Create the device debugfs entries. */ | |
1176 | drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev), | |
1177 | iwl_dbgfs_root); | |
1178 | ||
1179 | if (!drv->dbgfs_drv) { | |
1180 | IWL_ERR(drv, "failed to create debugfs directory\n"); | |
59f547ac | 1181 | ret = -ENOMEM; |
9da987ac MV |
1182 | goto err_free_drv; |
1183 | } | |
1184 | ||
1185 | /* Create transport layer debugfs dir */ | |
1186 | drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv); | |
1187 | ||
1188 | if (!drv->trans->dbgfs_dir) { | |
1189 | IWL_ERR(drv, "failed to create transport debugfs directory\n"); | |
59f547ac | 1190 | ret = -ENOMEM; |
9da987ac MV |
1191 | goto err_free_dbgfs; |
1192 | } | |
1193 | #endif | |
1194 | ||
965974a6 | 1195 | ret = iwl_request_firmware(drv, true); |
5c58edc6 | 1196 | if (ret) { |
c15797e6 | 1197 | IWL_ERR(trans, "Couldn't request the fw\n"); |
9da987ac | 1198 | goto err_fw; |
5c58edc6 EG |
1199 | } |
1200 | ||
9da987ac MV |
1201 | return drv; |
1202 | ||
1203 | err_fw: | |
1204 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
1205 | err_free_dbgfs: | |
1206 | debugfs_remove_recursive(drv->dbgfs_drv); | |
1207 | err_free_drv: | |
1208 | #endif | |
1209 | kfree(drv); | |
eafe25e0 | 1210 | err: |
59f547ac | 1211 | return ERR_PTR(ret); |
5c58edc6 EG |
1212 | } |
1213 | ||
9130bab1 | 1214 | void iwl_drv_stop(struct iwl_drv *drv) |
07590f08 | 1215 | { |
965974a6 | 1216 | wait_for_completion(&drv->request_firmware_complete); |
2e7eb117 | 1217 | |
9da987ac | 1218 | _iwl_op_mode_stop(drv); |
07590f08 | 1219 | |
965974a6 | 1220 | iwl_dealloc_ucode(drv); |
7db5b989 | 1221 | |
ff1ffb85 JB |
1222 | mutex_lock(&iwlwifi_opmode_table_mtx); |
1223 | /* | |
1224 | * List is empty (this item wasn't added) | |
1225 | * when firmware loading failed -- in that | |
1226 | * case we can't remove it from any list. | |
1227 | */ | |
1228 | if (!list_empty(&drv->list)) | |
1229 | list_del(&drv->list); | |
1230 | mutex_unlock(&iwlwifi_opmode_table_mtx); | |
1231 | ||
9da987ac MV |
1232 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
1233 | debugfs_remove_recursive(drv->dbgfs_drv); | |
1234 | #endif | |
1235 | ||
965974a6 | 1236 | kfree(drv); |
07590f08 | 1237 | } |
65de7e84 JB |
1238 | |
1239 | ||
1240 | /* shared module parameters */ | |
1241 | struct iwl_mod_params iwlwifi_mod_params = { | |
490953ac | 1242 | .restart_fw = true, |
65de7e84 JB |
1243 | .bt_coex_active = true, |
1244 | .power_level = IWL_POWER_INDEX_1, | |
020c8767 | 1245 | .wd_disable = true, |
65de7e84 JB |
1246 | /* the rest are 0 by default */ |
1247 | }; | |
48e29340 | 1248 | IWL_EXPORT_SYMBOL(iwlwifi_mod_params); |
cc5f7e39 DF |
1249 | |
1250 | int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops) | |
1251 | { | |
1252 | int i; | |
1253 | struct iwl_drv *drv; | |
9da987ac | 1254 | struct iwlwifi_opmode_table *op; |
cc5f7e39 | 1255 | |
ff1ffb85 | 1256 | mutex_lock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 | 1257 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
9da987ac MV |
1258 | op = &iwlwifi_opmode_table[i]; |
1259 | if (strcmp(op->name, name)) | |
cc5f7e39 | 1260 | continue; |
9da987ac MV |
1261 | op->ops = ops; |
1262 | /* TODO: need to handle exceptional case */ | |
1263 | list_for_each_entry(drv, &op->drv, list) | |
1264 | drv->op_mode = _iwl_op_mode_start(drv, op); | |
1265 | ||
ff1ffb85 | 1266 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 DF |
1267 | return 0; |
1268 | } | |
ff1ffb85 | 1269 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 DF |
1270 | return -EIO; |
1271 | } | |
48e29340 | 1272 | IWL_EXPORT_SYMBOL(iwl_opmode_register); |
cc5f7e39 DF |
1273 | |
1274 | void iwl_opmode_deregister(const char *name) | |
1275 | { | |
1276 | int i; | |
1277 | struct iwl_drv *drv; | |
1278 | ||
ff1ffb85 | 1279 | mutex_lock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 DF |
1280 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
1281 | if (strcmp(iwlwifi_opmode_table[i].name, name)) | |
1282 | continue; | |
1283 | iwlwifi_opmode_table[i].ops = NULL; | |
1284 | ||
1285 | /* call the stop routine for all devices */ | |
9da987ac MV |
1286 | list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list) |
1287 | _iwl_op_mode_stop(drv); | |
1288 | ||
ff1ffb85 | 1289 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 DF |
1290 | return; |
1291 | } | |
ff1ffb85 | 1292 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
cc5f7e39 | 1293 | } |
48e29340 | 1294 | IWL_EXPORT_SYMBOL(iwl_opmode_deregister); |
cc5f7e39 DF |
1295 | |
1296 | static int __init iwl_drv_init(void) | |
1297 | { | |
1298 | int i; | |
1299 | ||
ff1ffb85 JB |
1300 | mutex_init(&iwlwifi_opmode_table_mtx); |
1301 | ||
cc5f7e39 DF |
1302 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) |
1303 | INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv); | |
1304 | ||
1305 | pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); | |
1306 | pr_info(DRV_COPYRIGHT "\n"); | |
1307 | ||
9da987ac MV |
1308 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
1309 | /* Create the root of iwlwifi debugfs subsystem. */ | |
1310 | iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL); | |
1311 | ||
1312 | if (!iwl_dbgfs_root) | |
1313 | return -EFAULT; | |
1314 | #endif | |
1315 | ||
cc5f7e39 DF |
1316 | return iwl_pci_register_driver(); |
1317 | } | |
1318 | module_init(iwl_drv_init); | |
1319 | ||
1320 | static void __exit iwl_drv_exit(void) | |
1321 | { | |
1322 | iwl_pci_unregister_driver(); | |
9da987ac MV |
1323 | |
1324 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
1325 | debugfs_remove_recursive(iwl_dbgfs_root); | |
1326 | #endif | |
cc5f7e39 DF |
1327 | } |
1328 | module_exit(iwl_drv_exit); | |
65de7e84 JB |
1329 | |
1330 | #ifdef CONFIG_IWLWIFI_DEBUG | |
1331 | module_param_named(debug, iwlwifi_mod_params.debug_level, uint, | |
1332 | S_IRUGO | S_IWUSR); | |
1333 | MODULE_PARM_DESC(debug, "debug output mask"); | |
1334 | #endif | |
1335 | ||
1336 | module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO); | |
1337 | MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); | |
1338 | module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO); | |
1339 | MODULE_PARM_DESC(11n_disable, | |
205e2210 | 1340 | "disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX"); |
65de7e84 JB |
1341 | module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K, |
1342 | int, S_IRUGO); | |
aed7d9ac | 1343 | MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size (default 0)"); |
490953ac EG |
1344 | module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, bool, S_IRUGO); |
1345 | MODULE_PARM_DESC(fw_restart, "restart firmware in case of error (default true)"); | |
65de7e84 JB |
1346 | |
1347 | module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling, | |
1348 | int, S_IRUGO); | |
1349 | MODULE_PARM_DESC(antenna_coupling, | |
1350 | "specify antenna coupling in dB (defualt: 0 dB)"); | |
1351 | ||
65de7e84 JB |
1352 | module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO); |
1353 | MODULE_PARM_DESC(wd_disable, | |
82b715c2 | 1354 | "Disable stuck queue watchdog timer 0=system default, 1=disable (default: 1)"); |
65de7e84 | 1355 | |
1214755c EH |
1356 | module_param_named(nvm_file, iwlwifi_mod_params.nvm_file, charp, S_IRUGO); |
1357 | MODULE_PARM_DESC(nvm_file, "NVM file name"); | |
1358 | ||
65de7e84 JB |
1359 | /* |
1360 | * set bt_coex_active to true, uCode will do kill/defer | |
1361 | * every time the priority line is asserted (BT is sending signals on the | |
1362 | * priority line in the PCIx). | |
1363 | * set bt_coex_active to false, uCode will ignore the BT activity and | |
1364 | * perform the normal operation | |
1365 | * | |
1366 | * User might experience transmit issue on some platform due to WiFi/BT | |
1367 | * co-exist problem. The possible behaviors are: | |
1368 | * Able to scan and finding all the available AP | |
1369 | * Not able to associate with any AP | |
1370 | * On those platforms, WiFi communication can be restored by set | |
1371 | * "bt_coex_active" module parameter to "false" | |
1372 | * | |
1373 | * default: bt_coex_active = true (BT_COEX_ENABLE) | |
1374 | */ | |
1375 | module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active, | |
1376 | bool, S_IRUGO); | |
1377 | MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); | |
1378 | ||
1379 | module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO); | |
1380 | MODULE_PARM_DESC(led_mode, "0=system default, " | |
1381 | "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)"); | |
1382 | ||
1383 | module_param_named(power_save, iwlwifi_mod_params.power_save, | |
1384 | bool, S_IRUGO); | |
1385 | MODULE_PARM_DESC(power_save, | |
1386 | "enable WiFi power management (default: disable)"); | |
1387 | ||
1388 | module_param_named(power_level, iwlwifi_mod_params.power_level, | |
1389 | int, S_IRUGO); | |
1390 | MODULE_PARM_DESC(power_level, | |
1391 | "default power save level (range from 1 - 5, default: 1)"); |