iwl-5000.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007-2008 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 Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  23. *
  24. *****************************************************************************/
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/version.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/skbuff.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/wireless.h>
  35. #include <net/mac80211.h>
  36. #include <linux/etherdevice.h>
  37. #include <asm/unaligned.h>
  38. #include "iwl-eeprom.h"
  39. #include "iwl-dev.h"
  40. #include "iwl-core.h"
  41. #include "iwl-io.h"
  42. #include "iwl-sta.h"
  43. #include "iwl-helpers.h"
  44. #include "iwl-5000-hw.h"
  45. #define IWL5000_UCODE_API "-1"
  46. static const u16 iwl5000_default_queue_to_tx_fifo[] = {
  47. IWL_TX_FIFO_AC3,
  48. IWL_TX_FIFO_AC2,
  49. IWL_TX_FIFO_AC1,
  50. IWL_TX_FIFO_AC0,
  51. IWL50_CMD_FIFO_NUM,
  52. IWL_TX_FIFO_HCCA_1,
  53. IWL_TX_FIFO_HCCA_2
  54. };
  55. /* FIXME: same implementation as 4965 */
  56. static int iwl5000_apm_stop_master(struct iwl_priv *priv)
  57. {
  58. int ret = 0;
  59. unsigned long flags;
  60. spin_lock_irqsave(&priv->lock, flags);
  61. /* set stop master bit */
  62. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
  63. ret = iwl_poll_bit(priv, CSR_RESET,
  64. CSR_RESET_REG_FLAG_MASTER_DISABLED,
  65. CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
  66. if (ret < 0)
  67. goto out;
  68. out:
  69. spin_unlock_irqrestore(&priv->lock, flags);
  70. IWL_DEBUG_INFO("stop master\n");
  71. return ret;
  72. }
  73. static int iwl5000_apm_init(struct iwl_priv *priv)
  74. {
  75. int ret = 0;
  76. iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
  77. CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
  78. /* disable L0s without affecting L1 :don't wait for ICH L0s bug W/A) */
  79. iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
  80. CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
  81. iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
  82. /* set "initialization complete" bit to move adapter
  83. * D0U* --> D0A* state */
  84. iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  85. /* wait for clock stabilization */
  86. ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
  87. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
  88. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
  89. if (ret < 0) {
  90. IWL_DEBUG_INFO("Failed to init the card\n");
  91. return ret;
  92. }
  93. ret = iwl_grab_nic_access(priv);
  94. if (ret)
  95. return ret;
  96. /* enable DMA */
  97. iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
  98. udelay(20);
  99. /* disable L1-Active */
  100. iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
  101. APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
  102. iwl_release_nic_access(priv);
  103. return ret;
  104. }
  105. /* FIXME: this is indentical to 4965 */
  106. static void iwl5000_apm_stop(struct iwl_priv *priv)
  107. {
  108. unsigned long flags;
  109. iwl5000_apm_stop_master(priv);
  110. spin_lock_irqsave(&priv->lock, flags);
  111. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
  112. udelay(10);
  113. iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  114. spin_unlock_irqrestore(&priv->lock, flags);
  115. }
  116. static int iwl5000_apm_reset(struct iwl_priv *priv)
  117. {
  118. int ret = 0;
  119. unsigned long flags;
  120. iwl5000_apm_stop_master(priv);
  121. spin_lock_irqsave(&priv->lock, flags);
  122. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
  123. udelay(10);
  124. /* FIXME: put here L1A -L0S w/a */
  125. iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
  126. /* set "initialization complete" bit to move adapter
  127. * D0U* --> D0A* state */
  128. iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  129. /* wait for clock stabilization */
  130. ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
  131. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
  132. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
  133. if (ret < 0) {
  134. IWL_DEBUG_INFO("Failed to init the card\n");
  135. goto out;
  136. }
  137. ret = iwl_grab_nic_access(priv);
  138. if (ret)
  139. goto out;
  140. /* enable DMA */
  141. iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
  142. udelay(20);
  143. /* disable L1-Active */
  144. iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
  145. APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
  146. iwl_release_nic_access(priv);
  147. out:
  148. spin_unlock_irqrestore(&priv->lock, flags);
  149. return ret;
  150. }
  151. static void iwl5000_nic_config(struct iwl_priv *priv)
  152. {
  153. unsigned long flags;
  154. u16 radio_cfg;
  155. u8 val_link;
  156. spin_lock_irqsave(&priv->lock, flags);
  157. pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link);
  158. /* L1 is enabled by BIOS */
  159. if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN)
  160. /* diable L0S disabled L1A enabled */
  161. iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
  162. else
  163. /* L0S enabled L1A disabled */
  164. iwl_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
  165. radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
  166. /* write radio config values to register */
  167. if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) < EEPROM_5000_RF_CFG_TYPE_MAX)
  168. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  169. EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
  170. EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
  171. EEPROM_RF_CFG_DASH_MSK(radio_cfg));
  172. /* set CSR_HW_CONFIG_REG for uCode use */
  173. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  174. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  175. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  176. spin_unlock_irqrestore(&priv->lock, flags);
  177. }
  178. /*
  179. * EEPROM
  180. */
  181. static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
  182. {
  183. u16 offset = 0;
  184. if ((address & INDIRECT_ADDRESS) == 0)
  185. return address;
  186. switch (address & INDIRECT_TYPE_MSK) {
  187. case INDIRECT_HOST:
  188. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_HOST);
  189. break;
  190. case INDIRECT_GENERAL:
  191. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_GENERAL);
  192. break;
  193. case INDIRECT_REGULATORY:
  194. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_REGULATORY);
  195. break;
  196. case INDIRECT_CALIBRATION:
  197. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_CALIBRATION);
  198. break;
  199. case INDIRECT_PROCESS_ADJST:
  200. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_PROCESS_ADJST);
  201. break;
  202. case INDIRECT_OTHERS:
  203. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_OTHERS);
  204. break;
  205. default:
  206. IWL_ERROR("illegal indirect type: 0x%X\n",
  207. address & INDIRECT_TYPE_MSK);
  208. break;
  209. }
  210. /* translate the offset from words to byte */
  211. return (address & ADDRESS_MSK) + (offset << 1);
  212. }
  213. static int iwl5000_eeprom_check_version(struct iwl_priv *priv)
  214. {
  215. u16 eeprom_ver;
  216. struct iwl_eeprom_calib_hdr {
  217. u8 version;
  218. u8 pa_type;
  219. u16 voltage;
  220. } *hdr;
  221. eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
  222. hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
  223. EEPROM_5000_CALIB_ALL);
  224. if (eeprom_ver < EEPROM_5000_EEPROM_VERSION ||
  225. hdr->version < EEPROM_5000_TX_POWER_VERSION)
  226. goto err;
  227. return 0;
  228. err:
  229. IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
  230. eeprom_ver, EEPROM_5000_EEPROM_VERSION,
  231. hdr->version, EEPROM_5000_TX_POWER_VERSION);
  232. return -EINVAL;
  233. }
  234. static void iwl5000_gain_computation(struct iwl_priv *priv,
  235. u32 average_noise[NUM_RX_CHAINS],
  236. u16 min_average_noise_antenna_i,
  237. u32 min_average_noise)
  238. {
  239. int i;
  240. s32 delta_g;
  241. struct iwl_chain_noise_data *data = &priv->chain_noise_data;
  242. /* Find Gain Code for the antennas B and C */
  243. for (i = 1; i < NUM_RX_CHAINS; i++) {
  244. if ((data->disconn_array[i])) {
  245. data->delta_gain_code[i] = 0;
  246. continue;
  247. }
  248. delta_g = (1000 * ((s32)average_noise[0] -
  249. (s32)average_noise[i])) / 1500;
  250. /* bound gain by 2 bits value max, 3rd bit is sign */
  251. data->delta_gain_code[i] =
  252. min(abs(delta_g), CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
  253. if (delta_g < 0)
  254. /* set negative sign */
  255. data->delta_gain_code[i] |= (1 << 2);
  256. }
  257. IWL_DEBUG_CALIB("Delta gains: ANT_B = %d ANT_C = %d\n",
  258. data->delta_gain_code[1], data->delta_gain_code[2]);
  259. if (!data->radio_write) {
  260. struct iwl5000_calibration_chain_noise_gain_cmd cmd;
  261. memset(&cmd, 0, sizeof(cmd));
  262. cmd.op_code = IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD;
  263. cmd.delta_gain_1 = data->delta_gain_code[1];
  264. cmd.delta_gain_2 = data->delta_gain_code[2];
  265. iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD,
  266. sizeof(cmd), &cmd, NULL);
  267. data->radio_write = 1;
  268. data->state = IWL_CHAIN_NOISE_CALIBRATED;
  269. }
  270. data->chain_noise_a = 0;
  271. data->chain_noise_b = 0;
  272. data->chain_noise_c = 0;
  273. data->chain_signal_a = 0;
  274. data->chain_signal_b = 0;
  275. data->chain_signal_c = 0;
  276. data->beacon_count = 0;
  277. }
  278. static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
  279. {
  280. struct iwl_chain_noise_data *data = &priv->chain_noise_data;
  281. if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
  282. struct iwl5000_calibration_chain_noise_reset_cmd cmd;
  283. memset(&cmd, 0, sizeof(cmd));
  284. cmd.op_code = IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD;
  285. if (iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
  286. sizeof(cmd), &cmd))
  287. IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n");
  288. data->state = IWL_CHAIN_NOISE_ACCUMULATE;
  289. IWL_DEBUG_CALIB("Run chain_noise_calibrate\n");
  290. }
  291. }
  292. static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
  293. .min_nrg_cck = 95,
  294. .max_nrg_cck = 0,
  295. .auto_corr_min_ofdm = 90,
  296. .auto_corr_min_ofdm_mrc = 170,
  297. .auto_corr_min_ofdm_x1 = 120,
  298. .auto_corr_min_ofdm_mrc_x1 = 240,
  299. .auto_corr_max_ofdm = 120,
  300. .auto_corr_max_ofdm_mrc = 210,
  301. .auto_corr_max_ofdm_x1 = 155,
  302. .auto_corr_max_ofdm_mrc_x1 = 290,
  303. .auto_corr_min_cck = 125,
  304. .auto_corr_max_cck = 200,
  305. .auto_corr_min_cck_mrc = 170,
  306. .auto_corr_max_cck_mrc = 400,
  307. .nrg_th_cck = 95,
  308. .nrg_th_ofdm = 95,
  309. };
  310. static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
  311. size_t offset)
  312. {
  313. u32 address = eeprom_indirect_address(priv, offset);
  314. BUG_ON(address >= priv->cfg->eeprom_size);
  315. return &priv->eeprom[address];
  316. }
  317. /*
  318. * Calibration
  319. */
  320. static int iwl5000_send_Xtal_calib(struct iwl_priv *priv)
  321. {
  322. u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
  323. struct iwl5000_calibration cal_cmd = {
  324. .op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD,
  325. .data = {
  326. (u8)xtal_calib[0],
  327. (u8)xtal_calib[1],
  328. }
  329. };
  330. return iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
  331. sizeof(cal_cmd), &cal_cmd);
  332. }
  333. static int iwl5000_send_calib_results(struct iwl_priv *priv)
  334. {
  335. int ret = 0;
  336. struct iwl_host_cmd hcmd = {
  337. .id = REPLY_PHY_CALIBRATION_CMD,
  338. .meta.flags = CMD_SIZE_HUGE,
  339. };
  340. if (priv->calib_results.lo_res) {
  341. hcmd.len = priv->calib_results.lo_res_len;
  342. hcmd.data = priv->calib_results.lo_res;
  343. ret = iwl_send_cmd_sync(priv, &hcmd);
  344. if (ret)
  345. goto err;
  346. }
  347. if (priv->calib_results.tx_iq_res) {
  348. hcmd.len = priv->calib_results.tx_iq_res_len;
  349. hcmd.data = priv->calib_results.tx_iq_res;
  350. ret = iwl_send_cmd_sync(priv, &hcmd);
  351. if (ret)
  352. goto err;
  353. }
  354. if (priv->calib_results.tx_iq_perd_res) {
  355. hcmd.len = priv->calib_results.tx_iq_perd_res_len;
  356. hcmd.data = priv->calib_results.tx_iq_perd_res;
  357. ret = iwl_send_cmd_sync(priv, &hcmd);
  358. if (ret)
  359. goto err;
  360. }
  361. return 0;
  362. err:
  363. IWL_ERROR("Error %d\n", ret);
  364. return ret;
  365. }
  366. static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
  367. {
  368. struct iwl5000_calib_cfg_cmd calib_cfg_cmd;
  369. struct iwl_host_cmd cmd = {
  370. .id = CALIBRATION_CFG_CMD,
  371. .len = sizeof(struct iwl5000_calib_cfg_cmd),
  372. .data = &calib_cfg_cmd,
  373. };
  374. memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd));
  375. calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
  376. calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL;
  377. calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
  378. calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL;
  379. return iwl_send_cmd(priv, &cmd);
  380. }
  381. static void iwl5000_rx_calib_result(struct iwl_priv *priv,
  382. struct iwl_rx_mem_buffer *rxb)
  383. {
  384. struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
  385. struct iwl5000_calib_hdr *hdr = (struct iwl5000_calib_hdr *)pkt->u.raw;
  386. int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK;
  387. iwl_free_calib_results(priv);
  388. /* reduce the size of the length field itself */
  389. len -= 4;
  390. switch (hdr->op_code) {
  391. case IWL5000_PHY_CALIBRATE_LO_CMD:
  392. priv->calib_results.lo_res = kzalloc(len, GFP_ATOMIC);
  393. priv->calib_results.lo_res_len = len;
  394. memcpy(priv->calib_results.lo_res, pkt->u.raw, len);
  395. break;
  396. case IWL5000_PHY_CALIBRATE_TX_IQ_CMD:
  397. priv->calib_results.tx_iq_res = kzalloc(len, GFP_ATOMIC);
  398. priv->calib_results.tx_iq_res_len = len;
  399. memcpy(priv->calib_results.tx_iq_res, pkt->u.raw, len);
  400. break;
  401. case IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD:
  402. priv->calib_results.tx_iq_perd_res = kzalloc(len, GFP_ATOMIC);
  403. priv->calib_results.tx_iq_perd_res_len = len;
  404. memcpy(priv->calib_results.tx_iq_perd_res, pkt->u.raw, len);
  405. break;
  406. default:
  407. IWL_ERROR("Unknown calibration notification %d\n",
  408. hdr->op_code);
  409. return;
  410. }
  411. }
  412. static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
  413. struct iwl_rx_mem_buffer *rxb)
  414. {
  415. IWL_DEBUG_INFO("Init. calibration is completed, restarting fw.\n");
  416. queue_work(priv->workqueue, &priv->restart);
  417. }
  418. /*
  419. * ucode
  420. */
  421. static int iwl5000_load_section(struct iwl_priv *priv,
  422. struct fw_desc *image,
  423. u32 dst_addr)
  424. {
  425. int ret = 0;
  426. unsigned long flags;
  427. dma_addr_t phy_addr = image->p_addr;
  428. u32 byte_cnt = image->len;
  429. spin_lock_irqsave(&priv->lock, flags);
  430. ret = iwl_grab_nic_access(priv);
  431. if (ret) {
  432. spin_unlock_irqrestore(&priv->lock, flags);
  433. return ret;
  434. }
  435. iwl_write_direct32(priv,
  436. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  437. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
  438. iwl_write_direct32(priv,
  439. FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
  440. iwl_write_direct32(priv,
  441. FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
  442. phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
  443. /* FIME: write the MSB of the phy_addr in CTRL1
  444. * iwl_write_direct32(priv,
  445. IWL_FH_TFDIB_CTRL1_REG(IWL_FH_SRVC_CHNL),
  446. ((phy_addr & MSB_MSK)
  447. << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_count);
  448. */
  449. iwl_write_direct32(priv,
  450. FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), byte_cnt);
  451. iwl_write_direct32(priv,
  452. FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
  453. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
  454. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
  455. FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
  456. iwl_write_direct32(priv,
  457. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  458. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  459. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL |
  460. FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
  461. iwl_release_nic_access(priv);
  462. spin_unlock_irqrestore(&priv->lock, flags);
  463. return 0;
  464. }
  465. static int iwl5000_load_given_ucode(struct iwl_priv *priv,
  466. struct fw_desc *inst_image,
  467. struct fw_desc *data_image)
  468. {
  469. int ret = 0;
  470. ret = iwl5000_load_section(
  471. priv, inst_image, RTC_INST_LOWER_BOUND);
  472. if (ret)
  473. return ret;
  474. IWL_DEBUG_INFO("INST uCode section being loaded...\n");
  475. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  476. priv->ucode_write_complete, 5 * HZ);
  477. if (ret == -ERESTARTSYS) {
  478. IWL_ERROR("Could not load the INST uCode section due "
  479. "to interrupt\n");
  480. return ret;
  481. }
  482. if (!ret) {
  483. IWL_ERROR("Could not load the INST uCode section\n");
  484. return -ETIMEDOUT;
  485. }
  486. priv->ucode_write_complete = 0;
  487. ret = iwl5000_load_section(
  488. priv, data_image, RTC_DATA_LOWER_BOUND);
  489. if (ret)
  490. return ret;
  491. IWL_DEBUG_INFO("DATA uCode section being loaded...\n");
  492. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  493. priv->ucode_write_complete, 5 * HZ);
  494. if (ret == -ERESTARTSYS) {
  495. IWL_ERROR("Could not load the INST uCode section due "
  496. "to interrupt\n");
  497. return ret;
  498. } else if (!ret) {
  499. IWL_ERROR("Could not load the DATA uCode section\n");
  500. return -ETIMEDOUT;
  501. } else
  502. ret = 0;
  503. priv->ucode_write_complete = 0;
  504. return ret;
  505. }
  506. static int iwl5000_load_ucode(struct iwl_priv *priv)
  507. {
  508. int ret = 0;
  509. /* check whether init ucode should be loaded, or rather runtime ucode */
  510. if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
  511. IWL_DEBUG_INFO("Init ucode found. Loading init ucode...\n");
  512. ret = iwl5000_load_given_ucode(priv,
  513. &priv->ucode_init, &priv->ucode_init_data);
  514. if (!ret) {
  515. IWL_DEBUG_INFO("Init ucode load complete.\n");
  516. priv->ucode_type = UCODE_INIT;
  517. }
  518. } else {
  519. IWL_DEBUG_INFO("Init ucode not found, or already loaded. "
  520. "Loading runtime ucode...\n");
  521. ret = iwl5000_load_given_ucode(priv,
  522. &priv->ucode_code, &priv->ucode_data);
  523. if (!ret) {
  524. IWL_DEBUG_INFO("Runtime ucode load complete.\n");
  525. priv->ucode_type = UCODE_RT;
  526. }
  527. }
  528. return ret;
  529. }
  530. static void iwl5000_init_alive_start(struct iwl_priv *priv)
  531. {
  532. int ret = 0;
  533. /* Check alive response for "valid" sign from uCode */
  534. if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
  535. /* We had an error bringing up the hardware, so take it
  536. * all the way back down so we can try again */
  537. IWL_DEBUG_INFO("Initialize Alive failed.\n");
  538. goto restart;
  539. }
  540. /* initialize uCode was loaded... verify inst image.
  541. * This is a paranoid check, because we would not have gotten the
  542. * "initialize" alive if code weren't properly loaded. */
  543. if (iwl_verify_ucode(priv)) {
  544. /* Runtime instruction load was bad;
  545. * take it all the way back down so we can try again */
  546. IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n");
  547. goto restart;
  548. }
  549. iwlcore_clear_stations_table(priv);
  550. ret = priv->cfg->ops->lib->alive_notify(priv);
  551. if (ret) {
  552. IWL_WARNING("Could not complete ALIVE transition: %d\n", ret);
  553. goto restart;
  554. }
  555. iwl5000_send_calib_cfg(priv);
  556. return;
  557. restart:
  558. /* real restart (first load init_ucode) */
  559. queue_work(priv->workqueue, &priv->restart);
  560. }
  561. static void iwl5000_set_wr_ptrs(struct iwl_priv *priv,
  562. int txq_id, u32 index)
  563. {
  564. iwl_write_direct32(priv, HBUS_TARG_WRPTR,
  565. (index & 0xff) | (txq_id << 8));
  566. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(txq_id), index);
  567. }
  568. static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
  569. struct iwl_tx_queue *txq,
  570. int tx_fifo_id, int scd_retry)
  571. {
  572. int txq_id = txq->q.id;
  573. int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0;
  574. iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  575. (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
  576. (tx_fifo_id << IWL50_SCD_QUEUE_STTS_REG_POS_TXF) |
  577. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_WSL) |
  578. IWL50_SCD_QUEUE_STTS_REG_MSK);
  579. txq->sched_retry = scd_retry;
  580. IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n",
  581. active ? "Activate" : "Deactivate",
  582. scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
  583. }
  584. static int iwl5000_send_wimax_coex(struct iwl_priv *priv)
  585. {
  586. struct iwl_wimax_coex_cmd coex_cmd;
  587. memset(&coex_cmd, 0, sizeof(coex_cmd));
  588. return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
  589. sizeof(coex_cmd), &coex_cmd);
  590. }
  591. static int iwl5000_alive_notify(struct iwl_priv *priv)
  592. {
  593. u32 a;
  594. int i = 0;
  595. unsigned long flags;
  596. int ret;
  597. spin_lock_irqsave(&priv->lock, flags);
  598. ret = iwl_grab_nic_access(priv);
  599. if (ret) {
  600. spin_unlock_irqrestore(&priv->lock, flags);
  601. return ret;
  602. }
  603. priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
  604. a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
  605. for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
  606. a += 4)
  607. iwl_write_targ_mem(priv, a, 0);
  608. for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
  609. a += 4)
  610. iwl_write_targ_mem(priv, a, 0);
  611. for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
  612. iwl_write_targ_mem(priv, a, 0);
  613. iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
  614. (priv->shared_phys +
  615. offsetof(struct iwl5000_shared, queues_byte_cnt_tbls)) >> 10);
  616. iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
  617. IWL50_SCD_QUEUECHAIN_SEL_ALL(
  618. priv->hw_params.max_txq_num));
  619. iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
  620. /* initiate the queues */
  621. for (i = 0; i < priv->hw_params.max_txq_num; i++) {
  622. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0);
  623. iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
  624. iwl_write_targ_mem(priv, priv->scd_base_addr +
  625. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
  626. iwl_write_targ_mem(priv, priv->scd_base_addr +
  627. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) +
  628. sizeof(u32),
  629. ((SCD_WIN_SIZE <<
  630. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  631. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  632. ((SCD_FRAME_LIMIT <<
  633. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  634. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  635. }
  636. iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK,
  637. IWL_MASK(0, priv->hw_params.max_txq_num));
  638. /* Activate all Tx DMA/FIFO channels */
  639. priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
  640. iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
  641. /* map qos queues to fifos one-to-one */
  642. for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
  643. int ac = iwl5000_default_queue_to_tx_fifo[i];
  644. iwl_txq_ctx_activate(priv, i);
  645. iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
  646. }
  647. /* TODO - need to initialize those FIFOs inside the loop above,
  648. * not only mark them as active */
  649. iwl_txq_ctx_activate(priv, 4);
  650. iwl_txq_ctx_activate(priv, 7);
  651. iwl_txq_ctx_activate(priv, 8);
  652. iwl_txq_ctx_activate(priv, 9);
  653. iwl_release_nic_access(priv);
  654. spin_unlock_irqrestore(&priv->lock, flags);
  655. iwl5000_send_wimax_coex(priv);
  656. iwl5000_send_Xtal_calib(priv);
  657. if (priv->ucode_type == UCODE_RT) {
  658. iwl5000_send_calib_results(priv);
  659. set_bit(STATUS_READY, &priv->status);
  660. priv->is_open = 1;
  661. }
  662. return 0;
  663. }
  664. static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  665. {
  666. if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) ||
  667. (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
  668. IWL_ERROR("invalid queues_num, should be between %d and %d\n",
  669. IWL_MIN_NUM_QUEUES, IWL50_NUM_QUEUES);
  670. return -EINVAL;
  671. }
  672. priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
  673. priv->hw_params.first_ampdu_q = IWL50_FIRST_AMPDU_QUEUE;
  674. priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto;
  675. priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
  676. priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
  677. if (priv->cfg->mod_params->amsdu_size_8K)
  678. priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_8K;
  679. else
  680. priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_4K;
  681. priv->hw_params.max_pkt_size = priv->hw_params.rx_buf_size - 256;
  682. priv->hw_params.max_stations = IWL5000_STATION_COUNT;
  683. priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
  684. priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
  685. priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
  686. priv->hw_params.max_bsm_size = BSM_SRAM_SIZE;
  687. priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) |
  688. BIT(IEEE80211_BAND_5GHZ);
  689. priv->hw_params.sens = &iwl5000_sensitivity;
  690. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  691. case CSR_HW_REV_TYPE_5100:
  692. case CSR_HW_REV_TYPE_5150:
  693. priv->hw_params.tx_chains_num = 1;
  694. priv->hw_params.rx_chains_num = 2;
  695. /* FIXME: move to ANT_A, ANT_B, ANT_C enum */
  696. priv->hw_params.valid_tx_ant = ANT_A;
  697. priv->hw_params.valid_rx_ant = ANT_AB;
  698. break;
  699. case CSR_HW_REV_TYPE_5300:
  700. case CSR_HW_REV_TYPE_5350:
  701. priv->hw_params.tx_chains_num = 3;
  702. priv->hw_params.rx_chains_num = 3;
  703. priv->hw_params.valid_tx_ant = ANT_ABC;
  704. priv->hw_params.valid_rx_ant = ANT_ABC;
  705. break;
  706. }
  707. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  708. case CSR_HW_REV_TYPE_5100:
  709. case CSR_HW_REV_TYPE_5300:
  710. /* 5X00 wants in Celsius */
  711. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  712. break;
  713. case CSR_HW_REV_TYPE_5150:
  714. case CSR_HW_REV_TYPE_5350:
  715. /* 5X50 wants in Kelvin */
  716. priv->hw_params.ct_kill_threshold =
  717. CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
  718. break;
  719. }
  720. return 0;
  721. }
  722. static int iwl5000_alloc_shared_mem(struct iwl_priv *priv)
  723. {
  724. priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
  725. sizeof(struct iwl5000_shared),
  726. &priv->shared_phys);
  727. if (!priv->shared_virt)
  728. return -ENOMEM;
  729. memset(priv->shared_virt, 0, sizeof(struct iwl5000_shared));
  730. priv->rb_closed_offset = offsetof(struct iwl5000_shared, rb_closed);
  731. return 0;
  732. }
  733. static void iwl5000_free_shared_mem(struct iwl_priv *priv)
  734. {
  735. if (priv->shared_virt)
  736. pci_free_consistent(priv->pci_dev,
  737. sizeof(struct iwl5000_shared),
  738. priv->shared_virt,
  739. priv->shared_phys);
  740. }
  741. static int iwl5000_shared_mem_rx_idx(struct iwl_priv *priv)
  742. {
  743. struct iwl5000_shared *s = priv->shared_virt;
  744. return le32_to_cpu(s->rb_closed) & 0xFFF;
  745. }
  746. /**
  747. * iwl5000_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  748. */
  749. static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  750. struct iwl_tx_queue *txq,
  751. u16 byte_cnt)
  752. {
  753. struct iwl5000_shared *shared_data = priv->shared_virt;
  754. int txq_id = txq->q.id;
  755. u8 sec_ctl = 0;
  756. u8 sta = 0;
  757. int len;
  758. len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
  759. if (txq_id != IWL_CMD_QUEUE_NUM) {
  760. sta = txq->cmd[txq->q.write_ptr].cmd.tx.sta_id;
  761. sec_ctl = txq->cmd[txq->q.write_ptr].cmd.tx.sec_ctl;
  762. switch (sec_ctl & TX_CMD_SEC_MSK) {
  763. case TX_CMD_SEC_CCM:
  764. len += CCMP_MIC_LEN;
  765. break;
  766. case TX_CMD_SEC_TKIP:
  767. len += TKIP_ICV_LEN;
  768. break;
  769. case TX_CMD_SEC_WEP:
  770. len += WEP_IV_LEN + WEP_ICV_LEN;
  771. break;
  772. }
  773. }
  774. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  775. tfd_offset[txq->q.write_ptr], byte_cnt, len);
  776. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  777. tfd_offset[txq->q.write_ptr], sta_id, sta);
  778. if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) {
  779. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  780. tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr],
  781. byte_cnt, len);
  782. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  783. tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr],
  784. sta_id, sta);
  785. }
  786. }
  787. static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  788. struct iwl_tx_queue *txq)
  789. {
  790. int txq_id = txq->q.id;
  791. struct iwl5000_shared *shared_data = priv->shared_virt;
  792. u8 sta = 0;
  793. if (txq_id != IWL_CMD_QUEUE_NUM)
  794. sta = txq->cmd[txq->q.read_ptr].cmd.tx.sta_id;
  795. shared_data->queues_byte_cnt_tbls[txq_id].tfd_offset[txq->q.read_ptr].
  796. val = cpu_to_le16(1 | (sta << 12));
  797. if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) {
  798. shared_data->queues_byte_cnt_tbls[txq_id].
  799. tfd_offset[IWL50_QUEUE_SIZE + txq->q.read_ptr].
  800. val = cpu_to_le16(1 | (sta << 12));
  801. }
  802. }
  803. static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
  804. u16 txq_id)
  805. {
  806. u32 tbl_dw_addr;
  807. u32 tbl_dw;
  808. u16 scd_q2ratid;
  809. scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
  810. tbl_dw_addr = priv->scd_base_addr +
  811. IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
  812. tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
  813. if (txq_id & 0x1)
  814. tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
  815. else
  816. tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
  817. iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
  818. return 0;
  819. }
  820. static void iwl5000_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
  821. {
  822. /* Simply stop the queue, but don't change any configuration;
  823. * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
  824. iwl_write_prph(priv,
  825. IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  826. (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
  827. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
  828. }
  829. static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  830. int tx_fifo, int sta_id, int tid, u16 ssn_idx)
  831. {
  832. unsigned long flags;
  833. int ret;
  834. u16 ra_tid;
  835. if (IWL50_FIRST_AMPDU_QUEUE > txq_id)
  836. IWL_WARNING("queue number too small: %d, must be > %d\n",
  837. txq_id, IWL50_FIRST_AMPDU_QUEUE);
  838. ra_tid = BUILD_RAxTID(sta_id, tid);
  839. /* Modify device's station table to Tx this TID */
  840. iwl_sta_modify_enable_tid_tx(priv, sta_id, tid);
  841. spin_lock_irqsave(&priv->lock, flags);
  842. ret = iwl_grab_nic_access(priv);
  843. if (ret) {
  844. spin_unlock_irqrestore(&priv->lock, flags);
  845. return ret;
  846. }
  847. /* Stop this Tx queue before configuring it */
  848. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  849. /* Map receiver-address / traffic-ID to this queue */
  850. iwl5000_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
  851. /* Set this queue as a chain-building queue */
  852. iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id));
  853. /* enable aggregations for the queue */
  854. iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id));
  855. /* Place first TFD at index corresponding to start sequence number.
  856. * Assumes that ssn_idx is valid (!= 0xFFF) */
  857. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  858. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  859. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  860. /* Set up Tx window size and frame limit for this queue */
  861. iwl_write_targ_mem(priv, priv->scd_base_addr +
  862. IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
  863. sizeof(u32),
  864. ((SCD_WIN_SIZE <<
  865. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  866. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  867. ((SCD_FRAME_LIMIT <<
  868. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  869. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  870. iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  871. /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
  872. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
  873. iwl_release_nic_access(priv);
  874. spin_unlock_irqrestore(&priv->lock, flags);
  875. return 0;
  876. }
  877. static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  878. u16 ssn_idx, u8 tx_fifo)
  879. {
  880. int ret;
  881. if (IWL50_FIRST_AMPDU_QUEUE > txq_id) {
  882. IWL_WARNING("queue number too small: %d, must be > %d\n",
  883. txq_id, IWL50_FIRST_AMPDU_QUEUE);
  884. return -EINVAL;
  885. }
  886. ret = iwl_grab_nic_access(priv);
  887. if (ret)
  888. return ret;
  889. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  890. iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id));
  891. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  892. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  893. /* supposes that ssn_idx is valid (!= 0xFFF) */
  894. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  895. iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  896. iwl_txq_ctx_deactivate(priv, txq_id);
  897. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
  898. iwl_release_nic_access(priv);
  899. return 0;
  900. }
  901. static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
  902. {
  903. u16 size = (u16)sizeof(struct iwl_addsta_cmd);
  904. memcpy(data, cmd, size);
  905. return size;
  906. }
  907. /*
  908. * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask
  909. * must be called under priv->lock and mac access
  910. */
  911. static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask)
  912. {
  913. iwl_write_prph(priv, IWL50_SCD_TXFACT, mask);
  914. }
  915. static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
  916. {
  917. return le32_to_cpup((__le32*)&tx_resp->status +
  918. tx_resp->frame_count) & MAX_SN;
  919. }
  920. static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
  921. struct iwl_ht_agg *agg,
  922. struct iwl5000_tx_resp *tx_resp,
  923. int txq_id, u16 start_idx)
  924. {
  925. u16 status;
  926. struct agg_tx_status *frame_status = &tx_resp->status;
  927. struct ieee80211_tx_info *info = NULL;
  928. struct ieee80211_hdr *hdr = NULL;
  929. u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
  930. int i, sh, idx;
  931. u16 seq;
  932. if (agg->wait_for_ba)
  933. IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
  934. agg->frame_count = tx_resp->frame_count;
  935. agg->start_idx = start_idx;
  936. agg->rate_n_flags = rate_n_flags;
  937. agg->bitmap = 0;
  938. /* # frames attempted by Tx command */
  939. if (agg->frame_count == 1) {
  940. /* Only one frame was attempted; no block-ack will arrive */
  941. status = le16_to_cpu(frame_status[0].status);
  942. idx = start_idx;
  943. /* FIXME: code repetition */
  944. IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
  945. agg->frame_count, agg->start_idx, idx);
  946. info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
  947. info->status.retry_count = tx_resp->failure_frame;
  948. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  949. info->flags |= iwl_is_tx_success(status)?
  950. IEEE80211_TX_STAT_ACK : 0;
  951. iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
  952. /* FIXME: code repetition end */
  953. IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
  954. status & 0xff, tx_resp->failure_frame);
  955. IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
  956. agg->wait_for_ba = 0;
  957. } else {
  958. /* Two or more frames were attempted; expect block-ack */
  959. u64 bitmap = 0;
  960. int start = agg->start_idx;
  961. /* Construct bit-map of pending frames within Tx window */
  962. for (i = 0; i < agg->frame_count; i++) {
  963. u16 sc;
  964. status = le16_to_cpu(frame_status[i].status);
  965. seq = le16_to_cpu(frame_status[i].sequence);
  966. idx = SEQ_TO_INDEX(seq);
  967. txq_id = SEQ_TO_QUEUE(seq);
  968. if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
  969. AGG_TX_STATE_ABORT_MSK))
  970. continue;
  971. IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
  972. agg->frame_count, txq_id, idx);
  973. hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
  974. sc = le16_to_cpu(hdr->seq_ctrl);
  975. if (idx != (SEQ_TO_SN(sc) & 0xff)) {
  976. IWL_ERROR("BUG_ON idx doesn't match seq control"
  977. " idx=%d, seq_idx=%d, seq=%d\n",
  978. idx, SEQ_TO_SN(sc),
  979. hdr->seq_ctrl);
  980. return -1;
  981. }
  982. IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n",
  983. i, idx, SEQ_TO_SN(sc));
  984. sh = idx - start;
  985. if (sh > 64) {
  986. sh = (start - idx) + 0xff;
  987. bitmap = bitmap << sh;
  988. sh = 0;
  989. start = idx;
  990. } else if (sh < -64)
  991. sh = 0xff - (start - idx);
  992. else if (sh < 0) {
  993. sh = start - idx;
  994. start = idx;
  995. bitmap = bitmap << sh;
  996. sh = 0;
  997. }
  998. bitmap |= (1 << sh);
  999. IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n",
  1000. start, (u32)(bitmap & 0xFFFFFFFF));
  1001. }
  1002. agg->bitmap = bitmap;
  1003. agg->start_idx = start;
  1004. IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
  1005. agg->frame_count, agg->start_idx,
  1006. (unsigned long long)agg->bitmap);
  1007. if (bitmap)
  1008. agg->wait_for_ba = 1;
  1009. }
  1010. return 0;
  1011. }
  1012. static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
  1013. struct iwl_rx_mem_buffer *rxb)
  1014. {
  1015. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  1016. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  1017. int txq_id = SEQ_TO_QUEUE(sequence);
  1018. int index = SEQ_TO_INDEX(sequence);
  1019. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  1020. struct ieee80211_tx_info *info;
  1021. struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  1022. u32 status = le16_to_cpu(tx_resp->status.status);
  1023. int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
  1024. u16 fc;
  1025. struct ieee80211_hdr *hdr;
  1026. u8 *qc = NULL;
  1027. if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
  1028. IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
  1029. "is out of range [0-%d] %d %d\n", txq_id,
  1030. index, txq->q.n_bd, txq->q.write_ptr,
  1031. txq->q.read_ptr);
  1032. return;
  1033. }
  1034. info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
  1035. memset(&info->status, 0, sizeof(info->status));
  1036. hdr = iwl_tx_queue_get_hdr(priv, txq_id, index);
  1037. fc = le16_to_cpu(hdr->frame_control);
  1038. if (ieee80211_is_qos_data(fc)) {
  1039. qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc));
  1040. tid = qc[0] & 0xf;
  1041. }
  1042. sta_id = iwl_get_ra_sta_id(priv, hdr);
  1043. if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) {
  1044. IWL_ERROR("Station not known\n");
  1045. return;
  1046. }
  1047. if (txq->sched_retry) {
  1048. const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
  1049. struct iwl_ht_agg *agg = NULL;
  1050. if (!qc)
  1051. return;
  1052. agg = &priv->stations[sta_id].tid[tid].agg;
  1053. iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
  1054. if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) {
  1055. /* TODO: send BAR */
  1056. }
  1057. if (txq->q.read_ptr != (scd_ssn & 0xff)) {
  1058. int freed, ampdu_q;
  1059. index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
  1060. IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
  1061. "%d index %d\n", scd_ssn , index);
  1062. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1063. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1064. if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
  1065. txq_id >= 0 && priv->mac80211_registered &&
  1066. agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) {
  1067. /* calculate mac80211 ampdu sw queue to wake */
  1068. ampdu_q = txq_id - IWL50_FIRST_AMPDU_QUEUE +
  1069. priv->hw->queues;
  1070. if (agg->state == IWL_AGG_OFF)
  1071. ieee80211_wake_queue(priv->hw, txq_id);
  1072. else
  1073. ieee80211_wake_queue(priv->hw, ampdu_q);
  1074. }
  1075. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1076. }
  1077. } else {
  1078. info->status.retry_count = tx_resp->failure_frame;
  1079. info->flags =
  1080. iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
  1081. iwl_hwrate_to_tx_control(priv,
  1082. le32_to_cpu(tx_resp->rate_n_flags),
  1083. info);
  1084. IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags "
  1085. "0x%x retries %d\n", txq_id,
  1086. iwl_get_tx_fail_reason(status),
  1087. status, le32_to_cpu(tx_resp->rate_n_flags),
  1088. tx_resp->failure_frame);
  1089. IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
  1090. if (index != -1) {
  1091. int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1092. if (tid != MAX_TID_COUNT)
  1093. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1094. if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
  1095. (txq_id >= 0) && priv->mac80211_registered)
  1096. ieee80211_wake_queue(priv->hw, txq_id);
  1097. if (tid != MAX_TID_COUNT)
  1098. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1099. }
  1100. }
  1101. if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
  1102. IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
  1103. }
  1104. /* Currently 5000 is the supperset of everything */
  1105. static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
  1106. {
  1107. return len;
  1108. }
  1109. static void iwl5000_setup_deferred_work(struct iwl_priv *priv)
  1110. {
  1111. /* in 5000 the tx power calibration is done in uCode */
  1112. priv->disable_tx_power_cal = 1;
  1113. }
  1114. static void iwl5000_rx_handler_setup(struct iwl_priv *priv)
  1115. {
  1116. /* init calibration handlers */
  1117. priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
  1118. iwl5000_rx_calib_result;
  1119. priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] =
  1120. iwl5000_rx_calib_complete;
  1121. priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx;
  1122. }
  1123. static int iwl5000_hw_valid_rtc_data_addr(u32 addr)
  1124. {
  1125. return (addr >= RTC_DATA_LOWER_BOUND) &&
  1126. (addr < IWL50_RTC_DATA_UPPER_BOUND);
  1127. }
  1128. static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
  1129. {
  1130. int ret = 0;
  1131. struct iwl5000_rxon_assoc_cmd rxon_assoc;
  1132. const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
  1133. const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
  1134. if ((rxon1->flags == rxon2->flags) &&
  1135. (rxon1->filter_flags == rxon2->filter_flags) &&
  1136. (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
  1137. (rxon1->ofdm_ht_single_stream_basic_rates ==
  1138. rxon2->ofdm_ht_single_stream_basic_rates) &&
  1139. (rxon1->ofdm_ht_dual_stream_basic_rates ==
  1140. rxon2->ofdm_ht_dual_stream_basic_rates) &&
  1141. (rxon1->ofdm_ht_triple_stream_basic_rates ==
  1142. rxon2->ofdm_ht_triple_stream_basic_rates) &&
  1143. (rxon1->acquisition_data == rxon2->acquisition_data) &&
  1144. (rxon1->rx_chain == rxon2->rx_chain) &&
  1145. (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
  1146. IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n");
  1147. return 0;
  1148. }
  1149. rxon_assoc.flags = priv->staging_rxon.flags;
  1150. rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
  1151. rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
  1152. rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
  1153. rxon_assoc.reserved1 = 0;
  1154. rxon_assoc.reserved2 = 0;
  1155. rxon_assoc.reserved3 = 0;
  1156. rxon_assoc.ofdm_ht_single_stream_basic_rates =
  1157. priv->staging_rxon.ofdm_ht_single_stream_basic_rates;
  1158. rxon_assoc.ofdm_ht_dual_stream_basic_rates =
  1159. priv->staging_rxon.ofdm_ht_dual_stream_basic_rates;
  1160. rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain;
  1161. rxon_assoc.ofdm_ht_triple_stream_basic_rates =
  1162. priv->staging_rxon.ofdm_ht_triple_stream_basic_rates;
  1163. rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data;
  1164. ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
  1165. sizeof(rxon_assoc), &rxon_assoc, NULL);
  1166. if (ret)
  1167. return ret;
  1168. return ret;
  1169. }
  1170. static int iwl5000_send_tx_power(struct iwl_priv *priv)
  1171. {
  1172. struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
  1173. /* half dBm need to multiply */
  1174. tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
  1175. tx_power_cmd.flags = 0;
  1176. tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
  1177. return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD,
  1178. sizeof(tx_power_cmd), &tx_power_cmd,
  1179. NULL);
  1180. }
  1181. static struct iwl_hcmd_ops iwl5000_hcmd = {
  1182. .rxon_assoc = iwl5000_send_rxon_assoc,
  1183. };
  1184. static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
  1185. .get_hcmd_size = iwl5000_get_hcmd_size,
  1186. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  1187. .gain_computation = iwl5000_gain_computation,
  1188. .chain_noise_reset = iwl5000_chain_noise_reset,
  1189. };
  1190. static struct iwl_lib_ops iwl5000_lib = {
  1191. .set_hw_params = iwl5000_hw_set_hw_params,
  1192. .alloc_shared_mem = iwl5000_alloc_shared_mem,
  1193. .free_shared_mem = iwl5000_free_shared_mem,
  1194. .shared_mem_rx_idx = iwl5000_shared_mem_rx_idx,
  1195. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  1196. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  1197. .txq_set_sched = iwl5000_txq_set_sched,
  1198. .txq_agg_enable = iwl5000_txq_agg_enable,
  1199. .txq_agg_disable = iwl5000_txq_agg_disable,
  1200. .rx_handler_setup = iwl5000_rx_handler_setup,
  1201. .setup_deferred_work = iwl5000_setup_deferred_work,
  1202. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  1203. .load_ucode = iwl5000_load_ucode,
  1204. .init_alive_start = iwl5000_init_alive_start,
  1205. .alive_notify = iwl5000_alive_notify,
  1206. .send_tx_power = iwl5000_send_tx_power,
  1207. .apm_ops = {
  1208. .init = iwl5000_apm_init,
  1209. .reset = iwl5000_apm_reset,
  1210. .stop = iwl5000_apm_stop,
  1211. .config = iwl5000_nic_config,
  1212. .set_pwr_src = iwl4965_set_pwr_src,
  1213. },
  1214. .eeprom_ops = {
  1215. .regulatory_bands = {
  1216. EEPROM_5000_REG_BAND_1_CHANNELS,
  1217. EEPROM_5000_REG_BAND_2_CHANNELS,
  1218. EEPROM_5000_REG_BAND_3_CHANNELS,
  1219. EEPROM_5000_REG_BAND_4_CHANNELS,
  1220. EEPROM_5000_REG_BAND_5_CHANNELS,
  1221. EEPROM_5000_REG_BAND_24_FAT_CHANNELS,
  1222. EEPROM_5000_REG_BAND_52_FAT_CHANNELS
  1223. },
  1224. .verify_signature = iwlcore_eeprom_verify_signature,
  1225. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  1226. .release_semaphore = iwlcore_eeprom_release_semaphore,
  1227. .check_version = iwl5000_eeprom_check_version,
  1228. .query_addr = iwl5000_eeprom_query_addr,
  1229. },
  1230. };
  1231. static struct iwl_ops iwl5000_ops = {
  1232. .lib = &iwl5000_lib,
  1233. .hcmd = &iwl5000_hcmd,
  1234. .utils = &iwl5000_hcmd_utils,
  1235. };
  1236. static struct iwl_mod_params iwl50_mod_params = {
  1237. .num_of_queues = IWL50_NUM_QUEUES,
  1238. .enable_qos = 1,
  1239. .amsdu_size_8K = 1,
  1240. .restart_fw = 1,
  1241. /* the rest are 0 by default */
  1242. };
  1243. struct iwl_cfg iwl5300_agn_cfg = {
  1244. .name = "5300AGN",
  1245. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1246. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1247. .ops = &iwl5000_ops,
  1248. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1249. .mod_params = &iwl50_mod_params,
  1250. };
  1251. struct iwl_cfg iwl5100_agn_cfg = {
  1252. .name = "5100AGN",
  1253. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1254. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1255. .ops = &iwl5000_ops,
  1256. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1257. .mod_params = &iwl50_mod_params,
  1258. };
  1259. struct iwl_cfg iwl5350_agn_cfg = {
  1260. .name = "5350AGN",
  1261. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1262. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1263. .ops = &iwl5000_ops,
  1264. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1265. .mod_params = &iwl50_mod_params,
  1266. };
  1267. module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
  1268. MODULE_PARM_DESC(disable50,
  1269. "manually disable the 50XX radio (default 0 [radio on])");
  1270. module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, 0444);
  1271. MODULE_PARM_DESC(swcrypto50,
  1272. "using software crypto engine (default 0 [hardware])\n");
  1273. module_param_named(debug50, iwl50_mod_params.debug, int, 0444);
  1274. MODULE_PARM_DESC(debug50, "50XX debug output mask");
  1275. module_param_named(queues_num50, iwl50_mod_params.num_of_queues, int, 0444);
  1276. MODULE_PARM_DESC(queues_num50, "number of hw queues in 50xx series");
  1277. module_param_named(qos_enable50, iwl50_mod_params.enable_qos, int, 0444);
  1278. MODULE_PARM_DESC(qos_enable50, "enable all 50XX QoS functionality");
  1279. module_param_named(amsdu_size_8K50, iwl50_mod_params.amsdu_size_8K, int, 0444);
  1280. MODULE_PARM_DESC(amsdu_size_8K50, "enable 8K amsdu size in 50XX series");
  1281. module_param_named(fw_restart50, iwl50_mod_params.restart_fw, int, 0444);
  1282. MODULE_PARM_DESC(fw_restart50, "restart firmware in case of error");