iwl-legacy.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include <linux/kernel.h>
  29. #include <net/mac80211.h>
  30. #include "iwl-dev.h"
  31. #include "iwl-core.h"
  32. #include "iwl-helpers.h"
  33. #include "iwl-legacy.h"
  34. static void iwl_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
  35. {
  36. if (test_bit(STATUS_EXIT_PENDING, &priv->status))
  37. return;
  38. if (!ctx->is_active)
  39. return;
  40. ctx->qos_data.def_qos_parm.qos_flags = 0;
  41. if (ctx->qos_data.qos_active)
  42. ctx->qos_data.def_qos_parm.qos_flags |=
  43. QOS_PARAM_FLG_UPDATE_EDCA_MSK;
  44. if (ctx->ht.enabled)
  45. ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
  46. IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
  47. ctx->qos_data.qos_active,
  48. ctx->qos_data.def_qos_parm.qos_flags);
  49. iwl_send_cmd_pdu_async(priv, ctx->qos_cmd,
  50. sizeof(struct iwl_qosparam_cmd),
  51. &ctx->qos_data.def_qos_parm, NULL);
  52. }
  53. /**
  54. * iwl_legacy_mac_config - mac80211 config callback
  55. */
  56. int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed)
  57. {
  58. struct iwl_priv *priv = hw->priv;
  59. const struct iwl_channel_info *ch_info;
  60. struct ieee80211_conf *conf = &hw->conf;
  61. struct ieee80211_channel *channel = conf->channel;
  62. struct iwl_ht_config *ht_conf = &priv->current_ht_config;
  63. struct iwl_rxon_context *ctx;
  64. unsigned long flags = 0;
  65. int ret = 0;
  66. u16 ch;
  67. int scan_active = 0;
  68. bool ht_changed[NUM_IWL_RXON_CTX] = {};
  69. if (WARN_ON(!priv->cfg->ops->legacy))
  70. return -EOPNOTSUPP;
  71. mutex_lock(&priv->mutex);
  72. IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n",
  73. channel->hw_value, changed);
  74. if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) {
  75. scan_active = 1;
  76. IWL_DEBUG_MAC80211(priv, "scan active\n");
  77. }
  78. if (changed & (IEEE80211_CONF_CHANGE_SMPS |
  79. IEEE80211_CONF_CHANGE_CHANNEL)) {
  80. /* mac80211 uses static for non-HT which is what we want */
  81. priv->current_ht_config.smps = conf->smps_mode;
  82. /*
  83. * Recalculate chain counts.
  84. *
  85. * If monitor mode is enabled then mac80211 will
  86. * set up the SM PS mode to OFF if an HT channel is
  87. * configured.
  88. */
  89. if (priv->cfg->ops->hcmd->set_rxon_chain)
  90. for_each_context(priv, ctx)
  91. priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
  92. }
  93. /* during scanning mac80211 will delay channel setting until
  94. * scan finish with changed = 0
  95. */
  96. if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) {
  97. if (scan_active)
  98. goto set_ch_out;
  99. ch = channel->hw_value;
  100. ch_info = iwl_get_channel_info(priv, channel->band, ch);
  101. if (!is_channel_valid(ch_info)) {
  102. IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
  103. ret = -EINVAL;
  104. goto set_ch_out;
  105. }
  106. spin_lock_irqsave(&priv->lock, flags);
  107. for_each_context(priv, ctx) {
  108. /* Configure HT40 channels */
  109. if (ctx->ht.enabled != conf_is_ht(conf)) {
  110. ctx->ht.enabled = conf_is_ht(conf);
  111. ht_changed[ctx->ctxid] = true;
  112. }
  113. if (ctx->ht.enabled) {
  114. if (conf_is_ht40_minus(conf)) {
  115. ctx->ht.extension_chan_offset =
  116. IEEE80211_HT_PARAM_CHA_SEC_BELOW;
  117. ctx->ht.is_40mhz = true;
  118. } else if (conf_is_ht40_plus(conf)) {
  119. ctx->ht.extension_chan_offset =
  120. IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
  121. ctx->ht.is_40mhz = true;
  122. } else {
  123. ctx->ht.extension_chan_offset =
  124. IEEE80211_HT_PARAM_CHA_SEC_NONE;
  125. ctx->ht.is_40mhz = false;
  126. }
  127. } else
  128. ctx->ht.is_40mhz = false;
  129. /*
  130. * Default to no protection. Protection mode will
  131. * later be set from BSS config in iwl_ht_conf
  132. */
  133. ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
  134. /* if we are switching from ht to 2.4 clear flags
  135. * from any ht related info since 2.4 does not
  136. * support ht */
  137. if ((le16_to_cpu(ctx->staging.channel) != ch))
  138. ctx->staging.flags = 0;
  139. iwl_set_rxon_channel(priv, channel, ctx);
  140. iwl_set_rxon_ht(priv, ht_conf);
  141. iwl_set_flags_for_band(priv, ctx, channel->band,
  142. ctx->vif);
  143. }
  144. spin_unlock_irqrestore(&priv->lock, flags);
  145. if (priv->cfg->ops->legacy->update_bcast_stations)
  146. ret = priv->cfg->ops->legacy->update_bcast_stations(priv);
  147. set_ch_out:
  148. /* The list of supported rates and rate mask can be different
  149. * for each band; since the band may have changed, reset
  150. * the rate mask to what mac80211 lists */
  151. iwl_set_rate(priv);
  152. }
  153. if (changed & (IEEE80211_CONF_CHANGE_PS |
  154. IEEE80211_CONF_CHANGE_IDLE)) {
  155. ret = iwl_power_update_mode(priv, false);
  156. if (ret)
  157. IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n");
  158. }
  159. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  160. IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
  161. priv->tx_power_user_lmt, conf->power_level);
  162. iwl_set_tx_power(priv, conf->power_level, false);
  163. }
  164. if (!iwl_is_ready(priv)) {
  165. IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
  166. goto out;
  167. }
  168. if (scan_active)
  169. goto out;
  170. for_each_context(priv, ctx) {
  171. if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)))
  172. iwlcore_commit_rxon(priv, ctx);
  173. else
  174. IWL_DEBUG_INFO(priv,
  175. "Not re-sending same RXON configuration.\n");
  176. if (ht_changed[ctx->ctxid])
  177. iwl_update_qos(priv, ctx);
  178. }
  179. out:
  180. IWL_DEBUG_MAC80211(priv, "leave\n");
  181. mutex_unlock(&priv->mutex);
  182. return ret;
  183. }
  184. EXPORT_SYMBOL(iwl_legacy_mac_config);
  185. void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw)
  186. {
  187. struct iwl_priv *priv = hw->priv;
  188. unsigned long flags;
  189. /* IBSS can only be the IWL_RXON_CTX_BSS context */
  190. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  191. if (WARN_ON(!priv->cfg->ops->legacy))
  192. return;
  193. mutex_lock(&priv->mutex);
  194. IWL_DEBUG_MAC80211(priv, "enter\n");
  195. spin_lock_irqsave(&priv->lock, flags);
  196. memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_config));
  197. spin_unlock_irqrestore(&priv->lock, flags);
  198. spin_lock_irqsave(&priv->lock, flags);
  199. /* new association get rid of ibss beacon skb */
  200. if (priv->beacon_skb)
  201. dev_kfree_skb(priv->beacon_skb);
  202. priv->beacon_skb = NULL;
  203. priv->timestamp = 0;
  204. spin_unlock_irqrestore(&priv->lock, flags);
  205. iwl_scan_cancel_timeout(priv, 100);
  206. if (!iwl_is_ready_rf(priv)) {
  207. IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
  208. mutex_unlock(&priv->mutex);
  209. return;
  210. }
  211. /* we are restarting association process
  212. * clear RXON_FILTER_ASSOC_MSK bit
  213. */
  214. ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  215. iwlcore_commit_rxon(priv, ctx);
  216. iwl_set_rate(priv);
  217. mutex_unlock(&priv->mutex);
  218. IWL_DEBUG_MAC80211(priv, "leave\n");
  219. }
  220. EXPORT_SYMBOL(iwl_legacy_mac_reset_tsf);
  221. static void iwl_ht_conf(struct iwl_priv *priv,
  222. struct ieee80211_vif *vif)
  223. {
  224. struct iwl_ht_config *ht_conf = &priv->current_ht_config;
  225. struct ieee80211_sta *sta;
  226. struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
  227. struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
  228. IWL_DEBUG_ASSOC(priv, "enter:\n");
  229. if (!ctx->ht.enabled)
  230. return;
  231. ctx->ht.protection =
  232. bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
  233. ctx->ht.non_gf_sta_present =
  234. !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  235. ht_conf->single_chain_sufficient = false;
  236. switch (vif->type) {
  237. case NL80211_IFTYPE_STATION:
  238. rcu_read_lock();
  239. sta = ieee80211_find_sta(vif, bss_conf->bssid);
  240. if (sta) {
  241. struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
  242. int maxstreams;
  243. maxstreams = (ht_cap->mcs.tx_params &
  244. IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
  245. >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
  246. maxstreams += 1;
  247. if ((ht_cap->mcs.rx_mask[1] == 0) &&
  248. (ht_cap->mcs.rx_mask[2] == 0))
  249. ht_conf->single_chain_sufficient = true;
  250. if (maxstreams <= 1)
  251. ht_conf->single_chain_sufficient = true;
  252. } else {
  253. /*
  254. * If at all, this can only happen through a race
  255. * when the AP disconnects us while we're still
  256. * setting up the connection, in that case mac80211
  257. * will soon tell us about that.
  258. */
  259. ht_conf->single_chain_sufficient = true;
  260. }
  261. rcu_read_unlock();
  262. break;
  263. case NL80211_IFTYPE_ADHOC:
  264. ht_conf->single_chain_sufficient = true;
  265. break;
  266. default:
  267. break;
  268. }
  269. IWL_DEBUG_ASSOC(priv, "leave\n");
  270. }
  271. static inline void iwl_set_no_assoc(struct iwl_priv *priv,
  272. struct ieee80211_vif *vif)
  273. {
  274. struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
  275. /*
  276. * inform the ucode that there is no longer an
  277. * association and that no more packets should be
  278. * sent
  279. */
  280. ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  281. ctx->staging.assoc_id = 0;
  282. iwlcore_commit_rxon(priv, ctx);
  283. }
  284. static void iwlcore_beacon_update(struct ieee80211_hw *hw,
  285. struct ieee80211_vif *vif)
  286. {
  287. struct iwl_priv *priv = hw->priv;
  288. unsigned long flags;
  289. __le64 timestamp;
  290. struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
  291. if (!skb)
  292. return;
  293. IWL_DEBUG_MAC80211(priv, "enter\n");
  294. lockdep_assert_held(&priv->mutex);
  295. if (!priv->beacon_ctx) {
  296. IWL_ERR(priv, "update beacon but no beacon context!\n");
  297. dev_kfree_skb(skb);
  298. return;
  299. }
  300. spin_lock_irqsave(&priv->lock, flags);
  301. if (priv->beacon_skb)
  302. dev_kfree_skb(priv->beacon_skb);
  303. priv->beacon_skb = skb;
  304. timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
  305. priv->timestamp = le64_to_cpu(timestamp);
  306. IWL_DEBUG_MAC80211(priv, "leave\n");
  307. spin_unlock_irqrestore(&priv->lock, flags);
  308. if (!iwl_is_ready_rf(priv)) {
  309. IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
  310. return;
  311. }
  312. priv->cfg->ops->legacy->post_associate(priv);
  313. }
  314. void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw,
  315. struct ieee80211_vif *vif,
  316. struct ieee80211_bss_conf *bss_conf,
  317. u32 changes)
  318. {
  319. struct iwl_priv *priv = hw->priv;
  320. struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
  321. int ret;
  322. if (WARN_ON(!priv->cfg->ops->legacy))
  323. return;
  324. IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
  325. if (!iwl_is_alive(priv))
  326. return;
  327. mutex_lock(&priv->mutex);
  328. if (changes & BSS_CHANGED_QOS) {
  329. unsigned long flags;
  330. spin_lock_irqsave(&priv->lock, flags);
  331. ctx->qos_data.qos_active = bss_conf->qos;
  332. iwl_update_qos(priv, ctx);
  333. spin_unlock_irqrestore(&priv->lock, flags);
  334. }
  335. if (changes & BSS_CHANGED_BEACON_ENABLED) {
  336. /*
  337. * the add_interface code must make sure we only ever
  338. * have a single interface that could be beaconing at
  339. * any time.
  340. */
  341. if (vif->bss_conf.enable_beacon)
  342. priv->beacon_ctx = ctx;
  343. else
  344. priv->beacon_ctx = NULL;
  345. }
  346. if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) {
  347. dev_kfree_skb(priv->beacon_skb);
  348. priv->beacon_skb = ieee80211_beacon_get(hw, vif);
  349. }
  350. if (changes & BSS_CHANGED_BEACON_INT && vif->type == NL80211_IFTYPE_AP)
  351. iwl_send_rxon_timing(priv, ctx);
  352. if (changes & BSS_CHANGED_BSSID) {
  353. IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid);
  354. /*
  355. * If there is currently a HW scan going on in the
  356. * background then we need to cancel it else the RXON
  357. * below/in post_associate will fail.
  358. */
  359. if (iwl_scan_cancel_timeout(priv, 100)) {
  360. IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
  361. IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
  362. mutex_unlock(&priv->mutex);
  363. return;
  364. }
  365. /* mac80211 only sets assoc when in STATION mode */
  366. if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
  367. memcpy(ctx->staging.bssid_addr,
  368. bss_conf->bssid, ETH_ALEN);
  369. /* currently needed in a few places */
  370. memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
  371. } else {
  372. ctx->staging.filter_flags &=
  373. ~RXON_FILTER_ASSOC_MSK;
  374. }
  375. }
  376. /*
  377. * This needs to be after setting the BSSID in case
  378. * mac80211 decides to do both changes at once because
  379. * it will invoke post_associate.
  380. */
  381. if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON)
  382. iwlcore_beacon_update(hw, vif);
  383. if (changes & BSS_CHANGED_ERP_PREAMBLE) {
  384. IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
  385. bss_conf->use_short_preamble);
  386. if (bss_conf->use_short_preamble)
  387. ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
  388. else
  389. ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
  390. }
  391. if (changes & BSS_CHANGED_ERP_CTS_PROT) {
  392. IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
  393. if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
  394. ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
  395. else
  396. ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
  397. if (bss_conf->use_cts_prot)
  398. ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
  399. else
  400. ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
  401. }
  402. if (changes & BSS_CHANGED_BASIC_RATES) {
  403. /* XXX use this information
  404. *
  405. * To do that, remove code from iwl_set_rate() and put something
  406. * like this here:
  407. *
  408. if (A-band)
  409. ctx->staging.ofdm_basic_rates =
  410. bss_conf->basic_rates;
  411. else
  412. ctx->staging.ofdm_basic_rates =
  413. bss_conf->basic_rates >> 4;
  414. ctx->staging.cck_basic_rates =
  415. bss_conf->basic_rates & 0xF;
  416. */
  417. }
  418. if (changes & BSS_CHANGED_HT) {
  419. iwl_ht_conf(priv, vif);
  420. if (priv->cfg->ops->hcmd->set_rxon_chain)
  421. priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
  422. }
  423. if (changes & BSS_CHANGED_ASSOC) {
  424. IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
  425. if (bss_conf->assoc) {
  426. priv->timestamp = bss_conf->timestamp;
  427. if (!iwl_is_rfkill(priv))
  428. priv->cfg->ops->legacy->post_associate(priv);
  429. } else
  430. iwl_set_no_assoc(priv, vif);
  431. }
  432. if (changes && iwl_is_associated_ctx(ctx) && bss_conf->aid) {
  433. IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n",
  434. changes);
  435. ret = iwl_send_rxon_assoc(priv, ctx);
  436. if (!ret) {
  437. /* Sync active_rxon with latest change. */
  438. memcpy((void *)&ctx->active,
  439. &ctx->staging,
  440. sizeof(struct iwl_rxon_cmd));
  441. }
  442. }
  443. if (changes & BSS_CHANGED_BEACON_ENABLED) {
  444. if (vif->bss_conf.enable_beacon) {
  445. memcpy(ctx->staging.bssid_addr,
  446. bss_conf->bssid, ETH_ALEN);
  447. memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
  448. priv->cfg->ops->legacy->config_ap(priv);
  449. } else
  450. iwl_set_no_assoc(priv, vif);
  451. }
  452. if (changes & BSS_CHANGED_IBSS) {
  453. ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif,
  454. bss_conf->ibss_joined);
  455. if (ret)
  456. IWL_ERR(priv, "failed to %s IBSS station %pM\n",
  457. bss_conf->ibss_joined ? "add" : "remove",
  458. bss_conf->bssid);
  459. }
  460. mutex_unlock(&priv->mutex);
  461. IWL_DEBUG_MAC80211(priv, "leave\n");
  462. }
  463. EXPORT_SYMBOL(iwl_legacy_mac_bss_info_changed);
  464. irqreturn_t iwl_isr_legacy(int irq, void *data)
  465. {
  466. struct iwl_priv *priv = data;
  467. u32 inta, inta_mask;
  468. u32 inta_fh;
  469. unsigned long flags;
  470. if (!priv)
  471. return IRQ_NONE;
  472. spin_lock_irqsave(&priv->lock, flags);
  473. /* Disable (but don't clear!) interrupts here to avoid
  474. * back-to-back ISRs and sporadic interrupts from our NIC.
  475. * If we have something to service, the tasklet will re-enable ints.
  476. * If we *don't* have something, we'll re-enable before leaving here. */
  477. inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
  478. iwl_write32(priv, CSR_INT_MASK, 0x00000000);
  479. /* Discover which interrupts are active/pending */
  480. inta = iwl_read32(priv, CSR_INT);
  481. inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
  482. /* Ignore interrupt if there's nothing in NIC to service.
  483. * This may be due to IRQ shared with another device,
  484. * or due to sporadic interrupts thrown from our NIC. */
  485. if (!inta && !inta_fh) {
  486. IWL_DEBUG_ISR(priv,
  487. "Ignore interrupt, inta == 0, inta_fh == 0\n");
  488. goto none;
  489. }
  490. if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
  491. /* Hardware disappeared. It might have already raised
  492. * an interrupt */
  493. IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
  494. goto unplugged;
  495. }
  496. IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
  497. inta, inta_mask, inta_fh);
  498. inta &= ~CSR_INT_BIT_SCD;
  499. /* iwl_irq_tasklet() will service interrupts and re-enable them */
  500. if (likely(inta || inta_fh))
  501. tasklet_schedule(&priv->irq_tasklet);
  502. unplugged:
  503. spin_unlock_irqrestore(&priv->lock, flags);
  504. return IRQ_HANDLED;
  505. none:
  506. /* re-enable interrupts here since we don't have anything to service. */
  507. /* only Re-enable if disabled by irq */
  508. if (test_bit(STATUS_INT_ENABLED, &priv->status))
  509. iwl_enable_interrupts(priv);
  510. spin_unlock_irqrestore(&priv->lock, flags);
  511. return IRQ_NONE;
  512. }
  513. EXPORT_SYMBOL(iwl_isr_legacy);
  514. /*
  515. * iwl_legacy_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this
  516. * function.
  517. */
  518. void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv,
  519. struct ieee80211_tx_info *info,
  520. __le16 fc, __le32 *tx_flags)
  521. {
  522. if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
  523. *tx_flags |= TX_CMD_FLG_RTS_MSK;
  524. *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
  525. *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
  526. if (!ieee80211_is_mgmt(fc))
  527. return;
  528. switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
  529. case cpu_to_le16(IEEE80211_STYPE_AUTH):
  530. case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
  531. case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
  532. case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
  533. *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
  534. *tx_flags |= TX_CMD_FLG_CTS_MSK;
  535. break;
  536. }
  537. } else if (info->control.rates[0].flags &
  538. IEEE80211_TX_RC_USE_CTS_PROTECT) {
  539. *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
  540. *tx_flags |= TX_CMD_FLG_CTS_MSK;
  541. *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
  542. }
  543. }
  544. EXPORT_SYMBOL(iwl_legacy_tx_cmd_protection);