Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Wey-Yi Guy | fb4961d | 2012-01-06 13:16:33 -0800 | [diff] [blame] | 3 | * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 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" |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 29 | #include "iwl-core.h" |
| 30 | #include "iwl-agn-calib.h" |
Emmanuel Grumbach | bdfbf09 | 2011-07-08 08:46:16 -0700 | [diff] [blame] | 31 | #include "iwl-trans.h" |
Emmanuel Grumbach | 48f20d3 | 2011-08-25 23:10:36 -0700 | [diff] [blame] | 32 | #include "iwl-shared.h" |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 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; |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 42 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, |
Emmanuel Grumbach | e419d62 | 2011-07-08 08:46:14 -0700 | [diff] [blame] | 43 | CMD_SYNC, sizeof(*send), send); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 44 | |
| 45 | send->filter_flags = old_filter; |
| 46 | |
| 47 | if (ret) |
Todd Previte | b36b110 | 2011-11-10 06:55:02 -0800 | [diff] [blame] | 48 | IWL_DEBUG_QUIET_RFKILL(priv, |
| 49 | "Error clearing ASSOC_MSK on BSS (%d)\n", ret); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 50 | |
| 51 | return ret; |
| 52 | } |
| 53 | |
| 54 | static int iwlagn_disable_pan(struct iwl_priv *priv, |
| 55 | struct iwl_rxon_context *ctx, |
| 56 | struct iwl_rxon_cmd *send) |
| 57 | { |
Johannes Berg | 311dce7 | 2011-01-04 16:22:01 -0800 | [diff] [blame] | 58 | struct iwl_notification_wait disable_wait; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 59 | __le32 old_filter = send->filter_flags; |
| 60 | u8 old_dev_type = send->dev_type; |
| 61 | int ret; |
Johannes Berg | db662d4 | 2012-03-15 13:26:44 -0700 | [diff] [blame] | 62 | static const u8 deactivate_cmd[] = { |
| 63 | REPLY_WIPAN_DEACTIVATION_COMPLETE |
| 64 | }; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 65 | |
Johannes Berg | 4bd14dd | 2012-03-06 13:30:58 -0800 | [diff] [blame] | 66 | iwl_init_notification_wait(&priv->notif_wait, &disable_wait, |
Johannes Berg | db662d4 | 2012-03-15 13:26:44 -0700 | [diff] [blame] | 67 | deactivate_cmd, ARRAY_SIZE(deactivate_cmd), |
Johannes Berg | 4bd14dd | 2012-03-06 13:30:58 -0800 | [diff] [blame] | 68 | NULL, NULL); |
Johannes Berg | 311dce7 | 2011-01-04 16:22:01 -0800 | [diff] [blame] | 69 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 70 | send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 71 | send->dev_type = RXON_DEV_TYPE_P2P; |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 72 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, |
Emmanuel Grumbach | e419d62 | 2011-07-08 08:46:14 -0700 | [diff] [blame] | 73 | CMD_SYNC, sizeof(*send), send); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 74 | |
| 75 | send->filter_flags = old_filter; |
| 76 | send->dev_type = old_dev_type; |
| 77 | |
Johannes Berg | 311dce7 | 2011-01-04 16:22:01 -0800 | [diff] [blame] | 78 | if (ret) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 79 | IWL_ERR(priv, "Error disabling PAN (%d)\n", ret); |
Johannes Berg | 4bd14dd | 2012-03-06 13:30:58 -0800 | [diff] [blame] | 80 | iwl_remove_notification(&priv->notif_wait, &disable_wait); |
Johannes Berg | 311dce7 | 2011-01-04 16:22:01 -0800 | [diff] [blame] | 81 | } else { |
Johannes Berg | 4bd14dd | 2012-03-06 13:30:58 -0800 | [diff] [blame] | 82 | ret = iwl_wait_notification(&priv->notif_wait, |
| 83 | &disable_wait, HZ); |
Johannes Berg | a8674a1 | 2011-04-13 03:14:48 -0700 | [diff] [blame] | 84 | if (ret) |
Johannes Berg | 311dce7 | 2011-01-04 16:22:01 -0800 | [diff] [blame] | 85 | IWL_ERR(priv, "Timed out waiting for PAN disable\n"); |
| 86 | } |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 87 | |
| 88 | return ret; |
| 89 | } |
| 90 | |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 91 | static int iwlagn_disconn_pan(struct iwl_priv *priv, |
| 92 | struct iwl_rxon_context *ctx, |
| 93 | struct iwl_rxon_cmd *send) |
| 94 | { |
| 95 | __le32 old_filter = send->filter_flags; |
| 96 | int ret; |
| 97 | |
| 98 | send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 99 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, |
Emmanuel Grumbach | e419d62 | 2011-07-08 08:46:14 -0700 | [diff] [blame] | 100 | sizeof(*send), send); |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 101 | |
| 102 | send->filter_flags = old_filter; |
| 103 | |
| 104 | return ret; |
| 105 | } |
| 106 | |
Shanyu Zhao | f4115d4 | 2010-11-10 18:25:58 -0800 | [diff] [blame] | 107 | static void iwlagn_update_qos(struct iwl_priv *priv, |
| 108 | struct iwl_rxon_context *ctx) |
| 109 | { |
| 110 | int ret; |
| 111 | |
| 112 | if (!ctx->is_active) |
| 113 | return; |
| 114 | |
| 115 | ctx->qos_data.def_qos_parm.qos_flags = 0; |
| 116 | |
| 117 | if (ctx->qos_data.qos_active) |
| 118 | ctx->qos_data.def_qos_parm.qos_flags |= |
| 119 | QOS_PARAM_FLG_UPDATE_EDCA_MSK; |
| 120 | |
| 121 | if (ctx->ht.enabled) |
| 122 | ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; |
| 123 | |
Emmanuel Grumbach | 0dcf50c | 2011-11-10 06:55:23 -0800 | [diff] [blame] | 124 | IWL_DEBUG_INFO(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", |
Shanyu Zhao | f4115d4 | 2010-11-10 18:25:58 -0800 | [diff] [blame] | 125 | ctx->qos_data.qos_active, |
| 126 | ctx->qos_data.def_qos_parm.qos_flags); |
| 127 | |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 128 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC, |
Shanyu Zhao | f4115d4 | 2010-11-10 18:25:58 -0800 | [diff] [blame] | 129 | sizeof(struct iwl_qosparam_cmd), |
| 130 | &ctx->qos_data.def_qos_parm); |
| 131 | if (ret) |
Todd Previte | b36b110 | 2011-11-10 06:55:02 -0800 | [diff] [blame] | 132 | IWL_DEBUG_QUIET_RFKILL(priv, "Failed to update QoS\n"); |
Shanyu Zhao | f4115d4 | 2010-11-10 18:25:58 -0800 | [diff] [blame] | 133 | } |
| 134 | |
Johannes Berg | bd50a8ab | 2010-10-23 09:15:42 -0700 | [diff] [blame] | 135 | static int iwlagn_update_beacon(struct iwl_priv *priv, |
| 136 | struct ieee80211_vif *vif) |
| 137 | { |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 138 | lockdep_assert_held(&priv->mutex); |
Johannes Berg | bd50a8ab | 2010-10-23 09:15:42 -0700 | [diff] [blame] | 139 | |
| 140 | dev_kfree_skb(priv->beacon_skb); |
| 141 | priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif); |
| 142 | if (!priv->beacon_skb) |
| 143 | return -ENOMEM; |
| 144 | return iwlagn_send_beacon_cmd(priv); |
| 145 | } |
| 146 | |
Wey-Yi Guy | c3f6e9c | 2011-04-19 16:52:57 -0700 | [diff] [blame] | 147 | static int iwlagn_send_rxon_assoc(struct iwl_priv *priv, |
| 148 | struct iwl_rxon_context *ctx) |
| 149 | { |
| 150 | int ret = 0; |
Wey-Yi Guy | 89e746b | 2011-04-19 16:52:58 -0700 | [diff] [blame] | 151 | struct iwl_rxon_assoc_cmd rxon_assoc; |
Wey-Yi Guy | c3f6e9c | 2011-04-19 16:52:57 -0700 | [diff] [blame] | 152 | const struct iwl_rxon_cmd *rxon1 = &ctx->staging; |
| 153 | const struct iwl_rxon_cmd *rxon2 = &ctx->active; |
| 154 | |
| 155 | if ((rxon1->flags == rxon2->flags) && |
| 156 | (rxon1->filter_flags == rxon2->filter_flags) && |
| 157 | (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && |
| 158 | (rxon1->ofdm_ht_single_stream_basic_rates == |
| 159 | rxon2->ofdm_ht_single_stream_basic_rates) && |
| 160 | (rxon1->ofdm_ht_dual_stream_basic_rates == |
| 161 | rxon2->ofdm_ht_dual_stream_basic_rates) && |
| 162 | (rxon1->ofdm_ht_triple_stream_basic_rates == |
| 163 | rxon2->ofdm_ht_triple_stream_basic_rates) && |
| 164 | (rxon1->acquisition_data == rxon2->acquisition_data) && |
| 165 | (rxon1->rx_chain == rxon2->rx_chain) && |
| 166 | (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { |
| 167 | IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | rxon_assoc.flags = ctx->staging.flags; |
| 172 | rxon_assoc.filter_flags = ctx->staging.filter_flags; |
| 173 | rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; |
| 174 | rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; |
| 175 | rxon_assoc.reserved1 = 0; |
| 176 | rxon_assoc.reserved2 = 0; |
| 177 | rxon_assoc.reserved3 = 0; |
| 178 | rxon_assoc.ofdm_ht_single_stream_basic_rates = |
| 179 | ctx->staging.ofdm_ht_single_stream_basic_rates; |
| 180 | rxon_assoc.ofdm_ht_dual_stream_basic_rates = |
| 181 | ctx->staging.ofdm_ht_dual_stream_basic_rates; |
| 182 | rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; |
| 183 | rxon_assoc.ofdm_ht_triple_stream_basic_rates = |
| 184 | ctx->staging.ofdm_ht_triple_stream_basic_rates; |
| 185 | rxon_assoc.acquisition_data = ctx->staging.acquisition_data; |
| 186 | |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 187 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_assoc_cmd, |
Emmanuel Grumbach | e419d62 | 2011-07-08 08:46:14 -0700 | [diff] [blame] | 188 | CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc); |
Wey-Yi Guy | c3f6e9c | 2011-04-19 16:52:57 -0700 | [diff] [blame] | 189 | return ret; |
| 190 | } |
| 191 | |
Meenakshi Venkataraman | dff96c1 | 2012-03-15 13:26:59 -0700 | [diff] [blame^] | 192 | static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) |
| 193 | { |
| 194 | u16 new_val; |
| 195 | u16 beacon_factor; |
| 196 | |
| 197 | /* |
| 198 | * If mac80211 hasn't given us a beacon interval, program |
| 199 | * the default into the device (not checking this here |
| 200 | * would cause the adjustment below to return the maximum |
| 201 | * value, which may break PAN.) |
| 202 | */ |
| 203 | if (!beacon_val) |
| 204 | return DEFAULT_BEACON_INTERVAL; |
| 205 | |
| 206 | /* |
| 207 | * If the beacon interval we obtained from the peer |
| 208 | * is too large, we'll have to wake up more often |
| 209 | * (and in IBSS case, we'll beacon too much) |
| 210 | * |
| 211 | * For example, if max_beacon_val is 4096, and the |
| 212 | * requested beacon interval is 7000, we'll have to |
| 213 | * use 3500 to be able to wake up on the beacons. |
| 214 | * |
| 215 | * This could badly influence beacon detection stats. |
| 216 | */ |
| 217 | |
| 218 | beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; |
| 219 | new_val = beacon_val / beacon_factor; |
| 220 | |
| 221 | if (!new_val) |
| 222 | new_val = max_beacon_val; |
| 223 | |
| 224 | return new_val; |
| 225 | } |
| 226 | |
| 227 | static int iwl_send_rxon_timing(struct iwl_priv *priv, |
| 228 | struct iwl_rxon_context *ctx) |
| 229 | { |
| 230 | u64 tsf; |
| 231 | s32 interval_tm, rem; |
| 232 | struct ieee80211_conf *conf = NULL; |
| 233 | u16 beacon_int; |
| 234 | struct ieee80211_vif *vif = ctx->vif; |
| 235 | |
| 236 | conf = &priv->hw->conf; |
| 237 | |
| 238 | lockdep_assert_held(&priv->mutex); |
| 239 | |
| 240 | memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); |
| 241 | |
| 242 | ctx->timing.timestamp = cpu_to_le64(priv->timestamp); |
| 243 | ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); |
| 244 | |
| 245 | beacon_int = vif ? vif->bss_conf.beacon_int : 0; |
| 246 | |
| 247 | /* |
| 248 | * TODO: For IBSS we need to get atim_window from mac80211, |
| 249 | * for now just always use 0 |
| 250 | */ |
| 251 | ctx->timing.atim_window = 0; |
| 252 | |
| 253 | if (ctx->ctxid == IWL_RXON_CTX_PAN && |
| 254 | (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION) && |
| 255 | iwl_is_associated(priv, IWL_RXON_CTX_BSS) && |
| 256 | priv->contexts[IWL_RXON_CTX_BSS].vif && |
| 257 | priv->contexts[IWL_RXON_CTX_BSS].vif->bss_conf.beacon_int) { |
| 258 | ctx->timing.beacon_interval = |
| 259 | priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval; |
| 260 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); |
| 261 | } else if (ctx->ctxid == IWL_RXON_CTX_BSS && |
| 262 | iwl_is_associated(priv, IWL_RXON_CTX_PAN) && |
| 263 | priv->contexts[IWL_RXON_CTX_PAN].vif && |
| 264 | priv->contexts[IWL_RXON_CTX_PAN].vif->bss_conf.beacon_int && |
| 265 | (!iwl_is_associated_ctx(ctx) || !ctx->vif || |
| 266 | !ctx->vif->bss_conf.beacon_int)) { |
| 267 | ctx->timing.beacon_interval = |
| 268 | priv->contexts[IWL_RXON_CTX_PAN].timing.beacon_interval; |
| 269 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); |
| 270 | } else { |
| 271 | beacon_int = iwl_adjust_beacon_interval(beacon_int, |
| 272 | IWL_MAX_UCODE_BEACON_INTERVAL * TIME_UNIT); |
| 273 | ctx->timing.beacon_interval = cpu_to_le16(beacon_int); |
| 274 | } |
| 275 | |
| 276 | ctx->beacon_int = beacon_int; |
| 277 | |
| 278 | tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ |
| 279 | interval_tm = beacon_int * TIME_UNIT; |
| 280 | rem = do_div(tsf, interval_tm); |
| 281 | ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); |
| 282 | |
| 283 | ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; |
| 284 | |
| 285 | IWL_DEBUG_ASSOC(priv, |
| 286 | "beacon interval %d beacon timer %d beacon tim %d\n", |
| 287 | le16_to_cpu(ctx->timing.beacon_interval), |
| 288 | le32_to_cpu(ctx->timing.beacon_init_val), |
| 289 | le16_to_cpu(ctx->timing.atim_window)); |
| 290 | |
| 291 | return iwl_dvm_send_cmd_pdu(priv, ctx->rxon_timing_cmd, |
| 292 | CMD_SYNC, sizeof(ctx->timing), &ctx->timing); |
| 293 | } |
| 294 | |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 295 | static int iwlagn_rxon_disconn(struct iwl_priv *priv, |
| 296 | struct iwl_rxon_context *ctx) |
| 297 | { |
| 298 | int ret; |
| 299 | struct iwl_rxon_cmd *active = (void *)&ctx->active; |
| 300 | |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 301 | if (ctx->ctxid == IWL_RXON_CTX_BSS) { |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 302 | ret = iwlagn_disable_bss(priv, ctx, &ctx->staging); |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 303 | } else { |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 304 | ret = iwlagn_disable_pan(priv, ctx, &ctx->staging); |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 305 | if (ret) |
| 306 | return ret; |
| 307 | if (ctx->vif) { |
| 308 | ret = iwl_send_rxon_timing(priv, ctx); |
| 309 | if (ret) { |
| 310 | IWL_ERR(priv, "Failed to send timing (%d)!\n", ret); |
| 311 | return ret; |
| 312 | } |
| 313 | ret = iwlagn_disconn_pan(priv, ctx, &ctx->staging); |
| 314 | } |
| 315 | } |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 316 | if (ret) |
| 317 | return ret; |
| 318 | |
| 319 | /* |
| 320 | * Un-assoc RXON clears the station table and WEP |
| 321 | * keys, so we have to restore those afterwards. |
| 322 | */ |
| 323 | iwl_clear_ucode_stations(priv, ctx); |
Johannes Berg | f775aa0 | 2011-06-22 06:34:09 -0700 | [diff] [blame] | 324 | /* update -- might need P2P now */ |
| 325 | iwl_update_bcast_station(priv, ctx); |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 326 | iwl_restore_stations(priv, ctx); |
| 327 | ret = iwl_restore_default_wep_keys(priv, ctx); |
| 328 | if (ret) { |
| 329 | IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); |
| 330 | return ret; |
| 331 | } |
| 332 | |
| 333 | memcpy(active, &ctx->staging, sizeof(*active)); |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | static int iwlagn_rxon_connect(struct iwl_priv *priv, |
| 338 | struct iwl_rxon_context *ctx) |
| 339 | { |
| 340 | int ret; |
| 341 | struct iwl_rxon_cmd *active = (void *)&ctx->active; |
| 342 | |
| 343 | /* RXON timing must be before associated RXON */ |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 344 | if (ctx->ctxid == IWL_RXON_CTX_BSS) { |
| 345 | ret = iwl_send_rxon_timing(priv, ctx); |
| 346 | if (ret) { |
| 347 | IWL_ERR(priv, "Failed to send timing (%d)!\n", ret); |
| 348 | return ret; |
| 349 | } |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 350 | } |
| 351 | /* QoS info may be cleared by previous un-assoc RXON */ |
| 352 | iwlagn_update_qos(priv, ctx); |
| 353 | |
| 354 | /* |
| 355 | * We'll run into this code path when beaconing is |
| 356 | * enabled, but then we also need to send the beacon |
| 357 | * to the device. |
| 358 | */ |
| 359 | if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) { |
| 360 | ret = iwlagn_update_beacon(priv, ctx->vif); |
| 361 | if (ret) { |
| 362 | IWL_ERR(priv, |
| 363 | "Error sending required beacon (%d)!\n", |
| 364 | ret); |
| 365 | return ret; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | priv->start_calib = 0; |
| 370 | /* |
| 371 | * Apply the new configuration. |
| 372 | * |
| 373 | * Associated RXON doesn't clear the station table in uCode, |
| 374 | * so we don't need to restore stations etc. after this. |
| 375 | */ |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 376 | ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 377 | sizeof(struct iwl_rxon_cmd), &ctx->staging); |
| 378 | if (ret) { |
| 379 | IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); |
| 380 | return ret; |
| 381 | } |
| 382 | memcpy(active, &ctx->staging, sizeof(*active)); |
| 383 | |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 384 | /* IBSS beacon needs to be sent after setting assoc */ |
| 385 | if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC)) |
| 386 | if (iwlagn_update_beacon(priv, ctx->vif)) |
| 387 | IWL_ERR(priv, "Error sending IBSS beacon\n"); |
| 388 | iwl_init_sensitivity(priv); |
| 389 | |
| 390 | /* |
| 391 | * If we issue a new RXON command which required a tune then |
| 392 | * we must send a new TXPOWER command or we won't be able to |
| 393 | * Tx any frames. |
| 394 | * |
| 395 | * It's expected we set power here if channel is changing. |
| 396 | */ |
| 397 | ret = iwl_set_tx_power(priv, priv->tx_power_next, true); |
| 398 | if (ret) { |
| 399 | IWL_ERR(priv, "Error sending TX power (%d)\n", ret); |
| 400 | return ret; |
| 401 | } |
Wey-Yi Guy | 15b3f3b | 2011-06-03 07:54:13 -0700 | [diff] [blame] | 402 | |
Stanislaw Gruszka | 107ef97 | 2011-10-12 10:16:35 +0200 | [diff] [blame] | 403 | if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION && |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 404 | cfg(priv)->ht_params && cfg(priv)->ht_params->smps_mode) |
Wey-Yi Guy | 15b3f3b | 2011-06-03 07:54:13 -0700 | [diff] [blame] | 405 | ieee80211_request_smps(ctx->vif, |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 406 | cfg(priv)->ht_params->smps_mode); |
Wey-Yi Guy | 15b3f3b | 2011-06-03 07:54:13 -0700 | [diff] [blame] | 407 | |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 408 | return 0; |
| 409 | } |
| 410 | |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 411 | int iwlagn_set_pan_params(struct iwl_priv *priv) |
| 412 | { |
| 413 | struct iwl_wipan_params_cmd cmd; |
| 414 | struct iwl_rxon_context *ctx_bss, *ctx_pan; |
| 415 | int slot0 = 300, slot1 = 0; |
| 416 | int ret; |
| 417 | |
Johannes Berg | a18f61b | 2012-03-15 13:26:53 -0700 | [diff] [blame] | 418 | if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS)) |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 419 | return 0; |
| 420 | |
| 421 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); |
| 422 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 423 | lockdep_assert_held(&priv->mutex); |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 424 | |
| 425 | ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS]; |
| 426 | ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN]; |
| 427 | |
| 428 | /* |
| 429 | * If the PAN context is inactive, then we don't need |
| 430 | * to update the PAN parameters, the last thing we'll |
| 431 | * have done before it goes inactive is making the PAN |
| 432 | * parameters be WLAN-only. |
| 433 | */ |
| 434 | if (!ctx_pan->is_active) |
| 435 | return 0; |
| 436 | |
| 437 | memset(&cmd, 0, sizeof(cmd)); |
| 438 | |
| 439 | /* only 2 slots are currently allowed */ |
| 440 | cmd.num_slots = 2; |
| 441 | |
| 442 | cmd.slots[0].type = 0; /* BSS */ |
| 443 | cmd.slots[1].type = 1; /* PAN */ |
| 444 | |
Johannes Berg | c6baf7f | 2011-07-23 10:24:47 -0700 | [diff] [blame] | 445 | if (priv->hw_roc_setup) { |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 446 | /* both contexts must be used for this to happen */ |
Johannes Berg | c6baf7f | 2011-07-23 10:24:47 -0700 | [diff] [blame] | 447 | slot1 = IWL_MIN_SLOT_TIME; |
| 448 | slot0 = 3000; |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 449 | } else if (ctx_bss->vif && ctx_pan->vif) { |
Johannes Berg | bbb05cb | 2011-07-18 01:59:22 -0700 | [diff] [blame] | 450 | int bcnint = ctx_pan->beacon_int; |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 451 | int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1; |
| 452 | |
| 453 | /* should be set, but seems unused?? */ |
| 454 | cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE); |
| 455 | |
| 456 | if (ctx_pan->vif->type == NL80211_IFTYPE_AP && |
| 457 | bcnint && |
Johannes Berg | bbb05cb | 2011-07-18 01:59:22 -0700 | [diff] [blame] | 458 | bcnint != ctx_bss->beacon_int) { |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 459 | IWL_ERR(priv, |
| 460 | "beacon intervals don't match (%d, %d)\n", |
Johannes Berg | bbb05cb | 2011-07-18 01:59:22 -0700 | [diff] [blame] | 461 | ctx_bss->beacon_int, ctx_pan->beacon_int); |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 462 | } else |
| 463 | bcnint = max_t(int, bcnint, |
Johannes Berg | bbb05cb | 2011-07-18 01:59:22 -0700 | [diff] [blame] | 464 | ctx_bss->beacon_int); |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 465 | if (!bcnint) |
| 466 | bcnint = DEFAULT_BEACON_INTERVAL; |
| 467 | slot0 = bcnint / 2; |
| 468 | slot1 = bcnint - slot0; |
| 469 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 470 | if (test_bit(STATUS_SCAN_HW, &priv->status) || |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 471 | (!ctx_bss->vif->bss_conf.idle && |
| 472 | !ctx_bss->vif->bss_conf.assoc)) { |
| 473 | slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME; |
| 474 | slot1 = IWL_MIN_SLOT_TIME; |
| 475 | } else if (!ctx_pan->vif->bss_conf.idle && |
| 476 | !ctx_pan->vif->bss_conf.assoc) { |
Johannes Berg | 325a7dd | 2011-09-22 15:14:55 -0700 | [diff] [blame] | 477 | slot1 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME; |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 478 | slot0 = IWL_MIN_SLOT_TIME; |
| 479 | } |
| 480 | } else if (ctx_pan->vif) { |
| 481 | slot0 = 0; |
| 482 | slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) * |
Johannes Berg | bbb05cb | 2011-07-18 01:59:22 -0700 | [diff] [blame] | 483 | ctx_pan->beacon_int; |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 484 | slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1); |
| 485 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 486 | if (test_bit(STATUS_SCAN_HW, &priv->status)) { |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 487 | slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME; |
| 488 | slot1 = IWL_MIN_SLOT_TIME; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | cmd.slots[0].width = cpu_to_le16(slot0); |
| 493 | cmd.slots[1].width = cpu_to_le16(slot1); |
| 494 | |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 495 | ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC, |
Wey-Yi Guy | e505c43 | 2011-07-07 08:27:41 -0700 | [diff] [blame] | 496 | sizeof(cmd), &cmd); |
| 497 | if (ret) |
| 498 | IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret); |
| 499 | |
| 500 | return ret; |
| 501 | } |
| 502 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 503 | /** |
| 504 | * iwlagn_commit_rxon - commit staging_rxon to hardware |
| 505 | * |
| 506 | * The RXON command in staging_rxon is committed to the hardware and |
| 507 | * the active_rxon structure is updated with the new data. This |
| 508 | * function correctly transitions out of the RXON_ASSOC_MSK state if |
| 509 | * a HW tune is required based on the RXON structure changes. |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 510 | * |
| 511 | * The connect/disconnect flow should be as the following: |
| 512 | * |
| 513 | * 1. make sure send RXON command with association bit unset if not connect |
| 514 | * this should include the channel and the band for the candidate |
| 515 | * to be connected to |
| 516 | * 2. Add Station before RXON association with the AP |
| 517 | * 3. RXON_timing has to send before RXON for connection |
| 518 | * 4. full RXON command - associated bit set |
| 519 | * 5. use RXON_ASSOC command to update any flags changes |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 520 | */ |
| 521 | int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) |
| 522 | { |
| 523 | /* cast away the const for active_rxon in this function */ |
| 524 | struct iwl_rxon_cmd *active = (void *)&ctx->active; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 525 | bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); |
| 526 | int ret; |
| 527 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 528 | lockdep_assert_held(&priv->mutex); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 529 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 530 | if (!iwl_is_alive(priv)) |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 531 | return -EBUSY; |
| 532 | |
| 533 | /* This function hardcodes a bunch of dual-mode assumptions */ |
| 534 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); |
| 535 | |
| 536 | if (!ctx->is_active) |
| 537 | return 0; |
| 538 | |
| 539 | /* always get timestamp with Rx frame */ |
| 540 | ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; |
| 541 | |
Stanislaw Gruszka | 42b70a5 | 2011-05-26 17:14:22 +0200 | [diff] [blame] | 542 | /* |
| 543 | * force CTS-to-self frames protection if RTS-CTS is not preferred |
| 544 | * one aggregation protection method |
| 545 | */ |
Johannes Berg | b9ad70d | 2012-03-06 13:30:55 -0800 | [diff] [blame] | 546 | if (!hw_params(priv).use_rts_for_aggregation) |
Stanislaw Gruszka | 42b70a5 | 2011-05-26 17:14:22 +0200 | [diff] [blame] | 547 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; |
| 548 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 549 | if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || |
| 550 | !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK)) |
| 551 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
| 552 | else |
| 553 | ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; |
| 554 | |
Emmanuel Grumbach | 522376d | 2011-09-06 09:31:19 -0700 | [diff] [blame] | 555 | iwl_print_rx_config_cmd(priv, ctx->ctxid); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 556 | ret = iwl_check_rxon_cmd(priv, ctx); |
| 557 | if (ret) { |
| 558 | IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); |
| 559 | return -EINVAL; |
| 560 | } |
| 561 | |
| 562 | /* |
| 563 | * receive commit_rxon request |
| 564 | * abort any previous channel switch if still in process |
| 565 | */ |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 566 | if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && |
Stanislaw Gruszka | 6f213ff | 2011-06-02 18:17:15 +0200 | [diff] [blame] | 567 | (priv->switch_channel != ctx->staging.channel)) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 568 | IWL_DEBUG_11H(priv, "abort channel switch on %d\n", |
Stanislaw Gruszka | 6f213ff | 2011-06-02 18:17:15 +0200 | [diff] [blame] | 569 | le16_to_cpu(priv->switch_channel)); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 570 | iwl_chswitch_done(priv, false); |
| 571 | } |
| 572 | |
| 573 | /* |
| 574 | * If we don't need to send a full RXON, we can use |
| 575 | * iwl_rxon_assoc_cmd which is used to reconfigure filter |
| 576 | * and other flags for the current radio configuration. |
| 577 | */ |
| 578 | if (!iwl_full_rxon_required(priv, ctx)) { |
Wey-Yi Guy | c3f6e9c | 2011-04-19 16:52:57 -0700 | [diff] [blame] | 579 | ret = iwlagn_send_rxon_assoc(priv, ctx); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 580 | if (ret) { |
| 581 | IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); |
| 582 | return ret; |
| 583 | } |
| 584 | |
| 585 | memcpy(active, &ctx->staging, sizeof(*active)); |
Wey-Yi Guy | 891db88 | 2011-05-27 08:40:24 -0700 | [diff] [blame] | 586 | /* |
| 587 | * We do not commit tx power settings while channel changing, |
| 588 | * do it now if after settings changed. |
| 589 | */ |
| 590 | iwl_set_tx_power(priv, priv->tx_power_next, false); |
Wey-Yi Guy | 15b3f3b | 2011-06-03 07:54:13 -0700 | [diff] [blame] | 591 | |
| 592 | /* make sure we are in the right PS state */ |
| 593 | iwl_power_update_mode(priv, true); |
| 594 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 595 | return 0; |
| 596 | } |
| 597 | |
Don Fry | 9d143e9 | 2011-04-20 15:23:57 -0700 | [diff] [blame] | 598 | iwl_set_rxon_hwcrypto(priv, ctx, !iwlagn_mod_params.sw_crypto); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 599 | |
| 600 | IWL_DEBUG_INFO(priv, |
| 601 | "Going to commit RXON\n" |
| 602 | " * with%s RXON_FILTER_ASSOC_MSK\n" |
| 603 | " * channel = %d\n" |
| 604 | " * bssid = %pM\n", |
| 605 | (new_assoc ? "" : "out"), |
| 606 | le16_to_cpu(ctx->staging.channel), |
| 607 | ctx->staging.bssid_addr); |
| 608 | |
| 609 | /* |
Johannes Berg | 52d980c | 2010-11-10 09:56:45 -0800 | [diff] [blame] | 610 | * Always clear associated first, but with the correct config. |
| 611 | * This is required as for example station addition for the |
| 612 | * AP station must be done after the BSSID is set to correctly |
| 613 | * set up filters in the device. |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 614 | */ |
Wey-Yi Guy | 3083d03 | 2011-05-06 17:06:44 -0700 | [diff] [blame] | 615 | ret = iwlagn_rxon_disconn(priv, ctx); |
| 616 | if (ret) |
| 617 | return ret; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 618 | |
Wey-Yi Guy | e3f10ce | 2011-07-01 07:59:26 -0700 | [diff] [blame] | 619 | ret = iwlagn_set_pan_params(priv); |
| 620 | if (ret) |
| 621 | return ret; |
Johannes Berg | 2b9253d | 2011-05-27 08:40:26 -0700 | [diff] [blame] | 622 | |
Wey-Yi Guy | c1821c9 | 2011-04-19 16:52:59 -0700 | [diff] [blame] | 623 | if (new_assoc) |
| 624 | return iwlagn_rxon_connect(priv, ctx); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | |
Wey-Yi Guy | 34a5b4b | 2011-12-02 08:19:18 -0800 | [diff] [blame] | 629 | void iwlagn_config_ht40(struct ieee80211_conf *conf, |
| 630 | struct iwl_rxon_context *ctx) |
| 631 | { |
| 632 | if (conf_is_ht40_minus(conf)) { |
| 633 | ctx->ht.extension_chan_offset = |
| 634 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
| 635 | ctx->ht.is_40mhz = true; |
| 636 | } else if (conf_is_ht40_plus(conf)) { |
| 637 | ctx->ht.extension_chan_offset = |
| 638 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
| 639 | ctx->ht.is_40mhz = true; |
| 640 | } else { |
| 641 | ctx->ht.extension_chan_offset = |
| 642 | IEEE80211_HT_PARAM_CHA_SEC_NONE; |
| 643 | ctx->ht.is_40mhz = false; |
| 644 | } |
| 645 | } |
| 646 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 647 | int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) |
| 648 | { |
Emmanuel Grumbach | d0f76d6 | 2012-02-09 16:08:15 +0200 | [diff] [blame] | 649 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 650 | struct iwl_rxon_context *ctx; |
| 651 | struct ieee80211_conf *conf = &hw->conf; |
| 652 | struct ieee80211_channel *channel = conf->channel; |
| 653 | const struct iwl_channel_info *ch_info; |
| 654 | int ret = 0; |
| 655 | |
Johannes Berg | 0ca24da | 2012-03-15 13:26:46 -0700 | [diff] [blame] | 656 | IWL_DEBUG_MAC80211(priv, "enter: changed %#x\n", changed); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 657 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 658 | mutex_lock(&priv->mutex); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 659 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 660 | if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 661 | IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); |
| 662 | goto out; |
| 663 | } |
| 664 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 665 | if (!iwl_is_ready(priv)) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 666 | IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); |
| 667 | goto out; |
| 668 | } |
| 669 | |
| 670 | if (changed & (IEEE80211_CONF_CHANGE_SMPS | |
| 671 | IEEE80211_CONF_CHANGE_CHANNEL)) { |
| 672 | /* mac80211 uses static for non-HT which is what we want */ |
| 673 | priv->current_ht_config.smps = conf->smps_mode; |
| 674 | |
| 675 | /* |
| 676 | * Recalculate chain counts. |
| 677 | * |
| 678 | * If monitor mode is enabled then mac80211 will |
| 679 | * set up the SM PS mode to OFF if an HT channel is |
| 680 | * configured. |
| 681 | */ |
Wey-Yi Guy | e3f10ce | 2011-07-01 07:59:26 -0700 | [diff] [blame] | 682 | for_each_context(priv, ctx) |
| 683 | iwlagn_set_rxon_chain(priv, ctx); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 687 | ch_info = iwl_get_channel_info(priv, channel->band, |
| 688 | channel->hw_value); |
| 689 | if (!is_channel_valid(ch_info)) { |
| 690 | IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); |
| 691 | ret = -EINVAL; |
| 692 | goto out; |
| 693 | } |
| 694 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 695 | for_each_context(priv, ctx) { |
| 696 | /* Configure HT40 channels */ |
Daniel Halperin | 7caa231 | 2011-04-06 12:47:25 -0700 | [diff] [blame] | 697 | if (ctx->ht.enabled != conf_is_ht(conf)) |
Wey-Yi Guy | 35a6eb3 | 2010-11-10 09:56:43 -0800 | [diff] [blame] | 698 | ctx->ht.enabled = conf_is_ht(conf); |
Wey-Yi Guy | 35a6eb3 | 2010-11-10 09:56:43 -0800 | [diff] [blame] | 699 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 700 | if (ctx->ht.enabled) { |
Wey-Yi Guy | 34a5b4b | 2011-12-02 08:19:18 -0800 | [diff] [blame] | 701 | /* if HT40 is used, it should not change |
| 702 | * after associated except channel switch */ |
Wey-Yi Guy | 78feb35 | 2011-12-14 08:22:36 -0800 | [diff] [blame] | 703 | if (!ctx->ht.is_40mhz || |
| 704 | !iwl_is_associated_ctx(ctx)) |
Wey-Yi Guy | 34a5b4b | 2011-12-02 08:19:18 -0800 | [diff] [blame] | 705 | iwlagn_config_ht40(conf, ctx); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 706 | } else |
| 707 | ctx->ht.is_40mhz = false; |
| 708 | |
| 709 | /* |
| 710 | * Default to no protection. Protection mode will |
| 711 | * later be set from BSS config in iwl_ht_conf |
| 712 | */ |
| 713 | ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; |
| 714 | |
| 715 | /* if we are switching from ht to 2.4 clear flags |
| 716 | * from any ht related info since 2.4 does not |
| 717 | * support ht */ |
| 718 | if (le16_to_cpu(ctx->staging.channel) != |
| 719 | channel->hw_value) |
| 720 | ctx->staging.flags = 0; |
| 721 | |
| 722 | iwl_set_rxon_channel(priv, channel, ctx); |
| 723 | iwl_set_rxon_ht(priv, &priv->current_ht_config); |
| 724 | |
| 725 | iwl_set_flags_for_band(priv, ctx, channel->band, |
| 726 | ctx->vif); |
| 727 | } |
| 728 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 729 | iwl_update_bcast_stations(priv); |
| 730 | |
| 731 | /* |
| 732 | * The list of supported rates and rate mask can be different |
| 733 | * for each band; since the band may have changed, reset |
| 734 | * the rate mask to what mac80211 lists. |
| 735 | */ |
| 736 | iwl_set_rate(priv); |
| 737 | } |
| 738 | |
| 739 | if (changed & (IEEE80211_CONF_CHANGE_PS | |
| 740 | IEEE80211_CONF_CHANGE_IDLE)) { |
| 741 | ret = iwl_power_update_mode(priv, false); |
| 742 | if (ret) |
| 743 | IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); |
| 744 | } |
| 745 | |
| 746 | if (changed & IEEE80211_CONF_CHANGE_POWER) { |
| 747 | IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", |
| 748 | priv->tx_power_user_lmt, conf->power_level); |
| 749 | |
| 750 | iwl_set_tx_power(priv, conf->power_level, false); |
| 751 | } |
| 752 | |
| 753 | for_each_context(priv, ctx) { |
| 754 | if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) |
| 755 | continue; |
| 756 | iwlagn_commit_rxon(priv, ctx); |
| 757 | } |
| 758 | out: |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 759 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | 770c72c | 2011-10-10 07:27:10 -0700 | [diff] [blame] | 760 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 761 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 762 | return ret; |
| 763 | } |
| 764 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 765 | static void iwlagn_check_needed_chains(struct iwl_priv *priv, |
| 766 | struct iwl_rxon_context *ctx, |
| 767 | struct ieee80211_bss_conf *bss_conf) |
| 768 | { |
| 769 | struct ieee80211_vif *vif = ctx->vif; |
| 770 | struct iwl_rxon_context *tmp; |
| 771 | struct ieee80211_sta *sta; |
| 772 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; |
Johannes Berg | 850bedc | 2011-02-25 12:24:11 +0100 | [diff] [blame] | 773 | struct ieee80211_sta_ht_cap *ht_cap; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 774 | bool need_multiple; |
| 775 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 776 | lockdep_assert_held(&priv->mutex); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 777 | |
| 778 | switch (vif->type) { |
| 779 | case NL80211_IFTYPE_STATION: |
| 780 | rcu_read_lock(); |
| 781 | sta = ieee80211_find_sta(vif, bss_conf->bssid); |
Johannes Berg | 850bedc | 2011-02-25 12:24:11 +0100 | [diff] [blame] | 782 | if (!sta) { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 783 | /* |
| 784 | * If at all, this can only happen through a race |
| 785 | * when the AP disconnects us while we're still |
| 786 | * setting up the connection, in that case mac80211 |
| 787 | * will soon tell us about that. |
| 788 | */ |
| 789 | need_multiple = false; |
Johannes Berg | 850bedc | 2011-02-25 12:24:11 +0100 | [diff] [blame] | 790 | rcu_read_unlock(); |
| 791 | break; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 792 | } |
Johannes Berg | 850bedc | 2011-02-25 12:24:11 +0100 | [diff] [blame] | 793 | |
| 794 | ht_cap = &sta->ht_cap; |
| 795 | |
| 796 | need_multiple = true; |
| 797 | |
| 798 | /* |
| 799 | * If the peer advertises no support for receiving 2 and 3 |
| 800 | * stream MCS rates, it can't be transmitting them either. |
| 801 | */ |
| 802 | if (ht_cap->mcs.rx_mask[1] == 0 && |
| 803 | ht_cap->mcs.rx_mask[2] == 0) { |
| 804 | need_multiple = false; |
| 805 | } else if (!(ht_cap->mcs.tx_params & |
| 806 | IEEE80211_HT_MCS_TX_DEFINED)) { |
| 807 | /* If it can't TX MCS at all ... */ |
| 808 | need_multiple = false; |
| 809 | } else if (ht_cap->mcs.tx_params & |
| 810 | IEEE80211_HT_MCS_TX_RX_DIFF) { |
| 811 | int maxstreams; |
| 812 | |
| 813 | /* |
| 814 | * But if it can receive them, it might still not |
| 815 | * be able to transmit them, which is what we need |
| 816 | * to check here -- so check the number of streams |
| 817 | * it advertises for TX (if different from RX). |
| 818 | */ |
| 819 | |
| 820 | maxstreams = (ht_cap->mcs.tx_params & |
| 821 | IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK); |
| 822 | maxstreams >>= |
| 823 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; |
| 824 | maxstreams += 1; |
| 825 | |
| 826 | if (maxstreams <= 1) |
| 827 | need_multiple = false; |
| 828 | } |
| 829 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 830 | rcu_read_unlock(); |
| 831 | break; |
| 832 | case NL80211_IFTYPE_ADHOC: |
| 833 | /* currently */ |
| 834 | need_multiple = false; |
| 835 | break; |
| 836 | default: |
| 837 | /* only AP really */ |
| 838 | need_multiple = true; |
| 839 | break; |
| 840 | } |
| 841 | |
| 842 | ctx->ht_need_multiple_chains = need_multiple; |
| 843 | |
| 844 | if (!need_multiple) { |
| 845 | /* check all contexts */ |
| 846 | for_each_context(priv, tmp) { |
| 847 | if (!tmp->vif) |
| 848 | continue; |
| 849 | if (tmp->ht_need_multiple_chains) { |
| 850 | need_multiple = true; |
| 851 | break; |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | ht_conf->single_chain_sufficient = !need_multiple; |
| 857 | } |
| 858 | |
Don Fry | 5c3d29f | 2011-07-08 08:46:29 -0700 | [diff] [blame] | 859 | static void iwlagn_chain_noise_reset(struct iwl_priv *priv) |
| 860 | { |
| 861 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; |
| 862 | int ret; |
| 863 | |
| 864 | if ((data->state == IWL_CHAIN_NOISE_ALIVE) && |
| 865 | iwl_is_any_associated(priv)) { |
| 866 | struct iwl_calib_chain_noise_reset_cmd cmd; |
| 867 | |
| 868 | /* clear data for chain noise calibration algorithm */ |
| 869 | data->chain_noise_a = 0; |
| 870 | data->chain_noise_b = 0; |
| 871 | data->chain_noise_c = 0; |
| 872 | data->chain_signal_a = 0; |
| 873 | data->chain_signal_b = 0; |
| 874 | data->chain_signal_c = 0; |
| 875 | data->beacon_count = 0; |
| 876 | |
| 877 | memset(&cmd, 0, sizeof(cmd)); |
| 878 | iwl_set_calib_hdr(&cmd.hdr, |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 879 | priv->phy_calib_chain_noise_reset_cmd); |
Johannes Berg | e10a053 | 2012-03-06 13:30:39 -0800 | [diff] [blame] | 880 | ret = iwl_dvm_send_cmd_pdu(priv, |
Don Fry | 5c3d29f | 2011-07-08 08:46:29 -0700 | [diff] [blame] | 881 | REPLY_PHY_CALIBRATION_CMD, |
| 882 | CMD_SYNC, sizeof(cmd), &cmd); |
| 883 | if (ret) |
| 884 | IWL_ERR(priv, |
| 885 | "Could not send REPLY_PHY_CALIBRATION_CMD\n"); |
| 886 | data->state = IWL_CHAIN_NOISE_ACCUMULATE; |
| 887 | IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); |
| 888 | } |
| 889 | } |
| 890 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 891 | void iwlagn_bss_info_changed(struct ieee80211_hw *hw, |
| 892 | struct ieee80211_vif *vif, |
| 893 | struct ieee80211_bss_conf *bss_conf, |
| 894 | u32 changes) |
| 895 | { |
Emmanuel Grumbach | d0f76d6 | 2012-02-09 16:08:15 +0200 | [diff] [blame] | 896 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 897 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
| 898 | int ret; |
| 899 | bool force = false; |
| 900 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 901 | mutex_lock(&priv->mutex); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 902 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 903 | if (unlikely(!iwl_is_ready(priv))) { |
Wey-Yi Guy | 14a085e | 2010-12-14 07:38:58 -0800 | [diff] [blame] | 904 | IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 905 | mutex_unlock(&priv->mutex); |
Shanyu Zhao | ae0b693 | 2010-12-02 11:02:28 -0800 | [diff] [blame] | 906 | return; |
| 907 | } |
| 908 | |
| 909 | if (unlikely(!ctx->vif)) { |
| 910 | IWL_DEBUG_MAC80211(priv, "leave - vif is NULL\n"); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 911 | mutex_unlock(&priv->mutex); |
Johannes Berg | 893654d | 2010-11-10 18:25:47 -0800 | [diff] [blame] | 912 | return; |
| 913 | } |
| 914 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 915 | if (changes & BSS_CHANGED_BEACON_INT) |
| 916 | force = true; |
| 917 | |
| 918 | if (changes & BSS_CHANGED_QOS) { |
| 919 | ctx->qos_data.qos_active = bss_conf->qos; |
| 920 | iwlagn_update_qos(priv, ctx); |
| 921 | } |
| 922 | |
| 923 | ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); |
| 924 | if (vif->bss_conf.use_short_preamble) |
| 925 | ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
| 926 | else |
| 927 | ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; |
| 928 | |
| 929 | if (changes & BSS_CHANGED_ASSOC) { |
| 930 | if (bss_conf->assoc) { |
Johannes Berg | e9ac074 | 2012-03-13 14:29:30 +0100 | [diff] [blame] | 931 | priv->timestamp = bss_conf->last_tsf; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 932 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; |
| 933 | } else { |
Garen Tamrazian | 68b9931 | 2011-03-30 02:29:32 -0700 | [diff] [blame] | 934 | /* |
| 935 | * If we disassociate while there are pending |
| 936 | * frames, just wake up the queues and let the |
| 937 | * frames "escape" ... This shouldn't really |
| 938 | * be happening to start with, but we should |
| 939 | * not get stuck in this case either since it |
| 940 | * can happen if userspace gets confused. |
| 941 | */ |
Johannes Berg | e755f88 | 2012-03-07 09:52:16 -0800 | [diff] [blame] | 942 | iwlagn_lift_passive_no_rx(priv); |
| 943 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 944 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 945 | |
| 946 | if (ctx->ctxid == IWL_RXON_CTX_BSS) |
| 947 | priv->have_rekey_data = false; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 948 | } |
Meenakshi Venkataraman | 207ecc5 | 2011-07-08 08:46:23 -0700 | [diff] [blame] | 949 | |
| 950 | iwlagn_bt_coex_rssi_monitor(priv); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | if (ctx->ht.enabled) { |
| 954 | ctx->ht.protection = bss_conf->ht_operation_mode & |
| 955 | IEEE80211_HT_OP_MODE_PROTECTION; |
| 956 | ctx->ht.non_gf_sta_present = !!(bss_conf->ht_operation_mode & |
| 957 | IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); |
| 958 | iwlagn_check_needed_chains(priv, ctx, bss_conf); |
Johannes Berg | b2769b8 | 2010-11-10 09:56:47 -0800 | [diff] [blame] | 959 | iwl_set_rxon_ht(priv, &priv->current_ht_config); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 960 | } |
| 961 | |
Wey-Yi Guy | e3f10ce | 2011-07-01 07:59:26 -0700 | [diff] [blame] | 962 | iwlagn_set_rxon_chain(priv, ctx); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 963 | |
| 964 | if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) |
| 965 | ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; |
| 966 | else |
| 967 | ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; |
| 968 | |
| 969 | if (bss_conf->use_cts_prot) |
| 970 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; |
| 971 | else |
| 972 | ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; |
| 973 | |
| 974 | memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); |
| 975 | |
| 976 | if (vif->type == NL80211_IFTYPE_AP || |
| 977 | vif->type == NL80211_IFTYPE_ADHOC) { |
| 978 | if (vif->bss_conf.enable_beacon) { |
| 979 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; |
| 980 | priv->beacon_ctx = ctx; |
| 981 | } else { |
| 982 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 983 | priv->beacon_ctx = NULL; |
| 984 | } |
| 985 | } |
| 986 | |
Meenakshi Venkataraman | 758f555 | 2012-02-08 12:04:41 -0800 | [diff] [blame] | 987 | /* |
| 988 | * If the ucode decides to do beacon filtering before |
| 989 | * association, it will lose beacons that are needed |
| 990 | * before sending frames out on passive channels. This |
| 991 | * causes association failures on those channels. Enable |
| 992 | * receiving beacons in such cases. |
| 993 | */ |
| 994 | |
| 995 | if (vif->type == NL80211_IFTYPE_STATION) { |
| 996 | if (!bss_conf->assoc) |
| 997 | ctx->staging.filter_flags |= RXON_FILTER_BCON_AWARE_MSK; |
| 998 | else |
| 999 | ctx->staging.filter_flags &= |
| 1000 | ~RXON_FILTER_BCON_AWARE_MSK; |
| 1001 | } |
| 1002 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 1003 | if (force || memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) |
| 1004 | iwlagn_commit_rxon(priv, ctx); |
| 1005 | |
Johannes Berg | 8da8e62 | 2010-11-10 09:56:46 -0800 | [diff] [blame] | 1006 | if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) { |
| 1007 | /* |
| 1008 | * The chain noise calibration will enable PM upon |
| 1009 | * completion. If calibration has already been run |
| 1010 | * then we need to enable power management here. |
| 1011 | */ |
| 1012 | if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE) |
| 1013 | iwl_power_update_mode(priv, false); |
| 1014 | |
| 1015 | /* Enable RX differential gain and sensitivity calibrations */ |
Don Fry | 5c3d29f | 2011-07-08 08:46:29 -0700 | [diff] [blame] | 1016 | if (!priv->disable_chain_noise_cal) |
| 1017 | iwlagn_chain_noise_reset(priv); |
Johannes Berg | 8da8e62 | 2010-11-10 09:56:46 -0800 | [diff] [blame] | 1018 | priv->start_calib = 1; |
| 1019 | } |
| 1020 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 1021 | if (changes & BSS_CHANGED_IBSS) { |
| 1022 | ret = iwlagn_manage_ibss_station(priv, vif, |
| 1023 | bss_conf->ibss_joined); |
| 1024 | if (ret) |
| 1025 | IWL_ERR(priv, "failed to %s IBSS station %pM\n", |
| 1026 | bss_conf->ibss_joined ? "add" : "remove", |
| 1027 | bss_conf->bssid); |
| 1028 | } |
| 1029 | |
Johannes Berg | bd50a8ab | 2010-10-23 09:15:42 -0700 | [diff] [blame] | 1030 | if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_ADHOC && |
| 1031 | priv->beacon_ctx) { |
| 1032 | if (iwlagn_update_beacon(priv, vif)) |
| 1033 | IWL_ERR(priv, "Error sending IBSS beacon\n"); |
| 1034 | } |
| 1035 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1036 | mutex_unlock(&priv->mutex); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 1037 | } |
Johannes Berg | ae79d23 | 2010-11-10 09:56:38 -0800 | [diff] [blame] | 1038 | |
| 1039 | void iwlagn_post_scan(struct iwl_priv *priv) |
| 1040 | { |
| 1041 | struct iwl_rxon_context *ctx; |
| 1042 | |
| 1043 | /* |
Wey-Yi Guy | c2b821d | 2011-06-03 07:54:14 -0700 | [diff] [blame] | 1044 | * We do not commit power settings while scan is pending, |
| 1045 | * do it now if the settings changed. |
| 1046 | */ |
| 1047 | iwl_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); |
| 1048 | iwl_set_tx_power(priv, priv->tx_power_next, false); |
| 1049 | |
| 1050 | /* |
Johannes Berg | ae79d23 | 2010-11-10 09:56:38 -0800 | [diff] [blame] | 1051 | * Since setting the RXON may have been deferred while |
| 1052 | * performing the scan, fire one off if needed |
| 1053 | */ |
| 1054 | for_each_context(priv, ctx) |
| 1055 | if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) |
| 1056 | iwlagn_commit_rxon(priv, ctx); |
| 1057 | |
Wey-Yi Guy | e3f10ce | 2011-07-01 07:59:26 -0700 | [diff] [blame] | 1058 | iwlagn_set_pan_params(priv); |
Johannes Berg | ae79d23 | 2010-11-10 09:56:38 -0800 | [diff] [blame] | 1059 | } |