1 /******************************************************************************
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/etherdevice.h>
32 #include <linux/sched.h>
33 #include <linux/slab.h>
34 #include <net/mac80211.h>
36 #include "iwl-eeprom.h"
37 #include "iwl-dev.h" /* FIXME: remove */
38 #include "iwl-debug.h"
41 #include "iwl-power.h"
43 #include "iwl-helpers.h"
48 const u8 iwl_bcast_addr
[ETH_ALEN
] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
50 #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
51 #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
52 static void iwlcore_init_ht_hw_capab(const struct iwl_priv
*priv
,
53 struct ieee80211_sta_ht_cap
*ht_info
,
54 enum ieee80211_band band
)
57 u8 rx_chains_num
= priv
->hw_params
.rx_chains_num
;
58 u8 tx_chains_num
= priv
->hw_params
.tx_chains_num
;
61 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
63 ht_info
->ht_supported
= true;
65 if (priv
->cfg
->ht_params
&&
66 priv
->cfg
->ht_params
->ht_greenfield_support
)
67 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
68 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
69 max_bit_rate
= MAX_BIT_RATE_20_MHZ
;
70 if (priv
->hw_params
.ht40_channel
& BIT(band
)) {
71 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
72 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
73 ht_info
->mcs
.rx_mask
[4] = 0x01;
74 max_bit_rate
= MAX_BIT_RATE_40_MHZ
;
77 if (iwlagn_mod_params
.amsdu_size_8K
)
78 ht_info
->cap
|= IEEE80211_HT_CAP_MAX_AMSDU
;
80 ht_info
->ampdu_factor
= CFG_HT_RX_AMPDU_FACTOR_DEF
;
81 if (priv
->cfg
->bt_params
&& priv
->cfg
->bt_params
->ampdu_factor
)
82 ht_info
->ampdu_factor
= priv
->cfg
->bt_params
->ampdu_factor
;
83 ht_info
->ampdu_density
= CFG_HT_MPDU_DENSITY_DEF
;
84 if (priv
->cfg
->bt_params
&& priv
->cfg
->bt_params
->ampdu_density
)
85 ht_info
->ampdu_density
= priv
->cfg
->bt_params
->ampdu_density
;
87 ht_info
->mcs
.rx_mask
[0] = 0xFF;
88 if (rx_chains_num
>= 2)
89 ht_info
->mcs
.rx_mask
[1] = 0xFF;
90 if (rx_chains_num
>= 3)
91 ht_info
->mcs
.rx_mask
[2] = 0xFF;
93 /* Highest supported Rx data rate */
94 max_bit_rate
*= rx_chains_num
;
95 WARN_ON(max_bit_rate
& ~IEEE80211_HT_MCS_RX_HIGHEST_MASK
);
96 ht_info
->mcs
.rx_highest
= cpu_to_le16(max_bit_rate
);
98 /* Tx MCS capabilities */
99 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
100 if (tx_chains_num
!= rx_chains_num
) {
101 ht_info
->mcs
.tx_params
|= IEEE80211_HT_MCS_TX_RX_DIFF
;
102 ht_info
->mcs
.tx_params
|= ((tx_chains_num
- 1) <<
103 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT
);
108 * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom
110 int iwlcore_init_geos(struct iwl_priv
*priv
)
112 struct iwl_channel_info
*ch
;
113 struct ieee80211_supported_band
*sband
;
114 struct ieee80211_channel
*channels
;
115 struct ieee80211_channel
*geo_ch
;
116 struct ieee80211_rate
*rates
;
118 s8 max_tx_power
= IWLAGN_TX_POWER_TARGET_POWER_MIN
;
120 if (priv
->bands
[IEEE80211_BAND_2GHZ
].n_bitrates
||
121 priv
->bands
[IEEE80211_BAND_5GHZ
].n_bitrates
) {
122 IWL_DEBUG_INFO(priv
, "Geography modes already initialized.\n");
123 set_bit(STATUS_GEO_CONFIGURED
, &priv
->status
);
127 channels
= kzalloc(sizeof(struct ieee80211_channel
) *
128 priv
->channel_count
, GFP_KERNEL
);
132 rates
= kzalloc((sizeof(struct ieee80211_rate
) * IWL_RATE_COUNT_LEGACY
),
139 /* 5.2GHz channels start after the 2.4GHz channels */
140 sband
= &priv
->bands
[IEEE80211_BAND_5GHZ
];
141 sband
->channels
= &channels
[ARRAY_SIZE(iwl_eeprom_band_1
)];
143 sband
->bitrates
= &rates
[IWL_FIRST_OFDM_RATE
];
144 sband
->n_bitrates
= IWL_RATE_COUNT_LEGACY
- IWL_FIRST_OFDM_RATE
;
146 if (priv
->cfg
->sku
& EEPROM_SKU_CAP_11N_ENABLE
)
147 iwlcore_init_ht_hw_capab(priv
, &sband
->ht_cap
,
148 IEEE80211_BAND_5GHZ
);
150 sband
= &priv
->bands
[IEEE80211_BAND_2GHZ
];
151 sband
->channels
= channels
;
153 sband
->bitrates
= rates
;
154 sband
->n_bitrates
= IWL_RATE_COUNT_LEGACY
;
156 if (priv
->cfg
->sku
& EEPROM_SKU_CAP_11N_ENABLE
)
157 iwlcore_init_ht_hw_capab(priv
, &sband
->ht_cap
,
158 IEEE80211_BAND_2GHZ
);
160 priv
->ieee_channels
= channels
;
161 priv
->ieee_rates
= rates
;
163 for (i
= 0; i
< priv
->channel_count
; i
++) {
164 ch
= &priv
->channel_info
[i
];
166 /* FIXME: might be removed if scan is OK */
167 if (!is_channel_valid(ch
))
170 sband
= &priv
->bands
[ch
->band
];
172 geo_ch
= &sband
->channels
[sband
->n_channels
++];
174 geo_ch
->center_freq
=
175 ieee80211_channel_to_frequency(ch
->channel
, ch
->band
);
176 geo_ch
->max_power
= ch
->max_power_avg
;
177 geo_ch
->max_antenna_gain
= 0xff;
178 geo_ch
->hw_value
= ch
->channel
;
180 if (is_channel_valid(ch
)) {
181 if (!(ch
->flags
& EEPROM_CHANNEL_IBSS
))
182 geo_ch
->flags
|= IEEE80211_CHAN_NO_IBSS
;
184 if (!(ch
->flags
& EEPROM_CHANNEL_ACTIVE
))
185 geo_ch
->flags
|= IEEE80211_CHAN_PASSIVE_SCAN
;
187 if (ch
->flags
& EEPROM_CHANNEL_RADAR
)
188 geo_ch
->flags
|= IEEE80211_CHAN_RADAR
;
190 geo_ch
->flags
|= ch
->ht40_extension_channel
;
192 if (ch
->max_power_avg
> max_tx_power
)
193 max_tx_power
= ch
->max_power_avg
;
195 geo_ch
->flags
|= IEEE80211_CHAN_DISABLED
;
198 IWL_DEBUG_INFO(priv
, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n",
199 ch
->channel
, geo_ch
->center_freq
,
200 is_channel_a_band(ch
) ? "5.2" : "2.4",
201 geo_ch
->flags
& IEEE80211_CHAN_DISABLED
?
202 "restricted" : "valid",
206 priv
->tx_power_device_lmt
= max_tx_power
;
207 priv
->tx_power_user_lmt
= max_tx_power
;
208 priv
->tx_power_next
= max_tx_power
;
210 if ((priv
->bands
[IEEE80211_BAND_5GHZ
].n_channels
== 0) &&
211 priv
->cfg
->sku
& EEPROM_SKU_CAP_BAND_52GHZ
) {
213 priv
->bus
.ops
->get_hw_id(&priv
->bus
, buf
, sizeof(buf
));
214 IWL_INFO(priv
, "Incorrectly detected BG card as ABG. "
215 "Please send your %s to maintainer.\n", buf
);
216 priv
->cfg
->sku
&= ~EEPROM_SKU_CAP_BAND_52GHZ
;
219 IWL_INFO(priv
, "Tunable channels: %d 802.11bg, %d 802.11a channels\n",
220 priv
->bands
[IEEE80211_BAND_2GHZ
].n_channels
,
221 priv
->bands
[IEEE80211_BAND_5GHZ
].n_channels
);
223 set_bit(STATUS_GEO_CONFIGURED
, &priv
->status
);
229 * iwlcore_free_geos - undo allocations in iwlcore_init_geos
231 void iwlcore_free_geos(struct iwl_priv
*priv
)
233 kfree(priv
->ieee_channels
);
234 kfree(priv
->ieee_rates
);
235 clear_bit(STATUS_GEO_CONFIGURED
, &priv
->status
);
238 static bool iwl_is_channel_extension(struct iwl_priv
*priv
,
239 enum ieee80211_band band
,
240 u16 channel
, u8 extension_chan_offset
)
242 const struct iwl_channel_info
*ch_info
;
244 ch_info
= iwl_get_channel_info(priv
, band
, channel
);
245 if (!is_channel_valid(ch_info
))
248 if (extension_chan_offset
== IEEE80211_HT_PARAM_CHA_SEC_ABOVE
)
249 return !(ch_info
->ht40_extension_channel
&
250 IEEE80211_CHAN_NO_HT40PLUS
);
251 else if (extension_chan_offset
== IEEE80211_HT_PARAM_CHA_SEC_BELOW
)
252 return !(ch_info
->ht40_extension_channel
&
253 IEEE80211_CHAN_NO_HT40MINUS
);
258 bool iwl_is_ht40_tx_allowed(struct iwl_priv
*priv
,
259 struct iwl_rxon_context
*ctx
,
260 struct ieee80211_sta_ht_cap
*ht_cap
)
262 if (!ctx
->ht
.enabled
|| !ctx
->ht
.is_40mhz
)
266 * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40
267 * the bit will not set if it is pure 40MHz case
269 if (ht_cap
&& !ht_cap
->ht_supported
)
272 #ifdef CONFIG_IWLWIFI_DEBUGFS
273 if (priv
->disable_ht40
)
277 return iwl_is_channel_extension(priv
, priv
->band
,
278 le16_to_cpu(ctx
->staging
.channel
),
279 ctx
->ht
.extension_chan_offset
);
282 static u16
iwl_adjust_beacon_interval(u16 beacon_val
, u16 max_beacon_val
)
288 * If mac80211 hasn't given us a beacon interval, program
289 * the default into the device (not checking this here
290 * would cause the adjustment below to return the maximum
291 * value, which may break PAN.)
294 return DEFAULT_BEACON_INTERVAL
;
297 * If the beacon interval we obtained from the peer
298 * is too large, we'll have to wake up more often
299 * (and in IBSS case, we'll beacon too much)
301 * For example, if max_beacon_val is 4096, and the
302 * requested beacon interval is 7000, we'll have to
303 * use 3500 to be able to wake up on the beacons.
305 * This could badly influence beacon detection stats.
308 beacon_factor
= (beacon_val
+ max_beacon_val
) / max_beacon_val
;
309 new_val
= beacon_val
/ beacon_factor
;
312 new_val
= max_beacon_val
;
317 int iwl_send_rxon_timing(struct iwl_priv
*priv
, struct iwl_rxon_context
*ctx
)
320 s32 interval_tm
, rem
;
321 struct ieee80211_conf
*conf
= NULL
;
323 struct ieee80211_vif
*vif
= ctx
->vif
;
325 conf
= ieee80211_get_hw_conf(priv
->hw
);
327 lockdep_assert_held(&priv
->mutex
);
329 memset(&ctx
->timing
, 0, sizeof(struct iwl_rxon_time_cmd
));
331 ctx
->timing
.timestamp
= cpu_to_le64(priv
->timestamp
);
332 ctx
->timing
.listen_interval
= cpu_to_le16(conf
->listen_interval
);
334 beacon_int
= vif
? vif
->bss_conf
.beacon_int
: 0;
337 * TODO: For IBSS we need to get atim_window from mac80211,
338 * for now just always use 0
340 ctx
->timing
.atim_window
= 0;
342 if (ctx
->ctxid
== IWL_RXON_CTX_PAN
&&
343 (!ctx
->vif
|| ctx
->vif
->type
!= NL80211_IFTYPE_STATION
) &&
344 iwl_is_associated(priv
, IWL_RXON_CTX_BSS
) &&
345 priv
->contexts
[IWL_RXON_CTX_BSS
].vif
&&
346 priv
->contexts
[IWL_RXON_CTX_BSS
].vif
->bss_conf
.beacon_int
) {
347 ctx
->timing
.beacon_interval
=
348 priv
->contexts
[IWL_RXON_CTX_BSS
].timing
.beacon_interval
;
349 beacon_int
= le16_to_cpu(ctx
->timing
.beacon_interval
);
350 } else if (ctx
->ctxid
== IWL_RXON_CTX_BSS
&&
351 iwl_is_associated(priv
, IWL_RXON_CTX_PAN
) &&
352 priv
->contexts
[IWL_RXON_CTX_PAN
].vif
&&
353 priv
->contexts
[IWL_RXON_CTX_PAN
].vif
->bss_conf
.beacon_int
&&
354 (!iwl_is_associated_ctx(ctx
) || !ctx
->vif
||
355 !ctx
->vif
->bss_conf
.beacon_int
)) {
356 ctx
->timing
.beacon_interval
=
357 priv
->contexts
[IWL_RXON_CTX_PAN
].timing
.beacon_interval
;
358 beacon_int
= le16_to_cpu(ctx
->timing
.beacon_interval
);
360 beacon_int
= iwl_adjust_beacon_interval(beacon_int
,
361 priv
->hw_params
.max_beacon_itrvl
* TIME_UNIT
);
362 ctx
->timing
.beacon_interval
= cpu_to_le16(beacon_int
);
365 tsf
= priv
->timestamp
; /* tsf is modifed by do_div: copy it */
366 interval_tm
= beacon_int
* TIME_UNIT
;
367 rem
= do_div(tsf
, interval_tm
);
368 ctx
->timing
.beacon_init_val
= cpu_to_le32(interval_tm
- rem
);
370 ctx
->timing
.dtim_period
= vif
? (vif
->bss_conf
.dtim_period
?: 1) : 1;
372 IWL_DEBUG_ASSOC(priv
,
373 "beacon interval %d beacon timer %d beacon tim %d\n",
374 le16_to_cpu(ctx
->timing
.beacon_interval
),
375 le32_to_cpu(ctx
->timing
.beacon_init_val
),
376 le16_to_cpu(ctx
->timing
.atim_window
));
378 return iwl_send_cmd_pdu(priv
, ctx
->rxon_timing_cmd
,
379 sizeof(ctx
->timing
), &ctx
->timing
);
382 void iwl_set_rxon_hwcrypto(struct iwl_priv
*priv
, struct iwl_rxon_context
*ctx
,
385 struct iwl_rxon_cmd
*rxon
= &ctx
->staging
;
388 rxon
->filter_flags
&= ~RXON_FILTER_DIS_DECRYPT_MSK
;
390 rxon
->filter_flags
|= RXON_FILTER_DIS_DECRYPT_MSK
;
394 /* validate RXON structure is valid */
395 int iwl_check_rxon_cmd(struct iwl_priv
*priv
, struct iwl_rxon_context
*ctx
)
397 struct iwl_rxon_cmd
*rxon
= &ctx
->staging
;
400 if (rxon
->flags
& RXON_FLG_BAND_24G_MSK
) {
401 if (rxon
->flags
& RXON_FLG_TGJ_NARROW_BAND_MSK
) {
402 IWL_WARN(priv
, "check 2.4G: wrong narrow\n");
405 if (rxon
->flags
& RXON_FLG_RADAR_DETECT_MSK
) {
406 IWL_WARN(priv
, "check 2.4G: wrong radar\n");
410 if (!(rxon
->flags
& RXON_FLG_SHORT_SLOT_MSK
)) {
411 IWL_WARN(priv
, "check 5.2G: not short slot!\n");
414 if (rxon
->flags
& RXON_FLG_CCK_MSK
) {
415 IWL_WARN(priv
, "check 5.2G: CCK!\n");
419 if ((rxon
->node_addr
[0] | rxon
->bssid_addr
[0]) & 0x1) {
420 IWL_WARN(priv
, "mac/bssid mcast!\n");
424 /* make sure basic rates 6Mbps and 1Mbps are supported */
425 if ((rxon
->ofdm_basic_rates
& IWL_RATE_6M_MASK
) == 0 &&
426 (rxon
->cck_basic_rates
& IWL_RATE_1M_MASK
) == 0) {
427 IWL_WARN(priv
, "neither 1 nor 6 are basic\n");
431 if (le16_to_cpu(rxon
->assoc_id
) > 2007) {
432 IWL_WARN(priv
, "aid > 2007\n");
436 if ((rxon
->flags
& (RXON_FLG_CCK_MSK
| RXON_FLG_SHORT_SLOT_MSK
))
437 == (RXON_FLG_CCK_MSK
| RXON_FLG_SHORT_SLOT_MSK
)) {
438 IWL_WARN(priv
, "CCK and short slot\n");
442 if ((rxon
->flags
& (RXON_FLG_CCK_MSK
| RXON_FLG_AUTO_DETECT_MSK
))
443 == (RXON_FLG_CCK_MSK
| RXON_FLG_AUTO_DETECT_MSK
)) {
444 IWL_WARN(priv
, "CCK and auto detect");
448 if ((rxon
->flags
& (RXON_FLG_AUTO_DETECT_MSK
|
449 RXON_FLG_TGG_PROTECT_MSK
)) ==
450 RXON_FLG_TGG_PROTECT_MSK
) {
451 IWL_WARN(priv
, "TGg but no auto-detect\n");
455 if (rxon
->channel
== 0) {
456 IWL_WARN(priv
, "zero channel is invalid\n");
460 WARN(errors
, "Invalid RXON (%#x), channel %d",
461 errors
, le16_to_cpu(rxon
->channel
));
463 return errors
? -EINVAL
: 0;
467 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
468 * @priv: staging_rxon is compared to active_rxon
470 * If the RXON structure is changing enough to require a new tune,
471 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
472 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
474 int iwl_full_rxon_required(struct iwl_priv
*priv
,
475 struct iwl_rxon_context
*ctx
)
477 const struct iwl_rxon_cmd
*staging
= &ctx
->staging
;
478 const struct iwl_rxon_cmd
*active
= &ctx
->active
;
482 IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \
486 #define CHK_NEQ(c1, c2) \
487 if ((c1) != (c2)) { \
488 IWL_DEBUG_INFO(priv, "need full RXON - " \
489 #c1 " != " #c2 " - %d != %d\n", \
494 /* These items are only settable from the full RXON command */
495 CHK(!iwl_is_associated_ctx(ctx
));
496 CHK(compare_ether_addr(staging
->bssid_addr
, active
->bssid_addr
));
497 CHK(compare_ether_addr(staging
->node_addr
, active
->node_addr
));
498 CHK(compare_ether_addr(staging
->wlap_bssid_addr
,
499 active
->wlap_bssid_addr
));
500 CHK_NEQ(staging
->dev_type
, active
->dev_type
);
501 CHK_NEQ(staging
->channel
, active
->channel
);
502 CHK_NEQ(staging
->air_propagation
, active
->air_propagation
);
503 CHK_NEQ(staging
->ofdm_ht_single_stream_basic_rates
,
504 active
->ofdm_ht_single_stream_basic_rates
);
505 CHK_NEQ(staging
->ofdm_ht_dual_stream_basic_rates
,
506 active
->ofdm_ht_dual_stream_basic_rates
);
507 CHK_NEQ(staging
->ofdm_ht_triple_stream_basic_rates
,
508 active
->ofdm_ht_triple_stream_basic_rates
);
509 CHK_NEQ(staging
->assoc_id
, active
->assoc_id
);
511 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
512 * be updated with the RXON_ASSOC command -- however only some
513 * flag transitions are allowed using RXON_ASSOC */
515 /* Check if we are not switching bands */
516 CHK_NEQ(staging
->flags
& RXON_FLG_BAND_24G_MSK
,
517 active
->flags
& RXON_FLG_BAND_24G_MSK
);
519 /* Check if we are switching association toggle */
520 CHK_NEQ(staging
->filter_flags
& RXON_FILTER_ASSOC_MSK
,
521 active
->filter_flags
& RXON_FILTER_ASSOC_MSK
);
529 static void _iwl_set_rxon_ht(struct iwl_priv
*priv
,
530 struct iwl_ht_config
*ht_conf
,
531 struct iwl_rxon_context
*ctx
)
533 struct iwl_rxon_cmd
*rxon
= &ctx
->staging
;
535 if (!ctx
->ht
.enabled
) {
536 rxon
->flags
&= ~(RXON_FLG_CHANNEL_MODE_MSK
|
537 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
|
538 RXON_FLG_HT40_PROT_MSK
|
539 RXON_FLG_HT_PROT_MSK
);
543 /* FIXME: if the definition of ht.protection changed, the "translation"
544 * will be needed for rxon->flags
546 rxon
->flags
|= cpu_to_le32(ctx
->ht
.protection
<< RXON_FLG_HT_OPERATING_MODE_POS
);
548 /* Set up channel bandwidth:
549 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */
550 /* clear the HT channel mode before set the mode */
551 rxon
->flags
&= ~(RXON_FLG_CHANNEL_MODE_MSK
|
552 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
);
553 if (iwl_is_ht40_tx_allowed(priv
, ctx
, NULL
)) {
555 if (ctx
->ht
.protection
== IEEE80211_HT_OP_MODE_PROTECTION_20MHZ
) {
556 rxon
->flags
|= RXON_FLG_CHANNEL_MODE_PURE_40
;
557 /* Note: control channel is opposite of extension channel */
558 switch (ctx
->ht
.extension_chan_offset
) {
559 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
560 rxon
->flags
&= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
;
562 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
563 rxon
->flags
|= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
;
567 /* Note: control channel is opposite of extension channel */
568 switch (ctx
->ht
.extension_chan_offset
) {
569 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
570 rxon
->flags
&= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
);
571 rxon
->flags
|= RXON_FLG_CHANNEL_MODE_MIXED
;
573 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
574 rxon
->flags
|= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK
;
575 rxon
->flags
|= RXON_FLG_CHANNEL_MODE_MIXED
;
577 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
579 /* channel location only valid if in Mixed mode */
580 IWL_ERR(priv
, "invalid extension channel offset\n");
585 rxon
->flags
|= RXON_FLG_CHANNEL_MODE_LEGACY
;
588 if (priv
->cfg
->ops
->hcmd
->set_rxon_chain
)
589 priv
->cfg
->ops
->hcmd
->set_rxon_chain(priv
, ctx
);
591 IWL_DEBUG_ASSOC(priv
, "rxon flags 0x%X operation mode :0x%X "
592 "extension channel offset 0x%x\n",
593 le32_to_cpu(rxon
->flags
), ctx
->ht
.protection
,
594 ctx
->ht
.extension_chan_offset
);
597 void iwl_set_rxon_ht(struct iwl_priv
*priv
, struct iwl_ht_config
*ht_conf
)
599 struct iwl_rxon_context
*ctx
;
601 for_each_context(priv
, ctx
)
602 _iwl_set_rxon_ht(priv
, ht_conf
, ctx
);
605 /* Return valid, unused, channel for a passive scan to reset the RF */
606 u8
iwl_get_single_channel_number(struct iwl_priv
*priv
,
607 enum ieee80211_band band
)
609 const struct iwl_channel_info
*ch_info
;
613 struct iwl_rxon_context
*ctx
;
615 if (band
== IEEE80211_BAND_5GHZ
) {
617 max
= priv
->channel_count
;
623 for (i
= min
; i
< max
; i
++) {
626 for_each_context(priv
, ctx
) {
627 busy
= priv
->channel_info
[i
].channel
==
628 le16_to_cpu(ctx
->staging
.channel
);
636 channel
= priv
->channel_info
[i
].channel
;
637 ch_info
= iwl_get_channel_info(priv
, band
, channel
);
638 if (is_channel_valid(ch_info
))
646 * iwl_set_rxon_channel - Set the band and channel values in staging RXON
647 * @ch: requested channel as a pointer to struct ieee80211_channel
649 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
650 * in the staging RXON flag structure based on the ch->band
652 int iwl_set_rxon_channel(struct iwl_priv
*priv
, struct ieee80211_channel
*ch
,
653 struct iwl_rxon_context
*ctx
)
655 enum ieee80211_band band
= ch
->band
;
656 u16 channel
= ch
->hw_value
;
658 if ((le16_to_cpu(ctx
->staging
.channel
) == channel
) &&
659 (priv
->band
== band
))
662 ctx
->staging
.channel
= cpu_to_le16(channel
);
663 if (band
== IEEE80211_BAND_5GHZ
)
664 ctx
->staging
.flags
&= ~RXON_FLG_BAND_24G_MSK
;
666 ctx
->staging
.flags
|= RXON_FLG_BAND_24G_MSK
;
670 IWL_DEBUG_INFO(priv
, "Staging channel set to %d [%d]\n", channel
, band
);
675 void iwl_set_flags_for_band(struct iwl_priv
*priv
,
676 struct iwl_rxon_context
*ctx
,
677 enum ieee80211_band band
,
678 struct ieee80211_vif
*vif
)
680 if (band
== IEEE80211_BAND_5GHZ
) {
681 ctx
->staging
.flags
&=
682 ~(RXON_FLG_BAND_24G_MSK
| RXON_FLG_AUTO_DETECT_MSK
684 ctx
->staging
.flags
|= RXON_FLG_SHORT_SLOT_MSK
;
686 /* Copied from iwl_post_associate() */
687 if (vif
&& vif
->bss_conf
.use_short_slot
)
688 ctx
->staging
.flags
|= RXON_FLG_SHORT_SLOT_MSK
;
690 ctx
->staging
.flags
&= ~RXON_FLG_SHORT_SLOT_MSK
;
692 ctx
->staging
.flags
|= RXON_FLG_BAND_24G_MSK
;
693 ctx
->staging
.flags
|= RXON_FLG_AUTO_DETECT_MSK
;
694 ctx
->staging
.flags
&= ~RXON_FLG_CCK_MSK
;
699 * initialize rxon structure with default values from eeprom
701 void iwl_connection_init_rx_config(struct iwl_priv
*priv
,
702 struct iwl_rxon_context
*ctx
)
704 const struct iwl_channel_info
*ch_info
;
706 memset(&ctx
->staging
, 0, sizeof(ctx
->staging
));
709 ctx
->staging
.dev_type
= ctx
->unused_devtype
;
710 } else switch (ctx
->vif
->type
) {
711 case NL80211_IFTYPE_AP
:
712 ctx
->staging
.dev_type
= ctx
->ap_devtype
;
715 case NL80211_IFTYPE_STATION
:
716 ctx
->staging
.dev_type
= ctx
->station_devtype
;
717 ctx
->staging
.filter_flags
= RXON_FILTER_ACCEPT_GRP_MSK
;
720 case NL80211_IFTYPE_ADHOC
:
721 ctx
->staging
.dev_type
= ctx
->ibss_devtype
;
722 ctx
->staging
.flags
= RXON_FLG_SHORT_PREAMBLE_MSK
;
723 ctx
->staging
.filter_flags
= RXON_FILTER_BCON_AWARE_MSK
|
724 RXON_FILTER_ACCEPT_GRP_MSK
;
728 IWL_ERR(priv
, "Unsupported interface type %d\n",
734 /* TODO: Figure out when short_preamble would be set and cache from
736 if (!hw_to_local(priv
->hw
)->short_preamble
)
737 ctx
->staging
.flags
&= ~RXON_FLG_SHORT_PREAMBLE_MSK
;
739 ctx
->staging
.flags
|= RXON_FLG_SHORT_PREAMBLE_MSK
;
742 ch_info
= iwl_get_channel_info(priv
, priv
->band
,
743 le16_to_cpu(ctx
->active
.channel
));
746 ch_info
= &priv
->channel_info
[0];
748 ctx
->staging
.channel
= cpu_to_le16(ch_info
->channel
);
749 priv
->band
= ch_info
->band
;
751 iwl_set_flags_for_band(priv
, ctx
, priv
->band
, ctx
->vif
);
753 ctx
->staging
.ofdm_basic_rates
=
754 (IWL_OFDM_RATES_MASK
>> IWL_FIRST_OFDM_RATE
) & 0xFF;
755 ctx
->staging
.cck_basic_rates
=
756 (IWL_CCK_RATES_MASK
>> IWL_FIRST_CCK_RATE
) & 0xF;
758 /* clear both MIX and PURE40 mode flag */
759 ctx
->staging
.flags
&= ~(RXON_FLG_CHANNEL_MODE_MIXED
|
760 RXON_FLG_CHANNEL_MODE_PURE_40
);
762 memcpy(ctx
->staging
.node_addr
, ctx
->vif
->addr
, ETH_ALEN
);
764 ctx
->staging
.ofdm_ht_single_stream_basic_rates
= 0xff;
765 ctx
->staging
.ofdm_ht_dual_stream_basic_rates
= 0xff;
766 ctx
->staging
.ofdm_ht_triple_stream_basic_rates
= 0xff;
769 void iwl_set_rate(struct iwl_priv
*priv
)
771 const struct ieee80211_supported_band
*hw
= NULL
;
772 struct ieee80211_rate
*rate
;
773 struct iwl_rxon_context
*ctx
;
776 hw
= iwl_get_hw_mode(priv
, priv
->band
);
778 IWL_ERR(priv
, "Failed to set rate: unable to get hw mode\n");
782 priv
->active_rate
= 0;
784 for (i
= 0; i
< hw
->n_bitrates
; i
++) {
785 rate
= &(hw
->bitrates
[i
]);
786 if (rate
->hw_value
< IWL_RATE_COUNT_LEGACY
)
787 priv
->active_rate
|= (1 << rate
->hw_value
);
790 IWL_DEBUG_RATE(priv
, "Set active_rate = %0x\n", priv
->active_rate
);
792 for_each_context(priv
, ctx
) {
793 ctx
->staging
.cck_basic_rates
=
794 (IWL_CCK_BASIC_RATES_MASK
>> IWL_FIRST_CCK_RATE
) & 0xF;
796 ctx
->staging
.ofdm_basic_rates
=
797 (IWL_OFDM_BASIC_RATES_MASK
>> IWL_FIRST_OFDM_RATE
) & 0xFF;
801 void iwl_chswitch_done(struct iwl_priv
*priv
, bool is_success
)
805 * See iwl_mac_channel_switch.
807 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
809 if (test_bit(STATUS_EXIT_PENDING
, &priv
->status
))
812 if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING
, &priv
->status
))
813 ieee80211_chswitch_done(ctx
->vif
, is_success
);
816 #ifdef CONFIG_IWLWIFI_DEBUG
817 void iwl_print_rx_config_cmd(struct iwl_priv
*priv
,
818 struct iwl_rxon_context
*ctx
)
820 struct iwl_rxon_cmd
*rxon
= &ctx
->staging
;
822 IWL_DEBUG_RADIO(priv
, "RX CONFIG:\n");
823 iwl_print_hex_dump(priv
, IWL_DL_RADIO
, (u8
*) rxon
, sizeof(*rxon
));
824 IWL_DEBUG_RADIO(priv
, "u16 channel: 0x%x\n", le16_to_cpu(rxon
->channel
));
825 IWL_DEBUG_RADIO(priv
, "u32 flags: 0x%08X\n", le32_to_cpu(rxon
->flags
));
826 IWL_DEBUG_RADIO(priv
, "u32 filter_flags: 0x%08x\n",
827 le32_to_cpu(rxon
->filter_flags
));
828 IWL_DEBUG_RADIO(priv
, "u8 dev_type: 0x%x\n", rxon
->dev_type
);
829 IWL_DEBUG_RADIO(priv
, "u8 ofdm_basic_rates: 0x%02x\n",
830 rxon
->ofdm_basic_rates
);
831 IWL_DEBUG_RADIO(priv
, "u8 cck_basic_rates: 0x%02x\n", rxon
->cck_basic_rates
);
832 IWL_DEBUG_RADIO(priv
, "u8[6] node_addr: %pM\n", rxon
->node_addr
);
833 IWL_DEBUG_RADIO(priv
, "u8[6] bssid_addr: %pM\n", rxon
->bssid_addr
);
834 IWL_DEBUG_RADIO(priv
, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon
->assoc_id
));
838 static void iwlagn_abort_notification_waits(struct iwl_priv
*priv
)
841 struct iwl_notification_wait
*wait_entry
;
843 spin_lock_irqsave(&priv
->_agn
.notif_wait_lock
, flags
);
844 list_for_each_entry(wait_entry
, &priv
->_agn
.notif_waits
, list
)
845 wait_entry
->aborted
= true;
846 spin_unlock_irqrestore(&priv
->_agn
.notif_wait_lock
, flags
);
848 wake_up_all(&priv
->_agn
.notif_waitq
);
851 void iwlagn_fw_error(struct iwl_priv
*priv
, bool ondemand
)
853 unsigned int reload_msec
;
854 unsigned long reload_jiffies
;
856 /* Set the FW error flag -- cleared on iwl_down */
857 set_bit(STATUS_FW_ERROR
, &priv
->status
);
859 /* Cancel currently queued command. */
860 clear_bit(STATUS_HCMD_ACTIVE
, &priv
->status
);
862 iwlagn_abort_notification_waits(priv
);
864 /* Keep the restart process from trying to send host
865 * commands by clearing the ready bit */
866 clear_bit(STATUS_READY
, &priv
->status
);
868 wake_up_interruptible(&priv
->wait_command_queue
);
872 * If firmware keep reloading, then it indicate something
873 * serious wrong and firmware having problem to recover
874 * from it. Instead of keep trying which will fill the syslog
875 * and hang the system, let's just stop it
877 reload_jiffies
= jiffies
;
878 reload_msec
= jiffies_to_msecs((long) reload_jiffies
-
879 (long) priv
->reload_jiffies
);
880 priv
->reload_jiffies
= reload_jiffies
;
881 if (reload_msec
<= IWL_MIN_RELOAD_DURATION
) {
882 priv
->reload_count
++;
883 if (priv
->reload_count
>= IWL_MAX_CONTINUE_RELOAD_CNT
) {
884 IWL_ERR(priv
, "BUG_ON, Stop restarting\n");
888 priv
->reload_count
= 0;
891 if (!test_bit(STATUS_EXIT_PENDING
, &priv
->status
)) {
892 if (iwlagn_mod_params
.restart_fw
) {
893 IWL_DEBUG(priv
, IWL_DL_FW_ERRORS
,
894 "Restarting adapter due to uCode error.\n");
895 queue_work(priv
->workqueue
, &priv
->restart
);
897 IWL_DEBUG(priv
, IWL_DL_FW_ERRORS
,
898 "Detected FW error, but not restarting\n");
903 * iwl_irq_handle_error - called for HW or SW error interrupt from card
905 void iwl_irq_handle_error(struct iwl_priv
*priv
)
907 /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
908 if (priv
->cfg
->internal_wimax_coex
&&
909 (!(iwl_read_prph(priv
, APMG_CLK_CTRL_REG
) &
910 APMS_CLK_VAL_MRB_FUNC_MODE
) ||
911 (iwl_read_prph(priv
, APMG_PS_CTRL_REG
) &
912 APMG_PS_CTRL_VAL_RESET_REQ
))) {
914 * Keep the restart process from trying to send host
915 * commands by clearing the ready bit.
917 clear_bit(STATUS_READY
, &priv
->status
);
918 clear_bit(STATUS_HCMD_ACTIVE
, &priv
->status
);
919 wake_up_interruptible(&priv
->wait_command_queue
);
920 IWL_ERR(priv
, "RF is used by WiMAX\n");
924 IWL_ERR(priv
, "Loaded firmware version: %s\n",
925 priv
->hw
->wiphy
->fw_version
);
927 iwl_dump_nic_error_log(priv
);
929 iwl_dump_fh(priv
, NULL
, false);
930 iwl_dump_nic_event_log(priv
, false, NULL
, false);
931 #ifdef CONFIG_IWLWIFI_DEBUG
932 if (iwl_get_debug_level(priv
) & IWL_DL_FW_ERRORS
)
933 iwl_print_rx_config_cmd(priv
,
934 &priv
->contexts
[IWL_RXON_CTX_BSS
]);
937 iwlagn_fw_error(priv
, false);
940 static int iwl_apm_stop_master(struct iwl_priv
*priv
)
944 /* stop device's busmaster DMA activity */
945 iwl_set_bit(priv
, CSR_RESET
, CSR_RESET_REG_FLAG_STOP_MASTER
);
947 ret
= iwl_poll_bit(priv
, CSR_RESET
, CSR_RESET_REG_FLAG_MASTER_DISABLED
,
948 CSR_RESET_REG_FLAG_MASTER_DISABLED
, 100);
950 IWL_WARN(priv
, "Master Disable Timed Out, 100 usec\n");
952 IWL_DEBUG_INFO(priv
, "stop master\n");
957 void iwl_apm_stop(struct iwl_priv
*priv
)
959 IWL_DEBUG_INFO(priv
, "Stop card, put in low power state\n");
961 clear_bit(STATUS_DEVICE_ENABLED
, &priv
->status
);
963 /* Stop device's DMA activity */
964 iwl_apm_stop_master(priv
);
966 /* Reset the entire device */
967 iwl_set_bit(priv
, CSR_RESET
, CSR_RESET_REG_FLAG_SW_RESET
);
972 * Clear "initialization complete" bit to move adapter from
973 * D0A* (powered-up Active) --> D0U* (Uninitialized) state.
975 iwl_clear_bit(priv
, CSR_GP_CNTRL
, CSR_GP_CNTRL_REG_FLAG_INIT_DONE
);
980 * Start up NIC's basic functionality after it has been reset
981 * (e.g. after platform boot, or shutdown via iwl_apm_stop())
982 * NOTE: This does not load uCode nor start the embedded processor
984 int iwl_apm_init(struct iwl_priv
*priv
)
987 IWL_DEBUG_INFO(priv
, "Init card's basic functions\n");
990 * Use "set_bit" below rather than "write", to preserve any hardware
991 * bits already set by default after reset.
994 /* Disable L0S exit timer (platform NMI Work/Around) */
995 iwl_set_bit(priv
, CSR_GIO_CHICKEN_BITS
,
996 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER
);
999 * Disable L0s without affecting L1;
1000 * don't wait for ICH L0s (ICH bug W/A)
1002 iwl_set_bit(priv
, CSR_GIO_CHICKEN_BITS
,
1003 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX
);
1005 /* Set FH wait threshold to maximum (HW error during stress W/A) */
1006 iwl_set_bit(priv
, CSR_DBG_HPET_MEM_REG
, CSR_DBG_HPET_MEM_REG_VAL
);
1009 * Enable HAP INTA (interrupt from management bus) to
1010 * wake device's PCI Express link L1a -> L0s
1012 iwl_set_bit(priv
, CSR_HW_IF_CONFIG_REG
,
1013 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A
);
1015 priv
->bus
.ops
->apm_config(&priv
->bus
);
1017 /* Configure analog phase-lock-loop before activating to D0A */
1018 if (priv
->cfg
->base_params
->pll_cfg_val
)
1019 iwl_set_bit(priv
, CSR_ANA_PLL_CFG
,
1020 priv
->cfg
->base_params
->pll_cfg_val
);
1023 * Set "initialization complete" bit to move adapter from
1024 * D0U* --> D0A* (powered-up active) state.
1026 iwl_set_bit(priv
, CSR_GP_CNTRL
, CSR_GP_CNTRL_REG_FLAG_INIT_DONE
);
1029 * Wait for clock stabilization; once stabilized, access to
1030 * device-internal resources is supported, e.g. iwl_write_prph()
1031 * and accesses to uCode SRAM.
1033 ret
= iwl_poll_bit(priv
, CSR_GP_CNTRL
,
1034 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY
,
1035 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY
, 25000);
1037 IWL_DEBUG_INFO(priv
, "Failed to init the card\n");
1042 * Enable DMA clock and wait for it to stabilize.
1044 * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits
1045 * do not disable clocks. This preserves any hardware bits already
1046 * set by default in "CLK_CTRL_REG" after reset.
1048 iwl_write_prph(priv
, APMG_CLK_EN_REG
, APMG_CLK_VAL_DMA_CLK_RQT
);
1051 /* Disable L1-Active */
1052 iwl_set_bits_prph(priv
, APMG_PCIDEV_STT_REG
,
1053 APMG_PCIDEV_STT_VAL_L1_ACT_DIS
);
1055 set_bit(STATUS_DEVICE_ENABLED
, &priv
->status
);
1062 int iwl_set_tx_power(struct iwl_priv
*priv
, s8 tx_power
, bool force
)
1067 struct iwl_rxon_context
*ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
1069 lockdep_assert_held(&priv
->mutex
);
1071 if (priv
->tx_power_user_lmt
== tx_power
&& !force
)
1074 if (tx_power
< IWLAGN_TX_POWER_TARGET_POWER_MIN
) {
1076 "Requested user TXPOWER %d below lower limit %d.\n",
1078 IWLAGN_TX_POWER_TARGET_POWER_MIN
);
1082 if (tx_power
> priv
->tx_power_device_lmt
) {
1084 "Requested user TXPOWER %d above upper limit %d.\n",
1085 tx_power
, priv
->tx_power_device_lmt
);
1089 if (!iwl_is_ready_rf(priv
))
1092 /* scan complete and commit_rxon use tx_power_next value,
1093 * it always need to be updated for newest request */
1094 priv
->tx_power_next
= tx_power
;
1096 /* do not set tx power when scanning or channel changing */
1097 defer
= test_bit(STATUS_SCANNING
, &priv
->status
) ||
1098 memcmp(&ctx
->active
, &ctx
->staging
, sizeof(ctx
->staging
));
1099 if (defer
&& !force
) {
1100 IWL_DEBUG_INFO(priv
, "Deferring tx power set\n");
1104 prev_tx_power
= priv
->tx_power_user_lmt
;
1105 priv
->tx_power_user_lmt
= tx_power
;
1107 ret
= iwlagn_send_tx_power(priv
);
1109 /* if fail to set tx_power, restore the orig. tx power */
1111 priv
->tx_power_user_lmt
= prev_tx_power
;
1112 priv
->tx_power_next
= prev_tx_power
;
1117 void iwl_send_bt_config(struct iwl_priv
*priv
)
1119 struct iwl_bt_cmd bt_cmd
= {
1120 .lead_time
= BT_LEAD_TIME_DEF
,
1121 .max_kill
= BT_MAX_KILL_DEF
,
1126 if (!iwlagn_mod_params
.bt_coex_active
)
1127 bt_cmd
.flags
= BT_COEX_DISABLE
;
1129 bt_cmd
.flags
= BT_COEX_ENABLE
;
1131 priv
->bt_enable_flag
= bt_cmd
.flags
;
1132 IWL_DEBUG_INFO(priv
, "BT coex %s\n",
1133 (bt_cmd
.flags
== BT_COEX_DISABLE
) ? "disable" : "active");
1135 if (iwl_send_cmd_pdu(priv
, REPLY_BT_CONFIG
,
1136 sizeof(struct iwl_bt_cmd
), &bt_cmd
))
1137 IWL_ERR(priv
, "failed to send BT Coex Config\n");
1140 int iwl_send_statistics_request(struct iwl_priv
*priv
, u8 flags
, bool clear
)
1142 struct iwl_statistics_cmd statistics_cmd
= {
1143 .configuration_flags
=
1144 clear
? IWL_STATS_CONF_CLEAR_STATS
: 0,
1147 if (flags
& CMD_ASYNC
)
1148 return iwl_send_cmd_pdu_async(priv
, REPLY_STATISTICS_CMD
,
1149 sizeof(struct iwl_statistics_cmd
),
1150 &statistics_cmd
, NULL
);
1152 return iwl_send_cmd_pdu(priv
, REPLY_STATISTICS_CMD
,
1153 sizeof(struct iwl_statistics_cmd
),
1157 void iwl_clear_isr_stats(struct iwl_priv
*priv
)
1159 memset(&priv
->isr_stats
, 0, sizeof(priv
->isr_stats
));
1162 int iwl_mac_conf_tx(struct ieee80211_hw
*hw
, u16 queue
,
1163 const struct ieee80211_tx_queue_params
*params
)
1165 struct iwl_priv
*priv
= hw
->priv
;
1166 struct iwl_rxon_context
*ctx
;
1167 unsigned long flags
;
1170 IWL_DEBUG_MAC80211(priv
, "enter\n");
1172 if (!iwl_is_ready_rf(priv
)) {
1173 IWL_DEBUG_MAC80211(priv
, "leave - RF not ready\n");
1177 if (queue
>= AC_NUM
) {
1178 IWL_DEBUG_MAC80211(priv
, "leave - queue >= AC_NUM %d\n", queue
);
1182 q
= AC_NUM
- 1 - queue
;
1184 spin_lock_irqsave(&priv
->lock
, flags
);
1188 * This may need to be done per interface in nl80211/cfg80211/mac80211.
1190 for_each_context(priv
, ctx
) {
1191 ctx
->qos_data
.def_qos_parm
.ac
[q
].cw_min
=
1192 cpu_to_le16(params
->cw_min
);
1193 ctx
->qos_data
.def_qos_parm
.ac
[q
].cw_max
=
1194 cpu_to_le16(params
->cw_max
);
1195 ctx
->qos_data
.def_qos_parm
.ac
[q
].aifsn
= params
->aifs
;
1196 ctx
->qos_data
.def_qos_parm
.ac
[q
].edca_txop
=
1197 cpu_to_le16((params
->txop
* 32));
1199 ctx
->qos_data
.def_qos_parm
.ac
[q
].reserved1
= 0;
1202 spin_unlock_irqrestore(&priv
->lock
, flags
);
1204 IWL_DEBUG_MAC80211(priv
, "leave\n");
1208 int iwl_mac_tx_last_beacon(struct ieee80211_hw
*hw
)
1210 struct iwl_priv
*priv
= hw
->priv
;
1212 return priv
->ibss_manager
== IWL_IBSS_MANAGER
;
1215 static int iwl_set_mode(struct iwl_priv
*priv
, struct iwl_rxon_context
*ctx
)
1217 iwl_connection_init_rx_config(priv
, ctx
);
1219 if (priv
->cfg
->ops
->hcmd
->set_rxon_chain
)
1220 priv
->cfg
->ops
->hcmd
->set_rxon_chain(priv
, ctx
);
1222 return iwlagn_commit_rxon(priv
, ctx
);
1225 static int iwl_setup_interface(struct iwl_priv
*priv
,
1226 struct iwl_rxon_context
*ctx
)
1228 struct ieee80211_vif
*vif
= ctx
->vif
;
1231 lockdep_assert_held(&priv
->mutex
);
1234 * This variable will be correct only when there's just
1235 * a single context, but all code using it is for hardware
1236 * that supports only one context.
1238 priv
->iw_mode
= vif
->type
;
1240 ctx
->is_active
= true;
1242 err
= iwl_set_mode(priv
, ctx
);
1244 if (!ctx
->always_active
)
1245 ctx
->is_active
= false;
1249 if (priv
->cfg
->bt_params
&& priv
->cfg
->bt_params
->advanced_bt_coexist
&&
1250 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1252 * pretend to have high BT traffic as long as we
1253 * are operating in IBSS mode, as this will cause
1254 * the rate scaling etc. to behave as intended.
1256 priv
->bt_traffic_load
= IWL_BT_COEX_TRAFFIC_LOAD_HIGH
;
1262 int iwl_mac_add_interface(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
1264 struct iwl_priv
*priv
= hw
->priv
;
1265 struct iwl_vif_priv
*vif_priv
= (void *)vif
->drv_priv
;
1266 struct iwl_rxon_context
*tmp
, *ctx
= NULL
;
1268 enum nl80211_iftype viftype
= ieee80211_vif_type_p2p(vif
);
1270 IWL_DEBUG_MAC80211(priv
, "enter: type %d, addr %pM\n",
1271 viftype
, vif
->addr
);
1273 mutex_lock(&priv
->mutex
);
1275 if (!iwl_is_ready_rf(priv
)) {
1276 IWL_WARN(priv
, "Try to add interface when device not ready\n");
1281 for_each_context(priv
, tmp
) {
1282 u32 possible_modes
=
1283 tmp
->interface_modes
| tmp
->exclusive_interface_modes
;
1286 /* check if this busy context is exclusive */
1287 if (tmp
->exclusive_interface_modes
&
1288 BIT(tmp
->vif
->type
)) {
1295 if (!(possible_modes
& BIT(viftype
)))
1298 /* have maybe usable context w/o interface */
1308 vif_priv
->ctx
= ctx
;
1311 err
= iwl_setup_interface(priv
, ctx
);
1316 priv
->iw_mode
= NL80211_IFTYPE_STATION
;
1318 mutex_unlock(&priv
->mutex
);
1320 IWL_DEBUG_MAC80211(priv
, "leave\n");
1324 static void iwl_teardown_interface(struct iwl_priv
*priv
,
1325 struct ieee80211_vif
*vif
,
1328 struct iwl_rxon_context
*ctx
= iwl_rxon_ctx_from_vif(vif
);
1330 lockdep_assert_held(&priv
->mutex
);
1332 if (priv
->scan_vif
== vif
) {
1333 iwl_scan_cancel_timeout(priv
, 200);
1334 iwl_force_scan_end(priv
);
1338 iwl_set_mode(priv
, ctx
);
1339 if (!ctx
->always_active
)
1340 ctx
->is_active
= false;
1344 * When removing the IBSS interface, overwrite the
1345 * BT traffic load with the stored one from the last
1346 * notification, if any. If this is a device that
1347 * doesn't implement this, this has no effect since
1348 * both values are the same and zero.
1350 if (vif
->type
== NL80211_IFTYPE_ADHOC
)
1351 priv
->bt_traffic_load
= priv
->last_bt_traffic_load
;
1354 void iwl_mac_remove_interface(struct ieee80211_hw
*hw
,
1355 struct ieee80211_vif
*vif
)
1357 struct iwl_priv
*priv
= hw
->priv
;
1358 struct iwl_rxon_context
*ctx
= iwl_rxon_ctx_from_vif(vif
);
1360 IWL_DEBUG_MAC80211(priv
, "enter\n");
1362 mutex_lock(&priv
->mutex
);
1364 WARN_ON(ctx
->vif
!= vif
);
1367 iwl_teardown_interface(priv
, vif
, false);
1369 mutex_unlock(&priv
->mutex
);
1371 IWL_DEBUG_MAC80211(priv
, "leave\n");
1375 int iwl_alloc_txq_mem(struct iwl_priv
*priv
)
1378 priv
->txq
= kzalloc(
1379 sizeof(struct iwl_tx_queue
) *
1380 priv
->cfg
->base_params
->num_of_queues
,
1383 IWL_ERR(priv
, "Not enough memory for txq\n");
1389 void iwl_free_txq_mem(struct iwl_priv
*priv
)
1395 #ifdef CONFIG_IWLWIFI_DEBUGFS
1397 #define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES)
1399 void iwl_reset_traffic_log(struct iwl_priv
*priv
)
1401 priv
->tx_traffic_idx
= 0;
1402 priv
->rx_traffic_idx
= 0;
1403 if (priv
->tx_traffic
)
1404 memset(priv
->tx_traffic
, 0, IWL_TRAFFIC_DUMP_SIZE
);
1405 if (priv
->rx_traffic
)
1406 memset(priv
->rx_traffic
, 0, IWL_TRAFFIC_DUMP_SIZE
);
1409 int iwl_alloc_traffic_mem(struct iwl_priv
*priv
)
1411 u32 traffic_size
= IWL_TRAFFIC_DUMP_SIZE
;
1413 if (iwl_debug_level
& IWL_DL_TX
) {
1414 if (!priv
->tx_traffic
) {
1416 kzalloc(traffic_size
, GFP_KERNEL
);
1417 if (!priv
->tx_traffic
)
1421 if (iwl_debug_level
& IWL_DL_RX
) {
1422 if (!priv
->rx_traffic
) {
1424 kzalloc(traffic_size
, GFP_KERNEL
);
1425 if (!priv
->rx_traffic
)
1429 iwl_reset_traffic_log(priv
);
1433 void iwl_free_traffic_mem(struct iwl_priv
*priv
)
1435 kfree(priv
->tx_traffic
);
1436 priv
->tx_traffic
= NULL
;
1438 kfree(priv
->rx_traffic
);
1439 priv
->rx_traffic
= NULL
;
1442 void iwl_dbg_log_tx_data_frame(struct iwl_priv
*priv
,
1443 u16 length
, struct ieee80211_hdr
*header
)
1448 if (likely(!(iwl_debug_level
& IWL_DL_TX
)))
1451 if (!priv
->tx_traffic
)
1454 fc
= header
->frame_control
;
1455 if (ieee80211_is_data(fc
)) {
1456 len
= (length
> IWL_TRAFFIC_ENTRY_SIZE
)
1457 ? IWL_TRAFFIC_ENTRY_SIZE
: length
;
1458 memcpy((priv
->tx_traffic
+
1459 (priv
->tx_traffic_idx
* IWL_TRAFFIC_ENTRY_SIZE
)),
1461 priv
->tx_traffic_idx
=
1462 (priv
->tx_traffic_idx
+ 1) % IWL_TRAFFIC_ENTRIES
;
1466 void iwl_dbg_log_rx_data_frame(struct iwl_priv
*priv
,
1467 u16 length
, struct ieee80211_hdr
*header
)
1472 if (likely(!(iwl_debug_level
& IWL_DL_RX
)))
1475 if (!priv
->rx_traffic
)
1478 fc
= header
->frame_control
;
1479 if (ieee80211_is_data(fc
)) {
1480 len
= (length
> IWL_TRAFFIC_ENTRY_SIZE
)
1481 ? IWL_TRAFFIC_ENTRY_SIZE
: length
;
1482 memcpy((priv
->rx_traffic
+
1483 (priv
->rx_traffic_idx
* IWL_TRAFFIC_ENTRY_SIZE
)),
1485 priv
->rx_traffic_idx
=
1486 (priv
->rx_traffic_idx
+ 1) % IWL_TRAFFIC_ENTRIES
;
1490 const char *get_mgmt_string(int cmd
)
1493 IWL_CMD(MANAGEMENT_ASSOC_REQ
);
1494 IWL_CMD(MANAGEMENT_ASSOC_RESP
);
1495 IWL_CMD(MANAGEMENT_REASSOC_REQ
);
1496 IWL_CMD(MANAGEMENT_REASSOC_RESP
);
1497 IWL_CMD(MANAGEMENT_PROBE_REQ
);
1498 IWL_CMD(MANAGEMENT_PROBE_RESP
);
1499 IWL_CMD(MANAGEMENT_BEACON
);
1500 IWL_CMD(MANAGEMENT_ATIM
);
1501 IWL_CMD(MANAGEMENT_DISASSOC
);
1502 IWL_CMD(MANAGEMENT_AUTH
);
1503 IWL_CMD(MANAGEMENT_DEAUTH
);
1504 IWL_CMD(MANAGEMENT_ACTION
);
1511 const char *get_ctrl_string(int cmd
)
1514 IWL_CMD(CONTROL_BACK_REQ
);
1515 IWL_CMD(CONTROL_BACK
);
1516 IWL_CMD(CONTROL_PSPOLL
);
1517 IWL_CMD(CONTROL_RTS
);
1518 IWL_CMD(CONTROL_CTS
);
1519 IWL_CMD(CONTROL_ACK
);
1520 IWL_CMD(CONTROL_CFEND
);
1521 IWL_CMD(CONTROL_CFENDACK
);
1528 void iwl_clear_traffic_stats(struct iwl_priv
*priv
)
1530 memset(&priv
->tx_stats
, 0, sizeof(struct traffic_stats
));
1531 memset(&priv
->rx_stats
, 0, sizeof(struct traffic_stats
));
1535 * if CONFIG_IWLWIFI_DEBUGFS defined, iwl_update_stats function will
1536 * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass.
1537 * Use debugFs to display the rx/rx_statistics
1538 * if CONFIG_IWLWIFI_DEBUGFS not being defined, then no MGMT and CTRL
1539 * information will be recorded, but DATA pkt still will be recorded
1540 * for the reason of iwl_led.c need to control the led blinking based on
1541 * number of tx and rx data.
1544 void iwl_update_stats(struct iwl_priv
*priv
, bool is_tx
, __le16 fc
, u16 len
)
1546 struct traffic_stats
*stats
;
1549 stats
= &priv
->tx_stats
;
1551 stats
= &priv
->rx_stats
;
1553 if (ieee80211_is_mgmt(fc
)) {
1554 switch (fc
& cpu_to_le16(IEEE80211_FCTL_STYPE
)) {
1555 case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ
):
1556 stats
->mgmt
[MANAGEMENT_ASSOC_REQ
]++;
1558 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP
):
1559 stats
->mgmt
[MANAGEMENT_ASSOC_RESP
]++;
1561 case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ
):
1562 stats
->mgmt
[MANAGEMENT_REASSOC_REQ
]++;
1564 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP
):
1565 stats
->mgmt
[MANAGEMENT_REASSOC_RESP
]++;
1567 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ
):
1568 stats
->mgmt
[MANAGEMENT_PROBE_REQ
]++;
1570 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP
):
1571 stats
->mgmt
[MANAGEMENT_PROBE_RESP
]++;
1573 case cpu_to_le16(IEEE80211_STYPE_BEACON
):
1574 stats
->mgmt
[MANAGEMENT_BEACON
]++;
1576 case cpu_to_le16(IEEE80211_STYPE_ATIM
):
1577 stats
->mgmt
[MANAGEMENT_ATIM
]++;
1579 case cpu_to_le16(IEEE80211_STYPE_DISASSOC
):
1580 stats
->mgmt
[MANAGEMENT_DISASSOC
]++;
1582 case cpu_to_le16(IEEE80211_STYPE_AUTH
):
1583 stats
->mgmt
[MANAGEMENT_AUTH
]++;
1585 case cpu_to_le16(IEEE80211_STYPE_DEAUTH
):
1586 stats
->mgmt
[MANAGEMENT_DEAUTH
]++;
1588 case cpu_to_le16(IEEE80211_STYPE_ACTION
):
1589 stats
->mgmt
[MANAGEMENT_ACTION
]++;
1592 } else if (ieee80211_is_ctl(fc
)) {
1593 switch (fc
& cpu_to_le16(IEEE80211_FCTL_STYPE
)) {
1594 case cpu_to_le16(IEEE80211_STYPE_BACK_REQ
):
1595 stats
->ctrl
[CONTROL_BACK_REQ
]++;
1597 case cpu_to_le16(IEEE80211_STYPE_BACK
):
1598 stats
->ctrl
[CONTROL_BACK
]++;
1600 case cpu_to_le16(IEEE80211_STYPE_PSPOLL
):
1601 stats
->ctrl
[CONTROL_PSPOLL
]++;
1603 case cpu_to_le16(IEEE80211_STYPE_RTS
):
1604 stats
->ctrl
[CONTROL_RTS
]++;
1606 case cpu_to_le16(IEEE80211_STYPE_CTS
):
1607 stats
->ctrl
[CONTROL_CTS
]++;
1609 case cpu_to_le16(IEEE80211_STYPE_ACK
):
1610 stats
->ctrl
[CONTROL_ACK
]++;
1612 case cpu_to_le16(IEEE80211_STYPE_CFEND
):
1613 stats
->ctrl
[CONTROL_CFEND
]++;
1615 case cpu_to_le16(IEEE80211_STYPE_CFENDACK
):
1616 stats
->ctrl
[CONTROL_CFENDACK
]++;
1622 stats
->data_bytes
+= len
;
1627 static void iwl_force_rf_reset(struct iwl_priv
*priv
)
1629 if (test_bit(STATUS_EXIT_PENDING
, &priv
->status
))
1632 if (!iwl_is_any_associated(priv
)) {
1633 IWL_DEBUG_SCAN(priv
, "force reset rejected: not associated\n");
1637 * There is no easy and better way to force reset the radio,
1638 * the only known method is switching channel which will force to
1639 * reset and tune the radio.
1640 * Use internal short scan (single channel) operation to should
1641 * achieve this objective.
1642 * Driver should reset the radio when number of consecutive missed
1643 * beacon, or any other uCode error condition detected.
1645 IWL_DEBUG_INFO(priv
, "perform radio reset.\n");
1646 iwl_internal_short_hw_scan(priv
);
1650 int iwl_force_reset(struct iwl_priv
*priv
, int mode
, bool external
)
1652 struct iwl_force_reset
*force_reset
;
1654 if (test_bit(STATUS_EXIT_PENDING
, &priv
->status
))
1657 if (mode
>= IWL_MAX_FORCE_RESET
) {
1658 IWL_DEBUG_INFO(priv
, "invalid reset request.\n");
1661 force_reset
= &priv
->force_reset
[mode
];
1662 force_reset
->reset_request_count
++;
1664 if (force_reset
->last_force_reset_jiffies
&&
1665 time_after(force_reset
->last_force_reset_jiffies
+
1666 force_reset
->reset_duration
, jiffies
)) {
1667 IWL_DEBUG_INFO(priv
, "force reset rejected\n");
1668 force_reset
->reset_reject_count
++;
1672 force_reset
->reset_success_count
++;
1673 force_reset
->last_force_reset_jiffies
= jiffies
;
1674 IWL_DEBUG_INFO(priv
, "perform force reset (%d)\n", mode
);
1677 iwl_force_rf_reset(priv
);
1681 * if the request is from external(ex: debugfs),
1682 * then always perform the request in regardless the module
1684 * if the request is from internal (uCode error or driver
1685 * detect failure), then fw_restart module parameter
1686 * need to be check before performing firmware reload
1688 if (!external
&& !iwlagn_mod_params
.restart_fw
) {
1689 IWL_DEBUG_INFO(priv
, "Cancel firmware reload based on "
1690 "module parameter setting\n");
1693 IWL_ERR(priv
, "On demand firmware reload\n");
1694 iwlagn_fw_error(priv
, true);
1700 int iwl_mac_change_interface(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
1701 enum nl80211_iftype newtype
, bool newp2p
)
1703 struct iwl_priv
*priv
= hw
->priv
;
1704 struct iwl_rxon_context
*ctx
= iwl_rxon_ctx_from_vif(vif
);
1705 struct iwl_rxon_context
*bss_ctx
= &priv
->contexts
[IWL_RXON_CTX_BSS
];
1706 struct iwl_rxon_context
*tmp
;
1707 enum nl80211_iftype newviftype
= newtype
;
1708 u32 interface_modes
;
1711 newtype
= ieee80211_iftype_p2p(newtype
, newp2p
);
1713 mutex_lock(&priv
->mutex
);
1715 if (!ctx
->vif
|| !iwl_is_ready_rf(priv
)) {
1717 * Huh? But wait ... this can maybe happen when
1718 * we're in the middle of a firmware restart!
1724 interface_modes
= ctx
->interface_modes
| ctx
->exclusive_interface_modes
;
1726 if (!(interface_modes
& BIT(newtype
))) {
1732 * Refuse a change that should be done by moving from the PAN
1733 * context to the BSS context instead, if the BSS context is
1734 * available and can support the new interface type.
1736 if (ctx
->ctxid
== IWL_RXON_CTX_PAN
&& !bss_ctx
->vif
&&
1737 (bss_ctx
->interface_modes
& BIT(newtype
) ||
1738 bss_ctx
->exclusive_interface_modes
& BIT(newtype
))) {
1739 BUILD_BUG_ON(NUM_IWL_RXON_CTX
!= 2);
1744 if (ctx
->exclusive_interface_modes
& BIT(newtype
)) {
1745 for_each_context(priv
, tmp
) {
1753 * The current mode switch would be exclusive, but
1754 * another context is active ... refuse the switch.
1762 iwl_teardown_interface(priv
, vif
, true);
1763 vif
->type
= newviftype
;
1765 err
= iwl_setup_interface(priv
, ctx
);
1768 * We've switched internally, but submitting to the
1769 * device may have failed for some reason. Mask this
1770 * error, because otherwise mac80211 will not switch
1771 * (and set the interface type back) and we'll be
1772 * out of sync with it.
1777 mutex_unlock(&priv
->mutex
);
1782 * On every watchdog tick we check (latest) time stamp. If it does not
1783 * change during timeout period and queue is not empty we reset firmware.
1785 static int iwl_check_stuck_queue(struct iwl_priv
*priv
, int cnt
)
1787 struct iwl_tx_queue
*txq
= &priv
->txq
[cnt
];
1788 struct iwl_queue
*q
= &txq
->q
;
1789 unsigned long timeout
;
1792 if (q
->read_ptr
== q
->write_ptr
) {
1793 txq
->time_stamp
= jiffies
;
1797 timeout
= txq
->time_stamp
+
1798 msecs_to_jiffies(priv
->cfg
->base_params
->wd_timeout
);
1800 if (time_after(jiffies
, timeout
)) {
1801 IWL_ERR(priv
, "Queue %d stuck for %u ms.\n",
1802 q
->id
, priv
->cfg
->base_params
->wd_timeout
);
1803 ret
= iwl_force_reset(priv
, IWL_FW_RESET
, false);
1804 return (ret
== -EAGAIN
) ? 0 : 1;
1811 * Making watchdog tick be a quarter of timeout assure we will
1812 * discover the queue hung between timeout and 1.25*timeout
1814 #define IWL_WD_TICK(timeout) ((timeout) / 4)
1817 * Watchdog timer callback, we check each tx queue for stuck, if if hung
1818 * we reset the firmware. If everything is fine just rearm the timer.
1820 void iwl_bg_watchdog(unsigned long data
)
1822 struct iwl_priv
*priv
= (struct iwl_priv
*)data
;
1824 unsigned long timeout
;
1826 if (test_bit(STATUS_EXIT_PENDING
, &priv
->status
))
1829 timeout
= priv
->cfg
->base_params
->wd_timeout
;
1833 /* monitor and check for stuck cmd queue */
1834 if (iwl_check_stuck_queue(priv
, priv
->cmd_queue
))
1837 /* monitor and check for other stuck queues */
1838 if (iwl_is_any_associated(priv
)) {
1839 for (cnt
= 0; cnt
< priv
->hw_params
.max_txq_num
; cnt
++) {
1840 /* skip as we already checked the command queue */
1841 if (cnt
== priv
->cmd_queue
)
1843 if (iwl_check_stuck_queue(priv
, cnt
))
1848 mod_timer(&priv
->watchdog
, jiffies
+
1849 msecs_to_jiffies(IWL_WD_TICK(timeout
)));
1852 void iwl_setup_watchdog(struct iwl_priv
*priv
)
1854 unsigned int timeout
= priv
->cfg
->base_params
->wd_timeout
;
1856 if (timeout
&& !iwlagn_mod_params
.wd_disable
)
1857 mod_timer(&priv
->watchdog
,
1858 jiffies
+ msecs_to_jiffies(IWL_WD_TICK(timeout
)));
1860 del_timer(&priv
->watchdog
);
1864 * extended beacon time format
1865 * time in usec will be changed into a 32-bit value in extended:internal format
1866 * the extended part is the beacon counts
1867 * the internal part is the time in usec within one beacon interval
1869 u32
iwl_usecs_to_beacons(struct iwl_priv
*priv
, u32 usec
, u32 beacon_interval
)
1873 u32 interval
= beacon_interval
* TIME_UNIT
;
1875 if (!interval
|| !usec
)
1878 quot
= (usec
/ interval
) &
1879 (iwl_beacon_time_mask_high(priv
,
1880 priv
->hw_params
.beacon_time_tsf_bits
) >>
1881 priv
->hw_params
.beacon_time_tsf_bits
);
1882 rem
= (usec
% interval
) & iwl_beacon_time_mask_low(priv
,
1883 priv
->hw_params
.beacon_time_tsf_bits
);
1885 return (quot
<< priv
->hw_params
.beacon_time_tsf_bits
) + rem
;
1888 /* base is usually what we get from ucode with each received frame,
1889 * the same as HW timer counter counting down
1891 __le32
iwl_add_beacon_time(struct iwl_priv
*priv
, u32 base
,
1892 u32 addon
, u32 beacon_interval
)
1894 u32 base_low
= base
& iwl_beacon_time_mask_low(priv
,
1895 priv
->hw_params
.beacon_time_tsf_bits
);
1896 u32 addon_low
= addon
& iwl_beacon_time_mask_low(priv
,
1897 priv
->hw_params
.beacon_time_tsf_bits
);
1898 u32 interval
= beacon_interval
* TIME_UNIT
;
1899 u32 res
= (base
& iwl_beacon_time_mask_high(priv
,
1900 priv
->hw_params
.beacon_time_tsf_bits
)) +
1901 (addon
& iwl_beacon_time_mask_high(priv
,
1902 priv
->hw_params
.beacon_time_tsf_bits
));
1904 if (base_low
> addon_low
)
1905 res
+= base_low
- addon_low
;
1906 else if (base_low
< addon_low
) {
1907 res
+= interval
+ base_low
- addon_low
;
1908 res
+= (1 << priv
->hw_params
.beacon_time_tsf_bits
);
1910 res
+= (1 << priv
->hw_params
.beacon_time_tsf_bits
);
1912 return cpu_to_le32(res
);
1917 int iwl_suspend(struct iwl_priv
*priv
)
1920 * This function is called when system goes into suspend state
1921 * mac80211 will call iwl_mac_stop() from the mac80211 suspend function
1922 * first but since iwl_mac_stop() has no knowledge of who the caller is,
1923 * it will not call apm_ops.stop() to stop the DMA operation.
1924 * Calling apm_ops.stop here to make sure we stop the DMA.
1931 int iwl_resume(struct iwl_priv
*priv
)
1933 bool hw_rfkill
= false;
1935 iwl_enable_interrupts(priv
);
1937 if (!(iwl_read32(priv
, CSR_GP_CNTRL
) &
1938 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW
))
1942 set_bit(STATUS_RF_KILL_HW
, &priv
->status
);
1944 clear_bit(STATUS_RF_KILL_HW
, &priv
->status
);
1946 wiphy_rfkill_set_hw_state(priv
->hw
->wiphy
, hw_rfkill
);
1951 #endif /* CONFIG_PM */