1 /******************************************************************************
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
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 *****************************************************************************/
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/etherdevice.h>
32 #include <linux/sched.h>
33 #include <net/mac80211.h>
35 #include "iwl-eeprom.h"
36 #include "iwl-dev.h" /* FIXME: remove */
37 #include "iwl-debug.h"
40 #include "iwl-power.h"
42 #include "iwl-helpers.h"
45 MODULE_DESCRIPTION("iwl core");
46 MODULE_VERSION(IWLWIFI_VERSION);
47 MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
48 MODULE_LICENSE("GPL");
51 * set bt_coex_active to true, uCode will do kill/defer
52 * every time the priority line is asserted (BT is sending signals on the
53 * priority line in the PCIx).
54 * set bt_coex_active to false, uCode will ignore the BT activity and
55 * perform the normal operation
57 * User might experience transmit issue on some platform due to WiFi/BT
58 * co-exist problem. The possible behaviors are:
59 * Able to scan and finding all the available AP
60 * Not able to associate with any AP
61 * On those platforms, WiFi communication can be restored by set
62 * "bt_coex_active" module parameter to "false"
64 * default: bt_coex_active = true (BT_COEX_ENABLE)
66 static bool bt_coex_active = true;
67 module_param(bt_coex_active, bool, S_IRUGO);
68 MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist\n");
70 static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
71 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
72 0, COEX_UNASSOC_IDLE_FLAGS},
73 {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP,
74 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
75 {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP,
76 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
77 {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP,
78 0, COEX_CALIBRATION_FLAGS},
79 {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP,
80 0, COEX_PERIODIC_CALIBRATION_FLAGS},
81 {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP,
82 0, COEX_CONNECTION_ESTAB_FLAGS},
83 {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP,
84 0, COEX_ASSOCIATED_IDLE_FLAGS},
85 {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP,
86 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
87 {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP,
88 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
89 {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP,
90 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
91 {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS},
92 {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS},
93 {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP,
94 0, COEX_STAND_ALONE_DEBUG_FLAGS},
95 {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP,
96 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
97 {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS},
98 {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS}
101 #define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \
102 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
103 IWL_RATE_SISO_##s##M_PLCP, \
104 IWL_RATE_MIMO2_##s##M_PLCP,\
105 IWL_RATE_MIMO3_##s##M_PLCP,\
106 IWL_RATE_##r##M_IEEE, \
107 IWL_RATE_##ip##M_INDEX, \
108 IWL_RATE_##in##M_INDEX, \
109 IWL_RATE_##rp##M_INDEX, \
110 IWL_RATE_##rn##M_INDEX, \
111 IWL_RATE_##pp##M_INDEX, \
112 IWL_RATE_##np##M_INDEX }
115 EXPORT_SYMBOL(iwl_debug_level);
119 * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate
121 * If there isn't a valid next or previous rate then INV is used which
122 * maps to IWL_RATE_INVALID
125 const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT] = {
126 IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */
127 IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */
128 IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */
129 IWL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */
130 IWL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */
131 IWL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */
132 IWL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */
133 IWL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */
134 IWL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */
135 IWL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */
136 IWL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */
137 IWL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */
138 IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */
139 /* FIXME:RS: ^^ should be INV (legacy) */
141 EXPORT_SYMBOL(iwl_rates);
144 * translate ucode response to mac80211 tx status control values
146 void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
147 struct ieee80211_tx_info *info)
149 struct ieee80211_tx_rate *r = &info->control.rates[0];
151 info->antenna_sel_tx =
152 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
153 if (rate_n_flags & RATE_MCS_HT_MSK)
154 r->flags |= IEEE80211_TX_RC_MCS;
155 if (rate_n_flags & RATE_MCS_GF_MSK)
156 r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
157 if (rate_n_flags & RATE_MCS_HT40_MSK)
158 r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
159 if (rate_n_flags & RATE_MCS_DUP_MSK)
160 r->flags |= IEEE80211_TX_RC_DUP_DATA;
161 if (rate_n_flags & RATE_MCS_SGI_MSK)
162 r->flags |= IEEE80211_TX_RC_SHORT_GI;
163 r->idx = iwl_hwrate_to_mac80211_idx(rate_n_flags, info->band);
165 EXPORT_SYMBOL(iwl_hwrate_to_tx_control);
167 int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
172 if (rate_n_flags & RATE_MCS_HT_MSK) {
173 idx = (rate_n_flags & 0xff);
175 if (idx >= IWL_RATE_MIMO3_6M_PLCP)
176 idx = idx - IWL_RATE_MIMO3_6M_PLCP;
177 else if (idx >= IWL_RATE_MIMO2_6M_PLCP)
178 idx = idx - IWL_RATE_MIMO2_6M_PLCP;
180 idx += IWL_FIRST_OFDM_RATE;
181 /* skip 9M not supported in ht*/
182 if (idx >= IWL_RATE_9M_INDEX)
184 if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE))
187 /* legacy rate format, search for match in table */
189 for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++)
190 if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
196 EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx);
198 int iwl_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band)
203 /* HT rate format: mac80211 wants an MCS number, which is just LSB */
204 if (rate_n_flags & RATE_MCS_HT_MSK) {
205 idx = (rate_n_flags & 0xff);
207 /* Legacy rate format, search for match in table */
209 if (band == IEEE80211_BAND_5GHZ)
210 band_offset = IWL_FIRST_OFDM_RATE;
211 for (idx = band_offset; idx < IWL_RATE_COUNT_LEGACY; idx++)
212 if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
213 return idx - band_offset;
219 u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant)
223 for (i = 0; i < RATE_ANT_NUM - 1; i++) {
224 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0;
225 if (priv->hw_params.valid_tx_ant & BIT(ind))
230 EXPORT_SYMBOL(iwl_toggle_tx_ant);
232 const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
233 EXPORT_SYMBOL(iwl_bcast_addr);
236 /* This function both allocates and initializes hw and priv. */
237 struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
238 struct ieee80211_ops *hw_ops)
240 struct iwl_priv *priv;
242 /* mac80211 allocates memory for this device instance, including
243 * space for this driver's private structure */
244 struct ieee80211_hw *hw =
245 ieee80211_alloc_hw(sizeof(struct iwl_priv), hw_ops);
247 printk(KERN_ERR "%s: Can not allocate network device\n",
258 EXPORT_SYMBOL(iwl_alloc_all);
260 void iwl_hw_detect(struct iwl_priv *priv)
262 priv->hw_rev = _iwl_read32(priv, CSR_HW_REV);
263 priv->hw_wa_rev = _iwl_read32(priv, CSR_HW_REV_WA_REG);
264 pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &priv->rev_id);
266 EXPORT_SYMBOL(iwl_hw_detect);
271 void iwl_activate_qos(struct iwl_priv *priv, u8 force)
273 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
276 priv->qos_data.def_qos_parm.qos_flags = 0;
278 if (priv->qos_data.qos_cap.q_AP.queue_request &&
279 !priv->qos_data.qos_cap.q_AP.txop_request)
280 priv->qos_data.def_qos_parm.qos_flags |=
281 QOS_PARAM_FLG_TXOP_TYPE_MSK;
282 if (priv->qos_data.qos_active)
283 priv->qos_data.def_qos_parm.qos_flags |=
284 QOS_PARAM_FLG_UPDATE_EDCA_MSK;
286 if (priv->current_ht_config.is_ht)
287 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
289 if (force || iwl_is_associated(priv)) {
290 IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
291 priv->qos_data.qos_active,
292 priv->qos_data.def_qos_parm.qos_flags);
294 iwl_send_cmd_pdu_async(priv, REPLY_QOS_PARAM,
295 sizeof(struct iwl_qosparam_cmd),
296 &priv->qos_data.def_qos_parm, NULL);
299 EXPORT_SYMBOL(iwl_activate_qos);
302 * AC CWmin CW max AIFSN TXOP Limit TXOP Limit
303 * (802.11b) (802.11a/g)
304 * AC_BK 15 1023 7 0 0
305 * AC_BE 15 1023 3 0 0
306 * AC_VI 7 15 2 6.016ms 3.008ms
307 * AC_VO 3 7 2 3.264ms 1.504ms
309 void iwl_reset_qos(struct iwl_priv *priv)
314 bool is_legacy = false;
318 spin_lock_irqsave(&priv->lock, flags);
319 /* QoS always active in AP and ADHOC mode
320 * In STA mode wait for association
322 if (priv->iw_mode == NL80211_IFTYPE_ADHOC ||
323 priv->iw_mode == NL80211_IFTYPE_AP)
324 priv->qos_data.qos_active = 1;
326 priv->qos_data.qos_active = 0;
328 /* check for legacy mode */
329 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC &&
330 (priv->active_rate & IWL_OFDM_RATES_MASK) == 0) ||
331 (priv->iw_mode == NL80211_IFTYPE_STATION &&
332 (priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK) == 0)) {
337 if (priv->qos_data.qos_active)
341 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
342 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
343 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
344 priv->qos_data.def_qos_parm.ac[0].edca_txop = 0;
345 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
347 if (priv->qos_data.qos_active) {
350 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
351 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
352 priv->qos_data.def_qos_parm.ac[i].aifsn = 7;
353 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
354 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
358 priv->qos_data.def_qos_parm.ac[i].cw_min =
359 cpu_to_le16((cw_min + 1) / 2 - 1);
360 priv->qos_data.def_qos_parm.ac[i].cw_max =
362 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
364 priv->qos_data.def_qos_parm.ac[i].edca_txop =
367 priv->qos_data.def_qos_parm.ac[i].edca_txop =
369 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
373 priv->qos_data.def_qos_parm.ac[i].cw_min =
374 cpu_to_le16((cw_min + 1) / 4 - 1);
375 priv->qos_data.def_qos_parm.ac[i].cw_max =
376 cpu_to_le16((cw_min + 1) / 2 - 1);
377 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
378 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
380 priv->qos_data.def_qos_parm.ac[i].edca_txop =
383 priv->qos_data.def_qos_parm.ac[i].edca_txop =
386 for (i = 1; i < 4; i++) {
387 priv->qos_data.def_qos_parm.ac[i].cw_min =
389 priv->qos_data.def_qos_parm.ac[i].cw_max =
391 priv->qos_data.def_qos_parm.ac[i].aifsn = aifs;
392 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
393 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
396 IWL_DEBUG_QOS(priv, "set QoS to default \n");
398 spin_unlock_irqrestore(&priv->lock, flags);
400 EXPORT_SYMBOL(iwl_reset_qos);
402 #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
403 #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
404 static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
405 struct ieee80211_sta_ht_cap *ht_info,
406 enum ieee80211_band band)
408 u16 max_bit_rate = 0;
409 u8 rx_chains_num = priv->hw_params.rx_chains_num;
410 u8 tx_chains_num = priv->hw_params.tx_chains_num;
413 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
415 ht_info->ht_supported = true;
417 if (priv->cfg->ht_greenfield_support)
418 ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD;
419 ht_info->cap |= IEEE80211_HT_CAP_SGI_20;
420 max_bit_rate = MAX_BIT_RATE_20_MHZ;
421 if (priv->hw_params.ht40_channel & BIT(band)) {
422 ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
423 ht_info->cap |= IEEE80211_HT_CAP_SGI_40;
424 ht_info->mcs.rx_mask[4] = 0x01;
425 max_bit_rate = MAX_BIT_RATE_40_MHZ;
428 if (priv->cfg->mod_params->amsdu_size_8K)
429 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU;
431 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF;
432 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF;
434 ht_info->mcs.rx_mask[0] = 0xFF;
435 if (rx_chains_num >= 2)
436 ht_info->mcs.rx_mask[1] = 0xFF;
437 if (rx_chains_num >= 3)
438 ht_info->mcs.rx_mask[2] = 0xFF;
440 /* Highest supported Rx data rate */
441 max_bit_rate *= rx_chains_num;
442 WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK);
443 ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate);
445 /* Tx MCS capabilities */
446 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
447 if (tx_chains_num != rx_chains_num) {
448 ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF;
449 ht_info->mcs.tx_params |= ((tx_chains_num - 1) <<
450 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
455 * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom
457 int iwlcore_init_geos(struct iwl_priv *priv)
459 struct iwl_channel_info *ch;
460 struct ieee80211_supported_band *sband;
461 struct ieee80211_channel *channels;
462 struct ieee80211_channel *geo_ch;
463 struct ieee80211_rate *rates;
466 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
467 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
468 IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n");
469 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
473 channels = kzalloc(sizeof(struct ieee80211_channel) *
474 priv->channel_count, GFP_KERNEL);
478 rates = kzalloc((sizeof(struct ieee80211_rate) * IWL_RATE_COUNT_LEGACY),
485 /* 5.2GHz channels start after the 2.4GHz channels */
486 sband = &priv->bands[IEEE80211_BAND_5GHZ];
487 sband->channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)];
489 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
490 sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE;
492 if (priv->cfg->sku & IWL_SKU_N)
493 iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
494 IEEE80211_BAND_5GHZ);
496 sband = &priv->bands[IEEE80211_BAND_2GHZ];
497 sband->channels = channels;
499 sband->bitrates = rates;
500 sband->n_bitrates = IWL_RATE_COUNT_LEGACY;
502 if (priv->cfg->sku & IWL_SKU_N)
503 iwlcore_init_ht_hw_capab(priv, &sband->ht_cap,
504 IEEE80211_BAND_2GHZ);
506 priv->ieee_channels = channels;
507 priv->ieee_rates = rates;
509 for (i = 0; i < priv->channel_count; i++) {
510 ch = &priv->channel_info[i];
512 /* FIXME: might be removed if scan is OK */
513 if (!is_channel_valid(ch))
516 if (is_channel_a_band(ch))
517 sband = &priv->bands[IEEE80211_BAND_5GHZ];
519 sband = &priv->bands[IEEE80211_BAND_2GHZ];
521 geo_ch = &sband->channels[sband->n_channels++];
523 geo_ch->center_freq =
524 ieee80211_channel_to_frequency(ch->channel);
525 geo_ch->max_power = ch->max_power_avg;
526 geo_ch->max_antenna_gain = 0xff;
527 geo_ch->hw_value = ch->channel;
529 if (is_channel_valid(ch)) {
530 if (!(ch->flags & EEPROM_CHANNEL_IBSS))
531 geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
533 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
534 geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
536 if (ch->flags & EEPROM_CHANNEL_RADAR)
537 geo_ch->flags |= IEEE80211_CHAN_RADAR;
539 geo_ch->flags |= ch->ht40_extension_channel;
541 if (ch->max_power_avg > priv->tx_power_device_lmt)
542 priv->tx_power_device_lmt = ch->max_power_avg;
544 geo_ch->flags |= IEEE80211_CHAN_DISABLED;
547 IWL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n",
548 ch->channel, geo_ch->center_freq,
549 is_channel_a_band(ch) ? "5.2" : "2.4",
550 geo_ch->flags & IEEE80211_CHAN_DISABLED ?
551 "restricted" : "valid",
555 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
556 priv->cfg->sku & IWL_SKU_A) {
557 IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
558 "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n",
559 priv->pci_dev->device,
560 priv->pci_dev->subsystem_device);
561 priv->cfg->sku &= ~IWL_SKU_A;
564 IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n",
565 priv->bands[IEEE80211_BAND_2GHZ].n_channels,
566 priv->bands[IEEE80211_BAND_5GHZ].n_channels);
568 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
572 EXPORT_SYMBOL(iwlcore_init_geos);
575 * iwlcore_free_geos - undo allocations in iwlcore_init_geos
577 void iwlcore_free_geos(struct iwl_priv *priv)
579 kfree(priv->ieee_channels);
580 kfree(priv->ieee_rates);
581 clear_bit(STATUS_GEO_CONFIGURED, &priv->status);
583 EXPORT_SYMBOL(iwlcore_free_geos);
586 * iwlcore_rts_tx_cmd_flag: Set rts/cts. 3945 and 4965 only share this
589 void iwlcore_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
592 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
593 *tx_flags |= TX_CMD_FLG_RTS_MSK;
594 *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
595 } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
596 *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
597 *tx_flags |= TX_CMD_FLG_CTS_MSK;
600 EXPORT_SYMBOL(iwlcore_rts_tx_cmd_flag);
602 static bool is_single_rx_stream(struct iwl_priv *priv)
604 return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC ||
605 priv->current_ht_config.single_chain_sufficient;
608 static u8 iwl_is_channel_extension(struct iwl_priv *priv,
609 enum ieee80211_band band,
610 u16 channel, u8 extension_chan_offset)
612 const struct iwl_channel_info *ch_info;
614 ch_info = iwl_get_channel_info(priv, band, channel);
615 if (!is_channel_valid(ch_info))
618 if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
619 return !(ch_info->ht40_extension_channel &
620 IEEE80211_CHAN_NO_HT40PLUS);
621 else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW)
622 return !(ch_info->ht40_extension_channel &
623 IEEE80211_CHAN_NO_HT40MINUS);
628 u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
629 struct ieee80211_sta_ht_cap *sta_ht_inf)
631 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
633 if (!ht_conf->is_ht || !ht_conf->is_40mhz)
636 /* We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40
637 * the bit will not set if it is pure 40MHz case
640 if (!sta_ht_inf->ht_supported)
643 #ifdef CONFIG_IWLWIFI_DEBUG
644 if (priv->disable_ht40)
647 return iwl_is_channel_extension(priv, priv->band,
648 le16_to_cpu(priv->staging_rxon.channel),
649 ht_conf->extension_chan_offset);
651 EXPORT_SYMBOL(iwl_is_ht40_tx_allowed);
653 static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
656 u16 beacon_factor = 0;
658 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
659 new_val = beacon_val / beacon_factor;
662 new_val = max_beacon_val;
667 void iwl_setup_rxon_timing(struct iwl_priv *priv)
670 s32 interval_tm, rem;
672 struct ieee80211_conf *conf = NULL;
675 conf = ieee80211_get_hw_conf(priv->hw);
677 spin_lock_irqsave(&priv->lock, flags);
678 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
679 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
681 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
682 beacon_int = priv->beacon_int;
683 priv->rxon_timing.atim_window = 0;
685 beacon_int = priv->vif->bss_conf.beacon_int;
687 /* TODO: we need to get atim_window from upper stack
688 * for now we set to 0 */
689 priv->rxon_timing.atim_window = 0;
692 beacon_int = iwl_adjust_beacon_interval(beacon_int,
693 priv->hw_params.max_beacon_itrvl * 1024);
694 priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int);
696 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
697 interval_tm = beacon_int * 1024;
698 rem = do_div(tsf, interval_tm);
699 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
701 spin_unlock_irqrestore(&priv->lock, flags);
702 IWL_DEBUG_ASSOC(priv,
703 "beacon interval %d beacon timer %d beacon tim %d\n",
704 le16_to_cpu(priv->rxon_timing.beacon_interval),
705 le32_to_cpu(priv->rxon_timing.beacon_init_val),
706 le16_to_cpu(priv->rxon_timing.atim_window));
708 EXPORT_SYMBOL(iwl_setup_rxon_timing);
710 void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
712 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
715 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
717 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
720 EXPORT_SYMBOL(iwl_set_rxon_hwcrypto);
723 * iwl_check_rxon_cmd - validate RXON structure is valid
725 * NOTE: This is really only useful during development and can eventually
726 * be #ifdef'd out once the driver is stable and folks aren't actively
729 int iwl_check_rxon_cmd(struct iwl_priv *priv)
733 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
735 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
736 error |= le32_to_cpu(rxon->flags &
737 (RXON_FLG_TGJ_NARROW_BAND_MSK |
738 RXON_FLG_RADAR_DETECT_MSK));
740 IWL_WARN(priv, "check 24G fields %d | %d\n",
743 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
744 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
746 IWL_WARN(priv, "check 52 fields %d | %d\n",
748 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
750 IWL_WARN(priv, "check 52 CCK %d | %d\n",
753 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
755 IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error);
757 /* make sure basic rates 6Mbps and 1Mbps are supported */
758 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
759 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
761 IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error);
763 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
765 IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error);
767 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
768 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
770 IWL_WARN(priv, "check CCK and short slot %d | %d\n",
773 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
774 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
776 IWL_WARN(priv, "check CCK & auto detect %d | %d\n",
779 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
780 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
782 IWL_WARN(priv, "check TGG and auto detect %d | %d\n",
786 IWL_WARN(priv, "Tuning to channel %d\n",
787 le16_to_cpu(rxon->channel));
790 IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n");
795 EXPORT_SYMBOL(iwl_check_rxon_cmd);
798 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
799 * @priv: staging_rxon is compared to active_rxon
801 * If the RXON structure is changing enough to require a new tune,
802 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
803 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
805 int iwl_full_rxon_required(struct iwl_priv *priv)
808 /* These items are only settable from the full RXON command */
809 if (!(iwl_is_associated(priv)) ||
810 compare_ether_addr(priv->staging_rxon.bssid_addr,
811 priv->active_rxon.bssid_addr) ||
812 compare_ether_addr(priv->staging_rxon.node_addr,
813 priv->active_rxon.node_addr) ||
814 compare_ether_addr(priv->staging_rxon.wlap_bssid_addr,
815 priv->active_rxon.wlap_bssid_addr) ||
816 (priv->staging_rxon.dev_type != priv->active_rxon.dev_type) ||
817 (priv->staging_rxon.channel != priv->active_rxon.channel) ||
818 (priv->staging_rxon.air_propagation !=
819 priv->active_rxon.air_propagation) ||
820 (priv->staging_rxon.ofdm_ht_single_stream_basic_rates !=
821 priv->active_rxon.ofdm_ht_single_stream_basic_rates) ||
822 (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates !=
823 priv->active_rxon.ofdm_ht_dual_stream_basic_rates) ||
824 (priv->staging_rxon.ofdm_ht_triple_stream_basic_rates !=
825 priv->active_rxon.ofdm_ht_triple_stream_basic_rates) ||
826 (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id))
829 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
830 * be updated with the RXON_ASSOC command -- however only some
831 * flag transitions are allowed using RXON_ASSOC */
833 /* Check if we are not switching bands */
834 if ((priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) !=
835 (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK))
838 /* Check if we are switching association toggle */
839 if ((priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) !=
840 (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK))
845 EXPORT_SYMBOL(iwl_full_rxon_required);
847 u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
850 * Assign the lowest rate -- should really get this from
851 * the beacon skb from mac80211.
853 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
854 return IWL_RATE_1M_PLCP;
856 return IWL_RATE_6M_PLCP;
858 EXPORT_SYMBOL(iwl_rate_get_lowest_plcp);
860 void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
862 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
864 if (!ht_conf->is_ht) {
865 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
866 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
867 RXON_FLG_HT40_PROT_MSK |
868 RXON_FLG_HT_PROT_MSK);
872 /* FIXME: if the definition of ht_protection changed, the "translation"
873 * will be needed for rxon->flags
875 rxon->flags |= cpu_to_le32(ht_conf->ht_protection << RXON_FLG_HT_OPERATING_MODE_POS);
877 /* Set up channel bandwidth:
878 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */
879 /* clear the HT channel mode before set the mode */
880 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
881 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
882 if (iwl_is_ht40_tx_allowed(priv, NULL)) {
884 if (ht_conf->ht_protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) {
885 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40;
886 /* Note: control channel is opposite of extension channel */
887 switch (ht_conf->extension_chan_offset) {
888 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
889 rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
891 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
892 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
896 /* Note: control channel is opposite of extension channel */
897 switch (ht_conf->extension_chan_offset) {
898 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
899 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
900 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
902 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
903 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
904 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
906 case IEEE80211_HT_PARAM_CHA_SEC_NONE:
908 /* channel location only valid if in Mixed mode */
909 IWL_ERR(priv, "invalid extension channel offset\n");
914 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
917 if (priv->cfg->ops->hcmd->set_rxon_chain)
918 priv->cfg->ops->hcmd->set_rxon_chain(priv);
920 IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X "
921 "extension channel offset 0x%x\n",
922 le32_to_cpu(rxon->flags), ht_conf->ht_protection,
923 ht_conf->extension_chan_offset);
926 EXPORT_SYMBOL(iwl_set_rxon_ht);
928 #define IWL_NUM_RX_CHAINS_MULTIPLE 3
929 #define IWL_NUM_RX_CHAINS_SINGLE 2
930 #define IWL_NUM_IDLE_CHAINS_DUAL 2
931 #define IWL_NUM_IDLE_CHAINS_SINGLE 1
934 * Determine how many receiver/antenna chains to use.
936 * More provides better reception via diversity. Fewer saves power
937 * at the expense of throughput, but only when not in powersave to
940 * MIMO (dual stream) requires at least 2, but works better with 3.
941 * This does not determine *which* chains to use, just how many.
943 static int iwl_get_active_rx_chain_count(struct iwl_priv *priv)
945 /* # of Rx chains to use when expecting MIMO. */
946 if (is_single_rx_stream(priv))
947 return IWL_NUM_RX_CHAINS_SINGLE;
949 return IWL_NUM_RX_CHAINS_MULTIPLE;
953 * When we are in power saving mode, unless device support spatial
954 * multiplexing power save, use the active count for rx chain count.
956 static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
958 /* # Rx chains when idling, depending on SMPS mode */
959 switch (priv->current_ht_config.smps) {
960 case IEEE80211_SMPS_STATIC:
961 case IEEE80211_SMPS_DYNAMIC:
962 return IWL_NUM_IDLE_CHAINS_SINGLE;
963 case IEEE80211_SMPS_OFF:
966 WARN(1, "invalid SMPS mode %d",
967 priv->current_ht_config.smps);
973 static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
976 res = (chain_bitmap & BIT(0)) >> 0;
977 res += (chain_bitmap & BIT(1)) >> 1;
978 res += (chain_bitmap & BIT(2)) >> 2;
979 res += (chain_bitmap & BIT(3)) >> 3;
984 * iwl_is_monitor_mode - Determine if interface in monitor mode
986 * priv->iw_mode is set in add_interface, but add_interface is
987 * never called for monitor mode. The only way mac80211 informs us about
988 * monitor mode is through configuring filters (call to configure_filter).
990 bool iwl_is_monitor_mode(struct iwl_priv *priv)
992 return !!(priv->staging_rxon.filter_flags & RXON_FILTER_PROMISC_MSK);
994 EXPORT_SYMBOL(iwl_is_monitor_mode);
997 * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
999 * Selects how many and which Rx receivers/antennas/chains to use.
1000 * This should not be used for scan command ... it puts data in wrong place.
1002 void iwl_set_rxon_chain(struct iwl_priv *priv)
1004 bool is_single = is_single_rx_stream(priv);
1005 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
1006 u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
1010 /* Tell uCode which antennas are actually connected.
1011 * Before first association, we assume all antennas are connected.
1012 * Just after first association, iwl_chain_noise_calibration()
1013 * checks which antennas actually *are* connected. */
1014 if (priv->chain_noise_data.active_chains)
1015 active_chains = priv->chain_noise_data.active_chains;
1017 active_chains = priv->hw_params.valid_rx_ant;
1019 rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS;
1021 /* How many receivers should we use? */
1022 active_rx_cnt = iwl_get_active_rx_chain_count(priv);
1023 idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt);
1026 /* correct rx chain count according hw settings
1027 * and chain noise calibration
1029 valid_rx_cnt = iwl_count_chain_bitmap(active_chains);
1030 if (valid_rx_cnt < active_rx_cnt)
1031 active_rx_cnt = valid_rx_cnt;
1033 if (valid_rx_cnt < idle_rx_cnt)
1034 idle_rx_cnt = valid_rx_cnt;
1036 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS;
1037 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS;
1039 /* copied from 'iwl_bg_request_scan()' */
1040 /* Force use of chains B and C (0x6) for Rx for 4965
1041 * Avoid A (0x1) because of its off-channel reception on A-band.
1042 * MIMO is not used here, but value is required */
1043 if (iwl_is_monitor_mode(priv) &&
1044 !(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) &&
1045 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)) {
1046 rx_chain = ANT_ABC << RXON_RX_CHAIN_VALID_POS;
1047 rx_chain |= ANT_BC << RXON_RX_CHAIN_FORCE_SEL_POS;
1048 rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
1049 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
1052 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain);
1054 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam)
1055 priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK;
1057 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
1059 IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n",
1060 priv->staging_rxon.rx_chain,
1061 active_rx_cnt, idle_rx_cnt);
1063 WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 ||
1064 active_rx_cnt < idle_rx_cnt);
1066 EXPORT_SYMBOL(iwl_set_rxon_chain);
1069 * iwl_set_rxon_channel - Set the phymode and channel values in staging RXON
1070 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
1071 * @channel: Any channel valid for the requested phymode
1073 * In addition to setting the staging RXON, priv->phymode is also set.
1075 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
1076 * in the staging RXON flag structure based on the phymode
1078 int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch)
1080 enum ieee80211_band band = ch->band;
1081 u16 channel = ieee80211_frequency_to_channel(ch->center_freq);
1083 if (!iwl_get_channel_info(priv, band, channel)) {
1084 IWL_DEBUG_INFO(priv, "Could not set channel to %d [%d]\n",
1089 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
1090 (priv->band == band))
1093 priv->staging_rxon.channel = cpu_to_le16(channel);
1094 if (band == IEEE80211_BAND_5GHZ)
1095 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
1097 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
1101 IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band);
1105 EXPORT_SYMBOL(iwl_set_rxon_channel);
1107 void iwl_set_flags_for_band(struct iwl_priv *priv,
1108 enum ieee80211_band band)
1110 if (band == IEEE80211_BAND_5GHZ) {
1111 priv->staging_rxon.flags &=
1112 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
1113 | RXON_FLG_CCK_MSK);
1114 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
1116 /* Copied from iwl_post_associate() */
1117 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
1118 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
1120 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1122 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
1123 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1125 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
1126 priv->staging_rxon.flags |= RXON_FLG_AUTO_DETECT_MSK;
1127 priv->staging_rxon.flags &= ~RXON_FLG_CCK_MSK;
1132 * initialize rxon structure with default values from eeprom
1134 void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
1136 const struct iwl_channel_info *ch_info;
1138 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
1141 case NL80211_IFTYPE_AP:
1142 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
1145 case NL80211_IFTYPE_STATION:
1146 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS;
1147 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
1150 case NL80211_IFTYPE_ADHOC:
1151 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS;
1152 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
1153 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
1154 RXON_FILTER_ACCEPT_GRP_MSK;
1158 IWL_ERR(priv, "Unsupported interface type %d\n", mode);
1163 /* TODO: Figure out when short_preamble would be set and cache from
1165 if (!hw_to_local(priv->hw)->short_preamble)
1166 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1168 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1171 ch_info = iwl_get_channel_info(priv, priv->band,
1172 le16_to_cpu(priv->active_rxon.channel));
1175 ch_info = &priv->channel_info[0];
1177 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
1178 priv->band = ch_info->band;
1180 iwl_set_flags_for_band(priv, priv->band);
1182 priv->staging_rxon.ofdm_basic_rates =
1183 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1184 priv->staging_rxon.cck_basic_rates =
1185 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1187 /* clear both MIX and PURE40 mode flag */
1188 priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED |
1189 RXON_FLG_CHANNEL_MODE_PURE_40);
1190 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
1191 memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
1192 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
1193 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
1194 priv->staging_rxon.ofdm_ht_triple_stream_basic_rates = 0xff;
1196 EXPORT_SYMBOL(iwl_connection_init_rx_config);
1198 static void iwl_set_rate(struct iwl_priv *priv)
1200 const struct ieee80211_supported_band *hw = NULL;
1201 struct ieee80211_rate *rate;
1204 hw = iwl_get_hw_mode(priv, priv->band);
1206 IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n");
1210 priv->active_rate = 0;
1212 for (i = 0; i < hw->n_bitrates; i++) {
1213 rate = &(hw->bitrates[i]);
1214 if (rate->hw_value < IWL_RATE_COUNT_LEGACY)
1215 priv->active_rate |= (1 << rate->hw_value);
1218 IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate);
1220 priv->staging_rxon.cck_basic_rates =
1221 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1223 priv->staging_rxon.ofdm_basic_rates =
1224 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1227 void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1229 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1230 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon;
1231 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
1233 if (priv->switch_rxon.switch_in_progress) {
1234 if (!le32_to_cpu(csa->status) &&
1235 (csa->channel == priv->switch_rxon.channel)) {
1236 rxon->channel = csa->channel;
1237 priv->staging_rxon.channel = csa->channel;
1238 IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",
1239 le16_to_cpu(csa->channel));
1241 IWL_ERR(priv, "CSA notif (fail) : channel %d\n",
1242 le16_to_cpu(csa->channel));
1244 priv->switch_rxon.switch_in_progress = false;
1247 EXPORT_SYMBOL(iwl_rx_csa);
1249 #ifdef CONFIG_IWLWIFI_DEBUG
1250 void iwl_print_rx_config_cmd(struct iwl_priv *priv)
1252 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
1254 IWL_DEBUG_RADIO(priv, "RX CONFIG:\n");
1255 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
1256 IWL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
1257 IWL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
1258 IWL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n",
1259 le32_to_cpu(rxon->filter_flags));
1260 IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type);
1261 IWL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n",
1262 rxon->ofdm_basic_rates);
1263 IWL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
1264 IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr);
1265 IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
1266 IWL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
1268 EXPORT_SYMBOL(iwl_print_rx_config_cmd);
1271 * iwl_irq_handle_error - called for HW or SW error interrupt from card
1273 void iwl_irq_handle_error(struct iwl_priv *priv)
1275 /* Set the FW error flag -- cleared on iwl_down */
1276 set_bit(STATUS_FW_ERROR, &priv->status);
1278 /* Cancel currently queued command. */
1279 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
1281 priv->cfg->ops->lib->dump_nic_error_log(priv);
1282 if (priv->cfg->ops->lib->dump_csr)
1283 priv->cfg->ops->lib->dump_csr(priv);
1284 if (priv->cfg->ops->lib->dump_fh)
1285 priv->cfg->ops->lib->dump_fh(priv, NULL, false);
1286 priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false);
1287 #ifdef CONFIG_IWLWIFI_DEBUG
1288 if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS)
1289 iwl_print_rx_config_cmd(priv);
1292 wake_up_interruptible(&priv->wait_command_queue);
1294 /* Keep the restart process from trying to send host
1295 * commands by clearing the INIT status bit */
1296 clear_bit(STATUS_READY, &priv->status);
1298 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1299 IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
1300 "Restarting adapter due to uCode error.\n");
1302 if (priv->cfg->mod_params->restart_fw)
1303 queue_work(priv->workqueue, &priv->restart);
1306 EXPORT_SYMBOL(iwl_irq_handle_error);
1308 static int iwl_apm_stop_master(struct iwl_priv *priv)
1312 /* stop device's busmaster DMA activity */
1313 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
1315 ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED,
1316 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
1318 IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n");
1320 IWL_DEBUG_INFO(priv, "stop master\n");
1325 void iwl_apm_stop(struct iwl_priv *priv)
1327 IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n");
1329 /* Stop device's DMA activity */
1330 iwl_apm_stop_master(priv);
1332 /* Reset the entire device */
1333 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1338 * Clear "initialization complete" bit to move adapter from
1339 * D0A* (powered-up Active) --> D0U* (Uninitialized) state.
1341 iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
1343 EXPORT_SYMBOL(iwl_apm_stop);
1347 * Start up NIC's basic functionality after it has been reset
1348 * (e.g. after platform boot, or shutdown via iwl_apm_stop())
1349 * NOTE: This does not load uCode nor start the embedded processor
1351 int iwl_apm_init(struct iwl_priv *priv)
1356 IWL_DEBUG_INFO(priv, "Init card's basic functions\n");
1359 * Use "set_bit" below rather than "write", to preserve any hardware
1360 * bits already set by default after reset.
1363 /* Disable L0S exit timer (platform NMI Work/Around) */
1364 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
1365 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
1368 * Disable L0s without affecting L1;
1369 * don't wait for ICH L0s (ICH bug W/A)
1371 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
1372 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
1374 /* Set FH wait threshold to maximum (HW error during stress W/A) */
1375 iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
1378 * Enable HAP INTA (interrupt from management bus) to
1379 * wake device's PCI Express link L1a -> L0s
1380 * NOTE: This is no-op for 3945 (non-existant bit)
1382 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1383 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
1386 * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition.
1387 * Check if BIOS (or OS) enabled L1-ASPM on this device.
1388 * If so (likely), disable L0S, so device moves directly L0->L1;
1389 * costs negligible amount of power savings.
1390 * If not (unlikely), enable L0S, so there is at least some
1391 * power savings, even without L1.
1393 if (priv->cfg->set_l0s) {
1394 lctl = iwl_pcie_link_ctl(priv);
1395 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
1396 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
1397 /* L1-ASPM enabled; disable(!) L0S */
1398 iwl_set_bit(priv, CSR_GIO_REG,
1399 CSR_GIO_REG_VAL_L0S_ENABLED);
1400 IWL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n");
1402 /* L1-ASPM disabled; enable(!) L0S */
1403 iwl_clear_bit(priv, CSR_GIO_REG,
1404 CSR_GIO_REG_VAL_L0S_ENABLED);
1405 IWL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n");
1409 /* Configure analog phase-lock-loop before activating to D0A */
1410 if (priv->cfg->pll_cfg_val)
1411 iwl_set_bit(priv, CSR_ANA_PLL_CFG, priv->cfg->pll_cfg_val);
1414 * Set "initialization complete" bit to move adapter from
1415 * D0U* --> D0A* (powered-up active) state.
1417 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
1420 * Wait for clock stabilization; once stabilized, access to
1421 * device-internal resources is supported, e.g. iwl_write_prph()
1422 * and accesses to uCode SRAM.
1424 ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
1425 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
1426 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1428 IWL_DEBUG_INFO(priv, "Failed to init the card\n");
1433 * Enable DMA and BSM (if used) clocks, wait for them to stabilize.
1434 * BSM (Boostrap State Machine) is only in 3945 and 4965;
1435 * later devices (i.e. 5000 and later) have non-volatile SRAM,
1436 * and don't need BSM to restore data after power-saving sleep.
1438 * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits
1439 * do not disable clocks. This preserves any hardware bits already
1440 * set by default in "CLK_CTRL_REG" after reset.
1442 if (priv->cfg->use_bsm)
1443 iwl_write_prph(priv, APMG_CLK_EN_REG,
1444 APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT);
1446 iwl_write_prph(priv, APMG_CLK_EN_REG,
1447 APMG_CLK_VAL_DMA_CLK_RQT);
1450 /* Disable L1-Active */
1451 iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
1452 APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
1457 EXPORT_SYMBOL(iwl_apm_init);
1461 void iwl_configure_filter(struct ieee80211_hw *hw,
1462 unsigned int changed_flags,
1463 unsigned int *total_flags,
1466 struct iwl_priv *priv = hw->priv;
1467 __le32 *filter_flags = &priv->staging_rxon.filter_flags;
1469 IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n",
1470 changed_flags, *total_flags);
1472 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
1473 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
1474 *filter_flags |= RXON_FILTER_PROMISC_MSK;
1476 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
1478 if (changed_flags & FIF_ALLMULTI) {
1479 if (*total_flags & FIF_ALLMULTI)
1480 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
1482 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
1484 if (changed_flags & FIF_CONTROL) {
1485 if (*total_flags & FIF_CONTROL)
1486 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
1488 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
1490 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
1491 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
1492 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
1494 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
1497 /* We avoid iwl_commit_rxon here to commit the new filter flags
1498 * since mac80211 will call ieee80211_hw_config immediately.
1499 * (mc_list is not supported at this time). Otherwise, we need to
1500 * queue a background iwl_commit_rxon work.
1503 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1504 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
1506 EXPORT_SYMBOL(iwl_configure_filter);
1508 int iwl_set_hw_params(struct iwl_priv *priv)
1510 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
1511 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
1512 if (priv->cfg->mod_params->amsdu_size_8K)
1513 priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_8K);
1515 priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_4K);
1517 priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL;
1519 if (priv->cfg->mod_params->disable_11n)
1520 priv->cfg->sku &= ~IWL_SKU_N;
1522 /* Device-specific setup */
1523 return priv->cfg->ops->lib->set_hw_params(priv);
1525 EXPORT_SYMBOL(iwl_set_hw_params);
1527 int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1530 s8 prev_tx_power = priv->tx_power_user_lmt;
1532 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) {
1533 IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n",
1535 IWL_TX_POWER_TARGET_POWER_MIN);
1539 if (tx_power > priv->tx_power_device_lmt) {
1541 "Requested user TXPOWER %d above upper limit %d.\n",
1542 tx_power, priv->tx_power_device_lmt);
1546 if (priv->tx_power_user_lmt != tx_power)
1549 /* if nic is not up don't send command */
1550 if (iwl_is_ready_rf(priv)) {
1551 priv->tx_power_user_lmt = tx_power;
1552 if (force && priv->cfg->ops->lib->send_tx_power)
1553 ret = priv->cfg->ops->lib->send_tx_power(priv);
1554 else if (!priv->cfg->ops->lib->send_tx_power)
1557 * if fail to set tx_power, restore the orig. tx power
1560 priv->tx_power_user_lmt = prev_tx_power;
1564 * Even this is an async host command, the command
1565 * will always report success from uCode
1566 * So once driver can placing the command into the queue
1567 * successfully, driver can use priv->tx_power_user_lmt
1568 * to reflect the current tx power
1572 EXPORT_SYMBOL(iwl_set_tx_power);
1574 irqreturn_t iwl_isr_legacy(int irq, void *data)
1576 struct iwl_priv *priv = data;
1577 u32 inta, inta_mask;
1582 spin_lock(&priv->lock);
1584 /* Disable (but don't clear!) interrupts here to avoid
1585 * back-to-back ISRs and sporadic interrupts from our NIC.
1586 * If we have something to service, the tasklet will re-enable ints.
1587 * If we *don't* have something, we'll re-enable before leaving here. */
1588 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
1589 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
1591 /* Discover which interrupts are active/pending */
1592 inta = iwl_read32(priv, CSR_INT);
1593 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
1595 /* Ignore interrupt if there's nothing in NIC to service.
1596 * This may be due to IRQ shared with another device,
1597 * or due to sporadic interrupts thrown from our NIC. */
1598 if (!inta && !inta_fh) {
1599 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n");
1603 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
1604 /* Hardware disappeared. It might have already raised
1606 IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
1610 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
1611 inta, inta_mask, inta_fh);
1613 inta &= ~CSR_INT_BIT_SCD;
1615 /* iwl_irq_tasklet() will service interrupts and re-enable them */
1616 if (likely(inta || inta_fh))
1617 tasklet_schedule(&priv->irq_tasklet);
1620 spin_unlock(&priv->lock);
1624 /* re-enable interrupts here since we don't have anything to service. */
1625 /* only Re-enable if diabled by irq */
1626 if (test_bit(STATUS_INT_ENABLED, &priv->status))
1627 iwl_enable_interrupts(priv);
1628 spin_unlock(&priv->lock);
1631 EXPORT_SYMBOL(iwl_isr_legacy);
1633 int iwl_send_bt_config(struct iwl_priv *priv)
1635 struct iwl_bt_cmd bt_cmd = {
1636 .lead_time = BT_LEAD_TIME_DEF,
1637 .max_kill = BT_MAX_KILL_DEF,
1642 if (!bt_coex_active)
1643 bt_cmd.flags = BT_COEX_DISABLE;
1645 bt_cmd.flags = BT_COEX_ENABLE;
1647 IWL_DEBUG_INFO(priv, "BT coex %s\n",
1648 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
1650 return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1651 sizeof(struct iwl_bt_cmd), &bt_cmd);
1653 EXPORT_SYMBOL(iwl_send_bt_config);
1655 int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
1657 struct iwl_statistics_cmd statistics_cmd = {
1658 .configuration_flags =
1659 clear ? IWL_STATS_CONF_CLEAR_STATS : 0,
1662 if (flags & CMD_ASYNC)
1663 return iwl_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD,
1664 sizeof(struct iwl_statistics_cmd),
1665 &statistics_cmd, NULL);
1667 return iwl_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
1668 sizeof(struct iwl_statistics_cmd),
1671 EXPORT_SYMBOL(iwl_send_statistics_request);
1674 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
1675 * using sample data 100 bytes apart. If these sample points are good,
1676 * it's a pretty good bet that everything between them is good, too.
1678 static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len)
1685 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1687 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
1688 /* read data comes through single port, auto-incr addr */
1689 /* NOTE: Use the debugless read so we don't flood kernel log
1690 * if IWL_DL_IO is set */
1691 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
1692 i + IWL49_RTC_INST_LOWER_BOUND);
1693 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1694 if (val != le32_to_cpu(*image)) {
1706 * iwlcore_verify_inst_full - verify runtime uCode image in card vs. host,
1707 * looking at all data.
1709 static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
1717 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1719 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
1720 IWL49_RTC_INST_LOWER_BOUND);
1723 for (; len > 0; len -= sizeof(u32), image++) {
1724 /* read data comes through single port, auto-incr addr */
1725 /* NOTE: Use the debugless read so we don't flood kernel log
1726 * if IWL_DL_IO is set */
1727 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1728 if (val != le32_to_cpu(*image)) {
1729 IWL_ERR(priv, "uCode INST section is invalid at "
1730 "offset 0x%x, is 0x%x, s/b 0x%x\n",
1731 save_len - len, val, le32_to_cpu(*image));
1740 IWL_DEBUG_INFO(priv,
1741 "ucode image in INSTRUCTION memory is good\n");
1747 * iwl_verify_ucode - determine which instruction image is in SRAM,
1748 * and verify its contents
1750 int iwl_verify_ucode(struct iwl_priv *priv)
1757 image = (__le32 *)priv->ucode_boot.v_addr;
1758 len = priv->ucode_boot.len;
1759 ret = iwlcore_verify_inst_sparse(priv, image, len);
1761 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
1765 /* Try initialize */
1766 image = (__le32 *)priv->ucode_init.v_addr;
1767 len = priv->ucode_init.len;
1768 ret = iwlcore_verify_inst_sparse(priv, image, len);
1770 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
1774 /* Try runtime/protocol */
1775 image = (__le32 *)priv->ucode_code.v_addr;
1776 len = priv->ucode_code.len;
1777 ret = iwlcore_verify_inst_sparse(priv, image, len);
1779 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
1783 IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
1785 /* Since nothing seems to match, show first several data entries in
1786 * instruction SRAM, so maybe visual inspection will give a clue.
1787 * Selection of bootstrap image (vs. other images) is arbitrary. */
1788 image = (__le32 *)priv->ucode_boot.v_addr;
1789 len = priv->ucode_boot.len;
1790 ret = iwl_verify_inst_full(priv, image, len);
1794 EXPORT_SYMBOL(iwl_verify_ucode);
1797 void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1799 struct iwl_ct_kill_config cmd;
1800 struct iwl_ct_kill_throttling_config adv_cmd;
1801 unsigned long flags;
1804 spin_lock_irqsave(&priv->lock, flags);
1805 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
1806 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
1807 spin_unlock_irqrestore(&priv->lock, flags);
1808 priv->thermal_throttle.ct_kill_toggle = false;
1810 if (priv->cfg->support_ct_kill_exit) {
1811 adv_cmd.critical_temperature_enter =
1812 cpu_to_le32(priv->hw_params.ct_kill_threshold);
1813 adv_cmd.critical_temperature_exit =
1814 cpu_to_le32(priv->hw_params.ct_kill_exit_threshold);
1816 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD,
1817 sizeof(adv_cmd), &adv_cmd);
1819 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
1821 IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD "
1823 "critical temperature enter is %d,"
1825 priv->hw_params.ct_kill_threshold,
1826 priv->hw_params.ct_kill_exit_threshold);
1828 cmd.critical_temperature_R =
1829 cpu_to_le32(priv->hw_params.ct_kill_threshold);
1831 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD,
1834 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
1836 IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD "
1838 "critical temperature is %d\n",
1839 priv->hw_params.ct_kill_threshold);
1842 EXPORT_SYMBOL(iwl_rf_kill_ct_config);
1848 * Use: Sets the device's internal card state to enable, disable, or halt
1850 * When in the 'enable' state the card operates as normal.
1851 * When in the 'disable' state, the card enters into a low power mode.
1852 * When in the 'halt' state, the card is shut down and must be fully
1853 * restarted to come back on.
1855 int iwl_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag)
1857 struct iwl_host_cmd cmd = {
1858 .id = REPLY_CARD_STATE_CMD,
1864 return iwl_send_cmd(priv, &cmd);
1867 void iwl_rx_pm_sleep_notif(struct iwl_priv *priv,
1868 struct iwl_rx_mem_buffer *rxb)
1870 #ifdef CONFIG_IWLWIFI_DEBUG
1871 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1872 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
1873 IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
1874 sleep->pm_sleep_mode, sleep->pm_wakeup_src);
1877 EXPORT_SYMBOL(iwl_rx_pm_sleep_notif);
1879 void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
1880 struct iwl_rx_mem_buffer *rxb)
1882 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1883 u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
1884 IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
1885 "notification for %s:\n", len,
1886 get_cmd_string(pkt->hdr.cmd));
1887 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len);
1889 EXPORT_SYMBOL(iwl_rx_pm_debug_statistics_notif);
1891 void iwl_rx_reply_error(struct iwl_priv *priv,
1892 struct iwl_rx_mem_buffer *rxb)
1894 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1896 IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) "
1897 "seq 0x%04X ser 0x%08X\n",
1898 le32_to_cpu(pkt->u.err_resp.error_type),
1899 get_cmd_string(pkt->u.err_resp.cmd_id),
1900 pkt->u.err_resp.cmd_id,
1901 le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num),
1902 le32_to_cpu(pkt->u.err_resp.error_info));
1904 EXPORT_SYMBOL(iwl_rx_reply_error);
1906 void iwl_clear_isr_stats(struct iwl_priv *priv)
1908 memset(&priv->isr_stats, 0, sizeof(priv->isr_stats));
1911 int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1912 const struct ieee80211_tx_queue_params *params)
1914 struct iwl_priv *priv = hw->priv;
1915 unsigned long flags;
1918 IWL_DEBUG_MAC80211(priv, "enter\n");
1920 if (!iwl_is_ready_rf(priv)) {
1921 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
1925 if (queue >= AC_NUM) {
1926 IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
1930 q = AC_NUM - 1 - queue;
1932 spin_lock_irqsave(&priv->lock, flags);
1934 priv->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min);
1935 priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max);
1936 priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
1937 priv->qos_data.def_qos_parm.ac[q].edca_txop =
1938 cpu_to_le16((params->txop * 32));
1940 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
1941 priv->qos_data.qos_active = 1;
1943 if (priv->iw_mode == NL80211_IFTYPE_AP)
1944 iwl_activate_qos(priv, 1);
1945 else if (priv->assoc_id && iwl_is_associated(priv))
1946 iwl_activate_qos(priv, 0);
1948 spin_unlock_irqrestore(&priv->lock, flags);
1950 IWL_DEBUG_MAC80211(priv, "leave\n");
1953 EXPORT_SYMBOL(iwl_mac_conf_tx);
1955 static void iwl_ht_conf(struct iwl_priv *priv,
1956 struct ieee80211_bss_conf *bss_conf)
1958 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1959 struct ieee80211_sta *sta;
1961 IWL_DEBUG_MAC80211(priv, "enter: \n");
1963 if (!ht_conf->is_ht)
1966 ht_conf->ht_protection =
1967 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
1968 ht_conf->non_GF_STA_present =
1969 !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
1971 ht_conf->single_chain_sufficient = false;
1973 switch (priv->iw_mode) {
1974 case NL80211_IFTYPE_STATION:
1976 sta = ieee80211_find_sta(priv->vif, priv->bssid);
1978 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
1981 maxstreams = (ht_cap->mcs.tx_params &
1982 IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
1983 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
1986 if ((ht_cap->mcs.rx_mask[1] == 0) &&
1987 (ht_cap->mcs.rx_mask[2] == 0))
1988 ht_conf->single_chain_sufficient = true;
1989 if (maxstreams <= 1)
1990 ht_conf->single_chain_sufficient = true;
1993 * If at all, this can only happen through a race
1994 * when the AP disconnects us while we're still
1995 * setting up the connection, in that case mac80211
1996 * will soon tell us about that.
1998 ht_conf->single_chain_sufficient = true;
2002 case NL80211_IFTYPE_ADHOC:
2003 ht_conf->single_chain_sufficient = true;
2009 IWL_DEBUG_MAC80211(priv, "leave\n");
2012 static inline void iwl_set_no_assoc(struct iwl_priv *priv)
2015 iwl_led_disassociate(priv);
2017 * inform the ucode that there is no longer an
2018 * association and that no more packets should be
2021 priv->staging_rxon.filter_flags &=
2022 ~RXON_FILTER_ASSOC_MSK;
2023 priv->staging_rxon.assoc_id = 0;
2024 iwlcore_commit_rxon(priv);
2027 #define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
2028 void iwl_bss_info_changed(struct ieee80211_hw *hw,
2029 struct ieee80211_vif *vif,
2030 struct ieee80211_bss_conf *bss_conf,
2033 struct iwl_priv *priv = hw->priv;
2036 IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
2038 if (!iwl_is_alive(priv))
2041 mutex_lock(&priv->mutex);
2043 if (changes & BSS_CHANGED_BEACON &&
2044 priv->iw_mode == NL80211_IFTYPE_AP) {
2045 dev_kfree_skb(priv->ibss_beacon);
2046 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
2049 if (changes & BSS_CHANGED_BEACON_INT) {
2050 priv->beacon_int = bss_conf->beacon_int;
2051 /* TODO: in AP mode, do something to make this take effect */
2054 if (changes & BSS_CHANGED_BSSID) {
2055 IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid);
2058 * If there is currently a HW scan going on in the
2059 * background then we need to cancel it else the RXON
2060 * below/in post_associate will fail.
2062 if (iwl_scan_cancel_timeout(priv, 100)) {
2063 IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
2064 IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
2065 mutex_unlock(&priv->mutex);
2069 /* mac80211 only sets assoc when in STATION mode */
2070 if (priv->iw_mode == NL80211_IFTYPE_ADHOC ||
2072 memcpy(priv->staging_rxon.bssid_addr,
2073 bss_conf->bssid, ETH_ALEN);
2075 /* currently needed in a few places */
2076 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
2078 priv->staging_rxon.filter_flags &=
2079 ~RXON_FILTER_ASSOC_MSK;
2085 * This needs to be after setting the BSSID in case
2086 * mac80211 decides to do both changes at once because
2087 * it will invoke post_associate.
2089 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
2090 changes & BSS_CHANGED_BEACON) {
2091 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2094 iwl_mac_beacon_update(hw, beacon);
2097 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
2098 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
2099 bss_conf->use_short_preamble);
2100 if (bss_conf->use_short_preamble)
2101 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
2103 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
2106 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
2107 IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
2108 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
2109 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
2111 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
2114 if (changes & BSS_CHANGED_BASIC_RATES) {
2115 /* XXX use this information
2117 * To do that, remove code from iwl_set_rate() and put something
2121 priv->staging_rxon.ofdm_basic_rates =
2122 bss_conf->basic_rates;
2124 priv->staging_rxon.ofdm_basic_rates =
2125 bss_conf->basic_rates >> 4;
2126 priv->staging_rxon.cck_basic_rates =
2127 bss_conf->basic_rates & 0xF;
2131 if (changes & BSS_CHANGED_HT) {
2132 iwl_ht_conf(priv, bss_conf);
2134 if (priv->cfg->ops->hcmd->set_rxon_chain)
2135 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2138 if (changes & BSS_CHANGED_ASSOC) {
2139 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
2140 if (bss_conf->assoc) {
2141 priv->assoc_id = bss_conf->aid;
2142 priv->beacon_int = bss_conf->beacon_int;
2143 priv->timestamp = bss_conf->timestamp;
2144 priv->assoc_capability = bss_conf->assoc_capability;
2146 iwl_led_associate(priv);
2149 * We have just associated, don't start scan too early
2150 * leave time for EAPOL exchange to complete.
2152 * XXX: do this in mac80211
2154 priv->next_scan_jiffies = jiffies +
2155 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
2156 if (!iwl_is_rfkill(priv))
2157 priv->cfg->ops->lib->post_associate(priv);
2159 iwl_set_no_assoc(priv);
2162 if (changes && iwl_is_associated(priv) && priv->assoc_id) {
2163 IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n",
2165 ret = iwl_send_rxon_assoc(priv);
2167 /* Sync active_rxon with latest change. */
2168 memcpy((void *)&priv->active_rxon,
2169 &priv->staging_rxon,
2170 sizeof(struct iwl_rxon_cmd));
2174 if (changes & BSS_CHANGED_BEACON_ENABLED) {
2175 if (vif->bss_conf.enable_beacon) {
2176 memcpy(priv->staging_rxon.bssid_addr,
2177 bss_conf->bssid, ETH_ALEN);
2178 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
2179 iwlcore_config_ap(priv);
2181 iwl_set_no_assoc(priv);
2184 mutex_unlock(&priv->mutex);
2186 IWL_DEBUG_MAC80211(priv, "leave\n");
2188 EXPORT_SYMBOL(iwl_bss_info_changed);
2190 int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
2192 struct iwl_priv *priv = hw->priv;
2193 unsigned long flags;
2196 IWL_DEBUG_MAC80211(priv, "enter\n");
2198 if (!iwl_is_ready_rf(priv)) {
2199 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
2203 spin_lock_irqsave(&priv->lock, flags);
2205 if (priv->ibss_beacon)
2206 dev_kfree_skb(priv->ibss_beacon);
2208 priv->ibss_beacon = skb;
2211 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
2212 priv->timestamp = le64_to_cpu(timestamp);
2214 IWL_DEBUG_MAC80211(priv, "leave\n");
2215 spin_unlock_irqrestore(&priv->lock, flags);
2217 iwl_reset_qos(priv);
2219 priv->cfg->ops->lib->post_associate(priv);
2224 EXPORT_SYMBOL(iwl_mac_beacon_update);
2226 static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif)
2228 iwl_connection_init_rx_config(priv, vif->type);
2230 if (priv->cfg->ops->hcmd->set_rxon_chain)
2231 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2233 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2235 return iwlcore_commit_rxon(priv);
2238 int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2240 struct iwl_priv *priv = hw->priv;
2243 IWL_DEBUG_MAC80211(priv, "enter: type %d\n", vif->type);
2245 mutex_lock(&priv->mutex);
2247 if (WARN_ON(!iwl_is_ready_rf(priv))) {
2253 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
2259 priv->iw_mode = vif->type;
2261 IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr);
2262 memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
2264 err = iwl_set_mode(priv, vif);
2268 /* Add the broadcast address so we can send broadcast frames */
2269 priv->cfg->ops->lib->add_bcast_station(priv);
2275 priv->iw_mode = NL80211_IFTYPE_STATION;
2277 mutex_unlock(&priv->mutex);
2279 IWL_DEBUG_MAC80211(priv, "leave\n");
2282 EXPORT_SYMBOL(iwl_mac_add_interface);
2284 void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2285 struct ieee80211_vif *vif)
2287 struct iwl_priv *priv = hw->priv;
2289 IWL_DEBUG_MAC80211(priv, "enter\n");
2291 mutex_lock(&priv->mutex);
2293 iwl_clear_ucode_stations(priv, true);
2295 if (iwl_is_ready_rf(priv)) {
2296 iwl_scan_cancel_timeout(priv, 100);
2297 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2298 iwlcore_commit_rxon(priv);
2300 if (priv->vif == vif) {
2302 memset(priv->bssid, 0, ETH_ALEN);
2304 mutex_unlock(&priv->mutex);
2306 IWL_DEBUG_MAC80211(priv, "leave\n");
2309 EXPORT_SYMBOL(iwl_mac_remove_interface);
2312 * iwl_mac_config - mac80211 config callback
2314 * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
2315 * be set inappropriately and the driver currently sets the hardware up to
2316 * use it whenever needed.
2318 int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2320 struct iwl_priv *priv = hw->priv;
2321 const struct iwl_channel_info *ch_info;
2322 struct ieee80211_conf *conf = &hw->conf;
2323 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
2324 unsigned long flags = 0;
2327 int scan_active = 0;
2329 mutex_lock(&priv->mutex);
2331 IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n",
2332 conf->channel->hw_value, changed);
2334 if (unlikely(!priv->cfg->mod_params->disable_hw_scan &&
2335 test_bit(STATUS_SCANNING, &priv->status))) {
2337 IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
2340 if (changed & (IEEE80211_CONF_CHANGE_SMPS |
2341 IEEE80211_CONF_CHANGE_CHANNEL)) {
2342 /* mac80211 uses static for non-HT which is what we want */
2343 priv->current_ht_config.smps = conf->smps_mode;
2346 * Recalculate chain counts.
2348 * If monitor mode is enabled then mac80211 will
2349 * set up the SM PS mode to OFF if an HT channel is
2352 if (priv->cfg->ops->hcmd->set_rxon_chain)
2353 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2356 /* during scanning mac80211 will delay channel setting until
2357 * scan finish with changed = 0
2359 if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) {
2363 ch = ieee80211_frequency_to_channel(conf->channel->center_freq);
2364 ch_info = iwl_get_channel_info(priv, conf->channel->band, ch);
2365 if (!is_channel_valid(ch_info)) {
2366 IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
2371 spin_lock_irqsave(&priv->lock, flags);
2373 /* Configure HT40 channels */
2374 ht_conf->is_ht = conf_is_ht(conf);
2375 if (ht_conf->is_ht) {
2376 if (conf_is_ht40_minus(conf)) {
2377 ht_conf->extension_chan_offset =
2378 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
2379 ht_conf->is_40mhz = true;
2380 } else if (conf_is_ht40_plus(conf)) {
2381 ht_conf->extension_chan_offset =
2382 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
2383 ht_conf->is_40mhz = true;
2385 ht_conf->extension_chan_offset =
2386 IEEE80211_HT_PARAM_CHA_SEC_NONE;
2387 ht_conf->is_40mhz = false;
2390 ht_conf->is_40mhz = false;
2391 /* Default to no protection. Protection mode will later be set
2392 * from BSS config in iwl_ht_conf */
2393 ht_conf->ht_protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
2395 /* if we are switching from ht to 2.4 clear flags
2396 * from any ht related info since 2.4 does not
2398 if ((le16_to_cpu(priv->staging_rxon.channel) != ch))
2399 priv->staging_rxon.flags = 0;
2401 iwl_set_rxon_channel(priv, conf->channel);
2402 iwl_set_rxon_ht(priv, ht_conf);
2404 iwl_set_flags_for_band(priv, conf->channel->band);
2405 spin_unlock_irqrestore(&priv->lock, flags);
2406 if (iwl_is_associated(priv) &&
2407 (le16_to_cpu(priv->active_rxon.channel) != ch) &&
2408 priv->cfg->ops->lib->set_channel_switch) {
2411 * at this point, staging_rxon has the
2412 * configuration for channel switch
2414 ret = priv->cfg->ops->lib->set_channel_switch(priv,
2417 iwl_print_rx_config_cmd(priv);
2420 priv->switch_rxon.switch_in_progress = false;
2423 /* The list of supported rates and rate mask can be different
2424 * for each band; since the band may have changed, reset
2425 * the rate mask to what mac80211 lists */
2429 if (changed & (IEEE80211_CONF_CHANGE_PS |
2430 IEEE80211_CONF_CHANGE_IDLE)) {
2431 ret = iwl_power_update_mode(priv, false);
2433 IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n");
2436 if (changed & IEEE80211_CONF_CHANGE_POWER) {
2437 IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
2438 priv->tx_power_user_lmt, conf->power_level);
2440 iwl_set_tx_power(priv, conf->power_level, false);
2443 if (!iwl_is_ready(priv)) {
2444 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
2451 if (memcmp(&priv->active_rxon,
2452 &priv->staging_rxon, sizeof(priv->staging_rxon)))
2453 iwlcore_commit_rxon(priv);
2455 IWL_DEBUG_INFO(priv, "Not re-sending same RXON configuration.\n");
2459 IWL_DEBUG_MAC80211(priv, "leave\n");
2460 mutex_unlock(&priv->mutex);
2463 EXPORT_SYMBOL(iwl_mac_config);
2465 void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2467 struct iwl_priv *priv = hw->priv;
2468 unsigned long flags;
2470 mutex_lock(&priv->mutex);
2471 IWL_DEBUG_MAC80211(priv, "enter\n");
2473 spin_lock_irqsave(&priv->lock, flags);
2474 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_config));
2475 spin_unlock_irqrestore(&priv->lock, flags);
2477 iwl_reset_qos(priv);
2479 spin_lock_irqsave(&priv->lock, flags);
2481 priv->assoc_capability = 0;
2483 /* new association get rid of ibss beacon skb */
2484 if (priv->ibss_beacon)
2485 dev_kfree_skb(priv->ibss_beacon);
2487 priv->ibss_beacon = NULL;
2489 priv->beacon_int = priv->vif->bss_conf.beacon_int;
2490 priv->timestamp = 0;
2492 spin_unlock_irqrestore(&priv->lock, flags);
2494 if (!iwl_is_ready_rf(priv)) {
2495 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
2496 mutex_unlock(&priv->mutex);
2500 /* we are restarting association process
2501 * clear RXON_FILTER_ASSOC_MSK bit
2503 iwl_scan_cancel_timeout(priv, 100);
2504 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2505 iwlcore_commit_rxon(priv);
2509 mutex_unlock(&priv->mutex);
2511 IWL_DEBUG_MAC80211(priv, "leave\n");
2513 EXPORT_SYMBOL(iwl_mac_reset_tsf);
2515 int iwl_alloc_txq_mem(struct iwl_priv *priv)
2518 priv->txq = kzalloc(
2519 sizeof(struct iwl_tx_queue) * priv->cfg->num_of_queues,
2522 IWL_ERR(priv, "Not enough memory for txq \n");
2527 EXPORT_SYMBOL(iwl_alloc_txq_mem);
2529 void iwl_free_txq_mem(struct iwl_priv *priv)
2534 EXPORT_SYMBOL(iwl_free_txq_mem);
2536 int iwl_send_wimax_coex(struct iwl_priv *priv)
2538 struct iwl_wimax_coex_cmd uninitialized_var(coex_cmd);
2540 if (priv->cfg->support_wimax_coexist) {
2541 /* UnMask wake up src at associated sleep */
2542 coex_cmd.flags |= COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
2544 /* UnMask wake up src at unassociated sleep */
2545 coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK;
2546 memcpy(coex_cmd.sta_prio, cu_priorities,
2547 sizeof(struct iwl_wimax_coex_event_entry) *
2548 COEX_NUM_OF_EVENTS);
2550 /* enabling the coexistence feature */
2551 coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK;
2553 /* enabling the priorities tables */
2554 coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK;
2556 /* coexistence is disabled */
2557 memset(&coex_cmd, 0, sizeof(coex_cmd));
2559 return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
2560 sizeof(coex_cmd), &coex_cmd);
2562 EXPORT_SYMBOL(iwl_send_wimax_coex);
2564 #ifdef CONFIG_IWLWIFI_DEBUGFS
2566 #define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES)
2568 void iwl_reset_traffic_log(struct iwl_priv *priv)
2570 priv->tx_traffic_idx = 0;
2571 priv->rx_traffic_idx = 0;
2572 if (priv->tx_traffic)
2573 memset(priv->tx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE);
2574 if (priv->rx_traffic)
2575 memset(priv->rx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE);
2578 int iwl_alloc_traffic_mem(struct iwl_priv *priv)
2580 u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE;
2582 if (iwl_debug_level & IWL_DL_TX) {
2583 if (!priv->tx_traffic) {
2585 kzalloc(traffic_size, GFP_KERNEL);
2586 if (!priv->tx_traffic)
2590 if (iwl_debug_level & IWL_DL_RX) {
2591 if (!priv->rx_traffic) {
2593 kzalloc(traffic_size, GFP_KERNEL);
2594 if (!priv->rx_traffic)
2598 iwl_reset_traffic_log(priv);
2601 EXPORT_SYMBOL(iwl_alloc_traffic_mem);
2603 void iwl_free_traffic_mem(struct iwl_priv *priv)
2605 kfree(priv->tx_traffic);
2606 priv->tx_traffic = NULL;
2608 kfree(priv->rx_traffic);
2609 priv->rx_traffic = NULL;
2611 EXPORT_SYMBOL(iwl_free_traffic_mem);
2613 void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
2614 u16 length, struct ieee80211_hdr *header)
2619 if (likely(!(iwl_debug_level & IWL_DL_TX)))
2622 if (!priv->tx_traffic)
2625 fc = header->frame_control;
2626 if (ieee80211_is_data(fc)) {
2627 len = (length > IWL_TRAFFIC_ENTRY_SIZE)
2628 ? IWL_TRAFFIC_ENTRY_SIZE : length;
2629 memcpy((priv->tx_traffic +
2630 (priv->tx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)),
2632 priv->tx_traffic_idx =
2633 (priv->tx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES;
2636 EXPORT_SYMBOL(iwl_dbg_log_tx_data_frame);
2638 void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
2639 u16 length, struct ieee80211_hdr *header)
2644 if (likely(!(iwl_debug_level & IWL_DL_RX)))
2647 if (!priv->rx_traffic)
2650 fc = header->frame_control;
2651 if (ieee80211_is_data(fc)) {
2652 len = (length > IWL_TRAFFIC_ENTRY_SIZE)
2653 ? IWL_TRAFFIC_ENTRY_SIZE : length;
2654 memcpy((priv->rx_traffic +
2655 (priv->rx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)),
2657 priv->rx_traffic_idx =
2658 (priv->rx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES;
2661 EXPORT_SYMBOL(iwl_dbg_log_rx_data_frame);
2663 const char *get_mgmt_string(int cmd)
2666 IWL_CMD(MANAGEMENT_ASSOC_REQ);
2667 IWL_CMD(MANAGEMENT_ASSOC_RESP);
2668 IWL_CMD(MANAGEMENT_REASSOC_REQ);
2669 IWL_CMD(MANAGEMENT_REASSOC_RESP);
2670 IWL_CMD(MANAGEMENT_PROBE_REQ);
2671 IWL_CMD(MANAGEMENT_PROBE_RESP);
2672 IWL_CMD(MANAGEMENT_BEACON);
2673 IWL_CMD(MANAGEMENT_ATIM);
2674 IWL_CMD(MANAGEMENT_DISASSOC);
2675 IWL_CMD(MANAGEMENT_AUTH);
2676 IWL_CMD(MANAGEMENT_DEAUTH);
2677 IWL_CMD(MANAGEMENT_ACTION);
2684 const char *get_ctrl_string(int cmd)
2687 IWL_CMD(CONTROL_BACK_REQ);
2688 IWL_CMD(CONTROL_BACK);
2689 IWL_CMD(CONTROL_PSPOLL);
2690 IWL_CMD(CONTROL_RTS);
2691 IWL_CMD(CONTROL_CTS);
2692 IWL_CMD(CONTROL_ACK);
2693 IWL_CMD(CONTROL_CFEND);
2694 IWL_CMD(CONTROL_CFENDACK);
2701 void iwl_clear_traffic_stats(struct iwl_priv *priv)
2703 memset(&priv->tx_stats, 0, sizeof(struct traffic_stats));
2704 memset(&priv->rx_stats, 0, sizeof(struct traffic_stats));
2709 * if CONFIG_IWLWIFI_DEBUGFS defined, iwl_update_stats function will
2710 * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass.
2711 * Use debugFs to display the rx/rx_statistics
2712 * if CONFIG_IWLWIFI_DEBUGFS not being defined, then no MGMT and CTRL
2713 * information will be recorded, but DATA pkt still will be recorded
2714 * for the reason of iwl_led.c need to control the led blinking based on
2715 * number of tx and rx data.
2718 void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
2720 struct traffic_stats *stats;
2723 stats = &priv->tx_stats;
2725 stats = &priv->rx_stats;
2727 if (ieee80211_is_mgmt(fc)) {
2728 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
2729 case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
2730 stats->mgmt[MANAGEMENT_ASSOC_REQ]++;
2732 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
2733 stats->mgmt[MANAGEMENT_ASSOC_RESP]++;
2735 case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
2736 stats->mgmt[MANAGEMENT_REASSOC_REQ]++;
2738 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
2739 stats->mgmt[MANAGEMENT_REASSOC_RESP]++;
2741 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ):
2742 stats->mgmt[MANAGEMENT_PROBE_REQ]++;
2744 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
2745 stats->mgmt[MANAGEMENT_PROBE_RESP]++;
2747 case cpu_to_le16(IEEE80211_STYPE_BEACON):
2748 stats->mgmt[MANAGEMENT_BEACON]++;
2750 case cpu_to_le16(IEEE80211_STYPE_ATIM):
2751 stats->mgmt[MANAGEMENT_ATIM]++;
2753 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
2754 stats->mgmt[MANAGEMENT_DISASSOC]++;
2756 case cpu_to_le16(IEEE80211_STYPE_AUTH):
2757 stats->mgmt[MANAGEMENT_AUTH]++;
2759 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
2760 stats->mgmt[MANAGEMENT_DEAUTH]++;
2762 case cpu_to_le16(IEEE80211_STYPE_ACTION):
2763 stats->mgmt[MANAGEMENT_ACTION]++;
2766 } else if (ieee80211_is_ctl(fc)) {
2767 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
2768 case cpu_to_le16(IEEE80211_STYPE_BACK_REQ):
2769 stats->ctrl[CONTROL_BACK_REQ]++;
2771 case cpu_to_le16(IEEE80211_STYPE_BACK):
2772 stats->ctrl[CONTROL_BACK]++;
2774 case cpu_to_le16(IEEE80211_STYPE_PSPOLL):
2775 stats->ctrl[CONTROL_PSPOLL]++;
2777 case cpu_to_le16(IEEE80211_STYPE_RTS):
2778 stats->ctrl[CONTROL_RTS]++;
2780 case cpu_to_le16(IEEE80211_STYPE_CTS):
2781 stats->ctrl[CONTROL_CTS]++;
2783 case cpu_to_le16(IEEE80211_STYPE_ACK):
2784 stats->ctrl[CONTROL_ACK]++;
2786 case cpu_to_le16(IEEE80211_STYPE_CFEND):
2787 stats->ctrl[CONTROL_CFEND]++;
2789 case cpu_to_le16(IEEE80211_STYPE_CFENDACK):
2790 stats->ctrl[CONTROL_CFENDACK]++;
2796 stats->data_bytes += len;
2798 iwl_leds_background(priv);
2800 EXPORT_SYMBOL(iwl_update_stats);
2803 const static char *get_csr_string(int cmd)
2806 IWL_CMD(CSR_HW_IF_CONFIG_REG);
2807 IWL_CMD(CSR_INT_COALESCING);
2809 IWL_CMD(CSR_INT_MASK);
2810 IWL_CMD(CSR_FH_INT_STATUS);
2811 IWL_CMD(CSR_GPIO_IN);
2813 IWL_CMD(CSR_GP_CNTRL);
2814 IWL_CMD(CSR_HW_REV);
2815 IWL_CMD(CSR_EEPROM_REG);
2816 IWL_CMD(CSR_EEPROM_GP);
2817 IWL_CMD(CSR_OTP_GP_REG);
2818 IWL_CMD(CSR_GIO_REG);
2819 IWL_CMD(CSR_GP_UCODE_REG);
2820 IWL_CMD(CSR_GP_DRIVER_REG);
2821 IWL_CMD(CSR_UCODE_DRV_GP1);
2822 IWL_CMD(CSR_UCODE_DRV_GP2);
2823 IWL_CMD(CSR_LED_REG);
2824 IWL_CMD(CSR_DRAM_INT_TBL_REG);
2825 IWL_CMD(CSR_GIO_CHICKEN_BITS);
2826 IWL_CMD(CSR_ANA_PLL_CFG);
2827 IWL_CMD(CSR_HW_REV_WA_REG);
2828 IWL_CMD(CSR_DBG_HPET_MEM_REG);
2835 void iwl_dump_csr(struct iwl_priv *priv)
2839 CSR_HW_IF_CONFIG_REG,
2857 CSR_DRAM_INT_TBL_REG,
2858 CSR_GIO_CHICKEN_BITS,
2861 CSR_DBG_HPET_MEM_REG
2863 IWL_ERR(priv, "CSR values:\n");
2864 IWL_ERR(priv, "(2nd byte of CSR_INT_COALESCING is "
2865 "CSR_INT_PERIODIC_REG)\n");
2866 for (i = 0; i < ARRAY_SIZE(csr_tbl); i++) {
2867 IWL_ERR(priv, " %25s: 0X%08x\n",
2868 get_csr_string(csr_tbl[i]),
2869 iwl_read32(priv, csr_tbl[i]));
2872 EXPORT_SYMBOL(iwl_dump_csr);
2874 const static char *get_fh_string(int cmd)
2877 IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG);
2878 IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG);
2879 IWL_CMD(FH_RSCSR_CHNL0_WPTR);
2880 IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG);
2881 IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG);
2882 IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG);
2883 IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV);
2884 IWL_CMD(FH_TSSR_TX_STATUS_REG);
2885 IWL_CMD(FH_TSSR_TX_ERROR_REG);
2892 int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display)
2895 #ifdef CONFIG_IWLWIFI_DEBUG
2900 FH_RSCSR_CHNL0_STTS_WPTR_REG,
2901 FH_RSCSR_CHNL0_RBDCB_BASE_REG,
2902 FH_RSCSR_CHNL0_WPTR,
2903 FH_MEM_RCSR_CHNL0_CONFIG_REG,
2904 FH_MEM_RSSR_SHARED_CTRL_REG,
2905 FH_MEM_RSSR_RX_STATUS_REG,
2906 FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV,
2907 FH_TSSR_TX_STATUS_REG,
2908 FH_TSSR_TX_ERROR_REG
2910 #ifdef CONFIG_IWLWIFI_DEBUG
2912 bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40;
2913 *buf = kmalloc(bufsz, GFP_KERNEL);
2916 pos += scnprintf(*buf + pos, bufsz - pos,
2917 "FH register values:\n");
2918 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) {
2919 pos += scnprintf(*buf + pos, bufsz - pos,
2921 get_fh_string(fh_tbl[i]),
2922 iwl_read_direct32(priv, fh_tbl[i]));
2927 IWL_ERR(priv, "FH register values:\n");
2928 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) {
2929 IWL_ERR(priv, " %34s: 0X%08x\n",
2930 get_fh_string(fh_tbl[i]),
2931 iwl_read_direct32(priv, fh_tbl[i]));
2935 EXPORT_SYMBOL(iwl_dump_fh);
2937 static void iwl_force_rf_reset(struct iwl_priv *priv)
2939 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2942 if (!iwl_is_associated(priv)) {
2943 IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n");
2947 * There is no easy and better way to force reset the radio,
2948 * the only known method is switching channel which will force to
2949 * reset and tune the radio.
2950 * Use internal short scan (single channel) operation to should
2951 * achieve this objective.
2952 * Driver should reset the radio when number of consecutive missed
2953 * beacon, or any other uCode error condition detected.
2955 IWL_DEBUG_INFO(priv, "perform radio reset.\n");
2956 iwl_internal_short_hw_scan(priv);
2961 int iwl_force_reset(struct iwl_priv *priv, int mode)
2963 struct iwl_force_reset *force_reset;
2965 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2968 if (mode >= IWL_MAX_FORCE_RESET) {
2969 IWL_DEBUG_INFO(priv, "invalid reset request.\n");
2972 force_reset = &priv->force_reset[mode];
2973 force_reset->reset_request_count++;
2974 if (force_reset->last_force_reset_jiffies &&
2975 time_after(force_reset->last_force_reset_jiffies +
2976 force_reset->reset_duration, jiffies)) {
2977 IWL_DEBUG_INFO(priv, "force reset rejected\n");
2978 force_reset->reset_reject_count++;
2981 force_reset->reset_success_count++;
2982 force_reset->last_force_reset_jiffies = jiffies;
2983 IWL_DEBUG_INFO(priv, "perform force reset (%d)\n", mode);
2986 iwl_force_rf_reset(priv);
2989 IWL_ERR(priv, "On demand firmware reload\n");
2990 /* Set the FW error flag -- cleared on iwl_down */
2991 set_bit(STATUS_FW_ERROR, &priv->status);
2992 wake_up_interruptible(&priv->wait_command_queue);
2994 * Keep the restart process from trying to send host
2995 * commands by clearing the INIT status bit
2997 clear_bit(STATUS_READY, &priv->status);
2998 queue_work(priv->workqueue, &priv->restart);
3003 EXPORT_SYMBOL(iwl_force_reset);
3006 * iwl_bg_monitor_recover - Timer callback to check for stuck queue and recover
3008 * During normal condition (no queue is stuck), the timer is continually set to
3009 * execute every monitor_recover_period milliseconds after the last timer
3010 * expired. When the queue read_ptr is at the same place, the timer is
3011 * shorten to 100mSecs. This is
3012 * 1) to reduce the chance that the read_ptr may wrap around (not stuck)
3013 * 2) to detect the stuck queues quicker before the station and AP can
3014 * disassociate each other.
3016 * This function monitors all the tx queues and recover from it if any
3017 * of the queues are stuck.
3018 * 1. It first check the cmd queue for stuck conditions. If it is stuck,
3019 * it will recover by resetting the firmware and return.
3020 * 2. Then, it checks for station association. If it associates it will check
3021 * other queues. If any queue is stuck, it will recover by resetting
3023 * Note: It the number of times the queue read_ptr to be at the same place to
3024 * be MAX_REPEAT+1 in order to consider to be stuck.
3027 * The maximum number of times the read pointer of the tx queue at the
3028 * same place without considering to be stuck.
3030 #define MAX_REPEAT (2)
3031 static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt)
3033 struct iwl_tx_queue *txq;
3034 struct iwl_queue *q;
3036 txq = &priv->txq[cnt];
3038 /* queue is empty, skip */
3039 if (q->read_ptr != q->write_ptr) {
3040 if (q->read_ptr == q->last_read_ptr) {
3041 /* a queue has not been read from last time */
3042 if (q->repeat_same_read_ptr > MAX_REPEAT) {
3044 "queue %d stuck %d time. Fw reload.\n",
3045 q->id, q->repeat_same_read_ptr);
3046 q->repeat_same_read_ptr = 0;
3047 iwl_force_reset(priv, IWL_FW_RESET);
3049 q->repeat_same_read_ptr++;
3050 IWL_DEBUG_RADIO(priv,
3051 "queue %d, not read %d time\n",
3053 q->repeat_same_read_ptr);
3054 mod_timer(&priv->monitor_recover, jiffies +
3055 msecs_to_jiffies(IWL_ONE_HUNDRED_MSECS));
3059 q->last_read_ptr = q->read_ptr;
3060 q->repeat_same_read_ptr = 0;
3066 void iwl_bg_monitor_recover(unsigned long data)
3068 struct iwl_priv *priv = (struct iwl_priv *)data;
3071 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3074 /* monitor and check for stuck cmd queue */
3075 if (iwl_check_stuck_queue(priv, IWL_CMD_QUEUE_NUM))
3078 /* monitor and check for other stuck queues */
3079 if (iwl_is_associated(priv)) {
3080 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
3081 /* skip as we already checked the command queue */
3082 if (cnt == IWL_CMD_QUEUE_NUM)
3084 if (iwl_check_stuck_queue(priv, cnt))
3089 * Reschedule the timer to occur in
3090 * priv->cfg->monitor_recover_period
3092 mod_timer(&priv->monitor_recover,
3093 jiffies + msecs_to_jiffies(priv->cfg->monitor_recover_period));
3095 EXPORT_SYMBOL(iwl_bg_monitor_recover);
3099 int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
3101 struct iwl_priv *priv = pci_get_drvdata(pdev);
3104 * This function is called when system goes into suspend state
3105 * mac80211 will call iwl_mac_stop() from the mac80211 suspend function
3106 * first but since iwl_mac_stop() has no knowledge of who the caller is,
3107 * it will not call apm_ops.stop() to stop the DMA operation.
3108 * Calling apm_ops.stop here to make sure we stop the DMA.
3110 priv->cfg->ops->lib->apm_ops.stop(priv);
3112 pci_save_state(pdev);
3113 pci_disable_device(pdev);
3114 pci_set_power_state(pdev, PCI_D3hot);
3118 EXPORT_SYMBOL(iwl_pci_suspend);
3120 int iwl_pci_resume(struct pci_dev *pdev)
3122 struct iwl_priv *priv = pci_get_drvdata(pdev);
3125 pci_set_power_state(pdev, PCI_D0);
3126 ret = pci_enable_device(pdev);
3129 pci_restore_state(pdev);
3130 iwl_enable_interrupts(priv);
3134 EXPORT_SYMBOL(iwl_pci_resume);
3136 #endif /* CONFIG_PM */