iwl-agn-rxon.c 18 KB

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