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