4965.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/init.h>
  29. #include <linux/pci.h>
  30. #include <linux/dma-mapping.h>
  31. #include <linux/delay.h>
  32. #include <linux/sched.h>
  33. #include <linux/skbuff.h>
  34. #include <linux/netdevice.h>
  35. #include <net/mac80211.h>
  36. #include <linux/etherdevice.h>
  37. #include <asm/unaligned.h>
  38. #include "common.h"
  39. #include "4965.h"
  40. /**
  41. * il_verify_inst_sparse - verify runtime uCode image in card vs. host,
  42. * using sample data 100 bytes apart. If these sample points are good,
  43. * it's a pretty good bet that everything between them is good, too.
  44. */
  45. static int
  46. il4965_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len)
  47. {
  48. u32 val;
  49. int ret = 0;
  50. u32 errcnt = 0;
  51. u32 i;
  52. D_INFO("ucode inst image size is %u\n", len);
  53. for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) {
  54. /* read data comes through single port, auto-incr addr */
  55. /* NOTE: Use the debugless read so we don't flood kernel log
  56. * if IL_DL_IO is set */
  57. il_wr(il, HBUS_TARG_MEM_RADDR, i + IL4965_RTC_INST_LOWER_BOUND);
  58. val = _il_rd(il, HBUS_TARG_MEM_RDAT);
  59. if (val != le32_to_cpu(*image)) {
  60. ret = -EIO;
  61. errcnt++;
  62. if (errcnt >= 3)
  63. break;
  64. }
  65. }
  66. return ret;
  67. }
  68. /**
  69. * il4965_verify_inst_full - verify runtime uCode image in card vs. host,
  70. * looking at all data.
  71. */
  72. static int
  73. il4965_verify_inst_full(struct il_priv *il, __le32 * image, u32 len)
  74. {
  75. u32 val;
  76. u32 save_len = len;
  77. int ret = 0;
  78. u32 errcnt;
  79. D_INFO("ucode inst image size is %u\n", len);
  80. il_wr(il, HBUS_TARG_MEM_RADDR, IL4965_RTC_INST_LOWER_BOUND);
  81. errcnt = 0;
  82. for (; len > 0; len -= sizeof(u32), image++) {
  83. /* read data comes through single port, auto-incr addr */
  84. /* NOTE: Use the debugless read so we don't flood kernel log
  85. * if IL_DL_IO is set */
  86. val = _il_rd(il, HBUS_TARG_MEM_RDAT);
  87. if (val != le32_to_cpu(*image)) {
  88. IL_ERR("uCode INST section is invalid at "
  89. "offset 0x%x, is 0x%x, s/b 0x%x\n",
  90. save_len - len, val, le32_to_cpu(*image));
  91. ret = -EIO;
  92. errcnt++;
  93. if (errcnt >= 20)
  94. break;
  95. }
  96. }
  97. if (!errcnt)
  98. D_INFO("ucode image in INSTRUCTION memory is good\n");
  99. return ret;
  100. }
  101. /**
  102. * il4965_verify_ucode - determine which instruction image is in SRAM,
  103. * and verify its contents
  104. */
  105. int
  106. il4965_verify_ucode(struct il_priv *il)
  107. {
  108. __le32 *image;
  109. u32 len;
  110. int ret;
  111. /* Try bootstrap */
  112. image = (__le32 *) il->ucode_boot.v_addr;
  113. len = il->ucode_boot.len;
  114. ret = il4965_verify_inst_sparse(il, image, len);
  115. if (!ret) {
  116. D_INFO("Bootstrap uCode is good in inst SRAM\n");
  117. return 0;
  118. }
  119. /* Try initialize */
  120. image = (__le32 *) il->ucode_init.v_addr;
  121. len = il->ucode_init.len;
  122. ret = il4965_verify_inst_sparse(il, image, len);
  123. if (!ret) {
  124. D_INFO("Initialize uCode is good in inst SRAM\n");
  125. return 0;
  126. }
  127. /* Try runtime/protocol */
  128. image = (__le32 *) il->ucode_code.v_addr;
  129. len = il->ucode_code.len;
  130. ret = il4965_verify_inst_sparse(il, image, len);
  131. if (!ret) {
  132. D_INFO("Runtime uCode is good in inst SRAM\n");
  133. return 0;
  134. }
  135. IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
  136. /* Since nothing seems to match, show first several data entries in
  137. * instruction SRAM, so maybe visual inspection will give a clue.
  138. * Selection of bootstrap image (vs. other images) is arbitrary. */
  139. image = (__le32 *) il->ucode_boot.v_addr;
  140. len = il->ucode_boot.len;
  141. ret = il4965_verify_inst_full(il, image, len);
  142. return ret;
  143. }
  144. /******************************************************************************
  145. *
  146. * EEPROM related functions
  147. *
  148. ******************************************************************************/
  149. /*
  150. * The device's EEPROM semaphore prevents conflicts between driver and uCode
  151. * when accessing the EEPROM; each access is a series of pulses to/from the
  152. * EEPROM chip, not a single event, so even reads could conflict if they
  153. * weren't arbitrated by the semaphore.
  154. */
  155. int
  156. il4965_eeprom_acquire_semaphore(struct il_priv *il)
  157. {
  158. u16 count;
  159. int ret;
  160. for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
  161. /* Request semaphore */
  162. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  163. CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
  164. /* See if we got it */
  165. ret =
  166. _il_poll_bit(il, CSR_HW_IF_CONFIG_REG,
  167. CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
  168. CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
  169. EEPROM_SEM_TIMEOUT);
  170. if (ret >= 0)
  171. return ret;
  172. }
  173. return ret;
  174. }
  175. void
  176. il4965_eeprom_release_semaphore(struct il_priv *il)
  177. {
  178. il_clear_bit(il, CSR_HW_IF_CONFIG_REG,
  179. CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
  180. }
  181. int
  182. il4965_eeprom_check_version(struct il_priv *il)
  183. {
  184. u16 eeprom_ver;
  185. u16 calib_ver;
  186. eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION);
  187. calib_ver = il_eeprom_query16(il, EEPROM_4965_CALIB_VERSION_OFFSET);
  188. if (eeprom_ver < il->cfg->eeprom_ver ||
  189. calib_ver < il->cfg->eeprom_calib_ver)
  190. goto err;
  191. IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver);
  192. return 0;
  193. err:
  194. IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x "
  195. "CALIB=0x%x < 0x%x\n", eeprom_ver, il->cfg->eeprom_ver,
  196. calib_ver, il->cfg->eeprom_calib_ver);
  197. return -EINVAL;
  198. }
  199. void
  200. il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac)
  201. {
  202. const u8 *addr = il_eeprom_query_addr(il,
  203. EEPROM_MAC_ADDRESS);
  204. memcpy(mac, addr, ETH_ALEN);
  205. }
  206. /* Send led command */
  207. static int
  208. il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd)
  209. {
  210. struct il_host_cmd cmd = {
  211. .id = C_LEDS,
  212. .len = sizeof(struct il_led_cmd),
  213. .data = led_cmd,
  214. .flags = CMD_ASYNC,
  215. .callback = NULL,
  216. };
  217. u32 reg;
  218. reg = _il_rd(il, CSR_LED_REG);
  219. if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
  220. _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
  221. return il_send_cmd(il, &cmd);
  222. }
  223. /* Set led register off */
  224. void
  225. il4965_led_enable(struct il_priv *il)
  226. {
  227. _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
  228. }
  229. const struct il_led_ops il4965_led_ops = {
  230. .cmd = il4965_send_led_cmd,
  231. };
  232. static int il4965_send_tx_power(struct il_priv *il);
  233. static int il4965_hw_get_temperature(struct il_priv *il);
  234. /* Highest firmware API version supported */
  235. #define IL4965_UCODE_API_MAX 2
  236. /* Lowest firmware API version supported */
  237. #define IL4965_UCODE_API_MIN 2
  238. #define IL4965_FW_PRE "iwlwifi-4965-"
  239. #define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode"
  240. #define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api)
  241. /* check contents of special bootstrap uCode SRAM */
  242. static int
  243. il4965_verify_bsm(struct il_priv *il)
  244. {
  245. __le32 *image = il->ucode_boot.v_addr;
  246. u32 len = il->ucode_boot.len;
  247. u32 reg;
  248. u32 val;
  249. D_INFO("Begin verify bsm\n");
  250. /* verify BSM SRAM contents */
  251. val = il_rd_prph(il, BSM_WR_DWCOUNT_REG);
  252. for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len;
  253. reg += sizeof(u32), image++) {
  254. val = il_rd_prph(il, reg);
  255. if (val != le32_to_cpu(*image)) {
  256. IL_ERR("BSM uCode verification failed at "
  257. "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n",
  258. BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND,
  259. len, val, le32_to_cpu(*image));
  260. return -EIO;
  261. }
  262. }
  263. D_INFO("BSM bootstrap uCode image OK\n");
  264. return 0;
  265. }
  266. /**
  267. * il4965_load_bsm - Load bootstrap instructions
  268. *
  269. * BSM operation:
  270. *
  271. * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program
  272. * in special SRAM that does not power down during RFKILL. When powering back
  273. * up after power-saving sleeps (or during initial uCode load), the BSM loads
  274. * the bootstrap program into the on-board processor, and starts it.
  275. *
  276. * The bootstrap program loads (via DMA) instructions and data for a new
  277. * program from host DRAM locations indicated by the host driver in the
  278. * BSM_DRAM_* registers. Once the new program is loaded, it starts
  279. * automatically.
  280. *
  281. * When initializing the NIC, the host driver points the BSM to the
  282. * "initialize" uCode image. This uCode sets up some internal data, then
  283. * notifies host via "initialize alive" that it is complete.
  284. *
  285. * The host then replaces the BSM_DRAM_* pointer values to point to the
  286. * normal runtime uCode instructions and a backup uCode data cache buffer
  287. * (filled initially with starting data values for the on-board processor),
  288. * then triggers the "initialize" uCode to load and launch the runtime uCode,
  289. * which begins normal operation.
  290. *
  291. * When doing a power-save shutdown, runtime uCode saves data SRAM into
  292. * the backup data cache in DRAM before SRAM is powered down.
  293. *
  294. * When powering back up, the BSM loads the bootstrap program. This reloads
  295. * the runtime uCode instructions and the backup data cache into SRAM,
  296. * and re-launches the runtime uCode from where it left off.
  297. */
  298. static int
  299. il4965_load_bsm(struct il_priv *il)
  300. {
  301. __le32 *image = il->ucode_boot.v_addr;
  302. u32 len = il->ucode_boot.len;
  303. dma_addr_t pinst;
  304. dma_addr_t pdata;
  305. u32 inst_len;
  306. u32 data_len;
  307. int i;
  308. u32 done;
  309. u32 reg_offset;
  310. int ret;
  311. D_INFO("Begin load bsm\n");
  312. il->ucode_type = UCODE_RT;
  313. /* make sure bootstrap program is no larger than BSM's SRAM size */
  314. if (len > IL49_MAX_BSM_SIZE)
  315. return -EINVAL;
  316. /* Tell bootstrap uCode where to find the "Initialize" uCode
  317. * in host DRAM ... host DRAM physical address bits 35:4 for 4965.
  318. * NOTE: il_init_alive_start() will replace these values,
  319. * after the "initialize" uCode has run, to point to
  320. * runtime/protocol instructions and backup data cache.
  321. */
  322. pinst = il->ucode_init.p_addr >> 4;
  323. pdata = il->ucode_init_data.p_addr >> 4;
  324. inst_len = il->ucode_init.len;
  325. data_len = il->ucode_init_data.len;
  326. il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst);
  327. il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata);
  328. il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len);
  329. il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len);
  330. /* Fill BSM memory with bootstrap instructions */
  331. for (reg_offset = BSM_SRAM_LOWER_BOUND;
  332. reg_offset < BSM_SRAM_LOWER_BOUND + len;
  333. reg_offset += sizeof(u32), image++)
  334. _il_wr_prph(il, reg_offset, le32_to_cpu(*image));
  335. ret = il4965_verify_bsm(il);
  336. if (ret)
  337. return ret;
  338. /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
  339. il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0);
  340. il_wr_prph(il, BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND);
  341. il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32));
  342. /* Load bootstrap code into instruction SRAM now,
  343. * to prepare to load "initialize" uCode */
  344. il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START);
  345. /* Wait for load of bootstrap uCode to finish */
  346. for (i = 0; i < 100; i++) {
  347. done = il_rd_prph(il, BSM_WR_CTRL_REG);
  348. if (!(done & BSM_WR_CTRL_REG_BIT_START))
  349. break;
  350. udelay(10);
  351. }
  352. if (i < 100)
  353. D_INFO("BSM write complete, poll %d iterations\n", i);
  354. else {
  355. IL_ERR("BSM write did not complete!\n");
  356. return -EIO;
  357. }
  358. /* Enable future boot loads whenever power management unit triggers it
  359. * (e.g. when powering back up after power-save shutdown) */
  360. il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN);
  361. return 0;
  362. }
  363. /**
  364. * il4965_set_ucode_ptrs - Set uCode address location
  365. *
  366. * Tell initialization uCode where to find runtime uCode.
  367. *
  368. * BSM registers initially contain pointers to initialization uCode.
  369. * We need to replace them to load runtime uCode inst and data,
  370. * and to save runtime data when powering down.
  371. */
  372. static int
  373. il4965_set_ucode_ptrs(struct il_priv *il)
  374. {
  375. dma_addr_t pinst;
  376. dma_addr_t pdata;
  377. int ret = 0;
  378. /* bits 35:4 for 4965 */
  379. pinst = il->ucode_code.p_addr >> 4;
  380. pdata = il->ucode_data_backup.p_addr >> 4;
  381. /* Tell bootstrap uCode where to find image to load */
  382. il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst);
  383. il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata);
  384. il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len);
  385. /* Inst byte count must be last to set up, bit 31 signals uCode
  386. * that all new ptr/size info is in place */
  387. il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG,
  388. il->ucode_code.len | BSM_DRAM_INST_LOAD);
  389. D_INFO("Runtime uCode pointers are set.\n");
  390. return ret;
  391. }
  392. /**
  393. * il4965_init_alive_start - Called after N_ALIVE notification received
  394. *
  395. * Called after N_ALIVE notification received from "initialize" uCode.
  396. *
  397. * The 4965 "initialize" ALIVE reply contains calibration data for:
  398. * Voltage, temperature, and MIMO tx gain correction, now stored in il
  399. * (3945 does not contain this data).
  400. *
  401. * Tell "initialize" uCode to go ahead and load the runtime uCode.
  402. */
  403. static void
  404. il4965_init_alive_start(struct il_priv *il)
  405. {
  406. /* Bootstrap uCode has loaded initialize uCode ... verify inst image.
  407. * This is a paranoid check, because we would not have gotten the
  408. * "initialize" alive if code weren't properly loaded. */
  409. if (il4965_verify_ucode(il)) {
  410. /* Runtime instruction load was bad;
  411. * take it all the way back down so we can try again */
  412. D_INFO("Bad \"initialize\" uCode load.\n");
  413. goto restart;
  414. }
  415. /* Calculate temperature */
  416. il->temperature = il4965_hw_get_temperature(il);
  417. /* Send pointers to protocol/runtime uCode image ... init code will
  418. * load and launch runtime uCode, which will send us another "Alive"
  419. * notification. */
  420. D_INFO("Initialization Alive received.\n");
  421. if (il4965_set_ucode_ptrs(il)) {
  422. /* Runtime instruction load won't happen;
  423. * take it all the way back down so we can try again */
  424. D_INFO("Couldn't set up uCode pointers.\n");
  425. goto restart;
  426. }
  427. return;
  428. restart:
  429. queue_work(il->workqueue, &il->restart);
  430. }
  431. static bool
  432. iw4965_is_ht40_channel(__le32 rxon_flags)
  433. {
  434. int chan_mod =
  435. le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) >>
  436. RXON_FLG_CHANNEL_MODE_POS;
  437. return (chan_mod == CHANNEL_MODE_PURE_40 ||
  438. chan_mod == CHANNEL_MODE_MIXED);
  439. }
  440. static void
  441. il4965_nic_config(struct il_priv *il)
  442. {
  443. unsigned long flags;
  444. u16 radio_cfg;
  445. spin_lock_irqsave(&il->lock, flags);
  446. radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG);
  447. /* write radio config values to register */
  448. if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX)
  449. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  450. EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
  451. EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
  452. EEPROM_RF_CFG_DASH_MSK(radio_cfg));
  453. /* set CSR_HW_CONFIG_REG for uCode use */
  454. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  455. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  456. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  457. il->calib_info =
  458. (struct il_eeprom_calib_info *)
  459. il_eeprom_query_addr(il, EEPROM_4965_CALIB_TXPOWER_OFFSET);
  460. spin_unlock_irqrestore(&il->lock, flags);
  461. }
  462. /* Reset differential Rx gains in NIC to prepare for chain noise calibration.
  463. * Called after every association, but this runs only once!
  464. * ... once chain noise is calibrated the first time, it's good forever. */
  465. static void
  466. il4965_chain_noise_reset(struct il_priv *il)
  467. {
  468. struct il_chain_noise_data *data = &(il->chain_noise_data);
  469. if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) {
  470. struct il_calib_diff_gain_cmd cmd;
  471. /* clear data for chain noise calibration algorithm */
  472. data->chain_noise_a = 0;
  473. data->chain_noise_b = 0;
  474. data->chain_noise_c = 0;
  475. data->chain_signal_a = 0;
  476. data->chain_signal_b = 0;
  477. data->chain_signal_c = 0;
  478. data->beacon_count = 0;
  479. memset(&cmd, 0, sizeof(cmd));
  480. cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD;
  481. cmd.diff_gain_a = 0;
  482. cmd.diff_gain_b = 0;
  483. cmd.diff_gain_c = 0;
  484. if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd))
  485. IL_ERR("Could not send C_PHY_CALIBRATION\n");
  486. data->state = IL_CHAIN_NOISE_ACCUMULATE;
  487. D_CALIB("Run chain_noise_calibrate\n");
  488. }
  489. }
  490. static s32
  491. il4965_math_div_round(s32 num, s32 denom, s32 * res)
  492. {
  493. s32 sign = 1;
  494. if (num < 0) {
  495. sign = -sign;
  496. num = -num;
  497. }
  498. if (denom < 0) {
  499. sign = -sign;
  500. denom = -denom;
  501. }
  502. *res = 1;
  503. *res = ((num * 2 + denom) / (denom * 2)) * sign;
  504. return 1;
  505. }
  506. /**
  507. * il4965_get_voltage_compensation - Power supply voltage comp for txpower
  508. *
  509. * Determines power supply voltage compensation for txpower calculations.
  510. * Returns number of 1/2-dB steps to subtract from gain table idx,
  511. * to compensate for difference between power supply voltage during
  512. * factory measurements, vs. current power supply voltage.
  513. *
  514. * Voltage indication is higher for lower voltage.
  515. * Lower voltage requires more gain (lower gain table idx).
  516. */
  517. static s32
  518. il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage)
  519. {
  520. s32 comp = 0;
  521. if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage ||
  522. TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)
  523. return 0;
  524. il4965_math_div_round(current_voltage - eeprom_voltage,
  525. TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp);
  526. if (current_voltage > eeprom_voltage)
  527. comp *= 2;
  528. if ((comp < -2) || (comp > 2))
  529. comp = 0;
  530. return comp;
  531. }
  532. static s32
  533. il4965_get_tx_atten_grp(u16 channel)
  534. {
  535. if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH &&
  536. channel <= CALIB_IL_TX_ATTEN_GR5_LCH)
  537. return CALIB_CH_GROUP_5;
  538. if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH &&
  539. channel <= CALIB_IL_TX_ATTEN_GR1_LCH)
  540. return CALIB_CH_GROUP_1;
  541. if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH &&
  542. channel <= CALIB_IL_TX_ATTEN_GR2_LCH)
  543. return CALIB_CH_GROUP_2;
  544. if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH &&
  545. channel <= CALIB_IL_TX_ATTEN_GR3_LCH)
  546. return CALIB_CH_GROUP_3;
  547. if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH &&
  548. channel <= CALIB_IL_TX_ATTEN_GR4_LCH)
  549. return CALIB_CH_GROUP_4;
  550. return -EINVAL;
  551. }
  552. static u32
  553. il4965_get_sub_band(const struct il_priv *il, u32 channel)
  554. {
  555. s32 b = -1;
  556. for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) {
  557. if (il->calib_info->band_info[b].ch_from == 0)
  558. continue;
  559. if (channel >= il->calib_info->band_info[b].ch_from &&
  560. channel <= il->calib_info->band_info[b].ch_to)
  561. break;
  562. }
  563. return b;
  564. }
  565. static s32
  566. il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2)
  567. {
  568. s32 val;
  569. if (x2 == x1)
  570. return y1;
  571. else {
  572. il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val);
  573. return val + y2;
  574. }
  575. }
  576. /**
  577. * il4965_interpolate_chan - Interpolate factory measurements for one channel
  578. *
  579. * Interpolates factory measurements from the two sample channels within a
  580. * sub-band, to apply to channel of interest. Interpolation is proportional to
  581. * differences in channel frequencies, which is proportional to differences
  582. * in channel number.
  583. */
  584. static int
  585. il4965_interpolate_chan(struct il_priv *il, u32 channel,
  586. struct il_eeprom_calib_ch_info *chan_info)
  587. {
  588. s32 s = -1;
  589. u32 c;
  590. u32 m;
  591. const struct il_eeprom_calib_measure *m1;
  592. const struct il_eeprom_calib_measure *m2;
  593. struct il_eeprom_calib_measure *omeas;
  594. u32 ch_i1;
  595. u32 ch_i2;
  596. s = il4965_get_sub_band(il, channel);
  597. if (s >= EEPROM_TX_POWER_BANDS) {
  598. IL_ERR("Tx Power can not find channel %d\n", channel);
  599. return -1;
  600. }
  601. ch_i1 = il->calib_info->band_info[s].ch1.ch_num;
  602. ch_i2 = il->calib_info->band_info[s].ch2.ch_num;
  603. chan_info->ch_num = (u8) channel;
  604. D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", channel, s,
  605. ch_i1, ch_i2);
  606. for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) {
  607. for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) {
  608. m1 = &(il->calib_info->band_info[s].ch1.
  609. measurements[c][m]);
  610. m2 = &(il->calib_info->band_info[s].ch2.
  611. measurements[c][m]);
  612. omeas = &(chan_info->measurements[c][m]);
  613. omeas->actual_pow =
  614. (u8) il4965_interpolate_value(channel, ch_i1,
  615. m1->actual_pow, ch_i2,
  616. m2->actual_pow);
  617. omeas->gain_idx =
  618. (u8) il4965_interpolate_value(channel, ch_i1,
  619. m1->gain_idx, ch_i2,
  620. m2->gain_idx);
  621. omeas->temperature =
  622. (u8) il4965_interpolate_value(channel, ch_i1,
  623. m1->temperature,
  624. ch_i2,
  625. m2->temperature);
  626. omeas->pa_det =
  627. (s8) il4965_interpolate_value(channel, ch_i1,
  628. m1->pa_det, ch_i2,
  629. m2->pa_det);
  630. D_TXPOWER("chain %d meas %d AP1=%d AP2=%d AP=%d\n", c,
  631. m, m1->actual_pow, m2->actual_pow,
  632. omeas->actual_pow);
  633. D_TXPOWER("chain %d meas %d NI1=%d NI2=%d NI=%d\n", c,
  634. m, m1->gain_idx, m2->gain_idx,
  635. omeas->gain_idx);
  636. D_TXPOWER("chain %d meas %d PA1=%d PA2=%d PA=%d\n", c,
  637. m, m1->pa_det, m2->pa_det, omeas->pa_det);
  638. D_TXPOWER("chain %d meas %d T1=%d T2=%d T=%d\n", c,
  639. m, m1->temperature, m2->temperature,
  640. omeas->temperature);
  641. }
  642. }
  643. return 0;
  644. }
  645. /* bit-rate-dependent table to prevent Tx distortion, in half-dB units,
  646. * for OFDM 6, 12, 18, 24, 36, 48, 54, 60 MBit, and CCK all rates. */
  647. static s32 back_off_table[] = {
  648. 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 20 MHz */
  649. 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 20 MHz */
  650. 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 40 MHz */
  651. 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 40 MHz */
  652. 10 /* CCK */
  653. };
  654. /* Thermal compensation values for txpower for various frequency ranges ...
  655. * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */
  656. static struct il4965_txpower_comp_entry {
  657. s32 degrees_per_05db_a;
  658. s32 degrees_per_05db_a_denom;
  659. } tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = {
  660. {
  661. 9, 2}, /* group 0 5.2, ch 34-43 */
  662. {
  663. 4, 1}, /* group 1 5.2, ch 44-70 */
  664. {
  665. 4, 1}, /* group 2 5.2, ch 71-124 */
  666. {
  667. 4, 1}, /* group 3 5.2, ch 125-200 */
  668. {
  669. 3, 1} /* group 4 2.4, ch all */
  670. };
  671. static s32
  672. get_min_power_idx(s32 rate_power_idx, u32 band)
  673. {
  674. if (!band) {
  675. if ((rate_power_idx & 7) <= 4)
  676. return MIN_TX_GAIN_IDX_52GHZ_EXT;
  677. }
  678. return MIN_TX_GAIN_IDX;
  679. }
  680. struct gain_entry {
  681. u8 dsp;
  682. u8 radio;
  683. };
  684. static const struct gain_entry gain_table[2][108] = {
  685. /* 5.2GHz power gain idx table */
  686. {
  687. {123, 0x3F}, /* highest txpower */
  688. {117, 0x3F},
  689. {110, 0x3F},
  690. {104, 0x3F},
  691. {98, 0x3F},
  692. {110, 0x3E},
  693. {104, 0x3E},
  694. {98, 0x3E},
  695. {110, 0x3D},
  696. {104, 0x3D},
  697. {98, 0x3D},
  698. {110, 0x3C},
  699. {104, 0x3C},
  700. {98, 0x3C},
  701. {110, 0x3B},
  702. {104, 0x3B},
  703. {98, 0x3B},
  704. {110, 0x3A},
  705. {104, 0x3A},
  706. {98, 0x3A},
  707. {110, 0x39},
  708. {104, 0x39},
  709. {98, 0x39},
  710. {110, 0x38},
  711. {104, 0x38},
  712. {98, 0x38},
  713. {110, 0x37},
  714. {104, 0x37},
  715. {98, 0x37},
  716. {110, 0x36},
  717. {104, 0x36},
  718. {98, 0x36},
  719. {110, 0x35},
  720. {104, 0x35},
  721. {98, 0x35},
  722. {110, 0x34},
  723. {104, 0x34},
  724. {98, 0x34},
  725. {110, 0x33},
  726. {104, 0x33},
  727. {98, 0x33},
  728. {110, 0x32},
  729. {104, 0x32},
  730. {98, 0x32},
  731. {110, 0x31},
  732. {104, 0x31},
  733. {98, 0x31},
  734. {110, 0x30},
  735. {104, 0x30},
  736. {98, 0x30},
  737. {110, 0x25},
  738. {104, 0x25},
  739. {98, 0x25},
  740. {110, 0x24},
  741. {104, 0x24},
  742. {98, 0x24},
  743. {110, 0x23},
  744. {104, 0x23},
  745. {98, 0x23},
  746. {110, 0x22},
  747. {104, 0x18},
  748. {98, 0x18},
  749. {110, 0x17},
  750. {104, 0x17},
  751. {98, 0x17},
  752. {110, 0x16},
  753. {104, 0x16},
  754. {98, 0x16},
  755. {110, 0x15},
  756. {104, 0x15},
  757. {98, 0x15},
  758. {110, 0x14},
  759. {104, 0x14},
  760. {98, 0x14},
  761. {110, 0x13},
  762. {104, 0x13},
  763. {98, 0x13},
  764. {110, 0x12},
  765. {104, 0x08},
  766. {98, 0x08},
  767. {110, 0x07},
  768. {104, 0x07},
  769. {98, 0x07},
  770. {110, 0x06},
  771. {104, 0x06},
  772. {98, 0x06},
  773. {110, 0x05},
  774. {104, 0x05},
  775. {98, 0x05},
  776. {110, 0x04},
  777. {104, 0x04},
  778. {98, 0x04},
  779. {110, 0x03},
  780. {104, 0x03},
  781. {98, 0x03},
  782. {110, 0x02},
  783. {104, 0x02},
  784. {98, 0x02},
  785. {110, 0x01},
  786. {104, 0x01},
  787. {98, 0x01},
  788. {110, 0x00},
  789. {104, 0x00},
  790. {98, 0x00},
  791. {93, 0x00},
  792. {88, 0x00},
  793. {83, 0x00},
  794. {78, 0x00},
  795. },
  796. /* 2.4GHz power gain idx table */
  797. {
  798. {110, 0x3f}, /* highest txpower */
  799. {104, 0x3f},
  800. {98, 0x3f},
  801. {110, 0x3e},
  802. {104, 0x3e},
  803. {98, 0x3e},
  804. {110, 0x3d},
  805. {104, 0x3d},
  806. {98, 0x3d},
  807. {110, 0x3c},
  808. {104, 0x3c},
  809. {98, 0x3c},
  810. {110, 0x3b},
  811. {104, 0x3b},
  812. {98, 0x3b},
  813. {110, 0x3a},
  814. {104, 0x3a},
  815. {98, 0x3a},
  816. {110, 0x39},
  817. {104, 0x39},
  818. {98, 0x39},
  819. {110, 0x38},
  820. {104, 0x38},
  821. {98, 0x38},
  822. {110, 0x37},
  823. {104, 0x37},
  824. {98, 0x37},
  825. {110, 0x36},
  826. {104, 0x36},
  827. {98, 0x36},
  828. {110, 0x35},
  829. {104, 0x35},
  830. {98, 0x35},
  831. {110, 0x34},
  832. {104, 0x34},
  833. {98, 0x34},
  834. {110, 0x33},
  835. {104, 0x33},
  836. {98, 0x33},
  837. {110, 0x32},
  838. {104, 0x32},
  839. {98, 0x32},
  840. {110, 0x31},
  841. {104, 0x31},
  842. {98, 0x31},
  843. {110, 0x30},
  844. {104, 0x30},
  845. {98, 0x30},
  846. {110, 0x6},
  847. {104, 0x6},
  848. {98, 0x6},
  849. {110, 0x5},
  850. {104, 0x5},
  851. {98, 0x5},
  852. {110, 0x4},
  853. {104, 0x4},
  854. {98, 0x4},
  855. {110, 0x3},
  856. {104, 0x3},
  857. {98, 0x3},
  858. {110, 0x2},
  859. {104, 0x2},
  860. {98, 0x2},
  861. {110, 0x1},
  862. {104, 0x1},
  863. {98, 0x1},
  864. {110, 0x0},
  865. {104, 0x0},
  866. {98, 0x0},
  867. {97, 0},
  868. {96, 0},
  869. {95, 0},
  870. {94, 0},
  871. {93, 0},
  872. {92, 0},
  873. {91, 0},
  874. {90, 0},
  875. {89, 0},
  876. {88, 0},
  877. {87, 0},
  878. {86, 0},
  879. {85, 0},
  880. {84, 0},
  881. {83, 0},
  882. {82, 0},
  883. {81, 0},
  884. {80, 0},
  885. {79, 0},
  886. {78, 0},
  887. {77, 0},
  888. {76, 0},
  889. {75, 0},
  890. {74, 0},
  891. {73, 0},
  892. {72, 0},
  893. {71, 0},
  894. {70, 0},
  895. {69, 0},
  896. {68, 0},
  897. {67, 0},
  898. {66, 0},
  899. {65, 0},
  900. {64, 0},
  901. {63, 0},
  902. {62, 0},
  903. {61, 0},
  904. {60, 0},
  905. {59, 0},
  906. }
  907. };
  908. static int
  909. il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40,
  910. u8 ctrl_chan_high,
  911. struct il4965_tx_power_db *tx_power_tbl)
  912. {
  913. u8 saturation_power;
  914. s32 target_power;
  915. s32 user_target_power;
  916. s32 power_limit;
  917. s32 current_temp;
  918. s32 reg_limit;
  919. s32 current_regulatory;
  920. s32 txatten_grp = CALIB_CH_GROUP_MAX;
  921. int i;
  922. int c;
  923. const struct il_channel_info *ch_info = NULL;
  924. struct il_eeprom_calib_ch_info ch_eeprom_info;
  925. const struct il_eeprom_calib_measure *measurement;
  926. s16 voltage;
  927. s32 init_voltage;
  928. s32 voltage_compensation;
  929. s32 degrees_per_05db_num;
  930. s32 degrees_per_05db_denom;
  931. s32 factory_temp;
  932. s32 temperature_comp[2];
  933. s32 factory_gain_idx[2];
  934. s32 factory_actual_pwr[2];
  935. s32 power_idx;
  936. /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units
  937. * are used for idxing into txpower table) */
  938. user_target_power = 2 * il->tx_power_user_lmt;
  939. /* Get current (RXON) channel, band, width */
  940. D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40);
  941. ch_info = il_get_channel_info(il, il->band, channel);
  942. if (!il_is_channel_valid(ch_info))
  943. return -EINVAL;
  944. /* get txatten group, used to select 1) thermal txpower adjustment
  945. * and 2) mimo txpower balance between Tx chains. */
  946. txatten_grp = il4965_get_tx_atten_grp(channel);
  947. if (txatten_grp < 0) {
  948. IL_ERR("Can't find txatten group for channel %d.\n", channel);
  949. return txatten_grp;
  950. }
  951. D_TXPOWER("channel %d belongs to txatten group %d\n", channel,
  952. txatten_grp);
  953. if (is_ht40) {
  954. if (ctrl_chan_high)
  955. channel -= 2;
  956. else
  957. channel += 2;
  958. }
  959. /* hardware txpower limits ...
  960. * saturation (clipping distortion) txpowers are in half-dBm */
  961. if (band)
  962. saturation_power = il->calib_info->saturation_power24;
  963. else
  964. saturation_power = il->calib_info->saturation_power52;
  965. if (saturation_power < IL_TX_POWER_SATURATION_MIN ||
  966. saturation_power > IL_TX_POWER_SATURATION_MAX) {
  967. if (band)
  968. saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24;
  969. else
  970. saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52;
  971. }
  972. /* regulatory txpower limits ... reg_limit values are in half-dBm,
  973. * max_power_avg values are in dBm, convert * 2 */
  974. if (is_ht40)
  975. reg_limit = ch_info->ht40_max_power_avg * 2;
  976. else
  977. reg_limit = ch_info->max_power_avg * 2;
  978. if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) ||
  979. (reg_limit > IL_TX_POWER_REGULATORY_MAX)) {
  980. if (band)
  981. reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24;
  982. else
  983. reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52;
  984. }
  985. /* Interpolate txpower calibration values for this channel,
  986. * based on factory calibration tests on spaced channels. */
  987. il4965_interpolate_chan(il, channel, &ch_eeprom_info);
  988. /* calculate tx gain adjustment based on power supply voltage */
  989. voltage = le16_to_cpu(il->calib_info->voltage);
  990. init_voltage = (s32) le32_to_cpu(il->card_alive_init.voltage);
  991. voltage_compensation =
  992. il4965_get_voltage_compensation(voltage, init_voltage);
  993. D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage,
  994. voltage, voltage_compensation);
  995. /* get current temperature (Celsius) */
  996. current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN);
  997. current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX);
  998. current_temp = KELVIN_TO_CELSIUS(current_temp);
  999. /* select thermal txpower adjustment params, based on channel group
  1000. * (same frequency group used for mimo txatten adjustment) */
  1001. degrees_per_05db_num =
  1002. tx_power_cmp_tble[txatten_grp].degrees_per_05db_a;
  1003. degrees_per_05db_denom =
  1004. tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom;
  1005. /* get per-chain txpower values from factory measurements */
  1006. for (c = 0; c < 2; c++) {
  1007. measurement = &ch_eeprom_info.measurements[c][1];
  1008. /* txgain adjustment (in half-dB steps) based on difference
  1009. * between factory and current temperature */
  1010. factory_temp = measurement->temperature;
  1011. il4965_math_div_round((current_temp -
  1012. factory_temp) * degrees_per_05db_denom,
  1013. degrees_per_05db_num,
  1014. &temperature_comp[c]);
  1015. factory_gain_idx[c] = measurement->gain_idx;
  1016. factory_actual_pwr[c] = measurement->actual_pow;
  1017. D_TXPOWER("chain = %d\n", c);
  1018. D_TXPOWER("fctry tmp %d, " "curr tmp %d, comp %d steps\n",
  1019. factory_temp, current_temp, temperature_comp[c]);
  1020. D_TXPOWER("fctry idx %d, fctry pwr %d\n", factory_gain_idx[c],
  1021. factory_actual_pwr[c]);
  1022. }
  1023. /* for each of 33 bit-rates (including 1 for CCK) */
  1024. for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) {
  1025. u8 is_mimo_rate;
  1026. union il4965_tx_power_dual_stream tx_power;
  1027. /* for mimo, reduce each chain's txpower by half
  1028. * (3dB, 6 steps), so total output power is regulatory
  1029. * compliant. */
  1030. if (i & 0x8) {
  1031. current_regulatory =
  1032. reg_limit -
  1033. IL_TX_POWER_MIMO_REGULATORY_COMPENSATION;
  1034. is_mimo_rate = 1;
  1035. } else {
  1036. current_regulatory = reg_limit;
  1037. is_mimo_rate = 0;
  1038. }
  1039. /* find txpower limit, either hardware or regulatory */
  1040. power_limit = saturation_power - back_off_table[i];
  1041. if (power_limit > current_regulatory)
  1042. power_limit = current_regulatory;
  1043. /* reduce user's txpower request if necessary
  1044. * for this rate on this channel */
  1045. target_power = user_target_power;
  1046. if (target_power > power_limit)
  1047. target_power = power_limit;
  1048. D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i,
  1049. saturation_power - back_off_table[i],
  1050. current_regulatory, user_target_power, target_power);
  1051. /* for each of 2 Tx chains (radio transmitters) */
  1052. for (c = 0; c < 2; c++) {
  1053. s32 atten_value;
  1054. if (is_mimo_rate)
  1055. atten_value =
  1056. (s32) le32_to_cpu(il->card_alive_init.
  1057. tx_atten[txatten_grp][c]);
  1058. else
  1059. atten_value = 0;
  1060. /* calculate idx; higher idx means lower txpower */
  1061. power_idx =
  1062. (u8) (factory_gain_idx[c] -
  1063. (target_power - factory_actual_pwr[c]) -
  1064. temperature_comp[c] - voltage_compensation +
  1065. atten_value);
  1066. /* D_TXPOWER("calculated txpower idx %d\n",
  1067. power_idx); */
  1068. if (power_idx < get_min_power_idx(i, band))
  1069. power_idx = get_min_power_idx(i, band);
  1070. /* adjust 5 GHz idx to support negative idxes */
  1071. if (!band)
  1072. power_idx += 9;
  1073. /* CCK, rate 32, reduce txpower for CCK */
  1074. if (i == POWER_TBL_CCK_ENTRY)
  1075. power_idx +=
  1076. IL_TX_POWER_CCK_COMPENSATION_C_STEP;
  1077. /* stay within the table! */
  1078. if (power_idx > 107) {
  1079. IL_WARN("txpower idx %d > 107\n", power_idx);
  1080. power_idx = 107;
  1081. }
  1082. if (power_idx < 0) {
  1083. IL_WARN("txpower idx %d < 0\n", power_idx);
  1084. power_idx = 0;
  1085. }
  1086. /* fill txpower command for this rate/chain */
  1087. tx_power.s.radio_tx_gain[c] =
  1088. gain_table[band][power_idx].radio;
  1089. tx_power.s.dsp_predis_atten[c] =
  1090. gain_table[band][power_idx].dsp;
  1091. D_TXPOWER("chain %d mimo %d idx %d "
  1092. "gain 0x%02x dsp %d\n", c, atten_value,
  1093. power_idx, tx_power.s.radio_tx_gain[c],
  1094. tx_power.s.dsp_predis_atten[c]);
  1095. } /* for each chain */
  1096. tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw);
  1097. } /* for each rate */
  1098. return 0;
  1099. }
  1100. /**
  1101. * il4965_send_tx_power - Configure the TXPOWER level user limit
  1102. *
  1103. * Uses the active RXON for channel, band, and characteristics (ht40, high)
  1104. * The power limit is taken from il->tx_power_user_lmt.
  1105. */
  1106. static int
  1107. il4965_send_tx_power(struct il_priv *il)
  1108. {
  1109. struct il4965_txpowertable_cmd cmd = { 0 };
  1110. int ret;
  1111. u8 band = 0;
  1112. bool is_ht40 = false;
  1113. u8 ctrl_chan_high = 0;
  1114. if (WARN_ONCE
  1115. (test_bit(S_SCAN_HW, &il->status),
  1116. "TX Power requested while scanning!\n"))
  1117. return -EAGAIN;
  1118. band = il->band == IEEE80211_BAND_2GHZ;
  1119. is_ht40 = iw4965_is_ht40_channel(il->active.flags);
  1120. if (is_ht40 && (il->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK))
  1121. ctrl_chan_high = 1;
  1122. cmd.band = band;
  1123. cmd.channel = il->active.channel;
  1124. ret =
  1125. il4965_fill_txpower_tbl(il, band, le16_to_cpu(il->active.channel),
  1126. is_ht40, ctrl_chan_high, &cmd.tx_power);
  1127. if (ret)
  1128. goto out;
  1129. ret = il_send_cmd_pdu(il, C_TX_PWR_TBL, sizeof(cmd), &cmd);
  1130. out:
  1131. return ret;
  1132. }
  1133. static int
  1134. il4965_send_rxon_assoc(struct il_priv *il)
  1135. {
  1136. int ret = 0;
  1137. struct il4965_rxon_assoc_cmd rxon_assoc;
  1138. const struct il_rxon_cmd *rxon1 = &il->staging;
  1139. const struct il_rxon_cmd *rxon2 = &il->active;
  1140. if (rxon1->flags == rxon2->flags &&
  1141. rxon1->filter_flags == rxon2->filter_flags &&
  1142. rxon1->cck_basic_rates == rxon2->cck_basic_rates &&
  1143. rxon1->ofdm_ht_single_stream_basic_rates ==
  1144. rxon2->ofdm_ht_single_stream_basic_rates &&
  1145. rxon1->ofdm_ht_dual_stream_basic_rates ==
  1146. rxon2->ofdm_ht_dual_stream_basic_rates &&
  1147. rxon1->rx_chain == rxon2->rx_chain &&
  1148. rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) {
  1149. D_INFO("Using current RXON_ASSOC. Not resending.\n");
  1150. return 0;
  1151. }
  1152. rxon_assoc.flags = il->staging.flags;
  1153. rxon_assoc.filter_flags = il->staging.filter_flags;
  1154. rxon_assoc.ofdm_basic_rates = il->staging.ofdm_basic_rates;
  1155. rxon_assoc.cck_basic_rates = il->staging.cck_basic_rates;
  1156. rxon_assoc.reserved = 0;
  1157. rxon_assoc.ofdm_ht_single_stream_basic_rates =
  1158. il->staging.ofdm_ht_single_stream_basic_rates;
  1159. rxon_assoc.ofdm_ht_dual_stream_basic_rates =
  1160. il->staging.ofdm_ht_dual_stream_basic_rates;
  1161. rxon_assoc.rx_chain_select_flags = il->staging.rx_chain;
  1162. ret =
  1163. il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc),
  1164. &rxon_assoc, NULL);
  1165. return ret;
  1166. }
  1167. static int
  1168. il4965_commit_rxon(struct il_priv *il)
  1169. {
  1170. /* cast away the const for active_rxon in this function */
  1171. struct il_rxon_cmd *active_rxon = (void *)&il->active;
  1172. int ret;
  1173. bool new_assoc = !!(il->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
  1174. if (!il_is_alive(il))
  1175. return -EBUSY;
  1176. /* always get timestamp with Rx frame */
  1177. il->staging.flags |= RXON_FLG_TSF2HOST_MSK;
  1178. ret = il_check_rxon_cmd(il);
  1179. if (ret) {
  1180. IL_ERR("Invalid RXON configuration. Not committing.\n");
  1181. return -EINVAL;
  1182. }
  1183. /*
  1184. * receive commit_rxon request
  1185. * abort any previous channel switch if still in process
  1186. */
  1187. if (test_bit(S_CHANNEL_SWITCH_PENDING, &il->status) &&
  1188. il->switch_channel != il->staging.channel) {
  1189. D_11H("abort channel switch on %d\n",
  1190. le16_to_cpu(il->switch_channel));
  1191. il_chswitch_done(il, false);
  1192. }
  1193. /* If we don't need to send a full RXON, we can use
  1194. * il_rxon_assoc_cmd which is used to reconfigure filter
  1195. * and other flags for the current radio configuration. */
  1196. if (!il_full_rxon_required(il)) {
  1197. ret = il_send_rxon_assoc(il);
  1198. if (ret) {
  1199. IL_ERR("Error setting RXON_ASSOC (%d)\n", ret);
  1200. return ret;
  1201. }
  1202. memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
  1203. il_print_rx_config_cmd(il);
  1204. /*
  1205. * We do not commit tx power settings while channel changing,
  1206. * do it now if tx power changed.
  1207. */
  1208. il_set_tx_power(il, il->tx_power_next, false);
  1209. return 0;
  1210. }
  1211. /* If we are currently associated and the new config requires
  1212. * an RXON_ASSOC and the new config wants the associated mask enabled,
  1213. * we must clear the associated from the active configuration
  1214. * before we apply the new config */
  1215. if (il_is_associated(il) && new_assoc) {
  1216. D_INFO("Toggling associated bit on current RXON\n");
  1217. active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  1218. ret =
  1219. il_send_cmd_pdu(il, C_RXON,
  1220. sizeof(struct il_rxon_cmd), active_rxon);
  1221. /* If the mask clearing failed then we set
  1222. * active_rxon back to what it was previously */
  1223. if (ret) {
  1224. active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
  1225. IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret);
  1226. return ret;
  1227. }
  1228. il_clear_ucode_stations(il);
  1229. il_restore_stations(il);
  1230. ret = il4965_restore_default_wep_keys(il);
  1231. if (ret) {
  1232. IL_ERR("Failed to restore WEP keys (%d)\n", ret);
  1233. return ret;
  1234. }
  1235. }
  1236. D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n"
  1237. "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"),
  1238. le16_to_cpu(il->staging.channel), il->staging.bssid_addr);
  1239. il_set_rxon_hwcrypto(il, !il->cfg->mod_params->sw_crypto);
  1240. /* Apply the new configuration
  1241. * RXON unassoc clears the station table in uCode so restoration of
  1242. * stations is needed after it (the RXON command) completes
  1243. */
  1244. if (!new_assoc) {
  1245. ret =
  1246. il_send_cmd_pdu(il, C_RXON,
  1247. sizeof(struct il_rxon_cmd), &il->staging);
  1248. if (ret) {
  1249. IL_ERR("Error setting new RXON (%d)\n", ret);
  1250. return ret;
  1251. }
  1252. D_INFO("Return from !new_assoc RXON.\n");
  1253. memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
  1254. il_clear_ucode_stations(il);
  1255. il_restore_stations(il);
  1256. ret = il4965_restore_default_wep_keys(il);
  1257. if (ret) {
  1258. IL_ERR("Failed to restore WEP keys (%d)\n", ret);
  1259. return ret;
  1260. }
  1261. }
  1262. if (new_assoc) {
  1263. il->start_calib = 0;
  1264. /* Apply the new configuration
  1265. * RXON assoc doesn't clear the station table in uCode,
  1266. */
  1267. ret =
  1268. il_send_cmd_pdu(il, C_RXON,
  1269. sizeof(struct il_rxon_cmd), &il->staging);
  1270. if (ret) {
  1271. IL_ERR("Error setting new RXON (%d)\n", ret);
  1272. return ret;
  1273. }
  1274. memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
  1275. }
  1276. il_print_rx_config_cmd(il);
  1277. il4965_init_sensitivity(il);
  1278. /* If we issue a new RXON command which required a tune then we must
  1279. * send a new TXPOWER command or we won't be able to Tx any frames */
  1280. ret = il_set_tx_power(il, il->tx_power_next, true);
  1281. if (ret) {
  1282. IL_ERR("Error sending TX power (%d)\n", ret);
  1283. return ret;
  1284. }
  1285. return 0;
  1286. }
  1287. static int
  1288. il4965_hw_channel_switch(struct il_priv *il,
  1289. struct ieee80211_channel_switch *ch_switch)
  1290. {
  1291. int rc;
  1292. u8 band = 0;
  1293. bool is_ht40 = false;
  1294. u8 ctrl_chan_high = 0;
  1295. struct il4965_channel_switch_cmd cmd;
  1296. const struct il_channel_info *ch_info;
  1297. u32 switch_time_in_usec, ucode_switch_time;
  1298. u16 ch;
  1299. u32 tsf_low;
  1300. u8 switch_count;
  1301. u16 beacon_interval = le16_to_cpu(il->timing.beacon_interval);
  1302. struct ieee80211_vif *vif = il->vif;
  1303. band = (il->band == IEEE80211_BAND_2GHZ);
  1304. if (WARN_ON_ONCE(vif == NULL))
  1305. return -EIO;
  1306. is_ht40 = iw4965_is_ht40_channel(il->staging.flags);
  1307. if (is_ht40 && (il->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK))
  1308. ctrl_chan_high = 1;
  1309. cmd.band = band;
  1310. cmd.expect_beacon = 0;
  1311. ch = ch_switch->channel->hw_value;
  1312. cmd.channel = cpu_to_le16(ch);
  1313. cmd.rxon_flags = il->staging.flags;
  1314. cmd.rxon_filter_flags = il->staging.filter_flags;
  1315. switch_count = ch_switch->count;
  1316. tsf_low = ch_switch->timestamp & 0x0ffffffff;
  1317. /*
  1318. * calculate the ucode channel switch time
  1319. * adding TSF as one of the factor for when to switch
  1320. */
  1321. if (il->ucode_beacon_time > tsf_low && beacon_interval) {
  1322. if (switch_count >
  1323. ((il->ucode_beacon_time - tsf_low) / beacon_interval)) {
  1324. switch_count -=
  1325. (il->ucode_beacon_time - tsf_low) / beacon_interval;
  1326. } else
  1327. switch_count = 0;
  1328. }
  1329. if (switch_count <= 1)
  1330. cmd.switch_time = cpu_to_le32(il->ucode_beacon_time);
  1331. else {
  1332. switch_time_in_usec =
  1333. vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
  1334. ucode_switch_time =
  1335. il_usecs_to_beacons(il, switch_time_in_usec,
  1336. beacon_interval);
  1337. cmd.switch_time =
  1338. il_add_beacon_time(il, il->ucode_beacon_time,
  1339. ucode_switch_time, beacon_interval);
  1340. }
  1341. D_11H("uCode time for the switch is 0x%x\n", cmd.switch_time);
  1342. ch_info = il_get_channel_info(il, il->band, ch);
  1343. if (ch_info)
  1344. cmd.expect_beacon = il_is_channel_radar(ch_info);
  1345. else {
  1346. IL_ERR("invalid channel switch from %u to %u\n",
  1347. il->active.channel, ch);
  1348. return -EFAULT;
  1349. }
  1350. rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high,
  1351. &cmd.tx_power);
  1352. if (rc) {
  1353. D_11H("error:%d fill txpower_tbl\n", rc);
  1354. return rc;
  1355. }
  1356. return il_send_cmd_pdu(il, C_CHANNEL_SWITCH, sizeof(cmd), &cmd);
  1357. }
  1358. /**
  1359. * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  1360. */
  1361. static void
  1362. il4965_txq_update_byte_cnt_tbl(struct il_priv *il, struct il_tx_queue *txq,
  1363. u16 byte_cnt)
  1364. {
  1365. struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr;
  1366. int txq_id = txq->q.id;
  1367. int write_ptr = txq->q.write_ptr;
  1368. int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE;
  1369. __le16 bc_ent;
  1370. WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
  1371. bc_ent = cpu_to_le16(len & 0xFFF);
  1372. /* Set up byte count within first 256 entries */
  1373. scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
  1374. /* If within first 64 entries, duplicate at end */
  1375. if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
  1376. scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] =
  1377. bc_ent;
  1378. }
  1379. /**
  1380. * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin)
  1381. * @stats: Provides the temperature reading from the uCode
  1382. *
  1383. * A return of <0 indicates bogus data in the stats
  1384. */
  1385. static int
  1386. il4965_hw_get_temperature(struct il_priv *il)
  1387. {
  1388. s32 temperature;
  1389. s32 vt;
  1390. s32 R1, R2, R3;
  1391. u32 R4;
  1392. if (test_bit(S_TEMPERATURE, &il->status) &&
  1393. (il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK)) {
  1394. D_TEMP("Running HT40 temperature calibration\n");
  1395. R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[1]);
  1396. R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[1]);
  1397. R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[1]);
  1398. R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]);
  1399. } else {
  1400. D_TEMP("Running temperature calibration\n");
  1401. R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[0]);
  1402. R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[0]);
  1403. R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[0]);
  1404. R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]);
  1405. }
  1406. /*
  1407. * Temperature is only 23 bits, so sign extend out to 32.
  1408. *
  1409. * NOTE If we haven't received a stats notification yet
  1410. * with an updated temperature, use R4 provided to us in the
  1411. * "initialize" ALIVE response.
  1412. */
  1413. if (!test_bit(S_TEMPERATURE, &il->status))
  1414. vt = sign_extend32(R4, 23);
  1415. else
  1416. vt = sign_extend32(le32_to_cpu
  1417. (il->_4965.stats.general.common.temperature),
  1418. 23);
  1419. D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt);
  1420. if (R3 == R1) {
  1421. IL_ERR("Calibration conflict R1 == R3\n");
  1422. return -1;
  1423. }
  1424. /* Calculate temperature in degrees Kelvin, adjust by 97%.
  1425. * Add offset to center the adjustment around 0 degrees Centigrade. */
  1426. temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2);
  1427. temperature /= (R3 - R1);
  1428. temperature =
  1429. (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET;
  1430. D_TEMP("Calibrated temperature: %dK, %dC\n", temperature,
  1431. KELVIN_TO_CELSIUS(temperature));
  1432. return temperature;
  1433. }
  1434. /* Adjust Txpower only if temperature variance is greater than threshold. */
  1435. #define IL_TEMPERATURE_THRESHOLD 3
  1436. /**
  1437. * il4965_is_temp_calib_needed - determines if new calibration is needed
  1438. *
  1439. * If the temperature changed has changed sufficiently, then a recalibration
  1440. * is needed.
  1441. *
  1442. * Assumes caller will replace il->last_temperature once calibration
  1443. * executed.
  1444. */
  1445. static int
  1446. il4965_is_temp_calib_needed(struct il_priv *il)
  1447. {
  1448. int temp_diff;
  1449. if (!test_bit(S_STATS, &il->status)) {
  1450. D_TEMP("Temperature not updated -- no stats.\n");
  1451. return 0;
  1452. }
  1453. temp_diff = il->temperature - il->last_temperature;
  1454. /* get absolute value */
  1455. if (temp_diff < 0) {
  1456. D_POWER("Getting cooler, delta %d\n", temp_diff);
  1457. temp_diff = -temp_diff;
  1458. } else if (temp_diff == 0)
  1459. D_POWER("Temperature unchanged\n");
  1460. else
  1461. D_POWER("Getting warmer, delta %d\n", temp_diff);
  1462. if (temp_diff < IL_TEMPERATURE_THRESHOLD) {
  1463. D_POWER(" => thermal txpower calib not needed\n");
  1464. return 0;
  1465. }
  1466. D_POWER(" => thermal txpower calib needed\n");
  1467. return 1;
  1468. }
  1469. static void
  1470. il4965_temperature_calib(struct il_priv *il)
  1471. {
  1472. s32 temp;
  1473. temp = il4965_hw_get_temperature(il);
  1474. if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp))
  1475. return;
  1476. if (il->temperature != temp) {
  1477. if (il->temperature)
  1478. D_TEMP("Temperature changed " "from %dC to %dC\n",
  1479. KELVIN_TO_CELSIUS(il->temperature),
  1480. KELVIN_TO_CELSIUS(temp));
  1481. else
  1482. D_TEMP("Temperature " "initialized to %dC\n",
  1483. KELVIN_TO_CELSIUS(temp));
  1484. }
  1485. il->temperature = temp;
  1486. set_bit(S_TEMPERATURE, &il->status);
  1487. if (!il->disable_tx_power_cal &&
  1488. unlikely(!test_bit(S_SCANNING, &il->status)) &&
  1489. il4965_is_temp_calib_needed(il))
  1490. queue_work(il->workqueue, &il->txpower_work);
  1491. }
  1492. static u16
  1493. il4965_get_hcmd_size(u8 cmd_id, u16 len)
  1494. {
  1495. switch (cmd_id) {
  1496. case C_RXON:
  1497. return (u16) sizeof(struct il4965_rxon_cmd);
  1498. default:
  1499. return len;
  1500. }
  1501. }
  1502. static u16
  1503. il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data)
  1504. {
  1505. struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data;
  1506. addsta->mode = cmd->mode;
  1507. memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify));
  1508. memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo));
  1509. addsta->station_flags = cmd->station_flags;
  1510. addsta->station_flags_msk = cmd->station_flags_msk;
  1511. addsta->tid_disable_tx = cmd->tid_disable_tx;
  1512. addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid;
  1513. addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid;
  1514. addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn;
  1515. addsta->sleep_tx_count = cmd->sleep_tx_count;
  1516. addsta->reserved1 = cpu_to_le16(0);
  1517. addsta->reserved2 = cpu_to_le16(0);
  1518. return (u16) sizeof(struct il4965_addsta_cmd);
  1519. }
  1520. static inline u32
  1521. il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp)
  1522. {
  1523. return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN;
  1524. }
  1525. static inline u32
  1526. il4965_tx_status_to_mac80211(u32 status)
  1527. {
  1528. status &= TX_STATUS_MSK;
  1529. switch (status) {
  1530. case TX_STATUS_SUCCESS:
  1531. case TX_STATUS_DIRECT_DONE:
  1532. return IEEE80211_TX_STAT_ACK;
  1533. case TX_STATUS_FAIL_DEST_PS:
  1534. return IEEE80211_TX_STAT_TX_FILTERED;
  1535. default:
  1536. return 0;
  1537. }
  1538. }
  1539. static inline bool
  1540. il4965_is_tx_success(u32 status)
  1541. {
  1542. status &= TX_STATUS_MSK;
  1543. return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE);
  1544. }
  1545. /**
  1546. * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
  1547. */
  1548. static int
  1549. il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg,
  1550. struct il4965_tx_resp *tx_resp, int txq_id,
  1551. u16 start_idx)
  1552. {
  1553. u16 status;
  1554. struct agg_tx_status *frame_status = tx_resp->u.agg_status;
  1555. struct ieee80211_tx_info *info = NULL;
  1556. struct ieee80211_hdr *hdr = NULL;
  1557. u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
  1558. int i, sh, idx;
  1559. u16 seq;
  1560. if (agg->wait_for_ba)
  1561. D_TX_REPLY("got tx response w/o block-ack\n");
  1562. agg->frame_count = tx_resp->frame_count;
  1563. agg->start_idx = start_idx;
  1564. agg->rate_n_flags = rate_n_flags;
  1565. agg->bitmap = 0;
  1566. /* num frames attempted by Tx command */
  1567. if (agg->frame_count == 1) {
  1568. /* Only one frame was attempted; no block-ack will arrive */
  1569. status = le16_to_cpu(frame_status[0].status);
  1570. idx = start_idx;
  1571. D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
  1572. agg->frame_count, agg->start_idx, idx);
  1573. info = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]);
  1574. info->status.rates[0].count = tx_resp->failure_frame + 1;
  1575. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  1576. info->flags |= il4965_tx_status_to_mac80211(status);
  1577. il4965_hwrate_to_tx_control(il, rate_n_flags, info);
  1578. D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff,
  1579. tx_resp->failure_frame);
  1580. D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
  1581. agg->wait_for_ba = 0;
  1582. } else {
  1583. /* Two or more frames were attempted; expect block-ack */
  1584. u64 bitmap = 0;
  1585. int start = agg->start_idx;
  1586. struct sk_buff *skb;
  1587. /* Construct bit-map of pending frames within Tx win */
  1588. for (i = 0; i < agg->frame_count; i++) {
  1589. u16 sc;
  1590. status = le16_to_cpu(frame_status[i].status);
  1591. seq = le16_to_cpu(frame_status[i].sequence);
  1592. idx = SEQ_TO_IDX(seq);
  1593. txq_id = SEQ_TO_QUEUE(seq);
  1594. if (status &
  1595. (AGG_TX_STATE_FEW_BYTES_MSK |
  1596. AGG_TX_STATE_ABORT_MSK))
  1597. continue;
  1598. D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
  1599. agg->frame_count, txq_id, idx);
  1600. skb = il->txq[txq_id].skbs[idx];
  1601. if (WARN_ON_ONCE(skb == NULL))
  1602. return -1;
  1603. hdr = (struct ieee80211_hdr *) skb->data;
  1604. sc = le16_to_cpu(hdr->seq_ctrl);
  1605. if (idx != (SEQ_TO_SN(sc) & 0xff)) {
  1606. IL_ERR("BUG_ON idx doesn't match seq control"
  1607. " idx=%d, seq_idx=%d, seq=%d\n", idx,
  1608. SEQ_TO_SN(sc), hdr->seq_ctrl);
  1609. return -1;
  1610. }
  1611. D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx,
  1612. SEQ_TO_SN(sc));
  1613. sh = idx - start;
  1614. if (sh > 64) {
  1615. sh = (start - idx) + 0xff;
  1616. bitmap = bitmap << sh;
  1617. sh = 0;
  1618. start = idx;
  1619. } else if (sh < -64)
  1620. sh = 0xff - (start - idx);
  1621. else if (sh < 0) {
  1622. sh = start - idx;
  1623. start = idx;
  1624. bitmap = bitmap << sh;
  1625. sh = 0;
  1626. }
  1627. bitmap |= 1ULL << sh;
  1628. D_TX_REPLY("start=%d bitmap=0x%llx\n", start,
  1629. (unsigned long long)bitmap);
  1630. }
  1631. agg->bitmap = bitmap;
  1632. agg->start_idx = start;
  1633. D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
  1634. agg->frame_count, agg->start_idx,
  1635. (unsigned long long)agg->bitmap);
  1636. if (bitmap)
  1637. agg->wait_for_ba = 1;
  1638. }
  1639. return 0;
  1640. }
  1641. static u8
  1642. il4965_find_station(struct il_priv *il, const u8 * addr)
  1643. {
  1644. int i;
  1645. int start = 0;
  1646. int ret = IL_INVALID_STATION;
  1647. unsigned long flags;
  1648. if ((il->iw_mode == NL80211_IFTYPE_ADHOC))
  1649. start = IL_STA_ID;
  1650. if (is_broadcast_ether_addr(addr))
  1651. return il->hw_params.bcast_id;
  1652. spin_lock_irqsave(&il->sta_lock, flags);
  1653. for (i = start; i < il->hw_params.max_stations; i++)
  1654. if (il->stations[i].used &&
  1655. (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) {
  1656. ret = i;
  1657. goto out;
  1658. }
  1659. D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations);
  1660. out:
  1661. /*
  1662. * It may be possible that more commands interacting with stations
  1663. * arrive before we completed processing the adding of
  1664. * station
  1665. */
  1666. if (ret != IL_INVALID_STATION &&
  1667. (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) ||
  1668. ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) &&
  1669. (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) {
  1670. IL_ERR("Requested station info for sta %d before ready.\n",
  1671. ret);
  1672. ret = IL_INVALID_STATION;
  1673. }
  1674. spin_unlock_irqrestore(&il->sta_lock, flags);
  1675. return ret;
  1676. }
  1677. static int
  1678. il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr)
  1679. {
  1680. if (il->iw_mode == NL80211_IFTYPE_STATION) {
  1681. return IL_AP_ID;
  1682. } else {
  1683. u8 *da = ieee80211_get_DA(hdr);
  1684. return il4965_find_station(il, da);
  1685. }
  1686. }
  1687. /**
  1688. * il4965_hdl_tx - Handle standard (non-aggregation) Tx response
  1689. */
  1690. static void
  1691. il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb)
  1692. {
  1693. struct il_rx_pkt *pkt = rxb_addr(rxb);
  1694. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  1695. int txq_id = SEQ_TO_QUEUE(sequence);
  1696. int idx = SEQ_TO_IDX(sequence);
  1697. struct il_tx_queue *txq = &il->txq[txq_id];
  1698. struct sk_buff *skb;
  1699. struct ieee80211_hdr *hdr;
  1700. struct ieee80211_tx_info *info;
  1701. struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  1702. u32 status = le32_to_cpu(tx_resp->u.status);
  1703. int uninitialized_var(tid);
  1704. int sta_id;
  1705. int freed;
  1706. u8 *qc = NULL;
  1707. unsigned long flags;
  1708. if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) {
  1709. IL_ERR("Read idx for DMA queue txq_id (%d) idx %d "
  1710. "is out of range [0-%d] %d %d\n", txq_id, idx,
  1711. txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr);
  1712. return;
  1713. }
  1714. txq->time_stamp = jiffies;
  1715. skb = txq->skbs[txq->q.read_ptr];
  1716. info = IEEE80211_SKB_CB(skb);
  1717. memset(&info->status, 0, sizeof(info->status));
  1718. hdr = (struct ieee80211_hdr *) skb->data;
  1719. if (ieee80211_is_data_qos(hdr->frame_control)) {
  1720. qc = ieee80211_get_qos_ctl(hdr);
  1721. tid = qc[0] & 0xf;
  1722. }
  1723. sta_id = il4965_get_ra_sta_id(il, hdr);
  1724. if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) {
  1725. IL_ERR("Station not known\n");
  1726. return;
  1727. }
  1728. spin_lock_irqsave(&il->sta_lock, flags);
  1729. if (txq->sched_retry) {
  1730. const u32 scd_ssn = il4965_get_scd_ssn(tx_resp);
  1731. struct il_ht_agg *agg = NULL;
  1732. WARN_ON(!qc);
  1733. agg = &il->stations[sta_id].tid[tid].agg;
  1734. il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx);
  1735. /* check if BAR is needed */
  1736. if ((tx_resp->frame_count == 1) &&
  1737. !il4965_is_tx_success(status))
  1738. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  1739. if (txq->q.read_ptr != (scd_ssn & 0xff)) {
  1740. idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
  1741. D_TX_REPLY("Retry scheduler reclaim scd_ssn "
  1742. "%d idx %d\n", scd_ssn, idx);
  1743. freed = il4965_tx_queue_reclaim(il, txq_id, idx);
  1744. if (qc)
  1745. il4965_free_tfds_in_queue(il, sta_id, tid,
  1746. freed);
  1747. if (il->mac80211_registered &&
  1748. il_queue_space(&txq->q) > txq->q.low_mark &&
  1749. agg->state != IL_EMPTYING_HW_QUEUE_DELBA)
  1750. il_wake_queue(il, txq);
  1751. }
  1752. } else {
  1753. info->status.rates[0].count = tx_resp->failure_frame + 1;
  1754. info->flags |= il4965_tx_status_to_mac80211(status);
  1755. il4965_hwrate_to_tx_control(il,
  1756. le32_to_cpu(tx_resp->rate_n_flags),
  1757. info);
  1758. D_TX_REPLY("TXQ %d status %s (0x%08x) "
  1759. "rate_n_flags 0x%x retries %d\n", txq_id,
  1760. il4965_get_tx_fail_reason(status), status,
  1761. le32_to_cpu(tx_resp->rate_n_flags),
  1762. tx_resp->failure_frame);
  1763. freed = il4965_tx_queue_reclaim(il, txq_id, idx);
  1764. if (qc && likely(sta_id != IL_INVALID_STATION))
  1765. il4965_free_tfds_in_queue(il, sta_id, tid, freed);
  1766. else if (sta_id == IL_INVALID_STATION)
  1767. D_TX_REPLY("Station not known\n");
  1768. if (il->mac80211_registered &&
  1769. il_queue_space(&txq->q) > txq->q.low_mark)
  1770. il_wake_queue(il, txq);
  1771. }
  1772. if (qc && likely(sta_id != IL_INVALID_STATION))
  1773. il4965_txq_check_empty(il, sta_id, tid, txq_id);
  1774. il4965_check_abort_status(il, tx_resp->frame_count, status);
  1775. spin_unlock_irqrestore(&il->sta_lock, flags);
  1776. }
  1777. /* Set up 4965-specific Rx frame reply handlers */
  1778. static void
  1779. il4965_handler_setup(struct il_priv *il)
  1780. {
  1781. /* Legacy Rx frames */
  1782. il->handlers[N_RX] = il4965_hdl_rx;
  1783. /* Tx response */
  1784. il->handlers[C_TX] = il4965_hdl_tx;
  1785. }
  1786. static struct il_hcmd_ops il4965_hcmd = {
  1787. .rxon_assoc = il4965_send_rxon_assoc,
  1788. .commit_rxon = il4965_commit_rxon,
  1789. .set_rxon_chain = il4965_set_rxon_chain,
  1790. };
  1791. static void
  1792. il4965_post_scan(struct il_priv *il)
  1793. {
  1794. /*
  1795. * Since setting the RXON may have been deferred while
  1796. * performing the scan, fire one off if needed
  1797. */
  1798. if (memcmp(&il->staging, &il->active, sizeof(il->staging)))
  1799. il_commit_rxon(il);
  1800. }
  1801. static void
  1802. il4965_post_associate(struct il_priv *il)
  1803. {
  1804. struct ieee80211_vif *vif = il->vif;
  1805. struct ieee80211_conf *conf = NULL;
  1806. int ret = 0;
  1807. if (!vif || !il->is_open)
  1808. return;
  1809. if (test_bit(S_EXIT_PENDING, &il->status))
  1810. return;
  1811. il_scan_cancel_timeout(il, 200);
  1812. conf = &il->hw->conf;
  1813. il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  1814. il_commit_rxon(il);
  1815. ret = il_send_rxon_timing(il);
  1816. if (ret)
  1817. IL_WARN("RXON timing - " "Attempting to continue.\n");
  1818. il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
  1819. il_set_rxon_ht(il, &il->current_ht_config);
  1820. if (il->ops->hcmd->set_rxon_chain)
  1821. il->ops->hcmd->set_rxon_chain(il);
  1822. il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
  1823. D_ASSOC("assoc id %d beacon interval %d\n", vif->bss_conf.aid,
  1824. vif->bss_conf.beacon_int);
  1825. if (vif->bss_conf.use_short_preamble)
  1826. il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
  1827. else
  1828. il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
  1829. if (il->staging.flags & RXON_FLG_BAND_24G_MSK) {
  1830. if (vif->bss_conf.use_short_slot)
  1831. il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
  1832. else
  1833. il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
  1834. }
  1835. il_commit_rxon(il);
  1836. D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid,
  1837. il->active.bssid_addr);
  1838. switch (vif->type) {
  1839. case NL80211_IFTYPE_STATION:
  1840. break;
  1841. case NL80211_IFTYPE_ADHOC:
  1842. il4965_send_beacon_cmd(il);
  1843. break;
  1844. default:
  1845. IL_ERR("%s Should not be called in %d mode\n", __func__,
  1846. vif->type);
  1847. break;
  1848. }
  1849. /* the chain noise calibration will enabled PM upon completion
  1850. * If chain noise has already been run, then we need to enable
  1851. * power management here */
  1852. if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE)
  1853. il_power_update_mode(il, false);
  1854. /* Enable Rx differential gain and sensitivity calibrations */
  1855. il4965_chain_noise_reset(il);
  1856. il->start_calib = 1;
  1857. }
  1858. static void
  1859. il4965_config_ap(struct il_priv *il)
  1860. {
  1861. struct ieee80211_vif *vif = il->vif;
  1862. int ret = 0;
  1863. lockdep_assert_held(&il->mutex);
  1864. if (test_bit(S_EXIT_PENDING, &il->status))
  1865. return;
  1866. /* The following should be done only at AP bring up */
  1867. if (!il_is_associated(il)) {
  1868. /* RXON - unassoc (to set timing command) */
  1869. il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  1870. il_commit_rxon(il);
  1871. /* RXON Timing */
  1872. ret = il_send_rxon_timing(il);
  1873. if (ret)
  1874. IL_WARN("RXON timing failed - "
  1875. "Attempting to continue.\n");
  1876. /* AP has all antennas */
  1877. il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant;
  1878. il_set_rxon_ht(il, &il->current_ht_config);
  1879. if (il->ops->hcmd->set_rxon_chain)
  1880. il->ops->hcmd->set_rxon_chain(il);
  1881. il->staging.assoc_id = 0;
  1882. if (vif->bss_conf.use_short_preamble)
  1883. il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
  1884. else
  1885. il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
  1886. if (il->staging.flags & RXON_FLG_BAND_24G_MSK) {
  1887. if (vif->bss_conf.use_short_slot)
  1888. il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
  1889. else
  1890. il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
  1891. }
  1892. /* need to send beacon cmd before committing assoc RXON! */
  1893. il4965_send_beacon_cmd(il);
  1894. /* restore RXON assoc */
  1895. il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
  1896. il_commit_rxon(il);
  1897. }
  1898. il4965_send_beacon_cmd(il);
  1899. }
  1900. static struct il_hcmd_utils_ops il4965_hcmd_utils = {
  1901. .get_hcmd_size = il4965_get_hcmd_size,
  1902. .build_addsta_hcmd = il4965_build_addsta_hcmd,
  1903. .request_scan = il4965_request_scan,
  1904. .post_scan = il4965_post_scan,
  1905. };
  1906. static struct il_lib_ops il4965_lib = {
  1907. .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl,
  1908. .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd,
  1909. .txq_free_tfd = il4965_hw_txq_free_tfd,
  1910. .txq_init = il4965_hw_tx_queue_init,
  1911. .handler_setup = il4965_handler_setup,
  1912. .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr,
  1913. .init_alive_start = il4965_init_alive_start,
  1914. .load_ucode = il4965_load_bsm,
  1915. .dump_nic_error_log = il4965_dump_nic_error_log,
  1916. .dump_fh = il4965_dump_fh,
  1917. .set_channel_switch = il4965_hw_channel_switch,
  1918. .apm_ops = {
  1919. .init = il_apm_init,
  1920. .config = il4965_nic_config,
  1921. },
  1922. .eeprom_ops = {
  1923. .regulatory_bands = {
  1924. EEPROM_REGULATORY_BAND_1_CHANNELS,
  1925. EEPROM_REGULATORY_BAND_2_CHANNELS,
  1926. EEPROM_REGULATORY_BAND_3_CHANNELS,
  1927. EEPROM_REGULATORY_BAND_4_CHANNELS,
  1928. EEPROM_REGULATORY_BAND_5_CHANNELS,
  1929. EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS,
  1930. EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS},
  1931. .acquire_semaphore = il4965_eeprom_acquire_semaphore,
  1932. .release_semaphore = il4965_eeprom_release_semaphore,
  1933. },
  1934. .send_tx_power = il4965_send_tx_power,
  1935. .update_chain_flags = il4965_update_chain_flags,
  1936. .temp_ops = {
  1937. .temperature = il4965_temperature_calib,
  1938. },
  1939. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1940. .debugfs_ops = {
  1941. .rx_stats_read = il4965_ucode_rx_stats_read,
  1942. .tx_stats_read = il4965_ucode_tx_stats_read,
  1943. .general_stats_read = il4965_ucode_general_stats_read,
  1944. },
  1945. #endif
  1946. };
  1947. static const struct il_legacy_ops il4965_legacy_ops = {
  1948. .post_associate = il4965_post_associate,
  1949. .config_ap = il4965_config_ap,
  1950. .manage_ibss_station = il4965_manage_ibss_station,
  1951. .update_bcast_stations = il4965_update_bcast_stations,
  1952. };
  1953. const struct il_ops il4965_ops = {
  1954. .lib = &il4965_lib,
  1955. .hcmd = &il4965_hcmd,
  1956. .utils = &il4965_hcmd_utils,
  1957. .led = &il4965_led_ops,
  1958. .legacy = &il4965_legacy_ops,
  1959. };
  1960. struct il_cfg il4965_cfg = {
  1961. .name = "Intel(R) Wireless WiFi Link 4965AGN",
  1962. .fw_name_pre = IL4965_FW_PRE,
  1963. .ucode_api_max = IL4965_UCODE_API_MAX,
  1964. .ucode_api_min = IL4965_UCODE_API_MIN,
  1965. .sku = IL_SKU_A | IL_SKU_G | IL_SKU_N,
  1966. .valid_tx_ant = ANT_AB,
  1967. .valid_rx_ant = ANT_ABC,
  1968. .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
  1969. .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
  1970. .mod_params = &il4965_mod_params,
  1971. .led_mode = IL_LED_BLINK,
  1972. /*
  1973. * Force use of chains B and C for scan RX on 5 GHz band
  1974. * because the device has off-channel reception on chain A.
  1975. */
  1976. .scan_rx_antennas[IEEE80211_BAND_5GHZ] = ANT_BC,
  1977. .eeprom_size = IL4965_EEPROM_IMG_SIZE,
  1978. .num_of_queues = IL49_NUM_QUEUES,
  1979. .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES,
  1980. .pll_cfg_val = 0,
  1981. .set_l0s = true,
  1982. .use_bsm = true,
  1983. .led_compensation = 61,
  1984. .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS,
  1985. .wd_timeout = IL_DEF_WD_TIMEOUT,
  1986. .temperature_kelvin = true,
  1987. .ucode_tracing = true,
  1988. .sensitivity_calib_by_driver = true,
  1989. .chain_noise_calib_by_driver = true,
  1990. };
  1991. /* Module firmware */
  1992. MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX));