iwl-agn-rxon.c 19 KB

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