iwl-5000.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  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 void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
  293. __le32 *tx_flags)
  294. {
  295. if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
  296. (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
  297. *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
  298. else
  299. *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
  300. }
  301. static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
  302. .min_nrg_cck = 95,
  303. .max_nrg_cck = 0,
  304. .auto_corr_min_ofdm = 90,
  305. .auto_corr_min_ofdm_mrc = 170,
  306. .auto_corr_min_ofdm_x1 = 120,
  307. .auto_corr_min_ofdm_mrc_x1 = 240,
  308. .auto_corr_max_ofdm = 120,
  309. .auto_corr_max_ofdm_mrc = 210,
  310. .auto_corr_max_ofdm_x1 = 155,
  311. .auto_corr_max_ofdm_mrc_x1 = 290,
  312. .auto_corr_min_cck = 125,
  313. .auto_corr_max_cck = 200,
  314. .auto_corr_min_cck_mrc = 170,
  315. .auto_corr_max_cck_mrc = 400,
  316. .nrg_th_cck = 95,
  317. .nrg_th_ofdm = 95,
  318. };
  319. static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
  320. size_t offset)
  321. {
  322. u32 address = eeprom_indirect_address(priv, offset);
  323. BUG_ON(address >= priv->cfg->eeprom_size);
  324. return &priv->eeprom[address];
  325. }
  326. /*
  327. * Calibration
  328. */
  329. static int iwl5000_send_Xtal_calib(struct iwl_priv *priv)
  330. {
  331. u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
  332. struct iwl5000_calibration cal_cmd = {
  333. .op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD,
  334. .data = {
  335. (u8)xtal_calib[0],
  336. (u8)xtal_calib[1],
  337. }
  338. };
  339. return iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
  340. sizeof(cal_cmd), &cal_cmd);
  341. }
  342. static int iwl5000_send_calib_results(struct iwl_priv *priv)
  343. {
  344. int ret = 0;
  345. struct iwl_host_cmd hcmd = {
  346. .id = REPLY_PHY_CALIBRATION_CMD,
  347. .meta.flags = CMD_SIZE_HUGE,
  348. };
  349. if (priv->calib_results.lo_res) {
  350. hcmd.len = priv->calib_results.lo_res_len;
  351. hcmd.data = priv->calib_results.lo_res;
  352. ret = iwl_send_cmd_sync(priv, &hcmd);
  353. if (ret)
  354. goto err;
  355. }
  356. if (priv->calib_results.tx_iq_res) {
  357. hcmd.len = priv->calib_results.tx_iq_res_len;
  358. hcmd.data = priv->calib_results.tx_iq_res;
  359. ret = iwl_send_cmd_sync(priv, &hcmd);
  360. if (ret)
  361. goto err;
  362. }
  363. if (priv->calib_results.tx_iq_perd_res) {
  364. hcmd.len = priv->calib_results.tx_iq_perd_res_len;
  365. hcmd.data = priv->calib_results.tx_iq_perd_res;
  366. ret = iwl_send_cmd_sync(priv, &hcmd);
  367. if (ret)
  368. goto err;
  369. }
  370. return 0;
  371. err:
  372. IWL_ERROR("Error %d\n", ret);
  373. return ret;
  374. }
  375. static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
  376. {
  377. struct iwl5000_calib_cfg_cmd calib_cfg_cmd;
  378. struct iwl_host_cmd cmd = {
  379. .id = CALIBRATION_CFG_CMD,
  380. .len = sizeof(struct iwl5000_calib_cfg_cmd),
  381. .data = &calib_cfg_cmd,
  382. };
  383. memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd));
  384. calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
  385. calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL;
  386. calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
  387. calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL;
  388. return iwl_send_cmd(priv, &cmd);
  389. }
  390. static void iwl5000_rx_calib_result(struct iwl_priv *priv,
  391. struct iwl_rx_mem_buffer *rxb)
  392. {
  393. struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
  394. struct iwl5000_calib_hdr *hdr = (struct iwl5000_calib_hdr *)pkt->u.raw;
  395. int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK;
  396. iwl_free_calib_results(priv);
  397. /* reduce the size of the length field itself */
  398. len -= 4;
  399. switch (hdr->op_code) {
  400. case IWL5000_PHY_CALIBRATE_LO_CMD:
  401. priv->calib_results.lo_res = kzalloc(len, GFP_ATOMIC);
  402. priv->calib_results.lo_res_len = len;
  403. memcpy(priv->calib_results.lo_res, pkt->u.raw, len);
  404. break;
  405. case IWL5000_PHY_CALIBRATE_TX_IQ_CMD:
  406. priv->calib_results.tx_iq_res = kzalloc(len, GFP_ATOMIC);
  407. priv->calib_results.tx_iq_res_len = len;
  408. memcpy(priv->calib_results.tx_iq_res, pkt->u.raw, len);
  409. break;
  410. case IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD:
  411. priv->calib_results.tx_iq_perd_res = kzalloc(len, GFP_ATOMIC);
  412. priv->calib_results.tx_iq_perd_res_len = len;
  413. memcpy(priv->calib_results.tx_iq_perd_res, pkt->u.raw, len);
  414. break;
  415. default:
  416. IWL_ERROR("Unknown calibration notification %d\n",
  417. hdr->op_code);
  418. return;
  419. }
  420. }
  421. static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
  422. struct iwl_rx_mem_buffer *rxb)
  423. {
  424. IWL_DEBUG_INFO("Init. calibration is completed, restarting fw.\n");
  425. queue_work(priv->workqueue, &priv->restart);
  426. }
  427. /*
  428. * ucode
  429. */
  430. static int iwl5000_load_section(struct iwl_priv *priv,
  431. struct fw_desc *image,
  432. u32 dst_addr)
  433. {
  434. int ret = 0;
  435. unsigned long flags;
  436. dma_addr_t phy_addr = image->p_addr;
  437. u32 byte_cnt = image->len;
  438. spin_lock_irqsave(&priv->lock, flags);
  439. ret = iwl_grab_nic_access(priv);
  440. if (ret) {
  441. spin_unlock_irqrestore(&priv->lock, flags);
  442. return ret;
  443. }
  444. iwl_write_direct32(priv,
  445. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  446. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
  447. iwl_write_direct32(priv,
  448. FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
  449. iwl_write_direct32(priv,
  450. FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
  451. phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
  452. /* FIME: write the MSB of the phy_addr in CTRL1
  453. * iwl_write_direct32(priv,
  454. IWL_FH_TFDIB_CTRL1_REG(IWL_FH_SRVC_CHNL),
  455. ((phy_addr & MSB_MSK)
  456. << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_count);
  457. */
  458. iwl_write_direct32(priv,
  459. FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), byte_cnt);
  460. iwl_write_direct32(priv,
  461. FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
  462. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
  463. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
  464. FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
  465. iwl_write_direct32(priv,
  466. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  467. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  468. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL |
  469. FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
  470. iwl_release_nic_access(priv);
  471. spin_unlock_irqrestore(&priv->lock, flags);
  472. return 0;
  473. }
  474. static int iwl5000_load_given_ucode(struct iwl_priv *priv,
  475. struct fw_desc *inst_image,
  476. struct fw_desc *data_image)
  477. {
  478. int ret = 0;
  479. ret = iwl5000_load_section(
  480. priv, inst_image, RTC_INST_LOWER_BOUND);
  481. if (ret)
  482. return ret;
  483. IWL_DEBUG_INFO("INST uCode section being loaded...\n");
  484. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  485. priv->ucode_write_complete, 5 * HZ);
  486. if (ret == -ERESTARTSYS) {
  487. IWL_ERROR("Could not load the INST uCode section due "
  488. "to interrupt\n");
  489. return ret;
  490. }
  491. if (!ret) {
  492. IWL_ERROR("Could not load the INST uCode section\n");
  493. return -ETIMEDOUT;
  494. }
  495. priv->ucode_write_complete = 0;
  496. ret = iwl5000_load_section(
  497. priv, data_image, RTC_DATA_LOWER_BOUND);
  498. if (ret)
  499. return ret;
  500. IWL_DEBUG_INFO("DATA uCode section being loaded...\n");
  501. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  502. priv->ucode_write_complete, 5 * HZ);
  503. if (ret == -ERESTARTSYS) {
  504. IWL_ERROR("Could not load the INST uCode section due "
  505. "to interrupt\n");
  506. return ret;
  507. } else if (!ret) {
  508. IWL_ERROR("Could not load the DATA uCode section\n");
  509. return -ETIMEDOUT;
  510. } else
  511. ret = 0;
  512. priv->ucode_write_complete = 0;
  513. return ret;
  514. }
  515. static int iwl5000_load_ucode(struct iwl_priv *priv)
  516. {
  517. int ret = 0;
  518. /* check whether init ucode should be loaded, or rather runtime ucode */
  519. if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
  520. IWL_DEBUG_INFO("Init ucode found. Loading init ucode...\n");
  521. ret = iwl5000_load_given_ucode(priv,
  522. &priv->ucode_init, &priv->ucode_init_data);
  523. if (!ret) {
  524. IWL_DEBUG_INFO("Init ucode load complete.\n");
  525. priv->ucode_type = UCODE_INIT;
  526. }
  527. } else {
  528. IWL_DEBUG_INFO("Init ucode not found, or already loaded. "
  529. "Loading runtime ucode...\n");
  530. ret = iwl5000_load_given_ucode(priv,
  531. &priv->ucode_code, &priv->ucode_data);
  532. if (!ret) {
  533. IWL_DEBUG_INFO("Runtime ucode load complete.\n");
  534. priv->ucode_type = UCODE_RT;
  535. }
  536. }
  537. return ret;
  538. }
  539. static void iwl5000_init_alive_start(struct iwl_priv *priv)
  540. {
  541. int ret = 0;
  542. /* Check alive response for "valid" sign from uCode */
  543. if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
  544. /* We had an error bringing up the hardware, so take it
  545. * all the way back down so we can try again */
  546. IWL_DEBUG_INFO("Initialize Alive failed.\n");
  547. goto restart;
  548. }
  549. /* initialize uCode was loaded... verify inst image.
  550. * This is a paranoid check, because we would not have gotten the
  551. * "initialize" alive if code weren't properly loaded. */
  552. if (iwl_verify_ucode(priv)) {
  553. /* Runtime instruction load was bad;
  554. * take it all the way back down so we can try again */
  555. IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n");
  556. goto restart;
  557. }
  558. iwl_clear_stations_table(priv);
  559. ret = priv->cfg->ops->lib->alive_notify(priv);
  560. if (ret) {
  561. IWL_WARNING("Could not complete ALIVE transition: %d\n", ret);
  562. goto restart;
  563. }
  564. iwl5000_send_calib_cfg(priv);
  565. return;
  566. restart:
  567. /* real restart (first load init_ucode) */
  568. queue_work(priv->workqueue, &priv->restart);
  569. }
  570. static void iwl5000_set_wr_ptrs(struct iwl_priv *priv,
  571. int txq_id, u32 index)
  572. {
  573. iwl_write_direct32(priv, HBUS_TARG_WRPTR,
  574. (index & 0xff) | (txq_id << 8));
  575. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(txq_id), index);
  576. }
  577. static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
  578. struct iwl_tx_queue *txq,
  579. int tx_fifo_id, int scd_retry)
  580. {
  581. int txq_id = txq->q.id;
  582. int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0;
  583. iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  584. (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
  585. (tx_fifo_id << IWL50_SCD_QUEUE_STTS_REG_POS_TXF) |
  586. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_WSL) |
  587. IWL50_SCD_QUEUE_STTS_REG_MSK);
  588. txq->sched_retry = scd_retry;
  589. IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n",
  590. active ? "Activate" : "Deactivate",
  591. scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
  592. }
  593. static int iwl5000_send_wimax_coex(struct iwl_priv *priv)
  594. {
  595. struct iwl_wimax_coex_cmd coex_cmd;
  596. memset(&coex_cmd, 0, sizeof(coex_cmd));
  597. return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
  598. sizeof(coex_cmd), &coex_cmd);
  599. }
  600. static int iwl5000_alive_notify(struct iwl_priv *priv)
  601. {
  602. u32 a;
  603. int i = 0;
  604. unsigned long flags;
  605. int ret;
  606. spin_lock_irqsave(&priv->lock, flags);
  607. ret = iwl_grab_nic_access(priv);
  608. if (ret) {
  609. spin_unlock_irqrestore(&priv->lock, flags);
  610. return ret;
  611. }
  612. priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
  613. a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
  614. for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
  615. a += 4)
  616. iwl_write_targ_mem(priv, a, 0);
  617. for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
  618. a += 4)
  619. iwl_write_targ_mem(priv, a, 0);
  620. for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
  621. iwl_write_targ_mem(priv, a, 0);
  622. iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
  623. (priv->shared_phys +
  624. offsetof(struct iwl5000_shared, queues_byte_cnt_tbls)) >> 10);
  625. iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
  626. IWL50_SCD_QUEUECHAIN_SEL_ALL(
  627. priv->hw_params.max_txq_num));
  628. iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
  629. /* initiate the queues */
  630. for (i = 0; i < priv->hw_params.max_txq_num; i++) {
  631. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0);
  632. iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
  633. iwl_write_targ_mem(priv, priv->scd_base_addr +
  634. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
  635. iwl_write_targ_mem(priv, priv->scd_base_addr +
  636. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) +
  637. sizeof(u32),
  638. ((SCD_WIN_SIZE <<
  639. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  640. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  641. ((SCD_FRAME_LIMIT <<
  642. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  643. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  644. }
  645. iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK,
  646. IWL_MASK(0, priv->hw_params.max_txq_num));
  647. /* Activate all Tx DMA/FIFO channels */
  648. priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
  649. iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
  650. /* map qos queues to fifos one-to-one */
  651. for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
  652. int ac = iwl5000_default_queue_to_tx_fifo[i];
  653. iwl_txq_ctx_activate(priv, i);
  654. iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
  655. }
  656. /* TODO - need to initialize those FIFOs inside the loop above,
  657. * not only mark them as active */
  658. iwl_txq_ctx_activate(priv, 4);
  659. iwl_txq_ctx_activate(priv, 7);
  660. iwl_txq_ctx_activate(priv, 8);
  661. iwl_txq_ctx_activate(priv, 9);
  662. iwl_release_nic_access(priv);
  663. spin_unlock_irqrestore(&priv->lock, flags);
  664. iwl5000_send_wimax_coex(priv);
  665. iwl5000_send_Xtal_calib(priv);
  666. if (priv->ucode_type == UCODE_RT)
  667. iwl5000_send_calib_results(priv);
  668. return 0;
  669. }
  670. static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  671. {
  672. if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) ||
  673. (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
  674. IWL_ERROR("invalid queues_num, should be between %d and %d\n",
  675. IWL_MIN_NUM_QUEUES, IWL50_NUM_QUEUES);
  676. return -EINVAL;
  677. }
  678. priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
  679. priv->hw_params.first_ampdu_q = IWL50_FIRST_AMPDU_QUEUE;
  680. priv->hw_params.max_stations = IWL5000_STATION_COUNT;
  681. priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
  682. priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
  683. priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
  684. priv->hw_params.max_bsm_size = 0;
  685. priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) |
  686. BIT(IEEE80211_BAND_5GHZ);
  687. priv->hw_params.sens = &iwl5000_sensitivity;
  688. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  689. case CSR_HW_REV_TYPE_5100:
  690. case CSR_HW_REV_TYPE_5150:
  691. priv->hw_params.tx_chains_num = 1;
  692. priv->hw_params.rx_chains_num = 2;
  693. /* FIXME: move to ANT_A, ANT_B, ANT_C enum */
  694. priv->hw_params.valid_tx_ant = ANT_A;
  695. priv->hw_params.valid_rx_ant = ANT_AB;
  696. break;
  697. case CSR_HW_REV_TYPE_5300:
  698. case CSR_HW_REV_TYPE_5350:
  699. priv->hw_params.tx_chains_num = 3;
  700. priv->hw_params.rx_chains_num = 3;
  701. priv->hw_params.valid_tx_ant = ANT_ABC;
  702. priv->hw_params.valid_rx_ant = ANT_ABC;
  703. break;
  704. }
  705. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  706. case CSR_HW_REV_TYPE_5100:
  707. case CSR_HW_REV_TYPE_5300:
  708. /* 5X00 wants in Celsius */
  709. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  710. break;
  711. case CSR_HW_REV_TYPE_5150:
  712. case CSR_HW_REV_TYPE_5350:
  713. /* 5X50 wants in Kelvin */
  714. priv->hw_params.ct_kill_threshold =
  715. CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
  716. break;
  717. }
  718. return 0;
  719. }
  720. static int iwl5000_alloc_shared_mem(struct iwl_priv *priv)
  721. {
  722. priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
  723. sizeof(struct iwl5000_shared),
  724. &priv->shared_phys);
  725. if (!priv->shared_virt)
  726. return -ENOMEM;
  727. memset(priv->shared_virt, 0, sizeof(struct iwl5000_shared));
  728. priv->rb_closed_offset = offsetof(struct iwl5000_shared, rb_closed);
  729. return 0;
  730. }
  731. static void iwl5000_free_shared_mem(struct iwl_priv *priv)
  732. {
  733. if (priv->shared_virt)
  734. pci_free_consistent(priv->pci_dev,
  735. sizeof(struct iwl5000_shared),
  736. priv->shared_virt,
  737. priv->shared_phys);
  738. }
  739. static int iwl5000_shared_mem_rx_idx(struct iwl_priv *priv)
  740. {
  741. struct iwl5000_shared *s = priv->shared_virt;
  742. return le32_to_cpu(s->rb_closed) & 0xFFF;
  743. }
  744. /**
  745. * iwl5000_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  746. */
  747. static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  748. struct iwl_tx_queue *txq,
  749. u16 byte_cnt)
  750. {
  751. struct iwl5000_shared *shared_data = priv->shared_virt;
  752. int txq_id = txq->q.id;
  753. u8 sec_ctl = 0;
  754. u8 sta = 0;
  755. int len;
  756. len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
  757. if (txq_id != IWL_CMD_QUEUE_NUM) {
  758. sta = txq->cmd[txq->q.write_ptr].cmd.tx.sta_id;
  759. sec_ctl = txq->cmd[txq->q.write_ptr].cmd.tx.sec_ctl;
  760. switch (sec_ctl & TX_CMD_SEC_MSK) {
  761. case TX_CMD_SEC_CCM:
  762. len += CCMP_MIC_LEN;
  763. break;
  764. case TX_CMD_SEC_TKIP:
  765. len += TKIP_ICV_LEN;
  766. break;
  767. case TX_CMD_SEC_WEP:
  768. len += WEP_IV_LEN + WEP_ICV_LEN;
  769. break;
  770. }
  771. }
  772. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  773. tfd_offset[txq->q.write_ptr], byte_cnt, len);
  774. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  775. tfd_offset[txq->q.write_ptr], sta_id, sta);
  776. if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) {
  777. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  778. tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr],
  779. byte_cnt, len);
  780. IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
  781. tfd_offset[IWL50_QUEUE_SIZE + txq->q.write_ptr],
  782. sta_id, sta);
  783. }
  784. }
  785. static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  786. struct iwl_tx_queue *txq)
  787. {
  788. int txq_id = txq->q.id;
  789. struct iwl5000_shared *shared_data = priv->shared_virt;
  790. u8 sta = 0;
  791. if (txq_id != IWL_CMD_QUEUE_NUM)
  792. sta = txq->cmd[txq->q.read_ptr].cmd.tx.sta_id;
  793. shared_data->queues_byte_cnt_tbls[txq_id].tfd_offset[txq->q.read_ptr].
  794. val = cpu_to_le16(1 | (sta << 12));
  795. if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) {
  796. shared_data->queues_byte_cnt_tbls[txq_id].
  797. tfd_offset[IWL50_QUEUE_SIZE + txq->q.read_ptr].
  798. val = cpu_to_le16(1 | (sta << 12));
  799. }
  800. }
  801. static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
  802. u16 txq_id)
  803. {
  804. u32 tbl_dw_addr;
  805. u32 tbl_dw;
  806. u16 scd_q2ratid;
  807. scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
  808. tbl_dw_addr = priv->scd_base_addr +
  809. IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
  810. tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
  811. if (txq_id & 0x1)
  812. tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
  813. else
  814. tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
  815. iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
  816. return 0;
  817. }
  818. static void iwl5000_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
  819. {
  820. /* Simply stop the queue, but don't change any configuration;
  821. * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
  822. iwl_write_prph(priv,
  823. IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  824. (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
  825. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
  826. }
  827. static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  828. int tx_fifo, int sta_id, int tid, u16 ssn_idx)
  829. {
  830. unsigned long flags;
  831. int ret;
  832. u16 ra_tid;
  833. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  834. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  835. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  836. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  837. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  838. return -EINVAL;
  839. }
  840. ra_tid = BUILD_RAxTID(sta_id, tid);
  841. /* Modify device's station table to Tx this TID */
  842. iwl_sta_modify_enable_tid_tx(priv, sta_id, tid);
  843. spin_lock_irqsave(&priv->lock, flags);
  844. ret = iwl_grab_nic_access(priv);
  845. if (ret) {
  846. spin_unlock_irqrestore(&priv->lock, flags);
  847. return ret;
  848. }
  849. /* Stop this Tx queue before configuring it */
  850. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  851. /* Map receiver-address / traffic-ID to this queue */
  852. iwl5000_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
  853. /* Set this queue as a chain-building queue */
  854. iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id));
  855. /* enable aggregations for the queue */
  856. iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id));
  857. /* Place first TFD at index corresponding to start sequence number.
  858. * Assumes that ssn_idx is valid (!= 0xFFF) */
  859. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  860. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  861. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  862. /* Set up Tx window size and frame limit for this queue */
  863. iwl_write_targ_mem(priv, priv->scd_base_addr +
  864. IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
  865. sizeof(u32),
  866. ((SCD_WIN_SIZE <<
  867. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  868. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  869. ((SCD_FRAME_LIMIT <<
  870. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  871. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  872. iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  873. /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
  874. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
  875. iwl_release_nic_access(priv);
  876. spin_unlock_irqrestore(&priv->lock, flags);
  877. return 0;
  878. }
  879. static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  880. u16 ssn_idx, u8 tx_fifo)
  881. {
  882. int ret;
  883. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  884. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  885. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  886. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  887. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  888. return -EINVAL;
  889. }
  890. ret = iwl_grab_nic_access(priv);
  891. if (ret)
  892. return ret;
  893. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  894. iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id));
  895. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  896. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  897. /* supposes that ssn_idx is valid (!= 0xFFF) */
  898. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  899. iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  900. iwl_txq_ctx_deactivate(priv, txq_id);
  901. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
  902. iwl_release_nic_access(priv);
  903. return 0;
  904. }
  905. static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
  906. {
  907. u16 size = (u16)sizeof(struct iwl_addsta_cmd);
  908. memcpy(data, cmd, size);
  909. return size;
  910. }
  911. /*
  912. * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask
  913. * must be called under priv->lock and mac access
  914. */
  915. static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask)
  916. {
  917. iwl_write_prph(priv, IWL50_SCD_TXFACT, mask);
  918. }
  919. static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
  920. {
  921. return le32_to_cpup((__le32*)&tx_resp->status +
  922. tx_resp->frame_count) & MAX_SN;
  923. }
  924. static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
  925. struct iwl_ht_agg *agg,
  926. struct iwl5000_tx_resp *tx_resp,
  927. int txq_id, u16 start_idx)
  928. {
  929. u16 status;
  930. struct agg_tx_status *frame_status = &tx_resp->status;
  931. struct ieee80211_tx_info *info = NULL;
  932. struct ieee80211_hdr *hdr = NULL;
  933. u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
  934. int i, sh, idx;
  935. u16 seq;
  936. if (agg->wait_for_ba)
  937. IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
  938. agg->frame_count = tx_resp->frame_count;
  939. agg->start_idx = start_idx;
  940. agg->rate_n_flags = rate_n_flags;
  941. agg->bitmap = 0;
  942. /* # frames attempted by Tx command */
  943. if (agg->frame_count == 1) {
  944. /* Only one frame was attempted; no block-ack will arrive */
  945. status = le16_to_cpu(frame_status[0].status);
  946. idx = start_idx;
  947. /* FIXME: code repetition */
  948. IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
  949. agg->frame_count, agg->start_idx, idx);
  950. info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
  951. info->status.retry_count = tx_resp->failure_frame;
  952. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  953. info->flags |= iwl_is_tx_success(status)?
  954. IEEE80211_TX_STAT_ACK : 0;
  955. iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
  956. /* FIXME: code repetition end */
  957. IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
  958. status & 0xff, tx_resp->failure_frame);
  959. IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
  960. agg->wait_for_ba = 0;
  961. } else {
  962. /* Two or more frames were attempted; expect block-ack */
  963. u64 bitmap = 0;
  964. int start = agg->start_idx;
  965. /* Construct bit-map of pending frames within Tx window */
  966. for (i = 0; i < agg->frame_count; i++) {
  967. u16 sc;
  968. status = le16_to_cpu(frame_status[i].status);
  969. seq = le16_to_cpu(frame_status[i].sequence);
  970. idx = SEQ_TO_INDEX(seq);
  971. txq_id = SEQ_TO_QUEUE(seq);
  972. if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
  973. AGG_TX_STATE_ABORT_MSK))
  974. continue;
  975. IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
  976. agg->frame_count, txq_id, idx);
  977. hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
  978. sc = le16_to_cpu(hdr->seq_ctrl);
  979. if (idx != (SEQ_TO_SN(sc) & 0xff)) {
  980. IWL_ERROR("BUG_ON idx doesn't match seq control"
  981. " idx=%d, seq_idx=%d, seq=%d\n",
  982. idx, SEQ_TO_SN(sc),
  983. hdr->seq_ctrl);
  984. return -1;
  985. }
  986. IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n",
  987. i, idx, SEQ_TO_SN(sc));
  988. sh = idx - start;
  989. if (sh > 64) {
  990. sh = (start - idx) + 0xff;
  991. bitmap = bitmap << sh;
  992. sh = 0;
  993. start = idx;
  994. } else if (sh < -64)
  995. sh = 0xff - (start - idx);
  996. else if (sh < 0) {
  997. sh = start - idx;
  998. start = idx;
  999. bitmap = bitmap << sh;
  1000. sh = 0;
  1001. }
  1002. bitmap |= (1 << sh);
  1003. IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n",
  1004. start, (u32)(bitmap & 0xFFFFFFFF));
  1005. }
  1006. agg->bitmap = bitmap;
  1007. agg->start_idx = start;
  1008. IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
  1009. agg->frame_count, agg->start_idx,
  1010. (unsigned long long)agg->bitmap);
  1011. if (bitmap)
  1012. agg->wait_for_ba = 1;
  1013. }
  1014. return 0;
  1015. }
  1016. static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
  1017. struct iwl_rx_mem_buffer *rxb)
  1018. {
  1019. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  1020. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  1021. int txq_id = SEQ_TO_QUEUE(sequence);
  1022. int index = SEQ_TO_INDEX(sequence);
  1023. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  1024. struct ieee80211_tx_info *info;
  1025. struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  1026. u32 status = le16_to_cpu(tx_resp->status.status);
  1027. int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
  1028. struct ieee80211_hdr *hdr;
  1029. u8 *qc = NULL;
  1030. if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
  1031. IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
  1032. "is out of range [0-%d] %d %d\n", txq_id,
  1033. index, txq->q.n_bd, txq->q.write_ptr,
  1034. txq->q.read_ptr);
  1035. return;
  1036. }
  1037. info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
  1038. memset(&info->status, 0, sizeof(info->status));
  1039. hdr = iwl_tx_queue_get_hdr(priv, txq_id, index);
  1040. if (ieee80211_is_data_qos(hdr->frame_control)) {
  1041. qc = ieee80211_get_qos_ctl(hdr);
  1042. tid = qc[0] & 0xf;
  1043. }
  1044. sta_id = iwl_get_ra_sta_id(priv, hdr);
  1045. if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) {
  1046. IWL_ERROR("Station not known\n");
  1047. return;
  1048. }
  1049. if (txq->sched_retry) {
  1050. const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
  1051. struct iwl_ht_agg *agg = NULL;
  1052. if (!qc)
  1053. return;
  1054. agg = &priv->stations[sta_id].tid[tid].agg;
  1055. iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
  1056. /* check if BAR is needed */
  1057. if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status))
  1058. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  1059. if (txq->q.read_ptr != (scd_ssn & 0xff)) {
  1060. int freed, ampdu_q;
  1061. index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
  1062. IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
  1063. "%d index %d\n", scd_ssn , index);
  1064. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1065. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1066. if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
  1067. txq_id >= 0 && priv->mac80211_registered &&
  1068. agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) {
  1069. /* calculate mac80211 ampdu sw queue to wake */
  1070. ampdu_q = txq_id - IWL50_FIRST_AMPDU_QUEUE +
  1071. priv->hw->queues;
  1072. if (agg->state == IWL_AGG_OFF)
  1073. ieee80211_wake_queue(priv->hw, txq_id);
  1074. else
  1075. ieee80211_wake_queue(priv->hw, ampdu_q);
  1076. }
  1077. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1078. }
  1079. } else {
  1080. info->status.retry_count = tx_resp->failure_frame;
  1081. info->flags =
  1082. iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
  1083. iwl_hwrate_to_tx_control(priv,
  1084. le32_to_cpu(tx_resp->rate_n_flags),
  1085. info);
  1086. IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags "
  1087. "0x%x retries %d\n", txq_id,
  1088. iwl_get_tx_fail_reason(status),
  1089. status, le32_to_cpu(tx_resp->rate_n_flags),
  1090. tx_resp->failure_frame);
  1091. IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
  1092. if (index != -1) {
  1093. int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1094. if (tid != MAX_TID_COUNT)
  1095. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1096. if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
  1097. (txq_id >= 0) && priv->mac80211_registered)
  1098. ieee80211_wake_queue(priv->hw, txq_id);
  1099. if (tid != MAX_TID_COUNT)
  1100. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1101. }
  1102. }
  1103. if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
  1104. IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
  1105. }
  1106. /* Currently 5000 is the supperset of everything */
  1107. static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
  1108. {
  1109. return len;
  1110. }
  1111. static void iwl5000_setup_deferred_work(struct iwl_priv *priv)
  1112. {
  1113. /* in 5000 the tx power calibration is done in uCode */
  1114. priv->disable_tx_power_cal = 1;
  1115. }
  1116. static void iwl5000_rx_handler_setup(struct iwl_priv *priv)
  1117. {
  1118. /* init calibration handlers */
  1119. priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
  1120. iwl5000_rx_calib_result;
  1121. priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] =
  1122. iwl5000_rx_calib_complete;
  1123. priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx;
  1124. }
  1125. static int iwl5000_hw_valid_rtc_data_addr(u32 addr)
  1126. {
  1127. return (addr >= RTC_DATA_LOWER_BOUND) &&
  1128. (addr < IWL50_RTC_DATA_UPPER_BOUND);
  1129. }
  1130. static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
  1131. {
  1132. int ret = 0;
  1133. struct iwl5000_rxon_assoc_cmd rxon_assoc;
  1134. const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
  1135. const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
  1136. if ((rxon1->flags == rxon2->flags) &&
  1137. (rxon1->filter_flags == rxon2->filter_flags) &&
  1138. (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
  1139. (rxon1->ofdm_ht_single_stream_basic_rates ==
  1140. rxon2->ofdm_ht_single_stream_basic_rates) &&
  1141. (rxon1->ofdm_ht_dual_stream_basic_rates ==
  1142. rxon2->ofdm_ht_dual_stream_basic_rates) &&
  1143. (rxon1->ofdm_ht_triple_stream_basic_rates ==
  1144. rxon2->ofdm_ht_triple_stream_basic_rates) &&
  1145. (rxon1->acquisition_data == rxon2->acquisition_data) &&
  1146. (rxon1->rx_chain == rxon2->rx_chain) &&
  1147. (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
  1148. IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n");
  1149. return 0;
  1150. }
  1151. rxon_assoc.flags = priv->staging_rxon.flags;
  1152. rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
  1153. rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
  1154. rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
  1155. rxon_assoc.reserved1 = 0;
  1156. rxon_assoc.reserved2 = 0;
  1157. rxon_assoc.reserved3 = 0;
  1158. rxon_assoc.ofdm_ht_single_stream_basic_rates =
  1159. priv->staging_rxon.ofdm_ht_single_stream_basic_rates;
  1160. rxon_assoc.ofdm_ht_dual_stream_basic_rates =
  1161. priv->staging_rxon.ofdm_ht_dual_stream_basic_rates;
  1162. rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain;
  1163. rxon_assoc.ofdm_ht_triple_stream_basic_rates =
  1164. priv->staging_rxon.ofdm_ht_triple_stream_basic_rates;
  1165. rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data;
  1166. ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
  1167. sizeof(rxon_assoc), &rxon_assoc, NULL);
  1168. if (ret)
  1169. return ret;
  1170. return ret;
  1171. }
  1172. static int iwl5000_send_tx_power(struct iwl_priv *priv)
  1173. {
  1174. struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
  1175. /* half dBm need to multiply */
  1176. tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
  1177. tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED;
  1178. tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
  1179. return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD,
  1180. sizeof(tx_power_cmd), &tx_power_cmd,
  1181. NULL);
  1182. }
  1183. static void iwl5000_temperature(struct iwl_priv *priv)
  1184. {
  1185. /* store temperature from statistics (in Celsius) */
  1186. priv->temperature = le32_to_cpu(priv->statistics.general.temperature);
  1187. }
  1188. static struct iwl_hcmd_ops iwl5000_hcmd = {
  1189. .rxon_assoc = iwl5000_send_rxon_assoc,
  1190. };
  1191. static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
  1192. .get_hcmd_size = iwl5000_get_hcmd_size,
  1193. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  1194. .gain_computation = iwl5000_gain_computation,
  1195. .chain_noise_reset = iwl5000_chain_noise_reset,
  1196. .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
  1197. };
  1198. static struct iwl_lib_ops iwl5000_lib = {
  1199. .set_hw_params = iwl5000_hw_set_hw_params,
  1200. .alloc_shared_mem = iwl5000_alloc_shared_mem,
  1201. .free_shared_mem = iwl5000_free_shared_mem,
  1202. .shared_mem_rx_idx = iwl5000_shared_mem_rx_idx,
  1203. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  1204. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  1205. .txq_set_sched = iwl5000_txq_set_sched,
  1206. .txq_agg_enable = iwl5000_txq_agg_enable,
  1207. .txq_agg_disable = iwl5000_txq_agg_disable,
  1208. .rx_handler_setup = iwl5000_rx_handler_setup,
  1209. .setup_deferred_work = iwl5000_setup_deferred_work,
  1210. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  1211. .load_ucode = iwl5000_load_ucode,
  1212. .init_alive_start = iwl5000_init_alive_start,
  1213. .alive_notify = iwl5000_alive_notify,
  1214. .send_tx_power = iwl5000_send_tx_power,
  1215. .temperature = iwl5000_temperature,
  1216. .apm_ops = {
  1217. .init = iwl5000_apm_init,
  1218. .reset = iwl5000_apm_reset,
  1219. .stop = iwl5000_apm_stop,
  1220. .config = iwl5000_nic_config,
  1221. .set_pwr_src = iwl4965_set_pwr_src,
  1222. },
  1223. .eeprom_ops = {
  1224. .regulatory_bands = {
  1225. EEPROM_5000_REG_BAND_1_CHANNELS,
  1226. EEPROM_5000_REG_BAND_2_CHANNELS,
  1227. EEPROM_5000_REG_BAND_3_CHANNELS,
  1228. EEPROM_5000_REG_BAND_4_CHANNELS,
  1229. EEPROM_5000_REG_BAND_5_CHANNELS,
  1230. EEPROM_5000_REG_BAND_24_FAT_CHANNELS,
  1231. EEPROM_5000_REG_BAND_52_FAT_CHANNELS
  1232. },
  1233. .verify_signature = iwlcore_eeprom_verify_signature,
  1234. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  1235. .release_semaphore = iwlcore_eeprom_release_semaphore,
  1236. .check_version = iwl5000_eeprom_check_version,
  1237. .query_addr = iwl5000_eeprom_query_addr,
  1238. },
  1239. };
  1240. static struct iwl_ops iwl5000_ops = {
  1241. .lib = &iwl5000_lib,
  1242. .hcmd = &iwl5000_hcmd,
  1243. .utils = &iwl5000_hcmd_utils,
  1244. };
  1245. static struct iwl_mod_params iwl50_mod_params = {
  1246. .num_of_queues = IWL50_NUM_QUEUES,
  1247. .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
  1248. .enable_qos = 1,
  1249. .amsdu_size_8K = 1,
  1250. .restart_fw = 1,
  1251. /* the rest are 0 by default */
  1252. };
  1253. struct iwl_cfg iwl5300_agn_cfg = {
  1254. .name = "5300AGN",
  1255. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1256. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1257. .ops = &iwl5000_ops,
  1258. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1259. .mod_params = &iwl50_mod_params,
  1260. };
  1261. struct iwl_cfg iwl5100_bg_cfg = {
  1262. .name = "5100BG",
  1263. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1264. .sku = IWL_SKU_G,
  1265. .ops = &iwl5000_ops,
  1266. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1267. .mod_params = &iwl50_mod_params,
  1268. };
  1269. struct iwl_cfg iwl5100_abg_cfg = {
  1270. .name = "5100ABG",
  1271. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1272. .sku = IWL_SKU_A|IWL_SKU_G,
  1273. .ops = &iwl5000_ops,
  1274. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1275. .mod_params = &iwl50_mod_params,
  1276. };
  1277. struct iwl_cfg iwl5100_agn_cfg = {
  1278. .name = "5100AGN",
  1279. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1280. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1281. .ops = &iwl5000_ops,
  1282. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1283. .mod_params = &iwl50_mod_params,
  1284. };
  1285. struct iwl_cfg iwl5350_agn_cfg = {
  1286. .name = "5350AGN",
  1287. .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
  1288. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1289. .ops = &iwl5000_ops,
  1290. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1291. .mod_params = &iwl50_mod_params,
  1292. };
  1293. module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
  1294. MODULE_PARM_DESC(disable50,
  1295. "manually disable the 50XX radio (default 0 [radio on])");
  1296. module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, 0444);
  1297. MODULE_PARM_DESC(swcrypto50,
  1298. "using software crypto engine (default 0 [hardware])\n");
  1299. module_param_named(debug50, iwl50_mod_params.debug, int, 0444);
  1300. MODULE_PARM_DESC(debug50, "50XX debug output mask");
  1301. module_param_named(queues_num50, iwl50_mod_params.num_of_queues, int, 0444);
  1302. MODULE_PARM_DESC(queues_num50, "number of hw queues in 50xx series");
  1303. module_param_named(qos_enable50, iwl50_mod_params.enable_qos, int, 0444);
  1304. MODULE_PARM_DESC(qos_enable50, "enable all 50XX QoS functionality");
  1305. module_param_named(11n_disable50, iwl50_mod_params.disable_11n, int, 0444);
  1306. MODULE_PARM_DESC(11n_disable50, "disable 50XX 11n functionality");
  1307. module_param_named(amsdu_size_8K50, iwl50_mod_params.amsdu_size_8K, int, 0444);
  1308. MODULE_PARM_DESC(amsdu_size_8K50, "enable 8K amsdu size in 50XX series");
  1309. module_param_named(fw_restart50, iwl50_mod_params.restart_fw, int, 0444);
  1310. MODULE_PARM_DESC(fw_restart50, "restart firmware in case of error");