blob: 18776ab441482b9a2bd3f068cb61b773cc67077d [file] [log] [blame]
Johannes Berg2295c662010-10-23 09:15:41 -07001/******************************************************************************
2 *
Wey-Yi Guyfb4961d2012-01-06 13:16:33 -08003 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
Johannes Berg2295c662010-10-23 09:15:41 -07004 *
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
Meenakshi Venkataraman55620922012-03-15 13:27:02 -070027#include <linux/etherdevice.h>
Johannes Berg2295c662010-10-23 09:15:41 -070028#include "iwl-dev.h"
29#include "iwl-agn.h"
Johannes Berg2295c662010-10-23 09:15:41 -070030#include "iwl-core.h"
31#include "iwl-agn-calib.h"
Emmanuel Grumbachbdfbf092011-07-08 08:46:16 -070032#include "iwl-trans.h"
Emmanuel Grumbach48f20d32011-08-25 23:10:36 -070033#include "iwl-shared.h"
Johannes Berg2295c662010-10-23 09:15:41 -070034
Meenakshi Venkataraman47042ac2012-03-13 17:07:48 -070035/*
36 * initialize rxon structure with default values from eeprom
37 */
38void iwl_connection_init_rx_config(struct iwl_priv *priv,
39 struct iwl_rxon_context *ctx)
40{
41 const struct iwl_channel_info *ch_info;
42
43 memset(&ctx->staging, 0, sizeof(ctx->staging));
44
45 if (!ctx->vif) {
46 ctx->staging.dev_type = ctx->unused_devtype;
47 } else
48 switch (ctx->vif->type) {
49 case NL80211_IFTYPE_AP:
50 ctx->staging.dev_type = ctx->ap_devtype;
51 break;
52
53 case NL80211_IFTYPE_STATION:
54 ctx->staging.dev_type = ctx->station_devtype;
55 ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
56 break;
57
58 case NL80211_IFTYPE_ADHOC:
59 ctx->staging.dev_type = ctx->ibss_devtype;
60 ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
61 ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
62 RXON_FILTER_ACCEPT_GRP_MSK;
63 break;
64
65 default:
66 IWL_ERR(priv, "Unsupported interface type %d\n",
67 ctx->vif->type);
68 break;
69 }
70
71#if 0
72 /* TODO: Figure out when short_preamble would be set and cache from
73 * that */
74 if (!hw_to_local(priv->hw)->short_preamble)
75 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
76 else
77 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
78#endif
79
80 ch_info = iwl_get_channel_info(priv, priv->band,
81 le16_to_cpu(ctx->active.channel));
82
83 if (!ch_info)
84 ch_info = &priv->channel_info[0];
85
86 ctx->staging.channel = cpu_to_le16(ch_info->channel);
87 priv->band = ch_info->band;
88
89 iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif);
90
91 ctx->staging.ofdm_basic_rates =
92 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
93 ctx->staging.cck_basic_rates =
94 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
95
96 /* clear both MIX and PURE40 mode flag */
97 ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED |
98 RXON_FLG_CHANNEL_MODE_PURE_40);
99 if (ctx->vif)
100 memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN);
101
102 ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff;
103 ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff;
104 ctx->staging.ofdm_ht_triple_stream_basic_rates = 0xff;
105}
106
Johannes Berg2295c662010-10-23 09:15:41 -0700107static int iwlagn_disable_bss(struct iwl_priv *priv,
108 struct iwl_rxon_context *ctx,
109 struct iwl_rxon_cmd *send)
110{
111 __le32 old_filter = send->filter_flags;
112 int ret;
113
114 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
Johannes Berge10a0532012-03-06 13:30:39 -0800115 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd,
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700116 CMD_SYNC, sizeof(*send), send);
Johannes Berg2295c662010-10-23 09:15:41 -0700117
118 send->filter_flags = old_filter;
119
120 if (ret)
Todd Previteb36b1102011-11-10 06:55:02 -0800121 IWL_DEBUG_QUIET_RFKILL(priv,
122 "Error clearing ASSOC_MSK on BSS (%d)\n", ret);
Johannes Berg2295c662010-10-23 09:15:41 -0700123
124 return ret;
125}
126
127static int iwlagn_disable_pan(struct iwl_priv *priv,
128 struct iwl_rxon_context *ctx,
129 struct iwl_rxon_cmd *send)
130{
Johannes Berg311dce72011-01-04 16:22:01 -0800131 struct iwl_notification_wait disable_wait;
Johannes Berg2295c662010-10-23 09:15:41 -0700132 __le32 old_filter = send->filter_flags;
133 u8 old_dev_type = send->dev_type;
134 int ret;
Johannes Bergdb662d42012-03-15 13:26:44 -0700135 static const u8 deactivate_cmd[] = {
136 REPLY_WIPAN_DEACTIVATION_COMPLETE
137 };
Johannes Berg2295c662010-10-23 09:15:41 -0700138
Johannes Berg4bd14dd2012-03-06 13:30:58 -0800139 iwl_init_notification_wait(&priv->notif_wait, &disable_wait,
Johannes Bergdb662d42012-03-15 13:26:44 -0700140 deactivate_cmd, ARRAY_SIZE(deactivate_cmd),
Johannes Berg4bd14dd2012-03-06 13:30:58 -0800141 NULL, NULL);
Johannes Berg311dce72011-01-04 16:22:01 -0800142
Johannes Berg2295c662010-10-23 09:15:41 -0700143 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
144 send->dev_type = RXON_DEV_TYPE_P2P;
Johannes Berge10a0532012-03-06 13:30:39 -0800145 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd,
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700146 CMD_SYNC, sizeof(*send), send);
Johannes Berg2295c662010-10-23 09:15:41 -0700147
148 send->filter_flags = old_filter;
149 send->dev_type = old_dev_type;
150
Johannes Berg311dce72011-01-04 16:22:01 -0800151 if (ret) {
Johannes Berg2295c662010-10-23 09:15:41 -0700152 IWL_ERR(priv, "Error disabling PAN (%d)\n", ret);
Johannes Berg4bd14dd2012-03-06 13:30:58 -0800153 iwl_remove_notification(&priv->notif_wait, &disable_wait);
Johannes Berg311dce72011-01-04 16:22:01 -0800154 } else {
Johannes Berg4bd14dd2012-03-06 13:30:58 -0800155 ret = iwl_wait_notification(&priv->notif_wait,
156 &disable_wait, HZ);
Johannes Berga8674a12011-04-13 03:14:48 -0700157 if (ret)
Johannes Berg311dce72011-01-04 16:22:01 -0800158 IWL_ERR(priv, "Timed out waiting for PAN disable\n");
159 }
Johannes Berg2295c662010-10-23 09:15:41 -0700160
161 return ret;
162}
163
Johannes Berg2b9253d2011-05-27 08:40:26 -0700164static int iwlagn_disconn_pan(struct iwl_priv *priv,
165 struct iwl_rxon_context *ctx,
166 struct iwl_rxon_cmd *send)
167{
168 __le32 old_filter = send->filter_flags;
169 int ret;
170
171 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
Johannes Berge10a0532012-03-06 13:30:39 -0800172 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700173 sizeof(*send), send);
Johannes Berg2b9253d2011-05-27 08:40:26 -0700174
175 send->filter_flags = old_filter;
176
177 return ret;
178}
179
Shanyu Zhaof4115d42010-11-10 18:25:58 -0800180static void iwlagn_update_qos(struct iwl_priv *priv,
181 struct iwl_rxon_context *ctx)
182{
183 int ret;
184
185 if (!ctx->is_active)
186 return;
187
188 ctx->qos_data.def_qos_parm.qos_flags = 0;
189
190 if (ctx->qos_data.qos_active)
191 ctx->qos_data.def_qos_parm.qos_flags |=
192 QOS_PARAM_FLG_UPDATE_EDCA_MSK;
193
194 if (ctx->ht.enabled)
195 ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
196
Emmanuel Grumbach0dcf50c2011-11-10 06:55:23 -0800197 IWL_DEBUG_INFO(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
Shanyu Zhaof4115d42010-11-10 18:25:58 -0800198 ctx->qos_data.qos_active,
199 ctx->qos_data.def_qos_parm.qos_flags);
200
Johannes Berge10a0532012-03-06 13:30:39 -0800201 ret = iwl_dvm_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC,
Shanyu Zhaof4115d42010-11-10 18:25:58 -0800202 sizeof(struct iwl_qosparam_cmd),
203 &ctx->qos_data.def_qos_parm);
204 if (ret)
Todd Previteb36b1102011-11-10 06:55:02 -0800205 IWL_DEBUG_QUIET_RFKILL(priv, "Failed to update QoS\n");
Shanyu Zhaof4115d42010-11-10 18:25:58 -0800206}
207
Johannes Bergbd50a8ab2010-10-23 09:15:42 -0700208static int iwlagn_update_beacon(struct iwl_priv *priv,
209 struct ieee80211_vif *vif)
210{
Johannes Bergb1eea292012-03-06 13:30:42 -0800211 lockdep_assert_held(&priv->mutex);
Johannes Bergbd50a8ab2010-10-23 09:15:42 -0700212
213 dev_kfree_skb(priv->beacon_skb);
214 priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif);
215 if (!priv->beacon_skb)
216 return -ENOMEM;
217 return iwlagn_send_beacon_cmd(priv);
218}
219
Wey-Yi Guyc3f6e9c2011-04-19 16:52:57 -0700220static int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
221 struct iwl_rxon_context *ctx)
222{
223 int ret = 0;
Wey-Yi Guy89e746b2011-04-19 16:52:58 -0700224 struct iwl_rxon_assoc_cmd rxon_assoc;
Wey-Yi Guyc3f6e9c2011-04-19 16:52:57 -0700225 const struct iwl_rxon_cmd *rxon1 = &ctx->staging;
226 const struct iwl_rxon_cmd *rxon2 = &ctx->active;
227
228 if ((rxon1->flags == rxon2->flags) &&
229 (rxon1->filter_flags == rxon2->filter_flags) &&
230 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
231 (rxon1->ofdm_ht_single_stream_basic_rates ==
232 rxon2->ofdm_ht_single_stream_basic_rates) &&
233 (rxon1->ofdm_ht_dual_stream_basic_rates ==
234 rxon2->ofdm_ht_dual_stream_basic_rates) &&
235 (rxon1->ofdm_ht_triple_stream_basic_rates ==
236 rxon2->ofdm_ht_triple_stream_basic_rates) &&
237 (rxon1->acquisition_data == rxon2->acquisition_data) &&
238 (rxon1->rx_chain == rxon2->rx_chain) &&
239 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
240 IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
241 return 0;
242 }
243
244 rxon_assoc.flags = ctx->staging.flags;
245 rxon_assoc.filter_flags = ctx->staging.filter_flags;
246 rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates;
247 rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates;
248 rxon_assoc.reserved1 = 0;
249 rxon_assoc.reserved2 = 0;
250 rxon_assoc.reserved3 = 0;
251 rxon_assoc.ofdm_ht_single_stream_basic_rates =
252 ctx->staging.ofdm_ht_single_stream_basic_rates;
253 rxon_assoc.ofdm_ht_dual_stream_basic_rates =
254 ctx->staging.ofdm_ht_dual_stream_basic_rates;
255 rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain;
256 rxon_assoc.ofdm_ht_triple_stream_basic_rates =
257 ctx->staging.ofdm_ht_triple_stream_basic_rates;
258 rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
259
Johannes Berge10a0532012-03-06 13:30:39 -0800260 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_assoc_cmd,
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700261 CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc);
Wey-Yi Guyc3f6e9c2011-04-19 16:52:57 -0700262 return ret;
263}
264
Meenakshi Venkataramandff96c12012-03-15 13:26:59 -0700265static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
266{
267 u16 new_val;
268 u16 beacon_factor;
269
270 /*
271 * If mac80211 hasn't given us a beacon interval, program
272 * the default into the device (not checking this here
273 * would cause the adjustment below to return the maximum
274 * value, which may break PAN.)
275 */
276 if (!beacon_val)
277 return DEFAULT_BEACON_INTERVAL;
278
279 /*
280 * If the beacon interval we obtained from the peer
281 * is too large, we'll have to wake up more often
282 * (and in IBSS case, we'll beacon too much)
283 *
284 * For example, if max_beacon_val is 4096, and the
285 * requested beacon interval is 7000, we'll have to
286 * use 3500 to be able to wake up on the beacons.
287 *
288 * This could badly influence beacon detection stats.
289 */
290
291 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
292 new_val = beacon_val / beacon_factor;
293
294 if (!new_val)
295 new_val = max_beacon_val;
296
297 return new_val;
298}
299
300static int iwl_send_rxon_timing(struct iwl_priv *priv,
301 struct iwl_rxon_context *ctx)
302{
303 u64 tsf;
304 s32 interval_tm, rem;
305 struct ieee80211_conf *conf = NULL;
306 u16 beacon_int;
307 struct ieee80211_vif *vif = ctx->vif;
308
309 conf = &priv->hw->conf;
310
311 lockdep_assert_held(&priv->mutex);
312
313 memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd));
314
315 ctx->timing.timestamp = cpu_to_le64(priv->timestamp);
316 ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval);
317
318 beacon_int = vif ? vif->bss_conf.beacon_int : 0;
319
320 /*
321 * TODO: For IBSS we need to get atim_window from mac80211,
322 * for now just always use 0
323 */
324 ctx->timing.atim_window = 0;
325
326 if (ctx->ctxid == IWL_RXON_CTX_PAN &&
327 (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION) &&
328 iwl_is_associated(priv, IWL_RXON_CTX_BSS) &&
329 priv->contexts[IWL_RXON_CTX_BSS].vif &&
330 priv->contexts[IWL_RXON_CTX_BSS].vif->bss_conf.beacon_int) {
331 ctx->timing.beacon_interval =
332 priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval;
333 beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
334 } else if (ctx->ctxid == IWL_RXON_CTX_BSS &&
335 iwl_is_associated(priv, IWL_RXON_CTX_PAN) &&
336 priv->contexts[IWL_RXON_CTX_PAN].vif &&
337 priv->contexts[IWL_RXON_CTX_PAN].vif->bss_conf.beacon_int &&
338 (!iwl_is_associated_ctx(ctx) || !ctx->vif ||
339 !ctx->vif->bss_conf.beacon_int)) {
340 ctx->timing.beacon_interval =
341 priv->contexts[IWL_RXON_CTX_PAN].timing.beacon_interval;
342 beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
343 } else {
344 beacon_int = iwl_adjust_beacon_interval(beacon_int,
345 IWL_MAX_UCODE_BEACON_INTERVAL * TIME_UNIT);
346 ctx->timing.beacon_interval = cpu_to_le16(beacon_int);
347 }
348
349 ctx->beacon_int = beacon_int;
350
351 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
352 interval_tm = beacon_int * TIME_UNIT;
353 rem = do_div(tsf, interval_tm);
354 ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
355
356 ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1;
357
358 IWL_DEBUG_ASSOC(priv,
359 "beacon interval %d beacon timer %d beacon tim %d\n",
360 le16_to_cpu(ctx->timing.beacon_interval),
361 le32_to_cpu(ctx->timing.beacon_init_val),
362 le16_to_cpu(ctx->timing.atim_window));
363
364 return iwl_dvm_send_cmd_pdu(priv, ctx->rxon_timing_cmd,
365 CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
366}
367
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700368static int iwlagn_rxon_disconn(struct iwl_priv *priv,
369 struct iwl_rxon_context *ctx)
370{
371 int ret;
372 struct iwl_rxon_cmd *active = (void *)&ctx->active;
373
Johannes Berg2b9253d2011-05-27 08:40:26 -0700374 if (ctx->ctxid == IWL_RXON_CTX_BSS) {
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700375 ret = iwlagn_disable_bss(priv, ctx, &ctx->staging);
Johannes Berg2b9253d2011-05-27 08:40:26 -0700376 } else {
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700377 ret = iwlagn_disable_pan(priv, ctx, &ctx->staging);
Johannes Berg2b9253d2011-05-27 08:40:26 -0700378 if (ret)
379 return ret;
380 if (ctx->vif) {
381 ret = iwl_send_rxon_timing(priv, ctx);
382 if (ret) {
383 IWL_ERR(priv, "Failed to send timing (%d)!\n", ret);
384 return ret;
385 }
386 ret = iwlagn_disconn_pan(priv, ctx, &ctx->staging);
387 }
388 }
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700389 if (ret)
390 return ret;
391
392 /*
393 * Un-assoc RXON clears the station table and WEP
394 * keys, so we have to restore those afterwards.
395 */
396 iwl_clear_ucode_stations(priv, ctx);
Johannes Bergf775aa06d2011-06-22 06:34:09 -0700397 /* update -- might need P2P now */
398 iwl_update_bcast_station(priv, ctx);
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700399 iwl_restore_stations(priv, ctx);
400 ret = iwl_restore_default_wep_keys(priv, ctx);
401 if (ret) {
402 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
403 return ret;
404 }
405
406 memcpy(active, &ctx->staging, sizeof(*active));
407 return 0;
408}
409
410static int iwlagn_rxon_connect(struct iwl_priv *priv,
411 struct iwl_rxon_context *ctx)
412{
413 int ret;
414 struct iwl_rxon_cmd *active = (void *)&ctx->active;
415
416 /* RXON timing must be before associated RXON */
Johannes Berg2b9253d2011-05-27 08:40:26 -0700417 if (ctx->ctxid == IWL_RXON_CTX_BSS) {
418 ret = iwl_send_rxon_timing(priv, ctx);
419 if (ret) {
420 IWL_ERR(priv, "Failed to send timing (%d)!\n", ret);
421 return ret;
422 }
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700423 }
424 /* QoS info may be cleared by previous un-assoc RXON */
425 iwlagn_update_qos(priv, ctx);
426
427 /*
428 * We'll run into this code path when beaconing is
429 * enabled, but then we also need to send the beacon
430 * to the device.
431 */
432 if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) {
433 ret = iwlagn_update_beacon(priv, ctx->vif);
434 if (ret) {
435 IWL_ERR(priv,
436 "Error sending required beacon (%d)!\n",
437 ret);
438 return ret;
439 }
440 }
441
442 priv->start_calib = 0;
443 /*
444 * Apply the new configuration.
445 *
446 * Associated RXON doesn't clear the station table in uCode,
447 * so we don't need to restore stations etc. after this.
448 */
Johannes Berge10a0532012-03-06 13:30:39 -0800449 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700450 sizeof(struct iwl_rxon_cmd), &ctx->staging);
451 if (ret) {
452 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
453 return ret;
454 }
455 memcpy(active, &ctx->staging, sizeof(*active));
456
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700457 /* IBSS beacon needs to be sent after setting assoc */
458 if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC))
459 if (iwlagn_update_beacon(priv, ctx->vif))
460 IWL_ERR(priv, "Error sending IBSS beacon\n");
461 iwl_init_sensitivity(priv);
462
463 /*
464 * If we issue a new RXON command which required a tune then
465 * we must send a new TXPOWER command or we won't be able to
466 * Tx any frames.
467 *
468 * It's expected we set power here if channel is changing.
469 */
470 ret = iwl_set_tx_power(priv, priv->tx_power_next, true);
471 if (ret) {
472 IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
473 return ret;
474 }
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700475
Stanislaw Gruszka107ef972011-10-12 10:16:35 +0200476 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION &&
Don Fry38622412011-12-16 07:07:36 -0800477 cfg(priv)->ht_params && cfg(priv)->ht_params->smps_mode)
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700478 ieee80211_request_smps(ctx->vif,
Don Fry38622412011-12-16 07:07:36 -0800479 cfg(priv)->ht_params->smps_mode);
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700480
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700481 return 0;
482}
483
Wey-Yi Guye505c432011-07-07 08:27:41 -0700484int iwlagn_set_pan_params(struct iwl_priv *priv)
485{
486 struct iwl_wipan_params_cmd cmd;
487 struct iwl_rxon_context *ctx_bss, *ctx_pan;
488 int slot0 = 300, slot1 = 0;
489 int ret;
490
Johannes Berga18f61b2012-03-15 13:26:53 -0700491 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
Wey-Yi Guye505c432011-07-07 08:27:41 -0700492 return 0;
493
494 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
495
Johannes Bergb1eea292012-03-06 13:30:42 -0800496 lockdep_assert_held(&priv->mutex);
Wey-Yi Guye505c432011-07-07 08:27:41 -0700497
498 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
499 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
500
501 /*
502 * If the PAN context is inactive, then we don't need
503 * to update the PAN parameters, the last thing we'll
504 * have done before it goes inactive is making the PAN
505 * parameters be WLAN-only.
506 */
507 if (!ctx_pan->is_active)
508 return 0;
509
510 memset(&cmd, 0, sizeof(cmd));
511
512 /* only 2 slots are currently allowed */
513 cmd.num_slots = 2;
514
515 cmd.slots[0].type = 0; /* BSS */
516 cmd.slots[1].type = 1; /* PAN */
517
Johannes Bergc6baf7f2011-07-23 10:24:47 -0700518 if (priv->hw_roc_setup) {
Wey-Yi Guye505c432011-07-07 08:27:41 -0700519 /* both contexts must be used for this to happen */
Johannes Bergc6baf7f2011-07-23 10:24:47 -0700520 slot1 = IWL_MIN_SLOT_TIME;
521 slot0 = 3000;
Wey-Yi Guye505c432011-07-07 08:27:41 -0700522 } else if (ctx_bss->vif && ctx_pan->vif) {
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700523 int bcnint = ctx_pan->beacon_int;
Wey-Yi Guye505c432011-07-07 08:27:41 -0700524 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1;
525
526 /* should be set, but seems unused?? */
527 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
528
529 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
530 bcnint &&
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700531 bcnint != ctx_bss->beacon_int) {
Wey-Yi Guye505c432011-07-07 08:27:41 -0700532 IWL_ERR(priv,
533 "beacon intervals don't match (%d, %d)\n",
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700534 ctx_bss->beacon_int, ctx_pan->beacon_int);
Wey-Yi Guye505c432011-07-07 08:27:41 -0700535 } else
536 bcnint = max_t(int, bcnint,
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700537 ctx_bss->beacon_int);
Wey-Yi Guye505c432011-07-07 08:27:41 -0700538 if (!bcnint)
539 bcnint = DEFAULT_BEACON_INTERVAL;
540 slot0 = bcnint / 2;
541 slot1 = bcnint - slot0;
542
Don Fry83626402012-03-07 09:52:37 -0800543 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
Wey-Yi Guye505c432011-07-07 08:27:41 -0700544 (!ctx_bss->vif->bss_conf.idle &&
545 !ctx_bss->vif->bss_conf.assoc)) {
546 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
547 slot1 = IWL_MIN_SLOT_TIME;
548 } else if (!ctx_pan->vif->bss_conf.idle &&
549 !ctx_pan->vif->bss_conf.assoc) {
Johannes Berg325a7dd2011-09-22 15:14:55 -0700550 slot1 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
Wey-Yi Guye505c432011-07-07 08:27:41 -0700551 slot0 = IWL_MIN_SLOT_TIME;
552 }
553 } else if (ctx_pan->vif) {
554 slot0 = 0;
555 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700556 ctx_pan->beacon_int;
Wey-Yi Guye505c432011-07-07 08:27:41 -0700557 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
558
Don Fry83626402012-03-07 09:52:37 -0800559 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
Wey-Yi Guye505c432011-07-07 08:27:41 -0700560 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME;
561 slot1 = IWL_MIN_SLOT_TIME;
562 }
563 }
564
565 cmd.slots[0].width = cpu_to_le16(slot0);
566 cmd.slots[1].width = cpu_to_le16(slot1);
567
Johannes Berge10a0532012-03-06 13:30:39 -0800568 ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
Wey-Yi Guye505c432011-07-07 08:27:41 -0700569 sizeof(cmd), &cmd);
570 if (ret)
571 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
572
573 return ret;
574}
575
Meenakshi Venkataramandd641732012-03-13 16:25:38 -0700576static void _iwl_set_rxon_ht(struct iwl_priv *priv,
577 struct iwl_ht_config *ht_conf,
578 struct iwl_rxon_context *ctx)
579{
580 struct iwl_rxon_cmd *rxon = &ctx->staging;
581
582 if (!ctx->ht.enabled) {
583 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
584 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
585 RXON_FLG_HT40_PROT_MSK |
586 RXON_FLG_HT_PROT_MSK);
587 return;
588 }
589
590 /* FIXME: if the definition of ht.protection changed, the "translation"
591 * will be needed for rxon->flags
592 */
593 rxon->flags |= cpu_to_le32(ctx->ht.protection <<
594 RXON_FLG_HT_OPERATING_MODE_POS);
595
596 /* Set up channel bandwidth:
597 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */
598 /* clear the HT channel mode before set the mode */
599 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
600 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
601 if (iwl_is_ht40_tx_allowed(priv, ctx, NULL)) {
602 /* pure ht40 */
603 if (ctx->ht.protection ==
604 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) {
605 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40;
606 /*
607 * Note: control channel is opposite of extension
608 * channel
609 */
610 switch (ctx->ht.extension_chan_offset) {
611 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
612 rxon->flags &=
613 ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
614 break;
615 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
616 rxon->flags |=
617 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
618 break;
619 }
620 } else {
621 /*
622 * Note: control channel is opposite of extension
623 * channel
624 */
625 switch (ctx->ht.extension_chan_offset) {
626 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
627 rxon->flags &=
628 ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
629 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
630 break;
631 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
632 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
633 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
634 break;
635 case IEEE80211_HT_PARAM_CHA_SEC_NONE:
636 default:
637 /*
638 * channel location only valid if in Mixed
639 * mode
640 */
641 IWL_ERR(priv,
642 "invalid extension channel offset\n");
643 break;
644 }
645 }
646 } else {
647 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
648 }
649
650 iwlagn_set_rxon_chain(priv, ctx);
651
652 IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X "
653 "extension channel offset 0x%x\n",
654 le32_to_cpu(rxon->flags), ctx->ht.protection,
655 ctx->ht.extension_chan_offset);
656}
657
658void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
659{
660 struct iwl_rxon_context *ctx;
661
662 for_each_context(priv, ctx)
663 _iwl_set_rxon_ht(priv, ht_conf, ctx);
664}
665
Meenakshi Venkataramanfedfa872012-03-13 16:31:34 -0700666/**
667 * iwl_set_rxon_channel - Set the band and channel values in staging RXON
668 * @ch: requested channel as a pointer to struct ieee80211_channel
669
670 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
671 * in the staging RXON flag structure based on the ch->band
672 */
673void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
674 struct iwl_rxon_context *ctx)
675{
676 enum ieee80211_band band = ch->band;
677 u16 channel = ch->hw_value;
678
679 if ((le16_to_cpu(ctx->staging.channel) == channel) &&
680 (priv->band == band))
681 return;
682
683 ctx->staging.channel = cpu_to_le16(channel);
684 if (band == IEEE80211_BAND_5GHZ)
685 ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK;
686 else
687 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK;
688
689 priv->band = band;
690
691 IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band);
692
693}
694
Meenakshi Venkataraman50319f72012-03-13 16:45:00 -0700695void iwl_set_flags_for_band(struct iwl_priv *priv,
696 struct iwl_rxon_context *ctx,
697 enum ieee80211_band band,
698 struct ieee80211_vif *vif)
699{
700 if (band == IEEE80211_BAND_5GHZ) {
701 ctx->staging.flags &=
702 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
703 | RXON_FLG_CCK_MSK);
704 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
705 } else {
706 /* Copied from iwl_post_associate() */
707 if (vif && vif->bss_conf.use_short_slot)
708 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
709 else
710 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
711
712 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK;
713 ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK;
714 ctx->staging.flags &= ~RXON_FLG_CCK_MSK;
715 }
716}
717
Meenakshi Venkataramanaecd44f2012-03-13 17:16:07 -0700718void iwl_set_rate(struct iwl_priv *priv)
719{
720 struct iwl_rxon_context *ctx;
721
722 for_each_context(priv, ctx) {
723 ctx->staging.cck_basic_rates =
724 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
725
726 ctx->staging.ofdm_basic_rates =
727 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
728 }
729}
730
Meenakshi Venkataraman354a4532012-03-15 13:27:00 -0700731static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv,
732 struct iwl_rxon_context *ctx, int hw_decrypt)
733{
734 struct iwl_rxon_cmd *rxon = &ctx->staging;
735
736 if (hw_decrypt)
737 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
738 else
739 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
740
741}
742
Meenakshi Venkataraman8931b572012-03-15 13:27:01 -0700743/* validate RXON structure is valid */
744static int iwl_check_rxon_cmd(struct iwl_priv *priv,
745 struct iwl_rxon_context *ctx)
746{
747 struct iwl_rxon_cmd *rxon = &ctx->staging;
748 u32 errors = 0;
749
750 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
751 if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) {
752 IWL_WARN(priv, "check 2.4G: wrong narrow\n");
753 errors |= BIT(0);
754 }
755 if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) {
756 IWL_WARN(priv, "check 2.4G: wrong radar\n");
757 errors |= BIT(1);
758 }
759 } else {
760 if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) {
761 IWL_WARN(priv, "check 5.2G: not short slot!\n");
762 errors |= BIT(2);
763 }
764 if (rxon->flags & RXON_FLG_CCK_MSK) {
765 IWL_WARN(priv, "check 5.2G: CCK!\n");
766 errors |= BIT(3);
767 }
768 }
769 if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) {
770 IWL_WARN(priv, "mac/bssid mcast!\n");
771 errors |= BIT(4);
772 }
773
774 /* make sure basic rates 6Mbps and 1Mbps are supported */
775 if ((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0 &&
776 (rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0) {
777 IWL_WARN(priv, "neither 1 nor 6 are basic\n");
778 errors |= BIT(5);
779 }
780
781 if (le16_to_cpu(rxon->assoc_id) > 2007) {
782 IWL_WARN(priv, "aid > 2007\n");
783 errors |= BIT(6);
784 }
785
786 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
787 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) {
788 IWL_WARN(priv, "CCK and short slot\n");
789 errors |= BIT(7);
790 }
791
792 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
793 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) {
794 IWL_WARN(priv, "CCK and auto detect");
795 errors |= BIT(8);
796 }
797
798 if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
799 RXON_FLG_TGG_PROTECT_MSK)) ==
800 RXON_FLG_TGG_PROTECT_MSK) {
801 IWL_WARN(priv, "TGg but no auto-detect\n");
802 errors |= BIT(9);
803 }
804
805 if (rxon->channel == 0) {
806 IWL_WARN(priv, "zero channel is invalid\n");
807 errors |= BIT(10);
808 }
809
810 WARN(errors, "Invalid RXON (%#x), channel %d",
811 errors, le16_to_cpu(rxon->channel));
812
813 return errors ? -EINVAL : 0;
814}
815
Johannes Berg2295c662010-10-23 09:15:41 -0700816/**
Meenakshi Venkataraman55620922012-03-15 13:27:02 -0700817 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
818 * @priv: staging_rxon is compared to active_rxon
819 *
820 * If the RXON structure is changing enough to require a new tune,
821 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
822 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
823 */
824static int iwl_full_rxon_required(struct iwl_priv *priv,
825 struct iwl_rxon_context *ctx)
826{
827 const struct iwl_rxon_cmd *staging = &ctx->staging;
828 const struct iwl_rxon_cmd *active = &ctx->active;
829
830#define CHK(cond) \
831 if ((cond)) { \
832 IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \
833 return 1; \
834 }
835
836#define CHK_NEQ(c1, c2) \
837 if ((c1) != (c2)) { \
838 IWL_DEBUG_INFO(priv, "need full RXON - " \
839 #c1 " != " #c2 " - %d != %d\n", \
840 (c1), (c2)); \
841 return 1; \
842 }
843
844 /* These items are only settable from the full RXON command */
845 CHK(!iwl_is_associated_ctx(ctx));
846 CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
847 CHK(compare_ether_addr(staging->node_addr, active->node_addr));
848 CHK(compare_ether_addr(staging->wlap_bssid_addr,
849 active->wlap_bssid_addr));
850 CHK_NEQ(staging->dev_type, active->dev_type);
851 CHK_NEQ(staging->channel, active->channel);
852 CHK_NEQ(staging->air_propagation, active->air_propagation);
853 CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates,
854 active->ofdm_ht_single_stream_basic_rates);
855 CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates,
856 active->ofdm_ht_dual_stream_basic_rates);
857 CHK_NEQ(staging->ofdm_ht_triple_stream_basic_rates,
858 active->ofdm_ht_triple_stream_basic_rates);
859 CHK_NEQ(staging->assoc_id, active->assoc_id);
860
861 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
862 * be updated with the RXON_ASSOC command -- however only some
863 * flag transitions are allowed using RXON_ASSOC */
864
865 /* Check if we are not switching bands */
866 CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK,
867 active->flags & RXON_FLG_BAND_24G_MSK);
868
869 /* Check if we are switching association toggle */
870 CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK,
871 active->filter_flags & RXON_FILTER_ASSOC_MSK);
872
873#undef CHK
874#undef CHK_NEQ
875
876 return 0;
877}
878
879/**
Johannes Berg2295c662010-10-23 09:15:41 -0700880 * iwlagn_commit_rxon - commit staging_rxon to hardware
881 *
882 * The RXON command in staging_rxon is committed to the hardware and
883 * the active_rxon structure is updated with the new data. This
884 * function correctly transitions out of the RXON_ASSOC_MSK state if
885 * a HW tune is required based on the RXON structure changes.
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700886 *
887 * The connect/disconnect flow should be as the following:
888 *
889 * 1. make sure send RXON command with association bit unset if not connect
890 * this should include the channel and the band for the candidate
891 * to be connected to
892 * 2. Add Station before RXON association with the AP
893 * 3. RXON_timing has to send before RXON for connection
894 * 4. full RXON command - associated bit set
895 * 5. use RXON_ASSOC command to update any flags changes
Johannes Berg2295c662010-10-23 09:15:41 -0700896 */
897int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
898{
899 /* cast away the const for active_rxon in this function */
900 struct iwl_rxon_cmd *active = (void *)&ctx->active;
Johannes Berg2295c662010-10-23 09:15:41 -0700901 bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
902 int ret;
903
Johannes Bergb1eea292012-03-06 13:30:42 -0800904 lockdep_assert_held(&priv->mutex);
Johannes Berg2295c662010-10-23 09:15:41 -0700905
Don Fry83626402012-03-07 09:52:37 -0800906 if (!iwl_is_alive(priv))
Johannes Berg2295c662010-10-23 09:15:41 -0700907 return -EBUSY;
908
909 /* This function hardcodes a bunch of dual-mode assumptions */
910 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
911
912 if (!ctx->is_active)
913 return 0;
914
915 /* always get timestamp with Rx frame */
916 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
917
Stanislaw Gruszka42b70a52011-05-26 17:14:22 +0200918 /*
919 * force CTS-to-self frames protection if RTS-CTS is not preferred
920 * one aggregation protection method
921 */
Johannes Berg9e295112012-04-09 17:46:55 -0700922 if (!priv->hw_params.use_rts_for_aggregation)
Stanislaw Gruszka42b70a52011-05-26 17:14:22 +0200923 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
924
Johannes Berg2295c662010-10-23 09:15:41 -0700925 if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
926 !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK))
927 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
928 else
929 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
930
Emmanuel Grumbach522376d2011-09-06 09:31:19 -0700931 iwl_print_rx_config_cmd(priv, ctx->ctxid);
Johannes Berg2295c662010-10-23 09:15:41 -0700932 ret = iwl_check_rxon_cmd(priv, ctx);
933 if (ret) {
934 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
935 return -EINVAL;
936 }
937
938 /*
939 * receive commit_rxon request
940 * abort any previous channel switch if still in process
941 */
Don Fry83626402012-03-07 09:52:37 -0800942 if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) &&
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200943 (priv->switch_channel != ctx->staging.channel)) {
Johannes Berg2295c662010-10-23 09:15:41 -0700944 IWL_DEBUG_11H(priv, "abort channel switch on %d\n",
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200945 le16_to_cpu(priv->switch_channel));
Johannes Berg2295c662010-10-23 09:15:41 -0700946 iwl_chswitch_done(priv, false);
947 }
948
949 /*
950 * If we don't need to send a full RXON, we can use
951 * iwl_rxon_assoc_cmd which is used to reconfigure filter
952 * and other flags for the current radio configuration.
953 */
954 if (!iwl_full_rxon_required(priv, ctx)) {
Wey-Yi Guyc3f6e9c2011-04-19 16:52:57 -0700955 ret = iwlagn_send_rxon_assoc(priv, ctx);
Johannes Berg2295c662010-10-23 09:15:41 -0700956 if (ret) {
957 IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret);
958 return ret;
959 }
960
961 memcpy(active, &ctx->staging, sizeof(*active));
Wey-Yi Guy891db882011-05-27 08:40:24 -0700962 /*
963 * We do not commit tx power settings while channel changing,
964 * do it now if after settings changed.
965 */
966 iwl_set_tx_power(priv, priv->tx_power_next, false);
Wey-Yi Guy15b3f3b2011-06-03 07:54:13 -0700967
968 /* make sure we are in the right PS state */
969 iwl_power_update_mode(priv, true);
970
Johannes Berg2295c662010-10-23 09:15:41 -0700971 return 0;
972 }
973
Don Fry9d143e92011-04-20 15:23:57 -0700974 iwl_set_rxon_hwcrypto(priv, ctx, !iwlagn_mod_params.sw_crypto);
Johannes Berg2295c662010-10-23 09:15:41 -0700975
976 IWL_DEBUG_INFO(priv,
977 "Going to commit RXON\n"
978 " * with%s RXON_FILTER_ASSOC_MSK\n"
979 " * channel = %d\n"
980 " * bssid = %pM\n",
981 (new_assoc ? "" : "out"),
982 le16_to_cpu(ctx->staging.channel),
983 ctx->staging.bssid_addr);
984
985 /*
Johannes Berg52d980c2010-11-10 09:56:45 -0800986 * Always clear associated first, but with the correct config.
987 * This is required as for example station addition for the
988 * AP station must be done after the BSSID is set to correctly
989 * set up filters in the device.
Johannes Berg2295c662010-10-23 09:15:41 -0700990 */
Wey-Yi Guy3083d032011-05-06 17:06:44 -0700991 ret = iwlagn_rxon_disconn(priv, ctx);
992 if (ret)
993 return ret;
Johannes Berg2295c662010-10-23 09:15:41 -0700994
Wey-Yi Guye3f10ce2011-07-01 07:59:26 -0700995 ret = iwlagn_set_pan_params(priv);
996 if (ret)
997 return ret;
Johannes Berg2b9253d2011-05-27 08:40:26 -0700998
Wey-Yi Guyc1821c92011-04-19 16:52:59 -0700999 if (new_assoc)
1000 return iwlagn_rxon_connect(priv, ctx);
Johannes Berg2295c662010-10-23 09:15:41 -07001001
1002 return 0;
1003}
1004
Wey-Yi Guy34a5b4b2011-12-02 08:19:18 -08001005void iwlagn_config_ht40(struct ieee80211_conf *conf,
1006 struct iwl_rxon_context *ctx)
1007{
1008 if (conf_is_ht40_minus(conf)) {
1009 ctx->ht.extension_chan_offset =
1010 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
1011 ctx->ht.is_40mhz = true;
1012 } else if (conf_is_ht40_plus(conf)) {
1013 ctx->ht.extension_chan_offset =
1014 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
1015 ctx->ht.is_40mhz = true;
1016 } else {
1017 ctx->ht.extension_chan_offset =
1018 IEEE80211_HT_PARAM_CHA_SEC_NONE;
1019 ctx->ht.is_40mhz = false;
1020 }
1021}
1022
Johannes Berg2295c662010-10-23 09:15:41 -07001023int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
1024{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001025 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Johannes Berg2295c662010-10-23 09:15:41 -07001026 struct iwl_rxon_context *ctx;
1027 struct ieee80211_conf *conf = &hw->conf;
1028 struct ieee80211_channel *channel = conf->channel;
1029 const struct iwl_channel_info *ch_info;
1030 int ret = 0;
1031
Johannes Berg0ca24da2012-03-15 13:26:46 -07001032 IWL_DEBUG_MAC80211(priv, "enter: changed %#x\n", changed);
Johannes Berg2295c662010-10-23 09:15:41 -07001033
Johannes Bergb1eea292012-03-06 13:30:42 -08001034 mutex_lock(&priv->mutex);
Johannes Berg2295c662010-10-23 09:15:41 -07001035
Don Fry83626402012-03-07 09:52:37 -08001036 if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) {
Johannes Berg2295c662010-10-23 09:15:41 -07001037 IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
1038 goto out;
1039 }
1040
Don Fry83626402012-03-07 09:52:37 -08001041 if (!iwl_is_ready(priv)) {
Johannes Berg2295c662010-10-23 09:15:41 -07001042 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
1043 goto out;
1044 }
1045
1046 if (changed & (IEEE80211_CONF_CHANGE_SMPS |
1047 IEEE80211_CONF_CHANGE_CHANNEL)) {
1048 /* mac80211 uses static for non-HT which is what we want */
1049 priv->current_ht_config.smps = conf->smps_mode;
1050
1051 /*
1052 * Recalculate chain counts.
1053 *
1054 * If monitor mode is enabled then mac80211 will
1055 * set up the SM PS mode to OFF if an HT channel is
1056 * configured.
1057 */
Wey-Yi Guye3f10ce2011-07-01 07:59:26 -07001058 for_each_context(priv, ctx)
1059 iwlagn_set_rxon_chain(priv, ctx);
Johannes Berg2295c662010-10-23 09:15:41 -07001060 }
1061
1062 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
Johannes Berg2295c662010-10-23 09:15:41 -07001063 ch_info = iwl_get_channel_info(priv, channel->band,
1064 channel->hw_value);
1065 if (!is_channel_valid(ch_info)) {
1066 IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
1067 ret = -EINVAL;
1068 goto out;
1069 }
1070
Johannes Berg2295c662010-10-23 09:15:41 -07001071 for_each_context(priv, ctx) {
1072 /* Configure HT40 channels */
Daniel Halperin7caa2312011-04-06 12:47:25 -07001073 if (ctx->ht.enabled != conf_is_ht(conf))
Wey-Yi Guy35a6eb32010-11-10 09:56:43 -08001074 ctx->ht.enabled = conf_is_ht(conf);
Wey-Yi Guy35a6eb32010-11-10 09:56:43 -08001075
Johannes Berg2295c662010-10-23 09:15:41 -07001076 if (ctx->ht.enabled) {
Wey-Yi Guy34a5b4b2011-12-02 08:19:18 -08001077 /* if HT40 is used, it should not change
1078 * after associated except channel switch */
Wey-Yi Guy78feb352011-12-14 08:22:36 -08001079 if (!ctx->ht.is_40mhz ||
1080 !iwl_is_associated_ctx(ctx))
Wey-Yi Guy34a5b4b2011-12-02 08:19:18 -08001081 iwlagn_config_ht40(conf, ctx);
Johannes Berg2295c662010-10-23 09:15:41 -07001082 } else
1083 ctx->ht.is_40mhz = false;
1084
1085 /*
1086 * Default to no protection. Protection mode will
1087 * later be set from BSS config in iwl_ht_conf
1088 */
1089 ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
1090
1091 /* if we are switching from ht to 2.4 clear flags
1092 * from any ht related info since 2.4 does not
1093 * support ht */
1094 if (le16_to_cpu(ctx->staging.channel) !=
1095 channel->hw_value)
1096 ctx->staging.flags = 0;
1097
1098 iwl_set_rxon_channel(priv, channel, ctx);
1099 iwl_set_rxon_ht(priv, &priv->current_ht_config);
1100
1101 iwl_set_flags_for_band(priv, ctx, channel->band,
1102 ctx->vif);
1103 }
1104
Johannes Berg2295c662010-10-23 09:15:41 -07001105 iwl_update_bcast_stations(priv);
1106
1107 /*
1108 * The list of supported rates and rate mask can be different
1109 * for each band; since the band may have changed, reset
1110 * the rate mask to what mac80211 lists.
1111 */
1112 iwl_set_rate(priv);
1113 }
1114
1115 if (changed & (IEEE80211_CONF_CHANGE_PS |
1116 IEEE80211_CONF_CHANGE_IDLE)) {
1117 ret = iwl_power_update_mode(priv, false);
1118 if (ret)
1119 IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n");
1120 }
1121
1122 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1123 IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
1124 priv->tx_power_user_lmt, conf->power_level);
1125
1126 iwl_set_tx_power(priv, conf->power_level, false);
1127 }
1128
1129 for_each_context(priv, ctx) {
1130 if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
1131 continue;
1132 iwlagn_commit_rxon(priv, ctx);
1133 }
1134 out:
Johannes Bergb1eea292012-03-06 13:30:42 -08001135 mutex_unlock(&priv->mutex);
Wey-Yi Guy770c72c2011-10-10 07:27:10 -07001136 IWL_DEBUG_MAC80211(priv, "leave\n");
1137
Johannes Berg2295c662010-10-23 09:15:41 -07001138 return ret;
1139}
1140
Johannes Berg2295c662010-10-23 09:15:41 -07001141static void iwlagn_check_needed_chains(struct iwl_priv *priv,
1142 struct iwl_rxon_context *ctx,
1143 struct ieee80211_bss_conf *bss_conf)
1144{
1145 struct ieee80211_vif *vif = ctx->vif;
1146 struct iwl_rxon_context *tmp;
1147 struct ieee80211_sta *sta;
1148 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
Johannes Berg850bedc2011-02-25 12:24:11 +01001149 struct ieee80211_sta_ht_cap *ht_cap;
Johannes Berg2295c662010-10-23 09:15:41 -07001150 bool need_multiple;
1151
Johannes Bergb1eea292012-03-06 13:30:42 -08001152 lockdep_assert_held(&priv->mutex);
Johannes Berg2295c662010-10-23 09:15:41 -07001153
1154 switch (vif->type) {
1155 case NL80211_IFTYPE_STATION:
1156 rcu_read_lock();
1157 sta = ieee80211_find_sta(vif, bss_conf->bssid);
Johannes Berg850bedc2011-02-25 12:24:11 +01001158 if (!sta) {
Johannes Berg2295c662010-10-23 09:15:41 -07001159 /*
1160 * If at all, this can only happen through a race
1161 * when the AP disconnects us while we're still
1162 * setting up the connection, in that case mac80211
1163 * will soon tell us about that.
1164 */
1165 need_multiple = false;
Johannes Berg850bedc2011-02-25 12:24:11 +01001166 rcu_read_unlock();
1167 break;
Johannes Berg2295c662010-10-23 09:15:41 -07001168 }
Johannes Berg850bedc2011-02-25 12:24:11 +01001169
1170 ht_cap = &sta->ht_cap;
1171
1172 need_multiple = true;
1173
1174 /*
1175 * If the peer advertises no support for receiving 2 and 3
1176 * stream MCS rates, it can't be transmitting them either.
1177 */
1178 if (ht_cap->mcs.rx_mask[1] == 0 &&
1179 ht_cap->mcs.rx_mask[2] == 0) {
1180 need_multiple = false;
1181 } else if (!(ht_cap->mcs.tx_params &
1182 IEEE80211_HT_MCS_TX_DEFINED)) {
1183 /* If it can't TX MCS at all ... */
1184 need_multiple = false;
1185 } else if (ht_cap->mcs.tx_params &
1186 IEEE80211_HT_MCS_TX_RX_DIFF) {
1187 int maxstreams;
1188
1189 /*
1190 * But if it can receive them, it might still not
1191 * be able to transmit them, which is what we need
1192 * to check here -- so check the number of streams
1193 * it advertises for TX (if different from RX).
1194 */
1195
1196 maxstreams = (ht_cap->mcs.tx_params &
1197 IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK);
1198 maxstreams >>=
1199 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
1200 maxstreams += 1;
1201
1202 if (maxstreams <= 1)
1203 need_multiple = false;
1204 }
1205
Johannes Berg2295c662010-10-23 09:15:41 -07001206 rcu_read_unlock();
1207 break;
1208 case NL80211_IFTYPE_ADHOC:
1209 /* currently */
1210 need_multiple = false;
1211 break;
1212 default:
1213 /* only AP really */
1214 need_multiple = true;
1215 break;
1216 }
1217
1218 ctx->ht_need_multiple_chains = need_multiple;
1219
1220 if (!need_multiple) {
1221 /* check all contexts */
1222 for_each_context(priv, tmp) {
1223 if (!tmp->vif)
1224 continue;
1225 if (tmp->ht_need_multiple_chains) {
1226 need_multiple = true;
1227 break;
1228 }
1229 }
1230 }
1231
1232 ht_conf->single_chain_sufficient = !need_multiple;
1233}
1234
Don Fry5c3d29f2011-07-08 08:46:29 -07001235static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
1236{
1237 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
1238 int ret;
1239
1240 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
1241 iwl_is_any_associated(priv)) {
1242 struct iwl_calib_chain_noise_reset_cmd cmd;
1243
1244 /* clear data for chain noise calibration algorithm */
1245 data->chain_noise_a = 0;
1246 data->chain_noise_b = 0;
1247 data->chain_noise_c = 0;
1248 data->chain_signal_a = 0;
1249 data->chain_signal_b = 0;
1250 data->chain_signal_c = 0;
1251 data->beacon_count = 0;
1252
1253 memset(&cmd, 0, sizeof(cmd));
1254 iwl_set_calib_hdr(&cmd.hdr,
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001255 priv->phy_calib_chain_noise_reset_cmd);
Johannes Berge10a0532012-03-06 13:30:39 -08001256 ret = iwl_dvm_send_cmd_pdu(priv,
Don Fry5c3d29f2011-07-08 08:46:29 -07001257 REPLY_PHY_CALIBRATION_CMD,
1258 CMD_SYNC, sizeof(cmd), &cmd);
1259 if (ret)
1260 IWL_ERR(priv,
1261 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
1262 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
1263 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
1264 }
1265}
1266
Johannes Berg2295c662010-10-23 09:15:41 -07001267void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
1268 struct ieee80211_vif *vif,
1269 struct ieee80211_bss_conf *bss_conf,
1270 u32 changes)
1271{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001272 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Johannes Berg2295c662010-10-23 09:15:41 -07001273 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1274 int ret;
1275 bool force = false;
1276
Johannes Bergb1eea292012-03-06 13:30:42 -08001277 mutex_lock(&priv->mutex);
Johannes Berg2295c662010-10-23 09:15:41 -07001278
Don Fry83626402012-03-07 09:52:37 -08001279 if (unlikely(!iwl_is_ready(priv))) {
Wey-Yi Guy14a085e2010-12-14 07:38:58 -08001280 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
Johannes Bergb1eea292012-03-06 13:30:42 -08001281 mutex_unlock(&priv->mutex);
Shanyu Zhaoae0b6932010-12-02 11:02:28 -08001282 return;
1283 }
1284
1285 if (unlikely(!ctx->vif)) {
1286 IWL_DEBUG_MAC80211(priv, "leave - vif is NULL\n");
Johannes Bergb1eea292012-03-06 13:30:42 -08001287 mutex_unlock(&priv->mutex);
Johannes Berg893654d2010-11-10 18:25:47 -08001288 return;
1289 }
1290
Johannes Berg2295c662010-10-23 09:15:41 -07001291 if (changes & BSS_CHANGED_BEACON_INT)
1292 force = true;
1293
1294 if (changes & BSS_CHANGED_QOS) {
1295 ctx->qos_data.qos_active = bss_conf->qos;
1296 iwlagn_update_qos(priv, ctx);
1297 }
1298
1299 ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
1300 if (vif->bss_conf.use_short_preamble)
1301 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1302 else
1303 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1304
1305 if (changes & BSS_CHANGED_ASSOC) {
1306 if (bss_conf->assoc) {
Johannes Berge9ac0742012-03-13 14:29:30 +01001307 priv->timestamp = bss_conf->last_tsf;
Johannes Berg2295c662010-10-23 09:15:41 -07001308 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
1309 } else {
Garen Tamrazian68b99312011-03-30 02:29:32 -07001310 /*
1311 * If we disassociate while there are pending
1312 * frames, just wake up the queues and let the
1313 * frames "escape" ... This shouldn't really
1314 * be happening to start with, but we should
1315 * not get stuck in this case either since it
1316 * can happen if userspace gets confused.
1317 */
Johannes Berge755f882012-03-07 09:52:16 -08001318 iwlagn_lift_passive_no_rx(priv);
1319
Johannes Berg2295c662010-10-23 09:15:41 -07001320 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
Johannes Bergc8ac61c2011-07-15 13:23:45 -07001321
1322 if (ctx->ctxid == IWL_RXON_CTX_BSS)
1323 priv->have_rekey_data = false;
Johannes Berg2295c662010-10-23 09:15:41 -07001324 }
Meenakshi Venkataraman207ecc52011-07-08 08:46:23 -07001325
1326 iwlagn_bt_coex_rssi_monitor(priv);
Johannes Berg2295c662010-10-23 09:15:41 -07001327 }
1328
1329 if (ctx->ht.enabled) {
1330 ctx->ht.protection = bss_conf->ht_operation_mode &
1331 IEEE80211_HT_OP_MODE_PROTECTION;
1332 ctx->ht.non_gf_sta_present = !!(bss_conf->ht_operation_mode &
1333 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
1334 iwlagn_check_needed_chains(priv, ctx, bss_conf);
Johannes Bergb2769b82010-11-10 09:56:47 -08001335 iwl_set_rxon_ht(priv, &priv->current_ht_config);
Johannes Berg2295c662010-10-23 09:15:41 -07001336 }
1337
Wey-Yi Guye3f10ce2011-07-01 07:59:26 -07001338 iwlagn_set_rxon_chain(priv, ctx);
Johannes Berg2295c662010-10-23 09:15:41 -07001339
1340 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
1341 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
1342 else
1343 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
1344
1345 if (bss_conf->use_cts_prot)
1346 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
1347 else
1348 ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
1349
1350 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN);
1351
1352 if (vif->type == NL80211_IFTYPE_AP ||
1353 vif->type == NL80211_IFTYPE_ADHOC) {
1354 if (vif->bss_conf.enable_beacon) {
1355 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
1356 priv->beacon_ctx = ctx;
1357 } else {
1358 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1359 priv->beacon_ctx = NULL;
1360 }
1361 }
1362
Meenakshi Venkataraman758f5552012-02-08 12:04:41 -08001363 /*
1364 * If the ucode decides to do beacon filtering before
1365 * association, it will lose beacons that are needed
1366 * before sending frames out on passive channels. This
1367 * causes association failures on those channels. Enable
1368 * receiving beacons in such cases.
1369 */
1370
1371 if (vif->type == NL80211_IFTYPE_STATION) {
1372 if (!bss_conf->assoc)
1373 ctx->staging.filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
1374 else
1375 ctx->staging.filter_flags &=
1376 ~RXON_FILTER_BCON_AWARE_MSK;
1377 }
1378
Johannes Berg2295c662010-10-23 09:15:41 -07001379 if (force || memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
1380 iwlagn_commit_rxon(priv, ctx);
1381
Johannes Berg8da8e622010-11-10 09:56:46 -08001382 if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) {
1383 /*
1384 * The chain noise calibration will enable PM upon
1385 * completion. If calibration has already been run
1386 * then we need to enable power management here.
1387 */
1388 if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE)
1389 iwl_power_update_mode(priv, false);
1390
1391 /* Enable RX differential gain and sensitivity calibrations */
Don Fry5c3d29f2011-07-08 08:46:29 -07001392 if (!priv->disable_chain_noise_cal)
1393 iwlagn_chain_noise_reset(priv);
Johannes Berg8da8e622010-11-10 09:56:46 -08001394 priv->start_calib = 1;
1395 }
1396
Johannes Berg2295c662010-10-23 09:15:41 -07001397 if (changes & BSS_CHANGED_IBSS) {
1398 ret = iwlagn_manage_ibss_station(priv, vif,
1399 bss_conf->ibss_joined);
1400 if (ret)
1401 IWL_ERR(priv, "failed to %s IBSS station %pM\n",
1402 bss_conf->ibss_joined ? "add" : "remove",
1403 bss_conf->bssid);
1404 }
1405
Johannes Bergbd50a8ab2010-10-23 09:15:42 -07001406 if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_ADHOC &&
1407 priv->beacon_ctx) {
1408 if (iwlagn_update_beacon(priv, vif))
1409 IWL_ERR(priv, "Error sending IBSS beacon\n");
1410 }
1411
Johannes Bergb1eea292012-03-06 13:30:42 -08001412 mutex_unlock(&priv->mutex);
Johannes Berg2295c662010-10-23 09:15:41 -07001413}
Johannes Bergae79d232010-11-10 09:56:38 -08001414
1415void iwlagn_post_scan(struct iwl_priv *priv)
1416{
1417 struct iwl_rxon_context *ctx;
1418
1419 /*
Wey-Yi Guyc2b821d2011-06-03 07:54:14 -07001420 * We do not commit power settings while scan is pending,
1421 * do it now if the settings changed.
1422 */
1423 iwl_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false);
1424 iwl_set_tx_power(priv, priv->tx_power_next, false);
1425
1426 /*
Johannes Bergae79d232010-11-10 09:56:38 -08001427 * Since setting the RXON may have been deferred while
1428 * performing the scan, fire one off if needed
1429 */
1430 for_each_context(priv, ctx)
1431 if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
1432 iwlagn_commit_rxon(priv, ctx);
1433
Wey-Yi Guye3f10ce2011-07-01 07:59:26 -07001434 iwlagn_set_pan_params(priv);
Johannes Bergae79d232010-11-10 09:56:38 -08001435}