iwl-drv.c 34 KB

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