iwl-agn-rxon.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2010 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 Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #include "iwl-dev.h"
  27. #include "iwl-agn.h"
  28. #include "iwl-sta.h"
  29. #include "iwl-core.h"
  30. #include "iwl-agn-calib.h"
  31. static int iwlagn_disable_bss(struct iwl_priv *priv,
  32. struct iwl_rxon_context *ctx,
  33. struct iwl_rxon_cmd *send)
  34. {
  35. __le32 old_filter = send->filter_flags;
  36. int ret;
  37. send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  38. ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, sizeof(*send), send);
  39. send->filter_flags = old_filter;
  40. if (ret)
  41. IWL_ERR(priv, "Error clearing ASSOC_MSK on BSS (%d)\n", ret);
  42. return ret;
  43. }
  44. static int iwlagn_disable_pan(struct iwl_priv *priv,
  45. struct iwl_rxon_context *ctx,
  46. struct iwl_rxon_cmd *send)
  47. {
  48. __le32 old_filter = send->filter_flags;
  49. u8 old_dev_type = send->dev_type;
  50. int ret;
  51. send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  52. send->dev_type = RXON_DEV_TYPE_P2P;
  53. ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd, sizeof(*send), send);
  54. send->filter_flags = old_filter;
  55. send->dev_type = old_dev_type;
  56. if (ret)
  57. IWL_ERR(priv, "Error disabling PAN (%d)\n", ret);
  58. /* FIXME: WAIT FOR PAN DISABLE */
  59. msleep(300);
  60. return ret;
  61. }
  62. static void iwlagn_update_qos(struct iwl_priv *priv,
  63. struct iwl_rxon_context *ctx)
  64. {
  65. int ret;
  66. if (!ctx->is_active)
  67. return;
  68. ctx->qos_data.def_qos_parm.qos_flags = 0;
  69. if (ctx->qos_data.qos_active)
  70. ctx->qos_data.def_qos_parm.qos_flags |=
  71. QOS_PARAM_FLG_UPDATE_EDCA_MSK;
  72. if (ctx->ht.enabled)
  73. ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
  74. IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
  75. ctx->qos_data.qos_active,
  76. ctx->qos_data.def_qos_parm.qos_flags);
  77. ret = iwl_send_cmd_pdu(priv, ctx->qos_cmd,
  78. sizeof(struct iwl_qosparam_cmd),
  79. &ctx->qos_data.def_qos_parm);
  80. if (ret)
  81. IWL_ERR(priv, "Failed to update QoS\n");
  82. }
  83. static int iwlagn_update_beacon(struct iwl_priv *priv,
  84. struct ieee80211_vif *vif)
  85. {
  86. lockdep_assert_held(&priv->mutex);
  87. dev_kfree_skb(priv->beacon_skb);
  88. priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif);
  89. if (!priv->beacon_skb)
  90. return -ENOMEM;
  91. return iwlagn_send_beacon_cmd(priv);
  92. }
  93. /**
  94. * iwlagn_commit_rxon - commit staging_rxon to hardware
  95. *
  96. * The RXON command in staging_rxon is committed to the hardware and
  97. * the active_rxon structure is updated with the new data. This
  98. * function correctly transitions out of the RXON_ASSOC_MSK state if
  99. * a HW tune is required based on the RXON structure changes.
  100. */
  101. int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
  102. {
  103. /* cast away the const for active_rxon in this function */
  104. struct iwl_rxon_cmd *active = (void *)&ctx->active;
  105. bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
  106. bool old_assoc = !!(ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK);
  107. int ret;
  108. lockdep_assert_held(&priv->mutex);
  109. if (test_bit(STATUS_EXIT_PENDING, &priv->status))
  110. return -EINVAL;
  111. if (!iwl_is_alive(priv))
  112. return -EBUSY;
  113. /* This function hardcodes a bunch of dual-mode assumptions */
  114. BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
  115. if (!ctx->is_active)
  116. return 0;
  117. /* always get timestamp with Rx frame */
  118. ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
  119. if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
  120. !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK))
  121. ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
  122. else
  123. ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
  124. ret = iwl_check_rxon_cmd(priv, ctx);
  125. if (ret) {
  126. IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
  127. return -EINVAL;
  128. }
  129. /*
  130. * receive commit_rxon request
  131. * abort any previous channel switch if still in process
  132. */
  133. if (priv->switch_rxon.switch_in_progress &&
  134. (priv->switch_rxon.channel != ctx->staging.channel)) {
  135. IWL_DEBUG_11H(priv, "abort channel switch on %d\n",
  136. le16_to_cpu(priv->switch_rxon.channel));
  137. iwl_chswitch_done(priv, false);
  138. }
  139. /*
  140. * If we don't need to send a full RXON, we can use
  141. * iwl_rxon_assoc_cmd which is used to reconfigure filter
  142. * and other flags for the current radio configuration.
  143. */
  144. if (!iwl_full_rxon_required(priv, ctx)) {
  145. ret = iwl_send_rxon_assoc(priv, ctx);
  146. if (ret) {
  147. IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret);
  148. return ret;
  149. }
  150. memcpy(active, &ctx->staging, sizeof(*active));
  151. iwl_print_rx_config_cmd(priv, ctx);
  152. return 0;
  153. }
  154. if (priv->cfg->ops->hcmd->set_pan_params) {
  155. ret = priv->cfg->ops->hcmd->set_pan_params(priv);
  156. if (ret)
  157. return ret;
  158. }
  159. iwl_set_rxon_hwcrypto(priv, ctx, !priv->cfg->mod_params->sw_crypto);
  160. IWL_DEBUG_INFO(priv,
  161. "Going to commit RXON\n"
  162. " * with%s RXON_FILTER_ASSOC_MSK\n"
  163. " * channel = %d\n"
  164. " * bssid = %pM\n",
  165. (new_assoc ? "" : "out"),
  166. le16_to_cpu(ctx->staging.channel),
  167. ctx->staging.bssid_addr);
  168. /*
  169. * Always clear associated first, but with the correct config.
  170. * This is required as for example station addition for the
  171. * AP station must be done after the BSSID is set to correctly
  172. * set up filters in the device.
  173. */
  174. if ((old_assoc && new_assoc) || !new_assoc) {
  175. if (ctx->ctxid == IWL_RXON_CTX_BSS)
  176. ret = iwlagn_disable_bss(priv, ctx, &ctx->staging);
  177. else
  178. ret = iwlagn_disable_pan(priv, ctx, &ctx->staging);
  179. if (ret)
  180. return ret;
  181. memcpy(active, &ctx->staging, sizeof(*active));
  182. /*
  183. * Un-assoc RXON clears the station table and WEP
  184. * keys, so we have to restore those afterwards.
  185. */
  186. iwl_clear_ucode_stations(priv, ctx);
  187. iwl_restore_stations(priv, ctx);
  188. ret = iwl_restore_default_wep_keys(priv, ctx);
  189. if (ret) {
  190. IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
  191. return ret;
  192. }
  193. }
  194. /* RXON timing must be before associated RXON */
  195. ret = iwl_send_rxon_timing(priv, ctx);
  196. if (ret) {
  197. IWL_ERR(priv, "Failed to send timing (%d)!\n", ret);
  198. return ret;
  199. }
  200. if (new_assoc) {
  201. /* QoS info may be cleared by previous un-assoc RXON */
  202. iwlagn_update_qos(priv, ctx);
  203. /*
  204. * We'll run into this code path when beaconing is
  205. * enabled, but then we also need to send the beacon
  206. * to the device.
  207. */
  208. if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) {
  209. ret = iwlagn_update_beacon(priv, ctx->vif);
  210. if (ret) {
  211. IWL_ERR(priv,
  212. "Error sending required beacon (%d)!\n",
  213. ret);
  214. return ret;
  215. }
  216. }
  217. priv->start_calib = 0;
  218. /*
  219. * Apply the new configuration.
  220. *
  221. * Associated RXON doesn't clear the station table in uCode,
  222. * so we don't need to restore stations etc. after this.
  223. */
  224. ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
  225. sizeof(struct iwl_rxon_cmd), &ctx->staging);
  226. if (ret) {
  227. IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
  228. return ret;
  229. }
  230. memcpy(active, &ctx->staging, sizeof(*active));
  231. iwl_reprogram_ap_sta(priv, ctx);
  232. /* IBSS beacon needs to be sent after setting assoc */
  233. if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC))
  234. if (iwlagn_update_beacon(priv, ctx->vif))
  235. IWL_ERR(priv, "Error sending IBSS beacon\n");
  236. }
  237. iwl_print_rx_config_cmd(priv, ctx);
  238. iwl_init_sensitivity(priv);
  239. /*
  240. * If we issue a new RXON command which required a tune then we must
  241. * send a new TXPOWER command or we won't be able to Tx any frames.
  242. *
  243. * FIXME: which RXON requires a tune? Can we optimise this out in
  244. * some cases?
  245. */
  246. ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
  247. if (ret) {
  248. IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
  249. return ret;
  250. }
  251. return 0;
  252. }
  253. int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
  254. {
  255. struct iwl_priv *priv = hw->priv;
  256. struct iwl_rxon_context *ctx;
  257. struct ieee80211_conf *conf = &hw->conf;
  258. struct ieee80211_channel *channel = conf->channel;
  259. const struct iwl_channel_info *ch_info;
  260. int ret = 0;
  261. bool ht_changed[NUM_IWL_RXON_CTX] = {};
  262. IWL_DEBUG_MAC80211(priv, "changed %#x", changed);
  263. mutex_lock(&priv->mutex);
  264. if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) {
  265. IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
  266. goto out;
  267. }
  268. if (!iwl_is_ready(priv)) {
  269. IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
  270. goto out;
  271. }
  272. if (changed & (IEEE80211_CONF_CHANGE_SMPS |
  273. IEEE80211_CONF_CHANGE_CHANNEL)) {
  274. /* mac80211 uses static for non-HT which is what we want */
  275. priv->current_ht_config.smps = conf->smps_mode;
  276. /*
  277. * Recalculate chain counts.
  278. *
  279. * If monitor mode is enabled then mac80211 will
  280. * set up the SM PS mode to OFF if an HT channel is
  281. * configured.
  282. */
  283. if (priv->cfg->ops->hcmd->set_rxon_chain)
  284. for_each_context(priv, ctx)
  285. priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
  286. }
  287. if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  288. unsigned long flags;
  289. ch_info = iwl_get_channel_info(priv, channel->band,
  290. channel->hw_value);
  291. if (!is_channel_valid(ch_info)) {
  292. IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
  293. ret = -EINVAL;
  294. goto out;
  295. }
  296. spin_lock_irqsave(&priv->lock, flags);
  297. for_each_context(priv, ctx) {
  298. /* Configure HT40 channels */
  299. if (ctx->ht.enabled != conf_is_ht(conf)) {
  300. ctx->ht.enabled = conf_is_ht(conf);
  301. ht_changed[ctx->ctxid] = true;
  302. }
  303. if (ctx->ht.enabled) {
  304. if (conf_is_ht40_minus(conf)) {
  305. ctx->ht.extension_chan_offset =
  306. IEEE80211_HT_PARAM_CHA_SEC_BELOW;
  307. ctx->ht.is_40mhz = true;
  308. } else if (conf_is_ht40_plus(conf)) {
  309. ctx->ht.extension_chan_offset =
  310. IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
  311. ctx->ht.is_40mhz = true;
  312. } else {
  313. ctx->ht.extension_chan_offset =
  314. IEEE80211_HT_PARAM_CHA_SEC_NONE;
  315. ctx->ht.is_40mhz = false;
  316. }
  317. } else
  318. ctx->ht.is_40mhz = false;
  319. /*
  320. * Default to no protection. Protection mode will
  321. * later be set from BSS config in iwl_ht_conf
  322. */
  323. ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
  324. /* if we are switching from ht to 2.4 clear flags
  325. * from any ht related info since 2.4 does not
  326. * support ht */
  327. if (le16_to_cpu(ctx->staging.channel) !=
  328. channel->hw_value)
  329. ctx->staging.flags = 0;
  330. iwl_set_rxon_channel(priv, channel, ctx);
  331. iwl_set_rxon_ht(priv, &priv->current_ht_config);
  332. iwl_set_flags_for_band(priv, ctx, channel->band,
  333. ctx->vif);
  334. }
  335. spin_unlock_irqrestore(&priv->lock, flags);
  336. iwl_update_bcast_stations(priv);
  337. /*
  338. * The list of supported rates and rate mask can be different
  339. * for each band; since the band may have changed, reset
  340. * the rate mask to what mac80211 lists.
  341. */
  342. iwl_set_rate(priv);
  343. }
  344. if (changed & (IEEE80211_CONF_CHANGE_PS |
  345. IEEE80211_CONF_CHANGE_IDLE)) {
  346. ret = iwl_power_update_mode(priv, false);
  347. if (ret)
  348. IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n");
  349. }
  350. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  351. IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
  352. priv->tx_power_user_lmt, conf->power_level);
  353. iwl_set_tx_power(priv, conf->power_level, false);
  354. }
  355. for_each_context(priv, ctx) {
  356. if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
  357. continue;
  358. iwlagn_commit_rxon(priv, ctx);
  359. if (ht_changed[ctx->ctxid])
  360. iwlagn_update_qos(priv, ctx);
  361. }
  362. out:
  363. mutex_unlock(&priv->mutex);
  364. return ret;
  365. }
  366. static void iwlagn_check_needed_chains(struct iwl_priv *priv,
  367. struct iwl_rxon_context *ctx,
  368. struct ieee80211_bss_conf *bss_conf)
  369. {
  370. struct ieee80211_vif *vif = ctx->vif;
  371. struct iwl_rxon_context *tmp;
  372. struct ieee80211_sta *sta;
  373. struct iwl_ht_config *ht_conf = &priv->current_ht_config;
  374. bool need_multiple;
  375. lockdep_assert_held(&priv->mutex);
  376. switch (vif->type) {
  377. case NL80211_IFTYPE_STATION:
  378. rcu_read_lock();
  379. sta = ieee80211_find_sta(vif, bss_conf->bssid);
  380. if (sta) {
  381. struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
  382. int maxstreams;
  383. maxstreams = (ht_cap->mcs.tx_params &
  384. IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
  385. >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
  386. maxstreams += 1;
  387. need_multiple = true;
  388. if ((ht_cap->mcs.rx_mask[1] == 0) &&
  389. (ht_cap->mcs.rx_mask[2] == 0))
  390. need_multiple = false;
  391. if (maxstreams <= 1)
  392. need_multiple = false;
  393. } else {
  394. /*
  395. * If at all, this can only happen through a race
  396. * when the AP disconnects us while we're still
  397. * setting up the connection, in that case mac80211
  398. * will soon tell us about that.
  399. */
  400. need_multiple = false;
  401. }
  402. rcu_read_unlock();
  403. break;
  404. case NL80211_IFTYPE_ADHOC:
  405. /* currently */
  406. need_multiple = false;
  407. break;
  408. default:
  409. /* only AP really */
  410. need_multiple = true;
  411. break;
  412. }
  413. ctx->ht_need_multiple_chains = need_multiple;
  414. if (!need_multiple) {
  415. /* check all contexts */
  416. for_each_context(priv, tmp) {
  417. if (!tmp->vif)
  418. continue;
  419. if (tmp->ht_need_multiple_chains) {
  420. need_multiple = true;
  421. break;
  422. }
  423. }
  424. }
  425. ht_conf->single_chain_sufficient = !need_multiple;
  426. }
  427. void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
  428. struct ieee80211_vif *vif,
  429. struct ieee80211_bss_conf *bss_conf,
  430. u32 changes)
  431. {
  432. struct iwl_priv *priv = hw->priv;
  433. struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
  434. int ret;
  435. bool force = false;
  436. mutex_lock(&priv->mutex);
  437. if (WARN_ON(!ctx->vif)) {
  438. mutex_unlock(&priv->mutex);
  439. return;
  440. }
  441. if (changes & BSS_CHANGED_BEACON_INT)
  442. force = true;
  443. if (changes & BSS_CHANGED_QOS) {
  444. ctx->qos_data.qos_active = bss_conf->qos;
  445. iwlagn_update_qos(priv, ctx);
  446. }
  447. ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
  448. if (vif->bss_conf.use_short_preamble)
  449. ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
  450. else
  451. ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
  452. if (changes & BSS_CHANGED_ASSOC) {
  453. if (bss_conf->assoc) {
  454. iwl_led_associate(priv);
  455. priv->timestamp = bss_conf->timestamp;
  456. ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
  457. } else {
  458. ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  459. iwl_led_disassociate(priv);
  460. }
  461. }
  462. if (ctx->ht.enabled) {
  463. ctx->ht.protection = bss_conf->ht_operation_mode &
  464. IEEE80211_HT_OP_MODE_PROTECTION;
  465. ctx->ht.non_gf_sta_present = !!(bss_conf->ht_operation_mode &
  466. IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  467. iwlagn_check_needed_chains(priv, ctx, bss_conf);
  468. iwl_set_rxon_ht(priv, &priv->current_ht_config);
  469. }
  470. if (priv->cfg->ops->hcmd->set_rxon_chain)
  471. priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
  472. if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
  473. ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
  474. else
  475. ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
  476. if (bss_conf->use_cts_prot)
  477. ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
  478. else
  479. ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
  480. memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN);
  481. if (vif->type == NL80211_IFTYPE_AP ||
  482. vif->type == NL80211_IFTYPE_ADHOC) {
  483. if (vif->bss_conf.enable_beacon) {
  484. ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
  485. priv->beacon_ctx = ctx;
  486. } else {
  487. ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  488. priv->beacon_ctx = NULL;
  489. }
  490. }
  491. if (force || memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
  492. iwlagn_commit_rxon(priv, ctx);
  493. if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) {
  494. /*
  495. * The chain noise calibration will enable PM upon
  496. * completion. If calibration has already been run
  497. * then we need to enable power management here.
  498. */
  499. if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE)
  500. iwl_power_update_mode(priv, false);
  501. /* Enable RX differential gain and sensitivity calibrations */
  502. iwl_chain_noise_reset(priv);
  503. priv->start_calib = 1;
  504. }
  505. if (changes & BSS_CHANGED_IBSS) {
  506. ret = iwlagn_manage_ibss_station(priv, vif,
  507. bss_conf->ibss_joined);
  508. if (ret)
  509. IWL_ERR(priv, "failed to %s IBSS station %pM\n",
  510. bss_conf->ibss_joined ? "add" : "remove",
  511. bss_conf->bssid);
  512. }
  513. if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_ADHOC &&
  514. priv->beacon_ctx) {
  515. if (iwlagn_update_beacon(priv, vif))
  516. IWL_ERR(priv, "Error sending IBSS beacon\n");
  517. }
  518. mutex_unlock(&priv->mutex);
  519. }
  520. void iwlagn_post_scan(struct iwl_priv *priv)
  521. {
  522. struct iwl_rxon_context *ctx;
  523. /*
  524. * Since setting the RXON may have been deferred while
  525. * performing the scan, fire one off if needed
  526. */
  527. for_each_context(priv, ctx)
  528. if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
  529. iwlagn_commit_rxon(priv, ctx);
  530. if (priv->cfg->ops->hcmd->set_pan_params)
  531. priv->cfg->ops->hcmd->set_pan_params(priv);
  532. }