blob: 48d6d44c16d03053e36f5f04aa9e3baf1db8eaf7 [file] [log] [blame]
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63#include <linux/completion.h>
Johannes Berg15854ef2012-03-05 11:24:50 -080064#include <linux/dma-mapping.h>
65#include <linux/firmware.h>
66#include <linux/module.h>
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +020067
68#include "iwl-drv.h"
Emmanuel Grumbachc15797e2012-04-19 10:29:58 +030069#include "iwl-debug.h"
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +020070#include "iwl-trans.h"
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +020071#include "iwl-op-mode.h"
David Spinadel0cedacc2012-03-10 13:00:12 -080072#include "iwl-agn-hw.h"
Johannes Berg6238b002012-04-02 15:04:33 +020073#include "iwl-fw.h"
74#include "iwl-config.h"
Johannes Berg65de7e82012-04-17 07:36:30 -070075#include "iwl-modparams.h"
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +020076
Johannes Berg0692fe42012-03-06 13:30:37 -080077/* private includes */
Johannes Berg3995dea2012-03-06 13:30:44 -080078#include "iwl-fw-file.h"
Johannes Berg0692fe42012-03-06 13:30:37 -080079
Don Frycc5f7e32012-05-16 22:54:27 +020080/******************************************************************************
81 *
82 * module boiler plate
83 *
84 ******************************************************************************/
85
86/*
87 * module name, copyright, version, etc.
88 */
89#define DRV_DESCRIPTION "Intel(R) Wireless WiFi driver for Linux"
90
91#ifdef CONFIG_IWLWIFI_DEBUG
92#define VD "d"
93#else
94#define VD
95#endif
96
97#define DRV_VERSION IWLWIFI_VERSION VD
98
99MODULE_DESCRIPTION(DRV_DESCRIPTION);
100MODULE_VERSION(DRV_VERSION);
101MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
102MODULE_LICENSE("GPL");
103
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -0700104#ifdef CONFIG_IWLWIFI_DEBUGFS
105static struct dentry *iwl_dbgfs_root;
106#endif
107
Johannes Berg965974a2012-03-06 13:30:38 -0800108/**
109 * struct iwl_drv - drv common data
Don Frycc5f7e32012-05-16 22:54:27 +0200110 * @list: list of drv structures using this opmode
Johannes Berg965974a2012-03-06 13:30:38 -0800111 * @fw: the iwl_fw structure
Johannes Berg965974a2012-03-06 13:30:38 -0800112 * @op_mode: the running op_mode
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200113 * @trans: transport layer
Emmanuel Grumbach4b9844f2012-03-22 23:59:52 +0200114 * @dev: for debug prints only
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200115 * @cfg: configuration struct
Johannes Berg965974a2012-03-06 13:30:38 -0800116 * @fw_index: firmware revision to try loading
117 * @firmware_name: composite filename of ucode file to load
118 * @request_firmware_complete: the firmware has been obtained from user space
119 */
120struct iwl_drv {
Don Frycc5f7e32012-05-16 22:54:27 +0200121 struct list_head list;
Johannes Berg965974a2012-03-06 13:30:38 -0800122 struct iwl_fw fw;
123
Johannes Berg965974a2012-03-06 13:30:38 -0800124 struct iwl_op_mode *op_mode;
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -0700125 struct iwl_trans *trans;
Emmanuel Grumbach4b9844f2012-03-22 23:59:52 +0200126 struct device *dev;
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200127 const struct iwl_cfg *cfg;
Johannes Berg965974a2012-03-06 13:30:38 -0800128
129 int fw_index; /* firmware we're trying to load */
130 char firmware_name[25]; /* name of firmware file to load */
131
132 struct completion request_firmware_complete;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -0700133
134#ifdef CONFIG_IWLWIFI_DEBUGFS
135 struct dentry *dbgfs_drv;
136 struct dentry *dbgfs_trans;
137 struct dentry *dbgfs_op_mode;
138#endif
Johannes Berg965974a2012-03-06 13:30:38 -0800139};
140
Don Frycc5f7e32012-05-16 22:54:27 +0200141#define DVM_OP_MODE 0
142#define MVM_OP_MODE 1
Johannes Berg965974a2012-03-06 13:30:38 -0800143
Johannes Bergff1ffb82012-06-06 09:42:57 +0200144/* Protects the table contents, i.e. the ops pointer & drv list */
145static struct mutex iwlwifi_opmode_table_mtx;
Don Frycc5f7e32012-05-16 22:54:27 +0200146static struct iwlwifi_opmode_table {
147 const char *name; /* name: iwldvm, iwlmvm, etc */
148 const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */
149 struct list_head drv; /* list of devices using this op_mode */
150} iwlwifi_opmode_table[] = { /* ops set when driver is initialized */
151 { .name = "iwldvm", .ops = NULL },
152 { .name = "iwlmvm", .ops = NULL },
153};
Johannes Berg965974a2012-03-06 13:30:38 -0800154
David Spinadel0cedacc2012-03-10 13:00:12 -0800155/*
156 * struct fw_sec: Just for the image parsing proccess.
157 * For the fw storage we are using struct fw_desc.
158 */
159struct fw_sec {
160 const void *data; /* the sec data */
161 size_t size; /* section size */
162 u32 offset; /* offset of writing in the device */
163};
164
Johannes Berg965974a2012-03-06 13:30:38 -0800165static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
Johannes Berg15854ef2012-03-05 11:24:50 -0800166{
167 if (desc->v_addr)
Emmanuel Grumbach93faaee2012-03-22 17:51:44 +0200168 dma_free_coherent(drv->trans->dev, desc->len,
Johannes Berg15854ef2012-03-05 11:24:50 -0800169 desc->v_addr, desc->p_addr);
170 desc->v_addr = NULL;
171 desc->len = 0;
172}
173
Johannes Berg965974a2012-03-06 13:30:38 -0800174static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
Johannes Berg15854ef2012-03-05 11:24:50 -0800175{
David Spinadel6dfa8d02012-03-10 13:00:14 -0800176 int i;
177 for (i = 0; i < IWL_UCODE_SECTION_MAX; i++)
178 iwl_free_fw_desc(drv, &img->sec[i]);
Johannes Berg15854ef2012-03-05 11:24:50 -0800179}
180
Johannes Berg965974a2012-03-06 13:30:38 -0800181static void iwl_dealloc_ucode(struct iwl_drv *drv)
Johannes Berg15854ef2012-03-05 11:24:50 -0800182{
David Spinadel6dfa8d02012-03-10 13:00:14 -0800183 int i;
184 for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
185 iwl_free_fw_img(drv, drv->fw.img + i);
Johannes Berg15854ef2012-03-05 11:24:50 -0800186}
187
Johannes Berg965974a2012-03-06 13:30:38 -0800188static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
David Spinadel0cedacc2012-03-10 13:00:12 -0800189 struct fw_sec *sec)
Johannes Berg15854ef2012-03-05 11:24:50 -0800190{
David Spinadel0cedacc2012-03-10 13:00:12 -0800191 if (!sec || !sec->size) {
Johannes Berg15854ef2012-03-05 11:24:50 -0800192 desc->v_addr = NULL;
193 return -EINVAL;
194 }
195
Emmanuel Grumbach93faaee2012-03-22 17:51:44 +0200196 desc->v_addr = dma_alloc_coherent(drv->trans->dev, sec->size,
Johannes Berg15854ef2012-03-05 11:24:50 -0800197 &desc->p_addr, GFP_KERNEL);
198 if (!desc->v_addr)
199 return -ENOMEM;
200
David Spinadel0cedacc2012-03-10 13:00:12 -0800201 desc->len = sec->size;
202 desc->offset = sec->offset;
203 memcpy(desc->v_addr, sec->data, sec->size);
Johannes Berg15854ef2012-03-05 11:24:50 -0800204 return 0;
205}
206
Emmanuel Grumbach1c8e11e2012-07-16 12:31:28 +0300207static void iwl_req_fw_callback(const struct firmware *ucode_raw,
208 void *context);
Johannes Berg15854ef2012-03-05 11:24:50 -0800209
210#define UCODE_EXPERIMENTAL_INDEX 100
211#define UCODE_EXPERIMENTAL_TAG "exp"
212
Johannes Berg965974a2012-03-06 13:30:38 -0800213static int iwl_request_firmware(struct iwl_drv *drv, bool first)
Johannes Berg15854ef2012-03-05 11:24:50 -0800214{
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200215 const char *name_pre = drv->cfg->fw_name_pre;
Johannes Berg15854ef2012-03-05 11:24:50 -0800216 char tag[8];
217
218 if (first) {
219#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
Johannes Berg965974a2012-03-06 13:30:38 -0800220 drv->fw_index = UCODE_EXPERIMENTAL_INDEX;
Johannes Berg15854ef2012-03-05 11:24:50 -0800221 strcpy(tag, UCODE_EXPERIMENTAL_TAG);
Johannes Berg965974a2012-03-06 13:30:38 -0800222 } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
Johannes Berg15854ef2012-03-05 11:24:50 -0800223#endif
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200224 drv->fw_index = drv->cfg->ucode_api_max;
Johannes Berg965974a2012-03-06 13:30:38 -0800225 sprintf(tag, "%d", drv->fw_index);
Johannes Berg15854ef2012-03-05 11:24:50 -0800226 } else {
Johannes Berg965974a2012-03-06 13:30:38 -0800227 drv->fw_index--;
228 sprintf(tag, "%d", drv->fw_index);
Johannes Berg15854ef2012-03-05 11:24:50 -0800229 }
230
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200231 if (drv->fw_index < drv->cfg->ucode_api_min) {
Johannes Berg965974a2012-03-06 13:30:38 -0800232 IWL_ERR(drv, "no suitable firmware found!\n");
Johannes Berg15854ef2012-03-05 11:24:50 -0800233 return -ENOENT;
234 }
235
Johannes Berg965974a2012-03-06 13:30:38 -0800236 sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
Johannes Berg15854ef2012-03-05 11:24:50 -0800237
Johannes Berg965974a2012-03-06 13:30:38 -0800238 IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
239 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
Johannes Berg15854ef2012-03-05 11:24:50 -0800240 ? "EXPERIMENTAL " : "",
Johannes Berg965974a2012-03-06 13:30:38 -0800241 drv->firmware_name);
Johannes Berg15854ef2012-03-05 11:24:50 -0800242
Johannes Berg965974a2012-03-06 13:30:38 -0800243 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
Emmanuel Grumbach93faaee2012-03-22 17:51:44 +0200244 drv->trans->dev,
Emmanuel Grumbach1c8e11e2012-07-16 12:31:28 +0300245 GFP_KERNEL, drv, iwl_req_fw_callback);
Johannes Berg15854ef2012-03-05 11:24:50 -0800246}
247
David Spinadel0cedacc2012-03-10 13:00:12 -0800248struct fw_img_parsing {
David Spinadel6dfa8d02012-03-10 13:00:14 -0800249 struct fw_sec sec[IWL_UCODE_SECTION_MAX];
David Spinadel0cedacc2012-03-10 13:00:12 -0800250 int sec_counter;
251};
252
David Spinadeled8c8362012-03-10 13:00:13 -0800253/*
254 * struct fw_sec_parsing: to extract fw section and it's offset from tlv
255 */
256struct fw_sec_parsing {
257 __le32 offset;
258 const u8 data[];
259} __packed;
260
261/**
262 * struct iwl_tlv_calib_data - parse the default calib data from TLV
263 *
264 * @ucode_type: the uCode to which the following default calib relates.
265 * @calib: default calibrations.
266 */
267struct iwl_tlv_calib_data {
268 __le32 ucode_type;
269 __le64 calib;
270} __packed;
271
David Spinadel0cedacc2012-03-10 13:00:12 -0800272struct iwl_firmware_pieces {
273 struct fw_img_parsing img[IWL_UCODE_TYPE_MAX];
Johannes Berg15854ef2012-03-05 11:24:50 -0800274
275 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
276 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
277};
278
David Spinadel0cedacc2012-03-10 13:00:12 -0800279/*
280 * These functions are just to extract uCode section data from the pieces
281 * structure.
282 */
283static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces,
284 enum iwl_ucode_type type,
285 int sec)
286{
287 return &pieces->img[type].sec[sec];
288}
289
290static void set_sec_data(struct iwl_firmware_pieces *pieces,
291 enum iwl_ucode_type type,
292 int sec,
293 const void *data)
294{
295 pieces->img[type].sec[sec].data = data;
296}
297
298static void set_sec_size(struct iwl_firmware_pieces *pieces,
299 enum iwl_ucode_type type,
300 int sec,
301 size_t size)
302{
303 pieces->img[type].sec[sec].size = size;
304}
305
306static size_t get_sec_size(struct iwl_firmware_pieces *pieces,
307 enum iwl_ucode_type type,
308 int sec)
309{
310 return pieces->img[type].sec[sec].size;
311}
312
313static void set_sec_offset(struct iwl_firmware_pieces *pieces,
314 enum iwl_ucode_type type,
315 int sec,
316 u32 offset)
317{
318 pieces->img[type].sec[sec].offset = offset;
319}
320
David Spinadeled8c8362012-03-10 13:00:13 -0800321/*
322 * Gets uCode section from tlv.
323 */
324static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces,
325 const void *data, enum iwl_ucode_type type,
326 int size)
327{
328 struct fw_img_parsing *img;
329 struct fw_sec *sec;
330 struct fw_sec_parsing *sec_parse;
331
332 if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX))
333 return -1;
334
335 sec_parse = (struct fw_sec_parsing *)data;
336
337 img = &pieces->img[type];
338 sec = &img->sec[img->sec_counter];
339
340 sec->offset = le32_to_cpu(sec_parse->offset);
341 sec->data = sec_parse->data;
David Spinadel1176f432012-03-13 14:32:48 +0200342 sec->size = size - sizeof(sec_parse->offset);
David Spinadeled8c8362012-03-10 13:00:13 -0800343
344 ++img->sec_counter;
345
346 return 0;
347}
348
349static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data)
350{
351 struct iwl_tlv_calib_data *def_calib =
352 (struct iwl_tlv_calib_data *)data;
353 u32 ucode_type = le32_to_cpu(def_calib->ucode_type);
354 if (ucode_type >= IWL_UCODE_TYPE_MAX) {
355 IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n",
356 ucode_type);
357 return -EINVAL;
358 }
359 drv->fw.default_calib[ucode_type] = le64_to_cpu(def_calib->calib);
360 return 0;
361}
362
Johannes Berg965974a2012-03-06 13:30:38 -0800363static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
David Spinadel0cedacc2012-03-10 13:00:12 -0800364 const struct firmware *ucode_raw,
365 struct iwl_firmware_pieces *pieces)
Johannes Berg15854ef2012-03-05 11:24:50 -0800366{
367 struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
368 u32 api_ver, hdr_size, build;
369 char buildstr[25];
370 const u8 *src;
371
Johannes Berg965974a2012-03-06 13:30:38 -0800372 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
373 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
Johannes Berg15854ef2012-03-05 11:24:50 -0800374
375 switch (api_ver) {
376 default:
377 hdr_size = 28;
378 if (ucode_raw->size < hdr_size) {
Johannes Berg965974a2012-03-06 13:30:38 -0800379 IWL_ERR(drv, "File size too small!\n");
Johannes Berg15854ef2012-03-05 11:24:50 -0800380 return -EINVAL;
381 }
382 build = le32_to_cpu(ucode->u.v2.build);
David Spinadel0cedacc2012-03-10 13:00:12 -0800383 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
384 le32_to_cpu(ucode->u.v2.inst_size));
385 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
386 le32_to_cpu(ucode->u.v2.data_size));
387 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
388 le32_to_cpu(ucode->u.v2.init_size));
389 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
390 le32_to_cpu(ucode->u.v2.init_data_size));
Johannes Berg15854ef2012-03-05 11:24:50 -0800391 src = ucode->u.v2.data;
392 break;
393 case 0:
394 case 1:
395 case 2:
396 hdr_size = 24;
397 if (ucode_raw->size < hdr_size) {
Johannes Berg965974a2012-03-06 13:30:38 -0800398 IWL_ERR(drv, "File size too small!\n");
Johannes Berg15854ef2012-03-05 11:24:50 -0800399 return -EINVAL;
400 }
401 build = 0;
David Spinadel0cedacc2012-03-10 13:00:12 -0800402 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
403 le32_to_cpu(ucode->u.v1.inst_size));
404 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
405 le32_to_cpu(ucode->u.v1.data_size));
406 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
407 le32_to_cpu(ucode->u.v1.init_size));
408 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
409 le32_to_cpu(ucode->u.v1.init_data_size));
Johannes Berg15854ef2012-03-05 11:24:50 -0800410 src = ucode->u.v1.data;
411 break;
412 }
413
414 if (build)
415 sprintf(buildstr, " build %u%s", build,
Johannes Berg965974a2012-03-06 13:30:38 -0800416 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
Johannes Berg15854ef2012-03-05 11:24:50 -0800417 ? " (EXP)" : "");
418 else
419 buildstr[0] = '\0';
420
Johannes Berg965974a2012-03-06 13:30:38 -0800421 snprintf(drv->fw.fw_version,
422 sizeof(drv->fw.fw_version),
Johannes Berg15854ef2012-03-05 11:24:50 -0800423 "%u.%u.%u.%u%s",
Johannes Berg965974a2012-03-06 13:30:38 -0800424 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
425 IWL_UCODE_MINOR(drv->fw.ucode_ver),
426 IWL_UCODE_API(drv->fw.ucode_ver),
427 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
Johannes Berg15854ef2012-03-05 11:24:50 -0800428 buildstr);
429
430 /* Verify size of file vs. image size info in file's header */
David Spinadel0cedacc2012-03-10 13:00:12 -0800431
432 if (ucode_raw->size != hdr_size +
433 get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) +
434 get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) +
435 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) +
436 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
Johannes Berg15854ef2012-03-05 11:24:50 -0800437
Johannes Berg965974a2012-03-06 13:30:38 -0800438 IWL_ERR(drv,
Johannes Berg15854ef2012-03-05 11:24:50 -0800439 "uCode file size %d does not match expected size\n",
440 (int)ucode_raw->size);
441 return -EINVAL;
442 }
443
Johannes Berg15854ef2012-03-05 11:24:50 -0800444
David Spinadel0cedacc2012-03-10 13:00:12 -0800445 set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src);
446 src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST);
447 set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
448 IWLAGN_RTC_INST_LOWER_BOUND);
449 set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src);
450 src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA);
451 set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
452 IWLAGN_RTC_DATA_LOWER_BOUND);
453 set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src);
454 src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST);
455 set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
456 IWLAGN_RTC_INST_LOWER_BOUND);
457 set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src);
458 src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA);
459 set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
460 IWLAGN_RTC_DATA_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800461 return 0;
462}
463
Johannes Berg965974a2012-03-06 13:30:38 -0800464static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
Johannes Berg15854ef2012-03-05 11:24:50 -0800465 const struct firmware *ucode_raw,
David Spinadel0cedacc2012-03-10 13:00:12 -0800466 struct iwl_firmware_pieces *pieces,
Johannes Berg15854ef2012-03-05 11:24:50 -0800467 struct iwl_ucode_capabilities *capa)
468{
469 struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
470 struct iwl_ucode_tlv *tlv;
471 size_t len = ucode_raw->size;
472 const u8 *data;
Johannes Berg15854ef2012-03-05 11:24:50 -0800473 u32 tlv_len;
474 enum iwl_ucode_tlv_type tlv_type;
475 const u8 *tlv_data;
476 char buildstr[25];
477 u32 build;
478
479 if (len < sizeof(*ucode)) {
Johannes Berg965974a2012-03-06 13:30:38 -0800480 IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
Johannes Berg15854ef2012-03-05 11:24:50 -0800481 return -EINVAL;
482 }
483
484 if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
Johannes Berg965974a2012-03-06 13:30:38 -0800485 IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
Johannes Berg15854ef2012-03-05 11:24:50 -0800486 le32_to_cpu(ucode->magic));
487 return -EINVAL;
488 }
489
Johannes Berg965974a2012-03-06 13:30:38 -0800490 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
Johannes Berg15854ef2012-03-05 11:24:50 -0800491 build = le32_to_cpu(ucode->build);
492
493 if (build)
494 sprintf(buildstr, " build %u%s", build,
Johannes Berg965974a2012-03-06 13:30:38 -0800495 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
Johannes Berg15854ef2012-03-05 11:24:50 -0800496 ? " (EXP)" : "");
497 else
498 buildstr[0] = '\0';
499
Johannes Berg965974a2012-03-06 13:30:38 -0800500 snprintf(drv->fw.fw_version,
501 sizeof(drv->fw.fw_version),
Johannes Berg15854ef2012-03-05 11:24:50 -0800502 "%u.%u.%u.%u%s",
Johannes Berg965974a2012-03-06 13:30:38 -0800503 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
504 IWL_UCODE_MINOR(drv->fw.ucode_ver),
505 IWL_UCODE_API(drv->fw.ucode_ver),
506 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
Johannes Berg15854ef2012-03-05 11:24:50 -0800507 buildstr);
508
509 data = ucode->data;
510
511 len -= sizeof(*ucode);
512
513 while (len >= sizeof(*tlv)) {
Johannes Berg15854ef2012-03-05 11:24:50 -0800514 len -= sizeof(*tlv);
515 tlv = (void *)data;
516
517 tlv_len = le32_to_cpu(tlv->length);
Johannes Berg0479c192012-03-09 09:16:35 +0100518 tlv_type = le32_to_cpu(tlv->type);
Johannes Berg15854ef2012-03-05 11:24:50 -0800519 tlv_data = tlv->data;
520
521 if (len < tlv_len) {
Johannes Berg965974a2012-03-06 13:30:38 -0800522 IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
Johannes Berg15854ef2012-03-05 11:24:50 -0800523 len, tlv_len);
524 return -EINVAL;
525 }
526 len -= ALIGN(tlv_len, 4);
527 data += sizeof(*tlv) + ALIGN(tlv_len, 4);
528
Johannes Berg15854ef2012-03-05 11:24:50 -0800529 switch (tlv_type) {
530 case IWL_UCODE_TLV_INST:
David Spinadel0cedacc2012-03-10 13:00:12 -0800531 set_sec_data(pieces, IWL_UCODE_REGULAR,
532 IWL_UCODE_SECTION_INST, tlv_data);
533 set_sec_size(pieces, IWL_UCODE_REGULAR,
534 IWL_UCODE_SECTION_INST, tlv_len);
535 set_sec_offset(pieces, IWL_UCODE_REGULAR,
536 IWL_UCODE_SECTION_INST,
537 IWLAGN_RTC_INST_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800538 break;
539 case IWL_UCODE_TLV_DATA:
David Spinadel0cedacc2012-03-10 13:00:12 -0800540 set_sec_data(pieces, IWL_UCODE_REGULAR,
541 IWL_UCODE_SECTION_DATA, tlv_data);
542 set_sec_size(pieces, IWL_UCODE_REGULAR,
543 IWL_UCODE_SECTION_DATA, tlv_len);
544 set_sec_offset(pieces, IWL_UCODE_REGULAR,
545 IWL_UCODE_SECTION_DATA,
546 IWLAGN_RTC_DATA_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800547 break;
548 case IWL_UCODE_TLV_INIT:
David Spinadel0cedacc2012-03-10 13:00:12 -0800549 set_sec_data(pieces, IWL_UCODE_INIT,
550 IWL_UCODE_SECTION_INST, tlv_data);
551 set_sec_size(pieces, IWL_UCODE_INIT,
552 IWL_UCODE_SECTION_INST, tlv_len);
553 set_sec_offset(pieces, IWL_UCODE_INIT,
554 IWL_UCODE_SECTION_INST,
555 IWLAGN_RTC_INST_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800556 break;
557 case IWL_UCODE_TLV_INIT_DATA:
David Spinadel0cedacc2012-03-10 13:00:12 -0800558 set_sec_data(pieces, IWL_UCODE_INIT,
559 IWL_UCODE_SECTION_DATA, tlv_data);
560 set_sec_size(pieces, IWL_UCODE_INIT,
561 IWL_UCODE_SECTION_DATA, tlv_len);
562 set_sec_offset(pieces, IWL_UCODE_INIT,
563 IWL_UCODE_SECTION_DATA,
564 IWLAGN_RTC_DATA_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800565 break;
566 case IWL_UCODE_TLV_BOOT:
Johannes Berg965974a2012-03-06 13:30:38 -0800567 IWL_ERR(drv, "Found unexpected BOOT ucode\n");
Johannes Berg15854ef2012-03-05 11:24:50 -0800568 break;
569 case IWL_UCODE_TLV_PROBE_MAX_LEN:
570 if (tlv_len != sizeof(u32))
571 goto invalid_tlv_len;
572 capa->max_probe_length =
573 le32_to_cpup((__le32 *)tlv_data);
574 break;
575 case IWL_UCODE_TLV_PAN:
576 if (tlv_len)
577 goto invalid_tlv_len;
578 capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
579 break;
580 case IWL_UCODE_TLV_FLAGS:
581 /* must be at least one u32 */
582 if (tlv_len < sizeof(u32))
583 goto invalid_tlv_len;
584 /* and a proper number of u32s */
585 if (tlv_len % sizeof(u32))
586 goto invalid_tlv_len;
587 /*
588 * This driver only reads the first u32 as
589 * right now no more features are defined,
590 * if that changes then either the driver
591 * will not work with the new firmware, or
592 * it'll not take advantage of new features.
593 */
594 capa->flags = le32_to_cpup((__le32 *)tlv_data);
595 break;
596 case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
597 if (tlv_len != sizeof(u32))
598 goto invalid_tlv_len;
599 pieces->init_evtlog_ptr =
600 le32_to_cpup((__le32 *)tlv_data);
601 break;
602 case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
603 if (tlv_len != sizeof(u32))
604 goto invalid_tlv_len;
605 pieces->init_evtlog_size =
606 le32_to_cpup((__le32 *)tlv_data);
607 break;
608 case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
609 if (tlv_len != sizeof(u32))
610 goto invalid_tlv_len;
611 pieces->init_errlog_ptr =
612 le32_to_cpup((__le32 *)tlv_data);
613 break;
614 case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
615 if (tlv_len != sizeof(u32))
616 goto invalid_tlv_len;
617 pieces->inst_evtlog_ptr =
618 le32_to_cpup((__le32 *)tlv_data);
619 break;
620 case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
621 if (tlv_len != sizeof(u32))
622 goto invalid_tlv_len;
623 pieces->inst_evtlog_size =
624 le32_to_cpup((__le32 *)tlv_data);
625 break;
626 case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
627 if (tlv_len != sizeof(u32))
628 goto invalid_tlv_len;
629 pieces->inst_errlog_ptr =
630 le32_to_cpup((__le32 *)tlv_data);
631 break;
632 case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
633 if (tlv_len)
634 goto invalid_tlv_len;
Johannes Berg965974a2012-03-06 13:30:38 -0800635 drv->fw.enhance_sensitivity_table = true;
Johannes Berg15854ef2012-03-05 11:24:50 -0800636 break;
637 case IWL_UCODE_TLV_WOWLAN_INST:
David Spinadel0cedacc2012-03-10 13:00:12 -0800638 set_sec_data(pieces, IWL_UCODE_WOWLAN,
639 IWL_UCODE_SECTION_INST, tlv_data);
640 set_sec_size(pieces, IWL_UCODE_WOWLAN,
641 IWL_UCODE_SECTION_INST, tlv_len);
642 set_sec_offset(pieces, IWL_UCODE_WOWLAN,
643 IWL_UCODE_SECTION_INST,
644 IWLAGN_RTC_INST_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800645 break;
646 case IWL_UCODE_TLV_WOWLAN_DATA:
David Spinadel0cedacc2012-03-10 13:00:12 -0800647 set_sec_data(pieces, IWL_UCODE_WOWLAN,
648 IWL_UCODE_SECTION_DATA, tlv_data);
649 set_sec_size(pieces, IWL_UCODE_WOWLAN,
650 IWL_UCODE_SECTION_DATA, tlv_len);
651 set_sec_offset(pieces, IWL_UCODE_WOWLAN,
652 IWL_UCODE_SECTION_DATA,
653 IWLAGN_RTC_DATA_LOWER_BOUND);
Johannes Berg15854ef2012-03-05 11:24:50 -0800654 break;
655 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
656 if (tlv_len != sizeof(u32))
657 goto invalid_tlv_len;
658 capa->standard_phy_calibration_size =
659 le32_to_cpup((__le32 *)tlv_data);
660 break;
David Spinadeled8c8362012-03-10 13:00:13 -0800661 case IWL_UCODE_TLV_SEC_RT:
662 iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
663 tlv_len);
David Spinadel4db2c9a2012-03-10 13:00:15 -0800664 drv->fw.mvm_fw = true;
David Spinadeled8c8362012-03-10 13:00:13 -0800665 break;
666 case IWL_UCODE_TLV_SEC_INIT:
667 iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
668 tlv_len);
David Spinadel4db2c9a2012-03-10 13:00:15 -0800669 drv->fw.mvm_fw = true;
David Spinadeled8c8362012-03-10 13:00:13 -0800670 break;
671 case IWL_UCODE_TLV_SEC_WOWLAN:
672 iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
673 tlv_len);
David Spinadel4db2c9a2012-03-10 13:00:15 -0800674 drv->fw.mvm_fw = true;
David Spinadeled8c8362012-03-10 13:00:13 -0800675 break;
676 case IWL_UCODE_TLV_DEF_CALIB:
677 if (tlv_len != sizeof(struct iwl_tlv_calib_data))
678 goto invalid_tlv_len;
679 if (iwl_set_default_calib(drv, tlv_data))
680 goto tlv_error;
681 break;
682 case IWL_UCODE_TLV_PHY_SKU:
683 if (tlv_len != sizeof(u32))
684 goto invalid_tlv_len;
685 drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data);
686 break;
Johannes Berg15854ef2012-03-05 11:24:50 -0800687 default:
Johannes Berg965974a2012-03-06 13:30:38 -0800688 IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
Johannes Berg15854ef2012-03-05 11:24:50 -0800689 break;
690 }
691 }
692
693 if (len) {
Johannes Berg965974a2012-03-06 13:30:38 -0800694 IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
695 iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
Johannes Berg15854ef2012-03-05 11:24:50 -0800696 return -EINVAL;
697 }
698
699 return 0;
700
701 invalid_tlv_len:
Johannes Berg965974a2012-03-06 13:30:38 -0800702 IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
David Spinadeled8c8362012-03-10 13:00:13 -0800703 tlv_error:
Johannes Berg965974a2012-03-06 13:30:38 -0800704 iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
Johannes Berg15854ef2012-03-05 11:24:50 -0800705
706 return -EINVAL;
707}
708
Johannes Berg75813bd2012-05-16 22:49:49 +0200709static int iwl_alloc_ucode(struct iwl_drv *drv,
710 struct iwl_firmware_pieces *pieces,
711 enum iwl_ucode_type type)
David Spinadel6dfa8d02012-03-10 13:00:14 -0800712{
713 int i;
714 for (i = 0;
715 i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i);
716 i++)
717 if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]),
Johannes Berg75813bd2012-05-16 22:49:49 +0200718 get_sec(pieces, type, i)))
719 return -ENOMEM;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800720 return 0;
721}
722
723static int validate_sec_sizes(struct iwl_drv *drv,
724 struct iwl_firmware_pieces *pieces,
725 const struct iwl_cfg *cfg)
726{
727 IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
728 get_sec_size(pieces, IWL_UCODE_REGULAR,
729 IWL_UCODE_SECTION_INST));
730 IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
731 get_sec_size(pieces, IWL_UCODE_REGULAR,
732 IWL_UCODE_SECTION_DATA));
733 IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
734 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST));
735 IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
736 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA));
737
738 /* Verify that uCode images will fit in card's SRAM. */
739 if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) >
740 cfg->max_inst_size) {
741 IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
742 get_sec_size(pieces, IWL_UCODE_REGULAR,
743 IWL_UCODE_SECTION_INST));
744 return -1;
745 }
746
747 if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) >
748 cfg->max_data_size) {
749 IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
750 get_sec_size(pieces, IWL_UCODE_REGULAR,
751 IWL_UCODE_SECTION_DATA));
752 return -1;
753 }
754
755 if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) >
756 cfg->max_inst_size) {
757 IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
758 get_sec_size(pieces, IWL_UCODE_INIT,
759 IWL_UCODE_SECTION_INST));
760 return -1;
761 }
762
763 if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) >
764 cfg->max_data_size) {
765 IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
766 get_sec_size(pieces, IWL_UCODE_REGULAR,
767 IWL_UCODE_SECTION_DATA));
768 return -1;
769 }
770 return 0;
771}
772
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -0700773static struct iwl_op_mode *
774_iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op)
775{
776 const struct iwl_op_mode_ops *ops = op->ops;
777 struct dentry *dbgfs_dir = NULL;
778 struct iwl_op_mode *op_mode = NULL;
779
780#ifdef CONFIG_IWLWIFI_DEBUGFS
781 drv->dbgfs_op_mode = debugfs_create_dir(op->name,
782 drv->dbgfs_drv);
783 if (!drv->dbgfs_op_mode) {
784 IWL_ERR(drv,
785 "failed to create opmode debugfs directory\n");
786 return op_mode;
787 }
788 dbgfs_dir = drv->dbgfs_op_mode;
789#endif
790
791 op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir);
792
793#ifdef CONFIG_IWLWIFI_DEBUGFS
794 if (!op_mode) {
795 debugfs_remove_recursive(drv->dbgfs_op_mode);
796 drv->dbgfs_op_mode = NULL;
797 }
798#endif
799
800 return op_mode;
801}
802
803static void _iwl_op_mode_stop(struct iwl_drv *drv)
804{
805 /* op_mode can be NULL if its start failed */
806 if (drv->op_mode) {
807 iwl_op_mode_stop(drv->op_mode);
808 drv->op_mode = NULL;
809
810#ifdef CONFIG_IWLWIFI_DEBUGFS
811 debugfs_remove_recursive(drv->dbgfs_op_mode);
812 drv->dbgfs_op_mode = NULL;
813#endif
814 }
815}
816
Johannes Berg15854ef2012-03-05 11:24:50 -0800817/**
Emmanuel Grumbach1c8e11e2012-07-16 12:31:28 +0300818 * iwl_req_fw_callback - callback when firmware was loaded
Johannes Berg15854ef2012-03-05 11:24:50 -0800819 *
820 * If loaded successfully, copies the firmware into buffers
821 * for the card to fetch (via DMA).
822 */
Emmanuel Grumbach1c8e11e2012-07-16 12:31:28 +0300823static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
Johannes Berg15854ef2012-03-05 11:24:50 -0800824{
Johannes Berg965974a2012-03-06 13:30:38 -0800825 struct iwl_drv *drv = context;
Johannes Berg965974a2012-03-06 13:30:38 -0800826 struct iwl_fw *fw = &drv->fw;
Johannes Berg15854ef2012-03-05 11:24:50 -0800827 struct iwl_ucode_header *ucode;
Don Frycc5f7e32012-05-16 22:54:27 +0200828 struct iwlwifi_opmode_table *op;
Johannes Berg15854ef2012-03-05 11:24:50 -0800829 int err;
David Spinadel0cedacc2012-03-10 13:00:12 -0800830 struct iwl_firmware_pieces pieces;
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200831 const unsigned int api_max = drv->cfg->ucode_api_max;
832 unsigned int api_ok = drv->cfg->ucode_api_ok;
833 const unsigned int api_min = drv->cfg->ucode_api_min;
Johannes Berg15854ef2012-03-05 11:24:50 -0800834 u32 api_ver;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800835 int i;
Johannes Bergd4b10482012-06-12 19:50:43 +0200836 bool load_module = false;
Johannes Berg15854ef2012-03-05 11:24:50 -0800837
838 fw->ucode_capa.max_probe_length = 200;
839 fw->ucode_capa.standard_phy_calibration_size =
840 IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
841
842 if (!api_ok)
843 api_ok = api_max;
844
845 memset(&pieces, 0, sizeof(pieces));
846
847 if (!ucode_raw) {
Johannes Berg965974a2012-03-06 13:30:38 -0800848 if (drv->fw_index <= api_ok)
849 IWL_ERR(drv,
Johannes Berg15854ef2012-03-05 11:24:50 -0800850 "request for firmware file '%s' failed.\n",
Johannes Berg965974a2012-03-06 13:30:38 -0800851 drv->firmware_name);
Johannes Berg15854ef2012-03-05 11:24:50 -0800852 goto try_again;
853 }
854
Johannes Berg965974a2012-03-06 13:30:38 -0800855 IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
856 drv->firmware_name, ucode_raw->size);
Johannes Berg15854ef2012-03-05 11:24:50 -0800857
858 /* Make sure that we got at least the API version number */
859 if (ucode_raw->size < 4) {
Johannes Berg965974a2012-03-06 13:30:38 -0800860 IWL_ERR(drv, "File size way too small!\n");
Johannes Berg15854ef2012-03-05 11:24:50 -0800861 goto try_again;
862 }
863
864 /* Data from ucode file: header followed by uCode images */
865 ucode = (struct iwl_ucode_header *)ucode_raw->data;
866
867 if (ucode->ver)
Johannes Berg965974a2012-03-06 13:30:38 -0800868 err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces);
Johannes Berg15854ef2012-03-05 11:24:50 -0800869 else
Johannes Berg965974a2012-03-06 13:30:38 -0800870 err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces,
Johannes Berg15854ef2012-03-05 11:24:50 -0800871 &fw->ucode_capa);
872
873 if (err)
874 goto try_again;
875
Johannes Berg965974a2012-03-06 13:30:38 -0800876 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
Johannes Berg15854ef2012-03-05 11:24:50 -0800877
878 /*
879 * api_ver should match the api version forming part of the
880 * firmware filename ... but we don't check for that and only rely
881 * on the API version read from firmware header from here on forward
882 */
883 /* no api version check required for experimental uCode */
Johannes Berg965974a2012-03-06 13:30:38 -0800884 if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
Johannes Berg15854ef2012-03-05 11:24:50 -0800885 if (api_ver < api_min || api_ver > api_max) {
Johannes Berg965974a2012-03-06 13:30:38 -0800886 IWL_ERR(drv,
Johannes Berg15854ef2012-03-05 11:24:50 -0800887 "Driver unable to support your firmware API. "
888 "Driver supports v%u, firmware is v%u.\n",
889 api_max, api_ver);
890 goto try_again;
891 }
892
893 if (api_ver < api_ok) {
894 if (api_ok != api_max)
Johannes Berg965974a2012-03-06 13:30:38 -0800895 IWL_ERR(drv, "Firmware has old API version, "
Johannes Berg15854ef2012-03-05 11:24:50 -0800896 "expected v%u through v%u, got v%u.\n",
897 api_ok, api_max, api_ver);
898 else
Johannes Berg965974a2012-03-06 13:30:38 -0800899 IWL_ERR(drv, "Firmware has old API version, "
Johannes Berg15854ef2012-03-05 11:24:50 -0800900 "expected v%u, got v%u.\n",
901 api_max, api_ver);
Johannes Berg965974a2012-03-06 13:30:38 -0800902 IWL_ERR(drv, "New firmware can be obtained from "
Johannes Berg15854ef2012-03-05 11:24:50 -0800903 "http://www.intellinuxwireless.org/.\n");
904 }
905 }
906
Johannes Berg965974a2012-03-06 13:30:38 -0800907 IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version);
Johannes Berg15854ef2012-03-05 11:24:50 -0800908
909 /*
David Spinadel4db2c9a2012-03-10 13:00:15 -0800910 * In mvm uCode there is no difference between data and instructions
911 * sections.
912 */
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200913 if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg))
Johannes Berg15854ef2012-03-05 11:24:50 -0800914 goto try_again;
Johannes Berg15854ef2012-03-05 11:24:50 -0800915
916 /* Allocate ucode buffers for card's bus-master loading ... */
917
918 /* Runtime instructions and 2 copies of data:
919 * 1) unmodified from disk
920 * 2) backup cache for save/restore during power-downs */
David Spinadel6dfa8d02012-03-10 13:00:14 -0800921 for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
Johannes Berg75813bd2012-05-16 22:49:49 +0200922 if (iwl_alloc_ucode(drv, &pieces, i))
923 goto out_free_fw;
Johannes Berg15854ef2012-03-05 11:24:50 -0800924
925 /* Now that we can no longer fail, copy information */
926
927 /*
928 * The (size - 16) / 12 formula is based on the information recorded
929 * for each event, which is of mode 1 (including timestamp) for all
930 * new microcodes that include this information.
931 */
Johannes Berg0692fe42012-03-06 13:30:37 -0800932 fw->init_evtlog_ptr = pieces.init_evtlog_ptr;
Johannes Berg15854ef2012-03-05 11:24:50 -0800933 if (pieces.init_evtlog_size)
Johannes Berg0692fe42012-03-06 13:30:37 -0800934 fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
Johannes Berg15854ef2012-03-05 11:24:50 -0800935 else
Johannes Berg0692fe42012-03-06 13:30:37 -0800936 fw->init_evtlog_size =
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200937 drv->cfg->base_params->max_event_log_size;
Johannes Berg0692fe42012-03-06 13:30:37 -0800938 fw->init_errlog_ptr = pieces.init_errlog_ptr;
939 fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
Johannes Berg15854ef2012-03-05 11:24:50 -0800940 if (pieces.inst_evtlog_size)
Johannes Berg0692fe42012-03-06 13:30:37 -0800941 fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
Johannes Berg15854ef2012-03-05 11:24:50 -0800942 else
Johannes Berg0692fe42012-03-06 13:30:37 -0800943 fw->inst_evtlog_size =
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +0200944 drv->cfg->base_params->max_event_log_size;
Johannes Berg0692fe42012-03-06 13:30:37 -0800945 fw->inst_errlog_ptr = pieces.inst_errlog_ptr;
Johannes Berg15854ef2012-03-05 11:24:50 -0800946
947 /*
948 * figure out the offset of chain noise reset and gain commands
949 * base on the size of standard phy calibration commands table size
950 */
951 if (fw->ucode_capa.standard_phy_calibration_size >
952 IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
953 fw->ucode_capa.standard_phy_calibration_size =
954 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
955
956 /* We have our copies now, allow OS release its copies */
957 release_firmware(ucode_raw);
Johannes Berg15854ef2012-03-05 11:24:50 -0800958
Johannes Bergff1ffb82012-06-06 09:42:57 +0200959 mutex_lock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +0200960 op = &iwlwifi_opmode_table[DVM_OP_MODE];
Johannes Berg15854ef2012-03-05 11:24:50 -0800961
Don Frycc5f7e32012-05-16 22:54:27 +0200962 /* add this device to the list of devices using this op_mode */
963 list_add_tail(&drv->list, &op->drv);
964
965 if (op->ops) {
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -0700966 drv->op_mode = _iwl_op_mode_start(drv, op);
John W. Linville7c9c46c2012-06-06 14:40:06 -0400967
Dan Carpenterdaf67ce2012-06-14 21:35:26 +0300968 if (!drv->op_mode) {
969 mutex_unlock(&iwlwifi_opmode_table_mtx);
John W. Linville7c9c46c2012-06-06 14:40:06 -0400970 goto out_unbind;
Dan Carpenterdaf67ce2012-06-14 21:35:26 +0300971 }
Don Frycc5f7e32012-05-16 22:54:27 +0200972 } else {
Johannes Bergd4b10482012-06-12 19:50:43 +0200973 load_module = true;
Don Frycc5f7e32012-05-16 22:54:27 +0200974 }
Johannes Bergff1ffb82012-06-06 09:42:57 +0200975 mutex_unlock(&iwlwifi_opmode_table_mtx);
Johannes Berg15854ef2012-03-05 11:24:50 -0800976
Johannes Bergf69a23b2012-06-05 19:56:06 +0200977 /*
978 * Complete the firmware request last so that
979 * a driver unbind (stop) doesn't run while we
980 * are doing the start() above.
981 */
982 complete(&drv->request_firmware_complete);
Johannes Bergd4b10482012-06-12 19:50:43 +0200983
984 /*
985 * Load the module last so we don't block anything
986 * else from proceeding if the module fails to load
987 * or hangs loading.
988 */
989 if (load_module)
990 request_module("%s", op->name);
Johannes Berg15854ef2012-03-05 11:24:50 -0800991 return;
992
993 try_again:
994 /* try next, if any */
995 release_firmware(ucode_raw);
Johannes Berg965974a2012-03-06 13:30:38 -0800996 if (iwl_request_firmware(drv, false))
Johannes Berg15854ef2012-03-05 11:24:50 -0800997 goto out_unbind;
998 return;
999
Johannes Berg75813bd2012-05-16 22:49:49 +02001000 out_free_fw:
Johannes Berg965974a2012-03-06 13:30:38 -08001001 IWL_ERR(drv, "failed to allocate pci memory\n");
1002 iwl_dealloc_ucode(drv);
Johannes Berg15854ef2012-03-05 11:24:50 -08001003 release_firmware(ucode_raw);
1004 out_unbind:
Johannes Berg965974a2012-03-06 13:30:38 -08001005 complete(&drv->request_firmware_complete);
Emmanuel Grumbach93faaee2012-03-22 17:51:44 +02001006 device_release_driver(drv->trans->dev);
Johannes Berg15854ef2012-03-05 11:24:50 -08001007}
1008
Emmanuel Grumbach87ce05a2012-03-26 09:03:18 -07001009struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -07001010 const struct iwl_cfg *cfg)
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001011{
Johannes Berg965974a2012-03-06 13:30:38 -08001012 struct iwl_drv *drv;
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001013 int ret;
1014
Johannes Berg965974a2012-03-06 13:30:38 -08001015 drv = kzalloc(sizeof(*drv), GFP_KERNEL);
Emmanuel Grumbachc15797e2012-04-19 10:29:58 +03001016 if (!drv)
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -07001017 return NULL;
Emmanuel Grumbachc15797e2012-04-19 10:29:58 +03001018
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -07001019 drv->trans = trans;
Emmanuel Grumbach4b9844f2012-03-22 23:59:52 +02001020 drv->dev = trans->dev;
Emmanuel Grumbach68f360d2012-03-22 17:51:44 +02001021 drv->cfg = cfg;
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001022
Johannes Berg965974a2012-03-06 13:30:38 -08001023 init_completion(&drv->request_firmware_complete);
Johannes Bergff1ffb82012-06-06 09:42:57 +02001024 INIT_LIST_HEAD(&drv->list);
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001025
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001026#ifdef CONFIG_IWLWIFI_DEBUGFS
1027 /* Create the device debugfs entries. */
1028 drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev),
1029 iwl_dbgfs_root);
1030
1031 if (!drv->dbgfs_drv) {
1032 IWL_ERR(drv, "failed to create debugfs directory\n");
1033 goto err_free_drv;
1034 }
1035
1036 /* Create transport layer debugfs dir */
1037 drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv);
1038
1039 if (!drv->trans->dbgfs_dir) {
1040 IWL_ERR(drv, "failed to create transport debugfs directory\n");
1041 goto err_free_dbgfs;
1042 }
1043#endif
1044
Johannes Berg965974a2012-03-06 13:30:38 -08001045 ret = iwl_request_firmware(drv, true);
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001046
1047 if (ret) {
Emmanuel Grumbachc15797e2012-04-19 10:29:58 +03001048 IWL_ERR(trans, "Couldn't request the fw\n");
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001049 goto err_fw;
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001050 }
1051
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -07001052 return drv;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001053
1054err_fw:
1055#ifdef CONFIG_IWLWIFI_DEBUGFS
1056err_free_dbgfs:
1057 debugfs_remove_recursive(drv->dbgfs_drv);
1058err_free_drv:
1059#endif
1060 kfree(drv);
1061 drv = NULL;
1062
1063 return drv;
Emmanuel Grumbach5c58edc2012-02-07 14:18:40 +02001064}
1065
Emmanuel Grumbach9130bab2012-03-26 08:51:09 -07001066void iwl_drv_stop(struct iwl_drv *drv)
Emmanuel Grumbach07590f02012-02-07 14:27:31 +02001067{
Johannes Berg965974a2012-03-06 13:30:38 -08001068 wait_for_completion(&drv->request_firmware_complete);
Johannes Berg2e7eb112012-03-05 11:24:51 -08001069
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001070 _iwl_op_mode_stop(drv);
Emmanuel Grumbach07590f02012-02-07 14:27:31 +02001071
Johannes Berg965974a2012-03-06 13:30:38 -08001072 iwl_dealloc_ucode(drv);
Johannes Berg7db5b982012-03-05 11:24:48 -08001073
Johannes Bergff1ffb82012-06-06 09:42:57 +02001074 mutex_lock(&iwlwifi_opmode_table_mtx);
1075 /*
1076 * List is empty (this item wasn't added)
1077 * when firmware loading failed -- in that
1078 * case we can't remove it from any list.
1079 */
1080 if (!list_empty(&drv->list))
1081 list_del(&drv->list);
1082 mutex_unlock(&iwlwifi_opmode_table_mtx);
1083
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001084#ifdef CONFIG_IWLWIFI_DEBUGFS
1085 debugfs_remove_recursive(drv->dbgfs_drv);
1086#endif
1087
Johannes Berg965974a2012-03-06 13:30:38 -08001088 kfree(drv);
Emmanuel Grumbach07590f02012-02-07 14:27:31 +02001089}
Johannes Berg65de7e82012-04-17 07:36:30 -07001090
1091
1092/* shared module parameters */
1093struct iwl_mod_params iwlwifi_mod_params = {
1094 .amsdu_size_8K = 1,
1095 .restart_fw = 1,
1096 .plcp_check = true,
1097 .bt_coex_active = true,
1098 .power_level = IWL_POWER_INDEX_1,
1099 .bt_ch_announce = true,
1100 .auto_agg = true,
Emmanuel Grumbach020c8762012-06-24 15:51:59 +03001101 .wd_disable = true,
Johannes Berg65de7e82012-04-17 07:36:30 -07001102 /* the rest are 0 by default */
1103};
Don Frycc5f7e32012-05-16 22:54:27 +02001104EXPORT_SYMBOL_GPL(iwlwifi_mod_params);
1105
1106int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
1107{
1108 int i;
1109 struct iwl_drv *drv;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001110 struct iwlwifi_opmode_table *op;
Don Frycc5f7e32012-05-16 22:54:27 +02001111
Johannes Bergff1ffb82012-06-06 09:42:57 +02001112 mutex_lock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001113 for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001114 op = &iwlwifi_opmode_table[i];
1115 if (strcmp(op->name, name))
Don Frycc5f7e32012-05-16 22:54:27 +02001116 continue;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001117 op->ops = ops;
1118 /* TODO: need to handle exceptional case */
1119 list_for_each_entry(drv, &op->drv, list)
1120 drv->op_mode = _iwl_op_mode_start(drv, op);
1121
Johannes Bergff1ffb82012-06-06 09:42:57 +02001122 mutex_unlock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001123 return 0;
1124 }
Johannes Bergff1ffb82012-06-06 09:42:57 +02001125 mutex_unlock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001126 return -EIO;
1127}
1128EXPORT_SYMBOL_GPL(iwl_opmode_register);
1129
1130void iwl_opmode_deregister(const char *name)
1131{
1132 int i;
1133 struct iwl_drv *drv;
1134
Johannes Bergff1ffb82012-06-06 09:42:57 +02001135 mutex_lock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001136 for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
1137 if (strcmp(iwlwifi_opmode_table[i].name, name))
1138 continue;
1139 iwlwifi_opmode_table[i].ops = NULL;
1140
1141 /* call the stop routine for all devices */
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001142 list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
1143 _iwl_op_mode_stop(drv);
1144
Johannes Bergff1ffb82012-06-06 09:42:57 +02001145 mutex_unlock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001146 return;
1147 }
Johannes Bergff1ffb82012-06-06 09:42:57 +02001148 mutex_unlock(&iwlwifi_opmode_table_mtx);
Don Frycc5f7e32012-05-16 22:54:27 +02001149}
1150EXPORT_SYMBOL_GPL(iwl_opmode_deregister);
1151
1152static int __init iwl_drv_init(void)
1153{
1154 int i;
1155
Johannes Bergff1ffb82012-06-06 09:42:57 +02001156 mutex_init(&iwlwifi_opmode_table_mtx);
1157
Don Frycc5f7e32012-05-16 22:54:27 +02001158 for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++)
1159 INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);
1160
1161 pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
1162 pr_info(DRV_COPYRIGHT "\n");
1163
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001164#ifdef CONFIG_IWLWIFI_DEBUGFS
1165 /* Create the root of iwlwifi debugfs subsystem. */
1166 iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL);
1167
1168 if (!iwl_dbgfs_root)
1169 return -EFAULT;
1170#endif
1171
Don Frycc5f7e32012-05-16 22:54:27 +02001172 return iwl_pci_register_driver();
1173}
1174module_init(iwl_drv_init);
1175
1176static void __exit iwl_drv_exit(void)
1177{
1178 iwl_pci_unregister_driver();
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07001179
1180#ifdef CONFIG_IWLWIFI_DEBUGFS
1181 debugfs_remove_recursive(iwl_dbgfs_root);
1182#endif
Don Frycc5f7e32012-05-16 22:54:27 +02001183}
1184module_exit(iwl_drv_exit);
Johannes Berg65de7e82012-04-17 07:36:30 -07001185
1186#ifdef CONFIG_IWLWIFI_DEBUG
1187module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
1188 S_IRUGO | S_IWUSR);
1189MODULE_PARM_DESC(debug, "debug output mask");
1190#endif
1191
1192module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
1193MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
1194module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
1195MODULE_PARM_DESC(11n_disable,
1196 "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
1197module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
1198 int, S_IRUGO);
1199MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
1200module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO);
1201MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
1202
1203module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
1204 int, S_IRUGO);
1205MODULE_PARM_DESC(antenna_coupling,
1206 "specify antenna coupling in dB (defualt: 0 dB)");
1207
1208module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce,
1209 bool, S_IRUGO);
1210MODULE_PARM_DESC(bt_ch_inhibition,
1211 "Enable BT channel inhibition (default: enable)");
1212
1213module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO);
1214MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
1215
1216module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO);
1217MODULE_PARM_DESC(wd_disable,
1218 "Disable stuck queue watchdog timer 0=system default, "
1219 "1=disable, 2=enable (default: 0)");
1220
1221/*
1222 * set bt_coex_active to true, uCode will do kill/defer
1223 * every time the priority line is asserted (BT is sending signals on the
1224 * priority line in the PCIx).
1225 * set bt_coex_active to false, uCode will ignore the BT activity and
1226 * perform the normal operation
1227 *
1228 * User might experience transmit issue on some platform due to WiFi/BT
1229 * co-exist problem. The possible behaviors are:
1230 * Able to scan and finding all the available AP
1231 * Not able to associate with any AP
1232 * On those platforms, WiFi communication can be restored by set
1233 * "bt_coex_active" module parameter to "false"
1234 *
1235 * default: bt_coex_active = true (BT_COEX_ENABLE)
1236 */
1237module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
1238 bool, S_IRUGO);
1239MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
1240
1241module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
1242MODULE_PARM_DESC(led_mode, "0=system default, "
1243 "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
1244
1245module_param_named(power_save, iwlwifi_mod_params.power_save,
1246 bool, S_IRUGO);
1247MODULE_PARM_DESC(power_save,
1248 "enable WiFi power management (default: disable)");
1249
1250module_param_named(power_level, iwlwifi_mod_params.power_level,
1251 int, S_IRUGO);
1252MODULE_PARM_DESC(power_level,
1253 "default power save level (range from 1 - 5, default: 1)");
1254
1255module_param_named(auto_agg, iwlwifi_mod_params.auto_agg,
1256 bool, S_IRUGO);
1257MODULE_PARM_DESC(auto_agg,
1258 "enable agg w/o check traffic load (default: enable)");
Stanislaw Gruszkaf6b11542012-04-19 09:51:24 -07001259
1260module_param_named(5ghz_disable, iwlwifi_mod_params.disable_5ghz,
1261 bool, S_IRUGO);
1262MODULE_PARM_DESC(5ghz_disable, "disable 5GHz band (default: 0 [enabled])");