iwl-drv.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  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. op = &iwlwifi_opmode_table[DVM_OP_MODE];
  802. /* add this device to the list of devices using this op_mode */
  803. list_add_tail(&drv->list, &op->drv);
  804. if (op->ops) {
  805. const struct iwl_op_mode_ops *ops = op->ops;
  806. drv->op_mode = ops->start(drv->trans, drv->cfg, &drv->fw);
  807. if (!drv->op_mode)
  808. goto out_unbind;
  809. } else {
  810. request_module_nowait("%s", op->name);
  811. }
  812. /*
  813. * Complete the firmware request last so that
  814. * a driver unbind (stop) doesn't run while we
  815. * are doing the start() above.
  816. */
  817. complete(&drv->request_firmware_complete);
  818. return;
  819. try_again:
  820. /* try next, if any */
  821. release_firmware(ucode_raw);
  822. if (iwl_request_firmware(drv, false))
  823. goto out_unbind;
  824. return;
  825. out_free_fw:
  826. IWL_ERR(drv, "failed to allocate pci memory\n");
  827. iwl_dealloc_ucode(drv);
  828. release_firmware(ucode_raw);
  829. out_unbind:
  830. complete(&drv->request_firmware_complete);
  831. device_release_driver(drv->trans->dev);
  832. }
  833. struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
  834. const struct iwl_cfg *cfg)
  835. {
  836. struct iwl_drv *drv;
  837. int ret;
  838. drv = kzalloc(sizeof(*drv), GFP_KERNEL);
  839. if (!drv)
  840. return NULL;
  841. drv->trans = trans;
  842. drv->dev = trans->dev;
  843. drv->cfg = cfg;
  844. init_completion(&drv->request_firmware_complete);
  845. ret = iwl_request_firmware(drv, true);
  846. if (ret) {
  847. IWL_ERR(trans, "Couldn't request the fw\n");
  848. kfree(drv);
  849. drv = NULL;
  850. }
  851. return drv;
  852. }
  853. void iwl_drv_stop(struct iwl_drv *drv)
  854. {
  855. wait_for_completion(&drv->request_firmware_complete);
  856. /* op_mode can be NULL if its start failed */
  857. if (drv->op_mode)
  858. iwl_op_mode_stop(drv->op_mode);
  859. iwl_dealloc_ucode(drv);
  860. kfree(drv);
  861. }
  862. /* shared module parameters */
  863. struct iwl_mod_params iwlwifi_mod_params = {
  864. .amsdu_size_8K = 1,
  865. .restart_fw = 1,
  866. .plcp_check = true,
  867. .bt_coex_active = true,
  868. .power_level = IWL_POWER_INDEX_1,
  869. .bt_ch_announce = true,
  870. .auto_agg = true,
  871. /* the rest are 0 by default */
  872. };
  873. EXPORT_SYMBOL_GPL(iwlwifi_mod_params);
  874. int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
  875. {
  876. int i;
  877. struct iwl_drv *drv;
  878. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  879. if (strcmp(iwlwifi_opmode_table[i].name, name))
  880. continue;
  881. iwlwifi_opmode_table[i].ops = ops;
  882. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
  883. drv->op_mode = ops->start(drv->trans, drv->cfg,
  884. &drv->fw);
  885. return 0;
  886. }
  887. return -EIO;
  888. }
  889. EXPORT_SYMBOL_GPL(iwl_opmode_register);
  890. void iwl_opmode_deregister(const char *name)
  891. {
  892. int i;
  893. struct iwl_drv *drv;
  894. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  895. if (strcmp(iwlwifi_opmode_table[i].name, name))
  896. continue;
  897. iwlwifi_opmode_table[i].ops = NULL;
  898. /* call the stop routine for all devices */
  899. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list) {
  900. if (drv->op_mode) {
  901. iwl_op_mode_stop(drv->op_mode);
  902. drv->op_mode = NULL;
  903. }
  904. }
  905. return;
  906. }
  907. }
  908. EXPORT_SYMBOL_GPL(iwl_opmode_deregister);
  909. static int __init iwl_drv_init(void)
  910. {
  911. int i;
  912. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++)
  913. INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);
  914. pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
  915. pr_info(DRV_COPYRIGHT "\n");
  916. return iwl_pci_register_driver();
  917. }
  918. module_init(iwl_drv_init);
  919. static void __exit iwl_drv_exit(void)
  920. {
  921. iwl_pci_unregister_driver();
  922. }
  923. module_exit(iwl_drv_exit);
  924. #ifdef CONFIG_IWLWIFI_DEBUG
  925. module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
  926. S_IRUGO | S_IWUSR);
  927. MODULE_PARM_DESC(debug, "debug output mask");
  928. #endif
  929. module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
  930. MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
  931. module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
  932. MODULE_PARM_DESC(11n_disable,
  933. "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
  934. module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
  935. int, S_IRUGO);
  936. MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
  937. module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO);
  938. MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
  939. module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
  940. int, S_IRUGO);
  941. MODULE_PARM_DESC(antenna_coupling,
  942. "specify antenna coupling in dB (defualt: 0 dB)");
  943. module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce,
  944. bool, S_IRUGO);
  945. MODULE_PARM_DESC(bt_ch_inhibition,
  946. "Enable BT channel inhibition (default: enable)");
  947. module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO);
  948. MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
  949. module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO);
  950. MODULE_PARM_DESC(wd_disable,
  951. "Disable stuck queue watchdog timer 0=system default, "
  952. "1=disable, 2=enable (default: 0)");
  953. /*
  954. * set bt_coex_active to true, uCode will do kill/defer
  955. * every time the priority line is asserted (BT is sending signals on the
  956. * priority line in the PCIx).
  957. * set bt_coex_active to false, uCode will ignore the BT activity and
  958. * perform the normal operation
  959. *
  960. * User might experience transmit issue on some platform due to WiFi/BT
  961. * co-exist problem. The possible behaviors are:
  962. * Able to scan and finding all the available AP
  963. * Not able to associate with any AP
  964. * On those platforms, WiFi communication can be restored by set
  965. * "bt_coex_active" module parameter to "false"
  966. *
  967. * default: bt_coex_active = true (BT_COEX_ENABLE)
  968. */
  969. module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
  970. bool, S_IRUGO);
  971. MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
  972. module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
  973. MODULE_PARM_DESC(led_mode, "0=system default, "
  974. "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
  975. module_param_named(power_save, iwlwifi_mod_params.power_save,
  976. bool, S_IRUGO);
  977. MODULE_PARM_DESC(power_save,
  978. "enable WiFi power management (default: disable)");
  979. module_param_named(power_level, iwlwifi_mod_params.power_level,
  980. int, S_IRUGO);
  981. MODULE_PARM_DESC(power_level,
  982. "default power save level (range from 1 - 5, default: 1)");
  983. module_param_named(auto_agg, iwlwifi_mod_params.auto_agg,
  984. bool, S_IRUGO);
  985. MODULE_PARM_DESC(auto_agg,
  986. "enable agg w/o check traffic load (default: enable)");
  987. module_param_named(5ghz_disable, iwlwifi_mod_params.disable_5ghz,
  988. bool, S_IRUGO);
  989. MODULE_PARM_DESC(5ghz_disable, "disable 5GHz band (default: 0 [enabled])");