blob: 822f1a00efbb7c5f40ed3edf7ca14f11103d49cc [file] [log] [blame]
Wey-Yi Guy73356132011-11-10 06:55:11 -08001/******************************************************************************
2 *
Johannes Berg128e63e2013-01-21 21:39:26 +01003 * Copyright(c) 2003 - 2013 Intel Corporation. All rights reserved.
Wey-Yi Guy73356132011-11-10 06:55:11 -08004 *
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/slab.h>
33#include <linux/dma-mapping.h>
34#include <linux/delay.h>
35#include <linux/sched.h>
36#include <linux/skbuff.h>
37#include <linux/netdevice.h>
Wey-Yi Guy73356132011-11-10 06:55:11 -080038#include <linux/etherdevice.h>
39#include <linux/if_arp.h>
40
Johannes Berg53e11162012-05-16 23:59:03 +020041#include <net/ieee80211_radiotap.h>
Wey-Yi Guy73356132011-11-10 06:55:11 -080042#include <net/mac80211.h>
43
44#include <asm/div64.h>
45
Wey-Yi Guy73356132011-11-10 06:55:11 -080046#include "iwl-io.h"
Wey-Yi Guy73356132011-11-10 06:55:11 -080047#include "iwl-trans.h"
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +020048#include "iwl-op-mode.h"
Johannes Berg65de7e82012-04-17 07:36:30 -070049#include "iwl-modparams.h"
Wey-Yi Guy73356132011-11-10 06:55:11 -080050
Johannes Berg1023fdc2012-05-15 12:16:34 +020051#include "dev.h"
52#include "calib.h"
53#include "agn.h"
54
Wey-Yi Guy73356132011-11-10 06:55:11 -080055/*****************************************************************************
56 *
57 * mac80211 entry point functions
58 *
59 *****************************************************************************/
60
61static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = {
62 {
63 .max = 1,
64 .types = BIT(NL80211_IFTYPE_STATION),
65 },
66 {
67 .max = 1,
68 .types = BIT(NL80211_IFTYPE_AP),
69 },
70};
71
72static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = {
73 {
74 .max = 2,
75 .types = BIT(NL80211_IFTYPE_STATION),
76 },
77};
78
79static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = {
80 {
81 .max = 1,
82 .types = BIT(NL80211_IFTYPE_STATION),
83 },
84 {
85 .max = 1,
86 .types = BIT(NL80211_IFTYPE_P2P_GO) |
87 BIT(NL80211_IFTYPE_AP),
88 },
89};
90
91static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = {
92 {
93 .max = 2,
94 .types = BIT(NL80211_IFTYPE_STATION),
95 },
96 {
97 .max = 1,
98 .types = BIT(NL80211_IFTYPE_P2P_CLIENT),
99 },
100};
101
102static const struct ieee80211_iface_combination
103iwlagn_iface_combinations_dualmode[] = {
104 { .num_different_channels = 1,
105 .max_interfaces = 2,
106 .beacon_int_infra_match = true,
107 .limits = iwlagn_sta_ap_limits,
108 .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits),
109 },
110 { .num_different_channels = 1,
111 .max_interfaces = 2,
112 .limits = iwlagn_2sta_limits,
113 .n_limits = ARRAY_SIZE(iwlagn_2sta_limits),
114 },
115};
116
117static const struct ieee80211_iface_combination
118iwlagn_iface_combinations_p2p[] = {
119 { .num_different_channels = 1,
120 .max_interfaces = 2,
121 .beacon_int_infra_match = true,
122 .limits = iwlagn_p2p_sta_go_limits,
123 .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits),
124 },
125 { .num_different_channels = 1,
126 .max_interfaces = 2,
127 .limits = iwlagn_p2p_2sta_limits,
128 .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits),
129 },
130};
131
132/*
133 * Not a mac80211 entry point function, but it fits in with all the
134 * other mac80211 functions grouped here.
135 */
136int iwlagn_mac_setup_register(struct iwl_priv *priv,
Johannes Berg0692fe42012-03-06 13:30:37 -0800137 const struct iwl_ucode_capabilities *capa)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800138{
139 int ret;
140 struct ieee80211_hw *hw = priv->hw;
141 struct iwl_rxon_context *ctx;
142
143 hw->rate_control_algorithm = "iwl-agn-rs";
144
145 /* Tell mac80211 our characteristics */
146 hw->flags = IEEE80211_HW_SIGNAL_DBM |
147 IEEE80211_HW_AMPDU_AGGREGATION |
Emmanuel Grumbachc65dd142012-12-12 10:12:24 +0200148 IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC |
Wey-Yi Guy73356132011-11-10 06:55:11 -0800149 IEEE80211_HW_SPECTRUM_MGMT |
Johannes Berg14791772012-04-17 07:39:03 -0700150 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
151 IEEE80211_HW_QUEUE_CONTROL |
152 IEEE80211_HW_SUPPORTS_PS |
153 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
Johannes Bergf1e3e052013-02-06 23:57:57 +0100154 IEEE80211_HW_WANT_MONITOR_VIF;
Johannes Berg14791772012-04-17 07:39:03 -0700155
156 hw->offchannel_tx_hw_queue = IWL_AUX_QUEUE;
Johannes Berg53e11162012-05-16 23:59:03 +0200157 hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FMT;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800158
159 /*
160 * Including the following line will crash some AP's. This
161 * workaround removes the stimulus which causes the crash until
162 * the AP software can be fixed.
163 hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
164 */
165
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200166 if (priv->nvm_data->sku_cap_11n_enable)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800167 hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
168 IEEE80211_HW_SUPPORTS_STATIC_SMPS;
169
Johannes Berg686681b2012-11-15 11:35:57 +0100170 /*
171 * Enable 11w if advertised by firmware and software crypto
172 * is not enabled (as the firmware will interpret some mgmt
173 * packets, so enabling it with software crypto isn't safe)
174 */
175 if (priv->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP &&
176 !iwlwifi_mod_params.sw_crypto)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800177 hw->flags |= IEEE80211_HW_MFP_CAPABLE;
178
179 hw->sta_data_size = sizeof(struct iwl_station_priv);
180 hw->vif_data_size = sizeof(struct iwl_vif_priv);
181
182 for_each_context(priv, ctx) {
183 hw->wiphy->interface_modes |= ctx->interface_modes;
184 hw->wiphy->interface_modes |= ctx->exclusive_interface_modes;
185 }
186
187 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
188
189 if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) {
190 hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p;
191 hw->wiphy->n_iface_combinations =
192 ARRAY_SIZE(iwlagn_iface_combinations_p2p);
193 } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) {
194 hw->wiphy->iface_combinations =
195 iwlagn_iface_combinations_dualmode;
196 hw->wiphy->n_iface_combinations =
197 ARRAY_SIZE(iwlagn_iface_combinations_dualmode);
198 }
199
Johannes Bergda0cabb2012-07-25 17:06:47 +0200200 hw->wiphy->max_remain_on_channel_duration = 500;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800201
202 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
203 WIPHY_FLAG_DISABLE_BEACON_HINTS |
204 WIPHY_FLAG_IBSS_RSN;
205
Johannes Bergfcb6ff52012-06-04 13:43:11 +0200206#ifdef CONFIG_PM_SLEEP
David Spinadel6dfa8d02012-03-10 13:00:14 -0800207 if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len &&
Johannes Bergddaf5a52013-01-08 11:25:44 +0100208 priv->trans->ops->d3_suspend &&
209 priv->trans->ops->d3_resume &&
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700210 device_can_wakeup(priv->trans->dev)) {
Johannes Berg964dc9e2013-06-03 17:25:34 +0200211 priv->wowlan_support.flags = WIPHY_WOWLAN_MAGIC_PKT |
212 WIPHY_WOWLAN_DISCONNECT |
213 WIPHY_WOWLAN_EAP_IDENTITY_REQ |
214 WIPHY_WOWLAN_RFKILL_RELEASE;
Johannes Berg65de7e82012-04-17 07:36:30 -0700215 if (!iwlwifi_mod_params.sw_crypto)
Johannes Berg964dc9e2013-06-03 17:25:34 +0200216 priv->wowlan_support.flags |=
Wey-Yi Guy73356132011-11-10 06:55:11 -0800217 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
218 WIPHY_WOWLAN_GTK_REKEY_FAILURE;
219
Johannes Berg964dc9e2013-06-03 17:25:34 +0200220 priv->wowlan_support.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS;
221 priv->wowlan_support.pattern_min_len =
Wey-Yi Guy73356132011-11-10 06:55:11 -0800222 IWLAGN_WOWLAN_MIN_PATTERN_LEN;
Johannes Berg964dc9e2013-06-03 17:25:34 +0200223 priv->wowlan_support.pattern_max_len =
Wey-Yi Guy73356132011-11-10 06:55:11 -0800224 IWLAGN_WOWLAN_MAX_PATTERN_LEN;
Johannes Berg964dc9e2013-06-03 17:25:34 +0200225 hw->wiphy->wowlan = &priv->wowlan_support;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800226 }
Johannes Bergfcb6ff52012-06-04 13:43:11 +0200227#endif
Wey-Yi Guy73356132011-11-10 06:55:11 -0800228
Johannes Berg65de7e82012-04-17 07:36:30 -0700229 if (iwlwifi_mod_params.power_save)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800230 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
231 else
232 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
233
234 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
David Spinadel4f9bfbb2012-05-11 10:53:16 +0200235 /* we create the 802.11 header and a max-length SSID element */
236 hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 34;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800237
Johannes Berg14791772012-04-17 07:39:03 -0700238 /*
239 * We don't use all queues: 4 and 9 are unused and any
240 * aggregation queue gets mapped down to the AC queue.
241 */
242 hw->queues = IWLAGN_FIRST_AMPDU_QUEUE;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800243
244 hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
245
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200246 if (priv->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800247 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200248 &priv->nvm_data->bands[IEEE80211_BAND_2GHZ];
249 if (priv->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800250 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200251 &priv->nvm_data->bands[IEEE80211_BAND_5GHZ];
Wey-Yi Guy73356132011-11-10 06:55:11 -0800252
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700253 hw->wiphy->hw_version = priv->trans->hw_id;
Wey-Yi Guy0ba958e2011-12-10 11:33:52 -0800254
Wey-Yi Guy73356132011-11-10 06:55:11 -0800255 iwl_leds_init(priv);
256
257 ret = ieee80211_register_hw(priv->hw);
258 if (ret) {
259 IWL_ERR(priv, "Failed to register hw (error %d)\n", ret);
Johannes Berg0e1fa7e2012-06-05 09:38:35 +0200260 iwl_leds_exit(priv);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800261 return ret;
262 }
263 priv->mac80211_registered = 1;
264
265 return 0;
266}
267
Don Fry09af1402011-12-09 10:07:38 -0800268void iwlagn_mac_unregister(struct iwl_priv *priv)
269{
270 if (!priv->mac80211_registered)
271 return;
272 iwl_leds_exit(priv);
273 ieee80211_unregister_hw(priv->hw);
274 priv->mac80211_registered = 0;
275}
276
Wey-Yi Guy73356132011-11-10 06:55:11 -0800277static int __iwl_up(struct iwl_priv *priv)
278{
279 struct iwl_rxon_context *ctx;
280 int ret;
281
Johannes Bergb1eea292012-03-06 13:30:42 -0800282 lockdep_assert_held(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800283
Don Fry83626402012-03-07 09:52:37 -0800284 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
Wey-Yi Guy73356132011-11-10 06:55:11 -0800285 IWL_WARN(priv, "Exit pending; will not bring the NIC up\n");
286 return -EIO;
287 }
288
289 for_each_context(priv, ctx) {
290 ret = iwlagn_alloc_bcast_station(priv, ctx);
291 if (ret) {
292 iwl_dealloc_bcast_stations(priv);
293 return ret;
294 }
295 }
296
Johannes Berge1991882012-03-06 13:30:36 -0800297 ret = iwl_run_init_ucode(priv);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800298 if (ret) {
299 IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret);
300 goto error;
301 }
302
Johannes Berge1991882012-03-06 13:30:36 -0800303 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800304 if (ret) {
305 IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret);
306 goto error;
307 }
308
309 ret = iwl_alive_start(priv);
310 if (ret)
311 goto error;
312 return 0;
313
314 error:
Don Fry83626402012-03-07 09:52:37 -0800315 set_bit(STATUS_EXIT_PENDING, &priv->status);
Emmanuel Grumbach78e5a462012-02-17 10:34:53 -0800316 iwl_down(priv);
Don Fry83626402012-03-07 09:52:37 -0800317 clear_bit(STATUS_EXIT_PENDING, &priv->status);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800318
319 IWL_ERR(priv, "Unable to initialize device.\n");
320 return ret;
321}
322
323static int iwlagn_mac_start(struct ieee80211_hw *hw)
324{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200325 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800326 int ret;
327
328 IWL_DEBUG_MAC80211(priv, "enter\n");
329
330 /* we should be verifying the device is ready to be opened */
Johannes Bergb1eea292012-03-06 13:30:42 -0800331 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800332 ret = __iwl_up(priv);
Johannes Bergb1eea292012-03-06 13:30:42 -0800333 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800334 if (ret)
335 return ret;
336
337 IWL_DEBUG_INFO(priv, "Start UP work done.\n");
338
339 /* Now we should be done, and the READY bit should be set. */
Don Fry83626402012-03-07 09:52:37 -0800340 if (WARN_ON(!test_bit(STATUS_READY, &priv->status)))
Wey-Yi Guy73356132011-11-10 06:55:11 -0800341 ret = -EIO;
342
343 iwlagn_led_enable(priv);
344
345 priv->is_open = 1;
346 IWL_DEBUG_MAC80211(priv, "leave\n");
347 return 0;
348}
349
Johannes Bergaca86262012-05-14 09:08:50 +0200350static void iwlagn_mac_stop(struct ieee80211_hw *hw)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800351{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200352 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800353
354 IWL_DEBUG_MAC80211(priv, "enter\n");
355
356 if (!priv->is_open)
357 return;
358
359 priv->is_open = 0;
360
Johannes Bergb1eea292012-03-06 13:30:42 -0800361 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800362 iwl_down(priv);
Johannes Bergb1eea292012-03-06 13:30:42 -0800363 mutex_unlock(&priv->mutex);
Emmanuel Grumbach78e5a462012-02-17 10:34:53 -0800364
365 iwl_cancel_deferred_work(priv);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800366
Johannes Berg1ee158d2012-02-17 10:07:44 -0800367 flush_workqueue(priv->workqueue);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800368
369 /* User space software may expect getting rfkill changes
Emmanuel Grumbach1df06bd2012-01-09 16:35:08 +0200370 * even if interface is down, trans->down will leave the RF
371 * kill interrupt enabled
372 */
Emmanuel Grumbach218733c2012-03-31 08:28:38 -0700373 iwl_trans_stop_hw(priv->trans, false);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800374
375 IWL_DEBUG_MAC80211(priv, "leave\n");
376}
377
Johannes Bergaca86262012-05-14 09:08:50 +0200378static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
379 struct ieee80211_vif *vif,
380 struct cfg80211_gtk_rekey_data *data)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800381{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200382 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800383
Johannes Berg65de7e82012-04-17 07:36:30 -0700384 if (iwlwifi_mod_params.sw_crypto)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800385 return;
386
387 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -0800388 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800389
390 if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif)
391 goto out;
392
393 memcpy(priv->kek, data->kek, NL80211_KEK_LEN);
394 memcpy(priv->kck, data->kck, NL80211_KCK_LEN);
395 priv->replay_ctr =
396 cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
397 priv->have_rekey_data = true;
398
399 out:
Johannes Bergb1eea292012-03-06 13:30:42 -0800400 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800401 IWL_DEBUG_MAC80211(priv, "leave\n");
402}
403
404#ifdef CONFIG_PM_SLEEP
Wey-Yi Guy73356132011-11-10 06:55:11 -0800405
Johannes Bergaca86262012-05-14 09:08:50 +0200406static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
407 struct cfg80211_wowlan *wowlan)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800408{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200409 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800410 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
Wey-Yi Guy023ca582011-11-10 06:55:17 -0800411 int ret;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800412
413 if (WARN_ON(!wowlan))
414 return -EINVAL;
415
416 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -0800417 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800418
419 /* Don't attempt WoWLAN when not associated, tear down instead. */
420 if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION ||
421 !iwl_is_associated_ctx(ctx)) {
422 ret = 1;
423 goto out;
424 }
425
Johannes Bergea886a62012-03-07 09:52:15 -0800426 ret = iwlagn_suspend(priv, wowlan);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800427 if (ret)
428 goto error;
429
Johannes Berg8ade6282013-05-17 12:01:26 +0200430 /* let the ucode operate on its own */
431 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_SET,
432 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
433
Johannes Bergdebff612013-05-14 13:53:45 +0200434 iwl_trans_d3_suspend(priv->trans, false);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800435
436 goto out;
437
438 error:
Johannes Berg15b86bf2012-03-05 11:24:36 -0800439 priv->wowlan = false;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800440 iwlagn_prepare_restart(priv);
441 ieee80211_restart_hw(priv->hw);
442 out:
Johannes Bergb1eea292012-03-06 13:30:42 -0800443 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800444 IWL_DEBUG_MAC80211(priv, "leave\n");
445
446 return ret;
447}
448
Johannes Berg5718d272013-01-08 11:29:12 +0100449struct iwl_resume_data {
450 struct iwl_priv *priv;
451 struct iwlagn_wowlan_status *cmd;
452 bool valid;
453};
454
455static bool iwl_resume_status_fn(struct iwl_notif_wait_data *notif_wait,
456 struct iwl_rx_packet *pkt, void *data)
457{
458 struct iwl_resume_data *resume_data = data;
459 struct iwl_priv *priv = resume_data->priv;
460 u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
461
462 if (len - 4 != sizeof(*resume_data->cmd)) {
463 IWL_ERR(priv, "rx wrong size data\n");
464 return true;
465 }
466 memcpy(resume_data->cmd, pkt->data, sizeof(*resume_data->cmd));
467 resume_data->valid = true;
468
469 return true;
470}
471
Wey-Yi Guy73356132011-11-10 06:55:11 -0800472static int iwlagn_mac_resume(struct ieee80211_hw *hw)
473{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200474 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800475 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
476 struct ieee80211_vif *vif;
Johannes Berg5718d272013-01-08 11:29:12 +0100477 u32 base;
478 int ret;
479 enum iwl_d3_status d3_status;
480 struct error_table_start {
481 /* cf. struct iwl_error_event_table */
482 u32 valid;
483 u32 error_id;
484 } err_info;
485 struct iwl_notification_wait status_wait;
486 static const u8 status_cmd[] = {
487 REPLY_WOWLAN_GET_STATUS,
488 };
489 struct iwlagn_wowlan_status status_data = {};
490 struct iwl_resume_data resume_data = {
491 .priv = priv,
492 .cmd = &status_data,
493 .valid = false,
494 };
495 struct cfg80211_wowlan_wakeup wakeup = {
496 .pattern_idx = -1,
497 };
498#ifdef CONFIG_IWLWIFI_DEBUGFS
499 const struct fw_img *img;
500#endif
Wey-Yi Guy73356132011-11-10 06:55:11 -0800501
502 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -0800503 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800504
Wey-Yi Guy73356132011-11-10 06:55:11 -0800505 /* we'll clear ctx->vif during iwlagn_prepare_restart() */
506 vif = ctx->vif;
507
Johannes Bergdebff612013-05-14 13:53:45 +0200508 ret = iwl_trans_d3_resume(priv->trans, &d3_status, false);
Johannes Berg5718d272013-01-08 11:29:12 +0100509 if (ret)
510 goto out_unlock;
511
512 if (d3_status != IWL_D3_STATUS_ALIVE) {
513 IWL_INFO(priv, "Device was reset during suspend\n");
514 goto out_unlock;
515 }
516
Johannes Berg8ade6282013-05-17 12:01:26 +0200517 /* uCode is no longer operating by itself */
518 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
519 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
520
Johannes Berg5718d272013-01-08 11:29:12 +0100521 base = priv->device_pointers.error_event_table;
522 if (!iwlagn_hw_valid_rtc_data_addr(base)) {
523 IWL_WARN(priv, "Invalid error table during resume!\n");
524 goto out_unlock;
525 }
526
527 iwl_trans_read_mem_bytes(priv->trans, base,
528 &err_info, sizeof(err_info));
529
530 if (err_info.valid) {
531 IWL_INFO(priv, "error table is valid (%d, 0x%x)\n",
532 err_info.valid, err_info.error_id);
533 if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) {
534 wakeup.rfkill_release = true;
535 ieee80211_report_wowlan_wakeup(vif, &wakeup,
536 GFP_KERNEL);
537 }
538 goto out_unlock;
539 }
540
541#ifdef CONFIG_IWLWIFI_DEBUGFS
542 img = &priv->fw->img[IWL_UCODE_WOWLAN];
543 if (!priv->wowlan_sram)
544 priv->wowlan_sram =
545 kzalloc(img->sec[IWL_UCODE_SECTION_DATA].len,
546 GFP_KERNEL);
547
548 if (priv->wowlan_sram)
549 iwl_trans_read_mem(priv->trans, 0x800000,
550 priv->wowlan_sram,
551 img->sec[IWL_UCODE_SECTION_DATA].len / 4);
552#endif
553
554 /*
555 * This is very strange. The GET_STATUS command is sent but the device
556 * doesn't reply properly, it seems it doesn't close the RBD so one is
557 * always left open ... As a result, we need to send another command
558 * and have to reset the driver afterwards. As we need to switch to
559 * runtime firmware again that'll happen.
560 */
561
562 iwl_init_notification_wait(&priv->notif_wait, &status_wait, status_cmd,
563 ARRAY_SIZE(status_cmd), iwl_resume_status_fn,
564 &resume_data);
565
566 iwl_dvm_send_cmd_pdu(priv, REPLY_WOWLAN_GET_STATUS, CMD_ASYNC, 0, NULL);
567 iwl_dvm_send_cmd_pdu(priv, REPLY_ECHO, CMD_ASYNC, 0, NULL);
568 /* an RBD is left open in the firmware now! */
569
570 ret = iwl_wait_notification(&priv->notif_wait, &status_wait, HZ/5);
571 if (ret)
572 goto out_unlock;
573
574 if (resume_data.valid && priv->contexts[IWL_RXON_CTX_BSS].vif) {
575 u32 reasons = le32_to_cpu(status_data.wakeup_reason);
576 struct cfg80211_wowlan_wakeup *wakeup_report;
577
578 IWL_INFO(priv, "WoWLAN wakeup reason(s): 0x%.8x\n", reasons);
579
580 if (reasons) {
581 if (reasons & IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET)
582 wakeup.magic_pkt = true;
583 if (reasons & IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH)
584 wakeup.pattern_idx = status_data.pattern_number;
585 if (reasons & (IWLAGN_WOWLAN_WAKEUP_BEACON_MISS |
586 IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE))
587 wakeup.disconnect = true;
588 if (reasons & IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL)
589 wakeup.gtk_rekey_failure = true;
590 if (reasons & IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ)
591 wakeup.eap_identity_req = true;
592 if (reasons & IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE)
593 wakeup.four_way_handshake = true;
594 wakeup_report = &wakeup;
595 } else {
596 wakeup_report = NULL;
597 }
598
599 ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
600 }
601
Johannes Berg15b86bf2012-03-05 11:24:36 -0800602 priv->wowlan = false;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800603
Wey-Yi Guy73356132011-11-10 06:55:11 -0800604 iwlagn_prepare_restart(priv);
605
606 memset((void *)&ctx->active, 0, sizeof(ctx->active));
607 iwl_connection_init_rx_config(priv, ctx);
608 iwlagn_set_rxon_chain(priv, ctx);
609
Johannes Berg5718d272013-01-08 11:29:12 +0100610 out_unlock:
Johannes Bergb1eea292012-03-06 13:30:42 -0800611 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800612 IWL_DEBUG_MAC80211(priv, "leave\n");
613
614 ieee80211_resume_disconnect(vif);
615
616 return 1;
617}
618
Johannes Berg76ed2ed2012-05-16 22:54:25 +0200619static void iwlagn_mac_set_wakeup(struct ieee80211_hw *hw, bool enabled)
620{
621 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
622
623 device_set_wakeup_enable(priv->trans->dev, enabled);
624}
Wey-Yi Guy73356132011-11-10 06:55:11 -0800625#endif
626
Thomas Huehn36323f82012-07-23 21:33:42 +0200627static void iwlagn_mac_tx(struct ieee80211_hw *hw,
628 struct ieee80211_tx_control *control,
629 struct sk_buff *skb)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800630{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200631 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800632
Thomas Huehn36323f82012-07-23 21:33:42 +0200633 if (iwlagn_tx_skb(priv, control->sta, skb))
Johannes Berg31df3bb2012-10-31 22:07:39 +0100634 ieee80211_free_txskb(hw, skb);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800635}
636
Johannes Bergaca86262012-05-14 09:08:50 +0200637static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw,
638 struct ieee80211_vif *vif,
639 struct ieee80211_key_conf *keyconf,
640 struct ieee80211_sta *sta,
641 u32 iv32, u16 *phase1key)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800642{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200643 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800644
645 iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key);
646}
647
Johannes Bergaca86262012-05-14 09:08:50 +0200648static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
649 struct ieee80211_vif *vif,
650 struct ieee80211_sta *sta,
651 struct ieee80211_key_conf *key)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800652{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200653 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800654 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
655 struct iwl_rxon_context *ctx = vif_priv->ctx;
656 int ret;
657 bool is_default_wep_key = false;
658
659 IWL_DEBUG_MAC80211(priv, "enter\n");
660
Johannes Berg65de7e82012-04-17 07:36:30 -0700661 if (iwlwifi_mod_params.sw_crypto) {
Wey-Yi Guy73356132011-11-10 06:55:11 -0800662 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
663 return -EOPNOTSUPP;
664 }
665
Johannes Berga7e12c82011-11-25 03:20:09 -0800666 switch (key->cipher) {
667 case WLAN_CIPHER_SUITE_TKIP:
668 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
669 /* fall through */
670 case WLAN_CIPHER_SUITE_CCMP:
671 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
672 break;
673 default:
674 break;
675 }
676
Wey-Yi Guy73356132011-11-10 06:55:11 -0800677 /*
678 * We could program these keys into the hardware as well, but we
679 * don't expect much multicast traffic in IBSS and having keys
680 * for more stations is probably more useful.
681 *
682 * Mark key TX-only and return 0.
683 */
684 if (vif->type == NL80211_IFTYPE_ADHOC &&
685 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
686 key->hw_key_idx = WEP_INVALID_OFFSET;
687 return 0;
688 }
689
690 /* If they key was TX-only, accept deletion */
691 if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET)
692 return 0;
693
Johannes Bergb1eea292012-03-06 13:30:42 -0800694 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800695 iwl_scan_cancel_timeout(priv, 100);
696
697 BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT);
698
699 /*
700 * If we are getting WEP group key and we didn't receive any key mapping
701 * so far, we are in legacy wep mode (group key only), otherwise we are
702 * in 1X mode.
703 * In legacy wep mode, we use another host command to the uCode.
704 */
705 if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
706 key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) {
707 if (cmd == SET_KEY)
708 is_default_wep_key = !ctx->key_mapping_keys;
709 else
710 is_default_wep_key =
711 key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT;
712 }
713
714
715 switch (cmd) {
716 case SET_KEY:
717 if (is_default_wep_key) {
718 ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key);
719 break;
720 }
721 ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta);
722 if (ret) {
723 /*
724 * can't add key for RX, but we don't need it
725 * in the device for TX so still return 0
726 */
727 ret = 0;
728 key->hw_key_idx = WEP_INVALID_OFFSET;
729 }
730
731 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n");
732 break;
733 case DISABLE_KEY:
734 if (is_default_wep_key)
735 ret = iwl_remove_default_wep_key(priv, ctx, key);
736 else
737 ret = iwl_remove_dynamic_key(priv, ctx, key, sta);
738
739 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
740 break;
741 default:
742 ret = -EINVAL;
743 }
744
Johannes Bergb1eea292012-03-06 13:30:42 -0800745 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800746 IWL_DEBUG_MAC80211(priv, "leave\n");
747
748 return ret;
749}
750
Johannes Bergaca86262012-05-14 09:08:50 +0200751static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
752 struct ieee80211_vif *vif,
753 enum ieee80211_ampdu_mlme_action action,
754 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
755 u8 buf_size)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800756{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200757 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800758 int ret = -EINVAL;
759 struct iwl_station_priv *sta_priv = (void *) sta->drv_priv;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800760
761 IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
762 sta->addr, tid);
763
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200764 if (!(priv->nvm_data->sku_cap_11n_enable))
Wey-Yi Guy73356132011-11-10 06:55:11 -0800765 return -EACCES;
766
767 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -0800768 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800769
770 switch (action) {
771 case IEEE80211_AMPDU_RX_START:
Johannes Berg65de7e82012-04-17 07:36:30 -0700772 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
Johannes Berg74289942011-12-13 00:07:40 -0800773 break;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800774 IWL_DEBUG_HT(priv, "start Rx\n");
775 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
776 break;
777 case IEEE80211_AMPDU_RX_STOP:
778 IWL_DEBUG_HT(priv, "stop Rx\n");
779 ret = iwl_sta_rx_agg_stop(priv, sta, tid);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800780 break;
781 case IEEE80211_AMPDU_TX_START:
Emmanuel Grumbach4beaf6c2012-05-29 11:29:10 +0300782 if (!priv->trans->ops->txq_enable)
Johannes Berg9eae88f2012-03-15 13:26:52 -0700783 break;
Johannes Berg65de7e82012-04-17 07:36:30 -0700784 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
Johannes Berg74289942011-12-13 00:07:40 -0800785 break;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800786 IWL_DEBUG_HT(priv, "start Tx\n");
787 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
788 break;
Johannes Berg18b559d2012-07-18 13:51:25 +0200789 case IEEE80211_AMPDU_TX_STOP_FLUSH:
790 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
Emmanuel Grumbach2d055af2013-04-07 10:13:44 +0300791 IWL_DEBUG_HT(priv, "Flush Tx\n");
792 ret = iwlagn_tx_agg_flush(priv, vif, sta, tid);
793 break;
794 case IEEE80211_AMPDU_TX_STOP_CONT:
Wey-Yi Guy73356132011-11-10 06:55:11 -0800795 IWL_DEBUG_HT(priv, "stop Tx\n");
796 ret = iwlagn_tx_agg_stop(priv, vif, sta, tid);
797 if ((ret == 0) && (priv->agg_tids_count > 0)) {
798 priv->agg_tids_count--;
799 IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
800 priv->agg_tids_count);
801 }
Johannes Bergb9ad70d2012-03-06 13:30:55 -0800802 if (!priv->agg_tids_count &&
Johannes Berg9e295112012-04-09 17:46:55 -0700803 priv->hw_params.use_rts_for_aggregation) {
Wey-Yi Guy73356132011-11-10 06:55:11 -0800804 /*
805 * switch off RTS/CTS if it was previously enabled
806 */
807 sta_priv->lq_sta.lq.general_params.flags &=
808 ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK;
809 iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif),
810 &sta_priv->lq_sta.lq, CMD_ASYNC, false);
811 }
812 break;
813 case IEEE80211_AMPDU_TX_OPERATIONAL:
Emmanuel Grumbach822e8b22011-11-21 13:25:31 +0200814 ret = iwlagn_tx_agg_oper(priv, vif, sta, tid, buf_size);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800815 break;
816 }
Johannes Bergb1eea292012-03-06 13:30:42 -0800817 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800818 IWL_DEBUG_MAC80211(priv, "leave\n");
819 return ret;
820}
821
822static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
823 struct ieee80211_vif *vif,
824 struct ieee80211_sta *sta)
825{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200826 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800827 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
828 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
829 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800830 int ret;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800831 u8 sta_id;
832
Wey-Yi Guy73356132011-11-10 06:55:11 -0800833 IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
834 sta->addr);
835 sta_priv->sta_id = IWL_INVALID_STATION;
836
837 atomic_set(&sta_priv->pending_frames, 0);
838 if (vif->type == NL80211_IFTYPE_AP)
839 sta_priv->client = true;
840
841 ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr,
842 is_ap, sta, &sta_id);
843 if (ret) {
844 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
845 sta->addr, ret);
846 /* Should we return success if return code is EEXIST ? */
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800847 return ret;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800848 }
849
850 sta_priv->sta_id = sta_id;
851
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800852 return 0;
853}
854
855static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw,
856 struct ieee80211_vif *vif,
857 struct ieee80211_sta *sta)
858{
859 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
860 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
861 int ret;
862
Johannes Berg97420512012-03-07 09:52:42 -0800863 IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", sta->addr);
864
865 if (vif->type == NL80211_IFTYPE_STATION) {
866 /*
867 * Station will be removed from device when the RXON
868 * is set to unassociated -- just deactivate it here
869 * to avoid re-programming it.
870 */
871 ret = 0;
872 iwl_deactivate_station(priv, sta_priv->sta_id, sta->addr);
873 } else {
874 ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr);
875 if (ret)
876 IWL_DEBUG_QUIET_RFKILL(priv,
877 "Error removing station %pM\n", sta->addr);
878 }
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800879 return ret;
880}
881
Johannes Bergaca86262012-05-14 09:08:50 +0200882static int iwlagn_mac_sta_state(struct ieee80211_hw *hw,
883 struct ieee80211_vif *vif,
884 struct ieee80211_sta *sta,
885 enum ieee80211_sta_state old_state,
886 enum ieee80211_sta_state new_state)
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800887{
888 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Johannes Bergab0bd5b2012-03-05 11:24:47 -0800889 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800890 enum {
Johannes Bergab0bd5b2012-03-05 11:24:47 -0800891 NONE, ADD, REMOVE, HT_RATE_INIT, ADD_RATE_INIT,
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800892 } op = NONE;
893 int ret;
894
895 IWL_DEBUG_MAC80211(priv, "station %pM state change %d->%d\n",
896 sta->addr, old_state, new_state);
897
Johannes Bergb1eea292012-03-06 13:30:42 -0800898 mutex_lock(&priv->mutex);
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800899 if (vif->type == NL80211_IFTYPE_STATION) {
900 if (old_state == IEEE80211_STA_NOTEXIST &&
901 new_state == IEEE80211_STA_NONE)
902 op = ADD;
903 else if (old_state == IEEE80211_STA_NONE &&
904 new_state == IEEE80211_STA_NOTEXIST)
905 op = REMOVE;
906 else if (old_state == IEEE80211_STA_AUTH &&
907 new_state == IEEE80211_STA_ASSOC)
Johannes Bergab0bd5b2012-03-05 11:24:47 -0800908 op = HT_RATE_INIT;
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800909 } else {
910 if (old_state == IEEE80211_STA_AUTH &&
911 new_state == IEEE80211_STA_ASSOC)
912 op = ADD_RATE_INIT;
913 else if (old_state == IEEE80211_STA_ASSOC &&
914 new_state == IEEE80211_STA_AUTH)
915 op = REMOVE;
916 }
917
918 switch (op) {
919 case ADD:
920 ret = iwlagn_mac_sta_add(hw, vif, sta);
Johannes Bergeac9ac62012-06-25 09:36:41 +0200921 if (ret)
922 break;
923 /*
924 * Clear the in-progress flag, the AP station entry was added
925 * but we'll initialize LQ only when we've associated (which
926 * would also clear the in-progress flag). This is necessary
927 * in case we never initialize LQ because association fails.
928 */
929 spin_lock_bh(&priv->sta_lock);
930 priv->stations[iwl_sta_id(sta)].used &=
931 ~IWL_STA_UCODE_INPROGRESS;
932 spin_unlock_bh(&priv->sta_lock);
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800933 break;
934 case REMOVE:
935 ret = iwlagn_mac_sta_remove(hw, vif, sta);
936 break;
937 case ADD_RATE_INIT:
938 ret = iwlagn_mac_sta_add(hw, vif, sta);
939 if (ret)
940 break;
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800941 /* Initialize rate scaling */
942 IWL_DEBUG_INFO(priv,
943 "Initializing rate scaling for station %pM\n",
944 sta->addr);
945 iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
946 ret = 0;
947 break;
Johannes Bergab0bd5b2012-03-05 11:24:47 -0800948 case HT_RATE_INIT:
949 /* Initialize rate scaling */
950 ret = iwl_sta_update_ht(priv, vif_priv->ctx, sta);
951 if (ret)
952 break;
953 IWL_DEBUG_INFO(priv,
954 "Initializing rate scaling for station %pM\n",
955 sta->addr);
956 iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
957 ret = 0;
958 break;
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800959 default:
960 ret = 0;
961 break;
962 }
963
964 /*
965 * mac80211 might WARN if we fail, but due the way we
966 * (badly) handle hard rfkill, we might fail here
967 */
Don Fry83626402012-03-07 09:52:37 -0800968 if (iwl_is_rfkill(priv))
Johannes Bergfb5fe5b2012-03-05 11:24:29 -0800969 ret = 0;
970
Johannes Bergb1eea292012-03-06 13:30:42 -0800971 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800972 IWL_DEBUG_MAC80211(priv, "leave\n");
973
974 return ret;
975}
976
Johannes Bergaca86262012-05-14 09:08:50 +0200977static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
978 struct ieee80211_channel_switch *ch_switch)
Wey-Yi Guy73356132011-11-10 06:55:11 -0800979{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200980 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800981 struct ieee80211_conf *conf = &hw->conf;
Johannes Berg85220d72013-03-25 18:29:27 +0100982 struct ieee80211_channel *channel = ch_switch->chandef.chan;
Wey-Yi Guy73356132011-11-10 06:55:11 -0800983 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
984 /*
985 * MULTI-FIXME
986 * When we add support for multiple interfaces, we need to
987 * revisit this. The channel switch command in the device
988 * only affects the BSS context, but what does that really
989 * mean? And what if we get a CSA on the second interface?
990 * This needs a lot of work.
991 */
992 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
993 u16 ch;
994
995 IWL_DEBUG_MAC80211(priv, "enter\n");
996
Johannes Bergb1eea292012-03-06 13:30:42 -0800997 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -0800998
Don Fry83626402012-03-07 09:52:37 -0800999 if (iwl_is_rfkill(priv))
Wey-Yi Guy73356132011-11-10 06:55:11 -08001000 goto out;
1001
Don Fry83626402012-03-07 09:52:37 -08001002 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
1003 test_bit(STATUS_SCANNING, &priv->status) ||
1004 test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
Wey-Yi Guy73356132011-11-10 06:55:11 -08001005 goto out;
1006
1007 if (!iwl_is_associated_ctx(ctx))
1008 goto out;
1009
Johannes Berge9676692012-04-10 14:10:28 -07001010 if (!priv->lib->set_channel_switch)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001011 goto out;
1012
1013 ch = channel->hw_value;
1014 if (le16_to_cpu(ctx->active.channel) == ch)
1015 goto out;
1016
Wey-Yi Guy73356132011-11-10 06:55:11 -08001017 priv->current_ht_config.smps = conf->smps_mode;
1018
1019 /* Configure HT40 channels */
Johannes Berg85220d72013-03-25 18:29:27 +01001020 switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
1021 case NL80211_CHAN_NO_HT:
1022 case NL80211_CHAN_HT20:
Wey-Yi Guy73356132011-11-10 06:55:11 -08001023 ctx->ht.is_40mhz = false;
Johannes Berg85220d72013-03-25 18:29:27 +01001024 ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1025 break;
1026 case NL80211_CHAN_HT40MINUS:
1027 ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
1028 ctx->ht.is_40mhz = true;
1029 break;
1030 case NL80211_CHAN_HT40PLUS:
1031 ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
1032 ctx->ht.is_40mhz = true;
1033 break;
1034 }
Wey-Yi Guy73356132011-11-10 06:55:11 -08001035
1036 if ((le16_to_cpu(ctx->staging.channel) != ch))
1037 ctx->staging.flags = 0;
1038
1039 iwl_set_rxon_channel(priv, channel, ctx);
1040 iwl_set_rxon_ht(priv, ht_conf);
1041 iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
1042
Wey-Yi Guy73356132011-11-10 06:55:11 -08001043 /*
1044 * at this point, staging_rxon has the
1045 * configuration for channel switch
1046 */
Don Fry83626402012-03-07 09:52:37 -08001047 set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001048 priv->switch_channel = cpu_to_le16(ch);
Johannes Berge9676692012-04-10 14:10:28 -07001049 if (priv->lib->set_channel_switch(priv, ch_switch)) {
Don Fry83626402012-03-07 09:52:37 -08001050 clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001051 priv->switch_channel = 0;
1052 ieee80211_chswitch_done(ctx->vif, false);
1053 }
1054
1055out:
Johannes Bergb1eea292012-03-06 13:30:42 -08001056 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001057 IWL_DEBUG_MAC80211(priv, "leave\n");
1058}
1059
Meenakshi Venkataramanbedec3a2012-03-13 17:47:23 -07001060void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
1061{
1062 /*
1063 * MULTI-FIXME
1064 * See iwlagn_mac_channel_switch.
1065 */
1066 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1067
1068 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1069 return;
1070
1071 if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
1072 ieee80211_chswitch_done(ctx->vif, is_success);
1073}
1074
Johannes Bergaca86262012-05-14 09:08:50 +02001075static void iwlagn_configure_filter(struct ieee80211_hw *hw,
1076 unsigned int changed_flags,
1077 unsigned int *total_flags,
1078 u64 multicast)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001079{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001080 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001081 __le32 filter_or = 0, filter_nand = 0;
1082 struct iwl_rxon_context *ctx;
1083
1084#define CHK(test, flag) do { \
1085 if (*total_flags & (test)) \
1086 filter_or |= (flag); \
1087 else \
1088 filter_nand |= (flag); \
1089 } while (0)
1090
1091 IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n",
1092 changed_flags, *total_flags);
1093
1094 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK);
1095 /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */
1096 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK);
1097 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK);
1098
1099#undef CHK
1100
Johannes Bergb1eea292012-03-06 13:30:42 -08001101 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001102
1103 for_each_context(priv, ctx) {
1104 ctx->staging.filter_flags &= ~filter_nand;
1105 ctx->staging.filter_flags |= filter_or;
1106
1107 /*
1108 * Not committing directly because hardware can perform a scan,
1109 * but we'll eventually commit the filter flags change anyway.
1110 */
1111 }
1112
Johannes Bergb1eea292012-03-06 13:30:42 -08001113 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001114
1115 /*
1116 * Receiving all multicast frames is always enabled by the
1117 * default flags setup in iwl_connection_init_rx_config()
1118 * since we currently do not support programming multicast
1119 * filters into the device.
1120 */
1121 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1122 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
1123}
1124
Johannes Berg39ecc012013-02-13 12:11:00 +01001125static void iwlagn_mac_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001126{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001127 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001128
Johannes Bergb1eea292012-03-06 13:30:42 -08001129 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001130 IWL_DEBUG_MAC80211(priv, "enter\n");
1131
Don Fry83626402012-03-07 09:52:37 -08001132 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
Wey-Yi Guy73356132011-11-10 06:55:11 -08001133 IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n");
1134 goto done;
1135 }
Don Fry83626402012-03-07 09:52:37 -08001136 if (iwl_is_rfkill(priv)) {
Wey-Yi Guy73356132011-11-10 06:55:11 -08001137 IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n");
1138 goto done;
1139 }
1140
1141 /*
1142 * mac80211 will not push any more frames for transmit
1143 * until the flush is completed
1144 */
1145 if (drop) {
1146 IWL_DEBUG_MAC80211(priv, "send flush command\n");
Emmanuel Grumbach2d055af2013-04-07 10:13:44 +03001147 if (iwlagn_txfifo_flush(priv, 0)) {
Wey-Yi Guy73356132011-11-10 06:55:11 -08001148 IWL_ERR(priv, "flush request fail\n");
1149 goto done;
1150 }
1151 }
1152 IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n");
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07001153 iwl_trans_wait_tx_queue_empty(priv->trans);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001154done:
Johannes Bergb1eea292012-03-06 13:30:42 -08001155 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001156 IWL_DEBUG_MAC80211(priv, "leave\n");
1157}
1158
1159static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw,
Eliad Peller49884562012-11-19 17:05:09 +02001160 struct ieee80211_vif *vif,
Wey-Yi Guy73356132011-11-10 06:55:11 -08001161 struct ieee80211_channel *channel,
Ilan Peerd339d5c2013-02-12 09:34:13 +02001162 int duration,
1163 enum ieee80211_roc_type type)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001164{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001165 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001166 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
1167 int err = 0;
1168
Johannes Berga18f61b2012-03-15 13:26:53 -07001169 if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
Wey-Yi Guy73356132011-11-10 06:55:11 -08001170 return -EOPNOTSUPP;
1171
1172 if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)))
1173 return -EOPNOTSUPP;
1174
1175 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -08001176 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001177
Don Fry83626402012-03-07 09:52:37 -08001178 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
Johannes Berg601968b2012-06-14 21:22:17 +02001179 /* mac80211 should not scan while ROC or ROC while scanning */
1180 if (WARN_ON_ONCE(priv->scan_type != IWL_SCAN_RADIO_RESET)) {
1181 err = -EBUSY;
1182 goto out;
1183 }
1184
1185 iwl_scan_cancel_timeout(priv, 100);
1186
1187 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
1188 err = -EBUSY;
1189 goto out;
1190 }
Wey-Yi Guy73356132011-11-10 06:55:11 -08001191 }
1192
1193 priv->hw_roc_channel = channel;
Johannes Berg3ddf6be2011-11-10 06:55:21 -08001194 /* convert from ms to TU */
1195 priv->hw_roc_duration = DIV_ROUND_UP(1000 * duration, 1024);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001196 priv->hw_roc_start_notified = false;
1197 cancel_delayed_work(&priv->hw_roc_disable_work);
1198
1199 if (!ctx->is_active) {
Johannes Berga69cd042011-11-10 06:55:13 -08001200 static const struct iwl_qos_info default_qos_data = {
1201 .def_qos_parm = {
1202 .ac[0] = {
1203 .cw_min = cpu_to_le16(3),
1204 .cw_max = cpu_to_le16(7),
1205 .aifsn = 2,
1206 .edca_txop = cpu_to_le16(1504),
1207 },
1208 .ac[1] = {
1209 .cw_min = cpu_to_le16(7),
1210 .cw_max = cpu_to_le16(15),
1211 .aifsn = 2,
1212 .edca_txop = cpu_to_le16(3008),
1213 },
1214 .ac[2] = {
1215 .cw_min = cpu_to_le16(15),
1216 .cw_max = cpu_to_le16(1023),
1217 .aifsn = 3,
1218 },
1219 .ac[3] = {
1220 .cw_min = cpu_to_le16(15),
1221 .cw_max = cpu_to_le16(1023),
1222 .aifsn = 7,
1223 },
1224 },
1225 };
1226
Wey-Yi Guy73356132011-11-10 06:55:11 -08001227 ctx->is_active = true;
Johannes Berga69cd042011-11-10 06:55:13 -08001228 ctx->qos_data = default_qos_data;
Wey-Yi Guy73356132011-11-10 06:55:11 -08001229 ctx->staging.dev_type = RXON_DEV_TYPE_P2P;
1230 memcpy(ctx->staging.node_addr,
1231 priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr,
1232 ETH_ALEN);
1233 memcpy(ctx->staging.bssid_addr,
1234 priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr,
1235 ETH_ALEN);
1236 err = iwlagn_commit_rxon(priv, ctx);
1237 if (err)
1238 goto out;
1239 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK |
1240 RXON_FILTER_PROMISC_MSK |
1241 RXON_FILTER_CTL2HOST_MSK;
1242
1243 err = iwlagn_commit_rxon(priv, ctx);
1244 if (err) {
1245 iwlagn_disable_roc(priv);
1246 goto out;
1247 }
1248 priv->hw_roc_setup = true;
1249 }
1250
1251 err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band);
1252 if (err)
1253 iwlagn_disable_roc(priv);
1254
1255 out:
Johannes Bergb1eea292012-03-06 13:30:42 -08001256 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001257 IWL_DEBUG_MAC80211(priv, "leave\n");
1258
1259 return err;
1260}
1261
Johannes Bergaca86262012-05-14 09:08:50 +02001262static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001263{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001264 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001265
Johannes Berga18f61b2012-03-15 13:26:53 -07001266 if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
Wey-Yi Guy73356132011-11-10 06:55:11 -08001267 return -EOPNOTSUPP;
1268
1269 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -08001270 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001271 iwl_scan_cancel_timeout(priv, priv->hw_roc_duration);
1272 iwlagn_disable_roc(priv);
Johannes Bergb1eea292012-03-06 13:30:42 -08001273 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001274 IWL_DEBUG_MAC80211(priv, "leave\n");
1275
1276 return 0;
1277}
1278
Johannes Bergaca86262012-05-14 09:08:50 +02001279static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw,
Emmanuel Grumbach887da912013-01-20 17:32:41 +02001280 struct ieee80211_vif *vif,
Johannes Bergaca86262012-05-14 09:08:50 +02001281 enum ieee80211_rssi_event rssi_event)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001282{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001283 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001284
1285 IWL_DEBUG_MAC80211(priv, "enter\n");
Johannes Bergb1eea292012-03-06 13:30:42 -08001286 mutex_lock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001287
Johannes Berg0d8877a2013-05-17 10:36:29 +02001288 if (priv->lib->bt_params &&
1289 priv->lib->bt_params->advanced_bt_coexist) {
Wey-Yi Guy73356132011-11-10 06:55:11 -08001290 if (rssi_event == RSSI_EVENT_LOW)
1291 priv->bt_enable_pspoll = true;
1292 else if (rssi_event == RSSI_EVENT_HIGH)
1293 priv->bt_enable_pspoll = false;
1294
1295 iwlagn_send_advance_bt_config(priv);
1296 } else {
1297 IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled,"
1298 "ignoring RSSI callback\n");
1299 }
1300
Johannes Bergb1eea292012-03-06 13:30:42 -08001301 mutex_unlock(&priv->mutex);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001302 IWL_DEBUG_MAC80211(priv, "leave\n");
1303}
1304
Johannes Bergaca86262012-05-14 09:08:50 +02001305static int iwlagn_mac_set_tim(struct ieee80211_hw *hw,
1306 struct ieee80211_sta *sta, bool set)
Wey-Yi Guy73356132011-11-10 06:55:11 -08001307{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001308 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001309
Johannes Berg1ee158d2012-02-17 10:07:44 -08001310 queue_work(priv->workqueue, &priv->beacon_update);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001311
1312 return 0;
1313}
1314
Johannes Bergaca86262012-05-14 09:08:50 +02001315static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw,
1316 struct ieee80211_vif *vif, u16 queue,
1317 const struct ieee80211_tx_queue_params *params)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001318{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001319 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001320 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1321 struct iwl_rxon_context *ctx = vif_priv->ctx;
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001322 int q;
1323
1324 if (WARN_ON(!ctx))
1325 return -EINVAL;
1326
1327 IWL_DEBUG_MAC80211(priv, "enter\n");
1328
Don Fry83626402012-03-07 09:52:37 -08001329 if (!iwl_is_ready_rf(priv)) {
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001330 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
1331 return -EIO;
1332 }
1333
1334 if (queue >= AC_NUM) {
1335 IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
1336 return 0;
1337 }
1338
1339 q = AC_NUM - 1 - queue;
1340
Johannes Bergb1eea292012-03-06 13:30:42 -08001341 mutex_lock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001342
1343 ctx->qos_data.def_qos_parm.ac[q].cw_min =
1344 cpu_to_le16(params->cw_min);
1345 ctx->qos_data.def_qos_parm.ac[q].cw_max =
1346 cpu_to_le16(params->cw_max);
1347 ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
1348 ctx->qos_data.def_qos_parm.ac[q].edca_txop =
1349 cpu_to_le16((params->txop * 32));
1350
1351 ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0;
1352
Johannes Bergb1eea292012-03-06 13:30:42 -08001353 mutex_unlock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001354
1355 IWL_DEBUG_MAC80211(priv, "leave\n");
1356 return 0;
1357}
1358
Johannes Bergaca86262012-05-14 09:08:50 +02001359static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001360{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001361 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001362
1363 return priv->ibss_manager == IWL_IBSS_MANAGER;
1364}
1365
1366static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1367{
1368 iwl_connection_init_rx_config(priv, ctx);
1369
1370 iwlagn_set_rxon_chain(priv, ctx);
1371
1372 return iwlagn_commit_rxon(priv, ctx);
1373}
1374
Johannes Bergaca86262012-05-14 09:08:50 +02001375static int iwl_setup_interface(struct iwl_priv *priv,
1376 struct iwl_rxon_context *ctx)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001377{
1378 struct ieee80211_vif *vif = ctx->vif;
Johannes Berg14791772012-04-17 07:39:03 -07001379 int err, ac;
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001380
Johannes Bergb1eea292012-03-06 13:30:42 -08001381 lockdep_assert_held(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001382
1383 /*
1384 * This variable will be correct only when there's just
1385 * a single context, but all code using it is for hardware
1386 * that supports only one context.
1387 */
1388 priv->iw_mode = vif->type;
1389
1390 ctx->is_active = true;
1391
1392 err = iwl_set_mode(priv, ctx);
1393 if (err) {
1394 if (!ctx->always_active)
1395 ctx->is_active = false;
1396 return err;
1397 }
1398
Johannes Berg0d8877a2013-05-17 10:36:29 +02001399 if (priv->lib->bt_params && priv->lib->bt_params->advanced_bt_coexist &&
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001400 vif->type == NL80211_IFTYPE_ADHOC) {
1401 /*
1402 * pretend to have high BT traffic as long as we
1403 * are operating in IBSS mode, as this will cause
1404 * the rate scaling etc. to behave as intended.
1405 */
1406 priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
1407 }
1408
Johannes Berg14791772012-04-17 07:39:03 -07001409 /* set up queue mappings */
1410 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
1411 vif->hw_queue[ac] = ctx->ac_to_queue[ac];
1412
1413 if (vif->type == NL80211_IFTYPE_AP)
1414 vif->cab_queue = ctx->mcast_queue;
1415 else
1416 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
1417
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001418 return 0;
1419}
1420
1421static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
Johannes Berg14791772012-04-17 07:39:03 -07001422 struct ieee80211_vif *vif)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001423{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001424 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001425 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1426 struct iwl_rxon_context *tmp, *ctx = NULL;
1427 int err;
1428 enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif);
Stanislaw Gruszka8db4c7e2012-04-18 08:01:15 -07001429 bool reset = false;
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001430
1431 IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n",
1432 viftype, vif->addr);
1433
1434 cancel_delayed_work_sync(&priv->hw_roc_disable_work);
1435
Johannes Bergb1eea292012-03-06 13:30:42 -08001436 mutex_lock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001437
1438 iwlagn_disable_roc(priv);
1439
Don Fry83626402012-03-07 09:52:37 -08001440 if (!iwl_is_ready_rf(priv)) {
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001441 IWL_WARN(priv, "Try to add interface when device not ready\n");
1442 err = -EINVAL;
1443 goto out;
1444 }
1445
1446 for_each_context(priv, tmp) {
1447 u32 possible_modes =
1448 tmp->interface_modes | tmp->exclusive_interface_modes;
1449
1450 if (tmp->vif) {
Stanislaw Gruszka8db4c7e2012-04-18 08:01:15 -07001451 /* On reset we need to add the same interface again */
1452 if (tmp->vif == vif) {
1453 reset = true;
1454 ctx = tmp;
1455 break;
1456 }
1457
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001458 /* check if this busy context is exclusive */
1459 if (tmp->exclusive_interface_modes &
1460 BIT(tmp->vif->type)) {
1461 err = -EINVAL;
1462 goto out;
1463 }
1464 continue;
1465 }
1466
1467 if (!(possible_modes & BIT(viftype)))
1468 continue;
1469
1470 /* have maybe usable context w/o interface */
1471 ctx = tmp;
1472 break;
1473 }
1474
1475 if (!ctx) {
1476 err = -EOPNOTSUPP;
1477 goto out;
1478 }
1479
1480 vif_priv->ctx = ctx;
1481 ctx->vif = vif;
1482
Johannes Berg04baaa22012-11-13 21:28:44 +01001483 /*
1484 * In SNIFFER device type, the firmware reports the FCS to
1485 * the host, rather than snipping it off. Unfortunately,
1486 * mac80211 doesn't (yet) provide a per-packet flag for
1487 * this, so that we have to set the hardware flag based
1488 * on the interfaces added. As the monitor interface can
1489 * only be present by itself, and will be removed before
1490 * other interfaces are added, this is safe.
1491 */
1492 if (vif->type == NL80211_IFTYPE_MONITOR)
1493 priv->hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS;
1494 else
1495 priv->hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
1496
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001497 err = iwl_setup_interface(priv, ctx);
Stanislaw Gruszka8db4c7e2012-04-18 08:01:15 -07001498 if (!err || reset)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001499 goto out;
1500
1501 ctx->vif = NULL;
1502 priv->iw_mode = NL80211_IFTYPE_STATION;
1503 out:
Johannes Bergb1eea292012-03-06 13:30:42 -08001504 mutex_unlock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001505
1506 IWL_DEBUG_MAC80211(priv, "leave\n");
1507 return err;
1508}
1509
Johannes Bergaca86262012-05-14 09:08:50 +02001510static void iwl_teardown_interface(struct iwl_priv *priv,
1511 struct ieee80211_vif *vif,
1512 bool mode_change)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001513{
1514 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1515
Johannes Bergb1eea292012-03-06 13:30:42 -08001516 lockdep_assert_held(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001517
1518 if (priv->scan_vif == vif) {
1519 iwl_scan_cancel_timeout(priv, 200);
1520 iwl_force_scan_end(priv);
1521 }
1522
1523 if (!mode_change) {
1524 iwl_set_mode(priv, ctx);
1525 if (!ctx->always_active)
1526 ctx->is_active = false;
1527 }
1528
1529 /*
1530 * When removing the IBSS interface, overwrite the
1531 * BT traffic load with the stored one from the last
1532 * notification, if any. If this is a device that
1533 * doesn't implement this, this has no effect since
1534 * both values are the same and zero.
1535 */
1536 if (vif->type == NL80211_IFTYPE_ADHOC)
1537 priv->bt_traffic_load = priv->last_bt_traffic_load;
1538}
1539
1540static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw,
1541 struct ieee80211_vif *vif)
1542{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001543 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001544 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1545
1546 IWL_DEBUG_MAC80211(priv, "enter\n");
1547
Johannes Bergb1eea292012-03-06 13:30:42 -08001548 mutex_lock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001549
1550 if (WARN_ON(ctx->vif != vif)) {
1551 struct iwl_rxon_context *tmp;
1552 IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif);
1553 for_each_context(priv, tmp)
1554 IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n",
1555 tmp->ctxid, tmp, tmp->vif);
1556 }
1557 ctx->vif = NULL;
1558
1559 iwl_teardown_interface(priv, vif, false);
1560
Johannes Bergb1eea292012-03-06 13:30:42 -08001561 mutex_unlock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001562
1563 IWL_DEBUG_MAC80211(priv, "leave\n");
1564
1565}
1566
1567static int iwlagn_mac_change_interface(struct ieee80211_hw *hw,
Johannes Berge75dac92012-06-20 11:47:42 +02001568 struct ieee80211_vif *vif,
1569 enum nl80211_iftype newtype, bool newp2p)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001570{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001571 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Johannes Berge75dac92012-06-20 11:47:42 +02001572 struct iwl_rxon_context *ctx, *tmp;
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001573 enum nl80211_iftype newviftype = newtype;
1574 u32 interface_modes;
1575 int err;
1576
1577 IWL_DEBUG_MAC80211(priv, "enter\n");
1578
1579 newtype = ieee80211_iftype_p2p(newtype, newp2p);
1580
Johannes Bergb1eea292012-03-06 13:30:42 -08001581 mutex_lock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001582
Johannes Berge75dac92012-06-20 11:47:42 +02001583 ctx = iwl_rxon_ctx_from_vif(vif);
1584
1585 /*
1586 * To simplify this code, only support changes on the
1587 * BSS context. The PAN context is usually reassigned
1588 * by creating/removing P2P interfaces anyway.
1589 */
1590 if (ctx->ctxid != IWL_RXON_CTX_BSS) {
1591 err = -EBUSY;
1592 goto out;
1593 }
1594
Don Fry83626402012-03-07 09:52:37 -08001595 if (!ctx->vif || !iwl_is_ready_rf(priv)) {
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001596 /*
1597 * Huh? But wait ... this can maybe happen when
1598 * we're in the middle of a firmware restart!
1599 */
1600 err = -EBUSY;
1601 goto out;
1602 }
1603
Johannes Berge75dac92012-06-20 11:47:42 +02001604 /* Check if the switch is supported in the same context */
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001605 interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes;
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001606 if (!(interface_modes & BIT(newtype))) {
1607 err = -EBUSY;
1608 goto out;
1609 }
1610
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001611 if (ctx->exclusive_interface_modes & BIT(newtype)) {
1612 for_each_context(priv, tmp) {
1613 if (ctx == tmp)
1614 continue;
1615
Johannes Berge75dac92012-06-20 11:47:42 +02001616 if (!tmp->is_active)
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001617 continue;
1618
1619 /*
1620 * The current mode switch would be exclusive, but
1621 * another context is active ... refuse the switch.
1622 */
1623 err = -EBUSY;
1624 goto out;
1625 }
1626 }
1627
1628 /* success */
1629 iwl_teardown_interface(priv, vif, true);
1630 vif->type = newviftype;
1631 vif->p2p = newp2p;
1632 err = iwl_setup_interface(priv, ctx);
1633 WARN_ON(err);
1634 /*
1635 * We've switched internally, but submitting to the
1636 * device may have failed for some reason. Mask this
1637 * error, because otherwise mac80211 will not switch
1638 * (and set the interface type back) and we'll be
1639 * out of sync with it.
1640 */
1641 err = 0;
1642
1643 out:
Johannes Bergb1eea292012-03-06 13:30:42 -08001644 mutex_unlock(&priv->mutex);
Wey-Yi Guy0b7a4c72011-11-10 06:55:14 -08001645 IWL_DEBUG_MAC80211(priv, "leave\n");
1646
1647 return err;
1648}
1649
Johannes Bergaca86262012-05-14 09:08:50 +02001650static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw,
1651 struct ieee80211_vif *vif,
1652 struct cfg80211_scan_request *req)
Wey-Yi Guyba4c5312011-11-10 06:55:15 -08001653{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001654 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guyba4c5312011-11-10 06:55:15 -08001655 int ret;
1656
1657 IWL_DEBUG_MAC80211(priv, "enter\n");
1658
1659 if (req->n_channels == 0)
1660 return -EINVAL;
1661
Johannes Bergb1eea292012-03-06 13:30:42 -08001662 mutex_lock(&priv->mutex);
Wey-Yi Guyba4c5312011-11-10 06:55:15 -08001663
1664 /*
1665 * If an internal scan is in progress, just set
1666 * up the scan_request as per above.
1667 */
1668 if (priv->scan_type != IWL_SCAN_NORMAL) {
1669 IWL_DEBUG_SCAN(priv,
1670 "SCAN request during internal scan - defer\n");
1671 priv->scan_request = req;
1672 priv->scan_vif = vif;
1673 ret = 0;
1674 } else {
1675 priv->scan_request = req;
1676 priv->scan_vif = vif;
1677 /*
1678 * mac80211 will only ask for one band at a time
1679 * so using channels[0] here is ok
1680 */
1681 ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL,
1682 req->channels[0]->band);
1683 if (ret) {
1684 priv->scan_request = NULL;
1685 priv->scan_vif = NULL;
1686 }
1687 }
1688
1689 IWL_DEBUG_MAC80211(priv, "leave\n");
1690
Johannes Bergb1eea292012-03-06 13:30:42 -08001691 mutex_unlock(&priv->mutex);
Wey-Yi Guyba4c5312011-11-10 06:55:15 -08001692
1693 return ret;
1694}
1695
Wey-Yi Guy76b29332011-11-10 06:55:16 -08001696static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
1697{
Johannes Berg9451ca12012-03-05 11:24:23 -08001698 struct iwl_addsta_cmd cmd = {
1699 .mode = STA_CONTROL_MODIFY_MSK,
1700 .station_flags_msk = STA_FLG_PWR_SAVE_MSK,
1701 .sta.sta_id = sta_id,
1702 };
Wey-Yi Guy76b29332011-11-10 06:55:16 -08001703
Johannes Berg9451ca12012-03-05 11:24:23 -08001704 iwl_send_add_sta(priv, &cmd, CMD_ASYNC);
Wey-Yi Guy76b29332011-11-10 06:55:16 -08001705}
1706
Johannes Bergaca86262012-05-14 09:08:50 +02001707static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw,
1708 struct ieee80211_vif *vif,
1709 enum sta_notify_cmd cmd,
1710 struct ieee80211_sta *sta)
Wey-Yi Guy76b29332011-11-10 06:55:16 -08001711{
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001712 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
Wey-Yi Guy76b29332011-11-10 06:55:16 -08001713 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
1714 int sta_id;
1715
1716 IWL_DEBUG_MAC80211(priv, "enter\n");
1717
1718 switch (cmd) {
1719 case STA_NOTIFY_SLEEP:
1720 WARN_ON(!sta_priv->client);
1721 sta_priv->asleep = true;
1722 if (atomic_read(&sta_priv->pending_frames) > 0)
1723 ieee80211_sta_block_awake(hw, sta, true);
1724 break;
1725 case STA_NOTIFY_AWAKE:
1726 WARN_ON(!sta_priv->client);
1727 if (!sta_priv->asleep)
1728 break;
1729 sta_priv->asleep = false;
1730 sta_id = iwl_sta_id(sta);
1731 if (sta_id != IWL_INVALID_STATION)
1732 iwl_sta_modify_ps_wake(priv, sta_id);
1733 break;
1734 default:
1735 break;
1736 }
1737 IWL_DEBUG_MAC80211(priv, "leave\n");
1738}
1739
Wey-Yi Guy73356132011-11-10 06:55:11 -08001740struct ieee80211_ops iwlagn_hw_ops = {
1741 .tx = iwlagn_mac_tx,
1742 .start = iwlagn_mac_start,
1743 .stop = iwlagn_mac_stop,
1744#ifdef CONFIG_PM_SLEEP
1745 .suspend = iwlagn_mac_suspend,
1746 .resume = iwlagn_mac_resume,
Johannes Berg76ed2ed2012-05-16 22:54:25 +02001747 .set_wakeup = iwlagn_mac_set_wakeup,
Wey-Yi Guy73356132011-11-10 06:55:11 -08001748#endif
1749 .add_interface = iwlagn_mac_add_interface,
1750 .remove_interface = iwlagn_mac_remove_interface,
1751 .change_interface = iwlagn_mac_change_interface,
1752 .config = iwlagn_mac_config,
1753 .configure_filter = iwlagn_configure_filter,
1754 .set_key = iwlagn_mac_set_key,
1755 .update_tkip_key = iwlagn_mac_update_tkip_key,
1756 .set_rekey_data = iwlagn_mac_set_rekey_data,
1757 .conf_tx = iwlagn_mac_conf_tx,
1758 .bss_info_changed = iwlagn_bss_info_changed,
1759 .ampdu_action = iwlagn_mac_ampdu_action,
1760 .hw_scan = iwlagn_mac_hw_scan,
1761 .sta_notify = iwlagn_mac_sta_notify,
Johannes Bergfb5fe5b2012-03-05 11:24:29 -08001762 .sta_state = iwlagn_mac_sta_state,
Wey-Yi Guy73356132011-11-10 06:55:11 -08001763 .channel_switch = iwlagn_mac_channel_switch,
1764 .flush = iwlagn_mac_flush,
1765 .tx_last_beacon = iwlagn_mac_tx_last_beacon,
1766 .remain_on_channel = iwlagn_mac_remain_on_channel,
1767 .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel,
1768 .rssi_callback = iwlagn_mac_rssi_callback,
Wey-Yi Guy73356132011-11-10 06:55:11 -08001769 .set_tim = iwlagn_mac_set_tim,
1770};
1771
1772/* This function both allocates and initializes hw and priv. */
1773struct ieee80211_hw *iwl_alloc_all(void)
1774{
1775 struct iwl_priv *priv;
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001776 struct iwl_op_mode *op_mode;
Wey-Yi Guy73356132011-11-10 06:55:11 -08001777 /* mac80211 allocates memory for this device instance, including
1778 * space for this driver's private structure */
1779 struct ieee80211_hw *hw;
1780
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001781 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv) +
1782 sizeof(struct iwl_op_mode), &iwlagn_hw_ops);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001783 if (!hw)
1784 goto out;
1785
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +02001786 op_mode = hw->priv;
1787 priv = IWL_OP_MODE_GET_DVM(op_mode);
Wey-Yi Guy73356132011-11-10 06:55:11 -08001788 priv->hw = hw;
1789
1790out:
1791 return hw;
1792}