iwl-5000.c 47 KB

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