iwl-legacy.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. iwl_led_disassociate(priv);
  277. /*
  278. * inform the ucode that there is no longer an
  279. * association and that no more packets should be
  280. * sent
  281. */
  282. ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  283. ctx->staging.assoc_id = 0;
  284. iwlcore_commit_rxon(priv, ctx);
  285. }
  286. static void iwlcore_beacon_update(struct ieee80211_hw *hw,
  287. struct ieee80211_vif *vif)
  288. {
  289. struct iwl_priv *priv = hw->priv;
  290. unsigned long flags;
  291. __le64 timestamp;
  292. struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
  293. if (!skb)
  294. return;
  295. IWL_DEBUG_MAC80211(priv, "enter\n");
  296. lockdep_assert_held(&priv->mutex);
  297. if (!priv->beacon_ctx) {
  298. IWL_ERR(priv, "update beacon but no beacon context!\n");
  299. dev_kfree_skb(skb);
  300. return;
  301. }
  302. spin_lock_irqsave(&priv->lock, flags);
  303. if (priv->beacon_skb)
  304. dev_kfree_skb(priv->beacon_skb);
  305. priv->beacon_skb = skb;
  306. timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
  307. priv->timestamp = le64_to_cpu(timestamp);
  308. IWL_DEBUG_MAC80211(priv, "leave\n");
  309. spin_unlock_irqrestore(&priv->lock, flags);
  310. if (!iwl_is_ready_rf(priv)) {
  311. IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
  312. return;
  313. }
  314. priv->cfg->ops->legacy->post_associate(priv);
  315. }
  316. void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw,
  317. struct ieee80211_vif *vif,
  318. struct ieee80211_bss_conf *bss_conf,
  319. u32 changes)
  320. {
  321. struct iwl_priv *priv = hw->priv;
  322. struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
  323. int ret;
  324. if (WARN_ON(!priv->cfg->ops->legacy))
  325. return;
  326. IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
  327. if (!iwl_is_alive(priv))
  328. return;
  329. mutex_lock(&priv->mutex);
  330. if (changes & BSS_CHANGED_QOS) {
  331. unsigned long flags;
  332. spin_lock_irqsave(&priv->lock, flags);
  333. ctx->qos_data.qos_active = bss_conf->qos;
  334. iwl_update_qos(priv, ctx);
  335. spin_unlock_irqrestore(&priv->lock, flags);
  336. }
  337. if (changes & BSS_CHANGED_BEACON_ENABLED) {
  338. /*
  339. * the add_interface code must make sure we only ever
  340. * have a single interface that could be beaconing at
  341. * any time.
  342. */
  343. if (vif->bss_conf.enable_beacon)
  344. priv->beacon_ctx = ctx;
  345. else
  346. priv->beacon_ctx = NULL;
  347. }
  348. if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) {
  349. dev_kfree_skb(priv->beacon_skb);
  350. priv->beacon_skb = ieee80211_beacon_get(hw, vif);
  351. }
  352. if (changes & BSS_CHANGED_BEACON_INT && vif->type == NL80211_IFTYPE_AP)
  353. iwl_send_rxon_timing(priv, ctx);
  354. if (changes & BSS_CHANGED_BSSID) {
  355. IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid);
  356. /*
  357. * If there is currently a HW scan going on in the
  358. * background then we need to cancel it else the RXON
  359. * below/in post_associate will fail.
  360. */
  361. if (iwl_scan_cancel_timeout(priv, 100)) {
  362. IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
  363. IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
  364. mutex_unlock(&priv->mutex);
  365. return;
  366. }
  367. /* mac80211 only sets assoc when in STATION mode */
  368. if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
  369. memcpy(ctx->staging.bssid_addr,
  370. bss_conf->bssid, ETH_ALEN);
  371. /* currently needed in a few places */
  372. memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
  373. } else {
  374. ctx->staging.filter_flags &=
  375. ~RXON_FILTER_ASSOC_MSK;
  376. }
  377. }
  378. /*
  379. * This needs to be after setting the BSSID in case
  380. * mac80211 decides to do both changes at once because
  381. * it will invoke post_associate.
  382. */
  383. if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON)
  384. iwlcore_beacon_update(hw, vif);
  385. if (changes & BSS_CHANGED_ERP_PREAMBLE) {
  386. IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
  387. bss_conf->use_short_preamble);
  388. if (bss_conf->use_short_preamble)
  389. ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
  390. else
  391. ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
  392. }
  393. if (changes & BSS_CHANGED_ERP_CTS_PROT) {
  394. IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
  395. if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
  396. ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
  397. else
  398. ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
  399. if (bss_conf->use_cts_prot)
  400. ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
  401. else
  402. ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
  403. }
  404. if (changes & BSS_CHANGED_BASIC_RATES) {
  405. /* XXX use this information
  406. *
  407. * To do that, remove code from iwl_set_rate() and put something
  408. * like this here:
  409. *
  410. if (A-band)
  411. ctx->staging.ofdm_basic_rates =
  412. bss_conf->basic_rates;
  413. else
  414. ctx->staging.ofdm_basic_rates =
  415. bss_conf->basic_rates >> 4;
  416. ctx->staging.cck_basic_rates =
  417. bss_conf->basic_rates & 0xF;
  418. */
  419. }
  420. if (changes & BSS_CHANGED_HT) {
  421. iwl_ht_conf(priv, vif);
  422. if (priv->cfg->ops->hcmd->set_rxon_chain)
  423. priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
  424. }
  425. if (changes & BSS_CHANGED_ASSOC) {
  426. IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
  427. if (bss_conf->assoc) {
  428. priv->timestamp = bss_conf->timestamp;
  429. iwl_led_associate(priv);
  430. if (!iwl_is_rfkill(priv))
  431. priv->cfg->ops->legacy->post_associate(priv);
  432. } else
  433. iwl_set_no_assoc(priv, vif);
  434. }
  435. if (changes && iwl_is_associated_ctx(ctx) && bss_conf->aid) {
  436. IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n",
  437. changes);
  438. ret = iwl_send_rxon_assoc(priv, ctx);
  439. if (!ret) {
  440. /* Sync active_rxon with latest change. */
  441. memcpy((void *)&ctx->active,
  442. &ctx->staging,
  443. sizeof(struct iwl_rxon_cmd));
  444. }
  445. }
  446. if (changes & BSS_CHANGED_BEACON_ENABLED) {
  447. if (vif->bss_conf.enable_beacon) {
  448. memcpy(ctx->staging.bssid_addr,
  449. bss_conf->bssid, ETH_ALEN);
  450. memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
  451. iwl_led_associate(priv);
  452. priv->cfg->ops->legacy->config_ap(priv);
  453. } else
  454. iwl_set_no_assoc(priv, vif);
  455. }
  456. if (changes & BSS_CHANGED_IBSS) {
  457. ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif,
  458. bss_conf->ibss_joined);
  459. if (ret)
  460. IWL_ERR(priv, "failed to %s IBSS station %pM\n",
  461. bss_conf->ibss_joined ? "add" : "remove",
  462. bss_conf->bssid);
  463. }
  464. mutex_unlock(&priv->mutex);
  465. IWL_DEBUG_MAC80211(priv, "leave\n");
  466. }
  467. EXPORT_SYMBOL(iwl_legacy_mac_bss_info_changed);
  468. irqreturn_t iwl_isr_legacy(int irq, void *data)
  469. {
  470. struct iwl_priv *priv = data;
  471. u32 inta, inta_mask;
  472. u32 inta_fh;
  473. unsigned long flags;
  474. if (!priv)
  475. return IRQ_NONE;
  476. spin_lock_irqsave(&priv->lock, flags);
  477. /* Disable (but don't clear!) interrupts here to avoid
  478. * back-to-back ISRs and sporadic interrupts from our NIC.
  479. * If we have something to service, the tasklet will re-enable ints.
  480. * If we *don't* have something, we'll re-enable before leaving here. */
  481. inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
  482. iwl_write32(priv, CSR_INT_MASK, 0x00000000);
  483. /* Discover which interrupts are active/pending */
  484. inta = iwl_read32(priv, CSR_INT);
  485. inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
  486. /* Ignore interrupt if there's nothing in NIC to service.
  487. * This may be due to IRQ shared with another device,
  488. * or due to sporadic interrupts thrown from our NIC. */
  489. if (!inta && !inta_fh) {
  490. IWL_DEBUG_ISR(priv,
  491. "Ignore interrupt, inta == 0, inta_fh == 0\n");
  492. goto none;
  493. }
  494. if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
  495. /* Hardware disappeared. It might have already raised
  496. * an interrupt */
  497. IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
  498. goto unplugged;
  499. }
  500. IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
  501. inta, inta_mask, inta_fh);
  502. inta &= ~CSR_INT_BIT_SCD;
  503. /* iwl_irq_tasklet() will service interrupts and re-enable them */
  504. if (likely(inta || inta_fh))
  505. tasklet_schedule(&priv->irq_tasklet);
  506. unplugged:
  507. spin_unlock_irqrestore(&priv->lock, flags);
  508. return IRQ_HANDLED;
  509. none:
  510. /* re-enable interrupts here since we don't have anything to service. */
  511. /* only Re-enable if diabled by irq */
  512. if (test_bit(STATUS_INT_ENABLED, &priv->status))
  513. iwl_enable_interrupts(priv);
  514. spin_unlock_irqrestore(&priv->lock, flags);
  515. return IRQ_NONE;
  516. }
  517. EXPORT_SYMBOL(iwl_isr_legacy);
  518. /*
  519. * iwl_legacy_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this
  520. * function.
  521. */
  522. void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv,
  523. struct ieee80211_tx_info *info,
  524. __le16 fc, __le32 *tx_flags)
  525. {
  526. if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
  527. *tx_flags |= TX_CMD_FLG_RTS_MSK;
  528. *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
  529. *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
  530. if (!ieee80211_is_mgmt(fc))
  531. return;
  532. switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
  533. case cpu_to_le16(IEEE80211_STYPE_AUTH):
  534. case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
  535. case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
  536. case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
  537. *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
  538. *tx_flags |= TX_CMD_FLG_CTS_MSK;
  539. break;
  540. }
  541. } else if (info->control.rates[0].flags &
  542. IEEE80211_TX_RC_USE_CTS_PROTECT) {
  543. *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
  544. *tx_flags |= TX_CMD_FLG_CTS_MSK;
  545. *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
  546. }
  547. }
  548. EXPORT_SYMBOL(iwl_legacy_tx_cmd_protection);