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