iwl-drv.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 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>
  64. #include <linux/dma-mapping.h>
  65. #include <linux/firmware.h>
  66. #include <linux/module.h>
  67. #include "iwl-drv.h"
  68. #include "iwl-debug.h"
  69. #include "iwl-trans.h"
  70. #include "iwl-op-mode.h"
  71. #include "iwl-agn-hw.h"
  72. #include "iwl-fw.h"
  73. #include "iwl-config.h"
  74. #include "iwl-modparams.h"
  75. /* private includes */
  76. #include "iwl-fw-file.h"
  77. /******************************************************************************
  78. *
  79. * module boiler plate
  80. *
  81. ******************************************************************************/
  82. /*
  83. * module name, copyright, version, etc.
  84. */
  85. #define DRV_DESCRIPTION "Intel(R) Wireless WiFi driver for Linux"
  86. #ifdef CONFIG_IWLWIFI_DEBUG
  87. #define VD "d"
  88. #else
  89. #define VD
  90. #endif
  91. #define DRV_VERSION IWLWIFI_VERSION VD
  92. MODULE_DESCRIPTION(DRV_DESCRIPTION);
  93. MODULE_VERSION(DRV_VERSION);
  94. MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
  95. MODULE_LICENSE("GPL");
  96. /**
  97. * struct iwl_drv - drv common data
  98. * @list: list of drv structures using this opmode
  99. * @fw: the iwl_fw structure
  100. * @op_mode: the running op_mode
  101. * @trans: transport layer
  102. * @dev: for debug prints only
  103. * @cfg: configuration struct
  104. * @fw_index: firmware revision to try loading
  105. * @firmware_name: composite filename of ucode file to load
  106. * @request_firmware_complete: the firmware has been obtained from user space
  107. */
  108. struct iwl_drv {
  109. struct list_head list;
  110. struct iwl_fw fw;
  111. struct iwl_op_mode *op_mode;
  112. struct iwl_trans *trans;
  113. struct device *dev;
  114. const struct iwl_cfg *cfg;
  115. int fw_index; /* firmware we're trying to load */
  116. char firmware_name[25]; /* name of firmware file to load */
  117. struct completion request_firmware_complete;
  118. };
  119. #define DVM_OP_MODE 0
  120. #define MVM_OP_MODE 1
  121. static struct iwlwifi_opmode_table {
  122. const char *name; /* name: iwldvm, iwlmvm, etc */
  123. const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */
  124. struct list_head drv; /* list of devices using this op_mode */
  125. } iwlwifi_opmode_table[] = { /* ops set when driver is initialized */
  126. { .name = "iwldvm", .ops = NULL },
  127. { .name = "iwlmvm", .ops = NULL },
  128. };
  129. /*
  130. * struct fw_sec: Just for the image parsing proccess.
  131. * For the fw storage we are using struct fw_desc.
  132. */
  133. struct fw_sec {
  134. const void *data; /* the sec data */
  135. size_t size; /* section size */
  136. u32 offset; /* offset of writing in the device */
  137. };
  138. static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
  139. {
  140. if (desc->v_addr)
  141. dma_free_coherent(drv->trans->dev, desc->len,
  142. desc->v_addr, desc->p_addr);
  143. desc->v_addr = NULL;
  144. desc->len = 0;
  145. }
  146. static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
  147. {
  148. int i;
  149. for (i = 0; i < IWL_UCODE_SECTION_MAX; i++)
  150. iwl_free_fw_desc(drv, &img->sec[i]);
  151. }
  152. static void iwl_dealloc_ucode(struct iwl_drv *drv)
  153. {
  154. int i;
  155. for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
  156. iwl_free_fw_img(drv, drv->fw.img + i);
  157. }
  158. static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
  159. struct fw_sec *sec)
  160. {
  161. if (!sec || !sec->size) {
  162. desc->v_addr = NULL;
  163. return -EINVAL;
  164. }
  165. desc->v_addr = dma_alloc_coherent(drv->trans->dev, sec->size,
  166. &desc->p_addr, GFP_KERNEL);
  167. if (!desc->v_addr)
  168. return -ENOMEM;
  169. desc->len = sec->size;
  170. desc->offset = sec->offset;
  171. memcpy(desc->v_addr, sec->data, sec->size);
  172. return 0;
  173. }
  174. static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
  175. #define UCODE_EXPERIMENTAL_INDEX 100
  176. #define UCODE_EXPERIMENTAL_TAG "exp"
  177. static int iwl_request_firmware(struct iwl_drv *drv, bool first)
  178. {
  179. const char *name_pre = drv->cfg->fw_name_pre;
  180. char tag[8];
  181. if (first) {
  182. #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
  183. drv->fw_index = UCODE_EXPERIMENTAL_INDEX;
  184. strcpy(tag, UCODE_EXPERIMENTAL_TAG);
  185. } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
  186. #endif
  187. drv->fw_index = drv->cfg->ucode_api_max;
  188. sprintf(tag, "%d", drv->fw_index);
  189. } else {
  190. drv->fw_index--;
  191. sprintf(tag, "%d", drv->fw_index);
  192. }
  193. if (drv->fw_index < drv->cfg->ucode_api_min) {
  194. IWL_ERR(drv, "no suitable firmware found!\n");
  195. return -ENOENT;
  196. }
  197. sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
  198. IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
  199. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  200. ? "EXPERIMENTAL " : "",
  201. drv->firmware_name);
  202. return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
  203. drv->trans->dev,
  204. GFP_KERNEL, drv, iwl_ucode_callback);
  205. }
  206. struct fw_img_parsing {
  207. struct fw_sec sec[IWL_UCODE_SECTION_MAX];
  208. int sec_counter;
  209. };
  210. /*
  211. * struct fw_sec_parsing: to extract fw section and it's offset from tlv
  212. */
  213. struct fw_sec_parsing {
  214. __le32 offset;
  215. const u8 data[];
  216. } __packed;
  217. /**
  218. * struct iwl_tlv_calib_data - parse the default calib data from TLV
  219. *
  220. * @ucode_type: the uCode to which the following default calib relates.
  221. * @calib: default calibrations.
  222. */
  223. struct iwl_tlv_calib_data {
  224. __le32 ucode_type;
  225. __le64 calib;
  226. } __packed;
  227. struct iwl_firmware_pieces {
  228. struct fw_img_parsing img[IWL_UCODE_TYPE_MAX];
  229. u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
  230. u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
  231. };
  232. /*
  233. * These functions are just to extract uCode section data from the pieces
  234. * structure.
  235. */
  236. static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces,
  237. enum iwl_ucode_type type,
  238. int sec)
  239. {
  240. return &pieces->img[type].sec[sec];
  241. }
  242. static void set_sec_data(struct iwl_firmware_pieces *pieces,
  243. enum iwl_ucode_type type,
  244. int sec,
  245. const void *data)
  246. {
  247. pieces->img[type].sec[sec].data = data;
  248. }
  249. static void set_sec_size(struct iwl_firmware_pieces *pieces,
  250. enum iwl_ucode_type type,
  251. int sec,
  252. size_t size)
  253. {
  254. pieces->img[type].sec[sec].size = size;
  255. }
  256. static size_t get_sec_size(struct iwl_firmware_pieces *pieces,
  257. enum iwl_ucode_type type,
  258. int sec)
  259. {
  260. return pieces->img[type].sec[sec].size;
  261. }
  262. static void set_sec_offset(struct iwl_firmware_pieces *pieces,
  263. enum iwl_ucode_type type,
  264. int sec,
  265. u32 offset)
  266. {
  267. pieces->img[type].sec[sec].offset = offset;
  268. }
  269. /*
  270. * Gets uCode section from tlv.
  271. */
  272. static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces,
  273. const void *data, enum iwl_ucode_type type,
  274. int size)
  275. {
  276. struct fw_img_parsing *img;
  277. struct fw_sec *sec;
  278. struct fw_sec_parsing *sec_parse;
  279. if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX))
  280. return -1;
  281. sec_parse = (struct fw_sec_parsing *)data;
  282. img = &pieces->img[type];
  283. sec = &img->sec[img->sec_counter];
  284. sec->offset = le32_to_cpu(sec_parse->offset);
  285. sec->data = sec_parse->data;
  286. sec->size = size - sizeof(sec_parse->offset);
  287. ++img->sec_counter;
  288. return 0;
  289. }
  290. static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data)
  291. {
  292. struct iwl_tlv_calib_data *def_calib =
  293. (struct iwl_tlv_calib_data *)data;
  294. u32 ucode_type = le32_to_cpu(def_calib->ucode_type);
  295. if (ucode_type >= IWL_UCODE_TYPE_MAX) {
  296. IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n",
  297. ucode_type);
  298. return -EINVAL;
  299. }
  300. drv->fw.default_calib[ucode_type] = le64_to_cpu(def_calib->calib);
  301. return 0;
  302. }
  303. static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
  304. const struct firmware *ucode_raw,
  305. struct iwl_firmware_pieces *pieces)
  306. {
  307. struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
  308. u32 api_ver, hdr_size, build;
  309. char buildstr[25];
  310. const u8 *src;
  311. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  312. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  313. switch (api_ver) {
  314. default:
  315. hdr_size = 28;
  316. if (ucode_raw->size < hdr_size) {
  317. IWL_ERR(drv, "File size too small!\n");
  318. return -EINVAL;
  319. }
  320. build = le32_to_cpu(ucode->u.v2.build);
  321. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  322. le32_to_cpu(ucode->u.v2.inst_size));
  323. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  324. le32_to_cpu(ucode->u.v2.data_size));
  325. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  326. le32_to_cpu(ucode->u.v2.init_size));
  327. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  328. le32_to_cpu(ucode->u.v2.init_data_size));
  329. src = ucode->u.v2.data;
  330. break;
  331. case 0:
  332. case 1:
  333. case 2:
  334. hdr_size = 24;
  335. if (ucode_raw->size < hdr_size) {
  336. IWL_ERR(drv, "File size too small!\n");
  337. return -EINVAL;
  338. }
  339. build = 0;
  340. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  341. le32_to_cpu(ucode->u.v1.inst_size));
  342. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  343. le32_to_cpu(ucode->u.v1.data_size));
  344. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  345. le32_to_cpu(ucode->u.v1.init_size));
  346. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  347. le32_to_cpu(ucode->u.v1.init_data_size));
  348. src = ucode->u.v1.data;
  349. break;
  350. }
  351. if (build)
  352. sprintf(buildstr, " build %u%s", build,
  353. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  354. ? " (EXP)" : "");
  355. else
  356. buildstr[0] = '\0';
  357. snprintf(drv->fw.fw_version,
  358. sizeof(drv->fw.fw_version),
  359. "%u.%u.%u.%u%s",
  360. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  361. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  362. IWL_UCODE_API(drv->fw.ucode_ver),
  363. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  364. buildstr);
  365. /* Verify size of file vs. image size info in file's header */
  366. if (ucode_raw->size != hdr_size +
  367. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) +
  368. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) +
  369. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) +
  370. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
  371. IWL_ERR(drv,
  372. "uCode file size %d does not match expected size\n",
  373. (int)ucode_raw->size);
  374. return -EINVAL;
  375. }
  376. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src);
  377. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST);
  378. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  379. IWLAGN_RTC_INST_LOWER_BOUND);
  380. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src);
  381. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA);
  382. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  383. IWLAGN_RTC_DATA_LOWER_BOUND);
  384. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src);
  385. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST);
  386. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  387. IWLAGN_RTC_INST_LOWER_BOUND);
  388. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src);
  389. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA);
  390. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  391. IWLAGN_RTC_DATA_LOWER_BOUND);
  392. return 0;
  393. }
  394. static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
  395. const struct firmware *ucode_raw,
  396. struct iwl_firmware_pieces *pieces,
  397. struct iwl_ucode_capabilities *capa)
  398. {
  399. struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
  400. struct iwl_ucode_tlv *tlv;
  401. size_t len = ucode_raw->size;
  402. const u8 *data;
  403. u32 tlv_len;
  404. enum iwl_ucode_tlv_type tlv_type;
  405. const u8 *tlv_data;
  406. char buildstr[25];
  407. u32 build;
  408. if (len < sizeof(*ucode)) {
  409. IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
  410. return -EINVAL;
  411. }
  412. if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
  413. IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
  414. le32_to_cpu(ucode->magic));
  415. return -EINVAL;
  416. }
  417. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  418. build = le32_to_cpu(ucode->build);
  419. if (build)
  420. sprintf(buildstr, " build %u%s", build,
  421. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  422. ? " (EXP)" : "");
  423. else
  424. buildstr[0] = '\0';
  425. snprintf(drv->fw.fw_version,
  426. sizeof(drv->fw.fw_version),
  427. "%u.%u.%u.%u%s",
  428. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  429. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  430. IWL_UCODE_API(drv->fw.ucode_ver),
  431. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  432. buildstr);
  433. data = ucode->data;
  434. len -= sizeof(*ucode);
  435. while (len >= sizeof(*tlv)) {
  436. len -= sizeof(*tlv);
  437. tlv = (void *)data;
  438. tlv_len = le32_to_cpu(tlv->length);
  439. tlv_type = le32_to_cpu(tlv->type);
  440. tlv_data = tlv->data;
  441. if (len < tlv_len) {
  442. IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
  443. len, tlv_len);
  444. return -EINVAL;
  445. }
  446. len -= ALIGN(tlv_len, 4);
  447. data += sizeof(*tlv) + ALIGN(tlv_len, 4);
  448. switch (tlv_type) {
  449. case IWL_UCODE_TLV_INST:
  450. set_sec_data(pieces, IWL_UCODE_REGULAR,
  451. IWL_UCODE_SECTION_INST, tlv_data);
  452. set_sec_size(pieces, IWL_UCODE_REGULAR,
  453. IWL_UCODE_SECTION_INST, tlv_len);
  454. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  455. IWL_UCODE_SECTION_INST,
  456. IWLAGN_RTC_INST_LOWER_BOUND);
  457. break;
  458. case IWL_UCODE_TLV_DATA:
  459. set_sec_data(pieces, IWL_UCODE_REGULAR,
  460. IWL_UCODE_SECTION_DATA, tlv_data);
  461. set_sec_size(pieces, IWL_UCODE_REGULAR,
  462. IWL_UCODE_SECTION_DATA, tlv_len);
  463. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  464. IWL_UCODE_SECTION_DATA,
  465. IWLAGN_RTC_DATA_LOWER_BOUND);
  466. break;
  467. case IWL_UCODE_TLV_INIT:
  468. set_sec_data(pieces, IWL_UCODE_INIT,
  469. IWL_UCODE_SECTION_INST, tlv_data);
  470. set_sec_size(pieces, IWL_UCODE_INIT,
  471. IWL_UCODE_SECTION_INST, tlv_len);
  472. set_sec_offset(pieces, IWL_UCODE_INIT,
  473. IWL_UCODE_SECTION_INST,
  474. IWLAGN_RTC_INST_LOWER_BOUND);
  475. break;
  476. case IWL_UCODE_TLV_INIT_DATA:
  477. set_sec_data(pieces, IWL_UCODE_INIT,
  478. IWL_UCODE_SECTION_DATA, tlv_data);
  479. set_sec_size(pieces, IWL_UCODE_INIT,
  480. IWL_UCODE_SECTION_DATA, tlv_len);
  481. set_sec_offset(pieces, IWL_UCODE_INIT,
  482. IWL_UCODE_SECTION_DATA,
  483. IWLAGN_RTC_DATA_LOWER_BOUND);
  484. break;
  485. case IWL_UCODE_TLV_BOOT:
  486. IWL_ERR(drv, "Found unexpected BOOT ucode\n");
  487. break;
  488. case IWL_UCODE_TLV_PROBE_MAX_LEN:
  489. if (tlv_len != sizeof(u32))
  490. goto invalid_tlv_len;
  491. capa->max_probe_length =
  492. le32_to_cpup((__le32 *)tlv_data);
  493. break;
  494. case IWL_UCODE_TLV_PAN:
  495. if (tlv_len)
  496. goto invalid_tlv_len;
  497. capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
  498. break;
  499. case IWL_UCODE_TLV_FLAGS:
  500. /* must be at least one u32 */
  501. if (tlv_len < sizeof(u32))
  502. goto invalid_tlv_len;
  503. /* and a proper number of u32s */
  504. if (tlv_len % sizeof(u32))
  505. goto invalid_tlv_len;
  506. /*
  507. * This driver only reads the first u32 as
  508. * right now no more features are defined,
  509. * if that changes then either the driver
  510. * will not work with the new firmware, or
  511. * it'll not take advantage of new features.
  512. */
  513. capa->flags = le32_to_cpup((__le32 *)tlv_data);
  514. break;
  515. case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
  516. if (tlv_len != sizeof(u32))
  517. goto invalid_tlv_len;
  518. pieces->init_evtlog_ptr =
  519. le32_to_cpup((__le32 *)tlv_data);
  520. break;
  521. case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
  522. if (tlv_len != sizeof(u32))
  523. goto invalid_tlv_len;
  524. pieces->init_evtlog_size =
  525. le32_to_cpup((__le32 *)tlv_data);
  526. break;
  527. case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
  528. if (tlv_len != sizeof(u32))
  529. goto invalid_tlv_len;
  530. pieces->init_errlog_ptr =
  531. le32_to_cpup((__le32 *)tlv_data);
  532. break;
  533. case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
  534. if (tlv_len != sizeof(u32))
  535. goto invalid_tlv_len;
  536. pieces->inst_evtlog_ptr =
  537. le32_to_cpup((__le32 *)tlv_data);
  538. break;
  539. case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
  540. if (tlv_len != sizeof(u32))
  541. goto invalid_tlv_len;
  542. pieces->inst_evtlog_size =
  543. le32_to_cpup((__le32 *)tlv_data);
  544. break;
  545. case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
  546. if (tlv_len != sizeof(u32))
  547. goto invalid_tlv_len;
  548. pieces->inst_errlog_ptr =
  549. le32_to_cpup((__le32 *)tlv_data);
  550. break;
  551. case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
  552. if (tlv_len)
  553. goto invalid_tlv_len;
  554. drv->fw.enhance_sensitivity_table = true;
  555. break;
  556. case IWL_UCODE_TLV_WOWLAN_INST:
  557. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  558. IWL_UCODE_SECTION_INST, tlv_data);
  559. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  560. IWL_UCODE_SECTION_INST, tlv_len);
  561. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  562. IWL_UCODE_SECTION_INST,
  563. IWLAGN_RTC_INST_LOWER_BOUND);
  564. break;
  565. case IWL_UCODE_TLV_WOWLAN_DATA:
  566. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  567. IWL_UCODE_SECTION_DATA, tlv_data);
  568. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  569. IWL_UCODE_SECTION_DATA, tlv_len);
  570. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  571. IWL_UCODE_SECTION_DATA,
  572. IWLAGN_RTC_DATA_LOWER_BOUND);
  573. break;
  574. case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
  575. if (tlv_len != sizeof(u32))
  576. goto invalid_tlv_len;
  577. capa->standard_phy_calibration_size =
  578. le32_to_cpup((__le32 *)tlv_data);
  579. break;
  580. case IWL_UCODE_TLV_SEC_RT:
  581. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
  582. tlv_len);
  583. drv->fw.mvm_fw = true;
  584. break;
  585. case IWL_UCODE_TLV_SEC_INIT:
  586. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
  587. tlv_len);
  588. drv->fw.mvm_fw = true;
  589. break;
  590. case IWL_UCODE_TLV_SEC_WOWLAN:
  591. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
  592. tlv_len);
  593. drv->fw.mvm_fw = true;
  594. break;
  595. case IWL_UCODE_TLV_DEF_CALIB:
  596. if (tlv_len != sizeof(struct iwl_tlv_calib_data))
  597. goto invalid_tlv_len;
  598. if (iwl_set_default_calib(drv, tlv_data))
  599. goto tlv_error;
  600. break;
  601. case IWL_UCODE_TLV_PHY_SKU:
  602. if (tlv_len != sizeof(u32))
  603. goto invalid_tlv_len;
  604. drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data);
  605. break;
  606. default:
  607. IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
  608. break;
  609. }
  610. }
  611. if (len) {
  612. IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
  613. iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
  614. return -EINVAL;
  615. }
  616. return 0;
  617. invalid_tlv_len:
  618. IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
  619. tlv_error:
  620. iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
  621. return -EINVAL;
  622. }
  623. static int iwl_alloc_ucode(struct iwl_drv *drv,
  624. struct iwl_firmware_pieces *pieces,
  625. enum iwl_ucode_type type)
  626. {
  627. int i;
  628. for (i = 0;
  629. i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i);
  630. i++)
  631. if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]),
  632. get_sec(pieces, type, i)))
  633. return -ENOMEM;
  634. return 0;
  635. }
  636. static int validate_sec_sizes(struct iwl_drv *drv,
  637. struct iwl_firmware_pieces *pieces,
  638. const struct iwl_cfg *cfg)
  639. {
  640. IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
  641. get_sec_size(pieces, IWL_UCODE_REGULAR,
  642. IWL_UCODE_SECTION_INST));
  643. IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
  644. get_sec_size(pieces, IWL_UCODE_REGULAR,
  645. IWL_UCODE_SECTION_DATA));
  646. IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
  647. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST));
  648. IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
  649. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA));
  650. /* Verify that uCode images will fit in card's SRAM. */
  651. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) >
  652. cfg->max_inst_size) {
  653. IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
  654. get_sec_size(pieces, IWL_UCODE_REGULAR,
  655. IWL_UCODE_SECTION_INST));
  656. return -1;
  657. }
  658. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) >
  659. cfg->max_data_size) {
  660. IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
  661. get_sec_size(pieces, IWL_UCODE_REGULAR,
  662. IWL_UCODE_SECTION_DATA));
  663. return -1;
  664. }
  665. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) >
  666. cfg->max_inst_size) {
  667. IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
  668. get_sec_size(pieces, IWL_UCODE_INIT,
  669. IWL_UCODE_SECTION_INST));
  670. return -1;
  671. }
  672. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) >
  673. cfg->max_data_size) {
  674. IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
  675. get_sec_size(pieces, IWL_UCODE_REGULAR,
  676. IWL_UCODE_SECTION_DATA));
  677. return -1;
  678. }
  679. return 0;
  680. }
  681. /**
  682. * iwl_ucode_callback - callback when firmware was loaded
  683. *
  684. * If loaded successfully, copies the firmware into buffers
  685. * for the card to fetch (via DMA).
  686. */
  687. static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
  688. {
  689. struct iwl_drv *drv = context;
  690. struct iwl_fw *fw = &drv->fw;
  691. struct iwl_ucode_header *ucode;
  692. struct iwlwifi_opmode_table *op;
  693. int err;
  694. struct iwl_firmware_pieces pieces;
  695. const unsigned int api_max = drv->cfg->ucode_api_max;
  696. unsigned int api_ok = drv->cfg->ucode_api_ok;
  697. const unsigned int api_min = drv->cfg->ucode_api_min;
  698. u32 api_ver;
  699. int i;
  700. fw->ucode_capa.max_probe_length = 200;
  701. fw->ucode_capa.standard_phy_calibration_size =
  702. IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  703. if (!api_ok)
  704. api_ok = api_max;
  705. memset(&pieces, 0, sizeof(pieces));
  706. if (!ucode_raw) {
  707. if (drv->fw_index <= api_ok)
  708. IWL_ERR(drv,
  709. "request for firmware file '%s' failed.\n",
  710. drv->firmware_name);
  711. goto try_again;
  712. }
  713. IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
  714. drv->firmware_name, ucode_raw->size);
  715. /* Make sure that we got at least the API version number */
  716. if (ucode_raw->size < 4) {
  717. IWL_ERR(drv, "File size way too small!\n");
  718. goto try_again;
  719. }
  720. /* Data from ucode file: header followed by uCode images */
  721. ucode = (struct iwl_ucode_header *)ucode_raw->data;
  722. if (ucode->ver)
  723. err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces);
  724. else
  725. err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces,
  726. &fw->ucode_capa);
  727. if (err)
  728. goto try_again;
  729. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  730. /*
  731. * api_ver should match the api version forming part of the
  732. * firmware filename ... but we don't check for that and only rely
  733. * on the API version read from firmware header from here on forward
  734. */
  735. /* no api version check required for experimental uCode */
  736. if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
  737. if (api_ver < api_min || api_ver > api_max) {
  738. IWL_ERR(drv,
  739. "Driver unable to support your firmware API. "
  740. "Driver supports v%u, firmware is v%u.\n",
  741. api_max, api_ver);
  742. goto try_again;
  743. }
  744. if (api_ver < api_ok) {
  745. if (api_ok != api_max)
  746. IWL_ERR(drv, "Firmware has old API version, "
  747. "expected v%u through v%u, got v%u.\n",
  748. api_ok, api_max, api_ver);
  749. else
  750. IWL_ERR(drv, "Firmware has old API version, "
  751. "expected v%u, got v%u.\n",
  752. api_max, api_ver);
  753. IWL_ERR(drv, "New firmware can be obtained from "
  754. "http://www.intellinuxwireless.org/.\n");
  755. }
  756. }
  757. IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version);
  758. /*
  759. * In mvm uCode there is no difference between data and instructions
  760. * sections.
  761. */
  762. if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg))
  763. goto try_again;
  764. /* Allocate ucode buffers for card's bus-master loading ... */
  765. /* Runtime instructions and 2 copies of data:
  766. * 1) unmodified from disk
  767. * 2) backup cache for save/restore during power-downs */
  768. for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
  769. if (iwl_alloc_ucode(drv, &pieces, i))
  770. goto out_free_fw;
  771. /* Now that we can no longer fail, copy information */
  772. /*
  773. * The (size - 16) / 12 formula is based on the information recorded
  774. * for each event, which is of mode 1 (including timestamp) for all
  775. * new microcodes that include this information.
  776. */
  777. fw->init_evtlog_ptr = pieces.init_evtlog_ptr;
  778. if (pieces.init_evtlog_size)
  779. fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
  780. else
  781. fw->init_evtlog_size =
  782. drv->cfg->base_params->max_event_log_size;
  783. fw->init_errlog_ptr = pieces.init_errlog_ptr;
  784. fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
  785. if (pieces.inst_evtlog_size)
  786. fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
  787. else
  788. fw->inst_evtlog_size =
  789. drv->cfg->base_params->max_event_log_size;
  790. fw->inst_errlog_ptr = pieces.inst_errlog_ptr;
  791. /*
  792. * figure out the offset of chain noise reset and gain commands
  793. * base on the size of standard phy calibration commands table size
  794. */
  795. if (fw->ucode_capa.standard_phy_calibration_size >
  796. IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
  797. fw->ucode_capa.standard_phy_calibration_size =
  798. IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  799. /* We have our copies now, allow OS release its copies */
  800. release_firmware(ucode_raw);
  801. complete(&drv->request_firmware_complete);
  802. op = &iwlwifi_opmode_table[DVM_OP_MODE];
  803. /* add this device to the list of devices using this op_mode */
  804. list_add_tail(&drv->list, &op->drv);
  805. if (op->ops) {
  806. const struct iwl_op_mode_ops *ops = op->ops;
  807. drv->op_mode = ops->start(drv->trans, drv->cfg, &drv->fw);
  808. } else {
  809. request_module_nowait("%s", op->name);
  810. }
  811. return;
  812. try_again:
  813. /* try next, if any */
  814. release_firmware(ucode_raw);
  815. if (iwl_request_firmware(drv, false))
  816. goto out_unbind;
  817. return;
  818. out_free_fw:
  819. IWL_ERR(drv, "failed to allocate pci memory\n");
  820. iwl_dealloc_ucode(drv);
  821. release_firmware(ucode_raw);
  822. out_unbind:
  823. complete(&drv->request_firmware_complete);
  824. device_release_driver(drv->trans->dev);
  825. }
  826. struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
  827. const struct iwl_cfg *cfg)
  828. {
  829. struct iwl_drv *drv;
  830. int ret;
  831. drv = kzalloc(sizeof(*drv), GFP_KERNEL);
  832. if (!drv)
  833. return NULL;
  834. drv->trans = trans;
  835. drv->dev = trans->dev;
  836. drv->cfg = cfg;
  837. init_completion(&drv->request_firmware_complete);
  838. ret = iwl_request_firmware(drv, true);
  839. if (ret) {
  840. IWL_ERR(trans, "Couldn't request the fw\n");
  841. kfree(drv);
  842. drv = NULL;
  843. }
  844. return drv;
  845. }
  846. void iwl_drv_stop(struct iwl_drv *drv)
  847. {
  848. wait_for_completion(&drv->request_firmware_complete);
  849. /* op_mode can be NULL if its start failed */
  850. if (drv->op_mode)
  851. iwl_op_mode_stop(drv->op_mode);
  852. iwl_dealloc_ucode(drv);
  853. kfree(drv);
  854. }
  855. /* shared module parameters */
  856. struct iwl_mod_params iwlwifi_mod_params = {
  857. .amsdu_size_8K = 1,
  858. .restart_fw = 1,
  859. .plcp_check = true,
  860. .bt_coex_active = true,
  861. .power_level = IWL_POWER_INDEX_1,
  862. .bt_ch_announce = true,
  863. .auto_agg = true,
  864. /* the rest are 0 by default */
  865. };
  866. EXPORT_SYMBOL_GPL(iwlwifi_mod_params);
  867. int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
  868. {
  869. int i;
  870. struct iwl_drv *drv;
  871. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  872. if (strcmp(iwlwifi_opmode_table[i].name, name))
  873. continue;
  874. iwlwifi_opmode_table[i].ops = ops;
  875. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
  876. drv->op_mode = ops->start(drv->trans, drv->cfg,
  877. &drv->fw);
  878. return 0;
  879. }
  880. return -EIO;
  881. }
  882. EXPORT_SYMBOL_GPL(iwl_opmode_register);
  883. void iwl_opmode_deregister(const char *name)
  884. {
  885. int i;
  886. struct iwl_drv *drv;
  887. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  888. if (strcmp(iwlwifi_opmode_table[i].name, name))
  889. continue;
  890. iwlwifi_opmode_table[i].ops = NULL;
  891. /* call the stop routine for all devices */
  892. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list) {
  893. if (drv->op_mode) {
  894. iwl_op_mode_stop(drv->op_mode);
  895. drv->op_mode = NULL;
  896. }
  897. }
  898. return;
  899. }
  900. }
  901. EXPORT_SYMBOL_GPL(iwl_opmode_deregister);
  902. static int __init iwl_drv_init(void)
  903. {
  904. int i;
  905. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++)
  906. INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);
  907. pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
  908. pr_info(DRV_COPYRIGHT "\n");
  909. return iwl_pci_register_driver();
  910. }
  911. module_init(iwl_drv_init);
  912. static void __exit iwl_drv_exit(void)
  913. {
  914. iwl_pci_unregister_driver();
  915. }
  916. module_exit(iwl_drv_exit);
  917. #ifdef CONFIG_IWLWIFI_DEBUG
  918. module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
  919. S_IRUGO | S_IWUSR);
  920. MODULE_PARM_DESC(debug, "debug output mask");
  921. #endif
  922. module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
  923. MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
  924. module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
  925. MODULE_PARM_DESC(11n_disable,
  926. "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
  927. module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
  928. int, S_IRUGO);
  929. MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
  930. module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO);
  931. MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
  932. module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
  933. int, S_IRUGO);
  934. MODULE_PARM_DESC(antenna_coupling,
  935. "specify antenna coupling in dB (defualt: 0 dB)");
  936. module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce,
  937. bool, S_IRUGO);
  938. MODULE_PARM_DESC(bt_ch_inhibition,
  939. "Enable BT channel inhibition (default: enable)");
  940. module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO);
  941. MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
  942. module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO);
  943. MODULE_PARM_DESC(wd_disable,
  944. "Disable stuck queue watchdog timer 0=system default, "
  945. "1=disable, 2=enable (default: 0)");
  946. /*
  947. * set bt_coex_active to true, uCode will do kill/defer
  948. * every time the priority line is asserted (BT is sending signals on the
  949. * priority line in the PCIx).
  950. * set bt_coex_active to false, uCode will ignore the BT activity and
  951. * perform the normal operation
  952. *
  953. * User might experience transmit issue on some platform due to WiFi/BT
  954. * co-exist problem. The possible behaviors are:
  955. * Able to scan and finding all the available AP
  956. * Not able to associate with any AP
  957. * On those platforms, WiFi communication can be restored by set
  958. * "bt_coex_active" module parameter to "false"
  959. *
  960. * default: bt_coex_active = true (BT_COEX_ENABLE)
  961. */
  962. module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
  963. bool, S_IRUGO);
  964. MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
  965. module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
  966. MODULE_PARM_DESC(led_mode, "0=system default, "
  967. "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
  968. module_param_named(power_save, iwlwifi_mod_params.power_save,
  969. bool, S_IRUGO);
  970. MODULE_PARM_DESC(power_save,
  971. "enable WiFi power management (default: disable)");
  972. module_param_named(power_level, iwlwifi_mod_params.power_level,
  973. int, S_IRUGO);
  974. MODULE_PARM_DESC(power_level,
  975. "default power save level (range from 1 - 5, default: 1)");
  976. module_param_named(auto_agg, iwlwifi_mod_params.auto_agg,
  977. bool, S_IRUGO);
  978. MODULE_PARM_DESC(auto_agg,
  979. "enable agg w/o check traffic load (default: enable)");
  980. module_param_named(5ghz_disable, iwlwifi_mod_params.disable_5ghz,
  981. bool, S_IRUGO);
  982. MODULE_PARM_DESC(5ghz_disable, "disable 5GHz band (default: 0 [enabled])");