iwl-legacy.c 18 KB

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