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