iwl-drv.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  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 - 2015 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 - 2015 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), "/*(DEBLOBBED)*/",
  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. "/*(DEBLOBBED)*/", 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 reject_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. u32 api_flags = le32_to_cpu(ucode_api->api_flags);
  366. int i;
  367. if (api_index >= IWL_API_MAX_BITS / 32) {
  368. IWL_ERR(drv, "api_index larger than supported by driver\n");
  369. /* don't return an error so we can load FW that has more bits */
  370. return 0;
  371. }
  372. for (i = 0; i < 32; i++) {
  373. if (api_flags & BIT(i))
  374. __set_bit(i + 32 * api_index, capa->_api);
  375. }
  376. return 0;
  377. }
  378. static int iwl_set_ucode_capabilities(struct iwl_drv *drv, const u8 *data,
  379. struct iwl_ucode_capabilities *capa)
  380. {
  381. const struct iwl_ucode_capa *ucode_capa = (void *)data;
  382. u32 api_index = le32_to_cpu(ucode_capa->api_index);
  383. u32 api_flags = le32_to_cpu(ucode_capa->api_capa);
  384. int i;
  385. if (api_index >= IWL_CAPABILITIES_MAX_BITS / 32) {
  386. IWL_ERR(drv, "api_index larger than supported by driver\n");
  387. /* don't return an error so we can load FW that has more bits */
  388. return 0;
  389. }
  390. for (i = 0; i < 32; i++) {
  391. if (api_flags & BIT(i))
  392. __set_bit(i + 32 * api_index, capa->_capa);
  393. }
  394. return 0;
  395. }
  396. static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
  397. const struct firmware *ucode_raw,
  398. struct iwl_firmware_pieces *pieces)
  399. {
  400. struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
  401. u32 api_ver, hdr_size, build;
  402. char buildstr[25];
  403. const u8 *src;
  404. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  405. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  406. switch (api_ver) {
  407. default:
  408. hdr_size = 28;
  409. if (ucode_raw->size < hdr_size) {
  410. IWL_ERR(drv, "File size too small!\n");
  411. return -EINVAL;
  412. }
  413. build = le32_to_cpu(ucode->u.v2.build);
  414. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  415. le32_to_cpu(ucode->u.v2.inst_size));
  416. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  417. le32_to_cpu(ucode->u.v2.data_size));
  418. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  419. le32_to_cpu(ucode->u.v2.init_size));
  420. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  421. le32_to_cpu(ucode->u.v2.init_data_size));
  422. src = ucode->u.v2.data;
  423. break;
  424. case 0:
  425. case 1:
  426. case 2:
  427. hdr_size = 24;
  428. if (ucode_raw->size < hdr_size) {
  429. IWL_ERR(drv, "File size too small!\n");
  430. return -EINVAL;
  431. }
  432. build = 0;
  433. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  434. le32_to_cpu(ucode->u.v1.inst_size));
  435. set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  436. le32_to_cpu(ucode->u.v1.data_size));
  437. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  438. le32_to_cpu(ucode->u.v1.init_size));
  439. set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  440. le32_to_cpu(ucode->u.v1.init_data_size));
  441. src = ucode->u.v1.data;
  442. break;
  443. }
  444. if (build)
  445. sprintf(buildstr, " build %u%s", build,
  446. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  447. ? " (EXP)" : "");
  448. else
  449. buildstr[0] = '\0';
  450. snprintf(drv->fw.fw_version,
  451. sizeof(drv->fw.fw_version),
  452. "%u.%u.%u.%u%s",
  453. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  454. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  455. IWL_UCODE_API(drv->fw.ucode_ver),
  456. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  457. buildstr);
  458. /* Verify size of file vs. image size info in file's header */
  459. if (ucode_raw->size != hdr_size +
  460. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) +
  461. get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) +
  462. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) +
  463. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
  464. IWL_ERR(drv,
  465. "uCode file size %d does not match expected size\n",
  466. (int)ucode_raw->size);
  467. return -EINVAL;
  468. }
  469. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src);
  470. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST);
  471. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
  472. IWLAGN_RTC_INST_LOWER_BOUND);
  473. set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src);
  474. src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA);
  475. set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
  476. IWLAGN_RTC_DATA_LOWER_BOUND);
  477. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src);
  478. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST);
  479. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
  480. IWLAGN_RTC_INST_LOWER_BOUND);
  481. set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src);
  482. src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA);
  483. set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
  484. IWLAGN_RTC_DATA_LOWER_BOUND);
  485. return 0;
  486. }
  487. static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
  488. const struct firmware *ucode_raw,
  489. struct iwl_firmware_pieces *pieces,
  490. struct iwl_ucode_capabilities *capa)
  491. {
  492. struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
  493. struct iwl_ucode_tlv *tlv;
  494. size_t len = ucode_raw->size;
  495. const u8 *data;
  496. u32 tlv_len;
  497. enum iwl_ucode_tlv_type tlv_type;
  498. const u8 *tlv_data;
  499. char buildstr[25];
  500. u32 build;
  501. int num_of_cpus;
  502. bool usniffer_images = false;
  503. bool usniffer_req = false;
  504. if (len < sizeof(*ucode)) {
  505. IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
  506. return -EINVAL;
  507. }
  508. if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
  509. IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
  510. le32_to_cpu(ucode->magic));
  511. return -EINVAL;
  512. }
  513. drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
  514. memcpy(drv->fw.human_readable, ucode->human_readable,
  515. sizeof(drv->fw.human_readable));
  516. build = le32_to_cpu(ucode->build);
  517. if (build)
  518. sprintf(buildstr, " build %u%s", build,
  519. (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
  520. ? " (EXP)" : "");
  521. else
  522. buildstr[0] = '\0';
  523. snprintf(drv->fw.fw_version,
  524. sizeof(drv->fw.fw_version),
  525. "%u.%u.%u.%u%s",
  526. IWL_UCODE_MAJOR(drv->fw.ucode_ver),
  527. IWL_UCODE_MINOR(drv->fw.ucode_ver),
  528. IWL_UCODE_API(drv->fw.ucode_ver),
  529. IWL_UCODE_SERIAL(drv->fw.ucode_ver),
  530. buildstr);
  531. data = ucode->data;
  532. len -= sizeof(*ucode);
  533. while (len >= sizeof(*tlv)) {
  534. len -= sizeof(*tlv);
  535. tlv = (void *)data;
  536. tlv_len = le32_to_cpu(tlv->length);
  537. tlv_type = le32_to_cpu(tlv->type);
  538. tlv_data = tlv->data;
  539. if (len < tlv_len) {
  540. IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
  541. len, tlv_len);
  542. return -EINVAL;
  543. }
  544. len -= ALIGN(tlv_len, 4);
  545. data += sizeof(*tlv) + ALIGN(tlv_len, 4);
  546. switch (tlv_type) {
  547. case IWL_UCODE_TLV_INST:
  548. set_sec_data(pieces, IWL_UCODE_REGULAR,
  549. IWL_UCODE_SECTION_INST, tlv_data);
  550. set_sec_size(pieces, IWL_UCODE_REGULAR,
  551. IWL_UCODE_SECTION_INST, tlv_len);
  552. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  553. IWL_UCODE_SECTION_INST,
  554. IWLAGN_RTC_INST_LOWER_BOUND);
  555. break;
  556. case IWL_UCODE_TLV_DATA:
  557. set_sec_data(pieces, IWL_UCODE_REGULAR,
  558. IWL_UCODE_SECTION_DATA, tlv_data);
  559. set_sec_size(pieces, IWL_UCODE_REGULAR,
  560. IWL_UCODE_SECTION_DATA, tlv_len);
  561. set_sec_offset(pieces, IWL_UCODE_REGULAR,
  562. IWL_UCODE_SECTION_DATA,
  563. IWLAGN_RTC_DATA_LOWER_BOUND);
  564. break;
  565. case IWL_UCODE_TLV_INIT:
  566. set_sec_data(pieces, IWL_UCODE_INIT,
  567. IWL_UCODE_SECTION_INST, tlv_data);
  568. set_sec_size(pieces, IWL_UCODE_INIT,
  569. IWL_UCODE_SECTION_INST, tlv_len);
  570. set_sec_offset(pieces, IWL_UCODE_INIT,
  571. IWL_UCODE_SECTION_INST,
  572. IWLAGN_RTC_INST_LOWER_BOUND);
  573. break;
  574. case IWL_UCODE_TLV_INIT_DATA:
  575. set_sec_data(pieces, IWL_UCODE_INIT,
  576. IWL_UCODE_SECTION_DATA, tlv_data);
  577. set_sec_size(pieces, IWL_UCODE_INIT,
  578. IWL_UCODE_SECTION_DATA, tlv_len);
  579. set_sec_offset(pieces, IWL_UCODE_INIT,
  580. IWL_UCODE_SECTION_DATA,
  581. IWLAGN_RTC_DATA_LOWER_BOUND);
  582. break;
  583. case IWL_UCODE_TLV_BOOT:
  584. IWL_ERR(drv, "Found unexpected BOOT ucode\n");
  585. break;
  586. case IWL_UCODE_TLV_PROBE_MAX_LEN:
  587. if (tlv_len != sizeof(u32))
  588. goto invalid_tlv_len;
  589. capa->max_probe_length =
  590. le32_to_cpup((__le32 *)tlv_data);
  591. break;
  592. case IWL_UCODE_TLV_PAN:
  593. if (tlv_len)
  594. goto invalid_tlv_len;
  595. capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
  596. break;
  597. case IWL_UCODE_TLV_FLAGS:
  598. /* must be at least one u32 */
  599. if (tlv_len < sizeof(u32))
  600. goto invalid_tlv_len;
  601. /* and a proper number of u32s */
  602. if (tlv_len % sizeof(u32))
  603. goto invalid_tlv_len;
  604. /*
  605. * This driver only reads the first u32 as
  606. * right now no more features are defined,
  607. * if that changes then either the driver
  608. * will not work with the new firmware, or
  609. * it'll not take advantage of new features.
  610. */
  611. capa->flags = le32_to_cpup((__le32 *)tlv_data);
  612. break;
  613. case IWL_UCODE_TLV_API_CHANGES_SET:
  614. if (tlv_len != sizeof(struct iwl_ucode_api))
  615. goto invalid_tlv_len;
  616. if (iwl_set_ucode_api_flags(drv, tlv_data, capa))
  617. goto tlv_error;
  618. break;
  619. case IWL_UCODE_TLV_ENABLED_CAPABILITIES:
  620. if (tlv_len != sizeof(struct iwl_ucode_capa))
  621. goto invalid_tlv_len;
  622. if (iwl_set_ucode_capabilities(drv, tlv_data, capa))
  623. goto tlv_error;
  624. break;
  625. case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
  626. if (tlv_len != sizeof(u32))
  627. goto invalid_tlv_len;
  628. pieces->init_evtlog_ptr =
  629. le32_to_cpup((__le32 *)tlv_data);
  630. break;
  631. case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
  632. if (tlv_len != sizeof(u32))
  633. goto invalid_tlv_len;
  634. pieces->init_evtlog_size =
  635. le32_to_cpup((__le32 *)tlv_data);
  636. break;
  637. case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
  638. if (tlv_len != sizeof(u32))
  639. goto invalid_tlv_len;
  640. pieces->init_errlog_ptr =
  641. le32_to_cpup((__le32 *)tlv_data);
  642. break;
  643. case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
  644. if (tlv_len != sizeof(u32))
  645. goto invalid_tlv_len;
  646. pieces->inst_evtlog_ptr =
  647. le32_to_cpup((__le32 *)tlv_data);
  648. break;
  649. case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
  650. if (tlv_len != sizeof(u32))
  651. goto invalid_tlv_len;
  652. pieces->inst_evtlog_size =
  653. le32_to_cpup((__le32 *)tlv_data);
  654. break;
  655. case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
  656. if (tlv_len != sizeof(u32))
  657. goto invalid_tlv_len;
  658. pieces->inst_errlog_ptr =
  659. le32_to_cpup((__le32 *)tlv_data);
  660. break;
  661. case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
  662. if (tlv_len)
  663. goto invalid_tlv_len;
  664. drv->fw.enhance_sensitivity_table = true;
  665. break;
  666. case IWL_UCODE_TLV_WOWLAN_INST:
  667. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  668. IWL_UCODE_SECTION_INST, tlv_data);
  669. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  670. IWL_UCODE_SECTION_INST, tlv_len);
  671. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  672. IWL_UCODE_SECTION_INST,
  673. IWLAGN_RTC_INST_LOWER_BOUND);
  674. break;
  675. case IWL_UCODE_TLV_WOWLAN_DATA:
  676. set_sec_data(pieces, IWL_UCODE_WOWLAN,
  677. IWL_UCODE_SECTION_DATA, tlv_data);
  678. set_sec_size(pieces, IWL_UCODE_WOWLAN,
  679. IWL_UCODE_SECTION_DATA, tlv_len);
  680. set_sec_offset(pieces, IWL_UCODE_WOWLAN,
  681. IWL_UCODE_SECTION_DATA,
  682. IWLAGN_RTC_DATA_LOWER_BOUND);
  683. break;
  684. case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
  685. if (tlv_len != sizeof(u32))
  686. goto invalid_tlv_len;
  687. capa->standard_phy_calibration_size =
  688. le32_to_cpup((__le32 *)tlv_data);
  689. break;
  690. case IWL_UCODE_TLV_SEC_RT:
  691. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
  692. tlv_len);
  693. drv->fw.mvm_fw = true;
  694. break;
  695. case IWL_UCODE_TLV_SEC_INIT:
  696. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
  697. tlv_len);
  698. drv->fw.mvm_fw = true;
  699. break;
  700. case IWL_UCODE_TLV_SEC_WOWLAN:
  701. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
  702. tlv_len);
  703. drv->fw.mvm_fw = true;
  704. break;
  705. case IWL_UCODE_TLV_DEF_CALIB:
  706. if (tlv_len != sizeof(struct iwl_tlv_calib_data))
  707. goto invalid_tlv_len;
  708. if (iwl_set_default_calib(drv, tlv_data))
  709. goto tlv_error;
  710. break;
  711. case IWL_UCODE_TLV_PHY_SKU:
  712. if (tlv_len != sizeof(u32))
  713. goto invalid_tlv_len;
  714. drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data);
  715. drv->fw.valid_tx_ant = (drv->fw.phy_config &
  716. FW_PHY_CFG_TX_CHAIN) >>
  717. FW_PHY_CFG_TX_CHAIN_POS;
  718. drv->fw.valid_rx_ant = (drv->fw.phy_config &
  719. FW_PHY_CFG_RX_CHAIN) >>
  720. FW_PHY_CFG_RX_CHAIN_POS;
  721. break;
  722. case IWL_UCODE_TLV_SECURE_SEC_RT:
  723. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
  724. tlv_len);
  725. drv->fw.mvm_fw = true;
  726. break;
  727. case IWL_UCODE_TLV_SECURE_SEC_INIT:
  728. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT,
  729. tlv_len);
  730. drv->fw.mvm_fw = true;
  731. break;
  732. case IWL_UCODE_TLV_SECURE_SEC_WOWLAN:
  733. iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN,
  734. tlv_len);
  735. drv->fw.mvm_fw = true;
  736. break;
  737. case IWL_UCODE_TLV_NUM_OF_CPU:
  738. if (tlv_len != sizeof(u32))
  739. goto invalid_tlv_len;
  740. num_of_cpus =
  741. le32_to_cpup((__le32 *)tlv_data);
  742. if (num_of_cpus == 2) {
  743. drv->fw.img[IWL_UCODE_REGULAR].is_dual_cpus =
  744. true;
  745. drv->fw.img[IWL_UCODE_INIT].is_dual_cpus =
  746. true;
  747. drv->fw.img[IWL_UCODE_WOWLAN].is_dual_cpus =
  748. true;
  749. } else if ((num_of_cpus > 2) || (num_of_cpus < 1)) {
  750. IWL_ERR(drv, "Driver support upto 2 CPUs\n");
  751. return -EINVAL;
  752. }
  753. break;
  754. case IWL_UCODE_TLV_CSCHEME:
  755. if (iwl_store_cscheme(&drv->fw, tlv_data, tlv_len))
  756. goto invalid_tlv_len;
  757. break;
  758. case IWL_UCODE_TLV_N_SCAN_CHANNELS:
  759. if (tlv_len != sizeof(u32))
  760. goto invalid_tlv_len;
  761. capa->n_scan_channels =
  762. le32_to_cpup((__le32 *)tlv_data);
  763. break;
  764. case IWL_UCODE_TLV_FW_VERSION: {
  765. __le32 *ptr = (void *)tlv_data;
  766. u32 major, minor;
  767. u8 local_comp;
  768. if (tlv_len != sizeof(u32) * 3)
  769. goto invalid_tlv_len;
  770. major = le32_to_cpup(ptr++);
  771. minor = le32_to_cpup(ptr++);
  772. local_comp = le32_to_cpup(ptr);
  773. snprintf(drv->fw.fw_version,
  774. sizeof(drv->fw.fw_version), "%u.%u.%u",
  775. major, minor, local_comp);
  776. break;
  777. }
  778. case IWL_UCODE_TLV_FW_DBG_DEST: {
  779. struct iwl_fw_dbg_dest_tlv *dest = (void *)tlv_data;
  780. if (pieces->dbg_dest_tlv) {
  781. IWL_ERR(drv,
  782. "dbg destination ignored, already exists\n");
  783. break;
  784. }
  785. pieces->dbg_dest_tlv = dest;
  786. IWL_INFO(drv, "Found debug destination: %s\n",
  787. get_fw_dbg_mode_string(dest->monitor_mode));
  788. drv->fw.dbg_dest_reg_num =
  789. tlv_len - offsetof(struct iwl_fw_dbg_dest_tlv,
  790. reg_ops);
  791. drv->fw.dbg_dest_reg_num /=
  792. sizeof(drv->fw.dbg_dest_tlv->reg_ops[0]);
  793. break;
  794. }
  795. case IWL_UCODE_TLV_FW_DBG_CONF: {
  796. struct iwl_fw_dbg_conf_tlv *conf = (void *)tlv_data;
  797. if (!pieces->dbg_dest_tlv) {
  798. IWL_ERR(drv,
  799. "Ignore dbg config %d - no destination configured\n",
  800. conf->id);
  801. break;
  802. }
  803. if (conf->id >= ARRAY_SIZE(drv->fw.dbg_conf_tlv)) {
  804. IWL_ERR(drv,
  805. "Skip unknown configuration: %d\n",
  806. conf->id);
  807. break;
  808. }
  809. if (pieces->dbg_conf_tlv[conf->id]) {
  810. IWL_ERR(drv,
  811. "Ignore duplicate dbg config %d\n",
  812. conf->id);
  813. break;
  814. }
  815. if (conf->usniffer)
  816. usniffer_req = true;
  817. IWL_INFO(drv, "Found debug configuration: %d\n",
  818. conf->id);
  819. pieces->dbg_conf_tlv[conf->id] = conf;
  820. pieces->dbg_conf_tlv_len[conf->id] = tlv_len;
  821. break;
  822. }
  823. case IWL_UCODE_TLV_FW_DBG_TRIGGER: {
  824. struct iwl_fw_dbg_trigger_tlv *trigger =
  825. (void *)tlv_data;
  826. u32 trigger_id = le32_to_cpu(trigger->id);
  827. if (trigger_id >= ARRAY_SIZE(drv->fw.dbg_trigger_tlv)) {
  828. IWL_ERR(drv,
  829. "Skip unknown trigger: %u\n",
  830. trigger->id);
  831. break;
  832. }
  833. if (pieces->dbg_trigger_tlv[trigger_id]) {
  834. IWL_ERR(drv,
  835. "Ignore duplicate dbg trigger %u\n",
  836. trigger->id);
  837. break;
  838. }
  839. IWL_INFO(drv, "Found debug trigger: %u\n", trigger->id);
  840. pieces->dbg_trigger_tlv[trigger_id] = trigger;
  841. pieces->dbg_trigger_tlv_len[trigger_id] = tlv_len;
  842. break;
  843. }
  844. case IWL_UCODE_TLV_SEC_RT_USNIFFER:
  845. usniffer_images = true;
  846. iwl_store_ucode_sec(pieces, tlv_data,
  847. IWL_UCODE_REGULAR_USNIFFER,
  848. tlv_len);
  849. break;
  850. case IWL_UCODE_TLV_SDIO_ADMA_ADDR:
  851. if (tlv_len != sizeof(u32))
  852. goto invalid_tlv_len;
  853. drv->fw.sdio_adma_addr =
  854. le32_to_cpup((__le32 *)tlv_data);
  855. break;
  856. default:
  857. IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
  858. break;
  859. }
  860. }
  861. if (usniffer_req && !usniffer_images) {
  862. IWL_ERR(drv,
  863. "user selected to work with usniffer but usniffer image isn't available in ucode package\n");
  864. return -EINVAL;
  865. }
  866. if (len) {
  867. IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
  868. iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
  869. return -EINVAL;
  870. }
  871. return 0;
  872. invalid_tlv_len:
  873. IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
  874. tlv_error:
  875. iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
  876. return -EINVAL;
  877. }
  878. static int iwl_alloc_ucode(struct iwl_drv *drv,
  879. struct iwl_firmware_pieces *pieces,
  880. enum iwl_ucode_type type)
  881. {
  882. int i;
  883. for (i = 0;
  884. i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i);
  885. i++)
  886. if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]),
  887. get_sec(pieces, type, i)))
  888. return -ENOMEM;
  889. return 0;
  890. }
  891. static int validate_sec_sizes(struct iwl_drv *drv,
  892. struct iwl_firmware_pieces *pieces,
  893. const struct iwl_cfg *cfg)
  894. {
  895. IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
  896. get_sec_size(pieces, IWL_UCODE_REGULAR,
  897. IWL_UCODE_SECTION_INST));
  898. IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
  899. get_sec_size(pieces, IWL_UCODE_REGULAR,
  900. IWL_UCODE_SECTION_DATA));
  901. IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
  902. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST));
  903. IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
  904. get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA));
  905. /* Verify that uCode images will fit in card's SRAM. */
  906. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) >
  907. cfg->max_inst_size) {
  908. IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
  909. get_sec_size(pieces, IWL_UCODE_REGULAR,
  910. IWL_UCODE_SECTION_INST));
  911. return -1;
  912. }
  913. if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) >
  914. cfg->max_data_size) {
  915. IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
  916. get_sec_size(pieces, IWL_UCODE_REGULAR,
  917. IWL_UCODE_SECTION_DATA));
  918. return -1;
  919. }
  920. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) >
  921. cfg->max_inst_size) {
  922. IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
  923. get_sec_size(pieces, IWL_UCODE_INIT,
  924. IWL_UCODE_SECTION_INST));
  925. return -1;
  926. }
  927. if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) >
  928. cfg->max_data_size) {
  929. IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
  930. get_sec_size(pieces, IWL_UCODE_REGULAR,
  931. IWL_UCODE_SECTION_DATA));
  932. return -1;
  933. }
  934. return 0;
  935. }
  936. static struct iwl_op_mode *
  937. _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op)
  938. {
  939. const struct iwl_op_mode_ops *ops = op->ops;
  940. struct dentry *dbgfs_dir = NULL;
  941. struct iwl_op_mode *op_mode = NULL;
  942. #ifdef CONFIG_IWLWIFI_DEBUGFS
  943. drv->dbgfs_op_mode = debugfs_create_dir(op->name,
  944. drv->dbgfs_drv);
  945. if (!drv->dbgfs_op_mode) {
  946. IWL_ERR(drv,
  947. "failed to create opmode debugfs directory\n");
  948. return op_mode;
  949. }
  950. dbgfs_dir = drv->dbgfs_op_mode;
  951. #endif
  952. op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir);
  953. #ifdef CONFIG_IWLWIFI_DEBUGFS
  954. if (!op_mode) {
  955. debugfs_remove_recursive(drv->dbgfs_op_mode);
  956. drv->dbgfs_op_mode = NULL;
  957. }
  958. #endif
  959. return op_mode;
  960. }
  961. static void _iwl_op_mode_stop(struct iwl_drv *drv)
  962. {
  963. /* op_mode can be NULL if its start failed */
  964. if (drv->op_mode) {
  965. iwl_op_mode_stop(drv->op_mode);
  966. drv->op_mode = NULL;
  967. #ifdef CONFIG_IWLWIFI_DEBUGFS
  968. debugfs_remove_recursive(drv->dbgfs_op_mode);
  969. drv->dbgfs_op_mode = NULL;
  970. #endif
  971. }
  972. }
  973. /**
  974. * iwl_req_fw_callback - callback when firmware was loaded
  975. *
  976. * If loaded successfully, copies the firmware into buffers
  977. * for the card to fetch (via DMA).
  978. */
  979. static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
  980. {
  981. struct iwl_drv *drv = context;
  982. struct iwl_fw *fw = &drv->fw;
  983. struct iwl_ucode_header *ucode;
  984. struct iwlwifi_opmode_table *op;
  985. int err;
  986. struct iwl_firmware_pieces *pieces;
  987. const unsigned int api_max = drv->cfg->ucode_api_max;
  988. unsigned int api_ok = drv->cfg->ucode_api_ok;
  989. const unsigned int api_min = drv->cfg->ucode_api_min;
  990. size_t trigger_tlv_sz[FW_DBG_TRIGGER_MAX];
  991. u32 api_ver;
  992. int i;
  993. bool load_module = false;
  994. fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH;
  995. fw->ucode_capa.standard_phy_calibration_size =
  996. IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  997. fw->ucode_capa.n_scan_channels = IWL_DEFAULT_SCAN_CHANNELS;
  998. if (!api_ok)
  999. api_ok = api_max;
  1000. pieces = kzalloc(sizeof(*pieces), GFP_KERNEL);
  1001. if (!pieces)
  1002. return;
  1003. if (!ucode_raw) {
  1004. if (drv->fw_index <= api_ok)
  1005. IWL_ERR(drv,
  1006. "request for firmware file '%s' failed.\n",
  1007. drv->firmware_name);
  1008. goto try_again;
  1009. }
  1010. IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
  1011. drv->firmware_name, ucode_raw->size);
  1012. /* Make sure that we got at least the API version number */
  1013. if (ucode_raw->size < 4) {
  1014. IWL_ERR(drv, "File size way too small!\n");
  1015. goto try_again;
  1016. }
  1017. /* Data from ucode file: header followed by uCode images */
  1018. ucode = (struct iwl_ucode_header *)ucode_raw->data;
  1019. if (ucode->ver)
  1020. err = iwl_parse_v1_v2_firmware(drv, ucode_raw, pieces);
  1021. else
  1022. err = iwl_parse_tlv_firmware(drv, ucode_raw, pieces,
  1023. &fw->ucode_capa);
  1024. if (err)
  1025. goto try_again;
  1026. if (fw_has_api(&drv->fw.ucode_capa, IWL_UCODE_TLV_API_NEW_VERSION))
  1027. api_ver = drv->fw.ucode_ver;
  1028. else
  1029. api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
  1030. /*
  1031. * api_ver should match the api version forming part of the
  1032. * firmware filename ... but we don't check for that and only rely
  1033. * on the API version read from firmware header from here on forward
  1034. */
  1035. /* no api version check required for experimental uCode */
  1036. if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
  1037. if (api_ver < api_min || api_ver > api_max) {
  1038. IWL_ERR(drv,
  1039. "Driver unable to support your firmware API. "
  1040. "Driver supports v%u, firmware is v%u.\n",
  1041. api_max, api_ver);
  1042. goto try_again;
  1043. }
  1044. if (api_ver < api_ok) {
  1045. if (api_ok != api_max)
  1046. IWL_ERR(drv, "Firmware has old API version, "
  1047. "expected v%u through v%u, got v%u.\n",
  1048. api_ok, api_max, api_ver);
  1049. else
  1050. IWL_ERR(drv, "Firmware has old API version, "
  1051. "expected v%u, got v%u.\n",
  1052. api_max, api_ver);
  1053. IWL_ERR(drv, "New firmware can be obtained from "
  1054. "http://www.intellinuxwireless.org/.\n");
  1055. }
  1056. }
  1057. /*
  1058. * In mvm uCode there is no difference between data and instructions
  1059. * sections.
  1060. */
  1061. if (!fw->mvm_fw && validate_sec_sizes(drv, pieces, drv->cfg))
  1062. goto try_again;
  1063. /* Allocate ucode buffers for card's bus-master loading ... */
  1064. /* Runtime instructions and 2 copies of data:
  1065. * 1) unmodified from disk
  1066. * 2) backup cache for save/restore during power-downs */
  1067. for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
  1068. if (iwl_alloc_ucode(drv, pieces, i))
  1069. goto out_free_fw;
  1070. if (pieces->dbg_dest_tlv) {
  1071. drv->fw.dbg_dest_tlv =
  1072. kmemdup(pieces->dbg_dest_tlv,
  1073. sizeof(*pieces->dbg_dest_tlv) +
  1074. sizeof(pieces->dbg_dest_tlv->reg_ops[0]) *
  1075. drv->fw.dbg_dest_reg_num, GFP_KERNEL);
  1076. if (!drv->fw.dbg_dest_tlv)
  1077. goto out_free_fw;
  1078. }
  1079. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_conf_tlv); i++) {
  1080. if (pieces->dbg_conf_tlv[i]) {
  1081. drv->fw.dbg_conf_tlv_len[i] =
  1082. pieces->dbg_conf_tlv_len[i];
  1083. drv->fw.dbg_conf_tlv[i] =
  1084. kmemdup(pieces->dbg_conf_tlv[i],
  1085. drv->fw.dbg_conf_tlv_len[i],
  1086. GFP_KERNEL);
  1087. if (!drv->fw.dbg_conf_tlv[i])
  1088. goto out_free_fw;
  1089. }
  1090. }
  1091. memset(&trigger_tlv_sz, 0xff, sizeof(trigger_tlv_sz));
  1092. trigger_tlv_sz[FW_DBG_TRIGGER_MISSED_BEACONS] =
  1093. sizeof(struct iwl_fw_dbg_trigger_missed_bcon);
  1094. trigger_tlv_sz[FW_DBG_TRIGGER_CHANNEL_SWITCH] = 0;
  1095. trigger_tlv_sz[FW_DBG_TRIGGER_FW_NOTIF] =
  1096. sizeof(struct iwl_fw_dbg_trigger_cmd);
  1097. trigger_tlv_sz[FW_DBG_TRIGGER_MLME] =
  1098. sizeof(struct iwl_fw_dbg_trigger_mlme);
  1099. trigger_tlv_sz[FW_DBG_TRIGGER_STATS] =
  1100. sizeof(struct iwl_fw_dbg_trigger_stats);
  1101. trigger_tlv_sz[FW_DBG_TRIGGER_RSSI] =
  1102. sizeof(struct iwl_fw_dbg_trigger_low_rssi);
  1103. trigger_tlv_sz[FW_DBG_TRIGGER_TXQ_TIMERS] =
  1104. sizeof(struct iwl_fw_dbg_trigger_txq_timer);
  1105. trigger_tlv_sz[FW_DBG_TRIGGER_TIME_EVENT] =
  1106. sizeof(struct iwl_fw_dbg_trigger_time_event);
  1107. trigger_tlv_sz[FW_DBG_TRIGGER_BA] =
  1108. sizeof(struct iwl_fw_dbg_trigger_ba);
  1109. for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_trigger_tlv); i++) {
  1110. if (pieces->dbg_trigger_tlv[i]) {
  1111. /*
  1112. * If the trigger isn't long enough, WARN and exit.
  1113. * Someone is trying to debug something and he won't
  1114. * be able to catch the bug he is trying to chase.
  1115. * We'd better be noisy to be sure he knows what's
  1116. * going on.
  1117. */
  1118. if (WARN_ON(pieces->dbg_trigger_tlv_len[i] <
  1119. (trigger_tlv_sz[i] +
  1120. sizeof(struct iwl_fw_dbg_trigger_tlv))))
  1121. goto out_free_fw;
  1122. drv->fw.dbg_trigger_tlv_len[i] =
  1123. pieces->dbg_trigger_tlv_len[i];
  1124. drv->fw.dbg_trigger_tlv[i] =
  1125. kmemdup(pieces->dbg_trigger_tlv[i],
  1126. drv->fw.dbg_trigger_tlv_len[i],
  1127. GFP_KERNEL);
  1128. if (!drv->fw.dbg_trigger_tlv[i])
  1129. goto out_free_fw;
  1130. }
  1131. }
  1132. /* Now that we can no longer fail, copy information */
  1133. /*
  1134. * The (size - 16) / 12 formula is based on the information recorded
  1135. * for each event, which is of mode 1 (including timestamp) for all
  1136. * new microcodes that include this information.
  1137. */
  1138. fw->init_evtlog_ptr = pieces->init_evtlog_ptr;
  1139. if (pieces->init_evtlog_size)
  1140. fw->init_evtlog_size = (pieces->init_evtlog_size - 16)/12;
  1141. else
  1142. fw->init_evtlog_size =
  1143. drv->cfg->base_params->max_event_log_size;
  1144. fw->init_errlog_ptr = pieces->init_errlog_ptr;
  1145. fw->inst_evtlog_ptr = pieces->inst_evtlog_ptr;
  1146. if (pieces->inst_evtlog_size)
  1147. fw->inst_evtlog_size = (pieces->inst_evtlog_size - 16)/12;
  1148. else
  1149. fw->inst_evtlog_size =
  1150. drv->cfg->base_params->max_event_log_size;
  1151. fw->inst_errlog_ptr = pieces->inst_errlog_ptr;
  1152. /*
  1153. * figure out the offset of chain noise reset and gain commands
  1154. * base on the size of standard phy calibration commands table size
  1155. */
  1156. if (fw->ucode_capa.standard_phy_calibration_size >
  1157. IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
  1158. fw->ucode_capa.standard_phy_calibration_size =
  1159. IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
  1160. /* We have our copies now, allow OS release its copies */
  1161. release_firmware(ucode_raw);
  1162. mutex_lock(&iwlwifi_opmode_table_mtx);
  1163. if (fw->mvm_fw)
  1164. op = &iwlwifi_opmode_table[MVM_OP_MODE];
  1165. else
  1166. op = &iwlwifi_opmode_table[DVM_OP_MODE];
  1167. IWL_INFO(drv, "loaded firmware version %s op_mode %s\n",
  1168. drv->fw.fw_version, op->name);
  1169. /* add this device to the list of devices using this op_mode */
  1170. list_add_tail(&drv->list, &op->drv);
  1171. if (op->ops) {
  1172. drv->op_mode = _iwl_op_mode_start(drv, op);
  1173. if (!drv->op_mode) {
  1174. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1175. goto out_unbind;
  1176. }
  1177. } else {
  1178. load_module = true;
  1179. }
  1180. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1181. /*
  1182. * Complete the firmware request last so that
  1183. * a driver unbind (stop) doesn't run while we
  1184. * are doing the start() above.
  1185. */
  1186. complete(&drv->request_firmware_complete);
  1187. /*
  1188. * Load the module last so we don't block anything
  1189. * else from proceeding if the module fails to load
  1190. * or hangs loading.
  1191. */
  1192. if (load_module) {
  1193. err = request_module("%s", op->name);
  1194. #ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
  1195. if (err)
  1196. IWL_ERR(drv,
  1197. "failed to load module %s (error %d), is dynamic loading enabled?\n",
  1198. op->name, err);
  1199. #endif
  1200. }
  1201. kfree(pieces);
  1202. return;
  1203. try_again:
  1204. /* try next, if any */
  1205. release_firmware(ucode_raw);
  1206. if (iwl_request_firmware(drv, false))
  1207. goto out_unbind;
  1208. kfree(pieces);
  1209. return;
  1210. out_free_fw:
  1211. IWL_ERR(drv, "failed to allocate pci memory\n");
  1212. iwl_dealloc_ucode(drv);
  1213. release_firmware(ucode_raw);
  1214. out_unbind:
  1215. kfree(pieces);
  1216. complete(&drv->request_firmware_complete);
  1217. device_release_driver(drv->trans->dev);
  1218. }
  1219. struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
  1220. const struct iwl_cfg *cfg)
  1221. {
  1222. struct iwl_drv *drv;
  1223. int ret;
  1224. drv = kzalloc(sizeof(*drv), GFP_KERNEL);
  1225. if (!drv) {
  1226. ret = -ENOMEM;
  1227. goto err;
  1228. }
  1229. drv->trans = trans;
  1230. drv->dev = trans->dev;
  1231. drv->cfg = cfg;
  1232. init_completion(&drv->request_firmware_complete);
  1233. INIT_LIST_HEAD(&drv->list);
  1234. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1235. /* Create the device debugfs entries. */
  1236. drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev),
  1237. iwl_dbgfs_root);
  1238. if (!drv->dbgfs_drv) {
  1239. IWL_ERR(drv, "failed to create debugfs directory\n");
  1240. ret = -ENOMEM;
  1241. goto err_free_drv;
  1242. }
  1243. /* Create transport layer debugfs dir */
  1244. drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv);
  1245. if (!drv->trans->dbgfs_dir) {
  1246. IWL_ERR(drv, "failed to create transport debugfs directory\n");
  1247. ret = -ENOMEM;
  1248. goto err_free_dbgfs;
  1249. }
  1250. #endif
  1251. ret = iwl_request_firmware(drv, true);
  1252. if (ret) {
  1253. IWL_ERR(trans, "Couldn't request the fw\n");
  1254. goto err_fw;
  1255. }
  1256. return drv;
  1257. err_fw:
  1258. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1259. err_free_dbgfs:
  1260. debugfs_remove_recursive(drv->dbgfs_drv);
  1261. err_free_drv:
  1262. #endif
  1263. kfree(drv);
  1264. err:
  1265. return ERR_PTR(ret);
  1266. }
  1267. void iwl_drv_stop(struct iwl_drv *drv)
  1268. {
  1269. wait_for_completion(&drv->request_firmware_complete);
  1270. _iwl_op_mode_stop(drv);
  1271. iwl_dealloc_ucode(drv);
  1272. mutex_lock(&iwlwifi_opmode_table_mtx);
  1273. /*
  1274. * List is empty (this item wasn't added)
  1275. * when firmware loading failed -- in that
  1276. * case we can't remove it from any list.
  1277. */
  1278. if (!list_empty(&drv->list))
  1279. list_del(&drv->list);
  1280. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1281. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1282. debugfs_remove_recursive(drv->dbgfs_drv);
  1283. #endif
  1284. kfree(drv);
  1285. }
  1286. /* shared module parameters */
  1287. struct iwl_mod_params iwlwifi_mod_params = {
  1288. .restart_fw = true,
  1289. .bt_coex_active = true,
  1290. .power_level = IWL_POWER_INDEX_1,
  1291. .d0i3_disable = true,
  1292. #ifndef CONFIG_IWLWIFI_UAPSD
  1293. .uapsd_disable = true,
  1294. #endif /* CONFIG_IWLWIFI_UAPSD */
  1295. /* the rest are 0 by default */
  1296. };
  1297. IWL_EXPORT_SYMBOL(iwlwifi_mod_params);
  1298. int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
  1299. {
  1300. int i;
  1301. struct iwl_drv *drv;
  1302. struct iwlwifi_opmode_table *op;
  1303. mutex_lock(&iwlwifi_opmode_table_mtx);
  1304. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  1305. op = &iwlwifi_opmode_table[i];
  1306. if (strcmp(op->name, name))
  1307. continue;
  1308. op->ops = ops;
  1309. /* TODO: need to handle exceptional case */
  1310. list_for_each_entry(drv, &op->drv, list)
  1311. drv->op_mode = _iwl_op_mode_start(drv, op);
  1312. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1313. return 0;
  1314. }
  1315. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1316. return -EIO;
  1317. }
  1318. IWL_EXPORT_SYMBOL(iwl_opmode_register);
  1319. void iwl_opmode_deregister(const char *name)
  1320. {
  1321. int i;
  1322. struct iwl_drv *drv;
  1323. mutex_lock(&iwlwifi_opmode_table_mtx);
  1324. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
  1325. if (strcmp(iwlwifi_opmode_table[i].name, name))
  1326. continue;
  1327. iwlwifi_opmode_table[i].ops = NULL;
  1328. /* call the stop routine for all devices */
  1329. list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
  1330. _iwl_op_mode_stop(drv);
  1331. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1332. return;
  1333. }
  1334. mutex_unlock(&iwlwifi_opmode_table_mtx);
  1335. }
  1336. IWL_EXPORT_SYMBOL(iwl_opmode_deregister);
  1337. static int __init iwl_drv_init(void)
  1338. {
  1339. int i;
  1340. mutex_init(&iwlwifi_opmode_table_mtx);
  1341. for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++)
  1342. INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);
  1343. pr_info(DRV_DESCRIPTION "\n");
  1344. pr_info(DRV_COPYRIGHT "\n");
  1345. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1346. /* Create the root of iwlwifi debugfs subsystem. */
  1347. iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL);
  1348. if (!iwl_dbgfs_root)
  1349. return -EFAULT;
  1350. #endif
  1351. return iwl_pci_register_driver();
  1352. }
  1353. module_init(iwl_drv_init);
  1354. static void __exit iwl_drv_exit(void)
  1355. {
  1356. iwl_pci_unregister_driver();
  1357. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1358. debugfs_remove_recursive(iwl_dbgfs_root);
  1359. #endif
  1360. }
  1361. module_exit(iwl_drv_exit);
  1362. #ifdef CONFIG_IWLWIFI_DEBUG
  1363. module_param_named(debug, iwlwifi_mod_params.debug_level, uint,
  1364. S_IRUGO | S_IWUSR);
  1365. MODULE_PARM_DESC(debug, "debug output mask");
  1366. #endif
  1367. module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
  1368. MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
  1369. module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
  1370. MODULE_PARM_DESC(11n_disable,
  1371. "disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX");
  1372. module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
  1373. int, S_IRUGO);
  1374. MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size (default 0)");
  1375. module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, bool, S_IRUGO);
  1376. MODULE_PARM_DESC(fw_restart, "restart firmware in case of error (default true)");
  1377. module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling,
  1378. int, S_IRUGO);
  1379. MODULE_PARM_DESC(antenna_coupling,
  1380. "specify antenna coupling in dB (default: 0 dB)");
  1381. module_param_named(nvm_file, iwlwifi_mod_params.nvm_file, charp, S_IRUGO);
  1382. MODULE_PARM_DESC(nvm_file, "NVM file name");
  1383. module_param_named(d0i3_disable, iwlwifi_mod_params.d0i3_disable,
  1384. bool, S_IRUGO);
  1385. MODULE_PARM_DESC(d0i3_disable, "disable d0i3 functionality (default: Y)");
  1386. module_param_named(lar_disable, iwlwifi_mod_params.lar_disable,
  1387. bool, S_IRUGO);
  1388. MODULE_PARM_DESC(lar_disable, "disable LAR functionality (default: N)");
  1389. module_param_named(uapsd_disable, iwlwifi_mod_params.uapsd_disable,
  1390. bool, S_IRUGO | S_IWUSR);
  1391. #ifdef CONFIG_IWLWIFI_UAPSD
  1392. MODULE_PARM_DESC(uapsd_disable, "disable U-APSD functionality (default: N)");
  1393. #else
  1394. MODULE_PARM_DESC(uapsd_disable, "disable U-APSD functionality (default: Y)");
  1395. #endif
  1396. /*
  1397. * set bt_coex_active to true, uCode will do kill/defer
  1398. * every time the priority line is asserted (BT is sending signals on the
  1399. * priority line in the PCIx).
  1400. * set bt_coex_active to false, uCode will ignore the BT activity and
  1401. * perform the normal operation
  1402. *
  1403. * User might experience transmit issue on some platform due to WiFi/BT
  1404. * co-exist problem. The possible behaviors are:
  1405. * Able to scan and finding all the available AP
  1406. * Not able to associate with any AP
  1407. * On those platforms, WiFi communication can be restored by set
  1408. * "bt_coex_active" module parameter to "false"
  1409. *
  1410. * default: bt_coex_active = true (BT_COEX_ENABLE)
  1411. */
  1412. module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active,
  1413. bool, S_IRUGO);
  1414. MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
  1415. module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO);
  1416. MODULE_PARM_DESC(led_mode, "0=system default, "
  1417. "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
  1418. module_param_named(power_save, iwlwifi_mod_params.power_save,
  1419. bool, S_IRUGO);
  1420. MODULE_PARM_DESC(power_save,
  1421. "enable WiFi power management (default: disable)");
  1422. module_param_named(power_level, iwlwifi_mod_params.power_level,
  1423. int, S_IRUGO);
  1424. MODULE_PARM_DESC(power_level,
  1425. "default power save level (range from 1 - 5, default: 1)");
  1426. module_param_named(fw_monitor, iwlwifi_mod_params.fw_monitor, bool, S_IRUGO);
  1427. MODULE_PARM_DESC(fw_monitor,
  1428. "firmware monitor - to debug FW (default: false - needs lots of memory)");