iwl-agn-rxon.c 19 KB

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