iwl-drv.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622
  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 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #include <linux/completion.h>
  66. #include <linux/dma-mapping.h>
  67. #include <linux/firmware.h>
  68. #include <linux/module.h>
  69. #include <linux/vmalloc.h>
  70. #include "iwl-drv.h"
  71. #include "iwl-csr.h"
  72. #include "iwl-debug.h"
  73. #include "iwl-trans.h"
  74. #include "iwl-op-mode.h"
  75. #include "iwl-agn-hw.h"
  76. #include "iwl-fw.h"
  77. #include "iwl-config.h"
  78. #include "iwl-modparams.h"
  79. /******************************************************************************
  80. *
  81. * module boiler plate
  82. *
  83. ******************************************************************************/
  84. #define DRV_DESCRIPTION "Intel(R) Wireless WiFi driver for Linux"
  85. MODULE_DESCRIPTION(DRV_DESCRIPTION);
  86. MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
  87. MODULE_LICENSE("GPL");
  88. #ifdef CONFIG_IWLWIFI_DEBUGFS
  89. static struct dentry *iwl_dbgfs_root;
  90. #endif
  91. /**
  92. * struct iwl_drv - drv common data
  93. * @list: list of drv structures using this opmode
  94. * @fw: the iwl_fw structure
  95. * @op_mode: the running op_mode
  96. * @trans: transport layer
  97. * @dev: for debug prints only
  98. * @cfg: configuration struct
  99. * @fw_index: firmware revision to try loading
  100. * @firmware_name: composite filename of ucode file to load
  101. * @request_firmware_complete: the firmware has been obtained from user space
  102. */
  103. struct iwl_drv {
  104. struct list_head list;
  105. struct iwl_fw fw;
  106. struct iwl_op_mode *op_mode;
  107. struct iwl_trans *trans;
  108. struct device *dev;
  109. const struct iwl_cfg *cfg;
  110. int fw_index; /* firmware we're trying to load */
  111. char firmware_name[32]; /* name of firmware file to load */
  112. struct completion request_firmware_complete;
  113. #ifdef CONFIG_IWLWIFI_DEBUGFS
  114. struct dentry *dbgfs_drv;
  115. struct dentry *dbgfs_trans;
  116. struct dentry *dbgfs_op_mode;
  117. #endif
  118. };
  119. enum {
  120. DVM_OP_MODE = 0,
  121. MVM_OP_MODE = 1,
  122. };
  123. /* Protects the table contents, i.e. the ops pointer & drv list */
  124. static struct mutex iwlwifi_opmode_table_mtx;
  125. static struct iwlwifi_opmode_table {
  126. const char *name; /* name: iwldvm, iwlmvm, etc */
  127. const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */
  128. struct list_head drv; /* list of devices using this op_mode */
  129. } iwlwifi_opmode_table[] = { /* ops set when driver is initialized */
  130. [DVM_OP_MODE] = { .name = "iwldvm", .ops = NULL },
  131. [MVM_OP_MODE] = { .name = "iwlmvm", .ops = NULL },
  132. };
  133. #define IWL_DEFAULT_SCAN_CHANNELS 40
  134. /*
  135. * struct fw_sec: Just for the image parsing process.
  136. * For the fw storage we are using struct fw_desc.
  137. */
  138. struct fw_sec {
  139. const void *data; /* the sec data */
  140. size_t size; /* section size */
  141. u32 offset; /* offset of writing in the device */
  142. };
  143. static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
  144. {
  145. vfree(desc->data);
  146. desc->data = NULL;
  147. desc->len = 0;
  148. }
  149. static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
  150. {
  151. int i;
  152. for (i = 0; i < IWL_UCODE_SECTION_MAX; i++)
  153. iwl_free_fw_desc(drv, &img->sec[i]);
  154. }
  155. static void iwl_dealloc_ucode(struct iwl_drv *drv)
  156. {
  157. int i;
  158. kfree(drv->fw.dbg_dest_tlv);
  159. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_conf_tlv); i++)
  160. kfree(drv->fw.dbg_conf_tlv[i]);
  161. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_trigger_tlv); i++)
  162. kfree(drv->fw.dbg_trigger_tlv[i]);
  163. for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
  164. iwl_free_fw_img(drv, drv->fw.img + i);
  165. }
  166. static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
  167. struct fw_sec *sec)
  168. {
  169. void *data;
  170. desc->data = NULL;
  171. if (!sec || !sec->size)
  172. return -EINVAL;
  173. data = vmalloc(sec->size);
  174. if (!data)
  175. return -ENOMEM;
  176. desc->len = sec->size;
  177. desc->offset = sec->offset;
  178. memcpy(data, sec->data, desc->len);
  179. desc->data = data;
  180. return 0;
  181. }
  182. static void iwl_req_fw_callback(const struct firmware *ucode_raw,
  183. void *context);
  184. #define UCODE_EXPERIMENTAL_INDEX 100
  185. #define UCODE_EXPERIMENTAL_TAG "exp"
  186. static int iwl_request_firmware(struct iwl_drv *drv, bool first)
  187. {
  188. const char *name_pre = drv->cfg->fw_name_pre;
  189. char tag[8];
  190. if (first) {
  191. #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
  192. drv->fw_index = UCODE_EXPERIMENTAL_INDEX;
  193. strcpy(tag, UCODE_EXPERIMENTAL_TAG);
  194. } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
  195. #endif
  196. drv->fw_index = drv->cfg->ucode_api_max;
  197. sprintf(tag, "%d", drv->fw_index);
  198. } else {
  199. drv->fw_index--;
  200. sprintf(tag, "%d", drv->fw_index);
  201. }
  202. if (drv->fw_index < drv->cfg->ucode_api_min) {
  203. IWL_ERR(drv, "no suitable firmware found!\n");
  204. return -ENOENT;
  205. }
  206. snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode",
  207. name_pre, tag);
  208. /*
  209. * Starting 8000B - FW name format has changed. This overwrites the
  210. * previous name and uses the new format.
  211. */
  212. if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) {
  213. char rev_step = 'A' + CSR_HW_REV_STEP(drv->trans->hw_rev);
  214. snprintf(drv->firmware_name, sizeof(drv->firmware_name),
  215. "%s%c-%s.ucode", name_pre, rev_step, tag);
  216. }
  217. IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
  218. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  219. ? "EXPERIMENTAL " : "",
  220. drv->firmware_name);
  221. return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
  222. drv->trans->dev,
  223. GFP_KERNEL, drv, iwl_req_fw_callback);
  224. }
  225. struct fw_img_parsing {
  226. struct fw_sec sec[IWL_UCODE_SECTION_MAX];
  227. int sec_counter;
  228. };
  229. /*
  230. * struct fw_sec_parsing: to extract fw section and it's offset from tlv
  231. */
  232. struct fw_sec_parsing {
  233. __le32 offset;
  234. const u8 data[];
  235. } __packed;
  236. /**
  237. * struct iwl_tlv_calib_data - parse the default calib data from TLV
  238. *
  239. * @ucode_type: the uCode to which the following default calib relates.
  240. * @calib: default calibrations.
  241. */
  242. struct iwl_tlv_calib_data {
  243. __le32 ucode_type;
  244. struct iwl_tlv_calib_ctrl calib;
  245. } __packed;
  246. struct iwl_firmware_pieces {
  247. struct fw_img_parsing img[IWL_UCODE_TYPE_MAX];
  248. u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
  249. u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
  250. /* FW debug data parsed for driver usage */
  251. struct iwl_fw_dbg_dest_tlv *dbg_dest_tlv;
  252. struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX];
  253. size_t dbg_conf_tlv_len[FW_DBG_CONF_MAX];
  254. struct iwl_fw_dbg_trigger_tlv *dbg_trigger_tlv[FW_DBG_TRIGGER_MAX];
  255. size_t dbg_trigger_tlv_len[FW_DBG_TRIGGER_MAX];
  256. };
  257. /*
  258. * These functions are just to extract uCode section data from the pieces
  259. * structure.
  260. */
  261. static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces,
  262. enum iwl_ucode_type type,
  263. int sec)
  264. {
  265. return &pieces->img[type].sec[sec];
  266. }
  267. static void set_sec_data(struct iwl_firmware_pieces *pieces,
  268. enum iwl_ucode_type type,
  269. int sec,
  270. const void *data)
  271. {
  272. pieces->img[type].sec[sec].data = data;
  273. }
  274. static void set_sec_size(struct iwl_firmware_pieces *pieces,
  275. enum iwl_ucode_type type,
  276. int sec,
  277. size_t size)
  278. {
  279. pieces->img[type].sec[sec].size = size;
  280. }
  281. static size_t get_sec_size(struct iwl_firmware_pieces *pieces,
  282. enum iwl_ucode_type type,
  283. int sec)
  284. {
  285. return pieces->img[type].sec[sec].size;
  286. }
  287. static void set_sec_offset(struct iwl_firmware_pieces *pieces,
  288. enum iwl_ucode_type type,
  289. int sec,
  290. u32 offset)
  291. {
  292. pieces->img[type].sec[sec].offset = offset;
  293. }
  294. static int iwl_store_cscheme(struct iwl_fw *fw, const u8 *data, const u32 len)
  295. {
  296. int i, j;
  297. struct iwl_fw_cscheme_list *l = (struct iwl_fw_cscheme_list *)data;
  298. struct iwl_fw_cipher_scheme *fwcs;
  299. struct ieee80211_cipher_scheme *cs;
  300. u32 cipher;
  301. if (len < sizeof(*l) ||
  302. len < sizeof(l->size) + l->size * sizeof(l->cs[0]))
  303. return -EINVAL;
  304. for (i = 0, j = 0; i < IWL_UCODE_MAX_CS && i < l->size; i++) {
  305. fwcs = &l->cs[j];
  306. cipher = le32_to_cpu(fwcs->cipher);
  307. /* we skip schemes with zero cipher suite selector */
  308. if (!cipher)
  309. continue;
  310. cs = &fw->cs[j++];
  311. cs->cipher = cipher;
  312. cs->iftype = BIT(NL80211_IFTYPE_STATION);
  313. cs->hdr_len = fwcs->hdr_len;
  314. cs->pn_len = fwcs->pn_len;
  315. cs->pn_off = fwcs->pn_off;
  316. cs->key_idx_off = fwcs->key_idx_off;
  317. cs->key_idx_mask = fwcs->key_idx_mask;
  318. cs->key_idx_shift = fwcs->key_idx_shift;
  319. cs->mic_len = fwcs->mic_len;
  320. }
  321. return 0;
  322. }
  323. /*
  324. * Gets uCode section from tlv.
  325. */
  326. static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces,
  327. const void *data, enum iwl_ucode_type type,
  328. int size)
  329. {
  330. struct fw_img_parsing *img;
  331. struct fw_sec *sec;
  332. struct fw_sec_parsing *sec_parse;
  333. if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX))
  334. return -1;
  335. sec_parse = (struct fw_sec_parsing *)data;
  336. img = &pieces->img[type];
  337. sec = &img->sec[img->sec_counter];
  338. sec->offset = le32_to_cpu(sec_parse->offset);
  339. sec->data = sec_parse->data;
  340. sec->size = size - sizeof(sec_parse->offset);
  341. ++img->sec_counter;
  342. return 0;
  343. }
  344. static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data)
  345. {
  346. struct iwl_tlv_calib_data *def_calib =
  347. (struct iwl_tlv_calib_data *)data;
  348. u32 ucode_type = le32_to_cpu(def_calib->ucode_type);
  349. if (ucode_type >= IWL_UCODE_TYPE_MAX) {
  350. IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n",
  351. ucode_type);
  352. return -EINVAL;
  353. }
  354. drv->fw.default_calib[ucode_type].flow_trigger =
  355. def_calib->calib.flow_trigger;
  356. drv->fw.default_calib[ucode_type].event_trigger =
  357. def_calib->calib.event_trigger;
  358. return 0;
  359. }
  360. static int iwl_set_ucode_api_flags(struct iwl_drv *drv, const u8 *data,
  361. struct iwl_ucode_capabilities *capa)
  362. {
  363. const struct iwl_ucode_api *ucode_api = (void *)data;
  364. u32 api_index = le32_to_cpu(ucode_api->api_index);
  365. if (api_index >= IWL_API_ARRAY_SIZE) {
  366. IWL_ERR(drv, "api_index larger than supported by driver\n");
  367. return -EINVAL;
  368. }
  369. capa->api[api_index] = le32_to_cpu(ucode_api->api_flags);
  370. return 0;
  371. }
  372. static int iwl_set_ucode_capabilities(struct iwl_drv *drv, const u8 *data,
  373. struct iwl_ucode_capabilities *capa)
  374. {
  375. const struct iwl_ucode_capa *ucode_capa = (void *)data;
  376. u32 api_index = le32_to_cpu(ucode_capa->api_index);
  377. if (api_index >= IWL_CAPABILITIES_ARRAY_SIZE) {
  378. IWL_ERR(drv, "api_index larger than supported by driver\n");
  379. return -EINVAL;
  380. }
  381. capa->capa[api_index] = le32_to_cpu(ucode_capa->api_capa);
  382. return 0;
  383. }
  384. static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
  385. const struct firmware *ucode_raw,
  386. struct iwl_firmware_pieces *pieces)
  387. {
  388. struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
  389. u32 api_ver, hdr_size, build;
  390. char buildstr[25];
  391. const u8 *src;
  392. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  393. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  394. switch (api_ver) {
  395. default:
  396. hdr_size = 28;
  397. if (ucode_raw->size < hdr_size) {
  398. IWL_ERR(drv, "File size too small!\n");
  399. return -EINVAL;
  400. }
  401. build = le32_to_cpu(ucode->u.v2.build);
  402. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  403. le32_to_cpu(ucode->u.v2.inst_size));
  404. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  405. le32_to_cpu(ucode->u.v2.data_size));
  406. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  407. le32_to_cpu(ucode->u.v2.init_size));
  408. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  409. le32_to_cpu(ucode->u.v2.init_data_size));
  410. src = ucode->u.v2.data;
  411. break;
  412. case 0:
  413. case 1:
  414. case 2:
  415. hdr_size = 24;
  416. if (ucode_raw->size < hdr_size) {
  417. IWL_ERR(drv, "File size too small!\n");
  418. return -EINVAL;
  419. }
  420. build = 0;
  421. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  422. le32_to_cpu(ucode->u.v1.inst_size));
  423. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  424. le32_to_cpu(ucode->u.v1.data_size));
  425. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  426. le32_to_cpu(ucode->u.v1.init_size));
  427. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  428. le32_to_cpu(ucode->u.v1.init_data_size));
  429. src = ucode->u.v1.data;
  430. break;
  431. }
  432. if (build)
  433. sprintf(buildstr, " build %u%s", build,
  434. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  435. ? " (EXP)" : "");
  436. else
  437. buildstr[0] = '\0';
  438. snprintf(drv->fw.fw_version,
  439. sizeof(drv->fw.fw_version),
  440. "%u.%u.%u.%u%s",
  441. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  442. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  443. IWL_UCODE_API(drv->fw.ucode_ver),
  444. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  445. buildstr);
  446. /* Verify size of file vs. image size info in file's header */
  447. if (ucode_raw->size != hdr_size +
  448. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) +
  449. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) +
  450. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) +
  451. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
  452. IWL_ERR(drv,
  453. "uCode file size %d does not match expected size\n",
  454. (int)ucode_raw->size);
  455. return -EINVAL;
  456. }
  457. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src);
  458. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST);
  459. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  460. IWLAGN_RTC_INST_LOWER_BOUND);
  461. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src);
  462. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA);
  463. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  464. IWLAGN_RTC_DATA_LOWER_BOUND);
  465. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src);
  466. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST);
  467. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  468. IWLAGN_RTC_INST_LOWER_BOUND);
  469. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src);
  470. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA);
  471. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  472. IWLAGN_RTC_DATA_LOWER_BOUND);
  473. return 0;
  474. }
  475. static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
  476. const struct firmware *ucode_raw,
  477. struct iwl_firmware_pieces *pieces,
  478. struct iwl_ucode_capabilities *capa)
  479. {
  480. struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
  481. struct iwl_ucode_tlv *tlv;
  482. size_t len = ucode_raw->size;
  483. const u8 *data;
  484. u32 tlv_len;
  485. enum iwl_ucode_tlv_type tlv_type;
  486. const u8 *tlv_data;
  487. char buildstr[25];
  488. u32 build;
  489. int num_of_cpus;
  490. bool usniffer_images = false;
  491. bool usniffer_req = false;
  492. if (len < sizeof(*ucode)) {
  493. IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
  494. return -EINVAL;
  495. }
  496. if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
  497. IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
  498. le32_to_cpu(ucode->magic));
  499. return -EINVAL;
  500. }
  501. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  502. memcpy(drv->fw.human_readable, ucode->human_readable,
  503. sizeof(drv->fw.human_readable));
  504. build = le32_to_cpu(ucode->build);
  505. if (build)
  506. sprintf(buildstr, " build %u%s", build,
  507. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  508. ? " (EXP)" : "");
  509. else
  510. buildstr[0] = '\0';
  511. snprintf(drv->fw.fw_version,
  512. sizeof(drv->fw.fw_version),
  513. "%u.%u.%u.%u%s",
  514. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  515. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  516. IWL_UCODE_API(drv->fw.ucode_ver),
  517. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  518. buildstr);
  519. data = ucode->data;
  520. len -= sizeof(*ucode);
  521. while (len >= sizeof(*tlv)) {
  522. len -= sizeof(*tlv);
  523. tlv = (void *)data;
  524. tlv_len = le32_to_cpu(tlv->length);
  525. tlv_type = le32_to_cpu(tlv->type);
  526. tlv_data = tlv->data;
  527. if (len < tlv_len) {
  528. IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
  529. len, tlv_len);
  530. return -EINVAL;
  531. }
  532. len -= ALIGN(tlv_len, 4);
  533. data += sizeof(*tlv) + ALIGN(tlv_len, 4);
  534. switch (tlv_type) {
  535. case IWL_UCODE_TLV_INST:
  536. set_sec_data(pieces, IWL_UCODE_REGULAR,
  537. IWL_UCODE_SECTION_INST, tlv_data);
  538. set_sec_size(pieces, IWL_UCODE_REGULAR,
  539. IWL_UCODE_SECTION_INST, tlv_len);
  540. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  541. IWL_UCODE_SECTION_INST,
  542. IWLAGN_RTC_INST_LOWER_BOUND);
  543. break;
  544. case IWL_UCODE_TLV_DATA:
  545. set_sec_data(pieces, IWL_UCODE_REGULAR,
  546. IWL_UCODE_SECTION_DATA, tlv_data);
  547. set_sec_size(pieces, IWL_UCODE_REGULAR,
  548. IWL_UCODE_SECTION_DATA, tlv_len);
  549. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  550. IWL_UCODE_SECTION_DATA,
  551. IWLAGN_RTC_DATA_LOWER_BOUND);
  552. break;
  553. case IWL_UCODE_TLV_INIT:
  554. set_sec_data(pieces, IWL_UCODE_INIT,
  555. IWL_UCODE_SECTION_INST, tlv_data);
  556. set_sec_size(pieces, IWL_UCODE_INIT,
  557. IWL_UCODE_SECTION_INST, tlv_len);
  558. set_sec_offset(pieces, IWL_UCODE_INIT,
  559. IWL_UCODE_SECTION_INST,
  560. IWLAGN_RTC_INST_LOWER_BOUND);
  561. break;
  562. case IWL_UCODE_TLV_INIT_DATA:
  563. set_sec_data(pieces, IWL_UCODE_INIT,
  564. IWL_UCODE_SECTION_DATA, tlv_data);
  565. set_sec_size(pieces, IWL_UCODE_INIT,
  566. IWL_UCODE_SECTION_DATA, tlv_len);
  567. set_sec_offset(pieces, IWL_UCODE_INIT,
  568. IWL_UCODE_SECTION_DATA,
  569. IWLAGN_RTC_DATA_LOWER_BOUND);
  570. break;
  571. case IWL_UCODE_TLV_BOOT:
  572. IWL_ERR(drv, "Found unexpected BOOT ucode\n");
  573. break;
  574. case IWL_UCODE_TLV_PROBE_MAX_LEN:
  575. if (tlv_len != sizeof(u32))
  576. goto invalid_tlv_len;
  577. capa->max_probe_length =
  578. le32_to_cpup((__le32 *)tlv_data);
  579. break;
  580. case IWL_UCODE_TLV_PAN:
  581. if (tlv_len)
  582. goto invalid_tlv_len;
  583. capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
  584. break;
  585. case IWL_UCODE_TLV_FLAGS:
  586. /* must be at least one u32 */
  587. if (tlv_len < sizeof(u32))
  588. goto invalid_tlv_len;
  589. /* and a proper number of u32s */
  590. if (tlv_len % sizeof(u32))
  591. goto invalid_tlv_len;
  592. /*
  593. * This driver only reads the first u32 as
  594. * right now no more features are defined,
  595. * if that changes then either the driver
  596. * will not work with the new firmware, or
  597. * it'll not take advantage of new features.
  598. */
  599. capa->flags = le32_to_cpup((__le32 *)tlv_data);
  600. break;
  601. case IWL_UCODE_TLV_API_CHANGES_SET:
  602. if (tlv_len != sizeof(struct iwl_ucode_api))
  603. goto invalid_tlv_len;
  604. if (iwl_set_ucode_api_flags(drv, tlv_data, capa))
  605. goto tlv_error;
  606. break;
  607. case IWL_UCODE_TLV_ENABLED_CAPABILITIES:
  608. if (tlv_len != sizeof(struct iwl_ucode_capa))
  609. goto invalid_tlv_len;
  610. if (iwl_set_ucode_capabilities(drv, tlv_data, capa))
  611. goto tlv_error;
  612. break;
  613. case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
  614. if (tlv_len != sizeof(u32))
  615. goto invalid_tlv_len;
  616. pieces->init_evtlog_ptr =
  617. le32_to_cpup((__le32 *)tlv_data);
  618. break;
  619. case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
  620. if (tlv_len != sizeof(u32))
  621. goto invalid_tlv_len;
  622. pieces->init_evtlog_size =
  623. le32_to_cpup((__le32 *)tlv_data);
  624. break;
  625. case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
  626. if (tlv_len != sizeof(u32))
  627. goto invalid_tlv_len;
  628. pieces->init_errlog_ptr =
  629. le32_to_cpup((__le32 *)tlv_data);
  630. break;
  631. case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
  632. if (tlv_len != sizeof(u32))
  633. goto invalid_tlv_len;
  634. pieces->inst_evtlog_ptr =
  635. le32_to_cpup((__le32 *)tlv_data);
  636. break;
  637. case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
  638. if (tlv_len != sizeof(u32))
  639. goto invalid_tlv_len;
  640. pieces->inst_evtlog_size =
  641. le32_to_cpup((__le32 *)tlv_data);
  642. break;
  643. case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
  644. if (tlv_len != sizeof(u32))
  645. goto invalid_tlv_len;
  646. pieces->inst_errlog_ptr =
  647. le32_to_cpup((__le32 *)tlv_data);
  648. break;
  649. case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
  650. if (tlv_len)
  651. goto invalid_tlv_len;
  652. drv->fw.enhance_sensitivity_table = true;
  653. break;
  654. case IWL_UCODE_TLV_WOWLAN_INST:
  655. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  656. IWL_UCODE_SECTION_INST, tlv_data);
  657. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  658. IWL_UCODE_SECTION_INST, tlv_len);
  659. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  660. IWL_UCODE_SECTION_INST,
  661. IWLAGN_RTC_INST_LOWER_BOUND);
  662. break;
  663. case IWL_UCODE_TLV_WOWLAN_DATA:
  664. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  665. IWL_UCODE_SECTION_DATA, tlv_data);
  666. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  667. IWL_UCODE_SECTION_DATA, tlv_len);
  668. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  669. IWL_UCODE_SECTION_DATA,
  670. IWLAGN_RTC_DATA_LOWER_BOUND);
  671. break;
  672. case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
  673. if (tlv_len != sizeof(u32))
  674. goto invalid_tlv_len;
  675. capa->standard_phy_calibration_size =
  676. le32_to_cpup((__le32 *)tlv_data);
  677. break;
  678. case IWL_UCODE_TLV_SEC_RT:
  679. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
  680. tlv_len);
  681. drv->fw.mvm_fw = true;
  682. break;
  683. case IWL_UCODE_TLV_SEC_INIT:
  684. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
  685. tlv_len);
  686. drv->fw.mvm_fw = true;
  687. break;
  688. case IWL_UCODE_TLV_SEC_WOWLAN:
  689. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
  690. tlv_len);
  691. drv->fw.mvm_fw = true;
  692. break;
  693. case IWL_UCODE_TLV_DEF_CALIB:
  694. if (tlv_len != sizeof(struct iwl_tlv_calib_data))
  695. goto invalid_tlv_len;
  696. if (iwl_set_default_calib(drv, tlv_data))
  697. goto tlv_error;
  698. break;
  699. case IWL_UCODE_TLV_PHY_SKU:
  700. if (tlv_len != sizeof(u32))
  701. goto invalid_tlv_len;
  702. drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data);
  703. drv->fw.valid_tx_ant = (drv->fw.phy_config &
  704. FW_PHY_CFG_TX_CHAIN) >>
  705. FW_PHY_CFG_TX_CHAIN_POS;
  706. drv->fw.valid_rx_ant = (drv->fw.phy_config &
  707. FW_PHY_CFG_RX_CHAIN) >>
  708. FW_PHY_CFG_RX_CHAIN_POS;
  709. break;
  710. case IWL_UCODE_TLV_SECURE_SEC_RT:
  711. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
  712. tlv_len);
  713. drv->fw.mvm_fw = true;
  714. break;
  715. case IWL_UCODE_TLV_SECURE_SEC_INIT:
  716. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
  717. tlv_len);
  718. drv->fw.mvm_fw = true;
  719. break;
  720. case IWL_UCODE_TLV_SECURE_SEC_WOWLAN:
  721. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
  722. tlv_len);
  723. drv->fw.mvm_fw = true;
  724. break;
  725. case IWL_UCODE_TLV_NUM_OF_CPU:
  726. if (tlv_len != sizeof(u32))
  727. goto invalid_tlv_len;
  728. num_of_cpus =
  729. le32_to_cpup((__le32 *)tlv_data);
  730. if (num_of_cpus == 2) {
  731. drv->fw.img[IWL_UCODE_REGULAR].is_dual_cpus =
  732. true;
  733. drv->fw.img[IWL_UCODE_INIT].is_dual_cpus =
  734. true;
  735. drv->fw.img[IWL_UCODE_WOWLAN].is_dual_cpus =
  736. true;
  737. } else if ((num_of_cpus > 2) || (num_of_cpus < 1)) {
  738. IWL_ERR(drv, "Driver support upto 2 CPUs\n");
  739. return -EINVAL;
  740. }
  741. break;
  742. case IWL_UCODE_TLV_CSCHEME:
  743. if (iwl_store_cscheme(&drv->fw, tlv_data, tlv_len))
  744. goto invalid_tlv_len;
  745. break;
  746. case IWL_UCODE_TLV_N_SCAN_CHANNELS:
  747. if (tlv_len != sizeof(u32))
  748. goto invalid_tlv_len;
  749. capa->n_scan_channels =
  750. le32_to_cpup((__le32 *)tlv_data);
  751. break;
  752. case IWL_UCODE_TLV_FW_VERSION: {
  753. __le32 *ptr = (void *)tlv_data;
  754. u32 major, minor;
  755. u8 local_comp;
  756. if (tlv_len != sizeof(u32) * 3)
  757. goto invalid_tlv_len;
  758. major = le32_to_cpup(ptr++);
  759. minor = le32_to_cpup(ptr++);
  760. local_comp = le32_to_cpup(ptr);
  761. snprintf(drv->fw.fw_version,
  762. sizeof(drv->fw.fw_version), "%u.%u.%u",
  763. major, minor, local_comp);
  764. break;
  765. }
  766. case IWL_UCODE_TLV_FW_DBG_DEST: {
  767. struct iwl_fw_dbg_dest_tlv *dest = (void *)tlv_data;
  768. if (pieces->dbg_dest_tlv) {
  769. IWL_ERR(drv,
  770. "dbg destination ignored, already exists\n");
  771. break;
  772. }
  773. pieces->dbg_dest_tlv = dest;
  774. IWL_INFO(drv, "Found debug destination: %s\n",
  775. get_fw_dbg_mode_string(dest->monitor_mode));
  776. drv->fw.dbg_dest_reg_num =
  777. tlv_len - offsetof(struct iwl_fw_dbg_dest_tlv,
  778. reg_ops);
  779. drv->fw.dbg_dest_reg_num /=
  780. sizeof(drv->fw.dbg_dest_tlv->reg_ops[0]);
  781. break;
  782. }
  783. case IWL_UCODE_TLV_FW_DBG_CONF: {
  784. struct iwl_fw_dbg_conf_tlv *conf = (void *)tlv_data;
  785. if (!pieces->dbg_dest_tlv) {
  786. IWL_ERR(drv,
  787. "Ignore dbg config %d - no destination configured\n",
  788. conf->id);
  789. break;
  790. }
  791. if (conf->id >= ARRAY_SIZE(drv->fw.dbg_conf_tlv)) {
  792. IWL_ERR(drv,
  793. "Skip unknown configuration: %d\n",
  794. conf->id);
  795. break;
  796. }
  797. if (pieces->dbg_conf_tlv[conf->id]) {
  798. IWL_ERR(drv,
  799. "Ignore duplicate dbg config %d\n",
  800. conf->id);
  801. break;
  802. }
  803. if (conf->usniffer)
  804. usniffer_req = true;
  805. IWL_INFO(drv, "Found debug configuration: %d\n",
  806. conf->id);
  807. pieces->dbg_conf_tlv[conf->id] = conf;
  808. pieces->dbg_conf_tlv_len[conf->id] = tlv_len;
  809. break;
  810. }
  811. case IWL_UCODE_TLV_FW_DBG_TRIGGER: {
  812. struct iwl_fw_dbg_trigger_tlv *trigger =
  813. (void *)tlv_data;
  814. u32 trigger_id = le32_to_cpu(trigger->id);
  815. if (trigger_id >= ARRAY_SIZE(drv->fw.dbg_trigger_tlv)) {
  816. IWL_ERR(drv,
  817. "Skip unknown trigger: %u\n",
  818. trigger->id);
  819. break;
  820. }
  821. if (pieces->dbg_trigger_tlv[trigger_id]) {
  822. IWL_ERR(drv,
  823. "Ignore duplicate dbg trigger %u\n",
  824. trigger->id);
  825. break;
  826. }
  827. IWL_INFO(drv, "Found debug trigger: %u\n", trigger->id);
  828. pieces->dbg_trigger_tlv[trigger_id] = trigger;
  829. pieces->dbg_trigger_tlv_len[trigger_id] = tlv_len;
  830. break;
  831. }
  832. case IWL_UCODE_TLV_SEC_RT_USNIFFER:
  833. usniffer_images = true;
  834. iwl_store_ucode_sec(pieces, tlv_data,
  835. IWL_UCODE_REGULAR_USNIFFER,
  836. tlv_len);
  837. break;
  838. case IWL_UCODE_TLV_SDIO_ADMA_ADDR:
  839. if (tlv_len != sizeof(u32))
  840. goto invalid_tlv_len;
  841. drv->fw.sdio_adma_addr =
  842. le32_to_cpup((__le32 *)tlv_data);
  843. break;
  844. default:
  845. IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
  846. break;
  847. }
  848. }
  849. if (usniffer_req && !usniffer_images) {
  850. IWL_ERR(drv,
  851. "user selected to work with usniffer but usniffer image isn't available in ucode package\n");
  852. return -EINVAL;
  853. }
  854. if (len) {
  855. IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
  856. iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
  857. return -EINVAL;
  858. }
  859. return 0;
  860. invalid_tlv_len:
  861. IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
  862. tlv_error:
  863. iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
  864. return -EINVAL;
  865. }
  866. static int iwl_alloc_ucode(struct iwl_drv *drv,
  867. struct iwl_firmware_pieces *pieces,
  868. enum iwl_ucode_type type)
  869. {
  870. int i;
  871. for (i = 0;
  872. i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i);
  873. i++)
  874. if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]),
  875. get_sec(pieces, type, i)))
  876. return -ENOMEM;
  877. return 0;
  878. }
  879. static int validate_sec_sizes(struct iwl_drv *drv,
  880. struct iwl_firmware_pieces *pieces,
  881. const struct iwl_cfg *cfg)
  882. {
  883. IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
  884. get_sec_size(pieces, IWL_UCODE_REGULAR,
  885. IWL_UCODE_SECTION_INST));
  886. IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
  887. get_sec_size(pieces, IWL_UCODE_REGULAR,
  888. IWL_UCODE_SECTION_DATA));
  889. IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
  890. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST));
  891. IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
  892. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA));
  893. /* Verify that uCode images will fit in card's SRAM. */
  894. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) >
  895. cfg->max_inst_size) {
  896. IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
  897. get_sec_size(pieces, IWL_UCODE_REGULAR,
  898. IWL_UCODE_SECTION_INST));
  899. return -1;
  900. }
  901. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) >
  902. cfg->max_data_size) {
  903. IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
  904. get_sec_size(pieces, IWL_UCODE_REGULAR,
  905. IWL_UCODE_SECTION_DATA));
  906. return -1;
  907. }
  908. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) >
  909. cfg->max_inst_size) {
  910. IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
  911. get_sec_size(pieces, IWL_UCODE_INIT,
  912. IWL_UCODE_SECTION_INST));
  913. return -1;
  914. }
  915. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) >
  916. cfg->max_data_size) {
  917. IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
  918. get_sec_size(pieces, IWL_UCODE_REGULAR,
  919. IWL_UCODE_SECTION_DATA));
  920. return -1;
  921. }
  922. return 0;
  923. }
  924. static struct iwl_op_mode *
  925. _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op)
  926. {
  927. const struct iwl_op_mode_ops *ops = op->ops;
  928. struct dentry *dbgfs_dir = NULL;
  929. struct iwl_op_mode *op_mode = NULL;
  930. #ifdef CONFIG_IWLWIFI_DEBUGFS
  931. drv->dbgfs_op_mode = debugfs_create_dir(op->name,
  932. drv->dbgfs_drv);
  933. if (!drv->dbgfs_op_mode) {
  934. IWL_ERR(drv,
  935. "failed to create opmode debugfs directory\n");
  936. return op_mode;
  937. }
  938. dbgfs_dir = drv->dbgfs_op_mode;
  939. #endif
  940. op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir);
  941. #ifdef CONFIG_IWLWIFI_DEBUGFS
  942. if (!op_mode) {
  943. debugfs_remove_recursive(drv->dbgfs_op_mode);
  944. drv->dbgfs_op_mode = NULL;
  945. }
  946. #endif
  947. return op_mode;
  948. }
  949. static void _iwl_op_mode_stop(struct iwl_drv *drv)
  950. {
  951. /* op_mode can be NULL if its start failed */
  952. if (drv->op_mode) {
  953. iwl_op_mode_stop(drv->op_mode);
  954. drv->op_mode = NULL;
  955. #ifdef CONFIG_IWLWIFI_DEBUGFS
  956. debugfs_remove_recursive(drv->dbgfs_op_mode);
  957. drv->dbgfs_op_mode = NULL;
  958. #endif
  959. }
  960. }
  961. /**
  962. * iwl_req_fw_callback - callback when firmware was loaded
  963. *
  964. * If loaded successfully, copies the firmware into buffers
  965. * for the card to fetch (via DMA).
  966. */
  967. static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
  968. {
  969. struct iwl_drv *drv = context;
  970. struct iwl_fw *fw = &drv->fw;
  971. struct iwl_ucode_header *ucode;
  972. struct iwlwifi_opmode_table *op;
  973. int err;
  974. struct iwl_firmware_pieces *pieces;
  975. const unsigned int api_max = drv->cfg->ucode_api_max;
  976. unsigned int api_ok = drv->cfg->ucode_api_ok;
  977. const unsigned int api_min = drv->cfg->ucode_api_min;
  978. size_t trigger_tlv_sz[FW_DBG_TRIGGER_MAX];
  979. u32 api_ver;
  980. int i;
  981. bool load_module = false;
  982. fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH;
  983. fw->ucode_capa.standard_phy_calibration_size =
  984. IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  985. fw->ucode_capa.n_scan_channels = IWL_DEFAULT_SCAN_CHANNELS;
  986. if (!api_ok)
  987. api_ok = api_max;
  988. pieces = kzalloc(sizeof(*pieces), GFP_KERNEL);
  989. if (!pieces)
  990. return;
  991. if (!ucode_raw) {
  992. if (drv->fw_index <= api_ok)
  993. IWL_ERR(drv,
  994. "request for firmware file '%s' failed.\n",
  995. drv->firmware_name);
  996. goto try_again;
  997. }
  998. IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
  999. drv->firmware_name, ucode_raw->size);
  1000. /* Make sure that we got at least the API version number */
  1001. if (ucode_raw->size < 4) {
  1002. IWL_ERR(drv, "File size way too small!\n");
  1003. goto try_again;
  1004. }
  1005. /* Data from ucode file: header followed by uCode images */
  1006. ucode = (struct iwl_ucode_header *)ucode_raw->data;
  1007. if (ucode->ver)
  1008. err = iwl_parse_v1_v2_firmware(drv, ucode_raw, pieces);
  1009. else
  1010. err = iwl_parse_tlv_firmware(drv, ucode_raw, pieces,
  1011. &fw->ucode_capa);
  1012. if (err)
  1013. goto try_again;
  1014. if (drv->fw.ucode_capa.api[0] & IWL_UCODE_TLV_API_NEW_VERSION)
  1015. api_ver = drv->fw.ucode_ver;
  1016. else
  1017. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  1018. /*
  1019. * api_ver should match the api version forming part of the
  1020. * firmware filename ... but we don't check for that and only rely
  1021. * on the API version read from firmware header from here on forward
  1022. */
  1023. /* no api version check required for experimental uCode */
  1024. if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
  1025. if (api_ver < api_min || api_ver > api_max) {
  1026. IWL_ERR(drv,
  1027. "Driver unable to support your firmware API. "
  1028. "Driver supports v%u, firmware is v%u.\n",
  1029. api_max, api_ver);
  1030. goto try_again;
  1031. }
  1032. if (api_ver < api_ok) {
  1033. if (api_ok != api_max)
  1034. IWL_ERR(drv, "Firmware has old API version, "
  1035. "expected v%u through v%u, got v%u.\n",
  1036. api_ok, api_max, api_ver);
  1037. else
  1038. IWL_ERR(drv, "Firmware has old API version, "
  1039. "expected v%u, got v%u.\n",
  1040. api_max, api_ver);
  1041. IWL_ERR(drv, "New firmware can be obtained from "
  1042. "http://www.intellinuxwireless.org/.\n");
  1043. }
  1044. }
  1045. /*
  1046. * In mvm uCode there is no difference between data and instructions
  1047. * sections.
  1048. */
  1049. if (!fw->mvm_fw && validate_sec_sizes(drv, pieces, drv->cfg))
  1050. goto try_again;
  1051. /* Allocate ucode buffers for card's bus-master loading ... */
  1052. /* Runtime instructions and 2 copies of data:
  1053. * 1) unmodified from disk
  1054. * 2) backup cache for save/restore during power-downs */
  1055. for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
  1056. if (iwl_alloc_ucode(drv, pieces, i))
  1057. goto out_free_fw;
  1058. if (pieces->dbg_dest_tlv) {
  1059. drv->fw.dbg_dest_tlv =
  1060. kmemdup(pieces->dbg_dest_tlv,
  1061. sizeof(*pieces->dbg_dest_tlv) +
  1062. sizeof(pieces->dbg_dest_tlv->reg_ops[0]) *
  1063. drv->fw.dbg_dest_reg_num, GFP_KERNEL);
  1064. if (!drv->fw.dbg_dest_tlv)
  1065. goto out_free_fw;
  1066. }
  1067. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_conf_tlv); i++) {
  1068. if (pieces->dbg_conf_tlv[i]) {
  1069. drv->fw.dbg_conf_tlv_len[i] =
  1070. pieces->dbg_conf_tlv_len[i];
  1071. drv->fw.dbg_conf_tlv[i] =
  1072. kmemdup(pieces->dbg_conf_tlv[i],
  1073. drv->fw.dbg_conf_tlv_len[i],
  1074. GFP_KERNEL);
  1075. if (!drv->fw.dbg_conf_tlv[i])
  1076. goto out_free_fw;
  1077. }
  1078. }
  1079. memset(&trigger_tlv_sz, 0xff, sizeof(trigger_tlv_sz));
  1080. trigger_tlv_sz[FW_DBG_TRIGGER_MISSED_BEACONS] =
  1081. sizeof(struct iwl_fw_dbg_trigger_missed_bcon);
  1082. trigger_tlv_sz[FW_DBG_TRIGGER_CHANNEL_SWITCH] = 0;
  1083. trigger_tlv_sz[FW_DBG_TRIGGER_FW_NOTIF] =
  1084. sizeof(struct iwl_fw_dbg_trigger_cmd);
  1085. trigger_tlv_sz[FW_DBG_TRIGGER_MLME] =
  1086. sizeof(struct iwl_fw_dbg_trigger_mlme);
  1087. trigger_tlv_sz[FW_DBG_TRIGGER_STATS] =
  1088. sizeof(struct iwl_fw_dbg_trigger_stats);
  1089. trigger_tlv_sz[FW_DBG_TRIGGER_RSSI] =
  1090. sizeof(struct iwl_fw_dbg_trigger_low_rssi);
  1091. trigger_tlv_sz[FW_DBG_TRIGGER_TXQ_TIMERS] =
  1092. sizeof(struct iwl_fw_dbg_trigger_txq_timer);
  1093. trigger_tlv_sz[FW_DBG_TRIGGER_TIME_EVENT] =
  1094. sizeof(struct iwl_fw_dbg_trigger_time_event);
  1095. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_trigger_tlv); i++) {
  1096. if (pieces->dbg_trigger_tlv[i]) {
  1097. /*
  1098. * If the trigger isn't long enough, WARN and exit.
  1099. * Someone is trying to debug something and he won't
  1100. * be able to catch the bug he is trying to chase.
  1101. * We'd better be noisy to be sure he knows what's
  1102. * going on.
  1103. */
  1104. if (WARN_ON(pieces->dbg_trigger_tlv_len[i] <
  1105. (trigger_tlv_sz[i] +
  1106. sizeof(struct iwl_fw_dbg_trigger_tlv))))
  1107. goto out_free_fw;
  1108. drv->fw.dbg_trigger_tlv_len[i] =
  1109. pieces->dbg_trigger_tlv_len[i];
  1110. drv->fw.dbg_trigger_tlv[i] =
  1111. kmemdup(pieces->dbg_trigger_tlv[i],
  1112. drv->fw.dbg_trigger_tlv_len[i],
  1113. GFP_KERNEL);
  1114. if (!drv->fw.dbg_trigger_tlv[i])
  1115. goto out_free_fw;
  1116. }
  1117. }
  1118. /* Now that we can no longer fail, copy information */
  1119. /*
  1120. * The (size - 16) / 12 formula is based on the information recorded
  1121. * for each event, which is of mode 1 (including timestamp) for all
  1122. * new microcodes that include this information.
  1123. */
  1124. fw->init_evtlog_ptr = pieces->init_evtlog_ptr;
  1125. if (pieces->init_evtlog_size)
  1126. fw->init_evtlog_size = (pieces->init_evtlog_size - 16)/12;
  1127. else
  1128. fw->init_evtlog_size =
  1129. drv->cfg->base_params->max_event_log_size;
  1130. fw->init_errlog_ptr = pieces->init_errlog_ptr;
  1131. fw->inst_evtlog_ptr = pieces->inst_evtlog_ptr;
  1132. if (pieces->inst_evtlog_size)
  1133. fw->inst_evtlog_size = (pieces->inst_evtlog_size - 16)/12;
  1134. else
  1135. fw->inst_evtlog_size =
  1136. drv->cfg->base_params->max_event_log_size;
  1137. fw->inst_errlog_ptr = pieces->inst_errlog_ptr;
  1138. /*
  1139. * figure out the offset of chain noise reset and gain commands
  1140. * base on the size of standard phy calibration commands table size
  1141. */
  1142. if (fw->ucode_capa.standard_phy_calibration_size >
  1143. IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
  1144. fw->ucode_capa.standard_phy_calibration_size =
  1145. IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  1146. /* We have our copies now, allow OS release its copies */
  1147. release_firmware(ucode_raw);
  1148. mutex_lock(&iwlwifi_opmode_table_mtx);
  1149. if (fw->mvm_fw)
  1150. op = &iwlwifi_opmode_table[MVM_OP_MODE];
  1151. else
  1152. op = &iwlwifi_opmode_table[DVM_OP_MODE];
  1153. IWL_INFO(drv, "loaded firmware version %s op_mode %s\n",
  1154. drv->fw.fw_version, op->name);
  1155. /* add this device to the list of devices using this op_mode */
  1156. list_add_tail(&drv->list, &op->drv);
  1157. if (op->ops) {
  1158. drv->op_mode = _iwl_op_mode_start(drv, op);
  1159. if (!drv->op_mode) {
  1160. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1161. goto out_unbind;
  1162. }
  1163. } else {
  1164. load_module = true;
  1165. }
  1166. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1167. /*
  1168. * Complete the firmware request last so that
  1169. * a driver unbind (stop) doesn't run while we
  1170. * are doing the start() above.
  1171. */
  1172. complete(&drv->request_firmware_complete);
  1173. /*
  1174. * Load the module last so we don't block anything
  1175. * else from proceeding if the module fails to load
  1176. * or hangs loading.
  1177. */
  1178. if (load_module) {
  1179. err = request_module("%s", op->name);
  1180. #ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
  1181. if (err)
  1182. IWL_ERR(drv,
  1183. "failed to load module %s (error %d), is dynamic loading enabled?\n",
  1184. op->name, err);
  1185. #endif
  1186. }
  1187. kfree(pieces);
  1188. return;
  1189. try_again:
  1190. /* try next, if any */
  1191. release_firmware(ucode_raw);
  1192. if (iwl_request_firmware(drv, false))
  1193. goto out_unbind;
  1194. kfree(pieces);
  1195. return;
  1196. out_free_fw:
  1197. IWL_ERR(drv, "failed to allocate pci memory\n");
  1198. iwl_dealloc_ucode(drv);
  1199. release_firmware(ucode_raw);
  1200. out_unbind:
  1201. kfree(pieces);
  1202. complete(&drv->request_firmware_complete);
  1203. device_release_driver(drv->trans->dev);
  1204. }
  1205. struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
  1206. const struct iwl_cfg *cfg)
  1207. {
  1208. struct iwl_drv *drv;
  1209. int ret;
  1210. drv = kzalloc(sizeof(*drv), GFP_KERNEL);
  1211. if (!drv) {
  1212. ret = -ENOMEM;
  1213. goto err;
  1214. }
  1215. drv->trans = trans;
  1216. drv->dev = trans->dev;
  1217. drv->cfg = cfg;
  1218. init_completion(&drv->request_firmware_complete);
  1219. INIT_LIST_HEAD(&drv->list);
  1220. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1221. /* Create the device debugfs entries. */
  1222. drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev),
  1223. iwl_dbgfs_root);
  1224. if (!drv->dbgfs_drv) {
  1225. IWL_ERR(drv, "failed to create debugfs directory\n");
  1226. ret = -ENOMEM;
  1227. goto err_free_drv;
  1228. }
  1229. /* Create transport layer debugfs dir */
  1230. drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv);
  1231. if (!drv->trans->dbgfs_dir) {
  1232. IWL_ERR(drv, "failed to create transport debugfs directory\n");
  1233. ret = -ENOMEM;
  1234. goto err_free_dbgfs;
  1235. }
  1236. #endif
  1237. ret = iwl_request_firmware(drv, true);
  1238. if (ret) {
  1239. IWL_ERR(trans, "Couldn't request the fw\n");
  1240. goto err_fw;
  1241. }
  1242. return drv;
  1243. err_fw:
  1244. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1245. err_free_dbgfs:
  1246. debugfs_remove_recursive(drv->dbgfs_drv);
  1247. err_free_drv:
  1248. #endif
  1249. kfree(drv);
  1250. err:
  1251. return ERR_PTR(ret);
  1252. }
  1253. void iwl_drv_stop(struct iwl_drv *drv)
  1254. {
  1255. wait_for_completion(&drv->request_firmware_complete);
  1256. _iwl_op_mode_stop(drv);
  1257. iwl_dealloc_ucode(drv);
  1258. mutex_lock(&iwlwifi_opmode_table_mtx);
  1259. /*
  1260. * List is empty (this item wasn't added)
  1261. * when firmware loading failed -- in that
  1262. * case we can't remove it from any list.
  1263. */
  1264. if (!list_empty(&drv->list))
  1265. list_del(&drv->list);
  1266. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1267. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1268. debugfs_remove_recursive(drv->dbgfs_drv);
  1269. #endif
  1270. kfree(drv);
  1271. }
  1272. /* shared module parameters */
  1273. struct iwl_mod_params iwlwifi_mod_params = {
  1274. .restart_fw = true,
  1275. .bt_coex_active = true,
  1276. .power_level = IWL_POWER_INDEX_1,
  1277. .d0i3_disable = true,
  1278. #ifndef CONFIG_IWLWIFI_UAPSD
  1279. .uapsd_disable = true,
  1280. #endif /* CONFIG_IWLWIFI_UAPSD */
  1281. /* the rest are 0 by default */
  1282. };
  1283. IWL_EXPORT_SYMBOL(iwlwifi_mod_params);
  1284. int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
  1285. {
  1286. int i;
  1287. struct iwl_drv *drv;
  1288. struct iwlwifi_opmode_table *op;
  1289. mutex_lock(&iwlwifi_opmode_table_mtx);
  1290. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  1291. op = &iwlwifi_opmode_table[i];
  1292. if (strcmp(op->name, name))
  1293. continue;
  1294. op->ops = ops;
  1295. /* TODO: need to handle exceptional case */
  1296. list_for_each_entry(drv, &op->drv, list)
  1297. drv->op_mode = _iwl_op_mode_start(drv, op);
  1298. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1299. return 0;
  1300. }
  1301. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1302. return -EIO;
  1303. }
  1304. IWL_EXPORT_SYMBOL(iwl_opmode_register);
  1305. void iwl_opmode_deregister(const char *name)
  1306. {
  1307. int i;
  1308. struct iwl_drv *drv;
  1309. mutex_lock(&iwlwifi_opmode_table_mtx);
  1310. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  1311. if (strcmp(iwlwifi_opmode_table[i].name, name))
  1312. continue;
  1313. iwlwifi_opmode_table[i].ops = NULL;
  1314. /* call the stop routine for all devices */
  1315. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
  1316. _iwl_op_mode_stop(drv);
  1317. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1318. return;
  1319. }
  1320. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1321. }
  1322. IWL_EXPORT_SYMBOL(iwl_opmode_deregister);
  1323. static int __init iwl_drv_init(void)
  1324. {
  1325. int i;
  1326. mutex_init(&iwlwifi_opmode_table_mtx);
  1327. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++)
  1328. INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);
  1329. pr_info(DRV_DESCRIPTION "\n");
  1330. pr_info(DRV_COPYRIGHT "\n");
  1331. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1332. /* Create the root of iwlwifi debugfs subsystem. */
  1333. iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL);
  1334. if (!iwl_dbgfs_root)
  1335. return -EFAULT;
  1336. #endif
  1337. return iwl_pci_register_driver();
  1338. }
  1339. module_init(iwl_drv_init);
  1340. static void __exit iwl_drv_exit(void)
  1341. {
  1342. iwl_pci_unregister_driver();
  1343. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1344. debugfs_remove_recursive(iwl_dbgfs_root);
  1345. #endif
  1346. }
  1347. module_exit(iwl_drv_exit);
  1348. #ifdef CONFIG_IWLWIFI_DEBUG
  1349. module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
  1350. S_IRUGO | S_IWUSR);
  1351. MODULE_PARM_DESC(debug, "debug output mask");
  1352. #endif
  1353. module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
  1354. MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
  1355. module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
  1356. MODULE_PARM_DESC(11n_disable,
  1357. "disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX");
  1358. module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
  1359. int, S_IRUGO);
  1360. MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size (default 0)");
  1361. module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, bool, S_IRUGO);
  1362. MODULE_PARM_DESC(fw_restart, "restart firmware in case of error (default true)");
  1363. module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
  1364. int, S_IRUGO);
  1365. MODULE_PARM_DESC(antenna_coupling,
  1366. "specify antenna coupling in dB (default: 0 dB)");
  1367. module_param_named(nvm_file, iwlwifi_mod_params.nvm_file, charp, S_IRUGO);
  1368. MODULE_PARM_DESC(nvm_file, "NVM file name");
  1369. module_param_named(d0i3_disable, iwlwifi_mod_params.d0i3_disable,
  1370. bool, S_IRUGO);
  1371. MODULE_PARM_DESC(d0i3_disable, "disable d0i3 functionality (default: Y)");
  1372. module_param_named(lar_disable, iwlwifi_mod_params.lar_disable,
  1373. bool, S_IRUGO);
  1374. MODULE_PARM_DESC(lar_disable, "disable LAR functionality (default: N)");
  1375. module_param_named(uapsd_disable, iwlwifi_mod_params.uapsd_disable,
  1376. bool, S_IRUGO | S_IWUSR);
  1377. #ifdef CONFIG_IWLWIFI_UAPSD
  1378. MODULE_PARM_DESC(uapsd_disable, "disable U-APSD functionality (default: N)");
  1379. #else
  1380. MODULE_PARM_DESC(uapsd_disable, "disable U-APSD functionality (default: Y)");
  1381. #endif
  1382. /*
  1383. * set bt_coex_active to true, uCode will do kill/defer
  1384. * every time the priority line is asserted (BT is sending signals on the
  1385. * priority line in the PCIx).
  1386. * set bt_coex_active to false, uCode will ignore the BT activity and
  1387. * perform the normal operation
  1388. *
  1389. * User might experience transmit issue on some platform due to WiFi/BT
  1390. * co-exist problem. The possible behaviors are:
  1391. * Able to scan and finding all the available AP
  1392. * Not able to associate with any AP
  1393. * On those platforms, WiFi communication can be restored by set
  1394. * "bt_coex_active" module parameter to "false"
  1395. *
  1396. * default: bt_coex_active = true (BT_COEX_ENABLE)
  1397. */
  1398. module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
  1399. bool, S_IRUGO);
  1400. MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
  1401. module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
  1402. MODULE_PARM_DESC(led_mode, "0=system default, "
  1403. "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
  1404. module_param_named(power_save, iwlwifi_mod_params.power_save,
  1405. bool, S_IRUGO);
  1406. MODULE_PARM_DESC(power_save,
  1407. "enable WiFi power management (default: disable)");
  1408. module_param_named(power_level, iwlwifi_mod_params.power_level,
  1409. int, S_IRUGO);
  1410. MODULE_PARM_DESC(power_level,
  1411. "default power save level (range from 1 - 5, default: 1)");
  1412. module_param_named(fw_monitor, iwlwifi_mod_params.fw_monitor, bool, S_IRUGO);
  1413. MODULE_PARM_DESC(fw_monitor,
  1414. "firmware monitor - to debug FW (default: false - needs lots of memory)");