iwl-drv.c 34 KB

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