iwl-legacy.c 18 KB

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