Commit | Line | Data |
---|---|---|
df48c323 | 1 | /****************************************************************************** |
df48c323 TW |
2 | * |
3 | * GPL LICENSE SUMMARY | |
4 | * | |
1f447808 | 5 | * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. |
df48c323 TW |
6 | * |
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. | |
10 | * | |
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. | |
15 | * | |
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, | |
19 | * USA | |
20 | * | |
21 | * The full GNU General Public License is included in this distribution | |
22 | * in the file called LICENSE.GPL. | |
23 | * | |
24 | * Contact Information: | |
759ef89f | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
df48c323 TW |
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> | |
8ccde88a | 31 | #include <linux/etherdevice.h> |
d43c36dc | 32 | #include <linux/sched.h> |
5a0e3ad6 | 33 | #include <linux/slab.h> |
1d0a082d | 34 | #include <net/mac80211.h> |
df48c323 | 35 | |
6bc913bd | 36 | #include "iwl-eeprom.h" |
3e0d4cb1 | 37 | #include "iwl-dev.h" /* FIXME: remove */ |
19335774 | 38 | #include "iwl-debug.h" |
df48c323 | 39 | #include "iwl-core.h" |
b661c819 | 40 | #include "iwl-io.h" |
5da4b55f | 41 | #include "iwl-power.h" |
83dde8c9 | 42 | #include "iwl-sta.h" |
ef850d7c | 43 | #include "iwl-helpers.h" |
df48c323 | 44 | |
1d0a082d | 45 | |
df48c323 TW |
46 | MODULE_DESCRIPTION("iwl core"); |
47 | MODULE_VERSION(IWLWIFI_VERSION); | |
a7b75207 | 48 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
712b6cf5 | 49 | MODULE_LICENSE("GPL"); |
df48c323 | 50 | |
06702a73 WYG |
51 | /* |
52 | * set bt_coex_active to true, uCode will do kill/defer | |
53 | * every time the priority line is asserted (BT is sending signals on the | |
54 | * priority line in the PCIx). | |
55 | * set bt_coex_active to false, uCode will ignore the BT activity and | |
56 | * perform the normal operation | |
57 | * | |
58 | * User might experience transmit issue on some platform due to WiFi/BT | |
59 | * co-exist problem. The possible behaviors are: | |
60 | * Able to scan and finding all the available AP | |
61 | * Not able to associate with any AP | |
62 | * On those platforms, WiFi communication can be restored by set | |
63 | * "bt_coex_active" module parameter to "false" | |
64 | * | |
65 | * default: bt_coex_active = true (BT_COEX_ENABLE) | |
66 | */ | |
670245ed JB |
67 | bool bt_coex_active = true; |
68 | EXPORT_SYMBOL_GPL(bt_coex_active); | |
06702a73 | 69 | module_param(bt_coex_active, bool, S_IRUGO); |
6c69d121 | 70 | MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); |
06702a73 | 71 | |
c7de35cd RR |
72 | #define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ |
73 | [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ | |
74 | IWL_RATE_SISO_##s##M_PLCP, \ | |
75 | IWL_RATE_MIMO2_##s##M_PLCP,\ | |
76 | IWL_RATE_MIMO3_##s##M_PLCP,\ | |
77 | IWL_RATE_##r##M_IEEE, \ | |
78 | IWL_RATE_##ip##M_INDEX, \ | |
79 | IWL_RATE_##in##M_INDEX, \ | |
80 | IWL_RATE_##rp##M_INDEX, \ | |
81 | IWL_RATE_##rn##M_INDEX, \ | |
82 | IWL_RATE_##pp##M_INDEX, \ | |
83 | IWL_RATE_##np##M_INDEX } | |
84 | ||
a562a9dd RC |
85 | u32 iwl_debug_level; |
86 | EXPORT_SYMBOL(iwl_debug_level); | |
87 | ||
c7de35cd RR |
88 | /* |
89 | * Parameter order: | |
90 | * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate | |
91 | * | |
92 | * If there isn't a valid next or previous rate then INV is used which | |
93 | * maps to IWL_RATE_INVALID | |
94 | * | |
95 | */ | |
1826dcc0 | 96 | const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT] = { |
c7de35cd RR |
97 | IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ |
98 | IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ | |
99 | IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ | |
100 | IWL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ | |
101 | IWL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ | |
102 | IWL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ | |
103 | IWL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ | |
104 | IWL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ | |
105 | IWL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ | |
106 | IWL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ | |
107 | IWL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ | |
108 | IWL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ | |
109 | IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ | |
110 | /* FIXME:RS: ^^ should be INV (legacy) */ | |
111 | }; | |
1826dcc0 | 112 | EXPORT_SYMBOL(iwl_rates); |
c7de35cd | 113 | |
e7d326ac TW |
114 | int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) |
115 | { | |
116 | int idx = 0; | |
117 | ||
118 | /* HT rate format */ | |
119 | if (rate_n_flags & RATE_MCS_HT_MSK) { | |
120 | idx = (rate_n_flags & 0xff); | |
121 | ||
60d32215 DH |
122 | if (idx >= IWL_RATE_MIMO3_6M_PLCP) |
123 | idx = idx - IWL_RATE_MIMO3_6M_PLCP; | |
124 | else if (idx >= IWL_RATE_MIMO2_6M_PLCP) | |
e7d326ac TW |
125 | idx = idx - IWL_RATE_MIMO2_6M_PLCP; |
126 | ||
127 | idx += IWL_FIRST_OFDM_RATE; | |
128 | /* skip 9M not supported in ht*/ | |
129 | if (idx >= IWL_RATE_9M_INDEX) | |
130 | idx += 1; | |
131 | if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE)) | |
132 | return idx; | |
133 | ||
134 | /* legacy rate format, search for match in table */ | |
135 | } else { | |
136 | for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) | |
137 | if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF)) | |
138 | return idx; | |
139 | } | |
140 | ||
141 | return -1; | |
142 | } | |
143 | EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx); | |
144 | ||
0e1654fa | 145 | u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) |
76eff18b TW |
146 | { |
147 | int i; | |
148 | u8 ind = ant; | |
0e1654fa | 149 | |
bd6e2d57 JB |
150 | if (priv->band == IEEE80211_BAND_2GHZ && |
151 | priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) | |
152 | return 0; | |
153 | ||
76eff18b TW |
154 | for (i = 0; i < RATE_ANT_NUM - 1; i++) { |
155 | ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; | |
0e1654fa | 156 | if (valid & BIT(ind)) |
76eff18b TW |
157 | return ind; |
158 | } | |
159 | return ant; | |
160 | } | |
47ff65c4 | 161 | EXPORT_SYMBOL(iwl_toggle_tx_ant); |
57bd1bea TW |
162 | |
163 | const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | |
164 | EXPORT_SYMBOL(iwl_bcast_addr); | |
165 | ||
166 | ||
1d0a082d AK |
167 | /* This function both allocates and initializes hw and priv. */ |
168 | struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, | |
169 | struct ieee80211_ops *hw_ops) | |
170 | { | |
171 | struct iwl_priv *priv; | |
172 | ||
173 | /* mac80211 allocates memory for this device instance, including | |
174 | * space for this driver's private structure */ | |
175 | struct ieee80211_hw *hw = | |
176 | ieee80211_alloc_hw(sizeof(struct iwl_priv), hw_ops); | |
177 | if (hw == NULL) { | |
c96c31e4 | 178 | pr_err("%s: Can not allocate network device\n", |
a3139c59 | 179 | cfg->name); |
1d0a082d AK |
180 | goto out; |
181 | } | |
182 | ||
183 | priv = hw->priv; | |
184 | priv->hw = hw; | |
185 | ||
186 | out: | |
187 | return hw; | |
188 | } | |
189 | EXPORT_SYMBOL(iwl_alloc_all); | |
190 | ||
14d2aac5 AK |
191 | /* |
192 | * QoS support | |
193 | */ | |
8dfdb9d5 | 194 | static void iwl_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx) |
14d2aac5 AK |
195 | { |
196 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | |
197 | return; | |
198 | ||
763cc3bf JB |
199 | if (!ctx->is_active) |
200 | return; | |
201 | ||
8dfdb9d5 | 202 | ctx->qos_data.def_qos_parm.qos_flags = 0; |
14d2aac5 | 203 | |
8dfdb9d5 JB |
204 | if (ctx->qos_data.qos_active) |
205 | ctx->qos_data.def_qos_parm.qos_flags |= | |
14d2aac5 AK |
206 | QOS_PARAM_FLG_UPDATE_EDCA_MSK; |
207 | ||
7e6a5886 | 208 | if (ctx->ht.enabled) |
8dfdb9d5 | 209 | ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; |
14d2aac5 | 210 | |
e61146e3 | 211 | IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", |
8dfdb9d5 JB |
212 | ctx->qos_data.qos_active, |
213 | ctx->qos_data.def_qos_parm.qos_flags); | |
14d2aac5 | 214 | |
8dfdb9d5 | 215 | iwl_send_cmd_pdu_async(priv, ctx->qos_cmd, |
e61146e3 | 216 | sizeof(struct iwl_qosparam_cmd), |
8dfdb9d5 | 217 | &ctx->qos_data.def_qos_parm, NULL); |
14d2aac5 | 218 | } |
c7de35cd | 219 | |
d9fe60de JB |
220 | #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ |
221 | #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ | |
c7de35cd | 222 | static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, |
d9fe60de | 223 | struct ieee80211_sta_ht_cap *ht_info, |
c7de35cd RR |
224 | enum ieee80211_band band) |
225 | { | |
39130df3 RR |
226 | u16 max_bit_rate = 0; |
227 | u8 rx_chains_num = priv->hw_params.rx_chains_num; | |
228 | u8 tx_chains_num = priv->hw_params.tx_chains_num; | |
229 | ||
c7de35cd | 230 | ht_info->cap = 0; |
d9fe60de | 231 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
c7de35cd | 232 | |
d9fe60de | 233 | ht_info->ht_supported = true; |
c7de35cd | 234 | |
7cb1b088 WYG |
235 | if (priv->cfg->ht_params && |
236 | priv->cfg->ht_params->ht_greenfield_support) | |
b261793d | 237 | ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD; |
d9fe60de | 238 | ht_info->cap |= IEEE80211_HT_CAP_SGI_20; |
39130df3 | 239 | max_bit_rate = MAX_BIT_RATE_20_MHZ; |
7aafef1c | 240 | if (priv->hw_params.ht40_channel & BIT(band)) { |
d9fe60de JB |
241 | ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
242 | ht_info->cap |= IEEE80211_HT_CAP_SGI_40; | |
243 | ht_info->mcs.rx_mask[4] = 0x01; | |
39130df3 | 244 | max_bit_rate = MAX_BIT_RATE_40_MHZ; |
c7de35cd | 245 | } |
c7de35cd RR |
246 | |
247 | if (priv->cfg->mod_params->amsdu_size_8K) | |
d9fe60de | 248 | ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; |
c7de35cd RR |
249 | |
250 | ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; | |
7cb1b088 WYG |
251 | if (priv->cfg->bt_params && priv->cfg->bt_params->ampdu_factor) |
252 | ht_info->ampdu_factor = priv->cfg->bt_params->ampdu_factor; | |
c7de35cd | 253 | ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; |
7cb1b088 WYG |
254 | if (priv->cfg->bt_params && priv->cfg->bt_params->ampdu_density) |
255 | ht_info->ampdu_density = priv->cfg->bt_params->ampdu_density; | |
c7de35cd | 256 | |
d9fe60de | 257 | ht_info->mcs.rx_mask[0] = 0xFF; |
39130df3 | 258 | if (rx_chains_num >= 2) |
d9fe60de | 259 | ht_info->mcs.rx_mask[1] = 0xFF; |
39130df3 | 260 | if (rx_chains_num >= 3) |
d9fe60de | 261 | ht_info->mcs.rx_mask[2] = 0xFF; |
39130df3 RR |
262 | |
263 | /* Highest supported Rx data rate */ | |
264 | max_bit_rate *= rx_chains_num; | |
d9fe60de JB |
265 | WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); |
266 | ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); | |
39130df3 RR |
267 | |
268 | /* Tx MCS capabilities */ | |
d9fe60de | 269 | ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; |
39130df3 | 270 | if (tx_chains_num != rx_chains_num) { |
d9fe60de JB |
271 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; |
272 | ht_info->mcs.tx_params |= ((tx_chains_num - 1) << | |
273 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); | |
39130df3 | 274 | } |
c7de35cd | 275 | } |
c7de35cd | 276 | |
c7de35cd RR |
277 | /** |
278 | * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom | |
279 | */ | |
534166de | 280 | int iwlcore_init_geos(struct iwl_priv *priv) |
c7de35cd RR |
281 | { |
282 | struct iwl_channel_info *ch; | |
283 | struct ieee80211_supported_band *sband; | |
284 | struct ieee80211_channel *channels; | |
285 | struct ieee80211_channel *geo_ch; | |
286 | struct ieee80211_rate *rates; | |
287 | int i = 0; | |
288 | ||
289 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || | |
290 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { | |
e1623446 | 291 | IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); |
c7de35cd RR |
292 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
293 | return 0; | |
294 | } | |
295 | ||
296 | channels = kzalloc(sizeof(struct ieee80211_channel) * | |
297 | priv->channel_count, GFP_KERNEL); | |
298 | if (!channels) | |
299 | return -ENOMEM; | |
300 | ||
5027309b | 301 | rates = kzalloc((sizeof(struct ieee80211_rate) * IWL_RATE_COUNT_LEGACY), |
c7de35cd RR |
302 | GFP_KERNEL); |
303 | if (!rates) { | |
304 | kfree(channels); | |
305 | return -ENOMEM; | |
306 | } | |
307 | ||
308 | /* 5.2GHz channels start after the 2.4GHz channels */ | |
309 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; | |
310 | sband->channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)]; | |
311 | /* just OFDM */ | |
312 | sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; | |
5027309b | 313 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; |
c7de35cd | 314 | |
49779293 | 315 | if (priv->cfg->sku & IWL_SKU_N) |
d9fe60de | 316 | iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, |
49779293 | 317 | IEEE80211_BAND_5GHZ); |
c7de35cd RR |
318 | |
319 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; | |
320 | sband->channels = channels; | |
321 | /* OFDM & CCK */ | |
322 | sband->bitrates = rates; | |
5027309b | 323 | sband->n_bitrates = IWL_RATE_COUNT_LEGACY; |
c7de35cd | 324 | |
49779293 | 325 | if (priv->cfg->sku & IWL_SKU_N) |
d9fe60de | 326 | iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, |
49779293 | 327 | IEEE80211_BAND_2GHZ); |
c7de35cd RR |
328 | |
329 | priv->ieee_channels = channels; | |
330 | priv->ieee_rates = rates; | |
331 | ||
c7de35cd RR |
332 | for (i = 0; i < priv->channel_count; i++) { |
333 | ch = &priv->channel_info[i]; | |
334 | ||
335 | /* FIXME: might be removed if scan is OK */ | |
336 | if (!is_channel_valid(ch)) | |
337 | continue; | |
338 | ||
339 | if (is_channel_a_band(ch)) | |
340 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; | |
341 | else | |
342 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; | |
343 | ||
344 | geo_ch = &sband->channels[sband->n_channels++]; | |
345 | ||
346 | geo_ch->center_freq = | |
347 | ieee80211_channel_to_frequency(ch->channel); | |
348 | geo_ch->max_power = ch->max_power_avg; | |
349 | geo_ch->max_antenna_gain = 0xff; | |
350 | geo_ch->hw_value = ch->channel; | |
351 | ||
352 | if (is_channel_valid(ch)) { | |
353 | if (!(ch->flags & EEPROM_CHANNEL_IBSS)) | |
354 | geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; | |
355 | ||
356 | if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) | |
357 | geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; | |
358 | ||
359 | if (ch->flags & EEPROM_CHANNEL_RADAR) | |
360 | geo_ch->flags |= IEEE80211_CHAN_RADAR; | |
361 | ||
7aafef1c | 362 | geo_ch->flags |= ch->ht40_extension_channel; |
4d38c2e8 | 363 | |
dc1b0973 WYG |
364 | if (ch->max_power_avg > priv->tx_power_device_lmt) |
365 | priv->tx_power_device_lmt = ch->max_power_avg; | |
c7de35cd RR |
366 | } else { |
367 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; | |
368 | } | |
369 | ||
e1623446 | 370 | IWL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", |
c7de35cd RR |
371 | ch->channel, geo_ch->center_freq, |
372 | is_channel_a_band(ch) ? "5.2" : "2.4", | |
373 | geo_ch->flags & IEEE80211_CHAN_DISABLED ? | |
374 | "restricted" : "valid", | |
375 | geo_ch->flags); | |
376 | } | |
377 | ||
378 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && | |
379 | priv->cfg->sku & IWL_SKU_A) { | |
978785a3 TW |
380 | IWL_INFO(priv, "Incorrectly detected BG card as ABG. " |
381 | "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", | |
a3139c59 SO |
382 | priv->pci_dev->device, |
383 | priv->pci_dev->subsystem_device); | |
c7de35cd RR |
384 | priv->cfg->sku &= ~IWL_SKU_A; |
385 | } | |
386 | ||
978785a3 | 387 | IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", |
a3139c59 SO |
388 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, |
389 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | |
c7de35cd RR |
390 | |
391 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | |
392 | ||
393 | return 0; | |
394 | } | |
534166de | 395 | EXPORT_SYMBOL(iwlcore_init_geos); |
c7de35cd RR |
396 | |
397 | /* | |
398 | * iwlcore_free_geos - undo allocations in iwlcore_init_geos | |
399 | */ | |
534166de | 400 | void iwlcore_free_geos(struct iwl_priv *priv) |
c7de35cd RR |
401 | { |
402 | kfree(priv->ieee_channels); | |
403 | kfree(priv->ieee_rates); | |
404 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | |
405 | } | |
534166de | 406 | EXPORT_SYMBOL(iwlcore_free_geos); |
c7de35cd | 407 | |
37dc70fe | 408 | /* |
94597ab2 | 409 | * iwlcore_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this |
37dc70fe AK |
410 | * function. |
411 | */ | |
94597ab2 JB |
412 | void iwlcore_tx_cmd_protection(struct iwl_priv *priv, |
413 | struct ieee80211_tx_info *info, | |
414 | __le16 fc, __le32 *tx_flags) | |
37dc70fe AK |
415 | { |
416 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { | |
417 | *tx_flags |= TX_CMD_FLG_RTS_MSK; | |
418 | *tx_flags &= ~TX_CMD_FLG_CTS_MSK; | |
94597ab2 JB |
419 | *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; |
420 | ||
421 | if (!ieee80211_is_mgmt(fc)) | |
422 | return; | |
423 | ||
424 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { | |
425 | case cpu_to_le16(IEEE80211_STYPE_AUTH): | |
426 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): | |
427 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): | |
428 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): | |
429 | *tx_flags &= ~TX_CMD_FLG_RTS_MSK; | |
430 | *tx_flags |= TX_CMD_FLG_CTS_MSK; | |
431 | break; | |
432 | } | |
37dc70fe AK |
433 | } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { |
434 | *tx_flags &= ~TX_CMD_FLG_RTS_MSK; | |
435 | *tx_flags |= TX_CMD_FLG_CTS_MSK; | |
94597ab2 | 436 | *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; |
37dc70fe AK |
437 | } |
438 | } | |
94597ab2 JB |
439 | EXPORT_SYMBOL(iwlcore_tx_cmd_protection); |
440 | ||
37dc70fe | 441 | |
28a6b07a | 442 | static bool is_single_rx_stream(struct iwl_priv *priv) |
c7de35cd | 443 | { |
ba37a3d0 | 444 | return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC || |
02bb1bea | 445 | priv->current_ht_config.single_chain_sufficient; |
c7de35cd | 446 | } |
963f5517 | 447 | |
7e6a5886 JB |
448 | static bool iwl_is_channel_extension(struct iwl_priv *priv, |
449 | enum ieee80211_band band, | |
450 | u16 channel, u8 extension_chan_offset) | |
47c5196e TW |
451 | { |
452 | const struct iwl_channel_info *ch_info; | |
453 | ||
454 | ch_info = iwl_get_channel_info(priv, band, channel); | |
455 | if (!is_channel_valid(ch_info)) | |
7e6a5886 | 456 | return false; |
47c5196e | 457 | |
d9fe60de | 458 | if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) |
7aafef1c | 459 | return !(ch_info->ht40_extension_channel & |
689da1b3 | 460 | IEEE80211_CHAN_NO_HT40PLUS); |
d9fe60de | 461 | else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) |
7aafef1c | 462 | return !(ch_info->ht40_extension_channel & |
689da1b3 | 463 | IEEE80211_CHAN_NO_HT40MINUS); |
47c5196e | 464 | |
7e6a5886 | 465 | return false; |
47c5196e TW |
466 | } |
467 | ||
7e6a5886 JB |
468 | bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv, |
469 | struct iwl_rxon_context *ctx, | |
470 | struct ieee80211_sta_ht_cap *ht_cap) | |
47c5196e | 471 | { |
7e6a5886 JB |
472 | if (!ctx->ht.enabled || !ctx->ht.is_40mhz) |
473 | return false; | |
47c5196e | 474 | |
7e6a5886 JB |
475 | /* |
476 | * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
a2b0f02e WYG |
477 | * the bit will not set if it is pure 40MHz case |
478 | */ | |
7e6a5886 JB |
479 | if (ht_cap && !ht_cap->ht_supported) |
480 | return false; | |
481 | ||
d73e4923 | 482 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
1e4247d4 | 483 | if (priv->disable_ht40) |
7e6a5886 | 484 | return false; |
1e4247d4 | 485 | #endif |
7e6a5886 | 486 | |
611d3eb7 | 487 | return iwl_is_channel_extension(priv, priv->band, |
246ed355 | 488 | le16_to_cpu(ctx->staging.channel), |
7e6a5886 | 489 | ctx->ht.extension_chan_offset); |
47c5196e | 490 | } |
7aafef1c | 491 | EXPORT_SYMBOL(iwl_is_ht40_tx_allowed); |
47c5196e | 492 | |
2c2f3b33 TW |
493 | static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) |
494 | { | |
ea196fdb JB |
495 | u16 new_val; |
496 | u16 beacon_factor; | |
497 | ||
498 | /* | |
499 | * If mac80211 hasn't given us a beacon interval, program | |
500 | * the default into the device (not checking this here | |
501 | * would cause the adjustment below to return the maximum | |
502 | * value, which may break PAN.) | |
503 | */ | |
504 | if (!beacon_val) | |
505 | return DEFAULT_BEACON_INTERVAL; | |
506 | ||
507 | /* | |
508 | * If the beacon interval we obtained from the peer | |
509 | * is too large, we'll have to wake up more often | |
510 | * (and in IBSS case, we'll beacon too much) | |
511 | * | |
512 | * For example, if max_beacon_val is 4096, and the | |
513 | * requested beacon interval is 7000, we'll have to | |
514 | * use 3500 to be able to wake up on the beacons. | |
515 | * | |
516 | * This could badly influence beacon detection stats. | |
517 | */ | |
2c2f3b33 TW |
518 | |
519 | beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; | |
520 | new_val = beacon_val / beacon_factor; | |
521 | ||
522 | if (!new_val) | |
523 | new_val = max_beacon_val; | |
524 | ||
525 | return new_val; | |
526 | } | |
527 | ||
47313e34 | 528 | int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) |
2c2f3b33 TW |
529 | { |
530 | u64 tsf; | |
531 | s32 interval_tm, rem; | |
2c2f3b33 TW |
532 | struct ieee80211_conf *conf = NULL; |
533 | u16 beacon_int; | |
47313e34 | 534 | struct ieee80211_vif *vif = ctx->vif; |
2c2f3b33 TW |
535 | |
536 | conf = ieee80211_get_hw_conf(priv->hw); | |
537 | ||
948f5a2f JB |
538 | lockdep_assert_held(&priv->mutex); |
539 | ||
246ed355 | 540 | memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); |
948f5a2f | 541 | |
246ed355 JB |
542 | ctx->timing.timestamp = cpu_to_le64(priv->timestamp); |
543 | ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); | |
2c2f3b33 | 544 | |
47313e34 | 545 | beacon_int = vif ? vif->bss_conf.beacon_int : 0; |
2c2f3b33 | 546 | |
47313e34 JB |
547 | /* |
548 | * TODO: For IBSS we need to get atim_window from mac80211, | |
549 | * for now just always use 0 | |
550 | */ | |
551 | ctx->timing.atim_window = 0; | |
2c2f3b33 | 552 | |
bde4530e | 553 | if (ctx->ctxid == IWL_RXON_CTX_PAN && |
f1f270b2 JB |
554 | (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION) && |
555 | iwl_is_associated(priv, IWL_RXON_CTX_BSS) && | |
556 | priv->contexts[IWL_RXON_CTX_BSS].vif && | |
557 | priv->contexts[IWL_RXON_CTX_BSS].vif->bss_conf.beacon_int) { | |
bde4530e JB |
558 | ctx->timing.beacon_interval = |
559 | priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval; | |
560 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); | |
f1f270b2 JB |
561 | } else if (ctx->ctxid == IWL_RXON_CTX_BSS && |
562 | iwl_is_associated(priv, IWL_RXON_CTX_PAN) && | |
563 | priv->contexts[IWL_RXON_CTX_PAN].vif && | |
564 | priv->contexts[IWL_RXON_CTX_PAN].vif->bss_conf.beacon_int && | |
565 | (!iwl_is_associated_ctx(ctx) || !ctx->vif || | |
566 | !ctx->vif->bss_conf.beacon_int)) { | |
567 | ctx->timing.beacon_interval = | |
568 | priv->contexts[IWL_RXON_CTX_PAN].timing.beacon_interval; | |
569 | beacon_int = le16_to_cpu(ctx->timing.beacon_interval); | |
bde4530e JB |
570 | } else { |
571 | beacon_int = iwl_adjust_beacon_interval(beacon_int, | |
f8525e55 | 572 | priv->hw_params.max_beacon_itrvl * TIME_UNIT); |
bde4530e JB |
573 | ctx->timing.beacon_interval = cpu_to_le16(beacon_int); |
574 | } | |
2c2f3b33 TW |
575 | |
576 | tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ | |
f8525e55 | 577 | interval_tm = beacon_int * TIME_UNIT; |
2c2f3b33 | 578 | rem = do_div(tsf, interval_tm); |
246ed355 | 579 | ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); |
2c2f3b33 | 580 | |
47313e34 | 581 | ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; |
2491fa42 | 582 | |
2c2f3b33 TW |
583 | IWL_DEBUG_ASSOC(priv, |
584 | "beacon interval %d beacon timer %d beacon tim %d\n", | |
246ed355 JB |
585 | le16_to_cpu(ctx->timing.beacon_interval), |
586 | le32_to_cpu(ctx->timing.beacon_init_val), | |
587 | le16_to_cpu(ctx->timing.atim_window)); | |
948f5a2f | 588 | |
8f2d3d2a | 589 | return iwl_send_cmd_pdu(priv, ctx->rxon_timing_cmd, |
246ed355 | 590 | sizeof(ctx->timing), &ctx->timing); |
2c2f3b33 | 591 | } |
948f5a2f | 592 | EXPORT_SYMBOL(iwl_send_rxon_timing); |
2c2f3b33 | 593 | |
246ed355 JB |
594 | void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, |
595 | int hw_decrypt) | |
8ccde88a | 596 | { |
246ed355 | 597 | struct iwl_rxon_cmd *rxon = &ctx->staging; |
8ccde88a SO |
598 | |
599 | if (hw_decrypt) | |
600 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; | |
601 | else | |
602 | rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; | |
603 | ||
604 | } | |
605 | EXPORT_SYMBOL(iwl_set_rxon_hwcrypto); | |
606 | ||
607 | /** | |
608 | * iwl_check_rxon_cmd - validate RXON structure is valid | |
609 | * | |
610 | * NOTE: This is really only useful during development and can eventually | |
611 | * be #ifdef'd out once the driver is stable and folks aren't actively | |
612 | * making changes | |
613 | */ | |
246ed355 | 614 | int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx) |
8ccde88a SO |
615 | { |
616 | int error = 0; | |
617 | int counter = 1; | |
246ed355 | 618 | struct iwl_rxon_cmd *rxon = &ctx->staging; |
8ccde88a SO |
619 | |
620 | if (rxon->flags & RXON_FLG_BAND_24G_MSK) { | |
621 | error |= le32_to_cpu(rxon->flags & | |
622 | (RXON_FLG_TGJ_NARROW_BAND_MSK | | |
623 | RXON_FLG_RADAR_DETECT_MSK)); | |
624 | if (error) | |
625 | IWL_WARN(priv, "check 24G fields %d | %d\n", | |
626 | counter++, error); | |
627 | } else { | |
628 | error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ? | |
629 | 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK); | |
630 | if (error) | |
631 | IWL_WARN(priv, "check 52 fields %d | %d\n", | |
632 | counter++, error); | |
633 | error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK); | |
634 | if (error) | |
635 | IWL_WARN(priv, "check 52 CCK %d | %d\n", | |
636 | counter++, error); | |
637 | } | |
638 | error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1; | |
639 | if (error) | |
640 | IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error); | |
641 | ||
642 | /* make sure basic rates 6Mbps and 1Mbps are supported */ | |
643 | error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) && | |
644 | ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0)); | |
645 | if (error) | |
646 | IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error); | |
647 | ||
648 | error |= (le16_to_cpu(rxon->assoc_id) > 2007); | |
649 | if (error) | |
650 | IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error); | |
651 | ||
652 | error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) | |
653 | == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)); | |
654 | if (error) | |
655 | IWL_WARN(priv, "check CCK and short slot %d | %d\n", | |
656 | counter++, error); | |
657 | ||
658 | error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) | |
659 | == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)); | |
660 | if (error) | |
661 | IWL_WARN(priv, "check CCK & auto detect %d | %d\n", | |
662 | counter++, error); | |
663 | ||
664 | error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | | |
665 | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK); | |
666 | if (error) | |
667 | IWL_WARN(priv, "check TGG and auto detect %d | %d\n", | |
668 | counter++, error); | |
669 | ||
670 | if (error) | |
671 | IWL_WARN(priv, "Tuning to channel %d\n", | |
672 | le16_to_cpu(rxon->channel)); | |
673 | ||
674 | if (error) { | |
675 | IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n"); | |
676 | return -1; | |
677 | } | |
678 | return 0; | |
679 | } | |
680 | EXPORT_SYMBOL(iwl_check_rxon_cmd); | |
681 | ||
682 | /** | |
683 | * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed | |
684 | * @priv: staging_rxon is compared to active_rxon | |
685 | * | |
686 | * If the RXON structure is changing enough to require a new tune, | |
687 | * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that | |
688 | * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. | |
689 | */ | |
246ed355 JB |
690 | int iwl_full_rxon_required(struct iwl_priv *priv, |
691 | struct iwl_rxon_context *ctx) | |
8ccde88a | 692 | { |
246ed355 JB |
693 | const struct iwl_rxon_cmd *staging = &ctx->staging; |
694 | const struct iwl_rxon_cmd *active = &ctx->active; | |
695 | ||
696 | #define CHK(cond) \ | |
697 | if ((cond)) { \ | |
698 | IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ | |
699 | return 1; \ | |
700 | } | |
701 | ||
702 | #define CHK_NEQ(c1, c2) \ | |
703 | if ((c1) != (c2)) { \ | |
704 | IWL_DEBUG_INFO(priv, "need full RXON - " \ | |
705 | #c1 " != " #c2 " - %d != %d\n", \ | |
706 | (c1), (c2)); \ | |
707 | return 1; \ | |
708 | } | |
8ccde88a SO |
709 | |
710 | /* These items are only settable from the full RXON command */ | |
246ed355 JB |
711 | CHK(!iwl_is_associated_ctx(ctx)); |
712 | CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); | |
713 | CHK(compare_ether_addr(staging->node_addr, active->node_addr)); | |
714 | CHK(compare_ether_addr(staging->wlap_bssid_addr, | |
715 | active->wlap_bssid_addr)); | |
716 | CHK_NEQ(staging->dev_type, active->dev_type); | |
717 | CHK_NEQ(staging->channel, active->channel); | |
718 | CHK_NEQ(staging->air_propagation, active->air_propagation); | |
719 | CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, | |
720 | active->ofdm_ht_single_stream_basic_rates); | |
721 | CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, | |
722 | active->ofdm_ht_dual_stream_basic_rates); | |
723 | CHK_NEQ(staging->ofdm_ht_triple_stream_basic_rates, | |
724 | active->ofdm_ht_triple_stream_basic_rates); | |
725 | CHK_NEQ(staging->assoc_id, active->assoc_id); | |
8ccde88a SO |
726 | |
727 | /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can | |
728 | * be updated with the RXON_ASSOC command -- however only some | |
729 | * flag transitions are allowed using RXON_ASSOC */ | |
730 | ||
731 | /* Check if we are not switching bands */ | |
246ed355 JB |
732 | CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, |
733 | active->flags & RXON_FLG_BAND_24G_MSK); | |
8ccde88a SO |
734 | |
735 | /* Check if we are switching association toggle */ | |
246ed355 JB |
736 | CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, |
737 | active->filter_flags & RXON_FILTER_ASSOC_MSK); | |
738 | ||
739 | #undef CHK | |
740 | #undef CHK_NEQ | |
8ccde88a SO |
741 | |
742 | return 0; | |
743 | } | |
744 | EXPORT_SYMBOL(iwl_full_rxon_required); | |
745 | ||
76d04815 JB |
746 | u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv, |
747 | struct iwl_rxon_context *ctx) | |
8ccde88a | 748 | { |
4a02886b JB |
749 | /* |
750 | * Assign the lowest rate -- should really get this from | |
751 | * the beacon skb from mac80211. | |
752 | */ | |
246ed355 | 753 | if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) |
8ccde88a SO |
754 | return IWL_RATE_1M_PLCP; |
755 | else | |
756 | return IWL_RATE_6M_PLCP; | |
757 | } | |
758 | EXPORT_SYMBOL(iwl_rate_get_lowest_plcp); | |
759 | ||
246ed355 JB |
760 | static void _iwl_set_rxon_ht(struct iwl_priv *priv, |
761 | struct iwl_ht_config *ht_conf, | |
762 | struct iwl_rxon_context *ctx) | |
47c5196e | 763 | { |
246ed355 | 764 | struct iwl_rxon_cmd *rxon = &ctx->staging; |
47c5196e | 765 | |
7e6a5886 | 766 | if (!ctx->ht.enabled) { |
a2b0f02e | 767 | rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | |
42eb7c64 | 768 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | |
7aafef1c | 769 | RXON_FLG_HT40_PROT_MSK | |
42eb7c64 | 770 | RXON_FLG_HT_PROT_MSK); |
47c5196e | 771 | return; |
42eb7c64 | 772 | } |
47c5196e | 773 | |
7e6a5886 | 774 | /* FIXME: if the definition of ht.protection changed, the "translation" |
a2b0f02e WYG |
775 | * will be needed for rxon->flags |
776 | */ | |
7e6a5886 | 777 | rxon->flags |= cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); |
a2b0f02e WYG |
778 | |
779 | /* Set up channel bandwidth: | |
7aafef1c | 780 | * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ |
a2b0f02e WYG |
781 | /* clear the HT channel mode before set the mode */ |
782 | rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | | |
783 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); | |
7e6a5886 | 784 | if (iwl_is_ht40_tx_allowed(priv, ctx, NULL)) { |
7aafef1c | 785 | /* pure ht40 */ |
7e6a5886 | 786 | if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { |
a2b0f02e | 787 | rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; |
508b08e7 | 788 | /* Note: control channel is opposite of extension channel */ |
7e6a5886 | 789 | switch (ctx->ht.extension_chan_offset) { |
508b08e7 WYG |
790 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
791 | rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; | |
792 | break; | |
793 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | |
794 | rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; | |
795 | break; | |
796 | } | |
797 | } else { | |
a2b0f02e | 798 | /* Note: control channel is opposite of extension channel */ |
7e6a5886 | 799 | switch (ctx->ht.extension_chan_offset) { |
a2b0f02e WYG |
800 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
801 | rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); | |
802 | rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; | |
803 | break; | |
804 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | |
805 | rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; | |
806 | rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; | |
807 | break; | |
808 | case IEEE80211_HT_PARAM_CHA_SEC_NONE: | |
809 | default: | |
810 | /* channel location only valid if in Mixed mode */ | |
811 | IWL_ERR(priv, "invalid extension channel offset\n"); | |
812 | break; | |
813 | } | |
814 | } | |
815 | } else { | |
816 | rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; | |
47c5196e TW |
817 | } |
818 | ||
45823531 | 819 | if (priv->cfg->ops->hcmd->set_rxon_chain) |
246ed355 | 820 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
47c5196e | 821 | |
02bb1bea | 822 | IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " |
ae5eb026 | 823 | "extension channel offset 0x%x\n", |
7e6a5886 JB |
824 | le32_to_cpu(rxon->flags), ctx->ht.protection, |
825 | ctx->ht.extension_chan_offset); | |
47c5196e | 826 | } |
246ed355 JB |
827 | |
828 | void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf) | |
829 | { | |
830 | struct iwl_rxon_context *ctx; | |
831 | ||
832 | for_each_context(priv, ctx) | |
833 | _iwl_set_rxon_ht(priv, ht_conf, ctx); | |
834 | } | |
47c5196e TW |
835 | EXPORT_SYMBOL(iwl_set_rxon_ht); |
836 | ||
9e5e6c32 TW |
837 | #define IWL_NUM_RX_CHAINS_MULTIPLE 3 |
838 | #define IWL_NUM_RX_CHAINS_SINGLE 2 | |
839 | #define IWL_NUM_IDLE_CHAINS_DUAL 2 | |
840 | #define IWL_NUM_IDLE_CHAINS_SINGLE 1 | |
841 | ||
2b396a12 JB |
842 | /* |
843 | * Determine how many receiver/antenna chains to use. | |
844 | * | |
845 | * More provides better reception via diversity. Fewer saves power | |
846 | * at the expense of throughput, but only when not in powersave to | |
847 | * start with. | |
848 | * | |
c7de35cd RR |
849 | * MIMO (dual stream) requires at least 2, but works better with 3. |
850 | * This does not determine *which* chains to use, just how many. | |
851 | */ | |
28a6b07a | 852 | static int iwl_get_active_rx_chain_count(struct iwl_priv *priv) |
c7de35cd | 853 | { |
7cb1b088 WYG |
854 | if (priv->cfg->bt_params && |
855 | priv->cfg->bt_params->advanced_bt_coexist && | |
856 | (priv->bt_full_concurrent || | |
857 | priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) { | |
da5dbb97 WYG |
858 | /* |
859 | * only use chain 'A' in bt high traffic load or | |
860 | * full concurrency mode | |
861 | */ | |
bee008b7 WYG |
862 | return IWL_NUM_RX_CHAINS_SINGLE; |
863 | } | |
c7de35cd | 864 | /* # of Rx chains to use when expecting MIMO. */ |
02bb1bea | 865 | if (is_single_rx_stream(priv)) |
9e5e6c32 | 866 | return IWL_NUM_RX_CHAINS_SINGLE; |
c7de35cd | 867 | else |
9e5e6c32 | 868 | return IWL_NUM_RX_CHAINS_MULTIPLE; |
28a6b07a | 869 | } |
c7de35cd | 870 | |
2b396a12 | 871 | /* |
3f3e0376 WYG |
872 | * When we are in power saving mode, unless device support spatial |
873 | * multiplexing power save, use the active count for rx chain count. | |
2b396a12 | 874 | */ |
28a6b07a TW |
875 | static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) |
876 | { | |
ba37a3d0 JB |
877 | /* # Rx chains when idling, depending on SMPS mode */ |
878 | switch (priv->current_ht_config.smps) { | |
879 | case IEEE80211_SMPS_STATIC: | |
880 | case IEEE80211_SMPS_DYNAMIC: | |
881 | return IWL_NUM_IDLE_CHAINS_SINGLE; | |
882 | case IEEE80211_SMPS_OFF: | |
883 | return active_cnt; | |
c15d20c1 | 884 | default: |
ba37a3d0 JB |
885 | WARN(1, "invalid SMPS mode %d", |
886 | priv->current_ht_config.smps); | |
887 | return active_cnt; | |
3f3e0376 | 888 | } |
c7de35cd RR |
889 | } |
890 | ||
04816448 GE |
891 | /* up to 4 chains */ |
892 | static u8 iwl_count_chain_bitmap(u32 chain_bitmap) | |
893 | { | |
894 | u8 res; | |
895 | res = (chain_bitmap & BIT(0)) >> 0; | |
896 | res += (chain_bitmap & BIT(1)) >> 1; | |
897 | res += (chain_bitmap & BIT(2)) >> 2; | |
9bddbab3 | 898 | res += (chain_bitmap & BIT(3)) >> 3; |
04816448 GE |
899 | return res; |
900 | } | |
901 | ||
c7de35cd RR |
902 | /** |
903 | * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image | |
904 | * | |
905 | * Selects how many and which Rx receivers/antennas/chains to use. | |
906 | * This should not be used for scan command ... it puts data in wrong place. | |
907 | */ | |
246ed355 | 908 | void iwl_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) |
c7de35cd | 909 | { |
28a6b07a TW |
910 | bool is_single = is_single_rx_stream(priv); |
911 | bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); | |
04816448 GE |
912 | u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; |
913 | u32 active_chains; | |
28a6b07a | 914 | u16 rx_chain; |
c7de35cd RR |
915 | |
916 | /* Tell uCode which antennas are actually connected. | |
917 | * Before first association, we assume all antennas are connected. | |
918 | * Just after first association, iwl_chain_noise_calibration() | |
919 | * checks which antennas actually *are* connected. */ | |
bee008b7 | 920 | if (priv->chain_noise_data.active_chains) |
04816448 GE |
921 | active_chains = priv->chain_noise_data.active_chains; |
922 | else | |
923 | active_chains = priv->hw_params.valid_rx_ant; | |
924 | ||
7cb1b088 WYG |
925 | if (priv->cfg->bt_params && |
926 | priv->cfg->bt_params->advanced_bt_coexist && | |
927 | (priv->bt_full_concurrent || | |
928 | priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) { | |
da5dbb97 WYG |
929 | /* |
930 | * only use chain 'A' in bt high traffic load or | |
931 | * full concurrency mode | |
932 | */ | |
bee008b7 WYG |
933 | active_chains = first_antenna(active_chains); |
934 | } | |
935 | ||
04816448 | 936 | rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; |
c7de35cd RR |
937 | |
938 | /* How many receivers should we use? */ | |
28a6b07a TW |
939 | active_rx_cnt = iwl_get_active_rx_chain_count(priv); |
940 | idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt); | |
941 | ||
28a6b07a | 942 | |
04816448 GE |
943 | /* correct rx chain count according hw settings |
944 | * and chain noise calibration | |
945 | */ | |
946 | valid_rx_cnt = iwl_count_chain_bitmap(active_chains); | |
947 | if (valid_rx_cnt < active_rx_cnt) | |
948 | active_rx_cnt = valid_rx_cnt; | |
949 | ||
950 | if (valid_rx_cnt < idle_rx_cnt) | |
951 | idle_rx_cnt = valid_rx_cnt; | |
28a6b07a TW |
952 | |
953 | rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; | |
954 | rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; | |
955 | ||
246ed355 | 956 | ctx->staging.rx_chain = cpu_to_le16(rx_chain); |
28a6b07a | 957 | |
9e5e6c32 | 958 | if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam) |
246ed355 | 959 | ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; |
c7de35cd | 960 | else |
246ed355 | 961 | ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; |
c7de35cd | 962 | |
e1623446 | 963 | IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", |
246ed355 | 964 | ctx->staging.rx_chain, |
28a6b07a TW |
965 | active_rx_cnt, idle_rx_cnt); |
966 | ||
967 | WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || | |
968 | active_rx_cnt < idle_rx_cnt); | |
c7de35cd RR |
969 | } |
970 | EXPORT_SYMBOL(iwl_set_rxon_chain); | |
bf85ea4f | 971 | |
246ed355 | 972 | /* Return valid, unused, channel for a passive scan to reset the RF */ |
14023641 | 973 | u8 iwl_get_single_channel_number(struct iwl_priv *priv, |
246ed355 | 974 | enum ieee80211_band band) |
14023641 AK |
975 | { |
976 | const struct iwl_channel_info *ch_info; | |
977 | int i; | |
978 | u8 channel = 0; | |
246ed355 JB |
979 | u8 min, max; |
980 | struct iwl_rxon_context *ctx; | |
14023641 | 981 | |
14023641 | 982 | if (band == IEEE80211_BAND_5GHZ) { |
246ed355 JB |
983 | min = 14; |
984 | max = priv->channel_count; | |
14023641 | 985 | } else { |
246ed355 JB |
986 | min = 0; |
987 | max = 14; | |
988 | } | |
989 | ||
990 | for (i = min; i < max; i++) { | |
991 | bool busy = false; | |
992 | ||
993 | for_each_context(priv, ctx) { | |
994 | busy = priv->channel_info[i].channel == | |
995 | le16_to_cpu(ctx->staging.channel); | |
996 | if (busy) | |
997 | break; | |
14023641 | 998 | } |
246ed355 JB |
999 | |
1000 | if (busy) | |
1001 | continue; | |
1002 | ||
1003 | channel = priv->channel_info[i].channel; | |
1004 | ch_info = iwl_get_channel_info(priv, band, channel); | |
1005 | if (is_channel_valid(ch_info)) | |
1006 | break; | |
14023641 AK |
1007 | } |
1008 | ||
1009 | return channel; | |
1010 | } | |
1011 | EXPORT_SYMBOL(iwl_get_single_channel_number); | |
1012 | ||
bf85ea4f | 1013 | /** |
3edb5fd6 SZ |
1014 | * iwl_set_rxon_channel - Set the band and channel values in staging RXON |
1015 | * @ch: requested channel as a pointer to struct ieee80211_channel | |
bf85ea4f | 1016 | |
bf85ea4f | 1017 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields |
3edb5fd6 | 1018 | * in the staging RXON flag structure based on the ch->band |
bf85ea4f | 1019 | */ |
246ed355 JB |
1020 | int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, |
1021 | struct iwl_rxon_context *ctx) | |
bf85ea4f | 1022 | { |
17e72782 | 1023 | enum ieee80211_band band = ch->band; |
81e95430 | 1024 | u16 channel = ch->hw_value; |
17e72782 | 1025 | |
246ed355 | 1026 | if ((le16_to_cpu(ctx->staging.channel) == channel) && |
bf85ea4f AK |
1027 | (priv->band == band)) |
1028 | return 0; | |
1029 | ||
246ed355 | 1030 | ctx->staging.channel = cpu_to_le16(channel); |
bf85ea4f | 1031 | if (band == IEEE80211_BAND_5GHZ) |
246ed355 | 1032 | ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; |
bf85ea4f | 1033 | else |
246ed355 | 1034 | ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; |
bf85ea4f AK |
1035 | |
1036 | priv->band = band; | |
1037 | ||
e1623446 | 1038 | IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); |
bf85ea4f AK |
1039 | |
1040 | return 0; | |
1041 | } | |
c7de35cd | 1042 | EXPORT_SYMBOL(iwl_set_rxon_channel); |
bf85ea4f | 1043 | |
79d07325 | 1044 | void iwl_set_flags_for_band(struct iwl_priv *priv, |
246ed355 | 1045 | struct iwl_rxon_context *ctx, |
79d07325 WYG |
1046 | enum ieee80211_band band, |
1047 | struct ieee80211_vif *vif) | |
8ccde88a SO |
1048 | { |
1049 | if (band == IEEE80211_BAND_5GHZ) { | |
246ed355 | 1050 | ctx->staging.flags &= |
8ccde88a SO |
1051 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK |
1052 | | RXON_FLG_CCK_MSK); | |
246ed355 | 1053 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
8ccde88a SO |
1054 | } else { |
1055 | /* Copied from iwl_post_associate() */ | |
c213d745 | 1056 | if (vif && vif->bss_conf.use_short_slot) |
246ed355 | 1057 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
8ccde88a | 1058 | else |
246ed355 | 1059 | ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; |
8ccde88a | 1060 | |
246ed355 JB |
1061 | ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; |
1062 | ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; | |
1063 | ctx->staging.flags &= ~RXON_FLG_CCK_MSK; | |
8ccde88a SO |
1064 | } |
1065 | } | |
79d07325 | 1066 | EXPORT_SYMBOL(iwl_set_flags_for_band); |
8ccde88a SO |
1067 | |
1068 | /* | |
1069 | * initialize rxon structure with default values from eeprom | |
1070 | */ | |
1dda6d28 | 1071 | void iwl_connection_init_rx_config(struct iwl_priv *priv, |
d0fe478c | 1072 | struct iwl_rxon_context *ctx) |
8ccde88a SO |
1073 | { |
1074 | const struct iwl_channel_info *ch_info; | |
1075 | ||
246ed355 | 1076 | memset(&ctx->staging, 0, sizeof(ctx->staging)); |
8ccde88a | 1077 | |
d0fe478c JB |
1078 | if (!ctx->vif) { |
1079 | ctx->staging.dev_type = ctx->unused_devtype; | |
1080 | } else switch (ctx->vif->type) { | |
8ccde88a | 1081 | case NL80211_IFTYPE_AP: |
d0fe478c | 1082 | ctx->staging.dev_type = ctx->ap_devtype; |
8ccde88a SO |
1083 | break; |
1084 | ||
1085 | case NL80211_IFTYPE_STATION: | |
d0fe478c | 1086 | ctx->staging.dev_type = ctx->station_devtype; |
246ed355 | 1087 | ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; |
8ccde88a SO |
1088 | break; |
1089 | ||
1090 | case NL80211_IFTYPE_ADHOC: | |
d0fe478c | 1091 | ctx->staging.dev_type = ctx->ibss_devtype; |
246ed355 JB |
1092 | ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; |
1093 | ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | | |
8ccde88a SO |
1094 | RXON_FILTER_ACCEPT_GRP_MSK; |
1095 | break; | |
1096 | ||
8ccde88a | 1097 | default: |
d0fe478c JB |
1098 | IWL_ERR(priv, "Unsupported interface type %d\n", |
1099 | ctx->vif->type); | |
8ccde88a SO |
1100 | break; |
1101 | } | |
1102 | ||
1103 | #if 0 | |
1104 | /* TODO: Figure out when short_preamble would be set and cache from | |
1105 | * that */ | |
1106 | if (!hw_to_local(priv->hw)->short_preamble) | |
246ed355 | 1107 | ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; |
8ccde88a | 1108 | else |
246ed355 | 1109 | ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
8ccde88a SO |
1110 | #endif |
1111 | ||
1112 | ch_info = iwl_get_channel_info(priv, priv->band, | |
246ed355 | 1113 | le16_to_cpu(ctx->active.channel)); |
8ccde88a SO |
1114 | |
1115 | if (!ch_info) | |
1116 | ch_info = &priv->channel_info[0]; | |
1117 | ||
246ed355 | 1118 | ctx->staging.channel = cpu_to_le16(ch_info->channel); |
8ccde88a SO |
1119 | priv->band = ch_info->band; |
1120 | ||
d0fe478c | 1121 | iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif); |
8ccde88a | 1122 | |
246ed355 | 1123 | ctx->staging.ofdm_basic_rates = |
8ccde88a | 1124 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; |
246ed355 | 1125 | ctx->staging.cck_basic_rates = |
8ccde88a SO |
1126 | (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; |
1127 | ||
a2b0f02e | 1128 | /* clear both MIX and PURE40 mode flag */ |
246ed355 | 1129 | ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | |
a2b0f02e | 1130 | RXON_FLG_CHANNEL_MODE_PURE_40); |
d0fe478c JB |
1131 | if (ctx->vif) |
1132 | memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); | |
7684c408 | 1133 | |
246ed355 JB |
1134 | ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; |
1135 | ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; | |
1136 | ctx->staging.ofdm_ht_triple_stream_basic_rates = 0xff; | |
8ccde88a SO |
1137 | } |
1138 | EXPORT_SYMBOL(iwl_connection_init_rx_config); | |
1139 | ||
79d07325 | 1140 | void iwl_set_rate(struct iwl_priv *priv) |
8ccde88a SO |
1141 | { |
1142 | const struct ieee80211_supported_band *hw = NULL; | |
1143 | struct ieee80211_rate *rate; | |
246ed355 | 1144 | struct iwl_rxon_context *ctx; |
8ccde88a SO |
1145 | int i; |
1146 | ||
1147 | hw = iwl_get_hw_mode(priv, priv->band); | |
1148 | if (!hw) { | |
1149 | IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); | |
1150 | return; | |
1151 | } | |
1152 | ||
1153 | priv->active_rate = 0; | |
8ccde88a SO |
1154 | |
1155 | for (i = 0; i < hw->n_bitrates; i++) { | |
1156 | rate = &(hw->bitrates[i]); | |
5027309b | 1157 | if (rate->hw_value < IWL_RATE_COUNT_LEGACY) |
8ccde88a SO |
1158 | priv->active_rate |= (1 << rate->hw_value); |
1159 | } | |
1160 | ||
4a02886b | 1161 | IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); |
8ccde88a | 1162 | |
246ed355 JB |
1163 | for_each_context(priv, ctx) { |
1164 | ctx->staging.cck_basic_rates = | |
1165 | (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; | |
4a02886b | 1166 | |
246ed355 JB |
1167 | ctx->staging.ofdm_basic_rates = |
1168 | (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; | |
1169 | } | |
8ccde88a | 1170 | } |
79d07325 WYG |
1171 | EXPORT_SYMBOL(iwl_set_rate); |
1172 | ||
1173 | void iwl_chswitch_done(struct iwl_priv *priv, bool is_success) | |
1174 | { | |
8bd413e6 JB |
1175 | /* |
1176 | * MULTI-FIXME | |
1177 | * See iwl_mac_channel_switch. | |
1178 | */ | |
1179 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | |
1180 | ||
79d07325 WYG |
1181 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
1182 | return; | |
1183 | ||
1184 | if (priv->switch_rxon.switch_in_progress) { | |
8bd413e6 | 1185 | ieee80211_chswitch_done(ctx->vif, is_success); |
79d07325 WYG |
1186 | mutex_lock(&priv->mutex); |
1187 | priv->switch_rxon.switch_in_progress = false; | |
1188 | mutex_unlock(&priv->mutex); | |
1189 | } | |
1190 | } | |
1191 | EXPORT_SYMBOL(iwl_chswitch_done); | |
8ccde88a SO |
1192 | |
1193 | void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | |
1194 | { | |
2f301227 | 1195 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
8ccde88a | 1196 | struct iwl_csa_notification *csa = &(pkt->u.csa_notif); |
8bd413e6 JB |
1197 | /* |
1198 | * MULTI-FIXME | |
1199 | * See iwl_mac_channel_switch. | |
1200 | */ | |
246ed355 | 1201 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; |
246ed355 | 1202 | struct iwl_rxon_cmd *rxon = (void *)&ctx->active; |
4a56e965 | 1203 | |
0924e519 WYG |
1204 | if (priv->switch_rxon.switch_in_progress) { |
1205 | if (!le32_to_cpu(csa->status) && | |
1206 | (csa->channel == priv->switch_rxon.channel)) { | |
1207 | rxon->channel = csa->channel; | |
246ed355 | 1208 | ctx->staging.channel = csa->channel; |
0924e519 WYG |
1209 | IWL_DEBUG_11H(priv, "CSA notif: channel %d\n", |
1210 | le16_to_cpu(csa->channel)); | |
79d07325 WYG |
1211 | iwl_chswitch_done(priv, true); |
1212 | } else { | |
0924e519 WYG |
1213 | IWL_ERR(priv, "CSA notif (fail) : channel %d\n", |
1214 | le16_to_cpu(csa->channel)); | |
79d07325 WYG |
1215 | iwl_chswitch_done(priv, false); |
1216 | } | |
0924e519 | 1217 | } |
8ccde88a SO |
1218 | } |
1219 | EXPORT_SYMBOL(iwl_rx_csa); | |
1220 | ||
1221 | #ifdef CONFIG_IWLWIFI_DEBUG | |
246ed355 JB |
1222 | void iwl_print_rx_config_cmd(struct iwl_priv *priv, |
1223 | struct iwl_rxon_context *ctx) | |
8ccde88a | 1224 | { |
246ed355 | 1225 | struct iwl_rxon_cmd *rxon = &ctx->staging; |
8ccde88a | 1226 | |
e1623446 | 1227 | IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); |
3d816c77 | 1228 | iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); |
e1623446 TW |
1229 | IWL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); |
1230 | IWL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); | |
1231 | IWL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", | |
8ccde88a | 1232 | le32_to_cpu(rxon->filter_flags)); |
e1623446 TW |
1233 | IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); |
1234 | IWL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", | |
8ccde88a | 1235 | rxon->ofdm_basic_rates); |
e1623446 TW |
1236 | IWL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); |
1237 | IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); | |
1238 | IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); | |
1239 | IWL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); | |
8ccde88a | 1240 | } |
a643565e | 1241 | EXPORT_SYMBOL(iwl_print_rx_config_cmd); |
6686d17e | 1242 | #endif |
8ccde88a SO |
1243 | /** |
1244 | * iwl_irq_handle_error - called for HW or SW error interrupt from card | |
1245 | */ | |
1246 | void iwl_irq_handle_error(struct iwl_priv *priv) | |
1247 | { | |
1248 | /* Set the FW error flag -- cleared on iwl_down */ | |
1249 | set_bit(STATUS_FW_ERROR, &priv->status); | |
1250 | ||
1251 | /* Cancel currently queued command. */ | |
1252 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | |
1253 | ||
459bc732 SZ |
1254 | IWL_ERR(priv, "Loaded firmware version: %s\n", |
1255 | priv->hw->wiphy->fw_version); | |
1256 | ||
3a3ff72c | 1257 | priv->cfg->ops->lib->dump_nic_error_log(priv); |
696bdee3 WYG |
1258 | if (priv->cfg->ops->lib->dump_csr) |
1259 | priv->cfg->ops->lib->dump_csr(priv); | |
1b3eb823 WYG |
1260 | if (priv->cfg->ops->lib->dump_fh) |
1261 | priv->cfg->ops->lib->dump_fh(priv, NULL, false); | |
b03d7d0f | 1262 | priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false); |
8ccde88a | 1263 | #ifdef CONFIG_IWLWIFI_DEBUG |
c341ddb2 | 1264 | if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) |
246ed355 JB |
1265 | iwl_print_rx_config_cmd(priv, |
1266 | &priv->contexts[IWL_RXON_CTX_BSS]); | |
8ccde88a SO |
1267 | #endif |
1268 | ||
1269 | wake_up_interruptible(&priv->wait_command_queue); | |
1270 | ||
1271 | /* Keep the restart process from trying to send host | |
1272 | * commands by clearing the INIT status bit */ | |
1273 | clear_bit(STATUS_READY, &priv->status); | |
1274 | ||
1275 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { | |
e1623446 | 1276 | IWL_DEBUG(priv, IWL_DL_FW_ERRORS, |
8ccde88a SO |
1277 | "Restarting adapter due to uCode error.\n"); |
1278 | ||
8ccde88a SO |
1279 | if (priv->cfg->mod_params->restart_fw) |
1280 | queue_work(priv->workqueue, &priv->restart); | |
1281 | } | |
1282 | } | |
1283 | EXPORT_SYMBOL(iwl_irq_handle_error); | |
1284 | ||
f8e200de | 1285 | static int iwl_apm_stop_master(struct iwl_priv *priv) |
d68b603c | 1286 | { |
5220af0c | 1287 | int ret = 0; |
d68b603c | 1288 | |
5220af0c | 1289 | /* stop device's busmaster DMA activity */ |
d68b603c AK |
1290 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); |
1291 | ||
5220af0c | 1292 | ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, |
d68b603c | 1293 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); |
5220af0c BC |
1294 | if (ret) |
1295 | IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); | |
d68b603c | 1296 | |
d68b603c AK |
1297 | IWL_DEBUG_INFO(priv, "stop master\n"); |
1298 | ||
5220af0c | 1299 | return ret; |
d68b603c | 1300 | } |
d68b603c AK |
1301 | |
1302 | void iwl_apm_stop(struct iwl_priv *priv) | |
1303 | { | |
fadb3582 BC |
1304 | IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); |
1305 | ||
5220af0c | 1306 | /* Stop device's DMA activity */ |
d68b603c AK |
1307 | iwl_apm_stop_master(priv); |
1308 | ||
5220af0c | 1309 | /* Reset the entire device */ |
d68b603c AK |
1310 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
1311 | ||
1312 | udelay(10); | |
5220af0c BC |
1313 | |
1314 | /* | |
1315 | * Clear "initialization complete" bit to move adapter from | |
1316 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. | |
1317 | */ | |
d68b603c | 1318 | iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
d68b603c AK |
1319 | } |
1320 | EXPORT_SYMBOL(iwl_apm_stop); | |
1321 | ||
fadb3582 BC |
1322 | |
1323 | /* | |
1324 | * Start up NIC's basic functionality after it has been reset | |
1325 | * (e.g. after platform boot, or shutdown via iwl_apm_stop()) | |
1326 | * NOTE: This does not load uCode nor start the embedded processor | |
1327 | */ | |
1328 | int iwl_apm_init(struct iwl_priv *priv) | |
1329 | { | |
1330 | int ret = 0; | |
1331 | u16 lctl; | |
1332 | ||
1333 | IWL_DEBUG_INFO(priv, "Init card's basic functions\n"); | |
1334 | ||
1335 | /* | |
1336 | * Use "set_bit" below rather than "write", to preserve any hardware | |
1337 | * bits already set by default after reset. | |
1338 | */ | |
1339 | ||
1340 | /* Disable L0S exit timer (platform NMI Work/Around) */ | |
1341 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | |
1342 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); | |
1343 | ||
1344 | /* | |
1345 | * Disable L0s without affecting L1; | |
1346 | * don't wait for ICH L0s (ICH bug W/A) | |
1347 | */ | |
1348 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | |
1349 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); | |
1350 | ||
1351 | /* Set FH wait threshold to maximum (HW error during stress W/A) */ | |
1352 | iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); | |
1353 | ||
1354 | /* | |
1355 | * Enable HAP INTA (interrupt from management bus) to | |
1356 | * wake device's PCI Express link L1a -> L0s | |
1357 | * NOTE: This is no-op for 3945 (non-existant bit) | |
1358 | */ | |
1359 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | |
1360 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); | |
1361 | ||
1362 | /* | |
a6c5c731 BC |
1363 | * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. |
1364 | * Check if BIOS (or OS) enabled L1-ASPM on this device. | |
1365 | * If so (likely), disable L0S, so device moves directly L0->L1; | |
1366 | * costs negligible amount of power savings. | |
1367 | * If not (unlikely), enable L0S, so there is at least some | |
1368 | * power savings, even without L1. | |
fadb3582 | 1369 | */ |
7cb1b088 | 1370 | if (priv->cfg->base_params->set_l0s) { |
fadb3582 BC |
1371 | lctl = iwl_pcie_link_ctl(priv); |
1372 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == | |
1373 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { | |
1374 | /* L1-ASPM enabled; disable(!) L0S */ | |
1375 | iwl_set_bit(priv, CSR_GIO_REG, | |
1376 | CSR_GIO_REG_VAL_L0S_ENABLED); | |
1377 | IWL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); | |
1378 | } else { | |
1379 | /* L1-ASPM disabled; enable(!) L0S */ | |
1380 | iwl_clear_bit(priv, CSR_GIO_REG, | |
1381 | CSR_GIO_REG_VAL_L0S_ENABLED); | |
1382 | IWL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); | |
1383 | } | |
1384 | } | |
1385 | ||
1386 | /* Configure analog phase-lock-loop before activating to D0A */ | |
7cb1b088 WYG |
1387 | if (priv->cfg->base_params->pll_cfg_val) |
1388 | iwl_set_bit(priv, CSR_ANA_PLL_CFG, | |
1389 | priv->cfg->base_params->pll_cfg_val); | |
fadb3582 BC |
1390 | |
1391 | /* | |
1392 | * Set "initialization complete" bit to move adapter from | |
1393 | * D0U* --> D0A* (powered-up active) state. | |
1394 | */ | |
1395 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | |
1396 | ||
1397 | /* | |
1398 | * Wait for clock stabilization; once stabilized, access to | |
1399 | * device-internal resources is supported, e.g. iwl_write_prph() | |
1400 | * and accesses to uCode SRAM. | |
1401 | */ | |
1402 | ret = iwl_poll_bit(priv, CSR_GP_CNTRL, | |
1403 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | |
1404 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); | |
1405 | if (ret < 0) { | |
1406 | IWL_DEBUG_INFO(priv, "Failed to init the card\n"); | |
1407 | goto out; | |
1408 | } | |
1409 | ||
1410 | /* | |
1411 | * Enable DMA and BSM (if used) clocks, wait for them to stabilize. | |
1412 | * BSM (Boostrap State Machine) is only in 3945 and 4965; | |
1413 | * later devices (i.e. 5000 and later) have non-volatile SRAM, | |
1414 | * and don't need BSM to restore data after power-saving sleep. | |
1415 | * | |
1416 | * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits | |
1417 | * do not disable clocks. This preserves any hardware bits already | |
1418 | * set by default in "CLK_CTRL_REG" after reset. | |
1419 | */ | |
7cb1b088 | 1420 | if (priv->cfg->base_params->use_bsm) |
fadb3582 BC |
1421 | iwl_write_prph(priv, APMG_CLK_EN_REG, |
1422 | APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); | |
1423 | else | |
1424 | iwl_write_prph(priv, APMG_CLK_EN_REG, | |
1425 | APMG_CLK_VAL_DMA_CLK_RQT); | |
1426 | udelay(20); | |
1427 | ||
1428 | /* Disable L1-Active */ | |
1429 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | |
1430 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | |
1431 | ||
1432 | out: | |
1433 | return ret; | |
1434 | } | |
1435 | EXPORT_SYMBOL(iwl_apm_init); | |
1436 | ||
1437 | ||
630fe9b6 TW |
1438 | int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) |
1439 | { | |
1440 | int ret = 0; | |
5eadd94b WYG |
1441 | s8 prev_tx_power = priv->tx_power_user_lmt; |
1442 | ||
b744cb79 WYG |
1443 | if (tx_power < IWLAGN_TX_POWER_TARGET_POWER_MIN) { |
1444 | IWL_WARN(priv, | |
1445 | "Requested user TXPOWER %d below lower limit %d.\n", | |
daf518de | 1446 | tx_power, |
b744cb79 | 1447 | IWLAGN_TX_POWER_TARGET_POWER_MIN); |
630fe9b6 TW |
1448 | return -EINVAL; |
1449 | } | |
1450 | ||
dc1b0973 | 1451 | if (tx_power > priv->tx_power_device_lmt) { |
08f2d58d WYG |
1452 | IWL_WARN(priv, |
1453 | "Requested user TXPOWER %d above upper limit %d.\n", | |
dc1b0973 | 1454 | tx_power, priv->tx_power_device_lmt); |
630fe9b6 TW |
1455 | return -EINVAL; |
1456 | } | |
1457 | ||
1458 | if (priv->tx_power_user_lmt != tx_power) | |
1459 | force = true; | |
1460 | ||
019fb97d | 1461 | /* if nic is not up don't send command */ |
5eadd94b WYG |
1462 | if (iwl_is_ready_rf(priv)) { |
1463 | priv->tx_power_user_lmt = tx_power; | |
1464 | if (force && priv->cfg->ops->lib->send_tx_power) | |
1465 | ret = priv->cfg->ops->lib->send_tx_power(priv); | |
1466 | else if (!priv->cfg->ops->lib->send_tx_power) | |
1467 | ret = -EOPNOTSUPP; | |
1468 | /* | |
1469 | * if fail to set tx_power, restore the orig. tx power | |
1470 | */ | |
1471 | if (ret) | |
1472 | priv->tx_power_user_lmt = prev_tx_power; | |
1473 | } | |
630fe9b6 | 1474 | |
5eadd94b WYG |
1475 | /* |
1476 | * Even this is an async host command, the command | |
1477 | * will always report success from uCode | |
1478 | * So once driver can placing the command into the queue | |
1479 | * successfully, driver can use priv->tx_power_user_lmt | |
1480 | * to reflect the current tx power | |
1481 | */ | |
630fe9b6 TW |
1482 | return ret; |
1483 | } | |
1484 | EXPORT_SYMBOL(iwl_set_tx_power); | |
1485 | ||
ef850d7c | 1486 | irqreturn_t iwl_isr_legacy(int irq, void *data) |
f17d08a6 AK |
1487 | { |
1488 | struct iwl_priv *priv = data; | |
1489 | u32 inta, inta_mask; | |
1490 | u32 inta_fh; | |
6e8cc38d | 1491 | unsigned long flags; |
f17d08a6 AK |
1492 | if (!priv) |
1493 | return IRQ_NONE; | |
1494 | ||
6e8cc38d | 1495 | spin_lock_irqsave(&priv->lock, flags); |
f17d08a6 AK |
1496 | |
1497 | /* Disable (but don't clear!) interrupts here to avoid | |
1498 | * back-to-back ISRs and sporadic interrupts from our NIC. | |
1499 | * If we have something to service, the tasklet will re-enable ints. | |
1500 | * If we *don't* have something, we'll re-enable before leaving here. */ | |
1501 | inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ | |
1502 | iwl_write32(priv, CSR_INT_MASK, 0x00000000); | |
1503 | ||
1504 | /* Discover which interrupts are active/pending */ | |
1505 | inta = iwl_read32(priv, CSR_INT); | |
1506 | inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); | |
1507 | ||
1508 | /* Ignore interrupt if there's nothing in NIC to service. | |
1509 | * This may be due to IRQ shared with another device, | |
1510 | * or due to sporadic interrupts thrown from our NIC. */ | |
1511 | if (!inta && !inta_fh) { | |
1512 | IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); | |
1513 | goto none; | |
1514 | } | |
1515 | ||
1516 | if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { | |
1517 | /* Hardware disappeared. It might have already raised | |
1518 | * an interrupt */ | |
1519 | IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); | |
1520 | goto unplugged; | |
1521 | } | |
1522 | ||
1523 | IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", | |
1524 | inta, inta_mask, inta_fh); | |
1525 | ||
1526 | inta &= ~CSR_INT_BIT_SCD; | |
1527 | ||
1528 | /* iwl_irq_tasklet() will service interrupts and re-enable them */ | |
1529 | if (likely(inta || inta_fh)) | |
1530 | tasklet_schedule(&priv->irq_tasklet); | |
1531 | ||
1532 | unplugged: | |
6e8cc38d | 1533 | spin_unlock_irqrestore(&priv->lock, flags); |
f17d08a6 AK |
1534 | return IRQ_HANDLED; |
1535 | ||
1536 | none: | |
1537 | /* re-enable interrupts here since we don't have anything to service. */ | |
1538 | /* only Re-enable if diabled by irq */ | |
1539 | if (test_bit(STATUS_INT_ENABLED, &priv->status)) | |
1540 | iwl_enable_interrupts(priv); | |
6e8cc38d | 1541 | spin_unlock_irqrestore(&priv->lock, flags); |
f17d08a6 AK |
1542 | return IRQ_NONE; |
1543 | } | |
ef850d7c | 1544 | EXPORT_SYMBOL(iwl_isr_legacy); |
f17d08a6 | 1545 | |
65b52bde | 1546 | void iwl_send_bt_config(struct iwl_priv *priv) |
17f841cd SO |
1547 | { |
1548 | struct iwl_bt_cmd bt_cmd = { | |
456d0f76 WYG |
1549 | .lead_time = BT_LEAD_TIME_DEF, |
1550 | .max_kill = BT_MAX_KILL_DEF, | |
17f841cd SO |
1551 | .kill_ack_mask = 0, |
1552 | .kill_cts_mask = 0, | |
1553 | }; | |
1554 | ||
06702a73 WYG |
1555 | if (!bt_coex_active) |
1556 | bt_cmd.flags = BT_COEX_DISABLE; | |
1557 | else | |
1558 | bt_cmd.flags = BT_COEX_ENABLE; | |
1559 | ||
1560 | IWL_DEBUG_INFO(priv, "BT coex %s\n", | |
1561 | (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); | |
1562 | ||
65b52bde JB |
1563 | if (iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, |
1564 | sizeof(struct iwl_bt_cmd), &bt_cmd)) | |
1565 | IWL_ERR(priv, "failed to send BT Coex Config\n"); | |
17f841cd SO |
1566 | } |
1567 | EXPORT_SYMBOL(iwl_send_bt_config); | |
1568 | ||
ef8d5529 | 1569 | int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) |
49ea8596 | 1570 | { |
ef8d5529 WYG |
1571 | struct iwl_statistics_cmd statistics_cmd = { |
1572 | .configuration_flags = | |
1573 | clear ? IWL_STATS_CONF_CLEAR_STATS : 0, | |
49ea8596 | 1574 | }; |
ef8d5529 WYG |
1575 | |
1576 | if (flags & CMD_ASYNC) | |
1577 | return iwl_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, | |
1578 | sizeof(struct iwl_statistics_cmd), | |
1579 | &statistics_cmd, NULL); | |
1580 | else | |
1581 | return iwl_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, | |
1582 | sizeof(struct iwl_statistics_cmd), | |
1583 | &statistics_cmd); | |
49ea8596 EG |
1584 | } |
1585 | EXPORT_SYMBOL(iwl_send_statistics_request); | |
7e8c519e | 1586 | |
030f05ed AK |
1587 | void iwl_rx_pm_sleep_notif(struct iwl_priv *priv, |
1588 | struct iwl_rx_mem_buffer *rxb) | |
1589 | { | |
1590 | #ifdef CONFIG_IWLWIFI_DEBUG | |
2f301227 | 1591 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
030f05ed AK |
1592 | struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); |
1593 | IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", | |
1594 | sleep->pm_sleep_mode, sleep->pm_wakeup_src); | |
1595 | #endif | |
1596 | } | |
1597 | EXPORT_SYMBOL(iwl_rx_pm_sleep_notif); | |
1598 | ||
1599 | void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv, | |
1600 | struct iwl_rx_mem_buffer *rxb) | |
1601 | { | |
2f301227 | 1602 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
396887a2 | 1603 | u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; |
030f05ed | 1604 | IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " |
396887a2 DH |
1605 | "notification for %s:\n", len, |
1606 | get_cmd_string(pkt->hdr.cmd)); | |
1607 | iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len); | |
030f05ed AK |
1608 | } |
1609 | EXPORT_SYMBOL(iwl_rx_pm_debug_statistics_notif); | |
261b9c33 AK |
1610 | |
1611 | void iwl_rx_reply_error(struct iwl_priv *priv, | |
1612 | struct iwl_rx_mem_buffer *rxb) | |
1613 | { | |
2f301227 | 1614 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
261b9c33 AK |
1615 | |
1616 | IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " | |
1617 | "seq 0x%04X ser 0x%08X\n", | |
1618 | le32_to_cpu(pkt->u.err_resp.error_type), | |
1619 | get_cmd_string(pkt->u.err_resp.cmd_id), | |
1620 | pkt->u.err_resp.cmd_id, | |
1621 | le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), | |
1622 | le32_to_cpu(pkt->u.err_resp.error_info)); | |
1623 | } | |
1624 | EXPORT_SYMBOL(iwl_rx_reply_error); | |
1625 | ||
a83b9141 WYG |
1626 | void iwl_clear_isr_stats(struct iwl_priv *priv) |
1627 | { | |
1628 | memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); | |
1629 | } | |
a83b9141 | 1630 | |
488829f1 AK |
1631 | int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, |
1632 | const struct ieee80211_tx_queue_params *params) | |
1633 | { | |
1634 | struct iwl_priv *priv = hw->priv; | |
8dfdb9d5 | 1635 | struct iwl_rxon_context *ctx; |
488829f1 AK |
1636 | unsigned long flags; |
1637 | int q; | |
1638 | ||
1639 | IWL_DEBUG_MAC80211(priv, "enter\n"); | |
1640 | ||
1641 | if (!iwl_is_ready_rf(priv)) { | |
1642 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); | |
1643 | return -EIO; | |
1644 | } | |
1645 | ||
1646 | if (queue >= AC_NUM) { | |
1647 | IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); | |
1648 | return 0; | |
1649 | } | |
1650 | ||
1651 | q = AC_NUM - 1 - queue; | |
1652 | ||
1653 | spin_lock_irqsave(&priv->lock, flags); | |
1654 | ||
8dfdb9d5 JB |
1655 | /* |
1656 | * MULTI-FIXME | |
1657 | * This may need to be done per interface in nl80211/cfg80211/mac80211. | |
1658 | */ | |
1659 | for_each_context(priv, ctx) { | |
1660 | ctx->qos_data.def_qos_parm.ac[q].cw_min = | |
1661 | cpu_to_le16(params->cw_min); | |
1662 | ctx->qos_data.def_qos_parm.ac[q].cw_max = | |
1663 | cpu_to_le16(params->cw_max); | |
1664 | ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; | |
1665 | ctx->qos_data.def_qos_parm.ac[q].edca_txop = | |
1666 | cpu_to_le16((params->txop * 32)); | |
1667 | ||
1668 | ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; | |
1669 | } | |
488829f1 AK |
1670 | |
1671 | spin_unlock_irqrestore(&priv->lock, flags); | |
1672 | ||
1673 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
1674 | return 0; | |
1675 | } | |
1676 | EXPORT_SYMBOL(iwl_mac_conf_tx); | |
5bbe233b | 1677 | |
a85d7cca JB |
1678 | int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw) |
1679 | { | |
1680 | struct iwl_priv *priv = hw->priv; | |
1681 | ||
1682 | return priv->ibss_manager == IWL_IBSS_MANAGER; | |
1683 | } | |
1684 | EXPORT_SYMBOL_GPL(iwl_mac_tx_last_beacon); | |
1685 | ||
5bbe233b | 1686 | static void iwl_ht_conf(struct iwl_priv *priv, |
ca3c1f59 | 1687 | struct ieee80211_vif *vif) |
5bbe233b | 1688 | { |
fad95bf5 | 1689 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; |
5bbe233b | 1690 | struct ieee80211_sta *sta; |
ca3c1f59 | 1691 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
7e6a5886 | 1692 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
5bbe233b | 1693 | |
91dd6c27 | 1694 | IWL_DEBUG_MAC80211(priv, "enter:\n"); |
5bbe233b | 1695 | |
7e6a5886 | 1696 | if (!ctx->ht.enabled) |
5bbe233b AK |
1697 | return; |
1698 | ||
7e6a5886 | 1699 | ctx->ht.protection = |
9ed6bcce | 1700 | bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; |
7e6a5886 | 1701 | ctx->ht.non_gf_sta_present = |
9ed6bcce | 1702 | !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); |
5bbe233b | 1703 | |
02bb1bea JB |
1704 | ht_conf->single_chain_sufficient = false; |
1705 | ||
ca3c1f59 | 1706 | switch (vif->type) { |
02bb1bea JB |
1707 | case NL80211_IFTYPE_STATION: |
1708 | rcu_read_lock(); | |
ca3c1f59 | 1709 | sta = ieee80211_find_sta(vif, bss_conf->bssid); |
02bb1bea JB |
1710 | if (sta) { |
1711 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | |
1712 | int maxstreams; | |
1713 | ||
1714 | maxstreams = (ht_cap->mcs.tx_params & | |
1715 | IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) | |
1716 | >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; | |
1717 | maxstreams += 1; | |
1718 | ||
1719 | if ((ht_cap->mcs.rx_mask[1] == 0) && | |
1720 | (ht_cap->mcs.rx_mask[2] == 0)) | |
1721 | ht_conf->single_chain_sufficient = true; | |
1722 | if (maxstreams <= 1) | |
1723 | ht_conf->single_chain_sufficient = true; | |
1724 | } else { | |
1725 | /* | |
1726 | * If at all, this can only happen through a race | |
1727 | * when the AP disconnects us while we're still | |
1728 | * setting up the connection, in that case mac80211 | |
1729 | * will soon tell us about that. | |
1730 | */ | |
1731 | ht_conf->single_chain_sufficient = true; | |
1732 | } | |
1733 | rcu_read_unlock(); | |
1734 | break; | |
1735 | case NL80211_IFTYPE_ADHOC: | |
1736 | ht_conf->single_chain_sufficient = true; | |
1737 | break; | |
1738 | default: | |
1739 | break; | |
1740 | } | |
5bbe233b AK |
1741 | |
1742 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
1743 | } | |
1744 | ||
246ed355 JB |
1745 | static inline void iwl_set_no_assoc(struct iwl_priv *priv, |
1746 | struct ieee80211_vif *vif) | |
c91c3efc | 1747 | { |
246ed355 JB |
1748 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
1749 | ||
c91c3efc AK |
1750 | iwl_led_disassociate(priv); |
1751 | /* | |
1752 | * inform the ucode that there is no longer an | |
1753 | * association and that no more packets should be | |
1754 | * sent | |
1755 | */ | |
246ed355 JB |
1756 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
1757 | ctx->staging.assoc_id = 0; | |
1758 | iwlcore_commit_rxon(priv, ctx); | |
c91c3efc AK |
1759 | } |
1760 | ||
0bc5774f JB |
1761 | static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1762 | { | |
1763 | struct iwl_priv *priv = hw->priv; | |
1764 | unsigned long flags; | |
1765 | __le64 timestamp; | |
1766 | ||
1767 | IWL_DEBUG_MAC80211(priv, "enter\n"); | |
1768 | ||
76d04815 JB |
1769 | lockdep_assert_held(&priv->mutex); |
1770 | ||
1771 | if (!priv->beacon_ctx) { | |
1772 | IWL_ERR(priv, "update beacon but no beacon context!\n"); | |
1773 | dev_kfree_skb(skb); | |
1774 | return -EINVAL; | |
1775 | } | |
1776 | ||
0bc5774f JB |
1777 | if (!iwl_is_ready_rf(priv)) { |
1778 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); | |
1779 | return -EIO; | |
1780 | } | |
1781 | ||
1782 | spin_lock_irqsave(&priv->lock, flags); | |
1783 | ||
1784 | if (priv->ibss_beacon) | |
1785 | dev_kfree_skb(priv->ibss_beacon); | |
1786 | ||
1787 | priv->ibss_beacon = skb; | |
1788 | ||
1789 | timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; | |
1790 | priv->timestamp = le64_to_cpu(timestamp); | |
1791 | ||
1792 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
1793 | spin_unlock_irqrestore(&priv->lock, flags); | |
1794 | ||
76d04815 | 1795 | priv->cfg->ops->lib->post_associate(priv, priv->beacon_ctx->vif); |
0bc5774f JB |
1796 | |
1797 | return 0; | |
1798 | } | |
1799 | ||
5bbe233b | 1800 | void iwl_bss_info_changed(struct ieee80211_hw *hw, |
2d0ddec5 JB |
1801 | struct ieee80211_vif *vif, |
1802 | struct ieee80211_bss_conf *bss_conf, | |
1803 | u32 changes) | |
5bbe233b AK |
1804 | { |
1805 | struct iwl_priv *priv = hw->priv; | |
246ed355 | 1806 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
3a650292 | 1807 | int ret; |
5bbe233b AK |
1808 | |
1809 | IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); | |
1810 | ||
2d0ddec5 JB |
1811 | if (!iwl_is_alive(priv)) |
1812 | return; | |
1813 | ||
1814 | mutex_lock(&priv->mutex); | |
1815 | ||
4ced3f74 JB |
1816 | if (changes & BSS_CHANGED_QOS) { |
1817 | unsigned long flags; | |
1818 | ||
1819 | spin_lock_irqsave(&priv->lock, flags); | |
8dfdb9d5 JB |
1820 | ctx->qos_data.qos_active = bss_conf->qos; |
1821 | iwl_update_qos(priv, ctx); | |
4ced3f74 JB |
1822 | spin_unlock_irqrestore(&priv->lock, flags); |
1823 | } | |
1824 | ||
76d04815 JB |
1825 | if (changes & BSS_CHANGED_BEACON_ENABLED) { |
1826 | /* | |
1827 | * the add_interface code must make sure we only ever | |
1828 | * have a single interface that could be beaconing at | |
1829 | * any time. | |
1830 | */ | |
1831 | if (vif->bss_conf.enable_beacon) | |
1832 | priv->beacon_ctx = ctx; | |
1833 | else | |
1834 | priv->beacon_ctx = NULL; | |
1835 | } | |
1836 | ||
92445c95 | 1837 | if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) { |
2d0ddec5 JB |
1838 | dev_kfree_skb(priv->ibss_beacon); |
1839 | priv->ibss_beacon = ieee80211_beacon_get(hw, vif); | |
1840 | } | |
1841 | ||
2a3aeb44 JB |
1842 | if (changes & BSS_CHANGED_BEACON_INT && vif->type == NL80211_IFTYPE_AP) |
1843 | iwl_send_rxon_timing(priv, ctx); | |
d7129e19 JB |
1844 | |
1845 | if (changes & BSS_CHANGED_BSSID) { | |
1846 | IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); | |
1847 | ||
1848 | /* | |
1849 | * If there is currently a HW scan going on in the | |
1850 | * background then we need to cancel it else the RXON | |
1851 | * below/in post_associate will fail. | |
1852 | */ | |
2d0ddec5 | 1853 | if (iwl_scan_cancel_timeout(priv, 100)) { |
d7129e19 | 1854 | IWL_WARN(priv, "Aborted scan still in progress after 100ms\n"); |
2d0ddec5 JB |
1855 | IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n"); |
1856 | mutex_unlock(&priv->mutex); | |
1857 | return; | |
1858 | } | |
2d0ddec5 | 1859 | |
d7129e19 | 1860 | /* mac80211 only sets assoc when in STATION mode */ |
92445c95 | 1861 | if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { |
246ed355 | 1862 | memcpy(ctx->staging.bssid_addr, |
d7129e19 | 1863 | bss_conf->bssid, ETH_ALEN); |
2d0ddec5 | 1864 | |
d7129e19 JB |
1865 | /* currently needed in a few places */ |
1866 | memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); | |
1867 | } else { | |
246ed355 | 1868 | ctx->staging.filter_flags &= |
d7129e19 | 1869 | ~RXON_FILTER_ASSOC_MSK; |
2d0ddec5 | 1870 | } |
d7129e19 | 1871 | |
2d0ddec5 JB |
1872 | } |
1873 | ||
d7129e19 JB |
1874 | /* |
1875 | * This needs to be after setting the BSSID in case | |
1876 | * mac80211 decides to do both changes at once because | |
1877 | * it will invoke post_associate. | |
1878 | */ | |
92445c95 | 1879 | if (vif->type == NL80211_IFTYPE_ADHOC && |
2d0ddec5 JB |
1880 | changes & BSS_CHANGED_BEACON) { |
1881 | struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); | |
1882 | ||
1883 | if (beacon) | |
1884 | iwl_mac_beacon_update(hw, beacon); | |
1885 | } | |
1886 | ||
5bbe233b AK |
1887 | if (changes & BSS_CHANGED_ERP_PREAMBLE) { |
1888 | IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", | |
1889 | bss_conf->use_short_preamble); | |
1890 | if (bss_conf->use_short_preamble) | |
246ed355 | 1891 | ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
5bbe233b | 1892 | else |
246ed355 | 1893 | ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; |
5bbe233b AK |
1894 | } |
1895 | ||
1896 | if (changes & BSS_CHANGED_ERP_CTS_PROT) { | |
1897 | IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot); | |
1898 | if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) | |
246ed355 | 1899 | ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; |
5bbe233b | 1900 | else |
246ed355 | 1901 | ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; |
94597ab2 | 1902 | if (bss_conf->use_cts_prot) |
246ed355 | 1903 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; |
94597ab2 | 1904 | else |
246ed355 | 1905 | ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; |
5bbe233b AK |
1906 | } |
1907 | ||
d7129e19 JB |
1908 | if (changes & BSS_CHANGED_BASIC_RATES) { |
1909 | /* XXX use this information | |
1910 | * | |
1911 | * To do that, remove code from iwl_set_rate() and put something | |
1912 | * like this here: | |
1913 | * | |
1914 | if (A-band) | |
246ed355 | 1915 | ctx->staging.ofdm_basic_rates = |
d7129e19 JB |
1916 | bss_conf->basic_rates; |
1917 | else | |
246ed355 | 1918 | ctx->staging.ofdm_basic_rates = |
d7129e19 | 1919 | bss_conf->basic_rates >> 4; |
246ed355 | 1920 | ctx->staging.cck_basic_rates = |
d7129e19 JB |
1921 | bss_conf->basic_rates & 0xF; |
1922 | */ | |
1923 | } | |
1924 | ||
5bbe233b | 1925 | if (changes & BSS_CHANGED_HT) { |
ca3c1f59 | 1926 | iwl_ht_conf(priv, vif); |
45823531 AK |
1927 | |
1928 | if (priv->cfg->ops->hcmd->set_rxon_chain) | |
246ed355 | 1929 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
5bbe233b AK |
1930 | } |
1931 | ||
1932 | if (changes & BSS_CHANGED_ASSOC) { | |
1933 | IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); | |
5bbe233b | 1934 | if (bss_conf->assoc) { |
5bbe233b | 1935 | priv->timestamp = bss_conf->timestamp; |
5bbe233b | 1936 | |
e932a609 JB |
1937 | iwl_led_associate(priv); |
1938 | ||
d7129e19 | 1939 | if (!iwl_is_rfkill(priv)) |
1dda6d28 | 1940 | priv->cfg->ops->lib->post_associate(priv, vif); |
c91c3efc | 1941 | } else |
246ed355 | 1942 | iwl_set_no_assoc(priv, vif); |
d7129e19 JB |
1943 | } |
1944 | ||
246ed355 | 1945 | if (changes && iwl_is_associated_ctx(ctx) && bss_conf->aid) { |
d7129e19 JB |
1946 | IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", |
1947 | changes); | |
246ed355 | 1948 | ret = iwl_send_rxon_assoc(priv, ctx); |
d7129e19 JB |
1949 | if (!ret) { |
1950 | /* Sync active_rxon with latest change. */ | |
246ed355 JB |
1951 | memcpy((void *)&ctx->active, |
1952 | &ctx->staging, | |
d7129e19 | 1953 | sizeof(struct iwl_rxon_cmd)); |
5bbe233b | 1954 | } |
5bbe233b | 1955 | } |
d7129e19 | 1956 | |
c91c3efc AK |
1957 | if (changes & BSS_CHANGED_BEACON_ENABLED) { |
1958 | if (vif->bss_conf.enable_beacon) { | |
246ed355 | 1959 | memcpy(ctx->staging.bssid_addr, |
c91c3efc AK |
1960 | bss_conf->bssid, ETH_ALEN); |
1961 | memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); | |
1dda6d28 | 1962 | iwlcore_config_ap(priv, vif); |
c91c3efc | 1963 | } else |
246ed355 | 1964 | iwl_set_no_assoc(priv, vif); |
f513dfff DH |
1965 | } |
1966 | ||
1fa61b2e JB |
1967 | if (changes & BSS_CHANGED_IBSS) { |
1968 | ret = priv->cfg->ops->lib->manage_ibss_station(priv, vif, | |
1969 | bss_conf->ibss_joined); | |
1970 | if (ret) | |
1971 | IWL_ERR(priv, "failed to %s IBSS station %pM\n", | |
1972 | bss_conf->ibss_joined ? "add" : "remove", | |
1973 | bss_conf->bssid); | |
1974 | } | |
1975 | ||
52a02d15 JB |
1976 | if (changes & BSS_CHANGED_IDLE && |
1977 | priv->cfg->ops->hcmd->set_pan_params) { | |
1978 | if (priv->cfg->ops->hcmd->set_pan_params(priv)) | |
1979 | IWL_ERR(priv, "failed to update PAN params\n"); | |
1980 | } | |
1981 | ||
d7129e19 JB |
1982 | mutex_unlock(&priv->mutex); |
1983 | ||
2d0ddec5 | 1984 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
5bbe233b AK |
1985 | } |
1986 | EXPORT_SYMBOL(iwl_bss_info_changed); | |
1987 | ||
b55e75ed | 1988 | static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif) |
727882d6 | 1989 | { |
246ed355 JB |
1990 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
1991 | ||
d0fe478c | 1992 | iwl_connection_init_rx_config(priv, ctx); |
727882d6 AK |
1993 | |
1994 | if (priv->cfg->ops->hcmd->set_rxon_chain) | |
246ed355 | 1995 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
727882d6 | 1996 | |
246ed355 | 1997 | return iwlcore_commit_rxon(priv, ctx); |
727882d6 | 1998 | } |
727882d6 | 1999 | |
b55e75ed | 2000 | int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
cbb6ab94 AK |
2001 | { |
2002 | struct iwl_priv *priv = hw->priv; | |
246ed355 | 2003 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; |
d0fe478c | 2004 | struct iwl_rxon_context *tmp, *ctx = NULL; |
47e28f41 | 2005 | int err = 0; |
cbb6ab94 | 2006 | |
3779db10 JB |
2007 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", |
2008 | vif->type, vif->addr); | |
cbb6ab94 | 2009 | |
47e28f41 JB |
2010 | mutex_lock(&priv->mutex); |
2011 | ||
4bd530f3 SG |
2012 | if (!iwl_is_ready_rf(priv)) { |
2013 | IWL_WARN(priv, "Try to add interface when device not ready\n"); | |
b55e75ed JB |
2014 | err = -EINVAL; |
2015 | goto out; | |
2016 | } | |
2017 | ||
d0fe478c JB |
2018 | for_each_context(priv, tmp) { |
2019 | u32 possible_modes = | |
2020 | tmp->interface_modes | tmp->exclusive_interface_modes; | |
2021 | ||
2022 | if (tmp->vif) { | |
2023 | /* check if this busy context is exclusive */ | |
2024 | if (tmp->exclusive_interface_modes & | |
2025 | BIT(tmp->vif->type)) { | |
2026 | err = -EINVAL; | |
2027 | goto out; | |
2028 | } | |
2029 | continue; | |
2030 | } | |
2031 | ||
2032 | if (!(possible_modes & BIT(vif->type))) | |
2033 | continue; | |
2034 | ||
2035 | /* have maybe usable context w/o interface */ | |
2036 | ctx = tmp; | |
2037 | break; | |
2038 | } | |
2039 | ||
2040 | if (!ctx) { | |
47e28f41 JB |
2041 | err = -EOPNOTSUPP; |
2042 | goto out; | |
cbb6ab94 AK |
2043 | } |
2044 | ||
d0fe478c | 2045 | vif_priv->ctx = ctx; |
8bd413e6 | 2046 | ctx->vif = vif; |
d0fe478c JB |
2047 | /* |
2048 | * This variable will be correct only when there's just | |
2049 | * a single context, but all code using it is for hardware | |
2050 | * that supports only one context. | |
2051 | */ | |
1ed32e4f | 2052 | priv->iw_mode = vif->type; |
cbb6ab94 | 2053 | |
763cc3bf JB |
2054 | ctx->is_active = true; |
2055 | ||
b55e75ed | 2056 | err = iwl_set_mode(priv, vif); |
763cc3bf JB |
2057 | if (err) { |
2058 | if (!ctx->always_active) | |
2059 | ctx->is_active = false; | |
b55e75ed | 2060 | goto out_err; |
763cc3bf | 2061 | } |
7e246191 | 2062 | |
7cb1b088 WYG |
2063 | if (priv->cfg->bt_params && |
2064 | priv->cfg->bt_params->advanced_bt_coexist && | |
59079949 JB |
2065 | vif->type == NL80211_IFTYPE_ADHOC) { |
2066 | /* | |
2067 | * pretend to have high BT traffic as long as we | |
2068 | * are operating in IBSS mode, as this will cause | |
2069 | * the rate scaling etc. to behave as intended. | |
2070 | */ | |
2071 | priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; | |
2072 | } | |
2073 | ||
b55e75ed | 2074 | goto out; |
cbb6ab94 | 2075 | |
b55e75ed | 2076 | out_err: |
8bd413e6 | 2077 | ctx->vif = NULL; |
b55e75ed | 2078 | priv->iw_mode = NL80211_IFTYPE_STATION; |
47e28f41 | 2079 | out: |
cbb6ab94 AK |
2080 | mutex_unlock(&priv->mutex); |
2081 | ||
2082 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
47e28f41 | 2083 | return err; |
cbb6ab94 AK |
2084 | } |
2085 | EXPORT_SYMBOL(iwl_mac_add_interface); | |
2086 | ||
d8052319 | 2087 | void iwl_mac_remove_interface(struct ieee80211_hw *hw, |
b55e75ed | 2088 | struct ieee80211_vif *vif) |
d8052319 AK |
2089 | { |
2090 | struct iwl_priv *priv = hw->priv; | |
246ed355 | 2091 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); |
d8052319 AK |
2092 | |
2093 | IWL_DEBUG_MAC80211(priv, "enter\n"); | |
2094 | ||
2095 | mutex_lock(&priv->mutex); | |
2096 | ||
d0fe478c JB |
2097 | WARN_ON(ctx->vif != vif); |
2098 | ctx->vif = NULL; | |
2099 | ||
e7e16b90 SG |
2100 | if (priv->scan_vif == vif) { |
2101 | iwl_scan_cancel_timeout(priv, 200); | |
2102 | iwl_force_scan_end(priv); | |
2103 | } | |
d0fe478c | 2104 | iwl_set_mode(priv, vif); |
8bd413e6 | 2105 | |
763cc3bf JB |
2106 | if (!ctx->always_active) |
2107 | ctx->is_active = false; | |
2108 | ||
59079949 JB |
2109 | /* |
2110 | * When removing the IBSS interface, overwrite the | |
2111 | * BT traffic load with the stored one from the last | |
2112 | * notification, if any. If this is a device that | |
2113 | * doesn't implement this, this has no effect since | |
2114 | * both values are the same and zero. | |
2115 | */ | |
2116 | if (vif->type == NL80211_IFTYPE_ADHOC) | |
2117 | priv->bt_traffic_load = priv->notif_bt_traffic_load; | |
2118 | ||
8bd413e6 | 2119 | memset(priv->bssid, 0, ETH_ALEN); |
d8052319 AK |
2120 | mutex_unlock(&priv->mutex); |
2121 | ||
2122 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
2123 | ||
2124 | } | |
2125 | EXPORT_SYMBOL(iwl_mac_remove_interface); | |
2126 | ||
4808368d AK |
2127 | /** |
2128 | * iwl_mac_config - mac80211 config callback | |
4808368d AK |
2129 | */ |
2130 | int iwl_mac_config(struct ieee80211_hw *hw, u32 changed) | |
2131 | { | |
2132 | struct iwl_priv *priv = hw->priv; | |
2133 | const struct iwl_channel_info *ch_info; | |
2134 | struct ieee80211_conf *conf = &hw->conf; | |
aa2dc6b5 | 2135 | struct ieee80211_channel *channel = conf->channel; |
fad95bf5 | 2136 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; |
246ed355 | 2137 | struct iwl_rxon_context *ctx; |
4808368d AK |
2138 | unsigned long flags = 0; |
2139 | int ret = 0; | |
2140 | u16 ch; | |
2141 | int scan_active = 0; | |
2142 | ||
2143 | mutex_lock(&priv->mutex); | |
2144 | ||
4808368d | 2145 | IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", |
aa2dc6b5 | 2146 | channel->hw_value, changed); |
4808368d AK |
2147 | |
2148 | if (unlikely(!priv->cfg->mod_params->disable_hw_scan && | |
2149 | test_bit(STATUS_SCANNING, &priv->status))) { | |
2150 | scan_active = 1; | |
2151 | IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); | |
2152 | } | |
2153 | ||
ba37a3d0 JB |
2154 | if (changed & (IEEE80211_CONF_CHANGE_SMPS | |
2155 | IEEE80211_CONF_CHANGE_CHANNEL)) { | |
2156 | /* mac80211 uses static for non-HT which is what we want */ | |
2157 | priv->current_ht_config.smps = conf->smps_mode; | |
2158 | ||
2159 | /* | |
2160 | * Recalculate chain counts. | |
2161 | * | |
2162 | * If monitor mode is enabled then mac80211 will | |
2163 | * set up the SM PS mode to OFF if an HT channel is | |
2164 | * configured. | |
2165 | */ | |
2166 | if (priv->cfg->ops->hcmd->set_rxon_chain) | |
246ed355 JB |
2167 | for_each_context(priv, ctx) |
2168 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); | |
ba37a3d0 | 2169 | } |
4808368d AK |
2170 | |
2171 | /* during scanning mac80211 will delay channel setting until | |
2172 | * scan finish with changed = 0 | |
2173 | */ | |
2174 | if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { | |
2175 | if (scan_active) | |
2176 | goto set_ch_out; | |
2177 | ||
aa2dc6b5 SZ |
2178 | ch = channel->hw_value; |
2179 | ch_info = iwl_get_channel_info(priv, channel->band, ch); | |
4808368d AK |
2180 | if (!is_channel_valid(ch_info)) { |
2181 | IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); | |
2182 | ret = -EINVAL; | |
2183 | goto set_ch_out; | |
2184 | } | |
2185 | ||
4808368d AK |
2186 | spin_lock_irqsave(&priv->lock, flags); |
2187 | ||
246ed355 | 2188 | for_each_context(priv, ctx) { |
7e6a5886 JB |
2189 | /* Configure HT40 channels */ |
2190 | ctx->ht.enabled = conf_is_ht(conf); | |
2191 | if (ctx->ht.enabled) { | |
2192 | if (conf_is_ht40_minus(conf)) { | |
2193 | ctx->ht.extension_chan_offset = | |
2194 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; | |
2195 | ctx->ht.is_40mhz = true; | |
2196 | } else if (conf_is_ht40_plus(conf)) { | |
2197 | ctx->ht.extension_chan_offset = | |
2198 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; | |
2199 | ctx->ht.is_40mhz = true; | |
2200 | } else { | |
2201 | ctx->ht.extension_chan_offset = | |
2202 | IEEE80211_HT_PARAM_CHA_SEC_NONE; | |
2203 | ctx->ht.is_40mhz = false; | |
2204 | } | |
2205 | } else | |
2206 | ctx->ht.is_40mhz = false; | |
2207 | ||
2208 | /* | |
2209 | * Default to no protection. Protection mode will | |
2210 | * later be set from BSS config in iwl_ht_conf | |
2211 | */ | |
2212 | ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; | |
2213 | ||
246ed355 JB |
2214 | /* if we are switching from ht to 2.4 clear flags |
2215 | * from any ht related info since 2.4 does not | |
2216 | * support ht */ | |
2217 | if ((le16_to_cpu(ctx->staging.channel) != ch)) | |
2218 | ctx->staging.flags = 0; | |
4808368d | 2219 | |
246ed355 JB |
2220 | iwl_set_rxon_channel(priv, channel, ctx); |
2221 | iwl_set_rxon_ht(priv, ht_conf); | |
2222 | ||
2223 | iwl_set_flags_for_band(priv, ctx, channel->band, | |
8bd413e6 | 2224 | ctx->vif); |
246ed355 | 2225 | } |
4808368d | 2226 | |
4808368d | 2227 | spin_unlock_irqrestore(&priv->lock, flags); |
79d07325 | 2228 | |
a194e324 JB |
2229 | if (priv->cfg->ops->lib->update_bcast_stations) |
2230 | ret = priv->cfg->ops->lib->update_bcast_stations(priv); | |
278c2f6f | 2231 | |
4808368d AK |
2232 | set_ch_out: |
2233 | /* The list of supported rates and rate mask can be different | |
2234 | * for each band; since the band may have changed, reset | |
2235 | * the rate mask to what mac80211 lists */ | |
2236 | iwl_set_rate(priv); | |
2237 | } | |
2238 | ||
78f5fb7f JB |
2239 | if (changed & (IEEE80211_CONF_CHANGE_PS | |
2240 | IEEE80211_CONF_CHANGE_IDLE)) { | |
e312c24c | 2241 | ret = iwl_power_update_mode(priv, false); |
4808368d | 2242 | if (ret) |
e312c24c | 2243 | IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); |
4808368d AK |
2244 | } |
2245 | ||
2246 | if (changed & IEEE80211_CONF_CHANGE_POWER) { | |
2247 | IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", | |
2248 | priv->tx_power_user_lmt, conf->power_level); | |
2249 | ||
2250 | iwl_set_tx_power(priv, conf->power_level, false); | |
2251 | } | |
2252 | ||
0cf4c01e MA |
2253 | if (!iwl_is_ready(priv)) { |
2254 | IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); | |
2255 | goto out; | |
2256 | } | |
2257 | ||
4808368d AK |
2258 | if (scan_active) |
2259 | goto out; | |
2260 | ||
246ed355 JB |
2261 | for_each_context(priv, ctx) { |
2262 | if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) | |
2263 | iwlcore_commit_rxon(priv, ctx); | |
2264 | else | |
2265 | IWL_DEBUG_INFO(priv, | |
2266 | "Not re-sending same RXON configuration.\n"); | |
2267 | } | |
4808368d AK |
2268 | |
2269 | out: | |
2270 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
2271 | mutex_unlock(&priv->mutex); | |
2272 | return ret; | |
2273 | } | |
2274 | EXPORT_SYMBOL(iwl_mac_config); | |
2275 | ||
bd564261 AK |
2276 | void iwl_mac_reset_tsf(struct ieee80211_hw *hw) |
2277 | { | |
2278 | struct iwl_priv *priv = hw->priv; | |
2279 | unsigned long flags; | |
246ed355 JB |
2280 | /* IBSS can only be the IWL_RXON_CTX_BSS context */ |
2281 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | |
bd564261 AK |
2282 | |
2283 | mutex_lock(&priv->mutex); | |
2284 | IWL_DEBUG_MAC80211(priv, "enter\n"); | |
2285 | ||
2286 | spin_lock_irqsave(&priv->lock, flags); | |
fad95bf5 | 2287 | memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_config)); |
bd564261 AK |
2288 | spin_unlock_irqrestore(&priv->lock, flags); |
2289 | ||
bd564261 | 2290 | spin_lock_irqsave(&priv->lock, flags); |
bd564261 AK |
2291 | |
2292 | /* new association get rid of ibss beacon skb */ | |
2293 | if (priv->ibss_beacon) | |
2294 | dev_kfree_skb(priv->ibss_beacon); | |
2295 | ||
2296 | priv->ibss_beacon = NULL; | |
2297 | ||
bd564261 | 2298 | priv->timestamp = 0; |
bd564261 AK |
2299 | |
2300 | spin_unlock_irqrestore(&priv->lock, flags); | |
2301 | ||
f5354c17 | 2302 | iwl_scan_cancel_timeout(priv, 100); |
bd564261 AK |
2303 | if (!iwl_is_ready_rf(priv)) { |
2304 | IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); | |
2305 | mutex_unlock(&priv->mutex); | |
2306 | return; | |
2307 | } | |
2308 | ||
2309 | /* we are restarting association process | |
2310 | * clear RXON_FILTER_ASSOC_MSK bit | |
2311 | */ | |
246ed355 JB |
2312 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
2313 | iwlcore_commit_rxon(priv, ctx); | |
bd564261 AK |
2314 | |
2315 | iwl_set_rate(priv); | |
2316 | ||
2317 | mutex_unlock(&priv->mutex); | |
2318 | ||
2319 | IWL_DEBUG_MAC80211(priv, "leave\n"); | |
2320 | } | |
2321 | EXPORT_SYMBOL(iwl_mac_reset_tsf); | |
2322 | ||
88804e2b WYG |
2323 | int iwl_alloc_txq_mem(struct iwl_priv *priv) |
2324 | { | |
2325 | if (!priv->txq) | |
2326 | priv->txq = kzalloc( | |
7cb1b088 WYG |
2327 | sizeof(struct iwl_tx_queue) * |
2328 | priv->cfg->base_params->num_of_queues, | |
88804e2b WYG |
2329 | GFP_KERNEL); |
2330 | if (!priv->txq) { | |
91dd6c27 | 2331 | IWL_ERR(priv, "Not enough memory for txq\n"); |
88804e2b WYG |
2332 | return -ENOMEM; |
2333 | } | |
2334 | return 0; | |
2335 | } | |
2336 | EXPORT_SYMBOL(iwl_alloc_txq_mem); | |
2337 | ||
2338 | void iwl_free_txq_mem(struct iwl_priv *priv) | |
2339 | { | |
2340 | kfree(priv->txq); | |
2341 | priv->txq = NULL; | |
2342 | } | |
2343 | EXPORT_SYMBOL(iwl_free_txq_mem); | |
2344 | ||
20594eb0 WYG |
2345 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
2346 | ||
2347 | #define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES) | |
2348 | ||
2349 | void iwl_reset_traffic_log(struct iwl_priv *priv) | |
2350 | { | |
2351 | priv->tx_traffic_idx = 0; | |
2352 | priv->rx_traffic_idx = 0; | |
2353 | if (priv->tx_traffic) | |
2354 | memset(priv->tx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); | |
2355 | if (priv->rx_traffic) | |
2356 | memset(priv->rx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); | |
2357 | } | |
2358 | ||
2359 | int iwl_alloc_traffic_mem(struct iwl_priv *priv) | |
2360 | { | |
2361 | u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; | |
2362 | ||
2363 | if (iwl_debug_level & IWL_DL_TX) { | |
2364 | if (!priv->tx_traffic) { | |
2365 | priv->tx_traffic = | |
2366 | kzalloc(traffic_size, GFP_KERNEL); | |
2367 | if (!priv->tx_traffic) | |
2368 | return -ENOMEM; | |
2369 | } | |
2370 | } | |
2371 | if (iwl_debug_level & IWL_DL_RX) { | |
2372 | if (!priv->rx_traffic) { | |
2373 | priv->rx_traffic = | |
2374 | kzalloc(traffic_size, GFP_KERNEL); | |
2375 | if (!priv->rx_traffic) | |
2376 | return -ENOMEM; | |
2377 | } | |
2378 | } | |
2379 | iwl_reset_traffic_log(priv); | |
2380 | return 0; | |
2381 | } | |
2382 | EXPORT_SYMBOL(iwl_alloc_traffic_mem); | |
2383 | ||
2384 | void iwl_free_traffic_mem(struct iwl_priv *priv) | |
2385 | { | |
2386 | kfree(priv->tx_traffic); | |
2387 | priv->tx_traffic = NULL; | |
2388 | ||
2389 | kfree(priv->rx_traffic); | |
2390 | priv->rx_traffic = NULL; | |
2391 | } | |
2392 | EXPORT_SYMBOL(iwl_free_traffic_mem); | |
2393 | ||
2394 | void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv, | |
2395 | u16 length, struct ieee80211_hdr *header) | |
2396 | { | |
2397 | __le16 fc; | |
2398 | u16 len; | |
2399 | ||
2400 | if (likely(!(iwl_debug_level & IWL_DL_TX))) | |
2401 | return; | |
2402 | ||
2403 | if (!priv->tx_traffic) | |
2404 | return; | |
2405 | ||
2406 | fc = header->frame_control; | |
2407 | if (ieee80211_is_data(fc)) { | |
2408 | len = (length > IWL_TRAFFIC_ENTRY_SIZE) | |
2409 | ? IWL_TRAFFIC_ENTRY_SIZE : length; | |
2410 | memcpy((priv->tx_traffic + | |
2411 | (priv->tx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), | |
2412 | header, len); | |
2413 | priv->tx_traffic_idx = | |
2414 | (priv->tx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; | |
2415 | } | |
2416 | } | |
2417 | EXPORT_SYMBOL(iwl_dbg_log_tx_data_frame); | |
2418 | ||
2419 | void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv, | |
2420 | u16 length, struct ieee80211_hdr *header) | |
2421 | { | |
2422 | __le16 fc; | |
2423 | u16 len; | |
2424 | ||
2425 | if (likely(!(iwl_debug_level & IWL_DL_RX))) | |
2426 | return; | |
2427 | ||
2428 | if (!priv->rx_traffic) | |
2429 | return; | |
2430 | ||
2431 | fc = header->frame_control; | |
2432 | if (ieee80211_is_data(fc)) { | |
2433 | len = (length > IWL_TRAFFIC_ENTRY_SIZE) | |
2434 | ? IWL_TRAFFIC_ENTRY_SIZE : length; | |
2435 | memcpy((priv->rx_traffic + | |
2436 | (priv->rx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), | |
2437 | header, len); | |
2438 | priv->rx_traffic_idx = | |
2439 | (priv->rx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; | |
2440 | } | |
2441 | } | |
2442 | EXPORT_SYMBOL(iwl_dbg_log_rx_data_frame); | |
22fdf3c9 WYG |
2443 | |
2444 | const char *get_mgmt_string(int cmd) | |
2445 | { | |
2446 | switch (cmd) { | |
2447 | IWL_CMD(MANAGEMENT_ASSOC_REQ); | |
2448 | IWL_CMD(MANAGEMENT_ASSOC_RESP); | |
2449 | IWL_CMD(MANAGEMENT_REASSOC_REQ); | |
2450 | IWL_CMD(MANAGEMENT_REASSOC_RESP); | |
2451 | IWL_CMD(MANAGEMENT_PROBE_REQ); | |
2452 | IWL_CMD(MANAGEMENT_PROBE_RESP); | |
2453 | IWL_CMD(MANAGEMENT_BEACON); | |
2454 | IWL_CMD(MANAGEMENT_ATIM); | |
2455 | IWL_CMD(MANAGEMENT_DISASSOC); | |
2456 | IWL_CMD(MANAGEMENT_AUTH); | |
2457 | IWL_CMD(MANAGEMENT_DEAUTH); | |
2458 | IWL_CMD(MANAGEMENT_ACTION); | |
2459 | default: | |
2460 | return "UNKNOWN"; | |
2461 | ||
2462 | } | |
2463 | } | |
2464 | ||
2465 | const char *get_ctrl_string(int cmd) | |
2466 | { | |
2467 | switch (cmd) { | |
2468 | IWL_CMD(CONTROL_BACK_REQ); | |
2469 | IWL_CMD(CONTROL_BACK); | |
2470 | IWL_CMD(CONTROL_PSPOLL); | |
2471 | IWL_CMD(CONTROL_RTS); | |
2472 | IWL_CMD(CONTROL_CTS); | |
2473 | IWL_CMD(CONTROL_ACK); | |
2474 | IWL_CMD(CONTROL_CFEND); | |
2475 | IWL_CMD(CONTROL_CFENDACK); | |
2476 | default: | |
2477 | return "UNKNOWN"; | |
2478 | ||
2479 | } | |
2480 | } | |
2481 | ||
7163b8a4 | 2482 | void iwl_clear_traffic_stats(struct iwl_priv *priv) |
22fdf3c9 WYG |
2483 | { |
2484 | memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); | |
22fdf3c9 | 2485 | memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); |
7163b8a4 | 2486 | priv->led_tpt = 0; |
22fdf3c9 WYG |
2487 | } |
2488 | ||
2489 | /* | |
2490 | * if CONFIG_IWLWIFI_DEBUGFS defined, iwl_update_stats function will | |
2491 | * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass. | |
2492 | * Use debugFs to display the rx/rx_statistics | |
2493 | * if CONFIG_IWLWIFI_DEBUGFS not being defined, then no MGMT and CTRL | |
2494 | * information will be recorded, but DATA pkt still will be recorded | |
2495 | * for the reason of iwl_led.c need to control the led blinking based on | |
2496 | * number of tx and rx data. | |
2497 | * | |
2498 | */ | |
2499 | void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) | |
2500 | { | |
2501 | struct traffic_stats *stats; | |
2502 | ||
2503 | if (is_tx) | |
2504 | stats = &priv->tx_stats; | |
2505 | else | |
2506 | stats = &priv->rx_stats; | |
2507 | ||
2508 | if (ieee80211_is_mgmt(fc)) { | |
2509 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { | |
2510 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): | |
2511 | stats->mgmt[MANAGEMENT_ASSOC_REQ]++; | |
2512 | break; | |
2513 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): | |
2514 | stats->mgmt[MANAGEMENT_ASSOC_RESP]++; | |
2515 | break; | |
2516 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): | |
2517 | stats->mgmt[MANAGEMENT_REASSOC_REQ]++; | |
2518 | break; | |
2519 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): | |
2520 | stats->mgmt[MANAGEMENT_REASSOC_RESP]++; | |
2521 | break; | |
2522 | case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): | |
2523 | stats->mgmt[MANAGEMENT_PROBE_REQ]++; | |
2524 | break; | |
2525 | case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): | |
2526 | stats->mgmt[MANAGEMENT_PROBE_RESP]++; | |
2527 | break; | |
2528 | case cpu_to_le16(IEEE80211_STYPE_BEACON): | |
2529 | stats->mgmt[MANAGEMENT_BEACON]++; | |
2530 | break; | |
2531 | case cpu_to_le16(IEEE80211_STYPE_ATIM): | |
2532 | stats->mgmt[MANAGEMENT_ATIM]++; | |
2533 | break; | |
2534 | case cpu_to_le16(IEEE80211_STYPE_DISASSOC): | |
2535 | stats->mgmt[MANAGEMENT_DISASSOC]++; | |
2536 | break; | |
2537 | case cpu_to_le16(IEEE80211_STYPE_AUTH): | |
2538 | stats->mgmt[MANAGEMENT_AUTH]++; | |
2539 | break; | |
2540 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): | |
2541 | stats->mgmt[MANAGEMENT_DEAUTH]++; | |
2542 | break; | |
2543 | case cpu_to_le16(IEEE80211_STYPE_ACTION): | |
2544 | stats->mgmt[MANAGEMENT_ACTION]++; | |
2545 | break; | |
2546 | } | |
2547 | } else if (ieee80211_is_ctl(fc)) { | |
2548 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { | |
2549 | case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): | |
2550 | stats->ctrl[CONTROL_BACK_REQ]++; | |
2551 | break; | |
2552 | case cpu_to_le16(IEEE80211_STYPE_BACK): | |
2553 | stats->ctrl[CONTROL_BACK]++; | |
2554 | break; | |
2555 | case cpu_to_le16(IEEE80211_STYPE_PSPOLL): | |
2556 | stats->ctrl[CONTROL_PSPOLL]++; | |
2557 | break; | |
2558 | case cpu_to_le16(IEEE80211_STYPE_RTS): | |
2559 | stats->ctrl[CONTROL_RTS]++; | |
2560 | break; | |
2561 | case cpu_to_le16(IEEE80211_STYPE_CTS): | |
2562 | stats->ctrl[CONTROL_CTS]++; | |
2563 | break; | |
2564 | case cpu_to_le16(IEEE80211_STYPE_ACK): | |
2565 | stats->ctrl[CONTROL_ACK]++; | |
2566 | break; | |
2567 | case cpu_to_le16(IEEE80211_STYPE_CFEND): | |
2568 | stats->ctrl[CONTROL_CFEND]++; | |
2569 | break; | |
2570 | case cpu_to_le16(IEEE80211_STYPE_CFENDACK): | |
2571 | stats->ctrl[CONTROL_CFENDACK]++; | |
2572 | break; | |
2573 | } | |
2574 | } else { | |
2575 | /* data */ | |
2576 | stats->data_cnt++; | |
2577 | stats->data_bytes += len; | |
2578 | } | |
d5f4cf71 | 2579 | iwl_leds_background(priv); |
22fdf3c9 WYG |
2580 | } |
2581 | EXPORT_SYMBOL(iwl_update_stats); | |
20594eb0 WYG |
2582 | #endif |
2583 | ||
a0ea9493 | 2584 | static const char *get_csr_string(int cmd) |
696bdee3 WYG |
2585 | { |
2586 | switch (cmd) { | |
2587 | IWL_CMD(CSR_HW_IF_CONFIG_REG); | |
2588 | IWL_CMD(CSR_INT_COALESCING); | |
2589 | IWL_CMD(CSR_INT); | |
2590 | IWL_CMD(CSR_INT_MASK); | |
2591 | IWL_CMD(CSR_FH_INT_STATUS); | |
2592 | IWL_CMD(CSR_GPIO_IN); | |
2593 | IWL_CMD(CSR_RESET); | |
2594 | IWL_CMD(CSR_GP_CNTRL); | |
2595 | IWL_CMD(CSR_HW_REV); | |
2596 | IWL_CMD(CSR_EEPROM_REG); | |
2597 | IWL_CMD(CSR_EEPROM_GP); | |
2598 | IWL_CMD(CSR_OTP_GP_REG); | |
2599 | IWL_CMD(CSR_GIO_REG); | |
2600 | IWL_CMD(CSR_GP_UCODE_REG); | |
2601 | IWL_CMD(CSR_GP_DRIVER_REG); | |
2602 | IWL_CMD(CSR_UCODE_DRV_GP1); | |
2603 | IWL_CMD(CSR_UCODE_DRV_GP2); | |
2604 | IWL_CMD(CSR_LED_REG); | |
2605 | IWL_CMD(CSR_DRAM_INT_TBL_REG); | |
2606 | IWL_CMD(CSR_GIO_CHICKEN_BITS); | |
2607 | IWL_CMD(CSR_ANA_PLL_CFG); | |
2608 | IWL_CMD(CSR_HW_REV_WA_REG); | |
2609 | IWL_CMD(CSR_DBG_HPET_MEM_REG); | |
2610 | default: | |
2611 | return "UNKNOWN"; | |
2612 | ||
2613 | } | |
2614 | } | |
2615 | ||
2616 | void iwl_dump_csr(struct iwl_priv *priv) | |
2617 | { | |
2618 | int i; | |
2619 | u32 csr_tbl[] = { | |
2620 | CSR_HW_IF_CONFIG_REG, | |
2621 | CSR_INT_COALESCING, | |
2622 | CSR_INT, | |
2623 | CSR_INT_MASK, | |
2624 | CSR_FH_INT_STATUS, | |
2625 | CSR_GPIO_IN, | |
2626 | CSR_RESET, | |
2627 | CSR_GP_CNTRL, | |
2628 | CSR_HW_REV, | |
2629 | CSR_EEPROM_REG, | |
2630 | CSR_EEPROM_GP, | |
2631 | CSR_OTP_GP_REG, | |
2632 | CSR_GIO_REG, | |
2633 | CSR_GP_UCODE_REG, | |
2634 | CSR_GP_DRIVER_REG, | |
2635 | CSR_UCODE_DRV_GP1, | |
2636 | CSR_UCODE_DRV_GP2, | |
2637 | CSR_LED_REG, | |
2638 | CSR_DRAM_INT_TBL_REG, | |
2639 | CSR_GIO_CHICKEN_BITS, | |
2640 | CSR_ANA_PLL_CFG, | |
2641 | CSR_HW_REV_WA_REG, | |
2642 | CSR_DBG_HPET_MEM_REG | |
2643 | }; | |
2644 | IWL_ERR(priv, "CSR values:\n"); | |
2645 | IWL_ERR(priv, "(2nd byte of CSR_INT_COALESCING is " | |
2646 | "CSR_INT_PERIODIC_REG)\n"); | |
2647 | for (i = 0; i < ARRAY_SIZE(csr_tbl); i++) { | |
2648 | IWL_ERR(priv, " %25s: 0X%08x\n", | |
2649 | get_csr_string(csr_tbl[i]), | |
2650 | iwl_read32(priv, csr_tbl[i])); | |
2651 | } | |
2652 | } | |
2653 | EXPORT_SYMBOL(iwl_dump_csr); | |
2654 | ||
a0ea9493 | 2655 | static const char *get_fh_string(int cmd) |
1b3eb823 WYG |
2656 | { |
2657 | switch (cmd) { | |
2658 | IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); | |
2659 | IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); | |
2660 | IWL_CMD(FH_RSCSR_CHNL0_WPTR); | |
2661 | IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); | |
2662 | IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); | |
2663 | IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG); | |
2664 | IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); | |
2665 | IWL_CMD(FH_TSSR_TX_STATUS_REG); | |
2666 | IWL_CMD(FH_TSSR_TX_ERROR_REG); | |
2667 | default: | |
2668 | return "UNKNOWN"; | |
2669 | ||
2670 | } | |
2671 | } | |
2672 | ||
2673 | int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display) | |
2674 | { | |
2675 | int i; | |
2676 | #ifdef CONFIG_IWLWIFI_DEBUG | |
2677 | int pos = 0; | |
2678 | size_t bufsz = 0; | |
2679 | #endif | |
2680 | u32 fh_tbl[] = { | |
2681 | FH_RSCSR_CHNL0_STTS_WPTR_REG, | |
2682 | FH_RSCSR_CHNL0_RBDCB_BASE_REG, | |
2683 | FH_RSCSR_CHNL0_WPTR, | |
2684 | FH_MEM_RCSR_CHNL0_CONFIG_REG, | |
2685 | FH_MEM_RSSR_SHARED_CTRL_REG, | |
2686 | FH_MEM_RSSR_RX_STATUS_REG, | |
2687 | FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, | |
2688 | FH_TSSR_TX_STATUS_REG, | |
2689 | FH_TSSR_TX_ERROR_REG | |
2690 | }; | |
2691 | #ifdef CONFIG_IWLWIFI_DEBUG | |
2692 | if (display) { | |
2693 | bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; | |
2694 | *buf = kmalloc(bufsz, GFP_KERNEL); | |
2695 | if (!*buf) | |
2696 | return -ENOMEM; | |
2697 | pos += scnprintf(*buf + pos, bufsz - pos, | |
2698 | "FH register values:\n"); | |
2699 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { | |
2700 | pos += scnprintf(*buf + pos, bufsz - pos, | |
2701 | " %34s: 0X%08x\n", | |
2702 | get_fh_string(fh_tbl[i]), | |
2703 | iwl_read_direct32(priv, fh_tbl[i])); | |
2704 | } | |
2705 | return pos; | |
2706 | } | |
2707 | #endif | |
2708 | IWL_ERR(priv, "FH register values:\n"); | |
2709 | for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { | |
2710 | IWL_ERR(priv, " %34s: 0X%08x\n", | |
2711 | get_fh_string(fh_tbl[i]), | |
2712 | iwl_read_direct32(priv, fh_tbl[i])); | |
2713 | } | |
2714 | return 0; | |
2715 | } | |
2716 | EXPORT_SYMBOL(iwl_dump_fh); | |
2717 | ||
a93e7973 | 2718 | static void iwl_force_rf_reset(struct iwl_priv *priv) |
afbdd69a WYG |
2719 | { |
2720 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | |
2721 | return; | |
2722 | ||
246ed355 | 2723 | if (!iwl_is_any_associated(priv)) { |
afbdd69a WYG |
2724 | IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n"); |
2725 | return; | |
2726 | } | |
2727 | /* | |
2728 | * There is no easy and better way to force reset the radio, | |
2729 | * the only known method is switching channel which will force to | |
2730 | * reset and tune the radio. | |
2731 | * Use internal short scan (single channel) operation to should | |
2732 | * achieve this objective. | |
2733 | * Driver should reset the radio when number of consecutive missed | |
2734 | * beacon, or any other uCode error condition detected. | |
2735 | */ | |
2736 | IWL_DEBUG_INFO(priv, "perform radio reset.\n"); | |
2737 | iwl_internal_short_hw_scan(priv); | |
afbdd69a | 2738 | } |
a93e7973 | 2739 | |
a93e7973 | 2740 | |
c04f9f22 | 2741 | int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) |
a93e7973 | 2742 | { |
8a472da4 WYG |
2743 | struct iwl_force_reset *force_reset; |
2744 | ||
a93e7973 WYG |
2745 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
2746 | return -EINVAL; | |
2747 | ||
7acc7c68 WYG |
2748 | if (test_bit(STATUS_SCANNING, &priv->status)) { |
2749 | IWL_DEBUG_INFO(priv, "scan in progress.\n"); | |
2750 | return -EINVAL; | |
2751 | } | |
2752 | ||
8a472da4 WYG |
2753 | if (mode >= IWL_MAX_FORCE_RESET) { |
2754 | IWL_DEBUG_INFO(priv, "invalid reset request.\n"); | |
2755 | return -EINVAL; | |
2756 | } | |
2757 | force_reset = &priv->force_reset[mode]; | |
2758 | force_reset->reset_request_count++; | |
c04f9f22 WYG |
2759 | if (!external) { |
2760 | if (force_reset->last_force_reset_jiffies && | |
2761 | time_after(force_reset->last_force_reset_jiffies + | |
2762 | force_reset->reset_duration, jiffies)) { | |
2763 | IWL_DEBUG_INFO(priv, "force reset rejected\n"); | |
2764 | force_reset->reset_reject_count++; | |
2765 | return -EAGAIN; | |
2766 | } | |
a93e7973 | 2767 | } |
8a472da4 WYG |
2768 | force_reset->reset_success_count++; |
2769 | force_reset->last_force_reset_jiffies = jiffies; | |
a93e7973 | 2770 | IWL_DEBUG_INFO(priv, "perform force reset (%d)\n", mode); |
a93e7973 WYG |
2771 | switch (mode) { |
2772 | case IWL_RF_RESET: | |
2773 | iwl_force_rf_reset(priv); | |
2774 | break; | |
2775 | case IWL_FW_RESET: | |
c04f9f22 WYG |
2776 | /* |
2777 | * if the request is from external(ex: debugfs), | |
2778 | * then always perform the request in regardless the module | |
2779 | * parameter setting | |
2780 | * if the request is from internal (uCode error or driver | |
2781 | * detect failure), then fw_restart module parameter | |
2782 | * need to be check before performing firmware reload | |
2783 | */ | |
2784 | if (!external && !priv->cfg->mod_params->restart_fw) { | |
2785 | IWL_DEBUG_INFO(priv, "Cancel firmware reload based on " | |
2786 | "module parameter setting\n"); | |
2787 | break; | |
2788 | } | |
a93e7973 WYG |
2789 | IWL_ERR(priv, "On demand firmware reload\n"); |
2790 | /* Set the FW error flag -- cleared on iwl_down */ | |
2791 | set_bit(STATUS_FW_ERROR, &priv->status); | |
2792 | wake_up_interruptible(&priv->wait_command_queue); | |
2793 | /* | |
2794 | * Keep the restart process from trying to send host | |
2795 | * commands by clearing the INIT status bit | |
2796 | */ | |
2797 | clear_bit(STATUS_READY, &priv->status); | |
2798 | queue_work(priv->workqueue, &priv->restart); | |
2799 | break; | |
a93e7973 | 2800 | } |
a93e7973 WYG |
2801 | return 0; |
2802 | } | |
b74e31a9 WYG |
2803 | EXPORT_SYMBOL(iwl_force_reset); |
2804 | ||
2805 | /** | |
2806 | * iwl_bg_monitor_recover - Timer callback to check for stuck queue and recover | |
2807 | * | |
2808 | * During normal condition (no queue is stuck), the timer is continually set to | |
2809 | * execute every monitor_recover_period milliseconds after the last timer | |
2810 | * expired. When the queue read_ptr is at the same place, the timer is | |
2811 | * shorten to 100mSecs. This is | |
2812 | * 1) to reduce the chance that the read_ptr may wrap around (not stuck) | |
2813 | * 2) to detect the stuck queues quicker before the station and AP can | |
2814 | * disassociate each other. | |
2815 | * | |
2816 | * This function monitors all the tx queues and recover from it if any | |
2817 | * of the queues are stuck. | |
2818 | * 1. It first check the cmd queue for stuck conditions. If it is stuck, | |
2819 | * it will recover by resetting the firmware and return. | |
2820 | * 2. Then, it checks for station association. If it associates it will check | |
2821 | * other queues. If any queue is stuck, it will recover by resetting | |
2822 | * the firmware. | |
2823 | * Note: It the number of times the queue read_ptr to be at the same place to | |
2824 | * be MAX_REPEAT+1 in order to consider to be stuck. | |
2825 | */ | |
2826 | /* | |
2827 | * The maximum number of times the read pointer of the tx queue at the | |
2828 | * same place without considering to be stuck. | |
2829 | */ | |
2830 | #define MAX_REPEAT (2) | |
2831 | static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt) | |
2832 | { | |
2833 | struct iwl_tx_queue *txq; | |
2834 | struct iwl_queue *q; | |
2835 | ||
2836 | txq = &priv->txq[cnt]; | |
2837 | q = &txq->q; | |
2838 | /* queue is empty, skip */ | |
7cb1b088 WYG |
2839 | if (q->read_ptr == q->write_ptr) |
2840 | return 0; | |
2841 | ||
2842 | if (q->read_ptr == q->last_read_ptr) { | |
2843 | /* a queue has not been read from last time */ | |
2844 | if (q->repeat_same_read_ptr > MAX_REPEAT) { | |
2845 | IWL_ERR(priv, | |
2846 | "queue %d stuck %d time. Fw reload.\n", | |
2847 | q->id, q->repeat_same_read_ptr); | |
b74e31a9 | 2848 | q->repeat_same_read_ptr = 0; |
7cb1b088 WYG |
2849 | iwl_force_reset(priv, IWL_FW_RESET, false); |
2850 | } else { | |
2851 | q->repeat_same_read_ptr++; | |
2852 | IWL_DEBUG_RADIO(priv, | |
2853 | "queue %d, not read %d time\n", | |
2854 | q->id, | |
2855 | q->repeat_same_read_ptr); | |
2856 | if (priv->cfg->bt_params && | |
2857 | !priv->cfg->bt_params->advanced_bt_coexist) { | |
2858 | mod_timer(&priv->monitor_recover, | |
2859 | jiffies + msecs_to_jiffies( | |
2860 | IWL_ONE_HUNDRED_MSECS)); | |
2861 | return 1; | |
2862 | } | |
b74e31a9 | 2863 | } |
7cb1b088 WYG |
2864 | } else { |
2865 | q->last_read_ptr = q->read_ptr; | |
2866 | q->repeat_same_read_ptr = 0; | |
b74e31a9 WYG |
2867 | } |
2868 | return 0; | |
2869 | } | |
2870 | ||
2871 | void iwl_bg_monitor_recover(unsigned long data) | |
2872 | { | |
2873 | struct iwl_priv *priv = (struct iwl_priv *)data; | |
2874 | int cnt; | |
2875 | ||
2876 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | |
2877 | return; | |
2878 | ||
2879 | /* monitor and check for stuck cmd queue */ | |
13bb9483 | 2880 | if (iwl_check_stuck_queue(priv, priv->cmd_queue)) |
b74e31a9 WYG |
2881 | return; |
2882 | ||
2883 | /* monitor and check for other stuck queues */ | |
246ed355 | 2884 | if (iwl_is_any_associated(priv)) { |
b74e31a9 WYG |
2885 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
2886 | /* skip as we already checked the command queue */ | |
13bb9483 | 2887 | if (cnt == priv->cmd_queue) |
b74e31a9 WYG |
2888 | continue; |
2889 | if (iwl_check_stuck_queue(priv, cnt)) | |
2890 | return; | |
2891 | } | |
2892 | } | |
7cb1b088 | 2893 | if (priv->cfg->base_params->monitor_recover_period) { |
7bdc473c WYG |
2894 | /* |
2895 | * Reschedule the timer to occur in | |
7cb1b088 | 2896 | * priv->cfg->base_params->monitor_recover_period |
7bdc473c WYG |
2897 | */ |
2898 | mod_timer(&priv->monitor_recover, jiffies + msecs_to_jiffies( | |
7cb1b088 | 2899 | priv->cfg->base_params->monitor_recover_period)); |
7bdc473c | 2900 | } |
b74e31a9 WYG |
2901 | } |
2902 | EXPORT_SYMBOL(iwl_bg_monitor_recover); | |
afbdd69a | 2903 | |
a0ee74cf WYG |
2904 | |
2905 | /* | |
2906 | * extended beacon time format | |
2907 | * time in usec will be changed into a 32-bit value in extended:internal format | |
2908 | * the extended part is the beacon counts | |
2909 | * the internal part is the time in usec within one beacon interval | |
2910 | */ | |
2911 | u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval) | |
2912 | { | |
2913 | u32 quot; | |
2914 | u32 rem; | |
2915 | u32 interval = beacon_interval * TIME_UNIT; | |
2916 | ||
2917 | if (!interval || !usec) | |
2918 | return 0; | |
2919 | ||
2920 | quot = (usec / interval) & | |
2921 | (iwl_beacon_time_mask_high(priv, | |
2922 | priv->hw_params.beacon_time_tsf_bits) >> | |
2923 | priv->hw_params.beacon_time_tsf_bits); | |
2924 | rem = (usec % interval) & iwl_beacon_time_mask_low(priv, | |
2925 | priv->hw_params.beacon_time_tsf_bits); | |
2926 | ||
2927 | return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; | |
2928 | } | |
2929 | EXPORT_SYMBOL(iwl_usecs_to_beacons); | |
2930 | ||
2931 | /* base is usually what we get from ucode with each received frame, | |
2932 | * the same as HW timer counter counting down | |
2933 | */ | |
2934 | __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, | |
2935 | u32 addon, u32 beacon_interval) | |
2936 | { | |
2937 | u32 base_low = base & iwl_beacon_time_mask_low(priv, | |
2938 | priv->hw_params.beacon_time_tsf_bits); | |
2939 | u32 addon_low = addon & iwl_beacon_time_mask_low(priv, | |
2940 | priv->hw_params.beacon_time_tsf_bits); | |
2941 | u32 interval = beacon_interval * TIME_UNIT; | |
2942 | u32 res = (base & iwl_beacon_time_mask_high(priv, | |
2943 | priv->hw_params.beacon_time_tsf_bits)) + | |
2944 | (addon & iwl_beacon_time_mask_high(priv, | |
2945 | priv->hw_params.beacon_time_tsf_bits)); | |
2946 | ||
2947 | if (base_low > addon_low) | |
2948 | res += base_low - addon_low; | |
2949 | else if (base_low < addon_low) { | |
2950 | res += interval + base_low - addon_low; | |
2951 | res += (1 << priv->hw_params.beacon_time_tsf_bits); | |
2952 | } else | |
2953 | res += (1 << priv->hw_params.beacon_time_tsf_bits); | |
2954 | ||
2955 | return cpu_to_le32(res); | |
2956 | } | |
2957 | EXPORT_SYMBOL(iwl_add_beacon_time); | |
2958 | ||
6da3a13e WYG |
2959 | #ifdef CONFIG_PM |
2960 | ||
2961 | int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |
2962 | { | |
2963 | struct iwl_priv *priv = pci_get_drvdata(pdev); | |
2964 | ||
2965 | /* | |
2966 | * This function is called when system goes into suspend state | |
2967 | * mac80211 will call iwl_mac_stop() from the mac80211 suspend function | |
2968 | * first but since iwl_mac_stop() has no knowledge of who the caller is, | |
2969 | * it will not call apm_ops.stop() to stop the DMA operation. | |
2970 | * Calling apm_ops.stop here to make sure we stop the DMA. | |
2971 | */ | |
2972 | priv->cfg->ops->lib->apm_ops.stop(priv); | |
2973 | ||
2974 | pci_save_state(pdev); | |
2975 | pci_disable_device(pdev); | |
2976 | pci_set_power_state(pdev, PCI_D3hot); | |
2977 | ||
2978 | return 0; | |
2979 | } | |
2980 | EXPORT_SYMBOL(iwl_pci_suspend); | |
2981 | ||
2982 | int iwl_pci_resume(struct pci_dev *pdev) | |
2983 | { | |
2984 | struct iwl_priv *priv = pci_get_drvdata(pdev); | |
2985 | int ret; | |
0ab84cff | 2986 | bool hw_rfkill = false; |
6da3a13e | 2987 | |
cd398c31 AK |
2988 | /* |
2989 | * We disable the RETRY_TIMEOUT register (0x41) to keep | |
2990 | * PCI Tx retries from interfering with C3 CPU state. | |
2991 | */ | |
2992 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); | |
2993 | ||
6da3a13e WYG |
2994 | pci_set_power_state(pdev, PCI_D0); |
2995 | ret = pci_enable_device(pdev); | |
2996 | if (ret) | |
2997 | return ret; | |
2998 | pci_restore_state(pdev); | |
2999 | iwl_enable_interrupts(priv); | |
3000 | ||
0ab84cff JB |
3001 | if (!(iwl_read32(priv, CSR_GP_CNTRL) & |
3002 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) | |
3003 | hw_rfkill = true; | |
3004 | ||
3005 | if (hw_rfkill) | |
3006 | set_bit(STATUS_RF_KILL_HW, &priv->status); | |
3007 | else | |
3008 | clear_bit(STATUS_RF_KILL_HW, &priv->status); | |
3009 | ||
3010 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill); | |
3011 | ||
6da3a13e WYG |
3012 | return 0; |
3013 | } | |
3014 | EXPORT_SYMBOL(iwl_pci_resume); | |
3015 | ||
3016 | #endif /* CONFIG_PM */ |